/* ==========================================================================
   STG Gymnastics (Shenandoah Tumblers) — App design system (V3)
   Framework-free. Tokens → base → shell → components → utilities.
   Brand: Shenandoah Emerald (logo gymnast) + Tumblers blue-violet (logo wordmark) on navy ink.
   --coral = alert/urgent red (no pink anywhere); decorative accents use --violet.
   Token names (--teal / --coral) are kept from the shared core so every component works;
   only their values are STG's.
   ========================================================================== */

@font-face {
  font-family: 'Fraunces';
  src: url('../assets/fonts/fraunces.woff2') format('woff2-variations'), url('../assets/fonts/fraunces.woff2') format('woff2');
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: 'Figtree';
  src: url('../assets/fonts/figtree.woff2') format('woff2-variations'), url('../assets/fonts/figtree.woff2') format('woff2');
  font-weight: 300 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Figtree';
  src: url('../assets/fonts/figtree-italic.woff2') format('woff2-variations'), url('../assets/fonts/figtree-italic.woff2') format('woff2');
  font-weight: 300 900; font-style: italic; font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  /* brand */
  --ink:          #1B2159;   /* midnight — primary text, dark surfaces */
  --ink-2:        #233066;   /* legacy STG navy */
  --teal:         #1B2159;   /* Portal V3: STG navy is the primary accent (customer: no green in the portal). Var name kept for the shared core. */
  --on-teal:      #FFFFFF;   /* text/icons on solid teal fills */
  --teal-strong:  #1B2159;   /* text-safe primary (navy) */
  --teal-soft:    #E6E8F5;
  --coral:        #DC3D3D;   /* ribbon coral — logo script */
  --coral-strong: #B42318;   /* text/badge-safe coral */
  --coral-soft:   #FDECEC;
  --coral-fill:   #DC3D3D;   /* solid fills under white text */
  --gold:         #E9B140;   /* medals & top scores */
  --gold-soft:    #FCF1D7;
  --green:        #1F56B3;   /* Portal V3: "success" is blue, not green (customer). AA on --green-soft and white */
  --green-soft:   #E2EBFB;
  --amber:        #9A5B00;   /* AA on --amber-soft / --gold-soft */
  --amber-soft:   #FFF1D9;
  --violet:       #4A4FC0;
  --violet-soft:  #E8E9FA;
  --blue:         #2862C8;   /* AA on --blue-soft */
  --blue-soft:    #E3ECFC;

  /* neutrals (cool, teal-tinted) */
  --paper:     #F3F4F8;
  --surface:   #FFFFFF;
  --surface-2: #F7F8FB;
  --surface-3: #ECEEF5;
  --text:      #1B2159;
  --text-2:    #454D6E;
  --muted:     #585F7B;   /* 5.8:1 on paper */
  --faint:     #676E89;   /* 4.6:1 on paper (used for small meta text too) */
  --line:      rgba(27, 33, 89, .09);
  --line-2:    rgba(27, 33, 89, .14);
  --scrim:     rgba(12, 18, 40, .48);
  --glass:     rgba(255, 255, 255, .72);
  --glass-line:rgba(255, 255, 255, .6);
  --hero-1:    #1B2159;
  --hero-2:    #2E3A8C;
  --hero-text: #FFFFFF;

  /* elevation — navy tinted, used only on floating layers */
  --shadow-1: 0 1px 2px rgba(31,29,71,.05), 0 1px 1px rgba(31,29,71,.03);
  --shadow-2: 0 6px 18px -6px rgba(31,29,71,.18), 0 2px 6px rgba(31,29,71,.06);
  --shadow-3: 0 24px 48px -16px rgba(31,29,71,.35), 0 8px 18px -8px rgba(31,29,71,.18);

  /* shape — radius follows hierarchy */
  --r-hero: 28px;
  --r-card: 20px;
  --r-group: 16px;
  --r-input: 14px;
  --r-sm: 10px;
  --r-pill: 999px;

  /* type */
  --font-display: 'Fraunces', Georgia, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ui: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px;
  --fs-2xl: 24px; --fs-3xl: 30px; --fs-4xl: 38px; --fs-5xl: 48px;

  /* space */
  --gutter: 16px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  /* safe areas + chrome sizes */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --head-h: 52px;
  --tabbar-h: 64px;
  --tabbar-space: calc(var(--tabbar-h) + max(var(--sab), 10px) + 18px);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-nav: cubic-bezier(.32, .72, 0, 1);   /* iOS navigation curve */
  --dur: 340ms;
  --dur-push: 300ms;   /* keep in sync with DUR in js/core/router.js */
  --dur-pop: 270ms;
}

