/* Portal design system.
   Light and dark themes. Brand tokens are written by theme.js from the workspace config and
   the user's appearance settings; the values below are fallbacks for the first paint. */

:root {
  --brand: #172C4B;
  --brand-ink: #172C4B;          /* brand, darkened if needed for 4.5:1 text contrast */
  --brand-on: #FFFFFF;           /* text on a solid brand background */
  --brand-tint: rgba(23, 44, 75, .08);
  --brand-tint-strong: rgba(23, 44, 75, .14);
  --accent: #48A625;
  --accent-ink: #2F7A15;
  --accent-tint: rgba(72, 166, 37, .12);

  --surface: #F7F8FA;
  --card: #FFFFFF;
  --border: #E5E8EE;
  --border-strong: #D3D8E1;
  --text: #0F172A;
  --muted: #64748B;
  --faint: #94A3B8;

  --good: #16A34A; --good-tint: #DCFCE7; --good-ink: #15803D;
  --warn: #D97706; --warn-tint: #FEF3C7; --warn-ink: #B45309;
  --bad:  #DC2626; --bad-tint:  #FEE2E2; --bad-ink:  #B91C1C;
  --info: #2563EB; --info-tint: #DBEAFE; --info-ink: #1D4ED8;

  --font-head: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;

  --r-card: 12px; --r-ctl: 8px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-2: 0 8px 24px rgba(15, 23, 42, .10), 0 2px 6px rgba(15, 23, 42, .06);
  --pin-shadow: rgba(15, 23, 42, .18);
  --shadow-3: 0 24px 64px rgba(15, 23, 42, .18), 0 4px 12px rgba(15, 23, 42, .08);

  /* Surfaces that used to be hard-coded. */
  --on-solid: #FFFFFF;
  --topbar-bg: rgba(247, 248, 250, .86);
  --tabbar-bg: rgba(255, 255, 255, .94);
  --scrim: rgba(15, 23, 42, .28);
  --scrim-strong: rgba(15, 23, 42, .32);
  --toast-bg: #0F172A; --toast-fg: #FFFFFF; --toast-action: #A7F3D0;
  --banner-bg: #FDE68A; --banner-fg: #713F12; --banner-border: #F5C451;
  --sk-a: #EEF1F5; --sk-b: #F6F8FA;
  --swatch-border: rgba(15, 23, 42, .12);

  --row-h: 44px;
  --nav-w: 248px;
  --nav-w-collapsed: 68px;
  --topbar-h: 56px;
  --tabbar-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
:root[data-density="compact"] { --row-h: 36px; }

/* Dark theme. Same token names; every component reads tokens, so nothing needs its own dark rule. */
:root[data-theme="dark"] {
  --surface: #0B1220;
  --card: #111A2B;
  --border: #1F2A3D;
  --border-strong: #2C3A52;
  --text: #E6EBF2;
  --muted: #9AA8BC;
  --faint: #6B7A90;
  --good: #22C55E; --good-tint: rgba(34, 197, 94, .16); --good-ink: #4ADE80;
  --warn: #F59E0B; --warn-tint: rgba(245, 158, 11, .16); --warn-ink: #FBBF24;
  --bad:  #EF4444; --bad-tint:  rgba(239, 68, 68, .17); --bad-ink:  #F87171;
  --info: #3B82F6; --info-tint: rgba(59, 130, 246, .17); --info-ink: #93C5FD;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --pin-shadow: rgba(0, 0, 0, .55);
  --shadow-3: 0 24px 64px rgba(0, 0, 0, .6), 0 4px 12px rgba(0, 0, 0, .35);
  --topbar-bg: rgba(11, 18, 32, .86);
  --tabbar-bg: rgba(17, 26, 43, .94);
  --scrim: rgba(0, 0, 0, .5);
  --scrim-strong: rgba(0, 0, 0, .58);
  --toast-bg: #E6EBF2; --toast-fg: #0B1220; --toast-action: #047857;
  --banner-bg: #3A2D0E; --banner-fg: #FCD34D; --banner-border: #5C4813;
  --sk-a: #172133; --sk-b: #1F2B40;
  --swatch-border: rgba(255, 255, 255, .18);
  color-scheme: dark;
}

/* Text size chosen by the user (Appearance). */
:root[data-size="s"] body { zoom: .93; }
:root[data-size="l"] body { zoom: 1.1; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.25; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--brand-ink); }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Boot ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); animation: pulse 1s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: .5; } 50% { transform: scale(1.6); opacity: 1; } }

