/* styles/app.css: base, fonts, shells, utilities and UI-kit styles (E1).
   Tokens only (styles/tokens.css). Animate transform and opacity only.
   Prefixes: .ui-* kit, .shell-* shell, .fx-* effects. */

/* ---------- Fonts: Barlow Condensed (OFL, self-hosted, latin) ---------- */
@font-face {
  font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../assets/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../assets/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Barlow Condensed"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("../assets/fonts/barlow-condensed-latin-800-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Reset + base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Root text size: 17 px (106.25% of the browser default), and on iOS the
   system text size (Settings › Larger Text / Dynamic Type, 17 px at the
   default). The type tokens are rem, so text follows it. macOS Safari also
   knows -apple-system-body (13 px), hence the iOS-only touch-callout test. */
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) { html { font: -apple-system-body; } }
/* Keyboard focus and scrollIntoView keep targets clear of the sticky context
   bar and the fixed dock (with the raised Go disc). */
html[data-shell="tabs"], html[data-shell="drill"] {
  scroll-padding-top: calc(var(--bar-h) + var(--safe-top) + var(--s-2));
  scroll-padding-bottom: calc(var(--dock-h) + var(--safe-bottom) + var(--s-5));
}
html[data-viewport="wide"][data-shell], html[data-viewport="xl"][data-shell] { scroll-padding-bottom: var(--s-4); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: var(--fs-body); line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
h1, h2, h3, h4, p, figure, blockquote, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, canvas, video { display: block; max-width: 100%; }
svg { overflow: visible; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; margin: 0; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
a { color: var(--brand-strong); text-decoration: none; }
input, select, textarea { font-size: max(16px, 1em); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--brand-soft); }

/* Ambient motion pauses when the frame is blurred (hub tab switches). */
[data-blurred] .ambient, [data-blurred] .ambient * { animation-play-state: paused !important; }
[data-motion="reduced"] *, [data-motion="reduced"] *::before, [data-motion="reduced"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important;
}

/* ---------- Utilities ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ui-muted { color: var(--muted); }
.ui-ink2 { color: var(--ink-2); }
.ui-num { font-family: var(--font-num); font-variant-numeric: tabular-nums lining-nums; }
.ui-label { font-size: var(--fs-label); font-weight: 650; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); }
.ui-h1 { font-size: var(--fs-h1); line-height: 1.22; font-weight: 700; letter-spacing: -.01em; }
.ui-h2 { font-size: var(--fs-h2); line-height: 1.3; font-weight: 650; }
.ui-stack { display: flex; flex-direction: column; gap: var(--s-3); }
.ui-row { display: flex; align-items: center; gap: var(--s-3); }
.ui-grow { flex: 1 1 auto; min-width: 0; }
.ui-note { font-size: var(--fs-micro); line-height: 1.4; font-weight: 500; color: var(--muted); }
.bg-lab-grid {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
}
.bg-arena-light { background-image: radial-gradient(120% 60% at 50% -15%, var(--brand-soft), transparent 62%); }

/* ---------- Boot ---------- */
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.boot-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--brand); animation: boot-pulse 1s var(--ease-inout) infinite alternate; }
@keyframes boot-pulse { from { transform: scale(.6); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.noscript { padding: var(--s-5); }

/* ---------- Shells ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.shell--tabs, .shell--drill { padding-bottom: calc(var(--dock-h) + var(--safe-bottom) + var(--s-5)); }
.shell-col { min-width: 0; }
.shell-main { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gutter) var(--s-6); }
.shell-full { min-height: 100vh; min-height: 100dvh; }

.shell-bar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: calc(var(--bar-h) + var(--safe-top)); padding: var(--safe-top) calc(var(--gutter) - 8px) 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  background: var(--bg); view-transition-name: shell-bar;
}
.shell-bar-left, .shell-bar-right { display: flex; align-items: center; gap: 2px; }
.shell-bar--drill { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); }
.shell-bar-title { font-size: var(--fs-body); font-weight: 650; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-brand { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding: 0 8px; color: var(--ink); }
.shell-brand-mark { color: var(--brand); display: inline-flex; }
.shell-wordmark { font-family: var(--font-num); font-weight: 800; font-size: 22px; letter-spacing: .04em; transform: skewX(var(--skew)); line-height: 1; }
.shell-streak { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); min-width: var(--tap); padding: 0 10px; border-radius: var(--r-pill); color: var(--ink); }
.shell-streak-flame { color: var(--flame); display: inline-flex; }
.shell-streak-n { font-family: var(--font-num); font-weight: 700; font-size: 20px; line-height: 1; }
.shell-me { position: relative; width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: 50%; }
.shell-banners { padding: 0 var(--gutter) var(--s-2); max-width: var(--content-max); margin: 0 auto; }
.shell-page { padding-top: var(--s-2); }
.shell-page > .ui-h1 { margin: var(--s-2) 0 var(--s-4); }
.shell-page--center { min-height: 60vh; display: grid; place-items: center; }
.shell-404-mark { color: var(--brand); display: inline-flex; }
.shell-error-actions { display: flex; flex-direction: column; gap: var(--s-2); width: 100%; }

/* Dock */
.shell-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-dock);
  height: calc(var(--dock-h) + var(--safe-bottom)); padding: 0 var(--s-2) var(--safe-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
  background: var(--surface-raised); border-top: 1px solid var(--line);
  view-transition-name: shell-dock;
}
.shell-pill {
  position: absolute; top: 0; left: var(--s-2); width: calc((100% - var(--s-2) * 2) / 5); height: 3px;
  transform: translateX(calc(var(--tab-i) * 100%)); transition: transform var(--dur-4) var(--spring-snappy);
  pointer-events: none; view-transition-name: shell-pill;
}
.shell-pill::before { content: ""; position: absolute; left: 50%; top: 0; width: 20px; height: 3px; margin-left: -10px; border-radius: 0 0 3px 3px; background: var(--brand-strong); }
.shell-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tap-md); color: var(--muted); transition: color var(--dur-2) var(--ease-standard), transform var(--dur-1) var(--ease-standard);
}
.shell-tab:active { transform: scale(.94); }
.shell-tab.is-active { color: var(--brand-strong); }
.shell-tab-icon { display: inline-flex; }
.shell-tab-label { font-size: 11px; line-height: 13px; font-weight: 650; letter-spacing: .01em; }
.shell-go { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0; color: var(--muted); }
.shell-go-disc {
  position: relative; width: var(--dock-disc); height: var(--dock-disc); margin-top: -14px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 0 0 3px var(--bg); transition: transform var(--dur-1) var(--ease-standard);
}
.shell-go-disc::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: var(--glow-brand); opacity: 0; transition: opacity var(--dur-3) var(--ease-standard); }
.shell-go:active .shell-go-disc { transform: scale(.94); }
.shell-go.is-active { color: var(--brand-strong); }
.shell-go.is-active .shell-go-disc::after, .shell-go:hover .shell-go-disc::after { opacity: 1; }

