/* Summit tokens, from lib/core/theme/colors.dart (lightScheme, darkScheme, SniffariPalette), except
   five console-only values Summit has no role for: --gold-soft and --on-gold-soft in both themes
   (the Premium chip) and dark --brand-press (the primary button's hover). */
:root {
  color-scheme: light dark;
  --brand: #149e5c;
  --brand-press: #0c7a45;
  --brand-ink: #0c7a45; /* brand text on light surfaces: #149E5C fails AA at body size there */
  --on-brand: #ffffff;
  --brand-soft: #dcf0e5;
  --on-brand-soft: #06351e;
  --ink: #14201a;
  --moss: #5a615b;
  --canvas: #f4f5f2;
  --surface: #ffffff;
  --surface-low: #fafbfa;
  --field: #eef0ec;
  --line: #e7eae5;
  --line-strong: #d2d8d1;
  --land: #e3f1e9;
  --contour: #a9d6be;
  --danger: #c03a2b;
  --amber: #e0901b;
  --amber-soft: #f7e5d2;
  --on-amber-soft: #3f2510;
  --gold-soft: #f6e6c2;
  --on-gold-soft: #5a3d06;
  --shadow: 20 32 26;

  --radius-panel: 20px;
  --radius-control: 14px;
  --radius-dialog: 24px;
  --font-display: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #2bb873;
    --brand-press: #24a064;
    --brand-ink: #2bb873;
    --on-brand: #04321c;
    --brand-soft: #0e5b36;
    --on-brand-soft: #bfefd4;
    --ink: #e7eee9;
    --moss: #c2cbc4;
    --canvas: #0c120f;
    --surface: #121a16;
    --surface-low: #161f1a;
    --field: #1b241f;
    --line: #2a332e;
    --line-strong: #36413a;
    --land: #223429;
    --contour: #446753;
    --danger: #e5564a;
    --amber: #e7a86a;
    --amber-soft: #623e1c;
    --on-amber-soft: #f7e5d2;
    --gold-soft: #4a3a12;
    --on-gold-soft: #f3dca2;
    --shadow: 0 0 0;
  }
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, dl, dd { margin: 0; }

a { color: var(--brand-ink); text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 2px;
}

.sprite { position: absolute; }
.pin { fill: var(--brand); }
.paw { fill: var(--surface); }

/* ── the drawn map ─────────────────────────────────────────────────────────────────────────
   The design system's rule is that the map is the background. Here it is a survey sheet:
   contour lines masked out of a flat colour, so one file serves both themes. */
.terrain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: var(--canvas);
}
.terrain::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--contour);
  -webkit-mask: url('/terrain.svg') center / cover no-repeat;
  mask: url('/terrain.svg') center / cover no-repeat;
  opacity: 0.3;
}
body[data-view='signin'] .terrain { background: var(--land); }
body[data-view='signin'] .terrain::before { opacity: 1; }

#app { position: relative; }

/* ── type ──────────────────────────────────────────────────────────────────────────────── */
.title {
  font: 800 2rem/1.15 var(--font-display);
  letter-spacing: -0.02em;
}
.section-title {
  font: 700 1.125rem/1.3 var(--font-display);
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}
.lede { color: var(--moss); max-width: 60ch; margin-top: 6px; }
.muted { color: var(--moss); }
.small { font-size: 13px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--moss); }
.error-text { color: var(--danger); }
.loading { color: var(--moss); }
.empty { color: var(--moss); padding: 6px 0; }

/* ── brand ─────────────────────────────────────────────────────────────────────────────── */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font: 800 1.0625rem/1 var(--font-display);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-mark { width: 26px; height: 30px; flex: none; }

/* ── sign-in trailhead ─────────────────────────────────────────────────────────────────── */
.trailhead {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.trailhead-card {
  width: min(100%, 400px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-dialog);
  padding: 28px 26px 26px;
  box-shadow: 0 28px 56px -28px rgb(var(--shadow) / 0.35);
}
.trailhead-card > * + * { margin-top: 14px; }
.trailhead-card .brand-lockup { margin-bottom: 10px; }
.trailhead-card .title { font-size: 1.75rem; }

/* ── controls ──────────────────────────────────────────────────────────────────────────── */
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 28px; }
form.stack .label + .input { margin-top: 6px; }

