/* ═══════════════════════════════════════════════════════════════════════
   tidepage — application chrome
   Self-contained: design tokens (from the tidepage design system) + the
   host editor chrome (toolbar, floating selection toolbar, popovers,
   Ask bar, immersive mode, toasts). The rendered artifact lives in the
   webview and is styled by its own CSS, not this file.
   ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,300..600&family=Martian+Mono:wght@400..600&family=Schibsted+Grotesk:wght@400..700&display=swap');

/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Slate: cool graphite neutral ramp */
  --slate-50:#F5F8F7; --slate-100:#EAF0EE; --slate-200:#DCE4E1; --slate-300:#C3CFCB;
  --slate-400:#97A6A2; --slate-500:#66736F; --slate-600:#4A5754; --slate-700:#313D3A;
  --slate-800:#1D2725; --slate-900:#0F1614; --slate-950:#080D0C; --white:#FFFFFF;

  /* Tide: brand accent ramp (teal-green, not AI-blue) */
  --tide-50:#E4F6F2; --tide-100:#C5ECE6; --tide-200:#93DDD2; --tide-300:#4FCBBC;
  --tide-400:#1FB6A6; --tide-500:#0FA697; --tide-600:#0B8B7E; --tide-700:#097066;
  --tide-800:#06605A; --tide-900:#053F3B; --tide-bright:#2FD6C0;

  /* Semantic hues */
  --green-100:#D8F2E1; --green-500:#1F9D5C; --green-700:#137043;
  --amber-100:#FBE8C8; --amber-500:#D98A0B; --amber-700:#935C05;
  --red-100:#FBDFDA;   --red-500:#E0432E;   --red-700:#AE2B1B;
  --blue-100:#D7E6FA;  --blue-500:#2C72C9;  --blue-700:#1C4E94;

  /* Surfaces / text / borders (light) */
  --surface-page:var(--slate-100); --surface-card:var(--white); --surface-raised:var(--white);
  --surface-sunken:var(--slate-200); --surface-inset:var(--slate-50);
  --surface-hover:var(--slate-100); --surface-active:var(--slate-200);
  --text-primary:var(--slate-900); --text-secondary:var(--slate-600); --text-muted:var(--slate-500);
  --text-faint:var(--slate-400); --text-on-accent:#04201D; --text-link:var(--tide-700);
  --border-subtle:var(--slate-200); --border-default:var(--slate-300); --border-strong:var(--slate-400);

  /* Accent */
  --accent:var(--tide-500); --accent-hover:var(--tide-600); --accent-pressed:var(--tide-700);
  --accent-subtle:var(--tide-50); --accent-border:var(--tide-200); --accent-text:var(--tide-700);

  /* Highlight + status */
  --highlight-bg:var(--tide-50); --highlight-fg:var(--tide-700); --highlight-border:var(--tide-200);
  --success-bg:var(--green-100); --success-fg:var(--green-700); --success:var(--green-500);
  --warning-bg:var(--amber-100); --warning-fg:var(--amber-700); --warning:var(--amber-500);
  --danger-bg:var(--red-100);    --danger-fg:var(--red-700);    --danger:var(--red-500);
  --info-bg:var(--blue-100);     --info-fg:var(--blue-700);     --info:var(--blue-500);
  --focus-ring:color-mix(in srgb, var(--tide-500) 45%, transparent);
  --scrim:color-mix(in srgb, var(--slate-950) 48%, transparent);

  /* Type */
  --font-display:"Newsreader",Georgia,"Times New Roman",serif;
  --font-sans:"Schibsted Grotesk",ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --font-mono:"Martian Mono",ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  --text-2xs:11px; --text-xs:12px; --text-sm:13px; --text-base:15px; --text-md:16px;
  --text-lg:18px; --text-xl:22px; --text-2xl:28px;
  --weight-regular:400; --weight-medium:500; --weight-semibold:600; --weight-bold:700;
  --tracking-tight:-0.02em; --tracking-snug:-0.015em; --tracking-caps:0.05em;
  --wordmark-weight:300; --wordmark-tracking:-0.01em;

  /* Spacing / radii / sizing */
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:20px; --space-6:24px;
  --radius-xs:3px; --radius-sm:4px; --radius-md:6px; --radius-lg:9px; --radius-xl:13px; --radius-full:999px;
  --control-sm:28px; --control-md:36px; --control-lg:44px;
  --toolbar-height:52px;

  /* Elevation */
  --shadow-xs:0 1px 1px color-mix(in srgb, var(--slate-950) 6%, transparent);
  --shadow-sm:0 1px 2px color-mix(in srgb, var(--slate-950) 8%, transparent), 0 1px 3px color-mix(in srgb, var(--slate-950) 6%, transparent);
  --shadow-md:0 2px 4px color-mix(in srgb, var(--slate-950) 7%, transparent), 0 6px 16px color-mix(in srgb, var(--slate-950) 10%, transparent);
  --shadow-pop:0 2px 6px color-mix(in srgb, var(--slate-950) 9%, transparent), 0 12px 32px color-mix(in srgb, var(--slate-950) 18%, transparent);
  --shadow-hairline:inset 0 0 0 1px color-mix(in srgb, var(--slate-950) 5%, transparent);
  --shadow-glow:0 4px 14px color-mix(in srgb, var(--tide-500) 30%, transparent), 0 1px 4px color-mix(in srgb, var(--tide-500) 22%, transparent);
  --ring:0 0 0 3px var(--focus-ring);

  /* Motion */
  --dur-fast:140ms; --dur-base:220ms; --dur-slow:340ms;
  --ease-standard:cubic-bezier(0.2,0.6,0.2,1); --ease-out:cubic-bezier(0.16,1,0.3,1);
  --transition-colors:color var(--dur-fast) var(--ease-standard), background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}