/* Rail (≥ 960 px) */
.shell-rail { display: none; }
[data-viewport="wide"] .shell--tabs, [data-viewport="wide"] .shell--drill,
[data-viewport="xl"] .shell--tabs, [data-viewport="xl"] .shell--drill { padding-bottom: var(--s-6); padding-left: var(--rail-w); }
[data-viewport="wide"] .shell-rail, [data-viewport="xl"] .shell-rail {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: var(--z-dock); width: var(--rail-w);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: calc(var(--safe-top) + var(--s-3)) 0 var(--s-4);
  background: var(--surface-raised); border-right: 1px solid var(--line); view-transition-name: shell-dock;
}
.shell-rail-brand { color: var(--brand); width: var(--tap); height: var(--tap); display: grid; place-items: center; margin-bottom: var(--s-2); }
.shell-rail .shell-tab { width: 72px; min-height: 64px; border-radius: var(--r-md); }
.shell-rail .shell-tab.is-active { background: var(--brand-soft); }
.shell-go--rail { margin: 4px 0 var(--s-3); }
.shell-go--rail .shell-go-disc { margin-top: 0; width: 64px; height: 64px; box-shadow: none; }

/* View transitions (choreography A / B). Never on #/run (router skips it).
   Sequential, never overlapping: the old content is gone (90 ms) before the
   new content starts (at 90 ms), so two screens never show through each
   other. The dock and pill stay put; the context bar swaps in place on tab
   switches and fades out → in on push/back (its title changes). */