.input, .select {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  border: 1.5px solid transparent;
  background: var(--field);
  color: var(--ink);
  font: 400 16px/1.2 var(--font-body);
}
.input::placeholder { color: var(--moss); }
.input:focus-visible, .select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.select { width: auto; min-width: 210px; min-height: 44px; padding-right: 12px; }
.code-input {
  font: 700 1.5rem/1 var(--font-display);
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: 600 15px/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--surface-low); }
.btn.primary { background: var(--brand); border-color: transparent; color: var(--on-brand); font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--brand-press); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--moss); }
.btn.ghost:hover:not(:disabled) { background: var(--field); color: var(--ink); }
.btn.link {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-ink);
  text-decoration: underline;
}
.btn.link:hover:not(:disabled) { background: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.wide { width: 100%; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.split { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }

.form-status { font-size: 14px; }
.form-status:empty { display: none; }
.form-status[data-tone='error'] { color: var(--danger); }
.form-status[data-tone='ok'] { color: var(--brand-ink); }

/* ── console chrome ────────────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--moss);
  font-weight: 600;
  text-decoration: none;
}
.nav-link:hover { color: var(--ink); background: var(--field); }
.nav-link[aria-current='page'] { background: var(--brand-soft); color: var(--on-brand-soft); }
.account { display: flex; align-items: center; gap: 6px; min-width: 0; }
.account-email {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--moss);
  font-size: 13px;
}

.view { max-width: 960px; margin: 0 auto; padding: 32px 24px 96px; outline: none; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--field);
}
.segment {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--moss);
  font: 600 14px/1 var(--font-body);
  cursor: pointer;
}
.segment[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.12);
}

/* ── overview ──────────────────────────────────────────────────────────────────────────── */
.fresh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  overflow: hidden;
}
.fresh-item { background: var(--surface); padding: 16px 18px 18px; }
.fresh-item dt { color: var(--moss); font-size: 13px; }
.fresh-item dd {
  margin-top: 4px;
  font: 800 2rem/1 var(--font-display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.ledger-grid.two-up { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.ledger {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 18px 20px 6px;
}
.ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.ledger-row:first-child { border-top: 0; }
.ledger-row dd {
  font: 700 1.0625rem/1.2 var(--font-display);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ── lists ─────────────────────────────────────────────────────────────────────────────── */
.search { margin-bottom: 16px; }
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  overflow: hidden;
}
.list > li + li { border-top: 1px solid var(--line); }
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  color: inherit;
  text-decoration: none;
}
a.list-row:hover { background: var(--surface-low); }
.list-row.column { flex-direction: column; align-items: stretch; gap: 4px; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.summary { overflow-wrap: anywhere; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--field);
  color: var(--moss);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.role-admin { background: var(--brand); color: var(--on-brand); text-transform: capitalize; }
.chip.role-moderator { background: var(--brand-soft); color: var(--on-brand-soft); text-transform: capitalize; }
.chip.premium { background: var(--gold-soft); color: var(--on-gold-soft); }
.chip.status-open { background: var(--amber-soft); color: var(--on-amber-soft); }
.chip.status-actioned { background: var(--brand-soft); color: var(--on-brand-soft); }

.avatar {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--land);
}
.avatar.initial {
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--on-brand-soft);
  font: 700 1rem/1 var(--font-display);
}
.avatar.large { width: 72px; height: 72px; font-size: 1.75rem; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }

/* ── one user ──────────────────────────────────────────────────────────────────────────── */
.back { display: inline-block; margin-bottom: 16px; font-weight: 600; text-decoration: none; }
.back::before { content: '‹'; margin-right: 6px; }
.back:hover { text-decoration: underline; }

.profile-head { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 8px; }
.profile-head > .grow > * + * { margin-top: 8px; }
.profile-head .chips { justify-content: flex-start; }
.bio { max-width: 62ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.ident { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; user-select: all; }

.panel {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 20px 22px;
}
.panel .ledger { border: 0; border-radius: 0; padding: 0; background: none; }
.panel .list { border: 0; border-radius: 0; background: none; }
.panel .list-row { padding-left: 0; padding-right: 0; }
.control + .control { margin-top: 18px; }
.control .row { margin-top: 6px; }
.control .form-status { margin-top: 6px; }
.facts { max-width: 480px; }

.note {
  margin-top: 14px;
  padding: 10px 14px;
  border-left: 3px solid var(--amber);
  border-radius: 0 10px 10px 0;
  background: var(--field);
  font-size: 14px;
}

.notice {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.notice > * + * { margin-top: 6px; }
.notice + p { margin-top: 12px; }
.notice-title { font-weight: 700; }
.notice.error { border-color: var(--danger); }
.notice.error .notice-title { color: var(--danger); }

/* ── feedback ──────────────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 3;
  padding: 12px 18px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--surface);
  font-weight: 600;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.dialog {
  width: min(92vw, 440px);
  padding: 24px;
  border: 0;
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 64px -20px rgb(0 0 0 / 0.4);
}
.dialog p + p { margin-top: 10px; }
.dialog .row { margin-top: 22px; }
.dialog::backdrop { background: rgb(12 18 15 / 0.5); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .topbar .brand-lockup { flex: 1; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .account-email { max-width: 140px; }
  .view { padding: 24px 16px 80px; }
  .title { font-size: 1.625rem; }
  .user-row { flex-wrap: wrap; }
  .user-row .chips { flex-basis: 100%; justify-content: flex-start; padding-left: 54px; }
  .profile-head { gap: 14px; }
  .avatar.large { width: 56px; height: 56px; font-size: 1.375rem; }
  .select { flex: 1; min-width: 0; }
}

@media (max-width: 480px) {
  .account-email { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