:root[data-theme="dark"] {
  /* STG dark = Shenandoah night navy (not near-black). Text/muted tokens are WCAG AA on every surface below. */
  color-scheme: dark;
  --ink:          #EEF1FA;
  --teal:         #8E9CFF;
  --on-teal:      #0B1030;
  --teal-strong:  #B4BEFF;
  --teal-soft:    rgba(142, 156, 255, .17);
  --coral:        #F07070;
  --coral-strong: #FF7A7A;   /* text-safe on navy (>=4.8:1) */
  --coral-fill:   #D93F3F;   /* solid fills under white text */
  --coral-soft:   rgba(255, 122, 122, .16);
  --gold:         #F5C25C;
  --gold-soft:    rgba(245, 194, 92, .16);
  --green:        #8DB4FF;
  --green-soft:   rgba(141, 180, 255, .15);
  --amber:        #F2B04A;
  --amber-soft:   rgba(242, 176, 74, .15);
  --violet:       #A9ACF5;
  --violet-soft:  rgba(169, 172, 245, .17);
  --blue:         #8FB3F7;
  --blue-soft:    rgba(143, 179, 247, .16);
  --paper:     #101A3D;
  --surface:   #17224A;
  --surface-2: #1C2953;
  --surface-3: #243262;
  --text:      #EEF1FA;   /* 13.6:1 on surface */
  --text-2:    #C8CEE6;   /*  9.8:1 */
  --muted:     #9AA3C6;   /*  6.2:1 on surface, 4.9:1 on surface-3 */
  --faint:     #8C95B9;   /*  5.2:1 on surface (meta text, icons, placeholders) */
  --line:      rgba(255,255,255,.08);
  --line-2:    rgba(255,255,255,.14);
  --scrim:     rgba(6, 10, 30, .62);
  --glass:     rgba(20, 30, 66, .74);
  --glass-line:rgba(255,255,255,.09);
  --hero-1:    #1A2766;
  --hero-2:    #2A3580;
  --shadow-1: 0 1px 2px rgba(3,6,20,.35);
  --shadow-2: 0 8px 22px -8px rgba(3,6,20,.6);
  --shadow-3: 0 28px 56px -18px rgba(3,6,20,.75);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; width: 100%; max-width: 100%; overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font-family: var(--font-ui); font-size: var(--fs-md); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "ss01", "cv11";
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--teal-strong); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; line-height: 1.15; text-wrap: balance; }
.empty p, .pg-sub, .d-msg { text-wrap: pretty; }
p { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }
:focus-visible { outline: 2.5px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--teal-soft); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ico { width: 22px; height: 22px; flex: none; stroke-width: 2; }
.ico-sm { width: 16px; height: 16px; }
.ico-xs { width: 14px; height: 14px; }
.ico-lg { width: 28px; height: 28px; }
.ico-xl { width: 40px; height: 40px; stroke-width: 1.6; }

/* ---------- Boot splash ----------
   Emerald mark in the middle of a slowly turning gradient "orbit" (conic ring + particle swirl), on deep
   STG navy with soft emerald / blue-violet glows. CSS only, transform/opacity only (GPU). app.js removes it
   the moment the first screen is ready (never blocks); a hard cap in index.html hides it after 2.5s. */
#boot {
  position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; overflow: hidden;
  background:
    radial-gradient(60% 42% at 50% 40%, rgba(27, 33, 89,.30) 0%, transparent 70%),
    radial-gradient(70% 50% at 85% 100%, rgba(74,79,192,.34) 0%, transparent 70%),
    radial-gradient(60% 45% at 0% 0%, rgba(27, 33, 89,.22) 0%, transparent 70%),
    linear-gradient(180deg, #16215A 0%, #121A48 55%, #0D1336 100%);
  transition: opacity .32s cubic-bezier(.2,.8,.2,1), visibility .32s;
}
#boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }
#boot .boot-stage { --orb: min(64vw, 248px); position: relative; width: var(--orb); aspect-ratio: 1; display: grid; place-items: center; }
#boot .boot-orbit, #boot .boot-orbit-2, #boot .boot-swirl { position: absolute; inset: 0; border-radius: 50%; will-change: transform; }
#boot .boot-orbit {
  background: conic-gradient(from 0deg, transparent 0deg, rgba(142, 156, 255,.0) 40deg, #8E9CFF 150deg, #6C70E0 250deg, transparent 330deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: bootSpin 1.6s linear infinite;
}
#boot .boot-orbit-2 {
  inset: 9%;
  background: conic-gradient(from 180deg, transparent 0deg, rgba(108,112,224,.0) 60deg, rgba(108,112,224,.75) 170deg, rgba(142, 156, 255,.55) 230deg, transparent 300deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  animation: bootSpin 2.4s linear infinite reverse;
}
#boot .boot-swirl { inset: -14%; animation: bootSpin 6s linear infinite; }
#boot .boot-swirl i {
  position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%;
  background: #8FE3C2; box-shadow: 0 0 8px 1px rgba(143,227,194,.7);
  transform: rotate(var(--a)) translateX(var(--r)); opacity: var(--o, .8);
}
#boot .boot-swirl i:nth-child(3n) { background: #A9ACF5; box-shadow: 0 0 8px 1px rgba(169,172,245,.7); }
#boot .boot-swirl i:nth-child(4n) { width: 3px; height: 3px; }
#boot .boot-glow { position: absolute; inset: 18%; border-radius: 50%; background: radial-gradient(closest-side, rgba(142, 156, 255,.28), transparent 75%); animation: bootBreathe 1.8s ease-in-out infinite alternate; }
#boot .boot-badge {                                   /* official STG logo, unmodified, on a white disc */
  position: relative; width: 76%; aspect-ratio: 1; border-radius: 50%; background: #fff;
  display: grid; place-items: center; box-shadow: 0 12px 34px rgba(0,0,0,.35), 0 0 0 4px rgba(255,255,255,.08);
  animation: bootMarkIn .5s cubic-bezier(.2,.8,.2,1) both;
}
#boot .boot-mark { width: 84%; height: auto; display: block; }
#boot .boot-word {
  position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 9vh); text-align: center;
  font-family: var(--font-ui); font-weight: 800; font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: rgba(233,236,248,.55);
  animation: bootMarkIn .6s .1s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes bootSpin { to { transform: rotate(360deg); } }
