/* Editor chrome — UX Jobs sponsor palette (sponsor.uxjobs.io) */

/* Inter, self-hosted (SIL OFL 1.1 — see assets/fonts/LICENSE-Inter.txt).
   Served locally rather than from fonts.googleapis.com: no third-party
   request per load, works offline, and keeps html-to-image from trying to
   inline a cross-origin stylesheet during export. Latin subset only —
   matches the weights the editor actually uses. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/inter-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/inter-latin-700-normal.woff2') format('woff2');
}

:root {
  --gold: #ffcb05;
  --gold-deep: #e0a800;
  --ink: #16161a;
  --ink-soft: #3a3a40;
  --muted: #6b6b73;
  --muted-2: #8b8b93;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --line: rgb(22 22 26 / 0.1);
  --line-soft: rgb(22 22 26 / 0.05);
  --grid: rgb(22 22 26 / 0.045);
  --bg: var(--paper);
  --surface: var(--panel);
  --surface-2: #f5f4f0;
  --border: var(--line);
  --border-strong: var(--line);
  --text: var(--ink);
  --accent: var(--gold-deep);
  --accent-soft: #fff9df;
  --accent-strong: #b88600;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --shadow: 0 1px 2px rgb(22 22 26 / 0.04), 0 12px 32px -12px rgb(22 22 26 / 0.12);
  --topbar-bg: rgb(255 255 255 / 0.82);
  --chrome-bg: rgb(255 255 255 / 0.92);
  --menu-border: rgb(22 22 26 / 0.12);
  --menu-shadow: 0 8px 28px rgb(22 22 26 / 0.14), 0 24px 48px -16px rgb(22 22 26 / 0.2);
  --primary-btn-bg: #16161a;
  --primary-btn-hover: #2a2a30;
  --primary-btn-fg: var(--gold);
  --success: #1a7f37;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar: 320px;
  --topbar: 72px;
  --format-bar: 58px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

html[data-color-mode="dark"] {
  color-scheme: dark;
  --ink: #f2f1ec;
  --ink-soft: #c8c7c0;
  --muted: #9a9992;
  --muted-2: #7a7972;
  --paper: #121214;
  --panel: #1a1a1e;
  --line: rgb(255 255 255 / 0.12);
  --line-soft: rgb(255 255 255 / 0.07);
  --grid: rgb(255 255 255 / 0.05);
  --bg: var(--paper);
  --surface: var(--panel);
  --surface-2: #242428;
  --border: var(--line);
  --border-strong: rgb(255 255 255 / 0.16);
  --text: var(--ink);
  --accent: var(--gold);
  --accent-soft: rgb(255 203 5 / 0.14);
  --accent-strong: #ffd84a;
  --danger: #f97066;
  --danger-soft: rgb(249 112 102 / 0.14);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.35), 0 12px 32px -12px rgb(0 0 0 / 0.55);
  --topbar-bg: rgb(18 18 20 / 0.88);
  --chrome-bg: rgb(26 26 30 / 0.94);
  --menu-border: rgb(255 255 255 / 0.12);
  --menu-shadow: 0 8px 28px rgb(0 0 0 / 0.4), 0 24px 48px -16px rgb(0 0 0 / 0.5);
  --primary-btn-bg: var(--gold);
  --primary-btn-hover: #ffd633;
  --primary-btn-fg: #16161a;
  --success: #6fcf7f;
}

/* ============================================================
   UI THEMES — editor chrome only, ported from the UX Jobs Chrome
   extension panel themes (chrome-extension/sidepanel.css).
   These ride on top of the dark block above (resolveColorMode()
   maps every named theme to 'dark'), so they only remap the palette.
   Must stay AFTER the dark rule — equal specificity, source order wins.
   The card stage keeps its own fixed dark surface, so cards are
   unaffected by the editor's appearance.
   ============================================================ */
html[data-ui-theme="steel"] {          /* cool slate dossier — cyan on dark blue-gray (no CRT) */
  --ink: #cbdde6;
  --ink-soft: #a8c0cc;
  --muted: #6d8494;
  --muted-2: #566b79;
  --paper: #0d1620;
  --panel: #16232f;
  --surface-2: #20313f;
  --line: rgb(203 221 230 / 0.14);
  --line-soft: rgb(203 221 230 / 0.08);
  --grid: rgb(203 221 230 / 0.05);
  --border-strong: rgb(203 221 230 / 0.22);
  --accent: #5fd3d8;
  --accent-soft: rgb(95 211 216 / 0.14);
  --accent-strong: #8fe4e8;
  --topbar-bg: rgb(13 22 32 / 0.9);
  --chrome-bg: rgb(22 35 47 / 0.94);
  --menu-border: rgb(203 221 230 / 0.16);
  --primary-btn-bg: #5fd3d8;
  --primary-btn-hover: #8fe4e8;
  --primary-btn-fg: #0d1620;
  --success: #6fcf9f;
}
html[data-ui-theme="agency"] {         /* grayscale intel UI + orange accent (MI6), no CRT */
  --ink: #ececec;
  --ink-soft: #c4c4c4;
  --muted: #8a8a8a;
  --muted-2: #6e6e6e;
  --paper: #1a1a1a;
  --panel: #242424;
  --surface-2: #2f2f2f;
  --line: rgb(255 255 255 / 0.13);
  --line-soft: rgb(255 255 255 / 0.07);
  --grid: rgb(255 255 255 / 0.05);
  --border-strong: rgb(255 255 255 / 0.2);
  --accent: #f5891f;
  --accent-soft: rgb(245 137 31 / 0.14);
  --accent-strong: #ffa550;
  --topbar-bg: rgb(26 26 26 / 0.9);
  --chrome-bg: rgb(36 36 36 / 0.94);
  --menu-border: rgb(255 255 255 / 0.15);
  --primary-btn-bg: #f5891f;
  --primary-btn-hover: #ffa550;
  --primary-btn-fg: #1a1a1a;
  --success: #6fcf7f;
}
html[data-ui-theme="green"] {          /* green-phosphor CRT (Silo) */
  --ink: #5ff2b0;
  --ink-soft: #46c98f;
  --muted: #2e8f66;
  --muted-2: #247352;
  --paper: #04100a;
  --panel: #0a1a12;
  --surface-2: #10241a;
  --line: rgb(95 242 176 / 0.16);
  --line-soft: rgb(95 242 176 / 0.09);
  --grid: rgb(95 242 176 / 0.06);
  --border-strong: rgb(95 242 176 / 0.24);
  --accent: #5ff2b0;
  --accent-soft: rgb(95 242 176 / 0.14);
  --accent-strong: #8ff8cb;
  --topbar-bg: rgb(4 16 10 / 0.9);
  --chrome-bg: rgb(10 26 18 / 0.94);
  --menu-border: rgb(95 242 176 / 0.18);
  --primary-btn-bg: #5ff2b0;
  --primary-btn-hover: #8ff8cb;
  --primary-btn-fg: #04100a;
  --success: #5ff2b0;
}
/* Phosphor glow on the wordmark, as the extension does on .brand-title —
   tube/glow themes only. Steel and Agency are deliberately flat (no CRT). */
