/* =====================================================================
   Safe — Facebook accounts & pages vault (English UI, LTR)
   Design system: design-system/safe/MASTER.md
   Generated with ui-ux-pro-max (scripts/search.py --design-system:
   category Password Manager, style Minimalism & Swiss, dials
   variance 3 · motion 3 · density 8) and audited against
   references/quick-reference.md.
   ===================================================================== */

:root {
  /* type: one modular scale (ux: font-scale) */
  --font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 15px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;
  --text-3xl: 24px;
  --text-4xl: 32px;
  --text-5xl: 48px;
  /* space: density-8 scale from the generator, on a 4/8 rhythm */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --sp-16: 64px;
  /* radius: generator component specs (buttons 8, cards 12, modals 16) */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  /* layering (ux: z-index-management) */
  --z-sticky: 10;
  --z-topbar: 20;
  --z-nav: 30;
  --z-popover: 40;
  --z-overlay: 60;
  --z-toast: 80;
  --z-tooltip: 100;
  --z-skip: 200;
  /* layout */
  --side-w: 264px;
  --top-h: 72px;
  --content-max: 1400px;
  /* motion: shared tokens, exits ~65% of enters (ux: exit-faster-than-enter) */
  --dur-1: 140ms;
  --dur-2: 200ms;
  --dur-3: 280ms;
  --dur-exit: 180ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
}

/* ---------- Dark (default) ---------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --page: #0C1424;
  --side: #0F1829;
  --surface: #141E33;
  --surface-2: #1A2640;
  --surface-3: #22304D;
  --field: #0F182B;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --line-3: rgba(255, 255, 255, .24);
  --ink-1: #EEF2F7;
  --ink-2: #B9C3D3;
  --ink-3: #8794AA;
  --brand: #2563EB;
  --brand-hover: #3A72EE;
  --brand-ink: #8AB4FF;
  --brand-soft: rgba(59, 130, 246, .14);
  --brand-line: rgba(138, 180, 255, .38);
  --ring: #8AB4FF;
  --info: #2563EB;
  --info-ink: #8AB4FF;
  --info-soft: rgba(59, 130, 246, .14);
  --info-line: rgba(138, 180, 255, .38);
  --info-on: #FFFFFF;
  --t1: #F05252;
  --t1-ink: #FCA5A5;
  --t1-soft: rgba(240, 82, 82, .14);
  --t1-line: rgba(240, 82, 82, .38);
  --t1-on: #0B0B0B;
  --t2: #FBBF24;
  --t2-ink: #FCD34D;
  --t2-soft: rgba(251, 191, 36, .13);
  --t2-line: rgba(251, 191, 36, .36);
  --t2-on: #0B0B0B;
  --t3: #2DD4BF;
  --t3-ink: #5EEAD4;
  --t3-soft: rgba(45, 212, 191, .13);
  --t3-line: rgba(45, 212, 191, .36);
  --t3-on: #0B0B0B;
  --bar: #3B82F6;
  --scrim: rgba(4, 8, 16, .66);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .36);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .48), 0 2px 8px rgba(0, 0, 0, .3);
  --tip-bg: #EEF2F7;
  --tip-ink: #0C1424;
}

/* ---------- Light (a full second palette, never an inversion) ---------- */
[data-theme="light"] {
  color-scheme: light;
  --page: #F3F5F9;
  --side: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F1F4F8;
  --surface-3: #E6EBF2;
  --field: #FFFFFF;
  --line: #E3E8EF;
  --line-2: #D3DAE4;
  --line-3: #B4BECC;
  --ink-1: #0F172A;
  --ink-2: #334155;
  --ink-3: #5B677A;
  --brand: #1D4ED8;
  --brand-hover: #1E40AF;
  --brand-ink: #1D4ED8;
  --brand-soft: rgba(29, 78, 216, .08);
  --brand-line: rgba(29, 78, 216, .32);
  --ring: #1D4ED8;
  --info: #1D4ED8;
  --info-ink: #1D4ED8;
  --info-soft: rgba(29, 78, 216, .08);
  --info-line: rgba(29, 78, 216, .32);
  --info-on: #FFFFFF;
  --t1: #C81E1E;
  --t1-ink: #B91C1C;
  --t1-soft: rgba(200, 30, 30, .08);
  --t1-line: rgba(200, 30, 30, .28);
  --t1-on: #FFFFFF;
  --t2: #C98500;
  --t2-ink: #8A4B00;
  --t2-soft: rgba(201, 133, 0, .10);
  --t2-line: rgba(201, 133, 0, .34);
  --t2-on: #0B0B0B;
  --t3: #0F766E;
  --t3-ink: #0F6B63;
  --t3-soft: rgba(15, 118, 110, .08);
  --t3-line: rgba(15, 118, 110, .28);
  --t3-on: #FFFFFF;
  --bar: #2563EB;
  --scrim: rgba(15, 23, 42, .42);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
  --shadow-lg: 0 20px 56px rgba(15, 23, 42, .16), 0 2px 8px rgba(15, 23, 42, .06);
  --tip-bg: #0F172A;
  --tip-ink: #F8FAFC;
}

/* ---------- YouTube ledger: red and white (YouTube's own UI colours, contrast-checked) ----------
   Red is the brand (buttons, active items, marks). Focus, links, info and charts use YouTube's
   blue, so red never doubles as an error signal next to the red "bad" status. */
[data-app="youtube"][data-theme="light"] {
  --page: #F9F9F9;
  --side: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F2F2F2;
  --surface-3: #E5E5E5;
  --field: #FFFFFF;
  --line: #E5E5E5;
  --line-2: #D9D9D9;
  --line-3: #BDBDBD;
  --ink-1: #0F0F0F;
  --ink-2: #3D3D3D;
  --ink-3: #606060;
  --brand: #E00000;
  --brand-hover: #CC0000;
  --brand-ink: #CC0000;
  --brand-soft: rgba(255, 0, 0, .07);
  --brand-line: rgba(204, 0, 0, .30);
  --yt-red: #FF0000;
  --ring: #065FD4;
  --link: #065FD4;
  --focus-line: rgba(6, 95, 212, .55);
  --focus-soft: rgba(6, 95, 212, .12);
  --info: #065FD4;
  --info-ink: #065FD4;
  --info-soft: rgba(6, 95, 212, .08);
  --info-line: rgba(6, 95, 212, .30);
  --info-on: #FFFFFF;
  --bar: #065FD4;
  --scrim: rgba(0, 0, 0, .45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .10);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .16), 0 2px 8px rgba(0, 0, 0, .06);
  --tip-bg: #282828;
  --tip-ink: #FFFFFF;
}
[data-app="youtube"][data-theme="dark"] {
  --page: #0F0F0F;
  --side: #0F0F0F;
  --surface: #1A1A1A;
  --surface-2: #242424;
  --surface-3: #303030;
  --field: #121212;
  --line: rgba(255, 255, 255, .10);
  --line-2: rgba(255, 255, 255, .16);
  --line-3: rgba(255, 255, 255, .26);
  --ink-1: #F1F1F1;
  --ink-2: #CFCFCF;
  --ink-3: #9E9E9E;
  --brand: #E00000;
  --brand-hover: #CC0000;
  --brand-ink: #FF4E45;
  --brand-soft: rgba(255, 0, 0, .16);
  --brand-line: rgba(255, 78, 69, .42);
  --yt-red: #FF0000;
  --ring: #3EA6FF;
  --link: #3EA6FF;
  --focus-line: rgba(62, 166, 255, .60);
  --focus-soft: rgba(62, 166, 255, .16);
  --info: #3EA6FF;
  --info-ink: #3EA6FF;
  --info-soft: rgba(62, 166, 255, .14);
  --info-line: rgba(62, 166, 255, .38);
  --info-on: #0B0B0B;
  --bar: #3EA6FF;
  --scrim: rgba(0, 0, 0, .70);
  --tip-bg: #F1F1F1;
  --tip-ink: #0F0F0F;
}