[data-theme="dark"] {
  --surface-page:var(--slate-950); --surface-card:var(--slate-900); --surface-raised:#18211F;
  --surface-sunken:#060A09; --surface-inset:#101715; --surface-hover:#18211F; --surface-active:#202B28;
  --text-primary:var(--slate-50); --text-secondary:var(--slate-300); --text-muted:var(--slate-400);
  --text-faint:var(--slate-600); --text-on-accent:#04201D; --text-link:var(--tide-300);
  --border-subtle:#202B28; --border-default:#2E3A37; --border-strong:#43504C;
  --accent:var(--tide-500); --accent-hover:var(--tide-400); --accent-pressed:var(--tide-300);
  --accent-subtle:color-mix(in srgb, var(--tide-500) 20%, transparent);
  --accent-border:color-mix(in srgb, var(--tide-400) 40%, transparent); --accent-text:var(--tide-300);
  --highlight-bg:color-mix(in srgb, var(--tide-500) 22%, transparent); --highlight-fg:var(--tide-300);
  --highlight-border:color-mix(in srgb, var(--tide-400) 50%, transparent);
  --success-bg:color-mix(in srgb, var(--green-500) 20%, transparent); --success-fg:#6FD79C;
  --warning-bg:color-mix(in srgb, var(--amber-500) 22%, transparent); --warning-fg:#E6B65C;
  --danger-bg:color-mix(in srgb, var(--red-500) 22%, transparent); --danger-fg:#ED8A79;
  --info-bg:color-mix(in srgb, var(--blue-500) 24%, transparent); --info-fg:#8FB8EC;
  --focus-ring:color-mix(in srgb, var(--tide-400) 55%, transparent);
  --scrim:color-mix(in srgb, #000 62%, transparent);
  --shadow-md:0 2px 6px color-mix(in srgb,#000 40%,transparent), 0 8px 20px color-mix(in srgb,#000 45%,transparent);
  --shadow-pop:0 4px 10px color-mix(in srgb,#000 50%,transparent), 0 16px 40px color-mix(in srgb,#000 65%,transparent);
  --shadow-hairline:inset 0 0 0 1px color-mix(in srgb,#fff 6%,transparent);
}

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

/* ── Brand mark ─────────────────────────────────────────────────────── */
/* The horizon mark's ink strokes are currentColor; the live middle wave is
   the tide accent (brighter on dark). */
.tp-tide { stroke: var(--accent); }
[data-theme="dark"] .tp-tide { stroke: var(--tide-bright); }

/* ── Signature motion: save-state + waiting wave ────────────────────────
   The two (and only) functional animations in the product (BRAND_BRIEF §6).
   A standing wave whose amplitude swings through zero — crests oscillate up
   and down through the line — while work is unresolved (unsaved / waiting),
   and a flat solid line once it's safe (saved). Reduced-motion → static. */
.tp-wave { display: inline-flex; align-items: center; color: var(--accent); }
[data-theme="dark"] .tp-wave { color: var(--tide-bright); }
.tp-wave svg { display: block; overflow: visible; }
.tp-wave path, .tp-wave line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tp-wave--anim path { transform-box: fill-box; transform-origin: 50% 50%; animation: tp-amp 1.5s var(--ease-inout, ease-in-out) infinite; }
@keyframes tp-amp { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(-1); } }
@media (prefers-reduced-motion: reduce) { .tp-wave--anim path { animation: none; } }
.tp-save { margin-left: var(--space-2); }

/* ── Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--surface-card);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ── App shell ──────────────────────────────────────────────────────── */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--surface-card); overflow: hidden; }

/* ── Toolbar ────────────────────────────────────────────────────────── */
.bar {
  flex: none; display: flex; align-items: center; gap: var(--space-2);
  height: var(--toolbar-height); padding: 0 var(--space-3);
  background: color-mix(in srgb, var(--surface-card) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
/* The docked toolbar is the window's drag region (frameless window), and a
   stacking context above the webview so its tooltips/menus aren't painted under
   the document. */
.app > .bar { -webkit-app-region: drag; position: relative; z-index: 50; }
.app > .bar button, .app > .bar input, .app > .bar .seg, .app > .bar .menu, .app > .bar a { -webkit-app-region: no-drag; }
/* macOS keeps native traffic lights at top-left — inset the brand past them. */
.app[data-platform="mac"] > .bar { padding-left: 80px; }

/* Own window controls (Windows/Linux), flush into the top-right corner. */
.winctl { display: flex; align-self: stretch; margin-left: var(--space-1); margin-right: calc(-1 * var(--space-3)); -webkit-app-region: no-drag; }
.winctl__btn { width: 46px; height: var(--toolbar-height); border: none; background: transparent; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: var(--transition-colors); }
.winctl__btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.winctl__btn--close:hover { background: var(--danger); color: #fff; }
.winctl__btn svg { width: 15px; height: 15px; }
.bar__group { display: flex; align-items: center; gap: var(--space-1); }
.bar__spacer { flex: 1; }
.bar__divider { width: 1px; align-self: stretch; margin: 8px 4px; background: var(--border-default); }

.brand { display: inline-flex; align-items: center; gap: var(--space-2); padding-left: var(--space-1); }
.mark { width: 24px; height: 24px; flex: none; border-radius: 7px; display: inline-flex; }
.mark svg { width: 100%; height: 100%; display: block; }
.doc-title {
  font-family: var(--font-display); font-size: var(--text-md); font-weight: 600;
  letter-spacing: -0.02em; color: var(--text-primary);
  max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-left: var(--space-2);
}
/* Click-to-rename affordance (web): a subtle hover well, then a real input.
   Small positive margins on both sides keep the name clear of the brand mark
   and the save badge without the well overlapping either. */
.doc-title--editable { cursor: text; padding: 2px var(--space-2); margin: -2px var(--space-1); border-radius: var(--radius-md); transition: var(--transition-colors); }
.doc-title--editable:hover { background: var(--surface-hover); }
.doc-title--input {
  max-width: 32ch; min-width: 12ch; box-sizing: content-box;
  background: var(--surface-card); border: 1px solid var(--accent-border);
  border-radius: var(--radius-md); padding: 2px var(--space-2); margin: -2px var(--space-1);
  outline: none; box-shadow: var(--ring);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  --_bg: var(--accent); --_fg: var(--text-on-accent); --_bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 var(--space-4);
  font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1; white-space: nowrap;
  border: 1px solid var(--_bd); background: var(--_bg); color: var(--_fg);
  border-radius: var(--radius-md); cursor: pointer; user-select: none;
  transition: var(--transition-colors), transform var(--dur-fast) var(--ease-standard);
}
.btn:active { transform: translateY(0.5px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn--primary:hover { --_bg: var(--accent-hover); }
.btn--primary:active { --_bg: var(--accent-pressed); }
.btn--secondary { --_bg: var(--surface-card); --_fg: var(--text-primary); --_bd: var(--border-default); }
.btn--secondary:hover { --_bg: var(--surface-hover); --_bd: var(--border-strong); }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--control-md); height: var(--control-md);
  background: transparent; color: var(--text-secondary);
  border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; padding: 0;
  transition: var(--transition-colors), transform var(--dur-fast) var(--ease-standard);
}
.iconbtn:hover { background: var(--surface-hover); color: var(--text-primary); }
.iconbtn:active { background: var(--surface-active); transform: translateY(0.5px); }
.iconbtn[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn--solid { background: var(--accent); color: var(--text-on-accent); }
.iconbtn--solid:hover { background: var(--accent-hover); color: var(--text-on-accent); }
.iconbtn--active { background: var(--accent-subtle); color: var(--accent-text); }

/* ── Segmented control (Edit / Preview) ─────────────────────────────── */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface-sunken); border-radius: var(--radius-md); }
.seg__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 28px; padding: 0 var(--space-3); border: none; background: transparent;
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-muted);
  border-radius: calc(var(--radius-md) - 3px); cursor: pointer; white-space: nowrap;
  transition: var(--transition-colors);
}
.seg__btn:hover { color: var(--text-primary); }
.seg__btn svg { width: 15px; height: 15px; }
/* The active segment must read clearly against the sunken track in *both*
   themes. In dark mode the card surface is nearly the track colour and the
   light-theme shadow vanishes on near-black, so lift it onto the raised
   surface and add a hairline edge to define it. (#58) */
.seg__btn--active {
  background: var(--surface-raised); color: var(--text-primary);
  font-weight: var(--weight-semibold); box-shadow: var(--shadow-sm), var(--shadow-hairline);
}

/* ── Badge (save state) ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: 1;
  padding: 4px 8px; border-radius: var(--radius-full); white-space: nowrap;
}
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--neutral { background: var(--surface-sunken); color: var(--text-secondary); }
.badge--warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge--success { background: var(--success-bg); color: var(--success-fg); }

/* ── Avatar ─────────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-full);
  background: var(--tide-100); color: var(--tide-700);
  font-size: 11px; font-weight: var(--weight-semibold); user-select: none; box-shadow: var(--shadow-hairline);
}
[data-theme="dark"] .avatar { background: color-mix(in srgb, var(--tide-500) 30%, transparent); color: var(--tide-100); }

/* ── Menu (overflow) ────────────────────────────────────────────────── */
.menu { position: relative; display: inline-flex; }
.menu__pop {
  position: absolute; z-index: 80; min-width: 210px; top: calc(100% + 6px); right: 0;
  background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  padding: var(--space-1); display: flex; flex-direction: column; gap: 1px;
  animation: menu-in var(--dur-fast) var(--ease-out); transform-origin: top right;
}
/* Rendered at the app level so it floats above the webview (top/right set inline). */
.menu__pop--fixed { position: fixed; z-index: 90; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu__item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%;
  border: none; background: transparent; cursor: pointer; text-align: left;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--text-primary); font-family: inherit; transition: var(--transition-colors);
}
.menu__item:hover { background: var(--surface-hover); }
.menu__item svg { width: 16px; height: 16px; color: var(--text-secondary); flex: none; }
.menu__item--danger, .menu__item--danger svg { color: var(--danger-fg); }
.menu__label { flex: 1; }
.menu__shortcut { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.menu__divider { height: 1px; background: var(--border-subtle); margin: var(--space-1) 0; }
.menu__section {
  font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); color: var(--text-muted);
  padding: var(--space-2) var(--space-3) var(--space-1);
}
.menu__item--on { color: var(--accent-text); }
.menu__item--on .menu__label::after { content: " ✓"; color: var(--accent-text); }