html[data-ui-theme="green"] .brand h1 {
  text-shadow: 0 0 6px currentColor;
}

/* Theme swatches in the Appearance menu */
.settings-menu-subheading {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ui-theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex: none;
  border: 1px solid var(--border);
}
.ui-theme-swatch[data-ui-theme-swatch="steel"]    { background: #0d1620; box-shadow: inset 0 0 0 2px #5fd3d8; }
.ui-theme-swatch[data-ui-theme-swatch="agency"]   { background: #1a1a1a; box-shadow: inset 0 0 0 2px #f5891f; }
.ui-theme-swatch[data-ui-theme-swatch="green"]    { background: #04100a; box-shadow: inset 0 0 0 2px #5ff2b0; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font: inherit;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 20px 0 16px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
  z-index: 170;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-toggle.icon-btn {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  /* Borderless, like the job board's hamburger (.icon-btn has border:none). The base
     .btn class adds a 1px border and .ghost only clears the background, not the border. */
  border: none;
}

.sidebar-toggle-icon {
  grid-area: 1 / 1;
  display: flex;
  width: 20px;
  height: 20px;
  transition: opacity 140ms ease, transform 180ms cubic-bezier(0.33, 1, 0.68, 1);
}

.sidebar-toggle-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.sidebar-toggle-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

body.sidebar-open .sidebar-toggle-icon-menu {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

body.sidebar-open .sidebar-toggle-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex: none;
  display: block;
  object-fit: contain;
  background: transparent;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.beta-tag {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted-2);
  font-size: 11px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.pathway-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions .btn,
.pathway-actions .btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 37px;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1.2;
}

/* Download CTA follows the ACTIVE theme's primary button colour — every theme sets
   --primary-btn-bg / --primary-btn-fg, so this stays in sync instead of a hardcoded gold. */
.btn-download.btn.primary {
  background: var(--primary-btn-bg);
  color: var(--primary-btn-fg);
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 6px 16px -8px rgb(0 0 0 / 0.4);
}

.btn-download.btn.primary:hover {
  filter: brightness(1.06);
}

.icon-btn {
  width: 37px;
  min-width: 37px;
  padding: 0 !important;
}

.icon-btn-glyph {
  display: flex;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.icon-btn-glyph svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn:hover .icon-btn-glyph,
.icon-btn[aria-expanded="true"] .icon-btn-glyph {
  color: var(--text);
}

/* ---------- settings menu popover ---------- */

.settings-menu-anchor {
  position: relative;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 120;
  width: min(248px, calc(100vw - 32px));
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--menu-border);
  background: var(--panel);
  box-shadow: var(--menu-shadow);
}

.settings-menu[hidden] {
  display: none;
}

.settings-menu-heading {
  margin: 0 0 10px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.color-mode-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.color-mode-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 10px 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.color-mode-option:hover {
  background: var(--surface-2);
  color: var(--text);
}

.color-mode-option[aria-checked="true"] {
  background: var(--accent-soft);
  border-color: rgb(255 203 5 / 0.45);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgb(255 203 5 / 0.18);
}

.color-mode-option-icon {
  display: flex;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.color-mode-option-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.color-mode-option-label {
  letter-spacing: 0.01em;
}

/* ---------- export menu popover ---------- */

.export-menu-anchor {
  position: relative;
}

.export-menu-toggle {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.export-menu-toggle-label {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 12px 0 14px;
}

.export-menu-toggle.btn.ghost .export-menu-toggle-label {
  padding: 0 12px;
}

.export-menu-chevron-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  padding: 0 12px;
  border-left: 1px solid rgb(255 255 255 / 0.14);
  background: rgb(0 0 0 / 0.14);
  transition: background 180ms ease;
}

/* Post it yourself — equal space each side of chevron */
.pathway-actions .export-menu-toggle.btn.ghost {
  padding: 0;
}

.export-menu-toggle.btn.ghost .export-menu-chevron-wrap {
  padding: 0 12px;
}

.export-menu-toggle:hover .export-menu-chevron-wrap {
  background: rgb(0 0 0 / 0.22);
}

.export-menu-toggle[aria-expanded="true"] .export-menu-chevron-wrap {
  background: rgb(0 0 0 / 0.28);
}

.export-menu-chevron {
  display: flex;
  width: 16px;
  height: 16px;
  color: rgb(255 203 5 / 0.95);
  transition: transform 260ms cubic-bezier(0.33, 1, 0.68, 1);
}

.export-menu-chevron svg {
  width: 16px;
  height: 16px;
  display: block;
}

.export-menu-toggle[aria-expanded="true"] .export-menu-chevron {
  transform: rotate(180deg);
}

.export-menu-toggle.btn.ghost .export-menu-chevron-wrap,
.export-menu-toggle.btn.ghost:hover .export-menu-chevron-wrap,
.export-menu-toggle.btn.ghost[aria-expanded="true"] .export-menu-chevron-wrap {
  border-left-color: var(--line);
  background: transparent;
}

.export-menu-toggle.btn.ghost .export-menu-chevron {
  color: var(--muted);
}

.export-menu {
  position: fixed;
  z-index: 180;
  width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius);
  border: 1px solid var(--menu-border);
  background: var(--panel);
  box-shadow: var(--menu-shadow);
  overflow: hidden;
  /* Desktop top/right set in JS under the Post it yourself control */
}

.export-menu[hidden] {
  display: none;
}

/* Mobile: same download dialog, docked as a bottom sheet (not a new flow) */
.export-menu.export-menu-sheet {
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  top: auto;
  transform: none;
  width: auto;
  max-width: none;
  max-height: min(72dvh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
  box-shadow:
    0 -4px 24px rgb(0 0 0 / 0.18),
    var(--menu-shadow);
}

body.export-open {
  overflow: hidden;
}

body.export-open::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 170;
  background: rgb(22 22 26 / 0.4);
  pointer-events: none;
}

@media (min-width: 981px) {
  body.export-open {
    overflow: auto;
  }

  body.export-open::before {
    display: none;
  }
}

.export-menu-export {
  padding: 14px 16px 12px;
}

.export-menu-lede strong {
  color: var(--ink-soft);
  font-weight: 700;
}

.export-menu-heading,
.export-menu-featured-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.export-menu-heading {
  color: var(--muted);
}

.export-menu-lede {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.export-menu-guidelines {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border, rgb(0 0 0 / 0.08));
  background: var(--surface-2, rgb(0 0 0 / 0.03));
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.export-menu-guidelines strong {
  color: var(--ink-soft);
  font-weight: 700;
}

[data-color-mode="dark"] .export-menu-guidelines {
  background: rgb(255 255 255 / 0.04);
  border-color: rgb(255 255 255 / 0.08);
}

.export-menu-success {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #edf9f0;
  border: 1px solid rgb(34 120 60 / 0.16);
}

.export-menu-success[hidden] {
  display: none;
}

.export-menu-success-icon {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #1f7a3f;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.export-menu-success-body {
  min-width: 0;
}

.export-menu-success-title {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: #14532d;
}

.export-menu-success-copy {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #166534;
}

.export-menu-actions {
  margin: 0;
  padding: 0;
  list-style: none;
}

.export-menu-action {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.export-menu-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 2px;
  color: var(--muted);
}

.export-menu-action-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.export-menu-action:hover .export-menu-action-icon,
.export-menu-action:first-child .export-menu-action-icon {
  color: var(--ink);
}

.export-menu-action-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-menu-action-label {
  line-height: 1.25;
}

.export-menu-action-desc {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--muted);
}

.export-menu-action-hint {
  margin-left: auto;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: 42%;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  text-align: right;
}

.export-menu-action-hint-text {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.export-menu-action-hint-dim {
  font-size: 10px;
  line-height: 1.25;
  color: var(--muted);
}

.export-menu-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

.export-menu-action:hover:not(:disabled) {
  background: var(--surface-2);
}

.export-menu-action:first-child {
  background: var(--surface-2);
}

.export-menu-action:first-child:hover:not(:disabled) {
  background: var(--accent-soft);
}

.export-menu-featured {
  padding: 16px 16px 18px;
  background: var(--ink);
  color: rgb(255 255 255 / 0.88);
}

.export-menu-featured-title {
  color: #fff;
}

.export-menu-featured-copy {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: rgb(255 255 255 / 0.72);
}

.export-menu-tiers {
  margin: 0;
  padding: 0;
  list-style: none;
}

.export-menu-tier {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px dotted rgb(255 255 255 / 0.18);
}

.export-menu-tier:first-child {
  border-top: none;
  padding-top: 0;
}

.export-menu-tier-rec {
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.06);
}

.export-menu-tier-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.export-menu-tier-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.export-menu-tier-badge {
  color: #6fcf7f;
  font-size: 12px;
}

.export-menu-tier-detail {
  font-size: 12px;
  color: rgb(255 255 255 / 0.58);
}

.export-menu-tier-price {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.export-menu-featured-cta {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.export-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: min(440px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  background: #16161a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.28);
  transform: translateX(-50%);
  animation: export-toast-in 180ms ease;
}

.export-toast.is-error {
  background: #3b1210;
  border: 1px solid rgb(249 112 102 / 0.35);
}

.export-toast-text {
  min-width: 0;
  flex: 1;
}

.export-toast-retry {
  appearance: none;
  flex: none;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.1);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.export-toast-retry:hover {
  background: rgb(255 255 255 / 0.18);
}

.export-toast-retry[hidden] {
  display: none;
}

.export-toast[hidden] {
  display: none;
}

@keyframes export-toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ---------- floating action button ---------- */

.fab-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.fab-root > * {
  pointer-events: auto;
}

body.feed-open .fab-root,
body.onboard-open .fab-root {
  visibility: hidden;
  pointer-events: none;
}

body.feedback-open .fab-actions {
  display: none !important;
}

.fab {
  appearance: none;
  width: 56px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: #16161a;
  box-shadow:
    0 2px 6px rgb(0 0 0 / 0.12),
    0 10px 28px rgb(0 0 0 / 0.18);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.fab:hover {
  background: #ffd633;
  transform: translateY(-1px);
  box-shadow:
    0 4px 10px rgb(0 0 0 / 0.14),
    0 14px 32px rgb(0 0 0 / 0.2);
}

.fab:active {
  transform: translateY(0);
}

/* Under a named UI theme the FAB follows that theme's primary-action colours,
   matching .btn.primary. Light/Dark deliberately keep the gold FAB. */
html[data-ui-theme] .fab {
  background: var(--primary-btn-bg);
  color: var(--primary-btn-fg);
}
html[data-ui-theme] .fab:hover {
  background: var(--primary-btn-hover);
}

.fab-icon {
  grid-area: 1 / 1;
  display: flex;
  width: 24px;
  height: 24px;
  transition: opacity 140ms ease, transform 180ms cubic-bezier(0.33, 1, 0.68, 1);
}

.fab-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.fab-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

.fab[aria-expanded="true"] .fab-icon-plus {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

.fab[aria-expanded="true"] .fab-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.fab-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.fab-actions[hidden] {
  display: none;
}

.fab-action {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.fab-action-label {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--menu-border);
  background: var(--panel);
  box-shadow: var(--menu-shadow);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.fab-action-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--menu-border);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--menu-shadow);
  transition: background 120ms ease, transform 120ms ease;
}

.fab-action-btn svg,
.fab-action-btn [data-ui-icon] {
  width: 18px;
  height: 18px;
  display: block;
}

.fab-action-btn [data-ui-icon] svg {
  width: 18px;
  height: 18px;
  display: block;
}

.fab-action:hover .fab-action-btn {
  background: var(--surface-2);
  transform: scale(1.04);
}

.fab-action:hover .fab-action-label {
  background: var(--surface-2);
}

#fab-join-feed .fab-action-btn {
  background: #16161a;
  border-color: #16161a;
  color: var(--gold);
}

#fab-join-feed:hover .fab-action-btn {
  background: #2a2a30;
  border-color: #2a2a30;
}

/* Feedback panel (anchored to FAB) */

.fab-feedback {
  width: min(340px, calc(100vw - 40px));
  border-radius: var(--radius);
  border: 1px solid var(--menu-border);
  background: var(--panel);
  box-shadow: var(--menu-shadow);
  color: var(--text);
  overflow: hidden;
}

.fab-feedback[hidden] {
  display: none;
}

.fab-feedback-form {
  padding: 14px 14px 16px;
}

.fab-feedback-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.fab-feedback-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.fab-feedback-lede {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.fab-feedback-close {
  appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -4px -4px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.fab-feedback-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.fab-feedback-close [data-ui-icon],
.fab-feedback-close svg {
  width: 14px;
  height: 14px;
  display: block;
}

.fab-feedback-types {
  margin: 0 0 12px;
  padding: 0;
  border: none;
  min-width: 0;
}

.fab-feedback-legend {
  margin: 0 0 6px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.fab-feedback-type-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.fab-feedback-type {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.fab-feedback-type:has(input:checked) {
  background: var(--accent-soft);
  border-color: rgb(255 203 5 / 0.45);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgb(255 203 5 / 0.16);
}

.fab-feedback-type input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fab-feedback-field {
  margin-bottom: 10px;
}

.fab-feedback-field textarea,
.fab-feedback-field input[type="email"] {
  width: 100%;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  resize: vertical;
}

.fab-feedback-field textarea {
  min-height: 96px;
  line-height: 1.45;
}

.fab-feedback-field textarea:focus,
.fab-feedback-field input[type="email"]:focus {
  outline: none;
  border-color: rgb(255 203 5 / 0.55);
  box-shadow: 0 0 0 3px rgb(255 203 5 / 0.18);
}

.field-optional {
  font-weight: 500;
  color: var(--muted-2);
}

.fab-feedback-hint {
  margin: 0 0 12px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted-2);
}

.export-menu-featured-cta:hover {
  background: #ffd633;
}

/* ---------- unified Download dialog (Free / Feed) ---------- */

body.download-open,
body.feed-open,
body.export-open {
  overflow: hidden;
}

.download-backdrop[hidden] {
  display: none;
}

.download-backdrop {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: grid;
  place-items: center;
  padding: 20px 16px;
  background: rgb(12 11 9 / 0.5);
  backdrop-filter: blur(6px);
}

/* While the confetti plays, drop the blur — compositing an animated full-screen canvas over a
   live backdrop-filter is what made the burst stutter. The dark overlay stays, so it's subtle. */
body.confetti-active .download-backdrop {
  backdrop-filter: none;
}

.download-dialog {
  position: relative;
  width: min(452px, 100%);
  max-height: min(92vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--menu-border);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--menu-shadow);
}

.download-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.download-close:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.download-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.download-main[hidden] {
  display: none;
}

.download-head {
  padding: 20px 20px 0;
  padding-right: 48px;
}

.download-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
}

.download-sub {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.download-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 18px 0;
  /* Shared baseline the active tab's underline sits on — reads as connected tabs,
     not floating folder blobs (the old surface-2 fill didn't match the panel). */
  border-bottom: 1px solid var(--border);
}

.download-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 8px 11px;
  margin-bottom: -1px;                 /* overlap the track so the underline covers it */
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.download-tab:hover {
  color: var(--text);
}

.download-tab.is-active {
  color: var(--text);
  font-weight: 800;
  border-bottom-color: var(--accent);
}

.download-tab-badge {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink);
  background: var(--gold);
  border-radius: 999px;
  padding: 2px 7px;
  letter-spacing: 0.01em;
}

html[data-color-mode="dark"] .download-tab-badge {
  color: #16161a;
}

/* Both Free and Feed panels stack in one grid cell so the dialog
   keeps a constant height when switching tabs — no resize jump. */
.download-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "panel";
  padding: 16px 18px 18px;
  overflow-y: auto;
  min-height: 0;
}

.download-panel {
  grid-area: panel;
  min-width: 0;
  /* Keep inactive panel in layout for height; hide without display:none */
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
}

.download-panel.is-active {
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

/* Prefer class over [hidden] so inactive tab still contributes height */
.download-panel[hidden] {
  display: block;
  visibility: hidden;
  pointer-events: none;
}

.download-panel[hidden].is-active {
  visibility: visible;
  pointer-events: auto;
}

.download-lead {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.download-lead strong {
  color: var(--text);
  font-weight: 700;
}

/* Section headline above Free options / Feed tiers (matches mockup) */
.download-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
}

.download-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text);
}

.download-section-from {
  flex: none;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.download-section-sub {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.download-section-sub strong {
  color: var(--text);
  font-weight: 700;
}

.download-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.download-note strong {
  color: var(--text);
  font-weight: 700;
}

.download-note .note-featured,
.download-note .note-featured strong {
  color: #e0473f;
  font-weight: 600;
}
/* Give the FEATURED note its own line instead of wrapping mid-sentence off the
   watermark text; nowrap keeps the whole sentence together. */
.download-note .note-featured {
  display: block;
  margin-top: 4px;
  white-space: nowrap;
}

.download-success {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #edf9f0;
  border: 1px solid rgb(34 120 60 / 0.16);
}

.download-success[hidden] {
  display: none;
}

.download-success-icon {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #1f7a3f;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.download-success-title {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 700;
  color: #14532d;
}

.download-success-copy {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #166534;
}

.download-opts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.download-opts li + li {
  margin-top: 8px;
}

.download-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.download-opt:hover {
  border-color: var(--gold-deep);
  background: var(--accent-soft);
}

.download-opt:disabled {
  opacity: 0.55;
  cursor: wait;
}

.download-opt-icon {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink-soft);
}

.download-opt-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.download-opt-main {
  flex: 1 1 auto;
  min-width: 0;
}

.download-opt-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.download-opt-desc {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

.download-opt-meta {
  flex: none;
  font-size: 11px;
  color: var(--muted-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.download-fitnote {
  margin: 2px 2px 12px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted-2);
}

.download-reassure {
  margin: 10px 2px 0;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  color: var(--muted);
}

.download-reassure strong {
  color: var(--text);
  font-weight: 700;
}

.download-dialog .feed-tiers {
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
}

.download-dialog .feed-tier {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  margin: 0 0 8px;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.download-dialog .feed-tier:hover {
  border-color: var(--gold-deep);
}

.download-dialog .feed-tier[aria-checked="true"] {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgb(250 208 10 / 0.18);
}

.feed-tier-radio {
  flex: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid var(--border);
  position: relative;
}

.download-dialog .feed-tier[aria-checked="true"] .feed-tier-radio {
  border-color: var(--gold-deep);
}

.download-dialog .feed-tier[aria-checked="true"] .feed-tier-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--gold-deep);
}

.download-dialog .feed-tier-info {
  flex: 1 1 auto;
  min-width: 0;
}

.download-dialog .feed-tier-name {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
  /* Override legacy dark-modal .feed-tier-name { color: #fff } */
  color: var(--text) !important;
}

.download-dialog .feed-tier-detail {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted) !important;
}

.download-dialog .feed-tier-price {
  flex: none;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  background: var(--gold);
  border-radius: 999px;
  padding: 4px 11px;
  font-variant-numeric: tabular-nums;
}

html[data-color-mode="dark"] .download-dialog .feed-tier-price {
  color: #16161a;
}

.feed-tier-popular {
  display: inline-block;
  margin-left: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--gold);
  color: #0e0d0b;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.download-dialog .feed-cta {
  margin-top: 4px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
  border: none;
  box-shadow: 0 2px 0 var(--gold-deep);
}

.download-dialog .feed-cta:hover {
  background: #ffd84a;
  color: var(--ink);
}

.download-panel-success {
  padding: 36px 24px 28px;
  text-align: center;
}

.download-panel-success[hidden] {
  display: none;
}

/* When shown, override the base .download-panel { visibility: hidden } — the success panel
   is revealed by removing [hidden], not by gaining .is-active, so it needs this or it renders
   blank (the modal opened empty after a paid checkout). */
.download-panel-success:not([hidden]) {
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

/* Legacy feed success styles (used inside download success panel) */
.feed-consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}
.feed-consent input {
  margin: 2px 0 0;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: var(--accent-strong);
  cursor: pointer;
}
.feed-consent-text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.feed-consent.is-missing {
  border-color: #d64545;
  background: rgba(214, 69, 69, 0.06);
}
.feed-consent-more {
  display: inline-block;
  margin: -6px 0 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-2);
  text-decoration: none;
}
.feed-consent-more:hover { color: var(--text); }

/* Free-comp state (?comp=CODE): banner + the email field we collect when Stripe isn't in the loop. */
.feed-comp-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(243, 201, 16, 0.12);
  border: 1px solid rgba(243, 201, 16, 0.55);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}
