/* =========================================================================
   CVTA app — shell + design system
   Brand: navy #002060, blue #467bb8, slate #2b5672, red #e03939,
          orange #ff8044, page #f5f7fb, ink #1a1f2e. Font: Inter.
   Everything here is shared; feature modules own css/<feature>.css.
   ========================================================================= */

:root {
  /* brand */
  --navy: #002060;
  --navy-700: #001a4f;
  --navy-500: #103a8c;
  --blue: #467bb8;
  --blue-soft: #e6eefa;
  --slate: #2b5672;
  --red: #e03939;
  --orange: #ff8044;

  /* surfaces + ink */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --surface-3: #e6ebf4;
  --ink: #1a1f2e;
  --ink-2: #47506a;
  --muted: #6b7489;
  --line: #dfe4ee;
  --line-strong: #c7cfdf;

  /* semantic */
  --primary: var(--navy);
  --primary-ink: #ffffff;
  --accent: var(--blue);
  --danger: var(--red);
  --success: #157f4d;
  --warn: #b4630d;
  --focus: #6fa0ff;

  /* radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* shadows */
  --sh-1: 0 1px 2px rgba(16, 24, 48, .06), 0 1px 3px rgba(16, 24, 48, .08);
  --sh-2: 0 4px 14px rgba(16, 24, 48, .09);
  --sh-3: 0 14px 40px rgba(16, 24, 48, .18);

  /* spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;

  /* chrome metrics */
  --banner-h: 0px;
  --appbar-h: 70px;   /* tall enough for the real cvta.org lockup (54px) like the site header */
  --tabbar-h: 62px;
  --rail-w: 244px;
  --maxw: 880px;

  /* safe areas (iOS notch / home indicator via Capacitor) */
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Dark palette.
   It is declared TWICE on purpose, and js/theme.js decides which one wins:
     • no data-theme      -> "System": follow the OS (the media query below)
     • data-theme="light" -> pinned light, so the media query must not apply
     • data-theme="dark"  -> pinned dark, even on a light OS
   Keep the two blocks identical — edit one, edit the other. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1422;
    --surface: #161e30;
    --surface-2: #1d273c;
    --surface-3: #25314a;
    --ink: #eef2fa;
    --ink-2: #c3cbdd;
    --muted: #939db5;
    --line: #26314a;
    --line-strong: #35425f;
    --blue-soft: #1b2a45;
    --primary: #0b2d78;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 6px 18px rgba(0, 0, 0, .45);
    --sh-3: 0 18px 46px rgba(0, 0, 0, .6);
    --success: #45c88a;
    --warn: #e8a33d;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1422;
  --surface: #161e30;
  --surface-2: #1d273c;
  --surface-3: #25314a;
  --ink: #eef2fa;
  --ink-2: #c3cbdd;
  --muted: #939db5;
  --line: #26314a;
  --line-strong: #35425f;
  --blue-soft: #1b2a45;
  --primary: #0b2d78;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 6px 18px rgba(0, 0, 0, .45);
  --sh-3: 0 18px 46px rgba(0, 0, 0, .6);
  --success: #45c88a;
  --warn: #e8a33d;
}

/* --------------------------------------------------------------- reset */

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

/* The UA's `[hidden] { display: none }` is a plain type-less rule, so ANY class
   that sets `display` (.btn, .chip, .chat-jump …) silently beats it and the
   element stays on screen. Every `node.hidden = true` in the app relies on this
   one rule instead, so hiding works the same everywhere. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

body.overlay-open { overflow: hidden; }

h1, h2, h3, h4 { margin: 0 0 var(--s-2); line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }
figure, blockquote { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

ul, ol { margin: 0 0 var(--s-3); padding-left: 1.2em; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

.skip-link {
  position: fixed;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  box-shadow: var(--sh-2);
}
.skip-link:focus { left: 12px; top: calc(var(--banner-h) + 8px); }

/* ------------------------------------------------------------ app shell */

.shell { display: block; min-height: 100vh; }

.shell-main {
  padding-top: calc(var(--banner-h) + var(--appbar-h));
  min-height: 100vh;
}

.appbar {
  position: fixed;
  top: var(--banner-h);
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 calc(var(--s-4) + var(--sa-right)) 0 calc(var(--s-4) + var(--sa-left));
  background: var(--navy);
  color: #fff;
  box-shadow: var(--sh-1);
}