@keyframes bootBreathe { from { opacity: .55; transform: scale(.94); } to { opacity: 1; transform: scale(1.04); } }
@keyframes bootMarkIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

/* ---------- App shell ---------- */
#app { position: fixed; inset: 0; overflow: hidden; max-width: 100vw; }
#pages { position: absolute; inset: 0; background: var(--paper); overflow: hidden; }

.page {
  position: absolute; inset: 0; background: var(--paper);
  display: flex; flex-direction: column; overflow: hidden;
  isolation: isolate; backface-visibility: hidden;   /* own stacking context: no z-index bleed between stacked pages */
}
.page.enter-push, .page.leave-push, .page.enter-pop, .page.leave-pop, .page.swipe-top, .page.swipe-under { will-change: transform; }
.page.is-under, .page.is-leaving { pointer-events: none; }
.page-scroll {
  position: relative; flex: 1; overflow-y: auto; overflow-x: hidden; max-width: 100%;
  -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; overscroll-behavior-x: none; touch-action: manipulation;   /* overflow-x:hidden already stops sideways panning; pan-y here could block nested carousels in WebKit */
  padding-bottom: var(--tabbar-space);
}
.page.no-tabbar .page-scroll { padding-bottom: calc(var(--sab) + 24px); }
.page-body { max-width: 100%; min-width: 0; padding: 0 var(--gutter); padding-left: calc(var(--gutter) + var(--sal)); padding-right: calc(var(--gutter) + var(--sar)); }
.page-body.flush { padding-left: 0; padding-right: 0; }

/* Transitions: transform-only on whole pages (GPU-composited, no layout, no filter, no page opacity).
   The page underneath dims through its own ::after overlay (opacity on a pseudo layer only).
   Router (core/router.js) waits for the stg* keyframe by name; edge-swipe (app.js) drives the
   same transforms + --dim by hand. Tab switches fade only the content layer, never the page. */
.page::after {
  content: ""; position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background: var(--page-dim, rgba(14, 20, 46, .16)); opacity: 0; visibility: hidden;
}
:root[data-theme="dark"] .page { --page-dim: rgba(2, 5, 18, .42); }
.page.enter-push, .page.leave-pop { z-index: 3; box-shadow: -14px 0 36px -10px rgba(14, 20, 46, .22); }
.page.enter-push  { animation: stgPushIn  var(--dur-push) var(--ease-nav) both; }
.page.leave-push  { animation: stgUnderOut var(--dur-push) var(--ease-nav) both; }
.page.leave-push::after { visibility: visible; animation: stgDimIn var(--dur-push) var(--ease-nav) both; }
.page.enter-pop   { animation: stgUnderIn var(--dur-pop) var(--ease-nav) both; }
.page.enter-pop::after { visibility: visible; animation: stgDimOut var(--dur-pop) var(--ease-nav) both; }
.page.leave-pop   { animation: stgPopOut  var(--dur-pop) var(--ease-nav) both; }
.page.enter-fade > .page-scroll, .page.enter-fade > .page-bare { animation: stgContentIn 200ms var(--ease) both; }
.page.enter-fade .fade-in { animation: none; }            /* no double fade on tab switches */
.page.swipe-top { z-index: 3; box-shadow: -14px 0 36px -10px rgba(14, 20, 46, .22); }
.page.swipe-under::after { visibility: visible; opacity: var(--dim, 1); transition: opacity var(--dim-t, 0ms) cubic-bezier(.32,.72,0,1); }
@keyframes stgPushIn   { from { transform: translate3d(100%,0,0); } to { transform: translate3d(0,0,0); } }
@keyframes stgUnderOut { from { transform: translate3d(0,0,0); } to { transform: translate3d(-28%,0,0); } }
@keyframes stgUnderIn  { from { transform: translate3d(-28%,0,0); } to { transform: translate3d(0,0,0); } }
@keyframes stgPopOut   { from { transform: translate3d(0,0,0); } to { transform: translate3d(100%,0,0); } }
@keyframes stgDimIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes stgDimOut   { from { opacity: 1; } to { opacity: 0; } }
@keyframes stgContentIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }   /* opacity only: content never shifts while it loads */