/* tier / status scopes: every coloured element reads these four vars */
.t1, .bad  { --tier: var(--t1); --tier-ink: var(--t1-ink); --tier-soft: var(--t1-soft); --tier-line: var(--t1-line); --tier-on: var(--t1-on); }
.t2, .warn { --tier: var(--t2); --tier-ink: var(--t2-ink); --tier-soft: var(--t2-soft); --tier-line: var(--t2-line); --tier-on: var(--t2-on); }
.t3, .good { --tier: var(--t3); --tier-ink: var(--t3-ink); --tier-soft: var(--t3-soft); --tier-line: var(--t3-line); --tier-on: var(--t3-on); }
.t0, .muted-tone { --tier: var(--ink-3); --tier-ink: var(--ink-3); --tier-soft: var(--surface-2); --tier-line: var(--line-2); --tier-on: var(--ink-1); }
.info-tone { --tier: var(--info); --tier-ink: var(--info-ink); --tier-soft: var(--info-soft); --tier-line: var(--info-line); --tier-on: var(--info-on); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* ux: focus-not-obscured: keyboard focus never lands under the sticky bar */
  scroll-padding-top: calc(var(--top-h) + var(--sp-4));
  scroll-padding-bottom: var(--sp-4);
}
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink-1);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.has-overlay { overflow: hidden; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
a { color: var(--link, var(--brand-ink)); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
a, button, input, select, textarea, label, summary { touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; }
svg.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: rgba(59, 130, 246, .3); }
* { scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
[hidden] { display: none !important; }

.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; }
.mono { font-family: var(--mono); font-size: .9em; letter-spacing: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.skip { position: absolute; inset-inline-start: var(--sp-3); top: -64px; z-index: var(--z-skip); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm); background: var(--brand); color: #fff; }
.skip:focus { top: var(--sp-3); }

/* ledger labels: Plex Mono, uppercase (as in earnflow) */
.nav-label, .data th, .fs legend, .dw-sec > h3, .ac-pages-h, .sp-group, .flag-row .lbl, .matrix thead th {
  font-family: var(--mono);
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  background: var(--side);
  border-inline-end: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-2) var(--sp-5); }
.brand-mark {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--brand); color: #fff;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-size: var(--text-2xl); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub { font-size: var(--text-xs); color: var(--ink-3); line-height: 1.4; }

.nav-label { padding: var(--sp-3) var(--sp-3) var(--sp-2); color: var(--ink-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  height: 44px; padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  color: var(--ink-2); font-size: var(--text-md); font-weight: 500;
  text-decoration: none;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink-1); }
.nav a:active { background: var(--surface-3); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink-1); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute;
  inset-inline-start: calc(var(--sp-4) * -1); top: 10px; bottom: 10px; width: 3px;
  border-start-end-radius: 3px; border-end-end-radius: 3px;
  background: var(--brand-ink);
}
.nav a[aria-current="page"] svg.ic { color: var(--brand-ink); }
.count {
  margin-inline-start: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  background: var(--surface-3); color: var(--ink-2);
  font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1;
}
.count.is-alert { background: var(--t1-soft); color: var(--t1-ink); box-shadow: inset 0 0 0 1px var(--t1-line); }
.count:empty { display: none; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4) var(--sp-1) 0; border-top: 1px solid var(--line); }
.privacy-note { display: flex; gap: var(--sp-2); padding: 0 var(--sp-2); font-size: var(--text-xs); line-height: 1.55; color: var(--ink-3); }
.privacy-note svg.ic { width: 16px; height: 16px; margin-top: 1px; color: var(--t3-ink); }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 0 var(--sp-1) 0 var(--sp-2); }
.save-state { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-xs); color: var(--ink-3); }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--t3); box-shadow: 0 0 0 3px var(--t3-soft); transition: background var(--dur-2); }
.save-state.saving .save-dot { background: var(--t2); box-shadow: 0 0 0 3px var(--t2-soft); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
/* solid bar: blur is reserved for dismissible overlays (ux: blur-purpose) */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--sp-4);
  min-height: var(--top-h); padding: var(--sp-3) var(--sp-8);
  background: var(--page);
  border-bottom: 1px solid var(--line);
}
.tb-title { min-width: 0; margin-inline-end: auto; }
.tb-title h1 { font-size: var(--text-2xl); font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.tb-title p { font-size: var(--text-sm); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-actions { display: flex; align-items: center; gap: var(--sp-2); }
.only-mobile { display: none !important; }

main { width: 100%; max-width: var(--content-max); margin-inline: auto; padding: var(--sp-6) var(--sp-8) var(--sp-16); outline: none; }
/* main only receives focus to move screen readers after a route change; no ring on the whole region */
main:focus, main:focus-visible { outline: none; }
/* one subtle fade on route change (motion dial 3; ux: excessive-motion, continuity) */
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
main.is-entering { animation: enter var(--dur-3) var(--ease-out) both; }

/* ---------- Command palette / global search ---------- */
.search { position: relative; width: min(440px, 36vw); }
.search .lead { position: absolute; inset-inline-start: var(--sp-3); top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 40px;
  padding-inline: 40px 64px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--field); color: var(--ink-1);
  font-size: var(--text-md);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--focus-line, var(--brand-line)); box-shadow: 0 0 0 3px var(--focus-soft, var(--brand-soft)); }
.kbd {
  position: absolute; inset-inline-end: var(--sp-2); top: 50%; transform: translateY(-50%);
  padding: 4px 6px; border-radius: var(--r-xs);
  border: 1px solid var(--line-2); background: var(--surface-2);
  font-family: var(--mono); font-size: var(--text-2xs); line-height: 1; color: var(--ink-3);
  pointer-events: none;
}
.search-pop {
  position: absolute; top: calc(100% + var(--sp-2)); inset-inline: 0; z-index: var(--z-popover);
  max-height: min(520px, 70vh); overflow: auto;
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.sp-group { padding: var(--sp-2) var(--sp-2) var(--sp-1); color: var(--ink-3); }
.sp-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-2);
  border: 0; border-radius: var(--r-sm); background: transparent;
  text-align: start; cursor: pointer;
}
.sp-item[aria-selected="true"], .sp-item:hover { background: var(--surface-2); }
.sp-item:active { background: var(--surface-3); }
.sp-main { flex: 1; min-width: 0; }
.sp-title { display: block; font-size: var(--text-md); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-sub { display: block; font-size: var(--text-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-empty { padding: var(--sp-5) var(--sp-3); text-align: center; font-size: var(--text-sm); color: var(--ink-3); }
.sp-empty b { display: block; margin-bottom: var(--sp-1); font-size: var(--text-md); color: var(--ink-1); font-weight: 600; }
.sp-ic { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); }
.sp-ic svg.ic { width: 16px; height: 16px; }
.sp-hint { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: flex-end; margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-2) var(--sp-1); border-top: 1px solid var(--line); font-size: var(--text-2xs); color: var(--ink-3); }
.sp-hint kbd { margin-inline-end: var(--sp-1); padding: 1px 5px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--surface-2); font-family: var(--mono); font-size: var(--text-2xs); }

/* ---------- Buttons ---------- */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--h); padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent;
  font-size: var(--text-md); font-weight: 500; line-height: 1;
  white-space: nowrap; cursor: pointer;
  text-decoration: none !important;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: var(--surface-2); border-color: var(--line-2); color: var(--ink-1); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-3); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink-1); }