.brand {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: none;
  padding: 4px;
  margin-left: -4px;
  border-radius: var(--r-sm);
  flex: 0 0 auto;
}
.brand img {
  /* The website's own lockup: truck + CVTA + tagline, white on navy, natural
     aspect (viewBox 520.45 x 244.57 -> 2.128:1). Never squashed, never cropped. */
  height: 56px;
  width: auto;
  display: block;
}

.page-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-action {
  flex: 0 0 auto;
  min-width: 40px;
  display: flex;
  justify-content: flex-end;
}

.header-avatar {
  border: 0;
  background: none;
  padding: 0;
  border-radius: var(--r-pill);
  line-height: 0;
}
.header-avatar .avatar { border: 2px solid rgba(255, 255, 255, .55); }

.btn.header-signin,
.header-action .btn.ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, .5);
}
.header-action .btn.ghost:hover { background: rgba(255, 255, 255, .14); }

.view {
  display: block;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding:
    var(--s-4)
    calc(var(--s-4) + var(--sa-right))
    calc(var(--tabbar-h) + var(--sa-bottom) + var(--s-6))
    calc(var(--s-4) + var(--sa-left));
}
.view:focus { outline: none; }
.view-inner { display: block; }

/* --------------------------------------------------------------- nav */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 4px calc(4px + var(--sa-right)) calc(4px + var(--sa-bottom)) calc(4px + var(--sa-left));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}

.tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 4px 2px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
}
/* The icon slot holds an inline SVG from js/icons.js. font-size is the
   fallback for a module that still passes an emoji glyph. */
.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  font-size: 19px;
  line-height: 1;
}
.tab-icon svg { width: 22px; height: 22px; display: block; }
.tab-icon .icon { stroke-width: 1.75; }
.tab.active .tab-icon .icon { stroke-width: 2; }
.tab-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab.active { color: var(--navy); }
.tab.active .tab-icon { transform: translateY(-1px); }
.tab:hover { background: var(--surface-2); }

.tab-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.rail { display: none; }

.more-list { display: flex; flex-direction: column; gap: 2px; }
.more-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 12px var(--s-3);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  text-align: left;
  font-weight: 600;
  color: var(--ink);
}
.more-item:hover { background: var(--surface-2); }
.more-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  font-size: 18px;
  color: var(--muted);
}
.more-icon svg { width: 20px; height: 20px; }
.more-label { flex: 1 1 auto; }

@media (min-width: 900px) {
  :root { --appbar-h: 60px; }

  .rail {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--banner-h);
    bottom: 0;
    left: 0;
    width: var(--rail-w);
    z-index: 56;
    padding: var(--s-5) var(--s-3) var(--s-4);
    background: var(--navy);
    color: #fff;
    overflow-y: auto;
  }
  .rail-brand { padding: 0 var(--s-3) var(--s-6); }
  .rail-brand img { height: 76px; width: auto; display: block; }   /* exactly the size cvta.org draws it: 162 x 76 */
  .rail-nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
  /* Grouped sections: Conference / Community / Member tools / Admin. */
  .rail-group {
    margin: var(--s-4) var(--s-3) 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
  }
  .rail-section { display: flex; flex-direction: column; gap: 2px; }
  .rail-foot {
    padding: var(--s-4) var(--s-3) 0;
    font-size: 12px;
    color: rgba(255, 255, 255, .6);
  }
  .rail-foot a { color: rgba(255, 255, 255, .8); }

  .rail .tab {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--s-3);
    min-height: 44px;
    padding: 10px var(--s-3);
    font-size: 14px;
    color: rgba(255, 255, 255, .78);
  }
  .rail .tab:hover { background: rgba(255, 255, 255, .1); }
  .rail .tab.active { background: rgba(255, 255, 255, .17); color: #fff; }
  .rail .tab-label { font-size: 14px; }
  .rail .tab-icon { font-size: 17px; width: 22px; height: 20px; }
  .rail .tab-icon svg { width: 20px; height: 20px; }
  .rail .tab-badge {
    position: static;
    transform: none;
    margin-left: auto;
  }

  .shell-main { margin-left: var(--rail-w); }
  .appbar { left: var(--rail-w); }
  .appbar .brand { display: none; }
  .page-title { text-align: left; }
  .tabbar { display: none; }
  .view { padding-bottom: var(--s-8); max-width: var(--maxw); }
}

