:root {
  --paper: #f5f6fa;
  --surface: #ffffff;
  --ink: #1b2140;
  --ink-soft: #5b6280;
  --line: #dcdfea;
  --ultra: #3346d3;
  --ultra-ink: #ffffff;
  --amber: #e9a92b;
  --moss: #3c8b67;
  --rose: #c24d68;
  --mist: #a3a9be;
  --focus: #3346d3;

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5625rem;
  --fs-2xl: 2.4414rem;
  --fs-3xl: 3.8147rem;

  color-scheme: light;
}

/* Dark tokens: follow the OS unless the viewer forced light, or forced dark explicitly. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141830;
    --surface: #1c2140;
    --ink: #e8eaf4;
    --ink-soft: #a0a6c0;
    --line: #2e3458;
    --ultra: #8190ff;
    --ultra-ink: #141830;
    --amber: #f2bc4e;
    --moss: #5db38a;
    --rose: #e27891;
    --mist: #5f6687;
    --focus: #8190ff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #141830;
  --surface: #1c2140;
  --ink: #e8eaf4;
  --ink-soft: #a0a6c0;
  --line: #2e3458;
  --ultra: #8190ff;
  --ultra-ink: #141830;
  --amber: #f2bc4e;
  --moss: #5db38a;
  --rose: #e27891;
  --mist: #5f6687;
  --focus: #8190ff;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Schibsted Grotesk", system-ui, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Seal: left half = member paid, right half = admin confirmed ---------- */

.seal { display: block; overflow: visible; }
.seal-left, .seal-right { fill: transparent; transition: fill 240ms ease; }
.seal-left.is-filled { fill: var(--amber); }
.seal-right.is-filled { fill: var(--ultra); }
.seal-ring { fill: none; stroke: var(--mist); stroke-width: 2.5; }
.seal-ring.is-dotted { stroke-dasharray: 2 4.2; stroke-linecap: round; }
.seal-ring.is-stay { stroke: var(--ink); }
.seal-ring.is-leave { stroke: var(--rose); opacity: 0.7; }
.seal-ring.is-free { stroke: var(--moss); }
.seal-full { fill: var(--moss); }
.seal-strike { stroke: var(--rose); stroke-width: 2.5; stroke-linecap: round; opacity: 0.7; }
.seal-initials {
  font-size: 12px;
  font-weight: 700;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.02em;
}
.seal-initials.on-fill { fill: var(--paper); }
.seal-initials.has-halo { paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.seal-sm { width: 18px; height: 18px; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 12px;
}

.seal-login { width: 56px; height: 56px; margin-bottom: 8px; }
.seal-login .seal-left { fill: var(--amber); }
.seal-login .seal-right { fill: var(--ultra); }
.seal-login .seal-ring { stroke: var(--ink); }

.login-team { margin: 0; color: var(--ink-soft); font-weight: 500; }
.login-title {
  margin: 0 0 16px;
  font-size: var(--fs-2xl);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.field-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0;
}

input[type="text"], input[type="password"], select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

input[type="text"]:focus, input[type="password"]:focus, select:focus {
  border-color: var(--ultra);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ultra) 25%, transparent);
}

.form-error { margin: 0; min-height: 1.5em; color: var(--rose); font-size: var(--fs-sm); font-weight: 500; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--ink);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 120ms ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: var(--ultra); border-color: var(--ultra); color: var(--ultra-ink); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #1b2140; }
.btn-ultra { background: var(--ultra); border-color: var(--ultra); color: var(--ultra-ink); }
.btn-quiet { border-color: var(--line); color: var(--ink-soft); }
.btn-quiet:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn-danger { border-color: var(--rose); color: var(--rose); }

.btn-link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--ink); }

/* ---------- Preferences: language and theme ---------- */

.prefs { display: inline-flex; align-items: center; gap: 8px; }

.switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
}
.switch button {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
}
.switch button:hover { color: var(--ink); }
.switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.switch svg { width: 15px; height: 15px; display: block; }
.switch .icon-stroke { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.switch .icon-fill { fill: currentColor; }

.prefs-float { position: fixed; top: 14px; right: 16px; z-index: 5; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 14px max(16px, calc((100vw - 1080px) / 2));
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
}
.topbar-team { font-weight: 700; margin-right: auto; }
.topbar-deadline { color: var(--ink-soft); }
.topbar-deadline strong { color: var(--ink); }
.topbar-role {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--ultra);
  color: var(--ultra-ink);
  font-weight: 600;
  font-size: var(--fs-xs);
}

/* ---------- Page ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 96px;
}

.section-title {
  margin: 0 0 8px;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
  font-weight: 700;
}
.section-lede { margin: 0 0 24px; color: var(--ink-soft); max-width: 60ch; }

/* ---------- Hero: the seat map ---------- */

.hero { padding: 56px 0 40px; }

.hero-title {
  margin: 0;
  font-size: clamp(2.25rem, 7vw, var(--fs-3xl));
  line-height: 0.98;
  letter-spacing: -0.045em;
  font-weight: 800;
  max-width: 14ch;
}

