/* =============================================================================
   Synapse — Site stylesheet
   Light theme: airy off-white base, synaptic cyan→violet gradient accents.
   ========================================================================== */

/* ---- Design tokens ------------------------------------------------------- */
:root {
  --bg:          #f4f7fc;
  --bg-2:        #eaf0fa;
  --surface:     #ffffff;
  --surface-2:   #f1f5fd;
  --surface-3:   #e5edf9;
  --border:      rgba(28,48,118,0.12);
  --border-2:    rgba(28,48,118,0.22);

  --text:        #111a37;
  --muted:       #515d80;
  --faint:       #8590ad;

  --cyan:        #0891b2;
  --violet:      #7c3aed;
  --pink:        #db2777;
  --green:       #059669;
  --amber:       #d97706;
  --orange:      #ea580c;
  --red:         #e11d48;
  --indigo:      #3b5bdb;
  --slate:       #64748b;

  --grad:        linear-gradient(120deg, #0891b2 0%, #4f6ef0 50%, #7c3aed 100%);
  --grad-soft:   linear-gradient(120deg, rgba(8,145,178,.10), rgba(124,58,237,.10));

  --radius:      16px;
  --radius-sm:   10px;
  --radius-lg:   24px;
  --shadow:      0 12px 34px -14px rgba(23,42,99,.22);
  --shadow-glow: 0 0 0 1px var(--border-2), 0 18px 44px -20px rgba(8,145,178,.28);

  --font:    "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: "Space Grotesk", var(--font);

  --maxw: 1160px;
  --nav-h: 68px;
}

/* ---- Reset / base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {                       /* ambient gradient wash */
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(60% 50% at 80% -10%, rgba(124,58,237,.07), transparent 60%),
    radial-gradient(50% 50% at 0% 0%, rgba(8,145,178,.07), transparent 55%);
  pointer-events: none;
  z-index: 0;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.15; font-weight: 600; margin: 0 0 .4em; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.relative { position: relative; z-index: 1; }
.gradient-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.muted { color: var(--muted); }

/* ---- Navigation ---------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 11px; font-family: var(--display); font-weight: 700; font-size: 1.18rem; letter-spacing: -.02em; }
.brand img { width: 30px; height: 30px; }
.brand span { color: var(--text); }
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-links a {
  padding: 8px 14px; border-radius: 999px; color: var(--muted);
  font-size: .94rem; font-weight: 500; transition: .18s;
}
.nav-links a:hover { color: var(--text); background: var(--surface-3); }
.nav-links a.active { color: var(--text); background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--border-2); }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.5rem; cursor: pointer; margin-left: auto; }

/* ---- Buttons / pills ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: .95rem;
  cursor: pointer; transition: .18s; white-space: nowrap;
}
.btn:hover { border-color: transparent; background: var(--surface-2); transform: translateY(-1px); }
.btn-primary { background: var(--grad); border: 0; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 10px 30px -8px rgba(34,211,238,.5); }
.btn-ghost { background: transparent; }

/* ---- Hero ---------------------------------------------------------------- */
.hero { position: relative; padding: 88px 0 64px; overflow: hidden; }
#neural-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: .9; }
.hero .wrap { position: relative; z-index: 1; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--cyan);
  padding: 6px 14px; border-radius: 999px; background: var(--grad-soft);
  box-shadow: inset 0 0 0 1px var(--border-2); margin-bottom: 22px;
}
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); letter-spacing: -.03em; margin-bottom: 18px; }
.hero p.lead { font-size: clamp(1.05rem, 2vw, 1.3rem); color: var(--muted); max-width: 600px; margin: 0 0 30px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 36px; margin-top: 52px; flex-wrap: wrap; }
.hero-stats .stat .n { font-family: var(--display); font-size: 2rem; font-weight: 700; }
.hero-stats .stat .l { color: var(--faint); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }

/* ---- Section headers ----------------------------------------------------- */
.section { padding: 56px 0; position: relative; z-index: 1; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -.02em; }
.section-head p { color: var(--muted); margin: 4px 0 0; }
.section-head .link { color: var(--cyan); font-weight: 600; font-size: .95rem; }
.section-head .link:hover { text-decoration: underline; }

/* ---- Card grid ----------------------------------------------------------- */
.grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