/* ── Document area (full-bleed webview) ─────────────────────────────── */
.doc { flex: 1; min-height: 0; position: relative; background: var(--surface-card); }
.doc webview, .doc #artifact { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Notice banner (e.g. an unsupported/script-rendered document) */
.banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--info-bg); color: var(--info-fg);
  border-bottom: 1px solid color-mix(in srgb, var(--info-fg) 25%, transparent);
  font-size: var(--text-sm); line-height: 1.4;
  animation: toast-in var(--dur-base) var(--ease-out);
}
.banner__icon { display: inline-flex; flex: none; }
.banner__msg { flex: 1; }
.banner__action {
  flex: none; padding: 5px 12px; border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  border-radius: var(--radius-sm); background: var(--surface-card); color: var(--accent-text);
  font-size: var(--text-xs); font-weight: 600; cursor: pointer; transition: var(--transition-colors);
}
.banner__action:hover { background: var(--accent-subtle); }
.banner__close { border: none; background: transparent; color: inherit; cursor: pointer; padding: 4px; border-radius: var(--radius-sm); display: inline-flex; }
.banner__close:hover { background: color-mix(in srgb, currentColor 14%, transparent); }

/* Empty state when no file is open */
.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4); color: var(--text-muted); text-align: center; padding: var(--space-6);
}
.empty-state .mark { width: 56px; height: 56px; }
.empty-state h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); color: var(--text-primary); letter-spacing: -0.02em; }
.empty-state p { margin: 0; font-size: var(--text-sm); max-width: 42ch; line-height: 1.5; }
.empty-state .eyebrow { font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--accent-text); }