/* ---------- Buttons, pills, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-ctl); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--brand); color: var(--brand-on); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 0 3px var(--brand-tint-strong); }
.btn-secondary { background: var(--card); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--brand-tint); color: var(--text); }
.btn-danger { background: var(--bad); color: var(--on-solid); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14.5px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-ctl);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--brand-tint); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.pill svg { width: 12px; height: 12px; }
.pill-good { background: var(--good-tint); color: var(--good-ink); border-color: transparent; }
.pill-warn { background: var(--warn-tint); color: var(--warn-ink); border-color: transparent; }
.pill-bad  { background: var(--bad-tint);  color: var(--bad-ink);  border-color: transparent; }
.pill-info { background: var(--info-tint); color: var(--info-ink); border-color: transparent; }
.pill-brand { background: var(--brand-tint); color: var(--brand-ink); border-color: transparent; }
.pill-accent { background: var(--accent-tint); color: var(--accent-ink); border-color: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--card);
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text);
}
.chip[aria-pressed="true"], .chip.is-on { background: var(--brand-tint); border-color: transparent; color: var(--brand-ink); font-weight: 600; }

.kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px;
  font: 600 11px/1 var(--font-body); color: var(--muted); background: var(--card);
}

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.input {
  height: 40px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--border-strong);
  background: var(--card); width: 100%; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-strong); }
.form-error { color: var(--bad-ink); background: var(--bad-tint); border-radius: var(--r-ctl); padding: 10px 12px; font-size: 13px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-1); }
.card-pad { padding: 20px; }

/* ---------- Test-mode banner ---------- */
.test-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 34px; padding: 6px 16px; background: var(--banner-bg); color: var(--banner-fg);
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; text-align: center;
  border-bottom: 1px solid var(--banner-border);
}
.test-banner svg { width: 15px; height: 15px; flex: none; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s var(--ease); }
.shell.is-collapsed { grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr); }
.shell-main { min-width: 0; display: flex; flex-direction: column; }

.nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 12px 12px;
}
.nav-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 14px; }
.nav-logo { height: 30px; width: auto; max-width: 150px; object-fit: contain; object-position: left center; }
.nav-mark {
  display: none; width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: var(--brand-on);
  font: 800 14px/36px var(--font-head); text-align: center;
}
.nav-search {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 10px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--surface);
  color: var(--muted); font-size: 13px; cursor: pointer; text-align: left;
}
.nav-search:hover { border-color: var(--border-strong); }
.nav-search svg { width: 16px; height: 16px; flex: none; }
.nav-search span.grow { flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group-label {
  padding: 0 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; margin: 1px 0;
  border-radius: var(--r-ctl); color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13.5px;
  white-space: nowrap;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.nav-badge.is-urgent { background: var(--bad); color: var(--on-solid); border-color: transparent; }
.nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: var(--r-ctl);
  background: transparent; cursor: pointer; text-align: left;
}
.user-btn:hover { background: var(--surface); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-on); font: 700 12px/1 var(--font-head);
}
.user-meta { min-width: 0; flex: 1; }
.user-meta b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { display: block; color: var(--muted); font-size: 12px; }