/* ---------- Page header (compact bar + large title) ---------- */
.pg-head {
  position: relative; z-index: 5; flex: none;
  padding-top: var(--sat); padding-left: var(--sal); padding-right: var(--sar);
  background: transparent; transition: background .2s, box-shadow .2s;
}
.pg-head::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .2s;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.page.is-scrolled .pg-head::before { opacity: 1; }
.pg-bar { position: relative; height: var(--head-h); display: flex; align-items: center; gap: 4px; padding: 0 8px; }
.pg-bar .bar-left, .pg-bar .bar-right { display: flex; align-items: center; gap: 2px; min-width: 44px; }
.pg-bar .bar-right { justify-content: flex-end; }
.pg-bar .bar-title {
  flex: 1; min-width: 0; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transform: translateY(4px);
  transition: opacity .2s, transform .2s;
}
.page.is-scrolled .pg-bar .bar-title, .page.title-always .pg-bar .bar-title { opacity: 1; transform: none; }
.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text);
  transition: background .15s, transform .15s;
}
.icon-btn:active { transform: scale(.92); background: var(--surface-3); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--coral-strong); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--paper);
}
.back-btn { display: inline-flex; align-items: center; gap: 0; height: 44px; padding: 0 10px 0 4px; border-radius: 22px; font-weight: 600; color: var(--teal-strong); }
.back-btn:active { background: var(--surface-3); }
.back-btn .ico { width: 26px; height: 26px; }

.pg-hero { padding: 4px calc(var(--gutter) + var(--sar)) 14px calc(var(--gutter) + var(--sal)); }
.pg-title {
  font-family: var(--font-display); font-weight: 800; font-size: var(--fs-4xl); line-height: 1.02;
  font-stretch: 82%; letter-spacing: -.02em; color: var(--text);
}
.pg-sub { margin-top: 6px; color: var(--muted); font-size: var(--fs-md); }
.pg-hero-img {
  position: relative; margin: 0 var(--gutter) 18px; border-radius: var(--r-card); overflow: hidden; aspect-ratio: 16 / 7;
  background: var(--surface-3) center / cover no-repeat;
  opacity: 1; filter: none; mix-blend-mode: normal;
}
/* Banner artwork is designed on white (many are transparent PNGs): always back it with white so it renders
   exactly as designed in BOTH themes. No dimming, filter or overlay in dark mode. */
.pg-hero-img.has-img, :root[data-theme="dark"] .pg-hero-img.has-img { background-color: #fff; opacity: 1; filter: none; }
/* Never crop a banner: the whole image always shows (portrait photos sit centered on white, heads included). */
.pg-hero-img.has-img { background-size: contain; background-position: center; }
.pg-hero-img::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Tab bar (floating pill) ---------- */
#tabbar {
  position: fixed; z-index: 40; left: 50%; bottom: max(var(--sab), 10px);
  transform: translateX(-50%); width: min(calc(100% - 24px), 520px); height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px; border-radius: 24px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--glass-line); box-shadow: var(--shadow-3);
  transition: transform .35s var(--ease), opacity .25s;
}
#tabbar.hide { transform: translate(-50%, calc(100% + 40px)); opacity: 0; pointer-events: none; }
#tabbar .tab-ind {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 5); border-radius: 18px;
  background: var(--ink); transition: transform .42s var(--ease-out);
}
:root[data-theme="dark"] #tabbar .tab-ind { background: var(--teal); }
#tabbar a {
  position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .01em; border-radius: 18px;
  transition: color .25s;
}
#tabbar a .ico { width: 22px; height: 22px; transition: transform .3s var(--ease-out); }
#tabbar a.active { color: #fff; }
:root[data-theme="dark"] #tabbar a.active { color: #08201F; }
#tabbar a.active .ico { transform: translateY(-1px) scale(1.06); }
#tabbar a:active .ico { transform: scale(.88); }
#tabbar .tab-badge {
  position: absolute; top: 5px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--coral-strong); color: #fff; font-size: 10px; line-height: 16px; text-align: center; font-weight: 800;
}