.hero-lede { margin: 20px 0 40px; font-size: var(--fs-lg); color: var(--ink-soft); max-width: 52ch; }
.hero-lede strong { color: var(--ink); font-weight: 600; }

.seats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 40px;
  align-items: flex-start;
}

.seat-group { display: grid; gap: 10px; }
.seat-group-label { font-size: var(--fs-xs); color: var(--ink-soft); font-weight: 500; }
.seat-row { display: flex; flex-wrap: wrap; gap: 16px 14px; }

/* Full names always: the seat grows to fit, it never truncates. */
.seat {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 8px;
  min-width: 72px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
.seat .seal { width: 52px; height: 52px; transition: transform 160ms ease; }
.seat:hover .seal { transform: scale(1.06); }
.seat-name {
  display: grid;
  font-size: var(--fs-xs);
  line-height: 1.25;
  text-align: center;
  color: var(--ink-soft);
}
.seat-name span:first-child { color: var(--ink); font-weight: 600; }

/* Narrow screens: a two-column list with the name beside the seal. */
@media (max-width: 640px) {
  .seats { display: grid; gap: 24px; }
  .seat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
  .seat {
    grid-template-columns: 40px minmax(0, 1fr);
    justify-items: start;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .seat .seal { width: 40px; height: 40px; }
  .seat-name { text-align: left; }
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 36px 0 0;
  padding: 0;
  font-size: var(--fs-xs);
  color: var(--ink-soft);
}
.legend li { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Ledger ---------- */

.ledger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  margin: 8px 0 64px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ledger-block { padding: 24px 28px; }
.ledger-block + .ledger-block { border-left: 1.5px solid var(--ink); }
.ledger-title { margin: 0 0 16px; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; }

.ledger-lines { margin: 0; display: grid; gap: 8px; }
.ledger-line { display: flex; justify-content: space-between; gap: 16px; font-size: var(--fs-sm); }
.ledger-line dt { color: var(--ink-soft); }
.ledger-line dd { margin: 0; font-weight: 500; white-space: nowrap; }
.ledger-line.is-total { padding-top: 10px; border-top: 1px solid var(--line); font-size: var(--fs-md); }
.ledger-line.is-total dt { color: var(--ink); font-weight: 600; }
.ledger-line.is-total dd { font-weight: 700; }
.ledger-line.is-credit dd { color: var(--moss); }

.collect-figure {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.collect-caption { margin: 6px 0 18px; color: var(--ink-soft); font-size: var(--fs-sm); }

.bar {
  display: flex;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
}
.bar-confirmed { background: var(--ultra); transition: width 400ms ease; }
.bar-marked { background: var(--amber); transition: width 400ms ease; }

.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--ink-soft);
}
.bar-legend b { color: var(--ink); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot-ultra { background: var(--ultra); }
.dot-amber { background: var(--amber); }
.dot-line { background: var(--line); outline: 1px solid var(--mist); }

.ledger-note { margin: 16px 0 0; font-size: var(--fs-xs); color: var(--ink-soft); max-width: 48ch; }

/* ---------- Roster ---------- */

.roster-title { margin-bottom: 20px; }

.group { margin-bottom: 40px; }
.group-title { margin: 0 0 4px; font-size: var(--fs-md); font-weight: 700; }
.group-lede { margin: 0 0 12px; font-size: var(--fs-sm); color: var(--ink-soft); }

.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row { border-bottom: 1px solid var(--line); }

.row-head {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.4fr) minmax(110px, auto) 20px;
  align-items: center;
  gap: 16px;
  padding: 14px 12px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.row-head:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.row-head .seal { width: 36px; height: 36px; }

.row-name { font-weight: 600; }
.row-name small { display: block; font-weight: 400; font-size: var(--fs-xs); color: var(--ink-soft); }
.row-plan { font-size: var(--fs-sm); }
.row-plan.is-premium { font-weight: 700; }
.row-status { font-size: var(--fs-sm); color: var(--ink-soft); }
.row-amount { text-align: right; font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.01em; white-space: nowrap; }
.row-amount small { display: block; font-size: var(--fs-xs); font-weight: 500; color: var(--ink-soft); letter-spacing: 0; }
.row-amount.is-zero { color: var(--moss); }
.row-amount.is-muted { color: var(--mist); font-weight: 500; }

.chevron { width: 12px; height: 12px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: rotate(45deg) translate(-3px, -3px); transition: transform 200ms ease; }
.row-head[aria-expanded="true"] .chevron { transform: rotate(225deg) translate(-3px, -3px); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid currentColor;
}
.tag-stay { color: var(--moss); }
.tag-leave { color: var(--rose); }
.tag-undecided { color: var(--ink-soft); border-style: dashed; }
.tag-provisional { color: var(--ink-soft); border-color: transparent; padding: 0; font-weight: 500; }

/* ---------- Editor ---------- */

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px 40px;
  padding: 8px 12px 28px 68px;
  animation: open 220ms ease;
}

@keyframes open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.editor-col { display: grid; gap: 24px; align-content: start; min-width: 0; }
.editor-block { display: grid; gap: 8px; align-content: start; }

.segmented {
  display: inline-flex;
  justify-self: start;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border: 0;
  margin: 0;
}
.segmented button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  line-height: 1.25;
}
.segmented button small { font-weight: 500; font-size: var(--fs-xs); color: var(--ink-soft); }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 0 var(--line), 0 0 0 1.5px var(--ink); }
.segmented button[aria-pressed="true"] small { color: var(--ink); }
.segmented button:disabled { cursor: not-allowed; opacity: 0.5; }
/* Decision selector: staying / joining is green, leaving / withdrawing is red. */
.segmented button.tone-positive { color: var(--moss); }
.segmented button.tone-negative { color: var(--rose); }
.segmented button.tone-positive[aria-pressed="true"] { background: var(--moss); color: #fff; box-shadow: none; }
.segmented button.tone-negative[aria-pressed="true"] { background: var(--rose); color: #fff; box-shadow: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0; padding: 0; }
.chips button {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}
.chips button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.chips button:disabled { cursor: not-allowed; opacity: 0.5; }

.instructions {
  margin: 4px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  font-size: var(--fs-sm);
  white-space: pre-line;
  border-radius: 0 8px 8px 0;
}

/* Payment card: QR and the amount under it are centred; every other row reads from the left. */
.paybox {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  margin-top: 12px;
  padding: 24px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
}
.pay-hero { display: grid; justify-items: center; gap: 12px; text-align: center; }
.paybox-qr {
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
}
.paybox .qr { display: block; width: 192px; height: 192px; }
.paybox-amount { margin: 0; font-size: var(--fs-xl); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }

.pay-rows { display: grid; margin: 0; border-top: 1px solid var(--line); }
.pay-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.pay-row dt { font-size: var(--fs-xs); color: var(--ink-soft); }
.pay-row dd { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 2px 0 0; }
.pay-value { min-width: 0; font-size: var(--fs-sm); font-weight: 600; }
.pay-value a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ultra); text-underline-offset: 3px; }
.pay-value a:hover { color: var(--ultra); }
.pay-link { font-weight: 500; font-size: var(--fs-xs); line-height: 1.5; }
.rate-line { display: block; }
.rate-line + .rate-line { font-weight: 500; color: var(--ink-soft); }