.shell.is-collapsed .nav { padding-inline: 10px; }
.shell.is-collapsed .nav-logo, .shell.is-collapsed .nav-group-label, .shell.is-collapsed .nav-item .label,
.shell.is-collapsed .nav-badge, .shell.is-collapsed .nav-search span, .shell.is-collapsed .user-meta,
.shell.is-collapsed .nav-search .kbd { display: none; }
.shell.is-collapsed .nav-mark { display: block; }
.shell.is-collapsed .nav-head { flex-direction: column; padding-inline: 0; }
.shell.is-collapsed .nav-item, .shell.is-collapsed .nav-search { justify-content: center; padding: 0; }
.shell.is-collapsed .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.shell.is-collapsed .nav-group:first-of-type { border-top: 0; }
.shell.is-collapsed .nav-item[aria-current="page"]::before { left: -10px; }
.shell.is-collapsed .nav-item .dot-badge { display: block; }
.dot-badge { display: none; position: absolute; top: 7px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--topbar-bg); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--faint); }
.crumbs h1 { font-size: 16px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.updated { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.updated button { border: 0; background: transparent; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; }
.updated button:hover { background: var(--brand-tint); color: var(--text); }
.updated button svg { width: 15px; height: 15px; }
.updated button.is-spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 70ch; }

/* ---------- Empty state ---------- */
.empty {
  display: grid; justify-items: center; text-align: center; gap: 10px; padding: 56px 24px;
}
.empty-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-ink); }
.empty-icon svg { width: 24px; height: 24px; }
.empty h2 { font-size: 17px; }
.empty p { color: var(--muted); max-width: 52ch; }
.empty .step-list { margin-top: 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ---------- Home ---------- */
.hello { display: grid; gap: 4px; margin-bottom: 20px; }
.hello h1 { font-size: 24px; }
.hello p { color: var(--muted); }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.build-step { padding: 16px; display: grid; gap: 6px; align-content: start; }
.build-step .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.build-step .n { font: 700 12px/1 var(--font-head); color: var(--faint); letter-spacing: .06em; }
.build-step h3 { font-size: 14.5px; }
.build-step p { color: var(--muted); font-size: 13px; }
.build-step.is-done { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
a.tile { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.tile-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-ink); }
.tile-ico svg { width: 18px; height: 18px; }
.progress { height: 6px; border-radius: 99px; background: var(--surface); overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; width: 0; transition: width .8s var(--ease); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 10% -10%, var(--brand-tint), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, var(--accent-tint), transparent 60%), var(--surface); }
.login-card { width: 100%; max-width: 400px; padding: 32px 28px; display: grid; gap: 18px; }
.login-card .logo { height: 40px; width: auto; max-width: 200px; object-fit: contain; }
.login-card h1 { font-size: 22px; }
.login-card .sub { color: var(--muted); margin-top: -10px; }
.login-card form { display: grid; gap: 14px; }
.login-foot { font-size: 12px; color: var(--faint); text-align: center; }

/* Sign-in page: brand panel on the left, sign-in card on the right (stacked on phones). */
.login-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.login-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; padding: 40px 48px;
  color: #FFFFFF; background: linear-gradient(150deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 78%, #000) 100%); }
.lh-glow { position: absolute; inset: -60px; pointer-events: none;
  background: radial-gradient(520px 380px at 85% 10%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 70%),
    radial-gradient(460px 360px at 0% 100%, rgba(255, 255, 255, .10), transparent 70%); animation: lhDrift 14s ease-in-out infinite alternate; }