/* ── Floating selection toolbar (replaces the side panel) ───────────── */
.seltools {
  position: fixed; z-index: 80; display: flex; align-items: center; gap: 2px;
  background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 4px;
  animation: seltools-pop var(--dur-fast) var(--ease-out);
}
@keyframes seltools-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.seltools__kind { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 0 6px; white-space: nowrap; }
.seltools__div { width: 1px; align-self: stretch; background: var(--border-default); margin: 2px; }
.tool {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px;
  border: none; background: transparent; color: var(--text-secondary); cursor: pointer;
  border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: 500; transition: var(--transition-colors);
}
.tool:hover { background: var(--surface-hover); color: var(--text-primary); }
.tool--on { background: var(--accent-subtle); color: var(--accent-text); }
.tool--accent { color: var(--accent-text); }
.tool--accent:hover { background: var(--accent-subtle); }
.tool--danger:hover { background: var(--danger-bg); color: var(--danger-fg); }
.tool svg { width: 16px; height: 16px; }
.tool__fmt { width: 30px; padding: 0; justify-content: center; font-size: var(--text-md); }

/* ── Popovers (text / font / colour / style) ────────────────────────── */
.pop {
  position: fixed; z-index: 85; min-width: 200px; max-width: 280px;
  background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: var(--space-3);
  animation: menu-in var(--dur-fast) var(--ease-out);
}
.pop__title { font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); margin: 0 0 var(--space-2); }
.pop__title:not(:first-child) { margin-top: var(--space-3); }
.pop__hint { font-size: var(--text-2xs); color: var(--text-faint); margin-top: var(--space-2); line-height: 1.4; }
.pop__input { width: 100%; height: 32px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--surface-inset); color: var(--text-primary); font-family: var(--font-sans); font-size: var(--text-sm); padding: 0 var(--space-2); margin-bottom: var(--space-2); }
.pop__input:focus-visible { outline: none; box-shadow: var(--ring); }
.pop__btn { width: 100%; justify-content: center; margin-bottom: var(--space-2); }
.pop__row { display: flex; gap: var(--space-2); }

/* ── Deck filmstrip (§8.4): manage slides of a <deck-stage> deck ─────── */
.filmstrip {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 70; display: flex; align-items: center; gap: var(--space-2);
  max-width: min(90vw, 900px); overflow-x: auto; padding: var(--space-2);
  background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.filmchip {
  position: relative; display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  height: 34px; padding: 0 10px; border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); background: var(--surface-card); cursor: pointer;
  color: var(--text-secondary); font-size: var(--text-sm); transition: var(--transition-colors);
}
.filmchip:hover { background: var(--surface-hover); }
.filmchip--on { border-color: var(--accent); background: var(--accent-subtle); color: var(--accent-text); }
.filmchip--drop { box-shadow: -2px 0 0 0 var(--accent); }
.filmchip__n { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-faint); }
.filmchip__label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filmchip__act { display: none; width: 22px; height: 22px; border: none; background: transparent; border-radius: var(--radius-xs); color: var(--text-muted); cursor: pointer; }
.filmchip:hover .filmchip__act { display: inline-flex; align-items: center; justify-content: center; }
.filmchip__act:hover { background: var(--surface-active); color: var(--text-primary); }
.filmchip__act--danger:hover { background: var(--danger-bg); color: var(--danger-fg); }
.filmstrip__add { flex: 0 0 auto; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: transparent; color: var(--accent-text); cursor: pointer; }
.filmstrip__add:hover { background: var(--accent-subtle); }
.pop__hint kbd { font-family: var(--font-mono); background: var(--surface-sunken); border-radius: var(--radius-xs); padding: 0 4px; color: var(--text-secondary); }