.feed-comp-field.is-missing input { border-color: #d64545; }

.feed-success-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: #1f7a3f;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.feed-success-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
}

.feed-success-copy {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.feed-success-schedule {
  list-style: none;
  margin: 0 0 14px;
  padding: 12px 14px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.feed-success-schedule li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
}
.feed-success-schedule li + li {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding-top: 8px;
}
.feed-success-schedule .fss-where { color: var(--ink-soft); }
.feed-success-schedule .fss-when {
  color: var(--accent-strong);
  font-weight: 700;
  white-space: nowrap;
}

.feed-success-detail {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

/* Keep old feed class hooks no-ops if referenced */
.feed-backdrop[hidden],
.feed-panel[hidden] {
  display: none;
}

.feed-head {
  padding-right: 36px;
}

.feed-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #fff;
}

.feed-lede {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.55;
  color: rgb(255 255 255 / 0.68);
}

.feed-tiers {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.feed-tier {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 12px;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.03);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.feed-tiers li + li {
  margin-top: 8px;
}

.feed-tier:hover {
  background: rgb(255 255 255 / 0.06);
  border-color: rgb(255 255 255 / 0.18);
}

.feed-tier[aria-checked="true"] {
  background: rgb(255 255 255 / 0.1);
  border-color: rgb(255 203 5 / 0.45);
  box-shadow: inset 0 0 0 1px rgb(255 203 5 / 0.2);
}

.feed-tier-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.feed-tier-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.feed-tier-badge {
  color: var(--success, #1a7f37);
  font-size: 12px;
}

.feed-tier-detail {
  font-size: 12px;
  color: var(--muted);
}

.feed-tier-price {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--gold);
  color: #16161a;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.feed-note {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.45;
  color: rgb(255 255 255 / 0.55);
}

.feed-cta {
  margin-top: 4px;
}

/* Gold CTA on the fixed dark surface — same in light & dark editor modes */
.btn.primary.feed-cta {
  background: var(--gold);
  border-color: var(--gold);
  color: #16161a;
}

.btn.primary.feed-cta:hover:not(:disabled) {
  background: #ffd633;
  border-color: #ffd633;
}

.feed-cta:disabled {
  opacity: 0.55;
  cursor: wait;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.toggle-pill input {
  accent-color: var(--accent);
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn.primary {
  background: var(--primary-btn-bg);
  border-color: var(--primary-btn-bg);
  color: var(--primary-btn-fg);
}

.btn.primary:hover {
  background: var(--primary-btn-hover);
  border-color: var(--primary-btn-hover);
}

.btn.ghost {
  background: transparent;
}

.btn.text {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  padding: 6px 0;
  font-weight: 600;
}

.btn.text:hover {
  color: var(--accent);
}

.btn.danger {
  color: var(--danger);
  border-color: #fecdca;
  background: var(--danger-soft);
}

.btn.danger:hover {
  background: #fee4e2;
}

.btn.block {
  width: 100%;
}

/* ---------- workspace ---------- */

.workspace {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  align-items: stretch;
  min-height: calc(100vh - var(--topbar));
  /* Same ease-out curve as the mobile drawer so the collapse reads as one motion.
     NB: animating a grid track is layout-bound (not GPU-composited) — see the note to
     Ben about a transform-based slide if this still isn't buttery enough. */
  transition: grid-template-columns 240ms cubic-bezier(0.33, 1, 0.68, 1);
  will-change: grid-template-columns;
}

body:not(.sidebar-open) .workspace {
  grid-template-columns: 0 1fr;
}

/* ---------- sidebar ---------- */

.sidebar-backdrop {
  display: none;
}

.sidebar {
  position: sticky;
  top: var(--topbar);
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar));
  max-height: calc(100dvh - var(--topbar));
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 14px 0;
  min-width: 0;
  /* Match the workspace width animation (240ms, same curve) so opacity and width move
     together instead of the content fading 40ms before the column finishes collapsing. */
  transition: opacity 240ms cubic-bezier(0.33, 1, 0.68, 1), border-color 240ms ease;
}

body:not(.sidebar-open) .sidebar {
  opacity: 0;
  border-right-color: transparent;
  pointer-events: none;
  overflow: hidden;
}

/* Accordion column: open section fills leftover height; body scrolls inside. */
.sidebar-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 8px;
}

.section {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
}

/* Tall sections (e.g. Roles, Theme) fill leftover sidebar height and scroll. */
.section[open] {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Fit sections size to content, but shrink + scroll when they’d push
   later accordion headers (e.g. Role Preferences) off the bottom of the sidebar. */
.section.section-fit[open] {
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
}

.section.section-fit[open]::details-content {
  flex: 1 1 auto;
  min-block-size: 0;
  height: auto;
  max-block-size: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.section.section-fit[open] .section-panel {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.section[open] > summary {
  flex: 0 0 auto;
}

.section > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

.section > summary::-webkit-details-marker { display: none; }

.section-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted-2);
}

.section-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.section-label {
  min-width: 0;
}

.section-chevron {
  display: flex;
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--muted-2);
}

.section-chevron svg {
  width: 16px;
  height: 16px;
  display: block;
}

.section[open] > summary .section-chevron {
  transform: rotate(180deg);
}

.section[open] > summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
}