/* ------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
}
.card:last-child { margin-bottom: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.tappable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.card.tappable:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.card-title { font-size: 1.05rem; margin-bottom: var(--s-1); }
.card-sub { color: var(--muted); font-size: .875rem; margin-bottom: var(--s-3); }
.card-navy {
  background: linear-gradient(140deg, var(--navy), var(--navy-500));
  border-color: transparent;
  color: #fff;
}
.card-navy .card-sub,
.card-navy .muted { color: rgba(255, 255, 255, .78); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-6) 0 var(--s-3);
}
.section-head:first-child { margin-top: 0; }
.section-head h2 { margin: 0; font-size: 1.05rem; }
.section-head .link { font-size: .875rem; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 10px var(--s-5);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background .14s ease, border-color .14s ease, transform .08s ease, opacity .14s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }

.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-500); }

.btn.secondary {
  background: var(--blue-soft);
  color: var(--navy);
  border-color: color-mix(in srgb, var(--blue) 30%, transparent);
}
.btn.secondary:hover { background: color-mix(in srgb, var(--blue) 22%, var(--surface)); }

.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }

.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: #c22e2e; }

.btn.small { min-height: 34px; padding: 6px var(--s-4); font-size: .83rem; }
.btn.block { display: flex; width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.btn-row .btn { flex: 1 1 auto; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: inherit;
  font-size: 17px;
  line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }

.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

/* ------------------------------------------------------ chips + badges */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: .83rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.chip-row {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-bottom: var(--s-2);
  margin-bottom: var(--s-3);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
}
.badge.accent { background: var(--blue-soft); color: var(--navy); }
.badge.alert { background: var(--red); color: #fff; }
.badge.ok { background: color-mix(in srgb, var(--success) 18%, var(--surface)); color: var(--success); }
.badge.warn { background: color-mix(in srgb, var(--warn) 20%, var(--surface)); color: var(--warn); }

.source-pill { display: none !important; }


/* --------------------------------------------------------------- lists */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-1);
}
.list > li + li,
.list-item + .list-item { border-top: 1px solid var(--line); }