/* ── Share panel (hosted web): list / copy / revoke public links ─────── */
.share-pop { min-width: 320px; max-width: 380px; }
.share-pop__body { display: flex; flex-direction: column; gap: var(--space-2); }
.share-empty { font-size: var(--text-sm); color: var(--text-muted); line-height: 1.4; padding: 2px 0 var(--space-1); }
.share-link { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "url actions" "meta actions"; align-items: center; gap: 0 var(--space-2); padding: var(--space-2); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-card); }
.share-link__url { grid-area: url; display: flex; align-items: center; gap: 6px; min-width: 0; }
.share-link__icon { display: inline-flex; color: var(--text-muted); flex: none; }
.share-link__text { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-link__meta { grid-area: meta; font-size: var(--text-2xs); color: var(--text-muted); margin-top: 2px; }
.share-link__actions { grid-area: actions; display: flex; gap: 2px; }
.share-pop__create { align-self: flex-start; gap: 6px; margin-top: 2px; }
.iconbtn--danger:hover { background: var(--danger-bg); color: var(--danger-fg); }

.swatches { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.swatch { width: 24px; height: 24px; border-radius: var(--radius-full); border: 2px solid transparent; cursor: pointer; box-shadow: var(--shadow-hairline); padding: 0; }
.swatch--on { border-color: var(--text-primary); }

.optlist { display: flex; flex-direction: column; gap: 2px; }
.opt {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; text-align: left;
  padding: var(--space-2) var(--space-3); border: none; background: transparent; cursor: pointer;
  border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--text-primary); transition: var(--transition-colors);
}
.opt:hover { background: var(--surface-hover); }
.opt--on { background: var(--accent-subtle); color: var(--accent-text); }
.opt--reset { color: var(--danger-fg); }
.opt--reset:hover { background: var(--danger-bg); }
.seg-row { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.seg-row .opt { width: auto; flex: 1 0 auto; justify-content: center; padding: 6px 10px; border: 1px solid var(--border-subtle); }
.seg-row .opt--on { border-color: var(--accent-border); }

/* Style picker option: a WYSIWYG preview of the selected text in the candidate
   style (issue #54). No raw class name — pure "what my text will look like". */
.styleopt { position: relative; display: block; width: 100%; text-align: left; padding: 8px 10px; margin-bottom: 4px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-card); cursor: pointer; overflow: hidden; transition: var(--transition-colors); }
.styleopt:last-of-type { margin-bottom: 0; }
.styleopt:hover { border-color: var(--accent-border); background: var(--surface-hover); }
.styleopt--on { border-color: var(--accent-border); background: var(--accent-subtle); }
.styleopt__text { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }
.styleopt--on .styleopt__text { padding-right: 16px; }
.styleopt__check { position: absolute; top: 7px; right: 9px; color: var(--accent-text); font-size: var(--text-xs); }
/* "More options… / ← Back to looks" — the escape hatch to atomic class toggles. */
.styleopt-more { display: block; width: 100%; margin-top: 4px; padding: 6px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-xs); text-align: center; cursor: pointer; transition: var(--transition-colors); }
.styleopt-more:hover { background: var(--surface-hover); color: var(--text-primary); }

/* ── Ask bar (preview; bottom-right corner, collapses to a pill) ──────────
   Anchored in the corner so it clears the bottom-center slide controls of
   Claude Design presentations. Collapses to a compact pill and grows leftward
   out of the corner when approached. */
.ask {
  position: fixed; bottom: 24px; right: 24px; z-index: 60;
  width: min(480px, calc(100% - 48px)); max-width: calc(100% - 48px);
  display: flex; align-items: center; gap: var(--space-2); padding: 7px 7px 7px var(--space-4);
  background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full); box-shadow: var(--shadow-pop); overflow: hidden;
  transition: width var(--dur-base) var(--ease-out), box-shadow var(--dur-fast) var(--ease-standard);
}
.ask--collapsed { width: 142px; padding: 7px var(--space-4); cursor: pointer; box-shadow: var(--shadow-md); }
.ask__spark { width: 18px; height: 18px; color: var(--accent); flex: none; display: inline-flex; }
.ask__label { display: none; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.ask--collapsed .ask__label { display: inline; }
.ask--collapsed .ask__input, .ask--collapsed .ask__badge, .ask--collapsed .ask__send { display: none; }
.ask__input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-family: var(--font-sans); font-size: var(--text-base); color: var(--text-primary); }
.ask__input::placeholder { color: var(--text-muted); }
.ask__send { width: 34px; height: 34px; flex: none; border: none; border-radius: var(--radius-full); background: var(--accent); color: var(--text-on-accent); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: var(--transition-colors); }
.ask__send:hover { background: var(--accent-hover); }
.ask__send svg { width: 18px; height: 18px; }
.ask__badge { font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-faint); flex: none; padding-right: var(--space-1); }

/* Font-size stepper (popover) */
.stepper { display: flex; align-items: center; gap: var(--space-2); }
.stepper__btn { width: 30px; height: 30px; flex: none; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-card); color: var(--text-secondary); cursor: pointer; font-size: 16px; line-height: 1; transition: var(--transition-colors); }
.stepper__btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.stepper__input { flex: 1; min-width: 0; height: 30px; text-align: center; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-inset); color: var(--text-primary); font-size: var(--text-sm); font-family: var(--font-mono); }
.stepper__input:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── Immersive chrome ───────────────────────────────────────────────── */
.app[data-chrome="immersive"] > .bar { display: none; }
/* Floating toolbar + reveal handles belong to immersive mode only. */
.app:not([data-chrome="immersive"]) .float,
.app:not([data-chrome="immersive"]) .handle { display: none; }
.float { position: fixed; left: 50%; z-index: 75; transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
.float--top { top: 14px; transform: translate(-50%, -160%); opacity: 0; pointer-events: none; }
.float--top.is-open { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.float .bar { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); height: auto; padding: var(--space-1); background: var(--surface-raised); }
.handle { position: fixed; left: 50%; transform: translateX(-50%); z-index: 74; border: none; cursor: pointer; background: var(--surface-raised); box-shadow: var(--shadow-md); color: var(--text-muted); transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-standard); }
/* When the toolbar slides in, the grip fades so the two read as one morph. */
.handle.is-hidden { opacity: 0; pointer-events: none; }
.handle--top { top: 0; width: 96px; height: 22px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: grid; place-items: center; }
.handle--top .handle__grip { width: 34px; height: 4px; border-radius: var(--radius-full); background: var(--border-strong); transition: var(--transition-colors); }
.handle--top:hover .handle__grip { background: var(--accent); }