::view-transition-group(shell-dock) { animation: none; }
::view-transition-old(shell-dock) { display: none; }
::view-transition-new(shell-dock) { animation: none; }
::view-transition-group(shell-pill) { animation-duration: var(--spring-snappy-dur, 330ms); animation-timing-function: var(--spring-snappy); }
html[data-vt="tab"]::view-transition-group(shell-bar) { animation: none; }
html[data-vt="tab"]::view-transition-old(shell-bar) { display: none; }
html[data-vt="tab"]::view-transition-new(shell-bar) { animation: none; }
html[data-vt="push"]::view-transition-group(shell-bar), html[data-vt="back"]::view-transition-group(shell-bar) { animation: none; }
html[data-vt="push"]::view-transition-old(shell-bar), html[data-vt="back"]::view-transition-old(shell-bar) { animation: vt-out 90ms var(--ease-in) both; }
html[data-vt="push"]::view-transition-new(shell-bar), html[data-vt="back"]::view-transition-new(shell-bar) { animation: vt-fade-in 150ms var(--ease-out) 90ms both; }
html[data-vt="tab"]::view-transition-old(root) { animation: vt-out 90ms var(--ease-in) both; }
html[data-vt="tab"]::view-transition-new(root) { animation: vt-in-r12 180ms var(--ease-out) 90ms both; }
html[data-vt="tab"][data-vt-dir="-1"]::view-transition-new(root) { animation-name: vt-in-l12; }
html[data-vt="push"]::view-transition-old(root) { animation: vt-out-scale 90ms var(--ease-in) both; }
html[data-vt="push"]::view-transition-new(root) { animation: vt-in-r24 210ms var(--ease-out) 90ms both; }
html[data-vt="back"]::view-transition-old(root) { animation: vt-out-scale 90ms var(--ease-in) both; }
html[data-vt="back"]::view-transition-new(root) { animation: vt-in-l24 210ms var(--ease-out) 90ms both; }
html[data-vt="fade"]::view-transition-old(root) { animation: vt-out 120ms linear both; }
html[data-vt="fade"]::view-transition-new(root) { animation: vt-fade-in 120ms linear both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-out-scale { to { opacity: 0; transform: scale(.985); } }
@keyframes vt-fade-in { from { opacity: 0; } }
@keyframes vt-in-r12 { from { opacity: 0; transform: translateX(12px); } }
@keyframes vt-in-l12 { from { opacity: 0; transform: translateX(-12px); } }
@keyframes vt-in-r24 { from { opacity: 0; transform: translateX(24px); } }
@keyframes vt-in-l24 { from { opacity: 0; transform: translateX(-24px); } }

/* ---------- Buttons ---------- */
.ui-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5); border-radius: var(--r-md); border: 1px solid transparent;
  font-size: var(--fs-body); font-weight: 650; line-height: 1.15; text-align: center;
  transition: transform var(--dur-1) var(--ease-standard), background-color var(--dur-2) var(--ease-standard), opacity var(--dur-2);
}
.ui-btn:active:not(:disabled) { transform: scale(.96); }
.ui-btn:disabled { opacity: .45; }
.ui-btn--full { width: 100%; }
.ui-btn--lg { min-height: var(--tap-md); border-radius: var(--r-md); }
.ui-btn--xl { min-height: var(--tap-lg); border-radius: var(--r-lg); font-size: 19px; font-weight: 700; padding: 0 var(--s-6); }
.ui-btn--primary { background: var(--brand); color: var(--brand-ink); }
.ui-btn--primary::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: var(--glow-brand); opacity: .55; pointer-events: none; transition: opacity var(--dur-3); }
.ui-btn--primary:hover::after { opacity: 1; }
.ui-btn--primary:disabled::after { opacity: 0; }
.ui-btn--secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.ui-btn--ghost { background: transparent; color: var(--brand-strong); }
.ui-btn--danger { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.ui-btn-label { min-width: 0; }
.ui-btn .ui-icon { flex: none; }
.ui-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: ui-spin .7s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

.ui-icon-btn {
  position: relative; width: var(--tap); height: var(--tap); flex: none; display: grid; place-items: center; border-radius: 50%; color: inherit;
  transition: background-color var(--dur-2), transform var(--dur-1);
}
.ui-icon-btn:active { transform: scale(.92); background: var(--highlight); }
.ui-badge-dot { position: absolute; top: 9px; right: 9px; min-width: 9px; height: 9px; border-radius: var(--r-pill); background: var(--kudos); box-shadow: 0 0 0 2px var(--bg); font-size: 0; }

.ui-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); padding: 0 4px; color: var(--brand-strong); font-size: var(--fs-small); font-weight: 650; }

/* ---------- Chips + segmented ---------- */
.ui-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
  font-size: var(--fs-small); font-weight: 600; white-space: nowrap;
  transition: transform var(--dur-1), background-color var(--dur-2), color var(--dur-2), border-color var(--dur-2);
}
button.ui-chip::before { content: ""; position: absolute; inset: -6px -2px; } /* ≥ 48 px hit area */
button.ui-chip:active { transform: scale(.96); }
.ui-chip.is-selected { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand-line); }
.ui-chip--tone { color: var(--chip-tone); border-color: color-mix(in srgb, var(--chip-tone) 35%, transparent); background: color-mix(in srgb, var(--chip-tone) 12%, transparent); }
.ui-chip--static { cursor: default; }

.ui-seg {
  position: relative; display: grid; grid-template-columns: repeat(var(--seg-n), 1fr);
  padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line);
}
.ui-seg-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--seg-n));
  border-radius: var(--r-pill); background: var(--surface-raised); box-shadow: var(--shadow-1);
  transform: translateX(calc(var(--seg-i) * 100%)); transition: transform var(--dur-4) var(--spring-snappy);
}
[data-theme="dark"] .ui-seg-thumb, [data-theme="dark"].ui-seg-thumb { background: var(--surface-3); box-shadow: inset 0 1px 0 var(--highlight); }
.ui-seg-opt { position: relative; z-index: 1; min-height: 40px; padding: 0 var(--s-3); border-radius: var(--r-pill); font-size: var(--fs-small); font-weight: 650; color: var(--muted); transition: color var(--dur-2); }
.ui-seg-opt[aria-checked="true"] { color: var(--ink); }
.ui-seg-opt::before { content: ""; position: absolute; inset: -4px 0; }
.ui-seg--sm .ui-seg-opt { min-height: 32px; font-size: var(--fs-label); }

