/* ── BrightGroup design system ───────────────────────────────────────────
   Navy #0d2b3e, gold #a67a3e, navy ramp #193f55/#24536c/#306884, Inter.
   Light weights at large sizes; wide letter-spaced uppercase micro-labels.
   Specified in DESIGN.md — read it before changing anything here. */
:root {
  --navy:        #0d2b3e;
  --navy-2:      #193f55;
  --navy-3:      #24536c;
  --navy-4:      #306884;
  --gold:        #a67a3e;
  --gold-ink:    #ffffff;

  --ground:      #ffffff;
  --ground-sub:  #f7f7f7;
  --surface:     #ffffff;
  --line:        #e3e7ea;
  --line-strong: #cfd6dc;

  --ink:         #0d2b3e;
  --ink-mid:     #4d6577;
  --ink-dim:     #777777;
  --on-navy:     #ffffff;
  --on-navy-dim: #b7c6d1;

  --quiet-bg:    #ffffff;
  --quiet-edge:  #0d2b3e;
  --quiet-ink:   #0d2b3e;
  --quiet-hover-bg:  #306884;
  --quiet-hover-ink: #ffffff;
  --mine-edge:   #a67a3e;      /* gold outline on your own row */

  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 1px 2px rgba(13,43,62,.05), 0 6px 20px rgba(13,43,62,.07);
  color-scheme: light;
}

/* Theme variation is token-level ONLY. A flat
   `:root:not([data-theme="light"]) .component` rule matches the default
   un-stamped document and leaks dark values into light mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gold:        #c99b5b;
    --gold-ink:    #16100a;

    --ground:      #0a222f;
    --ground-sub:  #0d2b3e;
    --surface:     #133449;
    --line:        #27506a;
    --line-strong: #34647f;

    --ink:         #f2f6f8;
    --ink-mid:     #b7c6d1;
    --ink-dim:     #90a5b3;

    --quiet-edge:  #ffffff;
    --mine-edge:   #c99b5b;
    --shadow:      0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --gold:        #c99b5b;
  --gold-ink:    #16100a;

  --ground:      #0a222f;
  --ground-sub:  #0d2b3e;
  --surface:     #133449;
  --line:        #27506a;
  --line-strong: #34647f;

  --ink:         #f2f6f8;
  --ink-mid:     #b7c6d1;
  --ink-dim:     #90a5b3;

  --quiet-edge:  #ffffff;
  --mine-edge:   #c99b5b;
  --shadow:      0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* The reference site's signature micro-label. */
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 1.9px;
  text-transform: uppercase; line-height: 1.4;
}

.wrap {
  width: 100%; margin: 0;
  padding-inline: clamp(16px, 2.5vw, 48px);
  padding-block: 0 calc(48px + env(safe-area-inset-bottom));
}
.form-panel { max-width: 560px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions[hidden] { display: none; }
/* Compact action rows (e.g. MCP credential buttons) shouldn't stretch
   evenly to fill the row - they should size to their own content. */
.actions-compact { display: flex; gap: 8px; flex-wrap: wrap; }
.actions-compact[hidden] { display: none; }
.actions-compact .btn { flex: 0 0 auto; }
.sign-in-action { justify-content: center; }
select.member-select { width: 120px; max-width: 100%; }
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 14.5px; font-weight: 500;
  padding: 11px 22px; border-radius: 999px; border: 1.5px solid transparent;
  min-height: 44px; flex: 1 1 0;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--gold); color: var(--gold-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn-quiet { background: var(--quiet-bg); border-color: var(--quiet-edge); color: var(--quiet-ink); font-weight: 600; }
.btn-quiet:hover {
  background: var(--quiet-hover-bg); border-color: var(--quiet-hover-bg); color: var(--quiet-hover-ink);
}
.btn:disabled { background: var(--ground-sub); border-color: var(--line); color: var(--ink-dim); cursor: default; filter: none; }
.note { font-size: 13px; color: var(--ink-dim); }

/* ── Cards & data tables ──────────────────────────────────────────────
   The brand uses navy and gold only - no red/green - so table status
   reads through shape (hollow/filled/dashed) and the word itself, the
   same "dashed → hollow → filled" idea as the reference site's occupancy
   states, not a traffic-light palette. Gold stays reserved for actions,
   so it never appears in a status pill. */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* The card itself doesn't clip - a table with more columns than fit the
   viewport needs to scroll, not lose its rightmost columns. This inner
   wrapper clips to the card's rounded corners while still allowing that
   horizontal scroll. */
.table-scroll { overflow-x: auto; border-radius: var(--radius); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 1.3px;
  text-transform: uppercase; color: var(--ink-dim);
  padding: 14px 16px 10px;
}
.data-table td {
  padding: 12px 16px; border-top: 1px solid var(--line);
  font-size: 14px; color: var(--ink); vertical-align: middle;
}
.data-table td.meta { color: var(--ink-mid); font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: var(--ground-sub); }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.1px;
  padding: 4px 10px; border-radius: 999px; line-height: 1.4; white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; box-sizing: border-box; }