/* ── Review drawer (comments / change requests) ─────────────────────── */
.iconbtn--badged { position: relative; }
.count-badge {
  position: absolute; top: 1px; right: 1px; min-width: 15px; height: 15px;
  padding: 0 3px; border-radius: var(--radius-full); background: var(--accent);
  color: var(--text-on-accent); font-size: 9px; font-weight: 700; line-height: 15px;
  text-align: center; box-shadow: 0 0 0 2px var(--surface-card);
}
.review {
  position: fixed; top: var(--toolbar-height); right: 0; bottom: 0; width: 324px; z-index: 70;
  display: flex; flex-direction: column; background: var(--surface-card);
  border-left: 1px solid var(--border-subtle); box-shadow: var(--shadow-lg);
  animation: review-in var(--dur-base) var(--ease-out);
}
.app[data-chrome="immersive"] .review { top: 0; }
@keyframes review-in { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.review__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.review__title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.review__filter { display: flex; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.review__tab { flex: 1; padding: 5px 6px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-xs); font-weight: 500; cursor: pointer; transition: var(--transition-colors); }
.review__tab:hover { background: var(--surface-hover); color: var(--text-primary); }
.review__tab--on { background: var(--accent-subtle); color: var(--accent-text); }
.review__list { flex: 1; overflow-y: auto; padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); }
.review__empty { color: var(--text-muted); font-size: var(--text-sm); line-height: 1.5; padding: var(--space-4) var(--space-2); text-align: center; }

.comment { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-3); background: var(--surface-card); box-shadow: var(--shadow-xs); transition: box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.comment--resolved { opacity: 0.62; }
.comment--flash { border-color: var(--accent-border); box-shadow: 0 0 0 2px var(--accent-subtle); }
.comment__top { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.comment__num { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--radius-full); background: var(--accent); color: #fff; font-size: var(--text-2xs); font-weight: 700; }
.comment__num--off { background: var(--surface-sunken); color: var(--text-muted); }
.chip-assignee { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full); font-size: var(--text-2xs); font-weight: 600; }
.chip-assignee svg { width: 12px; height: 12px; }
.chip-assignee--claude { background: var(--accent-subtle); color: var(--accent-text); }
.chip-assignee--author { background: var(--surface-sunken); color: var(--text-secondary); }
.chip-orphan { margin-left: auto; font-size: var(--text-2xs); font-weight: 600; color: var(--warning-fg); background: var(--warning-bg); padding: 2px 8px; border-radius: var(--radius-full); }
.chip-dynamic { margin-left: auto; font-size: var(--text-2xs); font-weight: 600; color: var(--accent-text); background: var(--accent-subtle); padding: 2px 8px; border-radius: var(--radius-full); }
.comment__body { font-size: var(--text-sm); color: var(--text-primary); line-height: 1.45; }
.comment__quote { display: block; width: 100%; text-align: left; margin-top: var(--space-2); padding: 6px 8px; border: none; border-left: 2px solid var(--accent-border); background: var(--surface-inset); color: var(--text-secondary); font-size: var(--text-xs); border-radius: var(--radius-xs); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: var(--transition-colors); }
.comment__quote:hover:not(:disabled) { background: var(--surface-hover); color: var(--text-primary); }
.comment__quote:disabled { cursor: default; opacity: 0.7; }
.comment__actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.comment__action { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-card); color: var(--text-secondary); font-size: var(--text-xs); font-weight: 500; cursor: pointer; transition: var(--transition-colors); }
.comment__action:hover { background: var(--surface-hover); color: var(--text-primary); }
.comment__action--danger { margin-left: auto; }
.comment__action--danger:hover { background: var(--danger-bg); color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* Comment composer (popover) */
.composer__input { width: 100%; resize: vertical; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--surface-inset); color: var(--text-primary); font-family: var(--font-sans); font-size: var(--text-sm); padding: var(--space-2); }
.composer__input:focus-visible { outline: none; box-shadow: var(--ring); }
.composer__add { width: 100%; margin-top: var(--space-3); }

/* ── HTML inspector ("view source") ─────────────────────────────────── */
.inspector {
  position: fixed; top: var(--toolbar-height); right: 0; bottom: 0; width: 384px; max-width: 92vw; z-index: 72;
  display: flex; flex-direction: column; background: var(--surface-card);
  border-left: 1px solid var(--border-subtle); box-shadow: var(--shadow-pop);
  animation: review-in var(--dur-base) var(--ease-out);
}
.app[data-chrome="immersive"] .inspector { top: 0; }
.inspector__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.inspector__title { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); }
.inspector__title svg { width: 16px; height: 16px; color: var(--text-muted); }
.inspector__tabs { display: flex; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); }
.inspector__tab { flex: 1; padding: 5px 6px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-size: var(--text-xs); font-weight: 500; cursor: pointer; transition: var(--transition-colors); }
.inspector__tab:hover { background: var(--surface-hover); color: var(--text-primary); }
.inspector__tab--on { background: var(--accent-subtle); color: var(--accent-text); }
.inspector__body { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }

/* Adjust tab — friendly controls */
.adjust { display: flex; flex-direction: column; gap: var(--space-4); }
.adjust__empty { color: var(--text-muted); font-size: var(--text-sm); line-height: 1.5; padding: var(--space-5) var(--space-2); text-align: center; }
.adjust__group { display: flex; flex-direction: column; gap: var(--space-2); }
.adjust__gtitle { font-family: var(--font-mono); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); }
.adjust__row { display: flex; align-items: center; gap: var(--space-2); min-height: 30px; }
.adjust__row--block { flex-direction: column; align-items: stretch; gap: 6px; }
.adjust__rowhead { display: flex; align-items: center; gap: var(--space-2); }
.adjust__label { width: 62px; flex: none; font-size: var(--text-xs); color: var(--text-secondary); }
.adjust__slider { flex: 1; min-width: 0; accent-color: var(--accent); height: 4px; }
.adjust__num { width: 56px; flex: none; height: 28px; text-align: center; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-inset); color: var(--text-primary); font-family: var(--font-mono); font-size: var(--text-xs); }
.adjust__num:focus-visible { outline: none; box-shadow: var(--ring); }
.adjust__unit { flex: none; height: 28px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-inset); color: var(--text-secondary); font-size: var(--text-xs); padding: 0 2px; }
.adjust__swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; }
.adjust__cur { width: 22px; height: 22px; border-radius: var(--radius-sm); border: 1px solid var(--border-default); flex: none; margin-right: 2px; }
.adjust__sw { width: 22px; height: 22px; padding: 0; border-radius: var(--radius-sm); border: 1px solid var(--border-default); cursor: pointer; }
.adjust__sw--custom { overflow: hidden; background: conic-gradient(red, magenta, blue, cyan, lime, yellow, red); }
.adjust__sw--none { position: relative; background: var(--surface-card); }
.adjust__sw--none::after { content: ""; position: absolute; inset: 1px; background: linear-gradient(to top right, transparent 44%, var(--danger) 45%, var(--danger) 55%, transparent 56%); }
.adjust__expand { align-self: flex-start; background: none; border: none; color: var(--accent-text); font-size: var(--text-2xs); cursor: pointer; padding: 0; }
.adjust__sides { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.adjust__side { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.adjust__side span { font-size: var(--text-2xs); color: var(--text-faint); font-family: var(--font-mono); }
.adjust__side input { width: 100%; height: 26px; text-align: center; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-inset); color: var(--text-primary); font-family: var(--font-mono); font-size: var(--text-2xs); }
.adjust__side input:focus-visible { outline: none; box-shadow: var(--ring); }
.adjust__status { padding-top: var(--space-3); border-top: 1px solid var(--border-subtle); }
.inspector__empty { color: var(--text-muted); font-size: var(--text-sm); line-height: 1.55; padding: var(--space-6) var(--space-2); text-align: center; }

.inspector__crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; font-family: var(--font-mono); font-size: var(--text-2xs); }
.crumb { padding: 2px 6px; border-radius: var(--radius-xs); color: var(--text-muted); background: transparent; border: none; cursor: pointer; font: inherit; transition: var(--transition-colors); }
.crumb:hover { background: var(--surface-hover); color: var(--text-primary); }
.crumb--current { color: var(--accent-text); background: var(--accent-subtle); cursor: default; }
.crumb__sep { color: var(--text-faint); }

.code-field { border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-sunken); transition: var(--transition-colors); }
.code-field.is-focus { box-shadow: var(--ring); border-color: var(--accent-border); }
.code-field.is-error { border-color: color-mix(in srgb, var(--danger) 55%, transparent); box-shadow: 0 0 0 2px var(--danger-bg); }
.code-field__edit {
  margin: 0; padding: var(--space-3); min-height: 70px;
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.65; letter-spacing: 0; tab-size: 2;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  color: var(--text-secondary); caret-color: var(--accent); outline: none;
}
.code-field__edit::selection { background: var(--accent-subtle); }

.tok-punct { color: var(--text-faint); }
.tok-tag { color: var(--accent-text); font-weight: 600; }
.tok-attr { color: var(--info-fg); }
.tok-string, .tok-value { color: var(--success-fg); }

.inspector__status { min-height: 16px; font-size: var(--text-2xs); line-height: 1.4; }
.inspector__status--ok { color: var(--text-faint); }
.inspector__status--err { color: var(--danger-fg); }
.inspector__actions { display: flex; gap: var(--space-2); }
.inspector__actions .btn { flex: 1; justify-content: center; }
.inspector__hint { margin: 0; font-size: var(--text-2xs); color: var(--text-faint); line-height: 1.55; }
.inspector__hint code { font-family: var(--font-mono); background: var(--surface-sunken); border-radius: var(--radius-xs); padding: 0 4px; color: var(--text-secondary); }
.inspector__hint kbd { font-family: var(--font-mono); background: var(--surface-sunken); border-radius: var(--radius-xs); padding: 0 4px; color: var(--text-secondary); }

/* ── Toasts ─────────────────────────────────────────────────────────── */
.toast-layer { position: fixed; bottom: 20px; right: 20px; z-index: 95; display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-end; }
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: var(--surface-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  padding: var(--space-3) var(--space-4); min-width: 260px; max-width: 400px;
  animation: toast-in var(--dur-base) var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast__icon { width: 18px; height: 18px; flex: none; margin-top: 1px; display: inline-flex; }
.toast__icon svg { width: 18px; height: 18px; }
.toast--success .toast__icon { color: var(--success-fg); }
.toast--danger .toast__icon { color: var(--danger-fg); }
.toast--info .toast__icon { color: var(--info-fg); }
.toast--neutral .toast__icon { color: var(--text-secondary); }
.toast__body { flex: 1; font-size: var(--text-sm); color: var(--text-primary); line-height: 1.4; }

/* ── Tooltip (CSS-only, title-driven via data attr) ─────────────────── */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); left: 50%; translate: -50% 0;
  background: var(--slate-900); color: var(--slate-50); font-size: var(--text-xs); font-weight: 500;
  padding: 5px 8px; border-radius: var(--radius-sm); white-space: nowrap; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-fast) var(--ease-out); z-index: 90;
}
[data-theme="dark"] .tip::after { background: var(--slate-100); color: var(--slate-950); }
.tip:hover::after { opacity: 1; }
.tip--bottom::after { bottom: auto; top: calc(100% + 7px); }
/* Toolbar sits at the window's top edge — show its tooltips below the buttons. */
.bar .tip::after { bottom: auto; top: calc(100% + 7px); }