.btn-danger { background: var(--t1); color: var(--t1-on); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.07); }
.btn-soft-danger { background: var(--t1-soft); border-color: var(--t1-line); color: var(--t1-ink); }
.btn-soft-danger:hover:not(:disabled) { background: var(--t1-line); }
.btn-sm { --h: 32px; padding: 0 var(--sp-3); gap: 6px; font-size: var(--text-sm); }
.btn-sm svg.ic { width: 16px; height: 16px; }
.btn-lg { --h: 48px; padding: 0 var(--sp-5); font-size: var(--text-base); }
.btn-block { width: 100%; }
.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2);
  cursor: pointer;
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink-1); }
.icon-btn:active { background: var(--surface-3); }
.icon-btn.bordered { border-color: var(--line-2); background: var(--surface-2); }
.icon-btn.danger:hover { background: var(--t1-soft); color: var(--t1-ink); }
.link-btn {
  padding: 0; border: 0; background: none;
  color: var(--ink-1); font-weight: 600; text-align: start;
  cursor: pointer;
}
.link-btn:hover { color: var(--link, var(--brand-ink)); text-decoration: underline; text-underline-offset: 3px; }
.text-link { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--text-sm); font-weight: 500; }
.text-link svg.ic { width: 16px; height: 16px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) 0; }
.card-h h2 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-lg); font-weight: 600; letter-spacing: -.005em; }
.card-h .aside { font-size: var(--text-sm); color: var(--ink-3); }
.card-b { padding: var(--sp-4) var(--sp-5) var(--sp-5); }

/* ---------- Level badge (signal bars + number + name: never colour alone) ---------- */
.tier {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 28px; padding: 0 var(--sp-3);
  border: 1px solid var(--tier-line); border-radius: 999px;
  background: var(--tier-soft); color: var(--tier-ink);
  font-size: var(--text-sm); font-weight: 600; line-height: 1;
  white-space: nowrap;
}
.tier .tn { font-weight: 500; }
.tier .tl + .tn::before { content: "·"; margin-inline-end: 6px; opacity: .7; }
.tier svg.ic { width: 16px; height: 16px; }
.tier.sm { height: 24px; padding: 0 var(--sp-2); gap: 6px; font-size: var(--text-xs); }
.tier.lg { height: 36px; padding: 0 var(--sp-4); font-size: var(--text-md); }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i { width: 3px; border-radius: 1px; background: var(--tier); opacity: .28; }
.bars i:nth-child(1) { height: 5px; }
.bars i:nth-child(2) { height: 8.5px; }
.bars i:nth-child(3) { height: 12px; }
.t1 .bars i:nth-child(-n+1),
.t2 .bars i:nth-child(-n+2),
.t3 .bars i { opacity: 1; }
.tier.lg .bars { height: 16px; gap: 3px; }
.tier.lg .bars i { width: 4px; }
.tier.lg .bars i:nth-child(1) { height: 6px; }
.tier.lg .bars i:nth-child(2) { height: 11px; }
.tier.lg .bars i:nth-child(3) { height: 16px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 var(--sp-2);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  background: var(--surface-2); color: var(--ink-2);
  font-size: var(--text-xs); font-weight: 500; line-height: 1;
  white-space: nowrap;
}
.chip svg.ic { width: 14px; height: 14px; color: var(--ink-3); }
.chip.good svg.ic { color: var(--t3-ink); }
.chip.warn, .chip.bad, .chip.tint { background: var(--tier-soft); border-color: var(--tier-line); color: var(--tier-ink); }
.chip.warn svg.ic, .chip.bad svg.ic, .chip.tint svg.ic { color: var(--tier-ink); }
.chip.info-tone { background: var(--info-soft); border-color: var(--info-line); color: var(--info-ink); }
.chip.info-tone svg.ic { color: var(--info-ink); }
.chip.dim { color: var(--ink-3); }
.chip.xs { height: 20px; padding: 0 6px; gap: 4px; font-size: var(--text-2xs); }
.chip.xs svg.ic { width: 12px; height: 12px; }
.chip.lg { height: 32px; padding: 0 var(--sp-3); font-size: var(--text-sm); }
.chip.lg svg.ic { width: 16px; height: 16px; }

/* ---------- Avatar ---------- */
.avatar {
  --size: 40px;
  width: var(--size); height: var(--size); flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-3); color: var(--ink-1);
  font-size: var(--text-md); font-weight: 600; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--tier, var(--line-2));
}
.avatar.sm { --size: 32px; font-size: var(--text-xs); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--tier, var(--line-2)); }
.avatar.lg { --size: 56px; font-size: var(--text-2xl); }
.avatar.t0 { opacity: .7; }

/* ---------- Stat tiles (no decoration: Swiss "essential elements only") ---------- */
.kpis { display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.kpi { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: var(--sp-5); }
.kpi-l { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); font-weight: 500; color: var(--ink-3); }
.kpi-l svg.ic { width: 16px; height: 16px; }
.kpi-v { font-size: var(--text-4xl); font-weight: 600; line-height: 1.15; color: var(--ink-1); letter-spacing: -.01em; }
.kpi.hero .kpi-v { font-size: var(--text-5xl); line-height: 1.05; }
.kpi-unit { margin-inline-start: 6px; font-size: var(--text-xl); font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.kpi-s { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--sp-3); font-size: var(--text-sm); color: var(--ink-2); }
.kpi-flag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--tier-ink); }
.kpi-flag svg.ic { width: 16px; height: 16px; }

/* ---------- Overview grids ---------- */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--sp-4); margin-top: var(--sp-4); }
.ov-grid.b { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }

/* segmented bar: tall variant (28px, labels inside where they fit) */
.segbar { display: flex; gap: 2px; height: 28px; }
.segbar .part {
  flex-basis: 0; min-width: 6px; height: 100%;
  display: flex; align-items: center;
  padding-inline-start: var(--sp-2);
  border-radius: 4px;
  background: var(--tier); color: var(--tier-on);
  font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden;
  cursor: default;
  transition: filter var(--dur-1);
}
.segbar .part:hover, .segbar .part:focus-visible { filter: brightness(1.08); }
.segbar-empty { height: 28px; border-radius: 4px; background: var(--surface-2); }

.tier-rows { list-style: none; margin: var(--sp-4) 0 0; padding: 0; }
.tier-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto 18px; align-items: center; gap: var(--sp-4);
  width: 100%; padding: var(--sp-3);
  border: 0; border-top: 1px solid var(--line);
  background: transparent; text-align: start; cursor: pointer;
  transition: background var(--dur-1);
}
.tier-rows li:first-child .tier-row { border-top: 0; }
.tier-row:hover { background: var(--surface-2); }
.tier-row:active { background: var(--surface-3); }
.tier-row .tr-desc { font-size: var(--text-sm); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tier-row .tr-num { text-align: end; line-height: 1.25; }
.tier-row .tr-count { display: block; font-size: var(--text-2xl); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tier-row .tr-sub { display: block; font-size: var(--text-xs); color: var(--ink-3); white-space: nowrap; }
.tier-row > svg.ic { color: var(--ink-3); width: 16px; height: 16px; }

/* payout × level matrix */
.matrix { border-collapse: separate; border-spacing: var(--sp-2); margin: calc(var(--sp-2) * -1); width: calc(100% + var(--sp-4)); }
.matrix th { padding: 0 var(--sp-1); font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); text-align: center; }
.matrix th[scope="row"] { width: 1%; text-align: start; white-space: nowrap; }
.matrix td { padding: 0; }
.mx-cell {
  width: 100%; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: var(--sp-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1), transform var(--dur-1) var(--ease);
}
.mx-cell:hover { border-color: var(--line-3); }
.mx-cell:not(.zero):active { transform: scale(.98); }
.mx-cell b { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-2xl); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mx-cell small { font-size: var(--text-xs); color: var(--ink-3); }
.mx-cell.zero { background: transparent; cursor: default; }
.mx-cell.zero b { color: var(--ink-3); font-weight: 500; }
.mx-cell.hot { background: var(--t1-soft); border-color: var(--t1-line); }
.mx-cell.hot b { color: var(--t1-ink); }
.mx-cell.hot svg.ic { width: 18px; height: 18px; color: var(--t1-ink); }
.foot-note { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); font-size: var(--text-xs); color: var(--ink-3); }
.foot-note svg.ic { width: 16px; height: 16px; color: var(--t1-ink); }