.section[open] > summary .section-icon {
  color: var(--accent-strong);
}

.section[open] > summary .section-chevron {
  color: var(--muted);
}

.section > summary:hover {
  background: var(--surface-2);
  color: var(--ink-soft);
}

.section > summary:hover .section-icon {
  color: var(--muted);
}

/* Instant expand/collapse — no height or fade animation. */
.section::details-content {
  display: block;
  block-size: 0;
  overflow: clip;
}

.section[open]::details-content {
  /* Fill the open section; the panel is the scrollport. */
  flex: 1 1 auto;
  min-block-size: 0;
  block-size: auto;
  max-block-size: none;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Scroll long accordion bodies (e.g. Photos) inside the section. */
.section-panel {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.section-body {
  padding: 14px 16px 16px;
}

.section-lede {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.section-lede-warn {
  color: var(--danger);
  font-weight: 600;
}

.sidebar-foot {
  flex: none;
  position: relative;
  z-index: 1;
  margin-top: 0;
  padding: 12px 0 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 16px -12px rgb(22 22 26 / 0.12);
}

.trust-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 600;
}

.trust-links a {
  color: var(--muted);
  text-decoration: none;
}

.trust-links a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.trust-links-sep {
  color: var(--muted-2);
  user-select: none;
}

.trust-note {
  margin: 6px 0 0;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--muted-2);
}

/* ---------- form fields ---------- */

/* [hidden] must beat the .field display rule below — otherwise a hidden field
   (the comp-only "Your email" input) leaks into the normal paid checkout. */
.field[hidden] { display: none; }
.field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.field-label,
.field > span:first-child:not(.field-hint):not(.color-row) {
  display: block;
  margin-bottom: 0;
}

.field-hint {
  display: block;
  margin: -4px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-2);
}