/* ---------- Drawer (side menu) ---------- */
#drawer { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
#drawer .drawer-scrim { touch-action: none; }
#drawer .drawer-scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .3s; }
#drawer .drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 360px);
  background: var(--surface); transform: translateX(-102%); transition: transform .38s var(--ease-out);
  display: flex; flex-direction: column; box-shadow: var(--shadow-3);
  padding-top: var(--sat); padding-bottom: var(--sab);
}
#drawer.open { pointer-events: auto; }
#drawer.open .drawer-scrim { opacity: 1; }
#drawer.open .drawer-panel { transform: none; }
/* Locked like a native side menu: vertical scroll only, nothing can ever pan sideways. */
#drawer .drawer-panel { overflow: hidden; max-width: 100vw; touch-action: pan-y; }
.drawer-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 24px; max-width: 100%; min-width: 0;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none;
}
.drawer-scroll::-webkit-scrollbar { display: none; }
.drawer-scroll > * { max-width: 100%; }
.drawer-logo { max-width: calc(100% - 44px); height: auto; }
.drawer-logo { margin: 14px 22px 6px; width: 170px; }
:root[data-theme="dark"] .drawer-logo { background: #fff; border-radius: 14px; padding: 8px 10px; }
.drawer-user {
  margin: 14px 16px 6px; padding: 14px; border-radius: var(--r-card); display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2)); color: #fff;
}
.drawer-user .du-name { font-weight: 800; font-size: var(--fs-lg); line-height: 1.2; }
.drawer-user .du-role { font-size: var(--fs-sm); opacity: .75; }
.drawer-section { padding: 14px 22px 6px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.drawer-link { display: flex; align-items: center; gap: 14px; padding: 12px 22px; color: var(--text); font-weight: 600; text-align: left; min-width: 0; }
.drawer-link > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-link .dl-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-user .grow > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-foot { overflow-wrap: anywhere; }
.drawer-link:active { background: var(--surface-3); }
.drawer-link .ico { color: var(--teal-strong); }
.drawer-link .dl-sub { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.drawer-link .ext { margin-left: auto; color: var(--faint); width: 16px; height: 16px; }
.drawer-foot { padding: 16px 22px 8px; color: var(--muted); font-size: var(--fs-xs); line-height: 1.6; border-top: 1px solid var(--line); }
.drawer-foot strong { color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 14px;  /* STG: rounded-rect geometry */
  font-weight: 700; font-size: var(--fs-md); letter-spacing: .005em; white-space: nowrap;
  background: var(--teal); color: #fff; transition: transform .15s, filter .15s, background .15s;  /* STG: emerald primary */
}
:root[data-theme="dark"] .btn { background: var(--teal); color: #0B1030; }
.btn:active { transform: scale(.97); filter: brightness(.95); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
/* Buttons that float over scrolling content (sheet footers, sticky action bars) go solid-grey when disabled
   instead of translucent, so the list underneath never shows through them. */
:is(.sheet-foot, .tk-stickybar, .ca-new-cta, .ec-actbar) .btn:not(.btn-ghost):not(.btn-outline):is([disabled], .is-disabled) {
  opacity: 1; background: var(--surface-3); color: var(--muted); box-shadow: none; filter: none;
}
.btn .ico { width: 20px; height: 20px; }
.btn-block { display: flex; width: 100%; }
.btn-teal, :root[data-theme="dark"] .btn-teal { background: var(--teal); color: var(--on-teal); }
.btn-coral { background: var(--coral-strong); color: #fff; }
:root[data-theme="dark"] .btn-coral { background: var(--coral-fill); color: #fff; }
.btn-soft { background: var(--teal-soft); color: var(--teal-strong); }
:root[data-theme="dark"] .btn-soft { background: var(--teal-soft); color: var(--teal-strong); }
.btn-ghost { background: transparent; color: var(--teal-strong); }
:root[data-theme="dark"] .btn-ghost { background: transparent; color: var(--teal-strong); }
.btn-outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line-2); }
:root[data-theme="dark"] .btn-outline { background: transparent; color: var(--text); }
.btn-danger { background: var(--coral-soft); color: var(--coral-strong); }
:root[data-theme="dark"] .btn-danger { background: var(--coral-soft); color: var(--coral-strong); }
.btn-sm { height: 36px; padding: 0 14px; font-size: var(--fs-sm); }
.btn-sm .ico { width: 16px; height: 16px; }
.btn-lg { height: 56px; font-size: var(--fs-lg); }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.link-btn { color: var(--teal-strong); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
/* Comfortable hit areas: compact controls keep their look but get a >=44px invisible tap target */
.btn-sm, .chip, .link-btn, .back-btn, .hit, .segmented button,
.hm-ec-link, .ec-chip, .fn-paythis, .fn-acc, .cr-send, .gn-feed-more, .hm-forgot, .gn-frame-open { position: relative; }
.btn-sm::after, .chip::after, .link-btn::after, .back-btn::after, .hit::after, .segmented button::after,
.hm-ec-link::after, .ec-chip::after, .fn-paythis::after, .fn-acc::after, .cr-send::after, .gn-feed-more::after, .hm-forgot::after, .gn-frame-open::after {
  content: ""; position: absolute; left: -4px; right: -4px; top: 50%; height: max(44px, 100%); transform: translateY(-50%);
}
.link-btn::after { left: -8px; right: -8px; }
.cr-send::after { left: -3px; right: -3px; }
.segmented button::after { top: 50%; left: 0; right: 0; }
/* Press feedback for every tappable surface (transform/opacity only) */
.link-btn { transition: opacity .15s; }
.link-btn:active { opacity: .6; }
.chip:active { transform: scale(.96); }
.chip { transition: background .15s, color .15s, border-color .15s, transform .15s; }

/* ---------- Surfaces ---------- */
.card {
  background: var(--surface); border-radius: var(--r-card); padding: 16px;
  border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 12px; }
.card.tap { transition: transform .15s; cursor: pointer; }
.card.tap:active { transform: scale(.985); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: var(--fs-lg); flex: 1; }
.card-head .ico { color: var(--teal-strong); }

.hero-card {
  position: relative; overflow: hidden; border-radius: var(--r-hero); padding: 20px; color: var(--hero-text);
  background: radial-gradient(130% 120% at 100% 0%, #3A3787 0%, transparent 55%), linear-gradient(160deg, var(--hero-2), var(--hero-1));
  box-shadow: var(--shadow-2);
}
/* ui.ribbonSvg() now renders a soft light "glow" (no line art): a premium radial mesh in STG colors. */
.hero-card .ribbon, .ribbon.glow { position: absolute; right: -40px; top: -10px; width: 300px; height: 200px; pointer-events: none; }
.ribbon.glow, .hm-ribbon.glow, .glow {
  display: block; border-radius: 50%; z-index: -1;
  background:
    radial-gradient(closest-side at 62% 42%, rgba(142, 156, 255,.34), transparent 72%),
    radial-gradient(closest-side at 30% 70%, rgba(108,112,224,.30), transparent 70%);
  filter: blur(6px); transform: translateZ(0);
}
.hero-card, :has(> .glow) { isolation: isolate; }   /* glow paints above the card background, below its content */

.section { margin-top: 26px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
.section-head h2 { font-size: var(--fs-xl); font-weight: 800; }
.section-head .link-btn { font-size: var(--fs-sm); }

/* Inset grouped list (iOS-like) */
.list { background: var(--surface); border-radius: var(--r-group); border: 1px solid var(--line); overflow: hidden; }
.list + .list { margin-top: 14px; }
.list-label { margin: 22px 6px 8px; font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.row {
  position: relative; display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 12px 16px; color: var(--text);
  background: var(--surface); width: 100%; text-align: left;
}
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 64px; border-top: 1px solid var(--line); }
.row.no-icon + .row::before, .list.plain .row + .row::before { left: 16px; }
.row.tap { cursor: pointer; transition: background .12s; }
.row.tap:active { background: var(--surface-3); }
.row-icon {
  width: 36px; height: 36px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: var(--teal-soft); color: var(--teal-strong);
}
.row-icon .ico { width: 20px; height: 20px; }
.row-icon.coral { background: var(--coral-soft); color: var(--coral-strong); }
.row-icon.gold { background: var(--gold-soft); color: var(--amber); }
.row-icon.violet { background: var(--violet-soft); color: var(--violet); }
.row-icon.blue { background: var(--blue-soft); color: var(--blue); }
.row-icon.green { background: var(--green-soft); color: var(--green); }
.row-icon.ink { background: var(--ink); color: #fff; }
:root[data-theme="dark"] .row-icon.ink { background: var(--teal-soft); color: var(--teal-strong); }
.row-main { display: block; flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 700; line-height: 1.3; }
.row-sub { display: block; font-size: var(--fs-sm); color: var(--muted); line-height: 1.35; margin-top: 2px; }
.row-title.clamp1, .row-sub.clamp1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-end { flex: none; display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: var(--fs-sm); }
.row-end .chev { width: 18px; height: 18px; color: var(--faint); }
.row-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Key/value detail grid */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: var(--fs-md); }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tiles.three { grid-template-columns: repeat(3, 1fr); }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px; min-height: 104px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px; color: var(--text); position: relative; overflow: hidden;
}
.tile.tap:active { transform: scale(.98); }
.tile .t-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.tile .t-value { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-3xl); line-height: 1; font-stretch: 85%; font-variant-numeric: tabular-nums; }
.tile .t-foot { font-size: var(--fs-xs); color: var(--muted); }
.tile .t-icon { position: absolute; right: 12px; top: 12px; color: var(--teal-strong); }

.big-num { font-family: var(--font-display); font-weight: 800; font-stretch: 80%; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }

/* Pills, chips, badges */
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 800; letter-spacing: .01em; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill .ico { width: 12px; height: 12px; stroke-width: 2.5; }
.pill.teal { background: var(--teal-soft); color: var(--teal-strong); }
.pill.coral { background: var(--coral-soft); color: var(--coral-strong); }
.pill.gold { background: var(--gold-soft); color: var(--amber); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.ink { background: var(--ink); color: #fff; }
:root[data-theme="dark"] .pill.ink { background: #EEF1FA; color: #17224A; }
:root[data-theme="dark"] .pill.solid-coral, :root[data-theme="dark"] .icon-btn .dot, :root[data-theme="dark"] #tabbar .tab-badge, :root[data-theme="dark"] .toast.error .t-ico { background: var(--coral-fill); }
.pill.solid-coral { background: var(--coral-strong); color: #fff; }
.pill.solid-teal { background: var(--teal); color: var(--on-teal); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px var(--gutter) 6px; margin: 0 calc(-1 * var(--gutter)); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: var(--r-pill); display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text-2); font-weight: 700; font-size: var(--fs-sm);
  transition: background .15s, color .15s, border-color .15s;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
:root[data-theme="dark"] .chip.active { background: var(--teal); border-color: var(--teal); color: #072A1F; }
.chip .count { font-variant-numeric: tabular-nums; opacity: .7; }

/* Segmented control */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; gap: 4px; border-radius: 14px;
  background: var(--surface-3); position: relative;
}
.segmented button { height: 36px; border-radius: 10px; font-weight: 700; font-size: var(--fs-sm); color: var(--text-2); transition: background .2s, color .2s, box-shadow .2s; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* Avatars */
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  font-family: var(--font-display); font-weight: 800; font-size: 16px; color: #fff; background: #1B2159;
  background-size: cover; background-position: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.avatar.ring { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--teal); }
.online-dot { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: #22C55E; box-shadow: 0 0 0 2px var(--surface); }

/* Media cards (news) */
.media-card { position: relative; display: block; border-radius: var(--r-card); overflow: hidden; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.media-card .mc-img { aspect-ratio: 16 / 9; background: var(--surface-3) center / cover no-repeat; position: relative; }
.media-card .mc-body { padding: 14px 16px 16px; }
.media-card .mc-title { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); line-height: 1.2; }
.media-card .mc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: var(--fs-sm); color: var(--muted); }
.media-card .mc-pills { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.media-card:active { transform: scale(.99); }
.media-card + .media-card { margin-top: 14px; }

/* Rich text from the CMS */
.prose { font-size: var(--fs-md); line-height: 1.65; color: var(--text-2); overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { color: var(--text); margin: 1.2em 0 .5em; }
.prose h1 { font-size: var(--fs-2xl); } .prose h2 { font-size: var(--fs-xl); } .prose h3 { font-size: var(--fs-lg); }
.prose img { height: auto !important; border-radius: 14px; margin: 12px 0; }
.prose a { color: var(--teal-strong); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--line-2); padding: 6px 8px; }
.prose iframe, .prose video { max-width: 100%; border-radius: 14px; }
.prose * { max-width: 100%; }
.prose [style*="color"] { color: inherit; }
.prose [style*="background"] { background: transparent !important; }

/* Forms */
.field { display: block; margin-bottom: 14px; }
.field > span, .field-label { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); margin: 0 4px 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: var(--r-input);
  background: var(--surface); border: 1.5px solid var(--line-2); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; font-size: 16px;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236E7390' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap .input-icon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-wrap.lead .input { padding-left: 44px; padding-right: 14px; }
.input-wrap.lead .lead-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.field-hint { font-size: var(--fs-xs); color: var(--muted); margin: 6px 4px 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--teal); }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .25s var(--ease-out); }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .45; }

.search-bar { position: relative; }
.search-bar .input { padding-left: 42px; min-height: 44px; border-radius: 13px; background: var(--surface-3); border-color: transparent; }
.search-bar .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 19px; height: 19px; }
.search-bar .input::placeholder { text-overflow: ellipsis; }
@media (max-width: 380px) { .search-bar .input::placeholder { font-size: .9em; letter-spacing: -.005em; } }   /* Title Case placeholders are longer */

/* ---------- Overlays: sheet, dialog, toast, loader ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; }
.overlay .scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .3s; }
.overlay.open .scrim { opacity: 1; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(100% - var(--sat) - 24px);
  background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-3);
  transform: translateY(105%); transition: transform .42s var(--ease-out);
  display: flex; flex-direction: column; padding-bottom: var(--sab);
  max-width: 640px; margin: 0 auto;
}
.sheet.full { height: calc(100% - var(--sat) - 12px); }
.overlay.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px 10px 20px; flex: none; }
.sheet-head h3 { flex: 1; font-size: var(--fs-xl); }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-foot { flex: none; padding: 12px 20px 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }

.dialog {
  position: absolute; left: 50%; top: 50%; width: min(calc(100% - 48px), 360px);
  transform: translate(-50%, -46%) scale(.96); opacity: 0; transition: transform .3s var(--ease-out), opacity .2s;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-3); padding: 22px 20px 16px; text-align: center;
}
.overlay.open .dialog { transform: translate(-50%, -50%); opacity: 1; }
.dialog .d-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-strong); }
.dialog .d-icon.danger { background: var(--coral-soft); color: var(--coral-strong); }
.dialog h3 { font-size: var(--fs-xl); margin-bottom: 6px; }
.dialog .d-msg { color: var(--text-2); white-space: pre-line; }
.dialog .d-field { margin-top: 14px; text-align: left; }
.dialog .d-actions { display: flex; gap: 10px; margin-top: 18px; }
.dialog .d-actions .btn { flex: 1; }

.action-list { display: flex; flex-direction: column; gap: 2px; }
.action-item { display: flex; align-items: center; gap: 14px; padding: 14px 6px; border-radius: 14px; font-weight: 700; color: var(--text); text-align: left; width: 100%; }
.action-item:active { background: var(--surface-3); }
.action-item .ico { color: var(--teal-strong); }
.action-item.danger, .action-item.danger .ico { color: var(--coral-strong); }

#toasts { position: fixed; z-index: 95; left: 0; right: 0; top: calc(var(--sat) + 10px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; max-width: 460px; display: flex; align-items: center; gap: 10px; padding: 12px 16px 12px 12px; border-radius: 18px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: var(--fs-sm); box-shadow: var(--shadow-3);
  animation: toastIn .4s var(--ease-out) both;
}
:root[data-theme="dark"] .toast { background: #F2F4FB; color: #17224A; }
.toast .t-ico { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.14); flex: none; }
:root[data-theme="dark"] .toast .t-ico { background: rgba(21,27,50,.08); }
.toast.success .t-ico { background: var(--green); color: #fff; }
.toast.error .t-ico { background: var(--coral-strong); color: #fff; }
.toast.tap { cursor: pointer; }
.toast.out { animation: toastOut .3s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

#loader { position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; background: rgba(14,16,38,.25); opacity: 0; visibility: hidden; transition: opacity .2s; }
#loader.show { opacity: 1; visibility: visible; }
#loader .ld-box { background: var(--surface); border-radius: 22px; padding: 22px 26px; min-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: var(--shadow-3); font-weight: 700; font-size: var(--fs-sm); color: var(--text-2); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--teal-soft); border-top-color: var(--teal); animation: spin .8s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(5,7,18,.94); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .25s; }
.lightbox.open { opacity: 1; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; touch-action: pinch-zoom; }
.lightbox .lb-close { position: absolute; top: calc(var(--sat) + 10px); right: 12px; color: #fff; background: rgba(255,255,255,.12); }
.lightbox .lb-actions { position: absolute; bottom: calc(var(--sab) + 18px); left: 0; right: 0; display: flex; justify-content: center; gap: 12px; }

/* ---------- States ---------- */
.skel { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 12px; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.3s infinite;
}
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 12px; margin: 8px 0; }
.skel-row { display: flex; gap: 14px; align-items: center; padding: 12px 16px; }
.skel-row .skel-circle { width: 40px; height: 40px; border-radius: 12px; flex: none; }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .e-icon {
  position: relative; width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 24px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--teal-soft), var(--violet-soft)); color: var(--teal-strong);
  box-shadow: inset 0 0 0 1px var(--line);
}
.empty .e-icon .ico { width: 34px; height: 34px; stroke-width: 1.7; }
.empty h3 { color: var(--text); font-size: var(--fs-xl); margin-bottom: 6px; }
.empty p { max-width: 32ch; margin: 0 auto; }
.empty .btn { margin-top: 18px; }

/* Pull to refresh */
.ptr { position: absolute; left: 0; right: 0; top: 0; height: 0; display: flex; justify-content: center; pointer-events: none; z-index: 4; }
.ptr .ptr-dot { margin-top: 8px; width: 38px; height: 38px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-2); display: grid; place-items: center; color: var(--teal); transform: translateY(-60px); }
.ptr.spinning .ptr-dot .ico { animation: spin .8s linear infinite; }

/* Horizontal scroller (carousels) */
.scroller { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px var(--gutter) 8px; margin: 0 calc(-1 * var(--gutter)); scrollbar-width: none; scroll-padding: 0 var(--gutter); }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; flex: none; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line-2); transition: width .3s, background .3s; }
.dots i.on { width: 18px; background: var(--teal); }