/* alerts */
.alerts { list-style: none; margin: 0; padding: 0; }
.alert {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--line);
}
.alerts li:first-child.alert { border-top: 0; padding-top: var(--sp-1); }
.al-ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--tier-soft); color: var(--tier-ink); }
.al-title { font-size: var(--text-md); font-weight: 500; line-height: 1.5; }
.al-title, .al-sub { overflow-wrap: anywhere; } /* long emails and names wrap instead of overflowing */
.al-sub { margin-top: 2px; font-size: var(--text-sm); line-height: 1.5; color: var(--ink-3); }
.sev-tag {
  display: inline-block; margin-inline-end: 6px; padding: 1px var(--sp-2);
  border-radius: 999px;
  background: var(--tier-soft); color: var(--tier-ink);
  font-size: var(--text-2xs); font-weight: 600; vertical-align: 1px;
}
.all-good { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-2) 0; }
.all-good .al-ic { background: var(--t3-soft); color: var(--t3-ink); }

/* ranked bars (single series, no legend) */
.ranked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.rk { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-1) var(--sp-3); }
.rk .link-btn { font-size: var(--text-md); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rk-val { font-size: var(--text-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.rk-bar {
  grid-column: 1 / -1; height: 8px; min-width: 3px;
  background: var(--bar);
  border-start-end-radius: 4px; border-end-end-radius: 4px;
}
.rk-meta { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-xs); color: var(--ink-3); min-width: 0; }
.rk-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-meta > .chip { flex: none; } /* the status chip keeps its full label; the text beside it truncates */

/* banners */
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4);
  margin-bottom: var(--sp-4); padding: var(--sp-4);
  border: 1px solid var(--tier-line); border-radius: var(--r-lg);
  background: var(--tier-soft);
}
.bn-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface); color: var(--tier-ink); }
.bn-text { flex: 1 1 240px; min-width: 0; }
.bn-text b { display: block; font-size: var(--text-base); font-weight: 600; }
.bn-text span { font-size: var(--text-sm); color: var(--ink-2); }
.bn-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.tb-group { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.mini-search { position: relative; }
.mini-search svg.ic { position: absolute; inset-inline-start: var(--sp-3); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.mini-search input { width: 232px; height: 40px; padding-inline: 36px var(--sp-3); }
.select-wrap { position: relative; display: inline-block; }
.select-wrap svg.ic { position: absolute; inset-inline-end: var(--sp-3); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.select-wrap .select { height: 40px; padding-inline: var(--sp-3) 36px; font-size: var(--text-md); }
.flag-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.flag-row .lbl { color: var(--ink-3); margin-inline-end: var(--sp-1); }
.fchip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 var(--sp-3);
  border: 1px solid var(--line-2); border-radius: 999px;
  background: transparent; color: var(--ink-2);
  font-size: var(--text-sm); font-weight: 500; cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform var(--dur-1) var(--ease);
}
.fchip:hover { background: var(--surface-2); color: var(--ink-1); }
.fchip:active { transform: scale(.97); }
.fchip svg.ic { width: 16px; height: 16px; }
.fchip .c { font-size: var(--text-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.fchip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }
.fchip[aria-pressed="true"] .c { color: var(--brand-ink); }
.result-line { margin: calc(var(--sp-2) * -1) 0 var(--sp-3); font-size: var(--text-sm); color: var(--ink-3); }
.result-line button { margin-inline-start: var(--sp-2); }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--field);
}
.seg label { position: relative; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 var(--sp-3);
  border-radius: var(--r-xs);
  color: var(--ink-2); font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-1), color var(--dur-1);
}
.seg span:hover { color: var(--ink-1); background: var(--surface-2); }
.seg span:active { background: var(--surface-3); }
.seg span .c { font-size: var(--text-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.seg span svg.ic { width: 16px; height: 16px; }
.seg input:checked + span { background: var(--surface-3); color: var(--ink-1); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 1px; }
.seg.block { display: flex; }
.seg.block label { flex: 1; }
.seg.block span { justify-content: center; width: 100%; }
.seg .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tier); }

/* ---------- Accounts grid ---------- */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--sp-4); }
.acc-card {
  position: relative;
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.acc-card::before {
  content: ""; position: absolute; top: -1px; inset-inline: var(--sp-5); height: 2px;
  border-end-start-radius: 2px; border-end-end-radius: 2px;
  background: var(--tier);
}
.acc-card:hover { border-color: var(--line-3); box-shadow: var(--shadow-sm); }
.acc-card:focus-within { border-color: var(--focus-line, var(--brand-line)); }
.acc-card.is-disabled { background: transparent; }
.acc-card.is-disabled .ac-head, .acc-card.is-disabled .ac-pages { opacity: .66; }
.ac-head { display: flex; align-items: center; gap: var(--sp-3); }
.ac-id { flex: 1; min-width: 0; }
.ac-open {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  max-width: 100%; overflow: hidden; overflow-wrap: anywhere;
  padding: 0; border: 0; background: none;
  font-size: var(--text-lg); font-weight: 600; line-height: 1.35; text-align: start;
  cursor: pointer;
}
.ac-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-lg); }
.ac-open:focus-visible { outline: none; }
.ac-open:focus-visible::after { outline: 2px solid var(--ring); outline-offset: -2px; }
/* ux: truncation-strategy / long-token-wrapping: wrap instead of hiding text */
.ac-meta { display: flex; flex-direction: column; min-width: 0; font-size: var(--text-xs); line-height: 1.5; color: var(--ink-3); }
.ac-meta > * { overflow-wrap: anywhere; }
.ac-meta .ltr { text-align: left; }
.acc-card .tier, .acc-card .icon-btn, .acc-card a, .acc-card .chip[data-tip], .acc-card .more-btn { position: relative; z-index: 1; }