/* Waiting - nothing has happened yet. */
.status-pill.is-pending { border: 1px dashed var(--line-strong); color: var(--ink-dim); }
.status-pill.is-pending::before { border: 1.5px dashed var(--ink-dim); }
/* Done - the most committed state, so it's the filled one. */
/* `--navy`, unlike `--ink`, never flips with theme - this fill needs to
   stay solid navy in both, not become near-white in dark mode (which is
   what `--ink` resolves to there), or the white text sitting on it goes
   white-on-white. Matches the reference app's own filled badges, which
   use the same constant `--navy` for exactly this reason. */
.status-pill.is-good { background: var(--navy); color: var(--on-navy); }
.status-pill.is-good::before { background: var(--on-navy); }
/* Needs a look - an outline carries weight without borrowing a warning hue. */
.status-pill.is-flag { border: 1.5px solid var(--ink); color: var(--ink); }
.status-pill.is-flag::before { background: var(--ink); }
/* Void/inactive - deliberately the quietest of the four. */
.status-pill.is-muted { background: var(--ground-sub); color: var(--ink-dim); }
.status-pill.is-muted::before { background: var(--line-strong); }

label {
  font-size: 13px; font-weight: 600; color: var(--ink-mid);
  display: inline-block; margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  min-height: 44px;
}
select { cursor: pointer; }
input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.signin-brand { text-align: center; padding: 20px 0 12px; color: var(--gold); }
.signin-brand h1 { margin: 20px 0 8px; color: var(--ink); font-size: 28px; font-weight: 500; }
.signin-brand h1 span { color: var(--gold); }
.wrap:has(#signin-section:not([hidden])) > .eyebrow { display: none; }

/* ── Shared navigation (nav.js) ─────────────────────────────────────── */
.nav-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}
.nav-brand { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; color: var(--gold); text-decoration: none; }
.nav-brand svg { flex: 0 0 auto; }
.nav-project-name { color: var(--ink); font-size: 19px; font-weight: 500; white-space: nowrap; }
.nav-project-name span { color: var(--gold); }
.nav-toggle {
  appearance: none; cursor: pointer;
  background: var(--quiet-bg); border: 1.5px solid var(--quiet-edge); color: var(--quiet-ink);
  border-radius: 999px; width: 40px; height: 40px; padding: 0;
  display: grid; place-items: center;
}
.nav-toggle[hidden] { display: none; }
.nav-toggle svg { display: block; }
.nav-toggle:hover { background: var(--quiet-hover-bg); border-color: var(--quiet-hover-bg); color: var(--quiet-hover-ink); }
/* A floating menu card, not a stack of big pill buttons: flat, left-aligned
   rows that only pick up a background on hover, tightly packed - the same
   "settings dropdown" pattern as the reference app's own menu. */
.nav-menu {
  position: absolute; top: 56px; right: 18px;
  min-width: 250px; max-width: min(88vw, 320px); padding: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 14px 38px rgba(13, 43, 62, .22);
  display: flex; flex-direction: column; gap: 2px;
}
.nav-menu[hidden] { display: none; }
.nav-who {
  margin: 0; padding: 10px 12px 8px;
  font-size: 12.5px; color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
}
.nav-item {
  appearance: none; cursor: pointer; text-align: left; text-decoration: none; display: block;
  width: 100%; font: inherit; font-size: 14.5px; font-weight: 500; color: var(--ink);
  background: none; border: 0; border-radius: var(--radius-sm);
  padding: 11px 12px; min-height: 44px;
}
.nav-item[hidden] { display: none; }
.nav-item:hover { background: var(--ground-sub); }
.nav-item:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.nav-item.is-quiet { color: var(--ink-mid); }
.nav-theme-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.nav-theme-btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600;
  background: none; border: 1px solid var(--line-strong); color: var(--ink-mid);
  border-radius: 999px; padding: 6px 12px; min-height: 30px;
}
.nav-theme-btn.is-active { background: var(--quiet-hover-bg); border-color: var(--quiet-hover-bg); color: var(--quiet-hover-ink); }

/* ── Wheel ──────────────────────────────────────────────────────────── */
.wheel-row {
  display: grid; gap: clamp(20px, 3vw, 48px);
  grid-template-columns: minmax(0, 1fr) minmax(240px, .4fr);
  align-items: center;
  margin: 40px 0 24px;
}
.wheel-stage {
  display: grid; grid-template-columns: minmax(0, 720px) 100px;
  align-items: center; justify-content: center; gap: clamp(16px, 2vw, 32px);
  min-width: 0;
}
.wheel-stage:not(:has(.lever-panel:not([hidden]))) { grid-template-columns: minmax(0, 720px); }
.wheel-wrap {
  position: relative;
  width: 100%; max-width: 720px;
  aspect-ratio: 1 / 1;
}
.wheel-wrap canvas { display: block; width: 100%; height: 100%; }
/* A real lever, not a free-floating arrow: the mount is pinned well above
   the rim, and a single tapered needle hangs from it down to the rim
   where pegs actually pass - wider near the pivot, narrowing to a point
   at the tip, no bulb. A peg pushes the tip, not the pivot, so the
   leverage is real: that's what lets a modest rotation swing the tip
   through a readable arc while the needle stays legible as a rigid rod
   pinned at a fixed, distant point. */