.card {
  position: relative; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: .2s; text-align: left;
}
.card:hover { transform: translateY(-4px); border-color: var(--border-2); box-shadow: var(--shadow-glow); }
.card-top {
  position: relative; aspect-ratio: 16/8.5; display: flex; align-items: center; justify-content: center;
  background: var(--grad-soft); border-bottom: 1px solid var(--border); overflow: hidden;
}
/* type-coloured header band — the elegant fallback when an item has no thumbnail */
.card-top-presentation { background: linear-gradient(135deg, #0aa2c0 0%, #0e7490 100%); border-bottom-color: transparent; }
.card-top-video        { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); border-bottom-color: transparent; }
.card-top-audio        { background: linear-gradient(135deg, #10b981 0%, #047857 100%); border-bottom-color: transparent; }
.card-top-pdf          { background: linear-gradient(135deg, #fb7185 0%, #be123c 100%); border-bottom-color: transparent; }
.card-top-link         { background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%); border-bottom-color: transparent; }
.card-top .type-icon { width: 48px; height: 48px; color: #fff; opacity: .96; filter: drop-shadow(0 2px 6px rgba(0,0,0,.22)); }
.card-top img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.card h3 { font-size: 1.15rem; letter-spacing: -.01em; margin-bottom: 8px; }
.card .summary { color: var(--muted); font-size: .92rem; margin: 0 0 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: .83rem; margin-top: auto; flex-wrap: wrap; }
.card .meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }

/* Type + category badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.badge-presentation   { background: rgba(8,145,178,.12);  color: #0e7490; }
.badge-video  { background: rgba(124,58,237,.12); color: #6d28d9; }
.badge-audio  { background: rgba(5,150,105,.12);  color: #047857; }
.badge-pdf    { background: rgba(225,29,72,.12);  color: #be123c; }
.badge-link   { background: rgba(217,119,6,.12);  color: #b45309; }
.card-top .badge { position: absolute; top: 12px; left: 12px; z-index: 2; background: rgba(255,255,255,.94); backdrop-filter: blur(6px); box-shadow: 0 1px 4px rgba(16,24,48,.16); }
.card-top .dur { position: absolute; bottom: 12px; right: 12px; z-index: 2; font-size: .78rem; color: var(--text); background: rgba(255,255,255,.82); padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(6px); box-shadow: inset 0 0 0 1px var(--border); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: .76rem; color: var(--muted); background: var(--surface-2); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); }

/* ---- Filter / search bar ------------------------------------------------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 26px; }
.search {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 10px 18px;
}
.search input { flex: 1; background: none; border: 0; color: var(--text); font-size: .98rem; outline: none; }
.search svg { width: 18px; height: 18px; color: var(--faint); flex-shrink: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: .88rem; font-weight: 500; cursor: pointer; transition: .15s;
}
.chip:hover { color: var(--text); border-color: var(--border-2); }
.chip.active { background: var(--grad); color: #fff; border-color: transparent; font-weight: 700; }

.empty { text-align: center; padding: 70px 20px; color: var(--faint); }
.empty svg { width: 46px; height: 46px; margin-bottom: 14px; opacity: .5; }

/* ---- Calendar ------------------------------------------------------------ */
.cal-layout { display: grid; grid-template-columns: 1fr 340px; gap: 32px; align-items: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.cal-head h2 { font-size: 1.5rem; }
.cal-nav { display: flex; gap: 8px; }
.cal-nav button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1.1rem; transition: .15s; }
.cal-nav button:hover { background: var(--surface-2); border-color: var(--border-2); }

.calendar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-dow { display: grid; grid-template-columns: repeat(7,1fr); background: var(--bg-2); border-bottom: 1px solid var(--border); }
.cal-dow span { padding: 12px 8px; text-align: center; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); }
.cal-cell { min-height: 104px; min-width: 0; padding: 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); position: relative; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.muted { background: rgba(28,48,118,.035); }
.cal-cell .daynum { font-size: .82rem; color: var(--muted); font-weight: 600; }
.cal-cell.today .daynum { background: var(--grad); color: #fff; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.cal-ev {
  display: block; margin-top: 4px; padding: 4px 9px; border-radius: 7px;
  font-size: .73rem; font-weight: 600; line-height: 1.45; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; transition: .15s ease; background: rgba(60,80,140,.08); color: var(--muted);
}
.cal-ev:hover { box-shadow: 0 3px 10px -3px rgba(40,30,90,.3); }
.cal-ev.t-lecture      { background: rgba(8,145,178,.12);   color: #0e7490; }
.cal-ev.t-journal-club { background: rgba(124,58,237,.13);  color: #6d28d9; }
.cal-ev.t-case         { background: rgba(5,150,105,.13);   color: #047857; }
.cal-ev.t-workshop     { background: rgba(234,138,0,.17);   color: #b45309; }
.cal-ev.t-grand-rounds { background: rgba(219,39,119,.12);  color: #be185d; }
.cal-ev.t-exam         { background: rgba(217,119,6,.15);   color: #b45309; }
.cal-ev.t-other        { background: rgba(60,80,140,.1);    color: var(--muted); }
.cal-ev.t-anatomy      { background: rgba(59,91,219,.13);   color: #3b5bdb; }
.cal-ev.t-embryology   { background: rgba(219,39,119,.12);  color: #be185d; }
.cal-ev.t-radiology    { background: rgba(100,116,139,.16); color: #475569; }

/* Upcoming list (sidebar) */
.upcoming { display: flex; flex-direction: column; gap: 10px; }
.up-item {
  display: flex; gap: 15px; align-items: center; padding: 13px 16px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--faint);
  border-radius: var(--radius-sm); transition: .16s; box-shadow: 0 1px 2px rgba(28,48,118,.04);
}
.up-item:hover { border-color: var(--border-2); transform: translateY(-1px); box-shadow: 0 12px 26px -18px rgba(28,48,118,.45); }
.up-item.t-lecture      { border-left-color: var(--cyan); }
.up-item.t-journal-club { border-left-color: var(--violet); }
.up-item.t-workshop     { border-left-color: var(--orange); }
.up-item.t-grand-rounds { border-left-color: var(--pink); }
.up-item.t-case         { border-left-color: var(--green); }
.up-item.t-exam         { border-left-color: var(--amber); }
.up-item.t-other        { border-left-color: var(--faint); }
.up-item.t-anatomy      { border-left-color: var(--indigo); }
.up-item.t-embryology   { border-left-color: var(--pink); }
.up-item.t-radiology    { border-left-color: var(--slate); }
.up-date { flex: 0 0 44px; text-align: center; }
.up-date .m { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 700; }
.up-date .d { font-family: var(--display); font-size: 1.55rem; font-weight: 700; line-height: 1.02; color: var(--text); }
.up-body { flex: 1; min-width: 0; }
.up-body .t { font-weight: 600; font-size: .92rem; line-height: 1.32; margin-bottom: 4px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.up-body .sub { color: var(--faint); font-size: .8rem; line-height: 1.4; }
.up-body .sub .disc { font-weight: 600; }
.up-body .sub .posted { color: var(--green); font-weight: 600; }
.legend { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; font-size: .82rem; color: var(--muted); }
.leg-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.leg-track { flex: 0 0 130px; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.legend .li { display: flex; align-items: center; gap: 7px; }
.legend .sw { width: 10px; height: 10px; border-radius: 50%; }
@media (max-width: 880px) { .leg-track { flex-basis: 100%; margin-bottom: -2px; } }
.up-item { cursor: pointer; }

/* ---- Event detail modal -------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,24,54,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card {
  position: relative; z-index: 1; width: 100%; max-width: 540px; max-height: 86vh; overflow: auto;
  background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 30px 32px; box-shadow: var(--shadow); animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: 0; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-card .ev-date { color: var(--cyan); font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.modal-card h3 { font-size: 1.45rem; letter-spacing: -.01em; margin: 0 0 12px; padding-right: 24px; }
.modal-card .ev-sub { color: var(--muted); font-size: .92rem; margin-bottom: 4px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.modal-card .ev-notes { color: var(--muted); font-size: .98rem; line-height: 1.62; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 18px; }
.modal-card .ev-notes .label { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; margin-bottom: 7px; }
.modal-card .actions { margin-top: 22px; }
.modal-card .ev-links { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.modal-card .ev-links .label { display: block; width: 100%; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; margin-bottom: 4px; }
.modal-card .ev-links a { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--cyan); font-weight: 600; font-size: .86rem; transition: .15s; }
.modal-card .ev-links a:hover { border-color: var(--border-2); background: var(--surface-3); color: var(--violet); }

/* ---- Item (detail) page -------------------------------------------------- */
.item-hero { padding: 40px 0 8px; }
.crumb { color: var(--faint); font-size: .9rem; margin-bottom: 18px; }
.crumb a:hover { color: var(--cyan); }
.item-hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -.02em; max-width: 900px; }
.item-meta { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; color: var(--muted); margin-top: 14px; font-size: .95rem; }
.player {
  margin: 28px 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  background: #000; box-shadow: var(--shadow);
}
.player iframe, .player video { width: 100%; aspect-ratio: 16/9; display: block; border: 0; }
.audio-player { margin: 28px 0; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.audio-player audio { width: 100%; }
.deck-launch {
  margin: 28px 0; padding: 40px; text-align: center; border-radius: var(--radius);
  background: var(--grad-soft); border: 1px solid var(--border-2);
}
.deck-launch p { color: var(--muted); margin: 8px 0 22px; }
.item-body { max-width: 760px; font-size: 1.05rem; }
.item-body h3 { margin-top: 32px; }

/* ---- Study materials card (authored study guide + Anki deck) ------------- */
.study-card {
  margin: 28px 0; padding: 28px 30px; border-radius: var(--radius);
  background: var(--grad-soft); border: 1px solid var(--border-2);
}
.study-card h3 { margin: 0 0 4px; }
.study-card > p { color: var(--muted); margin: 0 0 18px; }
.study-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.study-hint { flex-basis: 100%; color: var(--faint); font-size: .85rem; margin-top: 2px; }

/* ---- Footer -------------------------------------------------------------- */
.footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 40px 0; position: relative; z-index: 1; }
.footer .wrap { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; color: var(--faint); font-size: .9rem; }
.footer .brand { font-size: 1rem; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 880px) {
  .cal-layout { grid-template-columns: 1fr; }
  .nav-links { position: absolute; top: var(--nav-h); left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--bg-2); border-bottom: 1px solid var(--border); padding: 8px; display: none; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 13px 16px; border-radius: var(--radius-sm); }
  .nav-toggle { display: block; }
}
@media (max-width: 520px) {
  .cal-cell { min-height: 64px; padding: 5px; }
  .cal-ev { padding: 3px 7px; font-size: .66rem; }
  .hero-stats { gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Reveal-on-scroll ---------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* =============================================================================
   PWA APP-SHELL — installable / mobile experience
   On phones (≤880px, where the hamburger used to appear) a bottom tab bar
   replaces the top nav, with iOS safe-area insets, tap polish, and native-feel
   page transitions. Injected by initAppShell() in site.js, so it never shows on
   full-screen decks / study guides. Desktop is untouched.
   ========================================================================== */
.tabbar { display: none; }
.a2hs-hint { display: none; }

@media (max-width: 880px) {
  /* Top bar → a slim, centered app header; primary nav moves to the bottom */
  .nav { padding-top: env(safe-area-inset-top); }
  .nav-toggle { display: none; }
  .nav-links { display: none; }
  .nav .wrap { justify-content: center; }

  /* Bottom tab bar — fills the width when it fits, scrolls when there are
     many tools (each tab keeps a comfortable min width instead of cramming). */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border);
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .tab {
    flex: 1 0 56px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 5px 2px; color: var(--faint); font-size: .64rem; font-weight: 600;
    text-decoration: none; -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none; user-select: none; transition: color .15s, transform .12s;
  }
  .tab-lb { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-ic { width: 24px; height: 24px; display: grid; place-items: center; }
  .tab-ic svg { width: 24px; height: 24px; }
  .tab.active { color: var(--cyan); }
  .tab.active .tab-ic { color: var(--violet); }
  .tab:active { transform: scale(.9); }

  /* Keep page content clear of the fixed bar */
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  /* iOS "Add to Home Screen" hint (shown by pwa.js) */
  .a2hs-hint {
    display: flex; position: fixed; left: 12px; right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 60;
    align-items: center; gap: 12px; background: #111a37; color: #fff;
    border-radius: 14px; padding: 12px 14px; font-size: .9rem; line-height: 1.35;
    box-shadow: 0 14px 34px -10px rgba(0, 0, 0, .45); animation: a2hsIn .3s ease;
  }
  .a2hs-hint b { color: #7dd3fc; font-weight: 700; }
  .a2hs-hint button {
    margin-left: auto; flex: none; background: transparent; border: 0;
    color: #fff; font-size: 1.5rem; line-height: 1; padding: 0 2px; cursor: pointer;
  }
}
@keyframes a2hsIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Tap polish on interactive chrome */
.btn, .chip, .tab, .nav-links a, .card { -webkit-tap-highlight-color: transparent; }

/* Native-feel cross-document page transitions (progressive — a no-op where
   unsupported). The header + tab bar are named so they persist across pages
   instead of cross-fading. */
@view-transition { navigation: auto; }
.nav { view-transition-name: app-header; }
.tabbar { view-transition-name: app-tabbar; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