.ac-pages { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--page); }
[data-theme="light"] .ac-pages { background: var(--surface-2); }
.ac-pages-h { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-2) var(--sp-3); color: var(--ink-3); border-bottom: 1px solid var(--line); }
.ac-pages ul { list-style: none; margin: 0; padding: var(--sp-1) 0; }
.ac-pages li { display: flex; align-items: flex-start; gap: var(--sp-2); padding: 6px var(--sp-3); font-size: var(--text-sm); }
.ac-pages li svg.ic { width: 16px; height: 16px; margin-top: 2px; color: var(--ink-3); }
.ac-pages .pg-name { flex: 1; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.ac-pages .pg-f { font-size: var(--text-xs); color: var(--ink-2); font-variant-numeric: tabular-nums; margin-top: 1px; }
.ac-pages .pg-money { color: var(--t3-ink); position: relative; z-index: 1; display: inline-flex; }
.ac-pages .pg-money svg.ic { color: var(--t3-ink); }
.more-btn { margin: 0 var(--sp-3) var(--sp-2); padding: 2px 0; border: 0; background: none; color: var(--link, var(--brand-ink)); font-size: var(--text-xs); font-weight: 600; cursor: pointer; }
.more-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.ac-nopages { padding: var(--sp-3); font-size: var(--text-sm); color: var(--ink-3); }
.ac-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding-top: var(--sp-3); border-top: 1px solid var(--line); margin-top: auto; }
.ac-facts { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); font-size: var(--text-xs); color: var(--ink-3); min-width: 0; }
.ac-facts span { display: inline-flex; align-items: center; gap: 6px; position: relative; z-index: 1; }
.ac-facts svg.ic { width: 16px; height: 16px; }
.ac-facts .is-stale { color: var(--t2-ink); }
.ac-actions { display: flex; gap: var(--sp-1); }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-md); }
.data th {
  position: sticky; top: 0; z-index: 1;
  padding: var(--sp-3);
  background: var(--surface);
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-3);
  text-align: start; white-space: nowrap;
}
.data th button { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.data th button:hover { color: var(--ink-1); }
.data th button svg.ic { width: 14px; height: 14px; opacity: .55; }
.data th[aria-sort="ascending"] button, .data th[aria-sort="descending"] button { color: var(--ink-1); }
.data th[aria-sort="ascending"] button svg.ic, .data th[aria-sort="descending"] button svg.ic { opacity: 1; color: var(--brand-ink); }
.data td { padding: var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data td .icon-btn { width: 32px; height: 32px; }
.data td .icon-btn + .icon-btn { margin-inline-start: var(--sp-1); }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr { transition: background var(--dur-1); }
.data tbody tr:hover { background: var(--surface-2); }
.data .num { text-align: end; }
.data th.num { text-align: end; }
.data .act { width: 1%; white-space: nowrap; }
.cell-id { display: flex; align-items: center; gap: var(--sp-3); min-width: 200px; }
.cell-id .sub { font-size: var(--text-xs); color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pg-avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.pg-avatar svg.ic { width: 18px; height: 18px; }
.acc-mini {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 200px; height: 28px; padding: 0 var(--sp-3);
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface-2); color: var(--ink-1);
  font-size: var(--text-xs); font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur-1), transform var(--dur-1) var(--ease);
}
.acc-mini:hover { border-color: var(--tier-line, var(--line-3)); }
.acc-mini:active { transform: scale(.97); }
.acc-mini { min-width: 0; }
.acc-mini span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-mini.t0 { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.mini-list { display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }
.sec-icons { display: flex; gap: var(--sp-1); }
.stale-txt { display: inline-flex; align-items: center; gap: 6px; color: var(--t2-ink); }
.stale-txt svg.ic { width: 16px; height: 16px; }

/* ---------- Empty states ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-16) var(--sp-6); text-align: center; }
.empty .em-ic { width: 56px; height: 56px; display: grid; place-items: center; border-radius: var(--r-xl); background: var(--brand-soft); color: var(--brand-ink); }
.empty .em-ic svg.ic { width: 28px; height: 28px; }
.empty h2 { font-size: var(--text-xl); font-weight: 600; }
.empty p { max-width: 440px; font-size: var(--text-md); color: var(--ink-3); }
.empty .actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; justify-content: center; margin-top: var(--sp-1); }

.welcome { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: var(--sp-12); align-items: center; padding: var(--sp-12); overflow: hidden; }
.wl-eyebrow { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-3); border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: var(--text-xs); font-weight: 600; }
.wl-eyebrow svg.ic { width: 16px; height: 16px; }
.welcome h2 { margin-top: var(--sp-4); font-size: var(--text-4xl); font-weight: 700; line-height: 1.22; letter-spacing: -.02em; }
.welcome .lead-p { max-width: 62ch; margin-top: var(--sp-3); font-size: var(--text-lg); line-height: 1.7; color: var(--ink-2); }
.wl-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-6); }
.wl-points { list-style: none; margin: var(--sp-6) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); font-size: var(--text-md); color: var(--ink-2); }
.wl-points li { display: flex; gap: var(--sp-3); align-items: flex-start; }
.wl-points svg.ic { width: 18px; height: 18px; margin-top: 2px; color: var(--t3-ink); }
.wl-art { position: relative; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-6); border-radius: var(--r-xl); background: var(--page); border: 1px solid var(--line); }
.wl-art .demo-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.wl-art .demo-row .grow { flex: 1; min-width: 0; }
.wl-art .demo-row b { display: block; font-size: var(--text-md); font-weight: 600; }
.wl-art .demo-row small { display: block; font-size: var(--text-xs); color: var(--ink-3); }
.wl-art .demo-row .tier { flex: none; }
.wl-art .demo-row:nth-child(2) { margin-inline-start: var(--sp-6); }
.wl-art .demo-row:nth-child(3) { margin-inline-start: var(--sp-12); }

/* ---------- Criteria page ---------- */
.tiers-explain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.te-card { position: relative; display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-6) var(--sp-5) var(--sp-5); overflow: hidden; }
.te-card::before { content: ""; position: absolute; top: 0; inset-inline: 0; height: 3px; background: var(--tier); }
.te-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.te-ic { width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--r-lg); background: var(--tier-soft); color: var(--tier-ink); }
.te-ic svg.ic { width: 24px; height: 24px; }
.te-title { font-size: var(--text-xl); font-weight: 600; letter-spacing: -.005em; }
.te-desc { margin-top: var(--sp-1); font-size: var(--text-md); line-height: 1.65; color: var(--ink-2); }
.te-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); font-size: var(--text-sm); }
.te-rules li { display: flex; gap: var(--sp-2); align-items: flex-start; line-height: 1.55; }
.te-rules svg.ic { width: 16px; height: 16px; margin-top: 2px; color: var(--tier-ink); }
.te-rules .or { padding-inline-start: var(--sp-6); font-family: var(--mono); font-size: var(--text-2xs); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.te-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--line); font-size: var(--text-sm); color: var(--ink-3); }
.te-foot b { font-size: var(--text-2xl); font-weight: 600; color: var(--ink-1); font-variant-numeric: tabular-nums; margin-inline-end: var(--sp-1); letter-spacing: -.01em; }
.hint { font-size: var(--text-xs); line-height: 1.5; color: var(--ink-3); }
.section-title { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; margin: var(--sp-8) 0 var(--sp-3); font-size: var(--text-lg); font-weight: 600; }
.section-title small { font-size: var(--text-sm); font-weight: 400; color: var(--ink-3); }
.prot-table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.prot-table td { padding: var(--sp-3) 0; border-top: 1px solid var(--line); vertical-align: middle; }
.prot-table tr:first-child td { border-top: 0; }
.prot-table td:first-child { width: 168px; }
.prot-table td:last-child { width: 96px; text-align: end; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5); padding: var(--sp-4) 0; border-top: 1px solid var(--line); }
.set-row:first-child { border-top: 0; padding-top: var(--sp-1); }
.set-text b { display: block; font-size: var(--text-md); font-weight: 600; }
.set-text span { display: block; font-size: var(--text-sm); color: var(--ink-3); line-height: 1.6; }
.num-input { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); color: var(--ink-2); }
.num-input .input { width: 92px; text-align: center; font-variant-numeric: tabular-nums; }
.tips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.tips li { display: flex; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--page); font-size: var(--text-sm); line-height: 1.6; color: var(--ink-2); }
[data-theme="light"] .tips li { background: var(--surface-2); }
.tips li b { display: block; margin-bottom: 2px; color: var(--ink-1); font-size: var(--text-md); }
.tips .tip-ic { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand-ink); }
.tips .tip-ic svg.ic { width: 16px; height: 16px; }