/* Instructions are read, so they sit left-aligned across the card. */
.paybox-hint { margin: 0; font-size: var(--fs-xs); color: var(--ink-soft); }

.btn-copy {
  flex-shrink: 0;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.btn-copy:hover { border-color: var(--ink); color: var(--ink); }

.breakdown { margin: 0; display: grid; gap: 4px; font-size: var(--fs-sm); max-width: 380px; }
.breakdown div { display: flex; justify-content: space-between; gap: 16px; }
.breakdown dt { color: var(--ink-soft); }
.breakdown dd { margin: 0; font-weight: 500; }
.breakdown .is-credit dd { color: var(--moss); }
.breakdown .is-total { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.breakdown .is-total dt { color: var(--ink); font-weight: 600; }
.breakdown .is-total dd { font-weight: 700; }

.hint { margin: 0; font-size: var(--fs-xs); color: var(--ink-soft); max-width: 52ch; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.handshake { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--fs-sm); color: var(--ink-soft); margin: 0; padding: 0; list-style: none; }
.handshake li { display: inline-flex; align-items: center; gap: 8px; }
.handshake .done { color: var(--ink); font-weight: 600; }

/* ---------- Join ---------- */

.join { padding: 24px 0 56px; border-top: 1.5px solid var(--ink); }
.join-form { display: grid; gap: 20px; max-width: 560px; }
.join-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.join-form .btn { justify-self: start; }

/* ---------- Rules ---------- */

.rules { padding-top: 24px; border-top: 1px solid var(--line); }
.rules ol { margin: 12px 0 0; padding-left: 1.3em; display: grid; gap: 10px; max-width: 70ch; color: var(--ink-soft); }
.rules ol strong { color: var(--ink); font-weight: 600; }
.rules ol li::marker { font-variant-numeric: normal; }
.rules a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--ultra);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.rules a:hover { color: var(--ultra); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--fs-sm);
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  max-width: calc(100vw - 32px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--rose); color: #fff; }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .ledger { grid-template-columns: minmax(0, 1fr); }
  .ledger-block + .ledger-block { border-left: 0; border-top: 1.5px solid var(--ink); }
  .row-head {
    grid-template-columns: 36px minmax(0, 1fr) auto 16px;
    grid-template-areas: "seal name amount chev" "seal meta meta meta";
    gap: 4px 12px;
  }
  .row-head .seal { grid-area: seal; align-self: start; width: 32px; height: 32px; }
  .row-name { grid-area: name; }
  .row-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 4px 10px; }
  .row-plan:empty { display: none; }
  .row-amount { grid-area: amount; }
  .chevron { grid-area: chev; }
  .editor { grid-template-columns: minmax(0, 1fr); padding: 4px 12px 24px; }
  .editor-col { display: contents; }
  .editor-block { order: var(--m-order, 9); }
  .hero { padding-top: 40px; }
}

@media (min-width: 821px) {
  .row-meta { display: contents; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