/* ---------- Banners ---------- */
.ui-banner {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 6px 8px 14px; border-radius: var(--r-sm);
  font-size: var(--fs-small); line-height: 1.35; font-weight: 550; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.ui-banner > .ui-icon { flex: none; }
.ui-banner-text { flex: 1 1 auto; min-width: 0; }
.ui-banner-action { flex: none; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.ui-banner--nodata, .ui-banner--permission { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.ui-banner--demo {
  background: var(--info-soft); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 30%, transparent);
  font-family: var(--font-num); font-weight: 700; letter-spacing: .035em; text-transform: uppercase; font-size: 13px; line-height: 1.2;
  min-height: 36px; padding-top: 6px; padding-bottom: 6px;
}
.ui-banner--rollup { background: var(--info-soft); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.ui-banner--beta { background: var(--violet-soft); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 25%, transparent); }
.ui-banner--ghost { background: var(--surface-2); color: var(--ink-2); }

/* ---------- Empty state ---------- */
.ui-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: var(--s-7) var(--s-4); max-width: 420px; margin: 0 auto; }
.ui-empty-art { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); margin-bottom: var(--s-2); }
.ui-empty-title { font-size: var(--fs-h2); line-height: 1.3; font-weight: 700; }
.ui-empty-body { color: var(--ink-2); font-size: var(--fs-small); }
.ui-empty-cta { margin-top: var(--s-3); width: 100%; display: flex; justify-content: center; }

/* ---------- Avatar ---------- */
.ui-avatar {
  position: relative; flex: none; width: var(--sz); height: var(--sz); border-radius: 50%;
  display: inline-grid; place-items: center; background: var(--av); color: var(--av-ink);
  font-weight: 750; letter-spacing: .02em; line-height: 1;
}
.ui-avatar.is-ghost { background: transparent; color: var(--av); border: 1.5px dashed var(--av); }
.ui-avatar.is-ghost .ui-avatar-txt { opacity: 0; }
.ui-avatar-ghost { position: absolute; inset: 0; display: grid; place-items: center; }
.ui-avatar-anon { display: inline-flex; opacity: .85; }
.ui-avatar[style*="--av-ring"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--av-ring); }

/* ---------- Skeleton ---------- */
.ui-skel { display: block; position: relative; overflow: hidden; background: var(--surface-2); }
.ui-skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--highlight), transparent);
  animation: ui-shimmer 1.4s var(--ease-inout) infinite;
}
@keyframes ui-shimmer { to { transform: translateX(100%); } }

/* ---------- Cards + tiles ---------- */
.ui-card {
  display: block; width: 100%; text-align: left; position: relative; contain: layout paint;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-4);
  box-shadow: inset 0 1px 0 var(--highlight);
}
[data-theme="light"] .ui-card, [data-theme="light"].ui-card { box-shadow: var(--shadow-1); border-color: transparent; }
.ui-card--btn { transition: transform var(--dur-1) var(--ease-standard); }
.ui-card--btn:active { transform: scale(.985); }
.ui-section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin: var(--s-5) 0 var(--s-2); }

.ui-tile {
  position: relative; display: flex; flex-direction: column; gap: 4px; min-height: 96px; width: 100%; text-align: left;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--highlight); contain: layout paint;
}
[data-theme="light"] .ui-tile { box-shadow: var(--shadow-1); border-color: transparent; }
.ui-tile--btn { transition: transform var(--dur-1); padding-right: 36px; }
.ui-tile--btn:active { transform: scale(.97); }
.ui-tile-label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-label); font-weight: 650; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); }
.ui-tile-value { font-family: var(--font-num); font-size: var(--fs-stat); font-weight: 600; line-height: 1; letter-spacing: .005em; }
.ui-tile-unit { font-size: .45em; color: var(--muted); margin-left: .12em; font-weight: 600; letter-spacing: .04em; }
.ui-tile-sub { font-size: var(--fs-label); color: var(--muted); }
.ui-tile-chev { position: absolute; right: 12px; top: 50%; margin-top: -9px; color: var(--faint); }

/* ---------- Chyron (moments only) ---------- */
.ui-chyron {
  display: inline-block; transform: skewX(var(--skew)); padding: 6px 14px 6px 12px;
  background: var(--surface-3); border-left: 4px solid var(--chy); border-radius: 2px;
}
.ui-chyron-txt { display: inline-block; transform: skewX(calc(var(--skew) * -1)); font-family: var(--font-num); font-weight: 700; font-size: 18px; line-height: 1; letter-spacing: var(--track-chyron); text-transform: uppercase; color: var(--ink); }