/* ---------- Backup page ---------- */
.bk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.bk-actions { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); }
.bk-actions .btn { justify-content: flex-start; height: auto; min-height: var(--h); padding-block: var(--sp-2); white-space: normal; text-align: start; line-height: 1.35; }
.bk-meta { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-4); font-size: var(--text-sm); color: var(--ink-3); }
.bk-meta svg.ic { width: 16px; height: 16px; }
.card-p { font-size: var(--text-md); line-height: 1.65; color: var(--ink-2); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  margin-top: var(--sp-4); padding: var(--sp-8) var(--sp-5);
  border: 1.5px dashed var(--line-3); border-radius: var(--r-lg);
  background: var(--field);
  text-align: center; cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1);
}
.dropzone:hover, .dropzone.drag, .dropzone:focus-within { border-color: var(--brand-line); background: var(--brand-soft); }
.dropzone svg.ic { width: 28px; height: 28px; color: var(--brand-ink); }
.dropzone b { font-size: var(--text-md); font-weight: 600; }
.dropzone span { font-size: var(--text-xs); color: var(--ink-3); }
.danger-zone { border-color: var(--t1-line); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); margin-top: var(--sp-4); }

/* ---------- Overlays: drawer & dialog ---------- */
.ov { position: fixed; inset: 0; z-index: var(--z-overlay); }
/* blur marks a dismissible background (ux: blur-purpose; generator modal spec: blur 4px) */
.ov .scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity var(--dur-2) var(--ease);
}
.ov.open .scrim { opacity: 1; }
.ov.closing .scrim { transition: opacity var(--dur-exit) var(--ease-in); }
.ov-modal { display: grid; place-items: center; padding: var(--sp-6); overflow: auto; }

.drawer {
  position: absolute; inset-block: 0; inset-inline-end: 0;
  width: min(560px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-inline-start: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg);
  transform: translateX(-104%);
  transition: transform var(--dur-3) var(--ease-out);
  outline: none;
}
[dir="ltr"] .drawer { transform: translateX(104%); }
.ov.open .drawer { transform: none; }
.ov.closing .drawer { transition: transform var(--dur-exit) var(--ease-in); }
.dw-h { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-4); border-bottom: 1px solid var(--line); }
.dw-id { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-4); }
.dw-id h2 { font-size: var(--text-2xl); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; letter-spacing: -.005em; }
.dw-id p { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); margin-top: 2px; font-size: var(--text-sm); color: var(--ink-3); }
.dw-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-6); border-bottom: 1px solid var(--line); }
.dw-b { flex: 1; overflow: auto; padding: var(--sp-1) var(--sp-6) var(--sp-8); }
.dw-sec { padding: var(--sp-5) 0; border-top: 1px solid var(--line); }
.dw-sec:first-child { border-top: 0; }
.dw-sec > h3 { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); color: var(--ink-3); }
.dw-sec > h3 .btn { font-family: var(--font); font-size: var(--text-sm); letter-spacing: 0; text-transform: none; }
.tier-panel { margin-top: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--tier-line); border-radius: var(--r-lg); background: var(--tier-soft); }
.tp-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.tp-mode { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--ink-2); }
.tp-mode svg.ic { width: 16px; height: 16px; }
.tp-desc { margin-top: var(--sp-3); font-size: var(--text-md); color: var(--ink-2); }
.crit { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.crit li { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--text-md); line-height: 1.5; }
.crit li svg.ic { width: 18px; height: 18px; margin-top: 1px; }
.crit .ok svg.ic { color: var(--t3-ink); }
.crit .no svg.ic { color: var(--ink-3); }
.crit .no { color: var(--ink-2); }
.crit small { display: block; font-size: var(--text-xs); color: var(--ink-3); }
.next-step { margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); font-size: var(--text-sm); line-height: 1.65; }
.next-step b { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: var(--sp-1); }
.next-step ul { margin: 0; padding-inline-start: var(--sp-5); color: var(--ink-2); }
.kv { display: grid; grid-template-columns: 136px minmax(0, 1fr); gap: var(--sp-3) var(--sp-4); margin: 0; font-size: var(--text-md); }
.kv dt { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); color: var(--ink-3); }
.kv dt svg.ic { width: 16px; height: 16px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.copy-btn { width: 28px; height: 28px; border-radius: var(--r-xs); }
.copy-btn svg.ic { width: 16px; height: 16px; }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.link-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--page); }
[data-theme="light"] .link-item { background: var(--surface-2); }
.link-item .grow { flex: 1; min-width: 0; }
.link-item .grow small { display: block; font-size: var(--text-xs); color: var(--ink-3); }
.link-add { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.link-add .select-wrap { flex: 1; }
.link-add .select { width: 100%; }
.notes-box { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--page); border: 1px solid var(--line); font-size: var(--text-md); line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
[data-theme="light"] .notes-box { background: var(--surface-2); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-inline-start: var(--sp-6); padding-bottom: var(--sp-3); font-size: var(--text-sm); line-height: 1.55; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--line-3); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 7px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li:first-child::before { background: var(--brand-ink); }
.timeline time { display: block; font-size: var(--text-xs); color: var(--ink-3); }

.dialog {
  position: relative; z-index: 1;
  width: min(760px, 100%); max-height: calc(100dvh - var(--sp-12));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px) scale(.985);
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-3) var(--ease-out);
  outline: none;
}
.ov.open .dialog { opacity: 1; transform: none; }
.ov.closing .dialog { transition: opacity var(--dur-exit) var(--ease-in), transform var(--dur-exit) var(--ease-in); }
.dialog-sm { width: min(460px, 100%); }
.dialog-md { width: min(620px, 100%); }
.dialog-h { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6) var(--sp-4); border-bottom: 1px solid var(--line); }
.dialog-h h2 { font-size: var(--text-xl); font-weight: 600; line-height: 1.4; letter-spacing: -.005em; }
.dialog-h p { margin-top: 2px; font-size: var(--text-sm); color: var(--ink-3); }
.dialog-b { display: flex; flex-direction: column; gap: var(--sp-6); padding: var(--sp-5) var(--sp-6) var(--sp-6); overflow: auto; }
.dialog-f { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--line); }
.dialog-f .spacer { margin-inline-end: auto; }
.confirm-body { font-size: var(--text-md); line-height: 1.7; color: var(--ink-2); }

/* forms */
.fs { min-width: 0; margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.fs legend { display: flex; align-items: center; gap: var(--sp-3); width: 100%; margin-bottom: var(--sp-4); padding: 0; color: var(--ink-3); }
.fs legend::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: var(--text-sm); font-weight: 500; color: var(--ink-2); }
.req { margin-inline-start: 3px; color: var(--t1-ink); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 var(--sp-3);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--field); color: var(--ink-1);
  font-size: var(--text-md);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.textarea { height: auto; min-height: 88px; padding: var(--sp-2) var(--sp-3); line-height: 1.65; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus-line, var(--brand-line)); box-shadow: 0 0 0 3px var(--focus-soft, var(--brand-soft)); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: .85; }