.login-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background-image: radial-gradient(#FFFFFF 1px, transparent 1px); background-size: 22px 22px; }
@keyframes lhDrift { from { transform: translate(0, 0); } to { transform: translate(-30px, 20px); } }
.lh-top, .lh-body, .lh-foot { position: relative; z-index: 1; }
.lh-logo { display: inline-flex; padding: 10px 14px; border-radius: 0; background: #FFFFFF; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.lh-logo img { height: 30px; width: auto; max-width: 180px; object-fit: contain; display: block; }
.lh-name { font: 700 20px/1 var(--font-head, var(--font-body)); }
.lh-body { max-width: 460px; display: grid; gap: 28px; }
.lh-body h2 { font-size: clamp(26px, 2.6vw, 36px); line-height: 1.15; letter-spacing: -.02em; color: #FFFFFF; }
.lh-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.lh-points li { display: flex; gap: 14px; align-items: flex-start; animation: lhIn .6s var(--ease) both; }
.lh-points li:nth-child(2) { animation-delay: .1s; } .lh-points li:nth-child(3) { animation-delay: .2s; }
@keyframes lhIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.lh-ico { flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); }
.lh-ico svg { width: 18px; height: 18px; }
.lh-points b { display: block; font-size: 15px; }
.lh-points small { display: block; margin-top: 2px; font-size: 13px; color: rgba(255, 255, 255, .72); }
.lh-foot { margin: 0; font-size: 12px; color: rgba(255, 255, 255, .6); }
.login-side { display: grid; place-items: center; padding: 32px 20px; }
.login-side .login-card { width: 100%; max-width: 380px; display: grid; gap: 18px; padding: 0; animation: dlgIn .35s var(--ease); }
.login-side .login-card h1 { font-size: 26px; letter-spacing: -.01em; }
.login-hello { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--accent-ink, var(--accent)); }
.login-logo-sm { display: none; height: 34px; width: auto; max-width: 180px; object-fit: contain; }
.login-expired { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--warn-tint); color: var(--warn-ink); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); font-size: 13.5px; line-height: 1.4; animation: dlgIn .3s var(--ease); }
.login-expired svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.login-expired b { font-weight: 700; }
.login-side .input { height: 44px; }
.login-side .btn-lg { height: 46px; }
.pass-field { position: relative; }
.pass-field .input { padding-right: 64px; }
.pass-eye { position: absolute; right: 6px; bottom: 7px; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 600 12px/1 var(--font-body); cursor: pointer; }
.pass-eye:hover { background: var(--surface); color: var(--text); }
@media (max-width: 860px) {
  .login-split { grid-template-columns: minmax(0, 1fr); }
  .login-hero { display: none; }
  .login-side { background: radial-gradient(900px 500px at 10% -10%, var(--brand-tint), transparent 60%), radial-gradient(700px 400px at 110% 110%, var(--accent-tint), transparent 60%), var(--surface); }
  .login-side .login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-2); padding: 28px 22px; }
  .login-logo-sm { display: block; }
}
@media (prefers-reduced-motion: reduce) { .lh-glow, .lh-points li, .login-side .login-card { animation: none; } }