/* Isometric tilt — the signature feature, surfaced right under the cover upload (not buried
   below the crop sliders). Gold tint when active so its on/off state reads at a glance. */
.cover-iso {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.cover-iso input {
  margin: 1px 0 0;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: #E0AD00;
  cursor: pointer;
}
.cover-iso-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cover-iso-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cover-iso-hint {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--muted-2);
}
.cover-iso:has(input:checked) {
  border-color: rgba(243, 201, 16, 0.55);
  background: rgba(243, 201, 16, 0.09);
}

/* Gold "Feed only" pill on the FEATURED field — signals it's a paid Feed perk, tied by
   colour to the gold FEATURED banner it controls. */
.field-badge-paid {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 7px;
  padding: 1px 7px 1px 5px;
  border-radius: 999px;
  background: #F4C90B;
  color: #1E1902;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}
.field-badge-lock {
  display: inline-flex;
  width: 11px;
  height: 11px;
}
.field-badge-lock svg { width: 100%; height: 100%; }

.field input[type="text"],
.field select,
.field textarea,
.inline-add input {
  display: block;
  width: 100%;
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
  font: inherit;
  font-weight: 500;
  line-height: 1.4;
}

.field select {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% + 2px),
    calc(100% - 12px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-add input:focus {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgb(255 203 5 / 0.22);
}

.headline-mode {
  display: flex;
  margin: 0 0 14px;
  border-bottom: 1px solid var(--border);
}

.headline-tab {
  flex: 1;
  margin: 0;
  padding: 10px 12px 11px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
}

.headline-tab:hover {
  color: var(--ink-soft);
  background: var(--surface-2);
}

.headline-tab.on {
  color: var(--ink);
  border-bottom-color: var(--gold-deep);
  background: transparent;
}

.headline-tab:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: -2px;
}

.field input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}
.field input[readonly]:focus {
  border-color: var(--border-strong);
  box-shadow: none;
}