.input.ltr { direction: ltr; text-align: left; }
.input.ltr::placeholder { text-align: left; }
.hint.warn-hint { display: flex; align-items: center; gap: 6px; color: var(--t2-ink); }
.hint.warn-hint svg.ic { width: 14px; height: 14px; }
.err { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--t1-ink); }
.err svg.ic { width: 14px; height: 14px; }
.field.has-err .input, .field.has-err .textarea { border-color: var(--t1-line); box-shadow: 0 0 0 3px var(--t1-soft); }
/* ux: error-summary: focusable summary linked to each invalid field */
.err-summary { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--t1-line); border-radius: var(--r-md); background: var(--t1-soft); outline: none; }
.err-summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.err-summary h3 { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-md); font-weight: 600; color: var(--t1-ink); }
.err-summary h3 svg.ic { width: 16px; height: 16px; }
.err-summary ul { margin: var(--sp-1) 0 0; padding-inline-start: var(--sp-6); font-size: var(--text-sm); color: var(--ink-2); }
.err-summary .link-btn { color: var(--t1-ink); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.switches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.switch-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--field);
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1);
}
.switch-row:has(input:checked) { border-color: var(--t3-line); background: var(--t3-soft); }
.sw-text b { display: block; font-size: var(--text-md); font-weight: 600; line-height: 1.4; }
.sw-text small { display: block; margin-top: 2px; font-size: var(--text-xs); line-height: 1.45; color: var(--ink-3); }
.switch {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  width: 40px; height: 24px; margin: 0;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2);
}
.switch::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink-2);
  transition: inset-inline-start var(--dur-2) var(--ease), background var(--dur-2);
}
.switch:checked { background: var(--t3); border-color: transparent; }
.switch:checked::after { inset-inline-start: 18px; background: #fff; }
.preview-box { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--tier-line, var(--line-2)); background: var(--tier-soft, var(--surface-2)); font-size: var(--text-sm); color: var(--ink-2); }
.preview-box .grow { flex: 1; min-width: 200px; line-height: 1.6; }

.acc-pick { border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--field); overflow: hidden; }
.acc-pick-search { padding: var(--sp-2); border-bottom: 1px solid var(--line); }
.acc-pick-search .input { height: 36px; }
.acc-pick ul { list-style: none; margin: 0; padding: 6px; max-height: 272px; overflow: auto; }
.pick-row { position: relative; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); cursor: pointer; transition: background var(--dur-1); }
.pick-row:hover { background: var(--surface-2); }
.pick-row:active { background: var(--surface-3); }
.pick-row input { position: absolute; opacity: 0; pointer-events: none; }
.pick-box { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border: 1.5px solid var(--line-3); border-radius: var(--r-xs); color: transparent; transition: background var(--dur-1), border-color var(--dur-1); }
.pick-box svg.ic { width: 14px; height: 14px; stroke-width: 2.5; }
.pick-row input:checked + .pick-box { background: var(--brand); border-color: var(--brand); color: #fff; }
.pick-row input:focus-visible + .pick-box { outline: 2px solid var(--ring); outline-offset: 2px; }
.pick-name { flex: 1; min-width: 0; font-size: var(--text-md); font-weight: 500; line-height: 1.4; }
.pick-name small { display: block; font-size: var(--text-xs); font-weight: 400; color: var(--ink-3); }
.pick-empty { padding: var(--sp-4); font-size: var(--text-sm); color: var(--ink-3); text-align: center; }

/* check round */
.cr-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); font-size: var(--text-sm); color: var(--ink-3); }
.cr-progress { height: 6px; margin-top: var(--sp-2); border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.cr-progress i { display: block; height: 100%; background: var(--brand); border-start-end-radius: 3px; border-end-end-radius: 3px; transition: width var(--dur-3) var(--ease-out); }
.cr-acc { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--field); }
.cr-acc .grow { flex: 1; min-width: 0; }
.cr-acc h3 { font-size: var(--text-xl); font-weight: 600; line-height: 1.4; }
.cr-acc p { font-size: var(--text-sm); color: var(--ink-3); }
.cr-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-4); font-size: var(--text-sm); }
.cr-facts div { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; color: var(--ink-2); }
.cr-facts div > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-facts svg.ic { width: 16px; height: 16px; color: var(--ink-3); }
.cr-q { font-size: var(--text-base); font-weight: 600; }
.cr-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.cr-opt {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: start; cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1), transform var(--dur-1) var(--ease);
}
.cr-opt:hover { border-color: var(--tier-line); background: var(--tier-soft); }
.cr-opt:active { transform: scale(.98); }
.cr-opt .oi { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: var(--tier-soft); color: var(--tier-ink); }
.cr-opt b { display: block; font-size: var(--text-md); font-weight: 600; }
.cr-opt small { display: block; font-size: var(--text-xs); color: var(--ink-3); line-height: 1.45; }
.cr-done { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0 var(--sp-1); text-align: center; }
.cr-done .em-ic { width: 56px; height: 56px; display: grid; place-items: center; border-radius: var(--r-xl); background: var(--t3-soft); color: var(--t3-ink); }
.cr-done .em-ic svg.ic { width: 28px; height: 28px; }
.cr-done h3 { font-size: var(--text-xl); font-weight: 600; }
.cr-sum { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); }

/* toasts & tooltip (solid surfaces: no decorative blur) */
.toasts { position: fixed; z-index: var(--z-toast); bottom: var(--sp-6); inset-inline-end: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--sp-3);
  min-width: 280px; max-width: 440px;
  padding-block: var(--sp-3); padding-inline: var(--sp-4) var(--sp-3);
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: var(--text-md);
  animation: toast-in var(--dur-3) var(--ease-out);
  transition: opacity var(--dur-exit) var(--ease-in), transform var(--dur-exit) var(--ease-in);
}
.toast .t-ic { color: var(--t3-ink); }
.toast.bad .t-ic { color: var(--t1-ink); }
.toast.info .t-ic { color: var(--info-ink); }
.toast .t-msg { flex: 1; line-height: 1.5; }
.toast .t-act { height: 32px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-xs); background: var(--info-soft); color: var(--info-ink); font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
.toast .t-act:hover { background: var(--info-line); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.tip {
  position: fixed; left: 0; top: 0; z-index: var(--z-tooltip);
  max-width: 280px; padding: 6px var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--tip-bg); color: var(--tip-ink);
  font-size: var(--text-xs); font-weight: 500; line-height: 1.5;
  pointer-events: none;
  opacity: 0; transition: opacity 120ms var(--ease);
}
.tip.show { opacity: 1; }

/* mobile tab bar */
.tabbar { display: none; }