/* Utilities */
.mt-0{margin-top:0!important}.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-5{margin-top:20px}.mt-6{margin-top:24px}.mt-8{margin-top:32px}
.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}
.muted{color:var(--muted)}.faint{color:var(--faint)}.small{font-size:var(--fs-sm)}.xsmall{font-size:var(--fs-xs)}
.bold{font-weight:700}.center{text-align:center}.right{text-align:right}
.text-green{color:var(--green)!important}.text-coral{color:var(--coral-strong)!important}.text-teal{color:var(--teal-strong)!important}.text-gold{color:var(--amber)!important}
.flex{display:flex}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-2{gap:8px}.gap-3{gap:12px}.grow{flex:1;min-width:0}
.wrap{flex-wrap:wrap}.nowrap{white-space:nowrap}.ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tabular{font-variant-numeric:tabular-nums}
.divider{height:1px;background:var(--line);margin:14px 0}
.fade-in { animation: fadeIn .22s var(--ease) both; }

@media (min-width: 720px) {
  :root { --gutter: 24px; }
  .page-scroll > * { max-width: 760px; margin-left: auto; margin-right: auto; }
  .pg-title { font-size: var(--fs-5xl); }
}

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

/* ---------- Native-app feel ----------
   UI chrome is not selectable / long-press-callout-able; real content (inputs, chat messages, news/CMS
   bodies, .selectable) stays selectable. No tap highlight, no double-tap zoom, no sideways panning.
   Touch devices never get :hover styles — any hover rule MUST be inside @media (hover: hover). */
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
* { -webkit-tap-highlight-color: transparent; }
input, textarea, select, [contenteditable], [contenteditable] *, .prose, .prose *, .selectable, .selectable *, .kv dd,
.cr-text, .cr-bubble .cr-text, .cr-msg-text, .nw-body, .nw-body * {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
.prose img, .statcard-preview img, .lightbox img { -webkit-touch-callout: default; }
.page-scroll, .sheet-body, .drawer-scroll { scrollbar-width: none; }
.page-scroll::-webkit-scrollbar, .sheet-body::-webkit-scrollbar { display: none; }
.sheet-body { overflow-x: hidden; }
/* Horizontal scrollers opt back into sideways panning */
.scroller, .chips, .page-scroll [data-hscroll] { touch-action: pan-x pan-y; overscroll-behavior-x: contain; }
/* Media never overflows the screen */
.page-body img, .page-body video, .page-body iframe, .page-body table { max-width: 100%; }
.page-body pre { max-width: 100%; overflow-x: auto; white-space: pre-wrap; }

/* ---------- Images: fade only the FIRST time (already-loaded images show instantly) ---------- */
img.img-fx { opacity: 0; transition: opacity .22s ease; }
img.img-fx.is-loaded { opacity: 1; }
img.img-fx.is-instant { transition: none; opacity: 1; }

/* CMS safety net (format.sanitizeHtml strips most of this): legacy inline colors never fight the theme */
.prose [style*="color"], .prose font[color], .prose [color] { color: inherit !important; }
.prose [style*="background"], .prose [bgcolor] { background: transparent !important; }
.prose hr { border: 0; height: 1px; background: var(--line-2); margin: 16px 0; }