/* ---------- Toggle ---------- */
.ui-toggle { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap-md); padding: 6px 0; cursor: pointer; position: relative; }
.ui-toggle.is-disabled { opacity: .5; cursor: default; }
.ui-toggle-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ui-toggle-label { font-weight: 550; }
.ui-toggle-sub { font-size: var(--fs-label); color: var(--muted); }
.ui-toggle-input { position: absolute; opacity: 0; width: 52px; height: 32px; right: 0; margin: 0; cursor: pointer; }
.ui-toggle-track { flex: none; width: 52px; height: 32px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; transition: background-color var(--dur-2); }
.ui-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); transition: transform var(--dur-3) var(--spring-snappy); }
.ui-toggle-input:checked + .ui-toggle-track { background: var(--brand); border-color: var(--brand); }
.ui-toggle-input:checked + .ui-toggle-track .ui-toggle-thumb { transform: translateX(20px); background: var(--brand-ink); }
.ui-toggle-input:focus-visible + .ui-toggle-track { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Fields + inputs ---------- */
.ui-field { position: relative; display: grid; gap: 6px; }
.ui-field-label { font-size: var(--fs-label); font-weight: 650; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); }
.ui-input, .ui-select {
  width: 100%; height: var(--tap-md); padding: 0 var(--s-4); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong);
  font-size: var(--fs-body); appearance: none; -webkit-appearance: none;
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
.ui-input::placeholder { color: var(--faint); }
.ui-input:focus, .ui-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ui-field.is-error .ui-input { border-color: var(--bad); }
.ui-field-error { font-size: var(--fs-label); color: var(--bad); }
.ui-field-hint { font-size: var(--fs-label); color: var(--muted); }
.ui-field--select .ui-select { padding-right: 44px; cursor: pointer; }
.ui-select-chev { position: absolute; right: 14px; bottom: 18px; color: var(--muted); pointer-events: none; }
.ui-monthyear { display: grid; grid-template-columns: 1.35fr 1fr; gap: var(--s-3); }
.ui-monthyear .ui-select { height: 64px; font-size: 19px; font-weight: 600; }
.ui-monthyear .ui-select-chev { bottom: 22px; }
.ui-postal { display: grid; gap: var(--s-3); }
.ui-handle { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-strong); }
.ui-handle-name { font-family: var(--font-num); font-size: 28px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ui-code { position: relative; display: block; }
.ui-code-input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.01; font-size: 16px; color: transparent; caret-color: transparent;
  border: 0; background: transparent; z-index: 1; letter-spacing: 2em;
}
.ui-code-boxes { display: grid; grid-template-columns: repeat(var(--len), 1fr); gap: var(--s-2); }
.ui-code-box {
  height: 64px; border-radius: var(--r-sm); background: var(--surface-2); border: 1.5px solid var(--line-strong);
  display: grid; place-items: center; font-family: var(--font-num); font-size: 34px; font-weight: 700; color: var(--ink);
  transition: border-color var(--dur-2), transform var(--dur-2) var(--spring-pop);
}
.ui-code-box::after { content: attr(data-ch); }
.ui-code-box:not([data-ch=""]) { border-color: var(--line-strong); background: var(--surface-3); }
.ui-code:focus-within .ui-code-box[data-on="1"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ui-code.is-error .ui-code-box { border-color: var(--bad); }

/* ---------- BigNumber (bw-number) ---------- */
bw-number { display: inline-block; font-family: var(--font-num); font-weight: 700; line-height: 1; color: var(--ink); font-variant-numeric: lining-nums; }
bw-number[size="hero"] { font-size: var(--fs-hero); }
bw-number[size="display"] { font-size: var(--fs-display); }
bw-number[size="stat"] { font-size: var(--fs-stat); font-weight: 600; }
bw-number[size="tile"] { font-size: 28px; font-weight: 600; }
bw-number[tone="pb"] { color: var(--gold-hi); }
[data-theme="light"] bw-number[tone="pb"] { color: var(--gold-ink); }
bw-number[tone="muted"] { color: var(--muted); }
bw-number[state="pending"] .ui-num-digits { opacity: .35; }
.ui-num-row { display: inline-flex; align-items: baseline; transform-origin: 50% 70%; }
bw-number[unit-pos="below"] .ui-num-row { flex-direction: column; align-items: center; }
.ui-num-digits { display: inline-flex; align-items: flex-end; line-height: 1; }
.ui-num-cell { display: inline-block; width: var(--digit-w); height: 1em; overflow: hidden; line-height: 1; }
.ui-num-cell.is-dec, .ui-num-sep.is-dec { font-size: .62em; margin-bottom: .11em; }
.ui-num-strip { display: flex; flex-direction: column; transform: translateY(0); }
.ui-num-strip > span { display: block; height: 1em; line-height: 1; text-align: center; }
/* a count-up in flight: digit cells fade at their top and bottom edges, so
   in-between frames read as motion rather than stacked half digits */
bw-number.is-rolling .ui-num-cell { -webkit-mask-image: linear-gradient(transparent, black 22%, black 78%, transparent); mask-image: linear-gradient(transparent, black 22%, black 78%, transparent); }
.ui-num-sep { display: inline-block; line-height: 1; height: 1em; }
.ui-num-sep.is-dec:first-child, .ui-num-sep.is-dec { width: .26em; text-align: center; }
.ui-num-unit { font-size: .28em; font-weight: 600; color: var(--muted); letter-spacing: .06em; margin-left: .08em; line-height: 1; }
bw-number[unit-pos="below"] .ui-num-unit { margin: .1em 0 0; font-size: .2em; letter-spacing: .14em; text-transform: uppercase; }

/* ---------- Ring (bw-ring) ---------- */
bw-ring { display: inline-block; }
.ui-ring { position: relative; width: var(--sz); height: var(--sz); }
.ui-ring-svg { width: 100%; height: 100%; }
.ui-ring-tick { stroke: var(--line-strong); stroke-width: 1.6; stroke-linecap: round; opacity: .7; transition: stroke 180ms var(--ease-standard), opacity 180ms var(--ease-standard); }
.ui-ring-tick.is-major { stroke-width: 2.2; }
.ui-ring-tick.is-on { stroke: var(--tick); opacity: 1; }
bw-ring[dashed] .ui-ring-tick.is-on { opacity: .55; }
.ui-ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }

/* ---------- Tier emblem ---------- */
.ui-emblem { position: relative; display: inline-grid; place-items: center; width: var(--sz); height: var(--sz); color: var(--tc); flex: none; }
.ui-emblem svg { width: 100%; height: 100%; position: relative; }
.ui-emblem-rays line { stroke: currentColor; stroke-linecap: round; }
.ui-emblem-core { fill: currentColor; }
.ui-emblem-core-hi { fill: var(--ink); opacity: .55; }
.ui-emblem-ring { fill: none; stroke: currentColor; stroke-width: 2; opacity: .45; }
.ui-emblem-glow { fill: currentColor; opacity: .22; }
.ui-emblem.is-locked { color: var(--faint); }
.ui-emblem.is-locked .ui-emblem-core { fill: none; stroke: currentColor; stroke-width: 2.5; }
.ui-emblem.is-silhouette { color: var(--ink); opacity: .2; }
.ui-emblem-halo {
  position: absolute; inset: -14%; border-radius: 50%; background: var(--tier-supernova-fx); opacity: .45;
  -webkit-mask: radial-gradient(circle, black 22%, transparent 68%); mask: radial-gradient(circle, black 22%, transparent 68%);
}
.ui-emblem.is-revealing .ui-emblem-halo { animation: ui-spin 20s linear infinite; }

/* ---------- Hold button (bw-hold) ---------- */
bw-hold { display: block; }
.ui-hold {
  position: relative; overflow: hidden; width: 100%; min-height: var(--tap-lg); padding: 0 var(--s-5);
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink);
  font-weight: 650; -webkit-touch-callout: none; touch-action: none;
}
.ui-hold-fill {
  position: absolute; left: 50%; top: 50%; width: 140%; aspect-ratio: 1; margin: -70% 0 0 -70%; border-radius: 50%;
  background: color-mix(in srgb, var(--hold-tone) 28%, transparent); transform: scale(0); transition: transform 160ms var(--ease-in);
}
.ui-hold.is-filling .ui-hold-fill { transform: scale(1); transition: transform var(--hold-ms) linear; }
.ui-hold.is-fired .ui-hold-fill { transform: scale(1); background: color-mix(in srgb, var(--hold-tone) 45%, transparent); }
.ui-hold > :not(.ui-hold-fill) { position: relative; }

/* ---------- Sheet ---------- */
.ui-sheet-scrim { position: fixed; inset: 0; z-index: var(--z-sheet); background: var(--scrim); }
.ui-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; z-index: var(--z-sheet); max-width: 640px;
  max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface-raised); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-2);
  border: 1px solid var(--line); border-bottom: 0; padding-bottom: var(--safe-bottom); outline: none;
}
.ui-sheet--half { min-height: 50vh; min-height: 50dvh; }
.ui-sheet--full { height: 92vh; height: 92dvh; }
.ui-sheet-grab { flex: none; padding: 8px var(--s-2) 0 var(--gutter); touch-action: none; cursor: grab; }
.ui-sheet-handle { display: block; width: 36px; height: 5px; border-radius: var(--r-pill); background: var(--line-strong); margin: 0 auto 4px; }
.ui-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: var(--tap); }
.ui-sheet-title { font-size: var(--fs-h2); line-height: 1.3; font-weight: 700; }
.ui-sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-2) var(--gutter) var(--s-5); }