.list-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
}
button.list-item:hover, a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-main { flex: 1 1 auto; min-width: 0; }
.list-title { font-weight: 600; font-size: .95rem; }
.list-sub {
  color: var(--muted);
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-meta { flex: 0 0 auto; color: var(--muted); font-size: .78rem; text-align: right; }

.list-head {
  padding: var(--s-2) var(--s-4);
  background: var(--surface-2);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------- avatars */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  background: var(--slate);
  color: #fff;
  font-weight: 700;
  overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.tone-a { background: #2b5672; }
.avatar.tone-b { background: #467bb8; }
.avatar.tone-c { background: #002060; }
.avatar.tone-d { background: #6b4f8a; }
.avatar.tone-e { background: #1d6a5a; }
.avatar.tone-f { background: #8a5a2b; }

/* ---------------------------------------------------- skeleton / empty */

.skeleton-wrap { display: flex; flex-direction: column; gap: var(--s-4); }

.skeleton {
  display: block;
  height: 12px;
  width: 100%;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton.short { width: 55%; }
.skeleton-title { height: 18px; width: 70%; margin-bottom: 4px; }
.skeleton-circle { width: 40px; height: 40px; border-radius: var(--r-pill); flex: 0 0 auto; }

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.skeleton-lines { flex: 1 1 auto; display: flex; flex-direction: column; gap: var(--s-2); }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-8) var(--s-5);
  text-align: center;
  color: var(--muted);
}
.empty-icon { font-size: 34px; line-height: 1; }
.empty-title { margin: 0; font-size: 1.05rem; color: var(--ink); }
.empty-body { margin: 0; max-width: 42ch; }
.empty .btn { margin-top: var(--s-3); }

/* ---------------------------------------------------------------- gates */

.gate { text-align: center; padding: var(--s-7) var(--s-5); }
.gate-icon { font-size: 30px; margin-bottom: var(--s-2); }
.gate-title { font-size: 1.15rem; margin-bottom: var(--s-2); }
.gate-body { color: var(--muted); max-width: 46ch; margin: 0 auto var(--s-4); }
.gate-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; }

.gate-banner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent);
  border-radius: var(--r);
  background: var(--blue-soft);
  color: var(--navy);
  font-size: .87rem;
  font-weight: 600;
}
.gate-banner-text { flex: 1 1 200px; }

/* ------------------------------------------------------- tabs/segmented */

.tabs {
  display: flex;
  gap: var(--s-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-4);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs .tab,
.tabs > button {
  flex: 0 0 auto;
  flex-direction: row;
  min-height: 42px;
  padding: 10px var(--s-4);
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
}
.tabs .tab.active,
.tabs > button.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
  background: none;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  margin-bottom: var(--s-4);
}
.segment {
  flex: 1 1 0;
  min-height: 38px;
  padding: 8px var(--s-3);
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
}
.segment.active {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--sh-1);
}

/* Dark mode: --navy is a light-theme ink and measures ~1.1:1 on the dark
   surfaces, so every "navy text" control switches to --ink here. Keep the two
   blocks identical. (.rail .tab.active stays white-on-navy: higher specificity.) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.secondary,
  :root:not([data-theme="light"]) .segment.active,
  :root:not([data-theme="light"]) .tabs .tab.active,
  :root:not([data-theme="light"]) .tabs > button.active,
  :root:not([data-theme="light"]) .tab.active,
  :root:not([data-theme="light"]) .gate-banner,
  :root:not([data-theme="light"]) .badge.accent { color: var(--ink); }
  :root:not([data-theme="light"]) .tabs .tab.active,
  :root:not([data-theme="light"]) .tabs > button.active { border-bottom-color: #9dc0f0; }
}
:root[data-theme="dark"] .btn.secondary,
:root[data-theme="dark"] .segment.active,
:root[data-theme="dark"] .tabs .tab.active,
:root[data-theme="dark"] .tabs > button.active,
:root[data-theme="dark"] .tab.active,
:root[data-theme="dark"] .gate-banner,
:root[data-theme="dark"] .badge.accent { color: var(--ink); }
:root[data-theme="dark"] .tabs .tab.active,
:root[data-theme="dark"] .tabs > button.active { border-bottom-color: #9dc0f0; }

/* --------------------------------------------------------------- forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--s-4);
}
.field-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: .78rem; color: var(--muted); }
.field-row { display: flex; gap: var(--s-3); }
.field-row .field { flex: 1 1 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="tel"], input[type="url"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
  appearance: none;
  -webkit-appearance: none;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  outline: 3px solid color-mix(in srgb, var(--blue) 28%, transparent);
  outline-offset: 0;
}
input::placeholder, textarea::placeholder { color: var(--muted); }

.form-error {
  margin: 0 0 var(--s-3);
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
  color: #a51f1f;
  font-size: .87rem;
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .form-error { color: #ff9a9a; }
}
:root[data-theme="dark"] .form-error { color: #ff9a9a; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; }

/* -------------------------------------------------------- sheets/modals */

.overlay-host { position: relative; z-index: 100; }

.overlay-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  background: rgba(8, 14, 30, .5);
  opacity: 0;
  transition: opacity .2s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.overlay-backdrop.in { opacity: 1; }
.overlay-backdrop.overlay-sheet { align-items: flex-end; justify-content: center; }
.overlay-backdrop.overlay-modal { align-items: center; justify-content: center; padding: var(--s-4); }

.sheet, .modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-3);
  transition: transform .22s cubic-bezier(.2, .8, .3, 1);
}

.sheet {
  max-width: 560px;
  max-height: min(90vh, 900px);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding-bottom: var(--sa-bottom);
  transform: translateY(14px);
}
.overlay-backdrop.in .sheet { transform: translateY(0); }

.modal {
  max-width: 460px;
  max-height: min(86vh, 760px);
  border-radius: var(--r-lg);
  transform: scale(.98);
}
.overlay-backdrop.in .modal { transform: scale(1); }

.overlay-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--line);
}
.sheet .overlay-head { padding-top: var(--s-5); }
.sheet-grip {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
}
.overlay-title { flex: 1 1 auto; margin: 0; font-size: 1.05rem; }
.overlay-close { flex: 0 0 auto; margin: -8px -8px -8px 0; }

.overlay-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--s-4);
}

.confirm-body p { margin-bottom: var(--s-4); }
.confirm-actions { display: flex; gap: var(--s-2); justify-content: flex-end; }

@media (min-width: 620px) {
  .overlay-backdrop.overlay-sheet { align-items: center; padding: var(--s-4); }
  .sheet { border-radius: var(--r-lg); max-height: min(84vh, 820px); }
  .sheet-grip { display: none; }
  .sheet .overlay-head { padding-top: var(--s-4); }
}

/* -------------------------------------------------------------- toasts */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--sa-bottom) + var(--s-3));
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: min(92vw, 420px);
  pointer-events: none;
}
@media (min-width: 900px) {
  .toast-host { bottom: var(--s-5); }
}