.field-grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.check input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.upload-block {
  margin-bottom: 12px;
  padding: 12px 14px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.upload-block:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.upload-head-text {
  min-width: 0;
  flex: 1 1 auto;
}

.upload-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 0;
  color: var(--text);
}

.upload-head-text .field-hint {
  margin: 2px 0 0;
}

/* Clear X — only the uploaded image, not the whole card. */
.upload-clear {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -4px -6px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.upload-clear:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.upload-clear[hidden] {
  display: none;
}

.upload-clear [data-ui-icon],
.upload-clear svg {
  width: 14px;
  height: 14px;
  display: block;
}

.upload {
  display: block;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.upload:hover {
  border-color: transparent;
  background: transparent;
}

.upload input[type="file"] {
  width: 100%;
  font-size: 12px;
  color: var(--muted);
}

.upload-url {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.upload-url input[type="url"] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  font-size: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.upload-url input[type="url"]::placeholder { color: var(--muted-2); }
.upload-url .upload-url-go {
  flex: none;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
}

.upload-status {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.upload-status.is-error { color: var(--danger, #c0392b); }

.upload-status[hidden] {
  display: none;
}

.image-frame-controls {
  margin: -4px 0 14px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.image-frame-controls .field-hint {
  margin: 0 0 8px;
}

.image-frame-controls .range-field {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.image-frame-controls .range-field input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 0;
  accent-color: var(--gold-deep);
}

.image-frame-controls .btn.text {
  margin-top: 2px;
  padding-left: 0;
}

/* ---------- theme accordion (fill height, dense chips) ---------- */

.section-theme[open] {
  flex: 1 1 auto;
  min-height: 0;
}

.section-theme .section-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.section-theme .section-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
}

.section-theme .theme-groups {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-theme .theme-accent-field {
  flex: none;
  margin-bottom: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

/* ---------- chips ---------- */

.theme-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.theme-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.theme-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.section-theme .chip {
  padding: 6px 10px;
  font-size: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip.on {
  background: var(--accent-soft);
  border-color: var(--gold);
  color: var(--ink-soft);
}

.chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.role-limit {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Roles counter sits above the chips (tagline counter stays below its textarea). */
#role-limit {
  margin: 0 0 10px;
}

.role-limit.at-cap {
  color: var(--accent-strong);
  font-weight: 600;
}

.inline-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inline-add input {
  flex: 1;
}

/* ---------- badges ---------- */

/* Badges: location dropdown must escape the panel; no inner scroll clip. */
.section-badges[open] {
  overflow: visible;
}

.section-badges[open]::details-content,
.section-badges .section-panel,
.section-badges .section-body {
  overflow: visible;
}

.badge-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.badge-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.badge-row input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.badge-combo {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.badge-combo:has(.badge-combo-toggle) input[type="text"] {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.badge-typeahead input[type="text"] {
  flex: 1;
  min-width: 0;
}

.badge-loc-flag {
  flex: none;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  border: 1px solid var(--border-strong);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface-2);
}

.badge-loc-flag[hidden] {
  display: none;
}

.badge-typeahead.has-flag input[type="text"] {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.badge-typeahead.open input[type="text"] {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgb(255 203 5 / 0.18);
}

.badge-typeahead.has-flag.open .badge-loc-flag {
  border-color: var(--gold-deep);
}

.badge-combo-toggle {
  flex: none;
  width: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.badge-combo-toggle:hover {
  background: var(--surface);
  color: var(--text);
}

.badge-combo.open .badge-combo-toggle {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--gold-deep);
}

.badge-combo.open input[type="text"] {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgb(255 203 5 / 0.18);
}

.badge-menu {
  /* Fixed (not absolute) + JS-positioned so the accordion section's overflow can't
     clip it — an absolute menu was cut off at the section edge (see openMenu). */
  position: fixed;
  z-index: 210;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}

.badge-menu li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
}

.badge-menu-flag {
  flex: none;
  width: 22px;
  font-size: 17px;
  line-height: 1;
  text-align: center;
}

.badge-menu-text {
  min-width: 0;
}

.badge-menu li:hover,
.badge-menu li.selected {
  background: var(--accent-soft);
  color: var(--text);
}

/* ---------- canvas / preview ---------- */

.canvas {
  position: sticky;
  top: var(--topbar);
  min-width: 0;
  height: calc(100vh - var(--topbar));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  z-index: 50;
}

.stage-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Stage theme float is desktop-only; mobile uses the sidebar Theme accordion. */
.stage-theme-float {
  display: none;
}

@media (min-width: 981px) {
  .stage-theme-float {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 24px;
    right: 18px;
    z-index: 45;
    width: min(272px, calc(100% - 36px));
    max-height: calc(100% - 48px);
    border-radius: calc(var(--radius) + 2px);
    border: 1px solid var(--menu-border);
    background: var(--panel);
    box-shadow: var(--menu-shadow);
    color: var(--text);
    pointer-events: auto;
    overflow: hidden;
  }

  .stage-theme-float-toggle {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 11px 12px;
    border: none;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
  }

  .stage-theme-float-toggle:hover {
    background: var(--surface-2);
    color: var(--ink-soft);
  }

  .stage-theme-float-icon {
    display: flex;
    width: 16px;
    height: 16px;
    flex: none;
    color: var(--muted-2);
  }

  .stage-theme-float-icon svg {
    width: 16px;
    height: 16px;
    display: block;
  }

  .stage-theme-float-label {
    flex: 1 1 auto;
    min-width: 0;
  }

  .stage-theme-float-chevron {
    display: flex;
    width: 16px;
    height: 16px;
    flex: none;
    color: var(--muted-2);
    transition: transform 200ms ease;
  }

  .stage-theme-float-chevron svg {
    width: 16px;
    height: 16px;
    display: block;
  }

  .stage-theme-float.is-open .stage-theme-float-chevron {
    transform: rotate(180deg);
  }

  .stage-theme-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 0 14px 14px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    max-height: min(420px, calc(100dvh - var(--topbar) - 120px));
  }

  .stage-theme-float.is-open .stage-theme-panel {
    display: flex;
    border-top: 1px solid var(--line-soft);
    padding-top: 12px;
  }

  .stage-theme-float.is-open .stage-theme-float-toggle {
    color: var(--ink);
  }

  .stage-theme-float .theme-groups {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: none;
  }

  .stage-theme-float .theme-group-chips {
    gap: 5px;
  }

  .stage-theme-float .chip {
    padding: 5px 9px;
    font-size: 11.5px;
  }

  .stage-theme-float .stage-theme-accent {
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
  }

  /* Theme lives on the stage on desktop — hide the sidebar accordion */
  .section-theme {
    display: none;
  }
}

/* Mobile: Theme is a normal sidebar accordion (never the stage float). */
@media (max-width: 980px) {
  .stage-theme-float {
    display: none !important;
  }

  .section-theme {
    display: block;
  }
}

.format-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--chrome-bg);
  backdrop-filter: saturate(140%) blur(10px);
  overflow-x: auto;
}

.format-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.format {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.format:hover {
  background: var(--surface-2);
  color: var(--ink-soft);
}

.format.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.format-name {
  font-size: 14px;
  font-weight: 700;
}

.format-size {
  font-size: 11px;
  opacity: 0.7;
}

.zoom-controls {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.zoom-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.zoom-btn:hover:not(:disabled) {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.zoom-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.zoom-btn-fit {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}

.zoom-controls .zoom {
  min-width: 3.25rem;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

.viewport.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.viewport.hint-dismissed .stage-hint {
  opacity: 0;
}

.stage-hint {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: var(--chrome-bg);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.2s ease;
  box-shadow: var(--shadow);
}

.stage-pan {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.scaler {
  transform-origin: 0 0;
  flex: none;
  /* Hidden until app.js runs the first fit() and adds body.stage-ready. The card
     is a fixed 960px template; without this the browser paints it full-size during
     HTML parse (before the trailing app.js scales it down), a large→small flash on
     load. Visibility (not display) keeps layout so offsetHeight measures correctly. */
  visibility: hidden;
}
body.stage-ready .scaler {
  visibility: visible;
}

.scaler .card {
  box-shadow: var(--shadow), 0 24px 60px rgb(22 22 26 / 0.14);
}

/* ---------- first-time onboarding ---------- */

body.onboard-open {
  overflow: hidden;
}

.onboard-backdrop[hidden] {
  display: none;
}

.onboard-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(22 22 26 / 0.58);
  backdrop-filter: blur(8px);
}

.onboard {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(780px, 100%);
  max-height: min(92vh, 860px);
  overflow: hidden;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid var(--menu-border);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--menu-shadow);
}

.onboard.onboard-compact {
  width: min(520px, 100%);
  /* Grow with content; keep overflow hidden so head/foot clip to rounded corners. */
  max-height: none;
  height: auto;
  overflow: hidden;
}

.onboard::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.35;
}

.onboard > * {
  position: relative;
  z-index: 1;
}

.onboard-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.onboard-close:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.onboard-head {
  flex: none;
  padding: 32px 40px 4px;
  padding-right: 56px;
  background:
    linear-gradient(180deg, var(--accent-soft) 0%, transparent 100%),
    var(--panel);
  border-bottom: 1px solid var(--line-soft);
  /* Match shell radius so the top isn’t square under the gradient fill */
  border-radius: calc(var(--radius) + 2px) calc(var(--radius) + 2px) 0 0;
}

html[data-color-mode="dark"] .onboard-head {
  background: var(--panel);
}

.onboard-title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.35em;
  font-size: clamp(1.65rem, 3.2vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.onboard-title-line {
  color: var(--ink);
  font-weight: 700;
}

.onboard-title-accent {
  color: var(--accent-strong);
  font-weight: 700;
}

.onboard-lede {
  margin: 10px 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.onboard-compact .onboard-head {
  padding: 28px 28px 12px;
  padding-right: 52px;
}

.onboard-compact .onboard-title {
  font-size: 1.45rem;
}

.onboard-compact .onboard-lede {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.onboard-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.onboard-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.onboard-step-num {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--gold);
  color: #16161a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.onboard-step-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.onboard-step-copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.onboard-step-copy strong {
  color: var(--ink-soft);
  font-weight: 700;
}

.onboard-compact .onboard-body {
  flex: none;
  padding: 16px 20px 8px;
  overflow: visible;
}

.onboard-compact .onboard-note {
  margin-top: 14px;
}

.onboard-compact .onboard-foot {
  flex: none;
  padding: 12px 20px 20px;
}

/* Only scroll the whole compact dialog if the viewport is very short */
@media (max-height: 640px) {
  .onboard.onboard-compact {
    max-height: 92vh;
    overflow-x: hidden;
    overflow-y: auto;
  }
}

.onboard-pathways {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.onboard-path {
  padding: 16px 16px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.onboard-path-feed {
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface-2) 100%);
  border-color: rgb(255 203 5 / 0.4);
}

html[data-color-mode="dark"] .onboard-path-feed {
  background: var(--accent-soft);
}

.onboard-path-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.onboard-path-lede {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.onboard-path .onboard-list {
  margin-bottom: 10px;
}

.onboard-path-cta-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted-2);
}

.onboard-path-cta-hint strong {
  color: var(--ink-soft);
}

.onboard-body {
  flex: 1;
  overflow: auto;
  padding: 18px 40px 12px;
  background: var(--panel);
}

.onboard-copy {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
}

.onboard-copy strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.onboard-copy-tight {
  margin-bottom: 14px;
}

.onboard-tiers {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.onboard-tier {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
}

.onboard-tier:first-child {
  border-top: none;
}

.onboard-tier-rec {
  background: var(--accent-soft);
}

.onboard-tier-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.onboard-tier-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.onboard-tier-badge {
  color: var(--success, #1a7f37);
  font-size: 13px;
}

.onboard-tier-detail {
  font-size: 12px;
  color: var(--muted);
}

.onboard-tier-price {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--gold);
  color: #16161a;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.onboard-note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.onboard-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.onboard-block-muted {
  margin-top: 16px;
  padding: 14px 14px 6px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.onboard-block h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.onboard-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.onboard-list li {
  position: relative;
  padding: 0 0 10px 28px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.onboard-list li:last-child {
  padding-bottom: 0;
}

.onboard-list-star li::before {
  content: "★";
  position: absolute;
  left: 0;
  top: 1px;
  color: var(--accent-strong);
  font-size: 13px;
}

.onboard-list-target li::before {
  content: "◎";
  position: absolute;
  left: 0;
  top: 1px;
  color: var(--accent-strong);
  font-size: 13px;
}

.onboard-foot {
  flex: none;
  padding: 16px 40px 28px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
  border-radius: 0 0 calc(var(--radius) + 2px) calc(var(--radius) + 2px);
}

.onboard-cta {
  width: 100%;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---------- mobile desktop-preferred gate ---------- */

.mobile-gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgb(255 203 5 / 0.12), transparent 55%),
    var(--paper);
  overflow: auto;
}

.mobile-gate[hidden] {
  display: none;
}

body.mobile-gate-open {
  overflow: hidden;
}

body.mobile-gate-open .topbar,
body.mobile-gate-open .workspace,
body.mobile-gate-open .fab-root,
body.mobile-gate-open .export-toast,
body.mobile-gate-open .export-menu,
body.mobile-gate-open .sidebar-backdrop,
body.mobile-gate-open .onboard-backdrop,
body.mobile-gate-open .feed-backdrop {
  visibility: hidden;
  pointer-events: none;
}

.mobile-gate-card {
  width: min(400px, 100%);
  padding: 28px 22px 24px;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid var(--menu-border);
  background: var(--panel);
  box-shadow: var(--menu-shadow);
  text-align: center;
  color: var(--text);
}

.mobile-gate-logo {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  object-fit: contain;
}

.mobile-gate-title {
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}

.mobile-gate-copy {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  text-align: left;
}

.mobile-gate-copy-soft {
  color: var(--muted);
  margin-bottom: 20px;
}

.mobile-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-gate-footnote {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted-2);
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .workspace {
    display: flex;
    flex-direction: column;
    min-height: 0;
    grid-template-columns: none;
  }

  body:not(.sidebar-open) .workspace {
    grid-template-columns: none;
  }

  /* Stage gets the viewport; editor is a hamburger drawer */
  .canvas {
    position: relative;
    top: auto;
    z-index: 1;
    flex: 1 1 auto;
    /* svh (smallest viewport, i.e. URL bar shown) not dvh: guarantees topbar +
       canvas never exceed the visible height, so there's no page overflow / scroll
       and the format bar can't slip under the sticky topbar (iOS/Chrome URL bar). */
    height: calc(100svh - var(--topbar-offset, 120px));
    min-height: 280px;
    border-bottom: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 160;
    width: min(var(--sidebar), calc(100vw - 52px));
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    padding: calc(var(--topbar-offset, 72px) + 8px) 14px 20px;
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 32px rgb(0 0 0 / 0.18);
    transform: translateX(-105%);
    opacity: 1;
    pointer-events: auto;
    transition: transform 240ms cubic-bezier(0.33, 1, 0.68, 1);
    overflow: hidden;
  }

  body.sidebar-open .sidebar,
  body:not(.sidebar-open) .sidebar {
    opacity: 1;
    border-right-color: var(--border);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    pointer-events: auto;
  }

  body:not(.sidebar-open) .sidebar {
    transform: translateX(-105%);
    pointer-events: none;
    box-shadow: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 155;
    background: rgb(22 22 26 / 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }

  .sidebar-backdrop:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-main {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    -webkit-overflow-scrolling: touch;
  }

  .section,
  .section[open] {
    flex: none;
    max-height: none;
    height: auto;
    overflow: visible;
  }

  .section[open]::details-content,
  .section-panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .topbar {
    /* Not sticky on mobile: a pinned topbar is what the format bar slid under.
       With svh sizing the stage, scroll is minimal, so the topbar scrolls with
       the page instead of staying pinned — and nothing can hide beneath it. */
    position: static;
    flex-wrap: wrap;
    height: auto;
    padding: 12px 12px 12px 10px;
    gap: 12px;
    align-items: flex-start;
  }

  .topbar-start {
    width: 100%;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  /* Keep Download on the same row as Settings + How it works (push it to the right). */
  .pathway-actions {
    width: auto;
    margin-left: auto;
    display: flex;
    gap: 8px;
  }

  .pathway-actions .export-menu-anchor,
  .pathway-actions .btn.primary {
    min-width: 0;
    width: auto;
  }

  .pathway-actions .export-menu-toggle {
    width: auto;
  }

  .format-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  .format {
    padding: 8px 10px;
  }

  .format-name {
    font-size: 12px;
  }

  .zoom-controls {
    margin-left: 0;
  }

  .stage-hint {
    display: none;
  }

  .onboard-pathways {
    grid-template-columns: 1fr;
  }

  .brand p {
    white-space: normal;
  }

  .export-menu-action {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    grid-template-areas:
      "icon main"
      ". hint";
    column-gap: 10px;
    row-gap: 8px;
    align-items: start;
  }

  .export-menu-action-icon {
    grid-area: icon;
    margin-top: 2px;
  }

  .export-menu-action-main {
    grid-area: main;
  }

  .export-menu-action-hint {
    grid-area: hint;
    margin-left: 0;
    max-width: none;
    width: 100%;
    align-items: flex-start;
    text-align: left;
  }
}