/* ---------- Ledger switch (Facebook / YouTube) ---------- */
.app-switch {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px;
  margin: 0 0 var(--sp-4); padding: 3px;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--field);
}
.app-switch a {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; border-radius: var(--r-xs);
  color: var(--ink-2); font-size: var(--text-sm); font-weight: 500; text-decoration: none;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.app-switch a svg.ic { width: 16px; height: 16px; }
.app-switch a:hover { background: var(--surface-2); color: var(--ink-1); }
.app-switch a:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.app-switch a[aria-current="page"] { background: var(--brand); color: #fff; }
.app-switch a[aria-current="page"]:hover { background: var(--brand-hover); color: #fff; }
/* hint colours: YouTube red and Facebook-ledger blue (icons, 3:1 or more on both themes) */
.app-switch a[href="youtube.html"]:not([aria-current]) svg.ic, .topbar a.only-mobile[href="youtube.html"] svg.ic { color: #FF0000; }
.app-switch a[href="index.html"]:not([aria-current]) svg.ic, .topbar a.only-mobile[href="index.html"] svg.ic { color: #3B82F6; }

/* ---------- YouTube ledger additions (see design-system/safe/pages/youtube.md) ---------- */
/* iconic red for the logo mark and the progress bar (graphics, 4:1 with white) */
[data-app="youtube"] .brand-mark, [data-app="youtube"] .cr-progress i { background: var(--yt-red); }
/* selected filter chips are inverted, like YouTube's chip bar */
[data-app="youtube"] .fchip[aria-pressed="true"], [data-app="youtube"] .seg.scroll input:checked + span { background: var(--ink-1); border-color: var(--ink-1); color: var(--surface); box-shadow: none; }
[data-app="youtube"] .fchip[aria-pressed="true"] .c, [data-app="youtube"] .fchip[aria-pressed="true"] svg.ic, [data-app="youtube"] .seg.scroll input:checked + span .c { color: inherit; }
/* switching between the two ledgers cross-fades instead of flashing (same-origin pages only) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 280ms; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
}
/* grey segments use the ink-3 fill, so their labels need their own colour to keep 4.5:1 */
.segbar .part.muted-tone { --tier-on: #0B0B0B; }
[data-theme="light"] .segbar .part.muted-tone { --tier-on: #FFFFFF; }
/* three-figure summary at the top of a drawer */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.stat-row > div { min-width: 0; padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--page); }
[data-theme="light"] .stat-row > div { background: var(--surface-2); }
.stat-row b { display: block; font-size: var(--text-2xl); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-row span { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--ink-3); }
/* the headline number on an email card (total subscribers) */
.ac-figure { flex: none; text-align: end; line-height: 1.2; }
.ac-figure b { display: block; font-size: var(--text-2xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.ac-figure span { display: block; margin-top: 2px; font-family: var(--mono); font-size: var(--text-2xs); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
/* check round: optional subscriber counts per channel */
.cr-ch-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.cr-ch-list li { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--text-sm); }
.cr-ch-list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cr-ch-list .input { flex: none; width: 136px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Responsive: systematic breakpoints 768 / 1024 / 1280 (ux: breakpoint-consistency) ---------- */
@media (max-width: 1279px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-grid, .ov-grid.b { grid-template-columns: minmax(0, 1fr); }
  .tiers-explain { grid-template-columns: minmax(0, 1fr); }
  .welcome { grid-template-columns: minmax(0, 1fr); gap: var(--sp-8); }
  .wl-art { flex-direction: row; flex-wrap: wrap; }
  .wl-art .demo-row { flex: 1 1 240px; }
  .wl-art .demo-row:nth-child(2), .wl-art .demo-row:nth-child(3) { margin-inline-start: 0; }
}
@media (max-width: 1023px) {
  html { scroll-padding-top: 136px; scroll-padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .only-mobile { display: inline-grid !important; }
  .topbar { flex-wrap: wrap; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
  .tb-title p { display: none; }
  .search { order: 3; width: 100%; }
  .tb-actions .btn .lbl-long { display: none; }
  .tb-actions .btn { padding: 0 var(--sp-3); }
  main { padding: var(--sp-4) var(--sp-4) calc(var(--sp-16) + 36px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; inset-inline: 0; bottom: 0; z-index: var(--z-nav);
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--side);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; border-radius: var(--r-md);
    color: var(--ink-3); font-size: var(--text-2xs); font-weight: 500; text-decoration: none;
  }
  .tabbar a:active { background: var(--surface-2); }
  .tabbar a[aria-current="page"] { color: var(--brand-ink); background: var(--brand-soft); }
  .tabbar .count { position: absolute; top: 4px; inset-inline-end: 18%; margin: 0; min-width: 18px; height: 18px; padding: 0 5px; font-size: var(--text-2xs); }
  .toasts { inset-inline: var(--sp-4); bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
  .welcome { padding: var(--sp-6); gap: var(--sp-6); }
  .welcome h2 { font-size: var(--text-3xl); }
  .bk-grid, .tips { grid-template-columns: minmax(0, 1fr); }
  .switches { grid-template-columns: minmax(0, 1fr); }
  /* ux: readable-font-size: 16px inputs stop iOS from zooming on focus */
  .input, .select, .textarea, .search input { font-size: var(--text-lg); }
}
@media (max-width: 767px) {
  .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-3); }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi { padding: var(--sp-4); }
  .kpi-v { font-size: var(--text-3xl); }
  .kpi.hero .kpi-v { font-size: 40px; }
  .acc-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar { align-items: stretch; }
  .tb-group { width: 100%; }
  /* search gets its own row; selects share the next one */
  .mini-search { flex: 1 1 100%; }
  .mini-search input { width: 100%; }
  .tb-group .select-wrap { flex: 1 1 0; min-width: 0; }
  .tb-group .select-wrap .select { width: 100%; }
  .seg.scroll { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .cr-options, .cr-facts { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: var(--sp-1); }
  .kv dd { margin-bottom: var(--sp-2); }

  /* tables collapse into stacked cards (ux: table handling) */
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  table.data, .data thead, .data tbody, .data tr, .data td { display: block; width: 100%; }
  .data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data tbody { display: flex; flex-direction: column; gap: var(--sp-3); }
  .data tbody tr { padding: 6px var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
  .data tbody tr:hover { background: var(--surface); }
  .data td { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); text-align: start; }
  .data td.num { text-align: start; }
  .data td::before { content: attr(data-label); flex: none; font-family: var(--mono); font-size: var(--text-2xs); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
  .data td.cell-main { display: block; }
  .data td.cell-main::before { display: none; }
  .data td.act { width: 100%; justify-content: flex-end; }
  .data td.act::before { display: none; }
  .data tbody tr td:last-child { border-bottom: 0; }
  .mini-list { justify-content: flex-end; }

  .ov-modal { place-items: end stretch; padding: 0; }
  .dialog, .dialog-sm, .dialog-md { width: 100%; max-height: 94dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; transform: translateY(24px); }
  .dialog-h, .dialog-b, .dialog-f { padding-inline: var(--sp-4); }
  .dw-h, .dw-actions, .dw-b { padding-inline: var(--sp-4); }
  .wl-art { display: none; }
  .matrix { border-spacing: 6px; margin: -6px; width: calc(100% + 12px); }
  .tier-row .tr-desc { display: none; }
}
/* very narrow panes and small phones: let buttons wrap instead of overflowing */
@media (max-width: 479px) {
  main { padding-inline: var(--sp-3); }
  .welcome { padding: var(--sp-5) var(--sp-4); }
  .wl-actions .btn, .empty .actions .btn, .bn-actions .btn { width: 100%; height: auto; min-height: var(--h); padding-block: var(--sp-2); white-space: normal; text-align: center; line-height: 1.3; }
  .topbar { padding-inline: var(--sp-3); }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .data td { flex-wrap: wrap; }
  .mini-list { justify-content: flex-start; max-width: 100%; }
  .acc-mini { max-width: 100%; }
  .matrix { border-spacing: 4px; margin: -4px; width: calc(100% + 8px); }
  .matrix th[scope="row"] .tn { display: none; }
  .matrix th { font-size: var(--text-2xs); }
  .tier-row { gap: var(--sp-2); grid-template-columns: auto minmax(0, 1fr) auto; }
  .tier-row .tn, .tier-row > svg.ic { display: none; }
  .tier-row .tr-sub { white-space: normal; }
  .alert { grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-1) var(--sp-3); }
  .alert > .btn { grid-column: 2; justify-self: start; }
  /* settings rows: the control drops below its text; link buttons take the full width */
  .set-row { flex-wrap: wrap; gap: var(--sp-3); }
  .set-row > .btn { width: 100%; height: auto; min-height: var(--h); padding-block: var(--sp-2); white-space: normal; text-align: center; line-height: 1.3; }
  /* status tables: badge and count on one line, the explanation below */
  .prot-table, .prot-table tbody { display: block; }
  .prot-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
  .prot-table tr:first-child { border-top: 0; }
  .prot-table td, .prot-table td:first-child, .prot-table td:last-child { display: block; width: auto; padding: 0; border: 0; }
  .prot-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; font-size: var(--text-sm); }
}
@media (pointer: coarse) {
  .btn { --h: 44px; }
  .btn-sm { --h: 40px; }
  .icon-btn, .data td .icon-btn { width: 44px; height: 44px; }
  .ac-actions { gap: var(--sp-2); }
  .seg span { height: 40px; }
  .fchip { height: 40px; }
  .input, .select { height: 44px; }
  .input, .select, .textarea, .search input { font-size: var(--text-lg); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .bars i { forced-color-adjust: none; background: CanvasText; }
  .segbar .part { border: 1px solid CanvasText; }
}