.wheel-pointer {
  position: absolute; top: -26px; left: 50%;
  width: 0; height: 0;
  transform: translateX(-50%) rotate(0deg);
  transform-origin: 50% 0%;
}
.wheel-pointer .pointer-mount {
  position: absolute; top: -5px; left: -5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--navy);
  border: 1.5px solid var(--gold);
  box-sizing: border-box;
}
.wheel-pointer .pointer-arm {
  position: absolute; top: 0; left: -5px;
  width: 10px; height: 40px;
  background: var(--gold);
  clip-path: polygon(20% 0%, 80% 0%, 50% 100%);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}
.side-panel { min-width: 0; width: 100%; align-self: start; }
.side-panel h2 { font-size: 15px; font-weight: 500; margin: 0 0 8px; }
.recent-draw-box {
  padding: 10px 12px; margin: 0 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
}
@keyframes recent-draw-pop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.recent-draw-pop { animation: recent-draw-pop 320ms ease-out; }

.details-panel {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 4px 12px;
}
.details-panel summary {
  cursor: pointer; font-weight: 600; font-size: 14px;
  padding: 8px 0;
}
.details-panel ul { list-style: none; padding: 0; margin: 0 0 8px; }
.details-panel li { padding: 4px 0; font-size: 13.5px; }
/* The same pill button as any other primary action, just rotated 90°:
   tall and narrow instead of wide and short, with the power fill
   growing from the bottom up instead of left to right. */
.lever-panel { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lever-panel[hidden] { display: none; }
.lever-button {
  position: relative; overflow: hidden; isolation: isolate;
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: 14px;
  background: var(--gold); color: var(--gold-ink); border: none;
  border-radius: 999px; width: 64px; height: 240px;
  user-select: none; touch-action: none;
}
.lever-button:active { filter: brightness(1.1); }
.lever-button:disabled { background: var(--ground-sub); color: var(--ink-dim); cursor: default; }
.lever-button.is-charging { background: var(--ground-sub); color: var(--ink); }
.lever-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: var(--gold);
  z-index: 0;
}
.lever-button-label {
  position: relative; z-index: 1;
  display: block; line-height: 1.3;
}
/* Keep the label on a stable surface while the charge fill passes behind
   it, so its contrast doesn't change between filled and unfilled areas. */
.lever-button.is-charging .lever-button-label {
  width: fit-content; margin-inline: auto; padding: 4px;
  border-radius: var(--radius-sm); background: var(--ground-sub);
}

.password-dialog {
  width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px);
  overflow: auto; padding: 24px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.password-dialog::backdrop { background: rgba(13, 43, 62, .65); }
.password-dialog h2 { margin: 0; font-size: 21px; font-weight: 500; }
.password-dialog input { font-family: ui-monospace, monospace; }
.password-dialog .actions { margin-bottom: 0; }

@media (max-width: 1000px) {
  .wheel-row { grid-template-columns: minmax(0, 1fr); }
  .side-panel { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  /* Keep the column labels with each value so tables can become cards. */
  .mobile-cards, .mobile-cards tbody, .mobile-cards tr { display: block; }
  .mobile-cards thead {
    position: absolute; width: 1px; height: 1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .mobile-cards tr + tr { border-top: 2px solid var(--line-strong); }
  .mobile-cards td {
    display: grid; grid-template-columns: 90px minmax(0, 1fr);
    align-items: center; gap: 12px; padding: 10px 14px;
    overflow-wrap: anywhere;
  }
  .mobile-cards td:first-child { border-top: 0; font-weight: 600; }
  .mobile-cards td::before {
    content: attr(data-label); font-size: 11px; font-weight: 600;
    letter-spacing: .6px; text-transform: uppercase; color: var(--ink-dim);
  }
  .mobile-cards td > * { min-width: 0; justify-self: start; max-width: 100%; }
  .mobile-cards td .status-pill { width: fit-content; }
  input[type="text"], input[type="password"], input[type="number"], select { font-size: 16px; }
}

@media (max-width: 600px) {
  .wheel-row { gap: 20px; }
  .wheel-stage { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .lever-panel { width: 100%; }
  .lever-button { width: 100%; height: 64px; }
  .lever-button-label br { display: none; }
  .lever-button-label { word-spacing: 3px; }
  .lever-panel p { margin: 0; }
  .actions > .btn { flex-basis: 140px; }
  .password-dialog .btn { padding-inline: 14px; }
  .nav-toggle { width: 44px; height: 44px; }
}