/* ── review view (web; spec §4.4) ─────────────────────────────────────── */
.rv-body { margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; background: var(--surface-page); color: var(--text-primary); }
.rv-top { display: flex; align-items: center; gap: var(--space-3); height: var(--toolbar-height); padding: 0 var(--space-4); background: var(--surface-card); border-bottom: 1px solid var(--border-subtle); flex: none; z-index: 5; }
.rv-back { border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-secondary); border-radius: var(--radius-md); padding: 6px 11px; font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.rv-back:hover { background: var(--surface-hover); color: var(--text-primary); }
.rv-title { font-weight: 600; font-size: var(--text-md); }
.rv-reviewing { display: inline-flex; align-items: center; gap: 7px; background: var(--warning-bg); color: var(--warning-fg); padding: 4px 11px; border-radius: var(--radius-full); font-weight: 600; font-size: var(--text-xs); }
.rv-reviewing::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.rv-top .rv-seg { margin-left: auto; }
.rv-seg { display: inline-flex; background: var(--surface-inset); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.rv-seg button { border: 0; background: transparent; color: var(--text-secondary); padding: 6px 12px; border-radius: var(--radius-sm); font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.rv-seg button[aria-pressed="true"] { background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.rv-stage { position: relative; flex: 1; overflow: hidden; }
.rv-framewrap { position: absolute; inset: 0 264px 0 0; background: var(--surface-inset); }
.rv-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.rv-ba { position: absolute; inset: 0; }
.rv-ba__before, .rv-ba__after { position: absolute; inset: 0; }
.rv-ba__after { background: #fff; }
.rv-ba__divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--accent); z-index: 5; cursor: ew-resize; }
.rv-ba__divider::after { content: "⇆"; position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; box-shadow: var(--shadow-md); }
.rv-ba__tag { position: absolute; top: 12px; z-index: 6; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0,0,0,.6); padding: 3px 9px; border-radius: var(--radius-full); }
.rv-ba__tag--l { left: 12px; } .rv-ba__tag--r { right: 12px; }

.rv-rail { position: absolute; top: 0; right: 0; bottom: 0; width: 264px; background: var(--surface-card); border-left: 1px solid var(--border-subtle); padding: var(--space-4) var(--space-3); overflow: auto; }
.rv-rail h3 { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--text-muted); margin: 4px 4px var(--space-3); }
.rv-empty { color: var(--text-muted); font-size: var(--text-sm); padding: 0 4px; }
.rv-item { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 9px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 9px 8px; border-radius: var(--radius-md); margin-bottom: 3px; color: var(--text-primary); cursor: pointer; }
.rv-item:hover { background: var(--surface-hover); }
.rv-item.is-sel { background: var(--surface-hover); border-color: var(--border-default); }
.rv-item.is-rejected { opacity: .6; }
.rv-item__txt { min-width: 0; display: flex; flex-direction: column; }
.rv-item__k { font-weight: 600; font-size: var(--text-sm); }
.rv-item__s { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-item__state { font-size: 10px; font-weight: 700; color: var(--danger-fg); text-transform: uppercase; }
.rv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint); }
.rv-item[data-kind="modified"] .rv-dot, .rv-card[data-kind="modified"] .rv-dot { background: #2563eb; }
.rv-item[data-kind="added"] .rv-dot, .rv-card[data-kind="added"] .rv-dot { background: #16a34a; }
.rv-item[data-kind="removed"] .rv-dot, .rv-card[data-kind="removed"] .rv-dot { background: #dc2626; }
.rv-item[data-kind="restyled"] .rv-dot, .rv-card[data-kind="restyled"] .rv-dot { background: #9333ea; }

.rv-card { position: absolute; z-index: 8; width: 300px; right: 300px; top: 90px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); display: none; overflow: hidden; }
.rv-card.show { display: block; }
.rv-card__head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--border-subtle); }
.rv-card__k { font-weight: 700; font-size: var(--text-sm); }
.rv-card__step { margin-left: auto; font-size: var(--text-xs); color: var(--text-muted); }
.rv-card__body { padding: 12px 14px; font-size: var(--text-sm); color: var(--text-secondary); }
.rv-card__actions { display: flex; gap: 8px; padding: 11px 14px; border-top: 1px solid var(--border-subtle); }
.rv-cbtn { flex: 1; border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-primary); padding: 7px 12px; border-radius: var(--radius-md); font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.rv-cbtn--rej:hover, .rv-cbtn--rej.is-on { border-color: var(--danger); color: var(--danger-fg); background: var(--danger-bg); }
.rv-cbtn--acc.is-on { border-color: var(--success, #16a34a); }

.rv-bar { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-4); background: var(--surface-card); border-top: 1px solid var(--border-subtle); flex: none; }
.rv-count { font-weight: 650; font-size: var(--text-sm); }
.rv-progress { font-size: var(--text-xs); color: var(--text-muted); }
.rv-sep { width: 1px; height: 22px; background: var(--border-subtle); }
.rv-nav { display: flex; gap: 4px; }
.rv-nav button { width: 30px; height: 30px; border: 1px solid var(--border-default); background: var(--surface-card); border-radius: var(--radius-md); color: var(--text-secondary); cursor: pointer; }
.rv-nav button:hover { background: var(--surface-hover); }
.rv-bar .rv-btn { margin-left: 0; border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-primary); padding: 8px 14px; border-radius: var(--radius-md); font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.rv-bar .rv-btn:first-of-type { margin-left: auto; }
.rv-btn--apply { background: var(--accent); border-color: var(--accent) !important; color: #fff; }
.rv-btn--apply:hover { filter: brightness(.96); }

/* ── version-history panel (hosted web) ───────────────────────────────── */
.ver-pop { width: 340px; }
.ver-row { gap: 4px 8px; }
.ver-row.is-cmp { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-md); }
.ver-badge { margin-left: 8px; font-size: var(--text-2xs); font-weight: 700; color: var(--text-muted); background: var(--surface-inset); border: 1px solid var(--border-subtle); border-radius: var(--radius-full); padding: 1px 7px; text-transform: uppercase; letter-spacing: .03em; }
.ver-badge--head { color: var(--success-fg, #15803d); background: var(--success-bg, #e9f7ee); border-color: transparent; }