/* ---------- Modal ---------- */
.ui-modal-host { position: fixed; inset: 0; z-index: calc(var(--z-sheet) + 2); display: grid; place-items: center; pointer-events: none; padding: var(--gutter); }
.ui-modal-host:empty { display: none; }
.ui-modal-scrim { position: absolute; inset: 0; background: var(--scrim-strong); pointer-events: auto; }
.ui-modal {
  position: relative; pointer-events: auto; width: min(400px, 100%); padding: var(--s-5); border-radius: var(--r-lg);
  background: var(--surface-raised); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.ui-modal-title { font-size: var(--fs-h2); line-height: 1.3; font-weight: 700; }
.ui-modal-body { color: var(--ink-2); font-size: var(--fs-small); }
.ui-modal-actions { display: flex; flex-direction: column-reverse; gap: var(--s-2); margin-top: var(--s-2); }

/* ---------- Toast ---------- */
.ui-toast-region {
  position: fixed; left: 0; right: 0; z-index: var(--z-toast); pointer-events: none;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + var(--s-4)); display: flex; justify-content: center; padding: 0 var(--gutter);
}
[data-shell="full"] .ui-toast-region { bottom: calc(var(--safe-bottom) + var(--s-5)); }
.ui-toast {
  display: inline-flex; align-items: center; gap: 10px; max-width: 480px; min-height: 48px; padding: 12px 18px;
  border-radius: var(--r-md); background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2); font-size: var(--fs-small); font-weight: 600; pointer-events: auto;
  animation: ui-toast-in var(--dur-4) var(--spring-pop) both;
}
.ui-toast.is-leaving { animation: ui-toast-out 200ms var(--ease-in) both; }
.ui-toast--good .ui-icon { color: var(--good); }
.ui-toast--warn .ui-icon { color: var(--warn-ink); }
.ui-toast--bad .ui-icon { color: var(--bad); }
.ui-toast--brand .ui-icon { color: var(--brand-strong); }
@keyframes ui-toast-in { from { opacity: 0; transform: translateY(calc(16px * var(--motion))); } }
@keyframes ui-toast-out { to { opacity: 0; transform: translateY(calc(8px * var(--motion))); } }

/* ---------- FX ---------- */
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: var(--z-fx); }
.fx-ring { position: fixed; border: 2px solid var(--brand); border-radius: 50%; pointer-events: none; z-index: var(--z-fx); opacity: 0; }
.fx-rays { position: fixed; pointer-events: none; z-index: var(--z-fx); opacity: 0; }
.fx-frame { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-fx); opacity: 0; }
.fx-go {
  position: fixed; inset: 0; z-index: var(--z-go); pointer-events: none; opacity: 0;
  display: grid; place-items: center; background: var(--go-flash); contain: strict;
}
.fx-go[data-mode="lab"] { background: var(--sync-flash); }
.fx-go-label { font-family: var(--font-num); font-weight: 800; font-size: 40vw; line-height: .8; letter-spacing: .02em; color: var(--go-ink); }

/* ---------- FootHeat (bw-foot-heat) ---------- */
bw-foot-heat { display: inline-block; }
.ui-fh { position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 6px; }
.ui-fh-svg { width: var(--fh-w); height: var(--fh-h); overflow: visible; }
.ui-fh-fill { fill: var(--surface-2); }
.ui-fh-dot { fill: var(--line-strong); }
.ui-fh-perf { opacity: .55; }
.ui-fh-outline { fill: none; stroke: var(--line-strong); stroke-width: 2.5; vector-effect: non-scaling-stroke; transition: stroke var(--dur-3) var(--ease-standard); }
.ui-fh-foot.is-live .ui-fh-outline { stroke: var(--brand-line); }
.ui-fh-foot.is-missing .ui-fh-outline { stroke-dasharray: 5 6; stroke: var(--faint); }
.ui-fh-foot.is-unneeded { opacity: .28; }
.ui-fh-foot { transition: opacity var(--dur-3) var(--ease-standard); }
.ui-fh-foot.is-dim { opacity: .35; }
.ui-fh.is-waiting .ui-fh-foot.is-missing .ui-fh-fill { animation: ui-fh-breathe 2.4s var(--ease-inout) infinite alternate; }
@keyframes ui-fh-breathe { from { opacity: .55; } to { opacity: 1; } }
.ui-fh-labels { display: flex; justify-content: space-between; width: calc(var(--fh-w) * .82); font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 600; color: var(--faint); }
.ui-fh-labels .is-live { color: var(--brand-strong); }