.toast {
  pointer-events: auto;
  padding: 12px var(--s-4);
  border-radius: var(--r-sm);
  background: #10182c;
  color: #fff;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--sh-2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast-success { background: #10603f; }
.toast-error { background: #8f1f1f; }
.toast-warn { background: #8a5a12; }

/* ------------------------------------------------------------- auth UI */

.auth-intro { color: var(--muted); font-size: .9rem; margin-bottom: var(--s-4); }
.auth-form { margin: 0; }
.auth-links { display: flex; justify-content: center; gap: var(--s-4); margin-top: var(--s-3); }
.auth-fine { margin-top: var(--s-3); color: var(--muted); font-size: .8rem; text-align: center; }

.auth-form .btn.block { margin-top: var(--s-2); }

/* ---------------------------------------------------------- utilities */

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 700; }
.center { text-align: center; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: var(--s-3); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--s-2); }
.mt-4 { margin-top: var(--s-4); }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--s-2); }
.mb-4 { margin-bottom: var(--s-4); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-3); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.divider { height: 1px; background: var(--line); margin: var(--s-4) 0; border: 0; }

/* =========================================================================
   Appearance switch (js/theme.js) — System / Light / Dark, per device.
   Shown in the More footer and appended to Profile by app.js.
   ========================================================================= */

.theme-card { margin-bottom: 0; }
.theme-card-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.theme-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--blue-soft);
  color: var(--navy);
}
.theme-card-copy { min-width: 0; }
.theme-card-title { margin: 0 0 2px; font-size: 1rem; }
.theme-card-note { margin: 0; color: var(--muted); font-size: .82rem; }

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.theme-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  padding: var(--s-2) 4px;
  border: 0;
  border-radius: var(--r-xs);
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.theme-opt-icon { display: inline-flex; }
.theme-opt:hover { background: var(--surface-3); }
.theme-opt.active {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--sh-1);
}
.theme-switch.compact .theme-opt { flex-direction: row; min-height: 40px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-card-icon,
  :root:not([data-theme="light"]) .theme-opt.active { color: #9dc0f0; }
}
:root[data-theme="dark"] .theme-card-icon,
:root[data-theme="dark"] .theme-opt.active { color: #9dc0f0; }

.profile-appearance { display: block; margin-top: var(--s-5); }

/* =========================================================================
   "What's new since your last visit" (js/whatsnew.js) — Home card.
   ========================================================================= */

.home-whatsnew { display: block; }

.wn-card { padding: var(--s-4); }

.wn-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.wn-head-icon { display: inline-flex; color: var(--blue); }
.wn-head-title { margin: 0; font-size: .98rem; flex: 1 1 auto; }
.wn-count { flex: 0 0 auto; }

.wn-list { list-style: none; margin: 0; padding: 0; }
.wn-item + .wn-item { border-top: 1px solid var(--line); }

.wn-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.wn-row:hover .wn-title { text-decoration: underline; }

.wn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--blue);
}
.wn-copy { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.wn-title { font-size: .9rem; font-weight: 600; }
.wn-detail {
  font-size: .8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wn-when { flex: 0 0 auto; font-size: .74rem; color: var(--muted); }

.wn-foot {
  margin: var(--s-3) 0 0;
  padding-top: var(--s-2);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
}

/* =========================================================================
   Splash sponsor line — "Fall Conference presented by …".
   Injected into the EXISTING #splash markup by app.js at runtime; neither
   js/logo3d.js, css/logo3d.css nor the splash markup itself is touched.
   ========================================================================= */

.splash-presented {
  margin: var(--s-3) 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  animation: splash-presented-in .5s ease both;
}
.splash-presented-lead {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #5b6478;
}
.splash-presented-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--navy);
}

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

@media (prefers-reduced-motion: reduce) {
  .splash-presented { animation: none; }
}

/* ------------------------------------------------------- first-run welcome */

.welcome-title { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.welcome-lede { margin: var(--s-2) 0 0; color: var(--ink-2); line-height: 1.55; }
.welcome-points {
  list-style: none;
  margin: var(--s-4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--s-3);
}
.welcome-point {
  display: grid;
  gap: 2px;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.welcome-point-title { font-weight: 600; font-size: .9375rem; color: var(--ink); }
.welcome-point-body { font-size: .8125rem; line-height: 1.5; color: var(--muted); }
.welcome-actions { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.welcome-skip { justify-self: center; min-height: 44px; }
.welcome-fine {
  margin: var(--s-4) 0 0;
  text-align: center;
  font-size: .75rem;
  line-height: 1.45;
  color: var(--muted);
}
