[data-theme="current"].dark {
  /* ── Core surfaces ── */
  --background: #131314;
  --foreground: #f1f1f1;

  /* Card */
  --card: #19191a;
  --card-foreground: #e7e7e7;

  /* Popover */
  --popover: #222222;
  --popover-foreground: #f1f1f1;

  /* Primary — same FAR Labs brand indigo both modes */
  --primary: #5462fd;
  --primary-foreground: #fafafa;

  /* Secondary */
  --secondary: #ffffff1a;
  /* white 10% */
  --secondary-foreground: #e7e7e7;

  /* Muted */
  --muted: #262626;
  --muted-foreground: #ffffff8a;
  /* white 54% */

  /* Accent */
  --accent: #404040;
  --accent-foreground: #fafafa;

  /* Destructive */
  --destructive: var(--destructive-60);
  /* custom/destructive dark:destructive\60 */
  --destructive-foreground: #fef2f2;
  /* red-50 */

  /* Border & Input — dark uses white alpha values */
  --border: #ffffff17;
  /* white 9% */
  --border-subtle: #ffffff08;
  /* white 3% */
  --input: #ffffff17;
  /* white 9% */

  /* Focus ring */
  --ring: #737373;

  /* Charts — dark (blue-700, emerald-500, amber-500, purple-500, rose-500) */
  --chart-1: #1d4ed8;
  --chart-2: #10b981;
  --chart-3: #f59e0b;
  --chart-4: #a855f7;
  --chart-5: #f43f5e;

  /* Sidebar — dark */
  --sidebar: #0e0e0e;
  --sidebar-foreground: #ffffffb8;
  /* white 72% */
  --sidebar-card: #2e2f31;
  --sidebar-primary: #ffffffeb;
  /* white 92% */
  --sidebar-primary-foreground: #191919;
  --sidebar-accent: #ffffff0a;
  /* white 4% */
  --sidebar-accent-foreground: #ffffffe5;
  /* white 90% */
  --sidebar-border: transparent;
  --sidebar-ring: #525252;

  /* ── FAR Labs Mode-Dark custom tokens (from Figma) ── */

  /* Alpha scale — dark base (#0A0A0A ≈ neutral-950) */
  --alpha-5: #0a0a0af2;
  /* black 95% */
  --alpha-10: #0a0a0ae5;
  /* black 90% */
  --alpha-20: #0a0a0acc;
  /* black 80% */
  --alpha-30: #0a0a0ab2;
  /* black 70% */
  --alpha-40: #0a0a0a99;
  /* black 60% */
  --alpha-50: #0a0a0a80;
  /* black 50% */
  --alpha-60: #0a0a0a66;
  /* black 40% */
  --alpha-70: #0a0a0a4d;
  /* black 30% */
  --alpha-80: #0a0a0a33;
  /* black 20% */
  --alpha-90: #0a0a0a1a;
  /* black 10% */

  /* Destructive alpha variants — dark (red-400 base #F87171) */
  --destructive-40: #f8717199;
  /* red-400 60% — maps to destructive\60 in dark */
  --destructive-60: #f8717199;
  /* red-400 60% */
  --destructive-70: #f87171b2;
  /* red-400 70% */
  --destructive-90: #f87171e5;
  /* red-400 90% */
  --destructive-20: #f8717166;
  /* red-400 40% — maps to destructive\40 in dark */

  /* Outline tokens — dark (#737373 ≈ neutral-500/600 boundary) */
  --outline: #73737380;
  /* neutral-500 50% */
  --outline-10: #73737333;
  /* neutral-500 20% */

  /* Background & primary tint overlays */
  --bg-overlay: #0a0a0a1a;
  /* black 10% — bg-background/10 */
  --bg-primary-tint: #ffffff1a;
  /* white 10% — bg-primary/10 */

  /* Component-specific input/accent surface aliases */
  --input-surface: var(--muted);
  /* custom-background-dark:input30 → #262626 */
  --calendar-surface: #ffffff0a;
  /* custom-background-dark:calendar30 — white 4% */
  --input-accent-surface: var(--muted);
  /* custom-accent-dark:input50 → #262626 */
  --calendar-accent: #ffffff14;
  /* custom-accent-dark:calendar50 — white 8% */
  --input-field: var(--muted);
  /* custom-input-dark:input80 → #262626 */

  /* Border/ring aliases — dark collapses to input var */
  --border-input: var(--input);
  /* custom-border-dark:input-dark */
  --ring-input: var(--input);
  /* custom-ring-dark:input-dark   */

  /* Field component — description text color changed to destructive (red-400) */
  --field-description: var(--destructive);
  /* red-400 — designer change */

  /* Blue accent alias — dark uses blue-600 */
  --blue-accent: #2563eb;
  /* tailwind blue-600 */

  /* Survey banner deep indigo — same shade in both modes */
  --bg-survey-accent: #2c3ad5;
}
:root[data-canvas-theme='light'], .graph-shell[data-canvas-theme='light'] {
  color-scheme: light;
  --background: #f6f1e7;
  --foreground: #302119;
  --card: #f9f5ed;
  --card-foreground: #302119;
  --popover: #fbf8f1;
  --popover-foreground: #302119;
  --primary: #926721;
  --primary-foreground: #fff9ed;
  --secondary: #eae2d4;
  --secondary-foreground: #302119;
  --muted: #eee7da;
  --muted-foreground: #7b6859;
  --accent: #e7ddcc;
  --accent-foreground: #302119;
  --border: #30211924;
  --input: #30211933;
  --ring: #926721;
  --sidebar: #eee7da;
  --sidebar-foreground: #574435;
  --sidebar-primary: #926721;
  --sidebar-primary-foreground: #fff9ed;
  --sidebar-accent: #f9f5ed;
  --sidebar-accent-foreground: #302119;
  --sidebar-border: #3021191f;
  --sidebar-ring: #926721;
}
.graph-shell { color: var(--foreground); background: var(--background); }
.graph-canvas { --board-canvas-background: var(--background); background: var(--board-canvas-background); }
.canvas-theme-switch { position: absolute; z-index: 10; top: 12px; left: 12px; display: flex; gap: 2px; padding: 3px; background: var(--background); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px #0000000a; }
.canvas-theme-switch button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 5px 9px; border-radius: 5px; color: var(--muted-foreground); font-size: 12px; cursor: pointer; }
.canvas-theme-switch button[aria-pressed='true'] { color: var(--foreground); background: var(--muted); }
.canvas-theme-switch button:hover { color: var(--foreground); }
.canvas-theme-switch button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.canvas-theme-switch svg { width: 14px; height: 14px; }
.graph-shell[data-canvas-theme='dark'] .graph-canvas { --board-canvas-background: #1e1e1e; }
.dossier-translation-credit { margin: 0 0 10px; color: var(--dossier-muted, #8a8a8a); font-size: 12px; }
.dossier-page-language { position: fixed; z-index: 70; top: 10px; right: 12px; }

.board-layout {
  display: flex;
  width: 100%;
  --board-motion: 640ms cubic-bezier(.22, 1, .36, 1);
}
.board-stage { position: relative; flex: 1; min-width: 0; height: 100%; isolation: isolate; }
/* The dossier shares the controls' stacking context without resizing the board. */
.board-stage > .character-dossier { position: absolute; z-index: 15; inset: 0 0 0 auto; }
.board-dossier-backdrop { position: absolute; inset: 0; z-index: 35; padding: 0; border: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 220ms ease; }
.board-dossier-backdrop[data-open="true"] { opacity: .24; pointer-events: auto; }
.graph-shell[data-canvas-theme="light"] .board-dossier-backdrop[data-open="true"] { opacity: .14; }
.board-stage[data-catalogue-dossier="true"] > .character-dossier { z-index: 40; }
.board-header { position: absolute; z-index: 20; inset: 24px 24px auto; height: 44px; pointer-events: none; }
.board-identity { display: flex; align-items: center; gap: 8px; width: fit-content; pointer-events: auto; }
.board-brand { height: 44px; margin: 0; font: 600 28px/1 "Cormorant Garamond", Georgia, serif; }
.board-language { display: inline-flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border: 0; border-radius: 2px; background: var(--card); color: var(--foreground); font: inherit; white-space: nowrap; cursor: pointer; transform: translateY(0) scale(1); box-shadow: inset 0 0 0 #0000; transition: transform 220ms cubic-bezier(.22, 1, .36, 1), box-shadow 220ms ease, background-color 160ms ease; }
.board-language__label-stack { position: relative; display: block; flex: none; height: 1.2em; overflow: hidden; text-align: left; transition: width 480ms ease 120ms; }
.board-language__label { position: absolute; inset: 0 auto auto 0; width: max-content; line-height: 1.2; visibility: hidden; opacity: 0; transition: opacity 340ms ease, visibility 0s 340ms; }
.board-language__label[data-active="true"] { visibility: visible; opacity: 1; transition: opacity 640ms ease 200ms, visibility 0s; }
.board-language > svg { flex: none; width: 16px; height: 16px; color: var(--muted-foreground); }
.board-language > svg path { d: path("M6 12 L12 18 L18 12"); transition: d 340ms cubic-bezier(.22, 1, .36, 1); }
.board-language[data-state="open"] > svg path { d: path("M6 12 L12 6 L18 12"); }
.board-language:hover, .board-language[data-state="open"] { background: var(--muted); }
.board-language[data-pressing="true"], .board-language-menu__item[data-pressing="true"] { animation: board-language-press 300ms ease-out; }
@keyframes board-language-press {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: inset 0 0 0 #0000; }
  30%, 50% { transform: translateY(1px) scale(.97); box-shadow: inset 0 2px 4px #0003, inset 0 0 0 1px #0001; }
}
.board-language:focus-visible { outline: 1px solid var(--ring); outline-offset: 3px; }
/* The shared language menu must also clear the loading screen at z-index 100. */
.board-language-menu { z-index: 110; min-width: max(230px, var(--radix-dropdown-menu-trigger-width)); max-width: calc(100vw - 32px); padding: 6px; border: 1px solid var(--border); border-radius: 3px; background: var(--popover); color: var(--popover-foreground); box-shadow: 0 8px 32px #0003; font: 600 22px/28px "Cormorant Garamond", Georgia, serif; }
.board-language-menu[data-state="closed"] { pointer-events: none; animation: board-language-menu-out 180ms ease-in forwards; }
@keyframes board-language-menu-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-4px); }
}
.board-language-menu__item { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 44px; padding: 8px 12px; border-radius: 1px; cursor: pointer; outline: none; }
.board-language-menu__item[data-state="checked"] { background: var(--background); }
.board-language-menu__item[data-highlighted] { background: var(--muted); }
.board-language-menu__item > svg { flex: none; width: 16px; height: 16px; color: var(--muted-foreground); }
.board-language-menu__separator { height: 1px; margin: 6px 12px; background: var(--border); }
.board-language-menu__about { display: block; width: fit-content; padding: 8px 12px; color: var(--muted-foreground); font: 500 18px/24px "Cormorant Garamond", Georgia, serif; text-decoration: none; outline: none; }
.board-language-menu__about:hover, .board-language-menu__about[data-highlighted] { color: var(--foreground); text-decoration: underline; text-underline-offset: 4px; }
.dossier-page-language .board-language { font: 600 24px/1 "Cormorant Garamond", Georgia, serif; }
.board-view-switch { position: absolute; top: 0; left: min(calc(50vw - 24px), calc(100% - 77px)); transform: translateX(-50%); pointer-events: auto; }
.board-view-switch [data-slot="tabs-list"],
.board-filter-fields [data-slot="tabs-list"] { height: 40px; padding: 3px; gap: 0; border: 1px solid var(--border); border-radius: 2px; background: var(--card); }
.board-view-switch [data-slot="tabs-trigger"],
.board-filter-fields [data-slot="tabs-trigger"] { height: 32px; padding: 0 12px; border-radius: 1px; font: 600 18px/24px "Cormorant Garamond", Georgia, serif; transition: color 200ms, background-color 200ms, box-shadow 200ms; }
.board-view-switch [data-slot="tabs-trigger"][data-state="active"],
.board-filter-fields [data-slot="tabs-trigger"][data-state="active"] { background: var(--background); color: var(--foreground); box-shadow: 0 0 0 1px var(--border); }
.board-surface, .board-graph { position: absolute; inset: 0; }
.board-graph[hidden] { display: none; }

.board-hover-preview { position: absolute; z-index: 10; top: 0; right: 0; width: 336px; max-width: 100%; isolation: isolate; }
/* A corner-wide fade joins the canvas without a panel edge or a clipped glow. */
.board-hover-preview::before { content: ''; position: absolute; z-index: -1; top: 0; right: 0; width: calc(100% + 200px); height: calc(100% + 180px); background: radial-gradient(ellipse farthest-side at 100% 0%, var(--board-canvas-background) 0% 64%, transparent 100%); pointer-events: none; }
.board-hover-preview__card { display: block; width: 100%; cursor: pointer; }
.board-hover-preview__card, .board-hover-preview__description { transform: translateY(24px); }
.board-hover-preview__card > svg { display: block; width: 100%; height: auto; overflow: visible; }
.board-hover-preview__card:focus-visible { outline: 1px solid var(--ring); outline-offset: 4px; border-radius: 4px; }
.board-hover-preview__description { position: relative; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; width: 260px; max-width: calc(100% - 48px); margin: 12px auto 0; overflow: hidden; color: var(--muted-foreground); font: 400 14px/20px 'Roboto Flex', sans-serif; overflow-wrap: anywhere; }

/* Suggestions expand above the input while the search row stays anchored. */
.board-toolbar { position: absolute; z-index: 30; left: 50%; bottom: max(32px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: center; width: min(440px, calc(100cqw - 160px)); min-height: 48px; padding: 3px; border: 1px solid var(--border); border-radius: 3px; background: var(--card); color: var(--foreground); box-shadow: 0 3px 10px #0000001a, 0 0 0 3px color-mix(in srgb, var(--card) 70%, transparent); outline: none; }
.board-toolbar:focus-within { box-shadow: 0 3px 12px #0000001a, 0 0 0 3px color-mix(in srgb, var(--ring) 12%, transparent); }
.board-toolbar__search { grid-column: 1; grid-row: 2; display: flex; align-items: center; min-width: 0; padding-left: 8px; gap: 8px; }
.board-toolbar__search > svg { flex: none; color: var(--muted-foreground); }
.board-toolbar__search input { flex: 1; min-width: 0; height: 40px; padding: 0 8px 0 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--foreground); font: 500 16px/24px "Cormorant Garamond", Georgia, serif; }
.board-toolbar__search input:focus-visible { border: 0; outline: 0; box-shadow: none; }
.board-toolbar__close, .board-toolbar__filters { display: grid; place-items: center; flex: none; width: 36px; height: 40px; cursor: pointer; color: var(--muted-foreground); }
.board-toolbar__filters { grid-column: 2; grid-row: 2; position: relative; width: 40px; border-left: 1px solid var(--border); }
.board-toolbar__filters[data-active="true"]::after { content: ''; position: absolute; top: 6px; right: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }
.board-toolbar__close:hover, .board-toolbar__filters:hover, .board-toolbar__filters[data-state="open"] { color: var(--foreground); background: var(--muted); }
.board-toolbar button:focus-visible { outline: 1px solid var(--ring); outline-offset: -3px; }
.board-search-results { grid-column: 1 / -1; grid-row: 1; min-width: 0; border-bottom: 1px solid var(--border); margin-bottom: 3px; }
.board-search-results__status { margin: 0; padding: 10px 12px; color: var(--muted-foreground); font: 400 12px/18px "Roboto Flex", sans-serif; }
.board-search-results__list { max-height: min(380px, 45svh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.board-search-result { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; text-align: left; cursor: pointer; border-top: 1px solid var(--border); }
.board-search-result[aria-selected="true"], .board-search-result:hover { background: var(--muted); }
.board-search-result__info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.board-search-result__info strong { color: var(--foreground); font: 500 20px/24px "Cormorant Garamond", Georgia, serif; overflow-wrap: anywhere; }
.board-search-result__info > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--muted-foreground); font: 400 12px/17px "Roboto Flex", sans-serif; overflow-wrap: anywhere; }
.board-controls { position: absolute; bottom: max(32px, env(safe-area-inset-bottom)); z-index: 25; left: 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.board-zoom { display: flex; flex-direction: column; gap: 4px; }
.board-zoom[hidden] { display: none; }
.board-zoom > button { background: var(--card); border-radius: 3px; }
.board-settings-panel { z-index: 60; width: 310px; max-width: calc(100vw - 32px); max-height: min(650px, calc(100svh - 110px)); overflow-y: auto; display: flex; flex-direction: column; gap: 20px; padding: 20px; background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 8px 32px #0003; }
.board-settings-panel h2 { margin: 0; font: 600 24px/28px "Cormorant Garamond", Georgia, serif; }
.board-settings-panel > [hidden] { display: none; }
.board-settings-panel > .segmented-control { width: 100%; height: 40px; }

.board-filter-fields { display: flex; flex-direction: column; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.board-filter-fields__field { display: flex; flex-direction: column; gap: 8px; }
.board-filter-fields__field > span { color: var(--muted-foreground); font: 500 14px/20px "Cormorant Garamond", Georgia, serif; }
.board-filter-fields__field[hidden] { display: none; }
.board-settings-panel [data-slot="select-trigger"] { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 3px; font: 600 16px/24px "Cormorant Garamond", Georgia, serif; }
.board-settings-panel [data-slot="select-trigger"] > span { flex: 1; text-align: left; }
.board-filter-fields [data-slot="tabs-list"] { display: flex; width: 100%; }
.board-filter-fields [data-slot="tabs-trigger"] { flex: 1; }

.board-catalogue { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 100px 48px 120px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.board-catalogue__count { margin: 0 0 28px; color: var(--muted-foreground); font: 500 16px/24px "Cormorant Garamond", Georgia, serif; }
.board-catalogue__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 36px 24px; }
.board-catalogue__card { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 12px 8px 20px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; transition: background-color 200ms, border-color 200ms; }
.board-catalogue__card:hover, .board-catalogue__card[aria-pressed="true"] { background: var(--card); border-color: var(--border); }
.board-catalogue__card:focus-visible { outline: 2px solid var(--ring); outline-offset: 4px; }
.board-catalogue__portrait { position: relative; display: grid; place-items: center; width: 100%; height: 180px; margin-bottom: 16px; overflow: hidden; }
.board-catalogue__portrait > img { position: absolute; inset: 0; max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; mask-image: linear-gradient(#000 75%, transparent); }
.board-catalogue__portrait > span { color: var(--muted-foreground); font: 400 72px/1 "Cormorant Garamond", Georgia, serif; opacity: .35; }
.board-catalogue__name { width: 100%; color: var(--foreground); text-align: center; overflow-wrap: anywhere; font: 600 24px/26px "Cormorant Garamond", Georgia, serif; }
.board-catalogue__kind { margin-top: 6px; color: var(--muted-foreground); font: 500 14px/20px "Cormorant Garamond", Georgia, serif; }
.board-catalogue__empty { color: var(--muted-foreground); text-align: center; padding: 15vh 0; }

@media (max-width: 1100px) {
  .board-controls { left: 12px; }
}
@container board-stage (max-width: 1000px) {
  .board-controls { bottom: max(96px, calc(env(safe-area-inset-bottom) + 80px)); }
}
@container board-stage (max-width: 700px) {
  .board-toolbar { width: min(440px, calc(100cqw - 24px)); bottom: max(20px, env(safe-area-inset-bottom)); }
  .board-header { inset: 16px 16px auto; }
  .board-brand { font-size: 24px; }
  .board-language { padding-inline: 10px; gap: 8px; }
  .board-view-switch { left: auto; right: 0; transform: none; }
  .board-controls { bottom: max(84px, calc(env(safe-area-inset-bottom) + 64px)); }
  .board-catalogue { padding: 96px 20px 100px; }
  .board-catalogue__grid { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 24px 12px; }
}
.board-stage { container-type: inline-size; container-name: board-stage; }
@media (max-width: 700px) {
  .board-stage > .character-dossier { width: 100%; max-width: 100%; }
  .board-stage > .character-dossier .dossier-navigation { padding-top: 72px; }
}
@container board-stage (max-width: 380px) {
  .board-view-switch { top: 52px; right: auto; left: 0; }
  .board-catalogue { padding-top: 128px; }
  .board-stage > .character-dossier .dossier-navigation { padding-top: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .board-dossier-backdrop { transition: none; }
  .board-layout { --board-motion: 0ms; }
  .board-language, .board-language__label-stack, .board-language__label, .board-language__label[data-active="true"], .board-language > svg path { transition: none; }
  .board-language[data-pressing="true"], .board-language-menu__item[data-pressing="true"], .board-language-menu[data-state="closed"] { animation: none; }
  .board-view-switch [data-slot="tabs-trigger"], .board-catalogue__card { transition: none; }
}

.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-self: flex-start;
  max-width: 100%;
  gap: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--card);
}
.segmented-control[hidden] { display: none; }
.segmented-control__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 1px;
  background: transparent;
  color: var(--muted-foreground);
  font: 600 18px/24px "Cormorant Garamond", Georgia, serif;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.segmented-control__item:hover { color: var(--foreground); }
.segmented-control__item[data-state="on"] {
  border-color: var(--border);
  background: var(--background);
  color: var(--foreground);
  box-shadow: none;
}
.segmented-control__item:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.segmented-control__item > svg { flex: none; width: 16px; height: 16px; }
@media (prefers-reduced-motion: reduce) {
  .segmented-control__item { transition: none; }
}