/* ---------- Streak flame (bw-streak-flame) ---------- */
bw-streak-flame { display: inline-flex; }
.ui-flame { display: inline-grid; place-items: center; width: var(--sz); height: var(--sz); }
.ui-flame svg { width: 100%; height: 100%; overflow: visible; }
.ui-flame-p { transform-box: fill-box; transform-origin: 50% 100%; }
.ui-flame-p1 { fill: var(--f1, var(--flame)); animation: ui-flick 1.6s var(--ease-inout) infinite alternate; }
.ui-flame-p2 { fill: var(--f2, var(--flame-core)); animation: ui-flick 1.9s var(--ease-inout) infinite alternate-reverse; }
.ui-flame-p3 { fill: var(--f3, var(--gold-hi)); animation: ui-flick 2.3s var(--ease-inout) infinite alternate; }
@keyframes ui-flick {
  0% { transform: scaleY(1) skewX(0deg); }
  33% { transform: scaleY(1.06) skewX(2deg); }
  66% { transform: scaleY(.98) skewX(-2deg); }
  100% { transform: scaleY(1) skewX(1deg); }
}
.ui-flame--teal { --f3: var(--brand); }
.ui-flame--blue { --f1: var(--info); --f2: var(--ice); --f3: var(--ink); }
[data-theme="light"] .ui-flame--blue { --f3: color-mix(in srgb, var(--ice) 30%, var(--surface)); }
.ui-flame--violet { --f1: var(--violet); --f2: var(--kudos); --f3: var(--gold-hi); }
.ui-flame--risk { --f1: var(--muted); --f2: var(--faint); --f3: var(--ink-2); animation: ui-breathe 3s var(--ease-inout) infinite alternate; }
@keyframes ui-breathe { from { opacity: .55; } to { opacity: 1; } }
.ui-flame--frozen { --f1: color-mix(in srgb, var(--ice) 70%, transparent); --f2: var(--info-soft); --f3: var(--ice); }
.ui-flame--frozen .ui-flame-p { animation: none; }
.ui-flame-flake { fill: none; stroke: var(--ice); stroke-width: 1.6; stroke-linecap: round; }
.ui-flame--out .ui-flame-p1 { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-linejoin: round; animation: none; }
bw-streak-flame.is-offscreen .ui-flame-p, bw-streak-flame.is-offscreen .ui-flame { animation-play-state: paused; }
.shell-streak.is-out .shell-streak-n { color: var(--muted); }

/* ---------- Coachmark ---------- */
.ui-coach { position: fixed; inset: 0; z-index: calc(var(--z-dock) + 1); pointer-events: none; }
.ui-coach-ring { position: fixed; border-radius: 50%; border: 2px solid var(--brand); opacity: 0; animation: ui-coach-ring 1.8s var(--ease-out) infinite; }
.ui-coach-ring--2 { animation-delay: .9s; }
@keyframes ui-coach-ring { 0% { transform: scale(.9); opacity: .8; } 100% { transform: scale(1.7); opacity: 0; } }
.ui-coach-bubble {
  position: fixed; padding: 12px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--bg);
  font-size: var(--fs-small); font-weight: 650; line-height: 1.35; box-shadow: var(--shadow-2); text-align: center;
}
.ui-coach-bubble::after { content: ""; position: absolute; width: 14px; height: 14px; background: inherit; border-radius: 3px; transform: rotate(45deg); }
.ui-coach-bubble.is-above::after { bottom: -6px; left: calc(var(--arrow-x) - 7px); }
.ui-coach-bubble.is-below::after { top: -6px; left: calc(var(--arrow-x) - 7px); }
.ui-coach-bubble.is-right { transform: translateY(-50%); text-align: left; width: auto !important; max-width: 280px; }
.ui-coach-bubble.is-right::after { left: -6px; top: calc(50% - 7px); }

/* ---------- Shell banners + chips ---------- */
.shell-banners { display: grid; gap: var(--s-2); }
.shell-resume {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px; padding: 10px 10px 10px 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--brand-line); color: var(--ink); font-size: var(--fs-small); font-weight: 600;
}
.shell-resume-icon { color: var(--brand-strong); display: inline-flex; }
.shell-resume-actions { grid-column: 1 / -1; display: flex; gap: var(--s-2); justify-content: flex-end; }
.shell-resume-btn { min-height: var(--tap); padding: 0 var(--s-4); border-radius: var(--r-sm); font-weight: 700; color: var(--ink-2); }
.shell-resume-btn.is-primary { background: var(--brand); color: var(--brand-ink); }
.shell-notsaved {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: var(--fs-label); font-weight: 600;
}
.shell-notsaved-cta { display: inline-flex; align-items: center; gap: 2px; color: var(--brand-strong); font-weight: 700; }
.shell--full:has(.ui-banner--demo) .shell-demo-tag { display: none; } /* the page shows its own demo banner */
.shell-demo-tag {
  position: fixed; top: var(--safe-top); left: 50%; transform: translateX(-50%); z-index: var(--z-toast); pointer-events: none;
  padding: 1px 8px 2px; border-radius: 0 0 var(--r-xs) var(--r-xs); background: var(--info); color: var(--bg);
  font-family: var(--font-num); font-weight: 700; font-size: 10px; line-height: 11px; letter-spacing: var(--track-chyron);
}

/* ---------- Mark ---------- */
.ui-mark, .ui-icon, .ui-reaction { flex: none; }
[data-viewport="wide"] .shell-brand, [data-viewport="xl"] .shell-brand { visibility: hidden; }