/* Welcome after sign-in */
.dialog.welcome-dialog { width: min(460px, calc(100vw - 32px)); padding: 0; gap: 0; overflow: hidden; }
.wl-hero { position: relative; height: 112px; display: grid; place-items: center;
  background: radial-gradient(260px 140px at 80% 0%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%), linear-gradient(150deg, var(--brand), color-mix(in srgb, var(--brand) 75%, #000)); }
.wl-badge { position: relative; z-index: 1; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: #FFFFFF; color: var(--brand); box-shadow: 0 8px 22px rgba(0, 0, 0, .22); animation: wlPop .5s var(--ease) both; }
.wl-badge svg { width: 26px; height: 26px; }
.wl-ring { position: absolute; width: 56px; height: 56px; border-radius: 16px; border: 2px solid rgba(255, 255, 255, .55); animation: wlRing 1.8s ease-out .3s 2 both; }
@keyframes wlPop { from { opacity: 0; transform: scale(.6) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes wlRing { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(1.9); } }
.wl-text { padding: 20px 24px 4px; display: grid; gap: 6px; text-align: center; }
.wl-text h2 { font-size: 21px; }
.wl-text p { margin: 0; color: var(--muted); }
.wl-list { list-style: none; margin: 14px 24px 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wl-list li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.wl-list li span { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand-ink); }
.wl-list li svg { width: 15px; height: 15px; }
.welcome-dialog .actions { padding: 18px 24px 22px; }
.welcome-dialog .actions .btn svg { width: 15px; height: 15px; }
@media (max-width: 420px) { .wl-list { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .wl-badge, .wl-ring { animation: none; } .wl-ring { display: none; } }
.v2-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; background: var(--accent-tint); color: var(--accent-ink); font: 700 11px/18px var(--font-body); vertical-align: middle; }

/* ---------- Popover menu ---------- */
.menu {
  position: fixed; z-index: 95; min-width: 220px; padding: 6px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-2);
  animation: pop .18s var(--ease);
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head b { display: block; font-size: 13.5px; }
.menu-head small { color: var(--muted); font-size: 12px; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 6px;
  background: transparent; text-align: left; cursor: pointer; text-decoration: none; color: var(--text); font-size: 13.5px;
}
.menu button:hover, .menu a:hover { background: var(--surface); }
.menu svg { width: 16px; height: 16px; color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Command palette ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 80; background: var(--scrim);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: fade .18s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.palette {
  position: fixed; z-index: 81; top: 12vh; left: 50%; transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px)); background: var(--card); border-radius: 14px; box-shadow: var(--shadow-3);
  border: 1px solid var(--border); overflow: hidden; animation: palIn .18s var(--ease);
}
@keyframes palIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.palette-input input { flex: 1; height: 54px; border: 0; outline: 0; font-size: 15px; background: transparent; }
.palette-list { max-height: min(56vh, 460px); overflow-y: auto; padding: 6px; }
.palette-section { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.palette-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; text-align: left;
}
.palette-item[aria-selected="true"] { background: var(--brand-tint); }
.palette-item .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--muted); flex: none; }
.palette-item .ico svg { width: 16px; height: 16px; }
.palette-item .avatar { width: 30px; height: 30px; font-size: 11px; }
.palette-item .txt { min-width: 0; flex: 1; }
.palette-item .txt b { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .txt small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Dialog ---------- */
.dialog {
  position: fixed; z-index: 91; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px)); background: var(--card); border-radius: 14px; box-shadow: var(--shadow-3);
  border: 1px solid var(--border); padding: 24px; display: grid; gap: 14px; animation: dlgIn .18s var(--ease);
}
@keyframes dlgIn { from { opacity: 0; transform: translate(-50%, calc(-50% + 6px)); } to { opacity: 1; transform: translate(-50%, -50%); } }
.dialog p { color: var(--muted); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--toast-bg); color: var(--toast-fg); box-shadow: var(--shadow-2); font-size: 13.5px; animation: toastIn .18s var(--ease);
}
.toast .grow { flex: 1; }
.toast button { border: 0; background: transparent; color: var(--toast-action); font-weight: 700; cursor: pointer; }
.toast.is-bad { background: var(--bad); color: var(--on-solid); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Skeleton ---------- */
.sk { background: linear-gradient(90deg, var(--sk-a) 0%, var(--sk-b) 50%, var(--sk-a) 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 6px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Mobile ---------- */
.tabbar { display: none; }
.more-sheet {
  position: fixed; z-index: 81; left: 0; right: 0; bottom: 0; max-height: 80vh; overflow-y: auto;
  background: var(--card); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-3);
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px)); animation: sheetUp .2s var(--ease);
}
.more-sheet .grab { width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 10px; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 899px) {
  .shell, .shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
  .topbar { padding: 0 16px; padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }
  .page { padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--tabbar-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 44px; border: 0; background: transparent;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; cursor: pointer;
  }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar [aria-current="page"] { color: var(--brand-ink); }
  .updated .when { display: none; }
  .palette { top: 0; left: 0; transform: none; width: 100vw; height: 100dvh; border-radius: 0; animation: fade .18s var(--ease); display: flex; flex-direction: column; }
  .palette-list { max-height: none; flex: 1; }
  .palette-foot { display: none; }
  .toast-root { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
}

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

/* First-visit hint. */
.tip { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; margin-bottom: 14px; border: 1px solid var(--info-tint); border-radius: 10px; background: var(--info-tint); color: var(--text); font-size: 13px; line-height: 1.45; }
.tip > svg { width: 16px; height: 16px; flex: none; color: var(--info-ink); }
.tip > span { flex: 1; min-width: 0; }
.tip .btn { flex: none; }
