/* ==========================================================================
   Holiday Ornament Workshop — Configurator
   Light theme "Frost & Pine" · Dark theme "Fireside Eve"
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Frost & Pine */
  --bg: #f7f3ea;
  --stage-bg: #ede8dc;
  --surface: #ffffff;
  --surface-subtle: #faf7f0;
  --surface-sunk: #f2ede2;
  --surface-glass: rgba(255, 253, 248, 0.86);
  --ink: #1c2420;
  --ink-secondary: #59615b;
  --ink-muted: #878b82;
  --line: #e7dfcf;
  --line-strong: #d5cab4;
  --pine: #184a36;
  --holly: #a9232c;
  --gold: #b6862e;
  --gold-soft: rgba(182, 134, 46, 0.13);
  --gold-line: rgba(182, 134, 46, 0.42);
  --accent: #184a36;
  --accent-hover: #113a2a;
  --accent-ink: #fbf8f1;
  --accent-soft: rgba(24, 74, 54, 0.09);
  --highlight: #a9232c;
  --highlight-soft: rgba(169, 35, 44, 0.08);
  --tip-bg: #fbf4e4;
  --tip-line: rgba(182, 134, 46, 0.38);
  --warn-border: rgba(169, 35, 44, 0.3);
  --shadow-sm: 0 1px 2px rgba(40, 32, 16, 0.06);
  --shadow-md: 0 8px 24px rgba(40, 32, 16, 0.12);
  --shadow-lg: 0 18px 44px rgba(32, 24, 12, 0.2);
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 15px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1613;
    --stage-bg: #111d18;
    --surface: #13201a;
    --surface-subtle: #172720;
    --surface-sunk: #0f1b16;
    --surface-glass: rgba(17, 29, 24, 0.86);
    --ink: #f0ece2;
    --ink-secondary: #b8b5a8;
    --ink-muted: #858a80;
    --line: #233830;
    --line-strong: #345044;
    --pine: #4f9a76;
    --holly: #d9464f;
    --gold: #dfa944;
    --gold-soft: rgba(223, 169, 68, 0.14);
    --gold-line: rgba(223, 169, 68, 0.4);
    --accent: #dfa944;
    --accent-hover: #ebb956;
    --accent-ink: #1a1408;
    --accent-soft: rgba(223, 169, 68, 0.12);
    --highlight: #d9464f;
    --highlight-soft: rgba(217, 70, 79, 0.12);
    --tip-bg: rgba(223, 169, 68, 0.08);
    --tip-line: rgba(223, 169, 68, 0.32);
    --warn-border: rgba(217, 70, 79, 0.38);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --bg: #0d1613;
  --stage-bg: #111d18;
  --surface: #13201a;
  --surface-subtle: #172720;
  --surface-sunk: #0f1b16;
  --surface-glass: rgba(17, 29, 24, 0.86);
  --ink: #f0ece2;
  --ink-secondary: #b8b5a8;
  --ink-muted: #858a80;
  --line: #233830;
  --line-strong: #345044;
  --pine: #4f9a76;
  --holly: #d9464f;
  --gold: #dfa944;
  --gold-soft: rgba(223, 169, 68, 0.14);
  --gold-line: rgba(223, 169, 68, 0.4);
  --accent: #dfa944;
  --accent-hover: #ebb956;
  --accent-ink: #1a1408;
  --accent-soft: rgba(223, 169, 68, 0.12);
  --highlight: #d9464f;
  --highlight-soft: rgba(217, 70, 79, 0.12);
  --tip-bg: rgba(223, 169, 68, 0.08);
  --tip-line: rgba(223, 169, 68, 0.32);
  --warn-border: rgba(217, 70, 79, 0.38);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ---- Layout ---- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 412px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "stage panel"
    "motion panel";
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* ==========================================================================
   Stage
   ========================================================================== */
.stage {
  grid-area: stage;
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--stage-bg);
  overflow: hidden;
}

.canvas-wrap { position: absolute; inset: 0; }
.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 1.2s ease;
  background:
    radial-gradient(ellipse 60% 55% at 50% 52%, rgba(255, 176, 74, 0.12), transparent 70%),
    radial-gradient(ellipse 120% 95% at 50% 50%, transparent 52%, rgba(8, 5, 2, 0.5) 100%);
}
.stage.is-glowing .stage-vignette { opacity: 1; }

.stage-top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 3;
}

.stage-badge {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  background: var(--surface-glass);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
  max-width: 52%;
  min-width: 0;
  cursor: default;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.stage-badge-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.stage-badge-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.badge-emblem {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
.badge-emblem svg { width: 16px; height: 16px; }

.badge-glint {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  animation: frostPulse 2.4s ease-in-out infinite;
}

.badge-holly {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.badge-holly svg { width: 24px; height: 20px; display: block; }

@keyframes frostPulse {
  0%, 100% { opacity: 0.48; transform: scale(0.88); }
  50% { opacity: 1; transform: scale(1.18); }
}

.stage-summary {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-dims {
  font-size: 11.5px;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-tools {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font: 500 12.5px/1 var(--font-sans);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.tool-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.tool-btn.icon-only { width: 34px; padding: 0; }
.tool-btn:hover { border-color: var(--line-strong); background: var(--surface); }
.tool-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.tool-glow[aria-pressed="true"] {
  background: linear-gradient(180deg, #e7b252, #c8892a);
  border-color: #c8892a;
  color: #2a1a05;
  box-shadow: 0 0 0 3px rgba(231, 178, 82, 0.22), 0 4px 14px rgba(214, 140, 40, 0.35);
}
.tool-tree[aria-pressed="true"] {
  background: linear-gradient(180deg, #226649, #164833);
  border-color: #164833;
  color: #f6f2e8;
  box-shadow: 0 0 0 3px rgba(34, 102, 73, 0.22), 0 4px 14px rgba(18, 60, 42, 0.32);
}

/* ---- Loading / error ---- */
.stage-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 24, 14, 0.1);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  z-index: 6;
}

.loading-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--gold);
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-error {
  position: absolute;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 28px);
  background: var(--surface);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-md);
  padding: 10px 12px 10px 14px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 7;
}
.stage-error p { margin: 0; font-size: 13px; }
.error-icon { width: 18px; height: 18px; color: var(--holly); flex-shrink: 0; }

/* ---- Step callout ---- */
.step-callout {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(620px, calc(100% - 28px));
  z-index: 4;
  background: var(--surface-glass);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 12px 12px 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  animation: callout-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes callout-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.callout-progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: transparent;
}
.callout-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--holly));
}

.callout-body { display: flex; align-items: flex-start; gap: 12px; min-width: 0; flex: 1; }

.callout-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 15px/1 var(--font-serif);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.callout-text { min-width: 0; }
.callout-kicker {
  margin: 0;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.callout-title {
  margin: 1px 0 2px;
  font: 600 16px/1.25 var(--font-serif);
  letter-spacing: -0.005em;
}
.callout-summary {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.callout-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.pill-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 600 12.5px/1 var(--font-sans);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.pill-btn svg { width: 15px; height: 15px; }
.pill-btn:hover:not(:disabled) { border-color: var(--line-strong); }
.pill-btn:disabled { opacity: 0.4; cursor: default; }
.pill-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.pill-icon { width: 34px; padding: 0; justify-content: center; }

/* ==========================================================================
   Motion bar
   ========================================================================== */
.motion-bar {
  grid-area: motion;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 18px;
  padding: 11px 18px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-width: 0;
  position: relative;
}
.motion-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-line) 30%, var(--gold-line) 70%, transparent);
}

.motion-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.motion-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; min-height: 28px; }

.motion-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.motion-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--ink);
  font: 600 12.5px/1 var(--font-sans);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.motion-toggle:hover:not(:disabled) { border-color: var(--line-strong); }
.motion-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.motion-val {
  font-size: 12px;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.motion-item input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  height: 20px;
}

.walk-stepper {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px 32px;
  gap: 5px;
  align-items: center;
}
.motion-walk .motion-head { min-height: 0; }
.motion-walk { gap: 4px; justify-content: flex-end; }

.step-btn {
  appearance: none;
  height: 32px;
  width: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.step-btn svg { width: 16px; height: 16px; }
.step-btn:hover:not(:disabled) { border-color: var(--line-strong); }
.step-btn:disabled { opacity: 0.4; cursor: default; }
.step-play .icon-pause { display: none; }
.step-play[aria-pressed="true"] .icon-play { display: none; }
.step-play[aria-pressed="true"] .icon-pause { display: block; }
.step-play[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1b1407; }

.step-label-btn {
  appearance: none;
  height: 32px;
  min-width: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 12.5px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}
.step-label-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.step-label-btn.is-active {
  background: var(--accent-soft);
  color: var(--ink);
  border-color: var(--gold-line);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.panel {
  grid-area: panel;
  background: var(--bg);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  scroll-padding-top: 64px;
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 12px;
  position: relative;
}
.panel-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.panel-header::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-line), transparent 85%);
}

/* ---- Workshop UI style switcher (Frost Crystal / Nordic Holly) ---- */
.style-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.style-opt {
  appearance: none;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font: 650 11px/1 var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.14s ease, box-shadow 0.16s ease;
}
.style-opt svg { width: 13px; height: 13px; flex-shrink: 0; }
:root[data-style="nordic"] .style-opt[data-ui-style="nordic"][aria-pressed="true"] svg {
  background: #f8f1e1;
  border-radius: 50%;
  padding: 1px;
  width: 15px;
  height: 15px;
}
.style-opt:hover { color: var(--ink); }
.style-opt[aria-pressed="true"] {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.panel-title { min-width: 0; }

.eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}
.eyebrow svg { width: 10px; height: 10px; }

.panel-header h1 {
  margin: 0;
  font: 600 23px/1.15 var(--font-serif);
  letter-spacing: -0.01em;
}

.tagline {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-secondary);
  line-height: 1.4;
}

.btn-ghost {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 500 12.5px/1 var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-ghost svg { width: 15px; height: 15px; }
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-ghost.is-done { border-color: var(--pine); color: var(--pine); }

/* ---- Ornament switcher ---- */
.ornament-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.orn-tile {
  appearance: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 2px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-secondary);
  cursor: pointer;
  min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.orn-tile:hover { border-color: var(--line-strong); color: var(--ink); transform: translateY(-1px); }
.orn-tile svg { width: 34px; height: 34px; }
.orn-tile .orn-name {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.orn-tile[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--ink);
  background: linear-gradient(180deg, var(--gold-soft), var(--surface) 70%);
  box-shadow: 0 0 0 1px var(--gold), var(--shadow-md);
}
.orn-tile .orn-fill { fill: var(--surface-sunk); transition: fill 0.16s ease; }
.orn-tile[aria-pressed="true"] .orn-fill { fill: var(--highlight-soft); }
.orn-tile[aria-pressed="true"] .orn-stroke { stroke: var(--holly); }
.orn-tile .orn-gold { fill: var(--gold); }

.orn-badge {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}
.orn-tile[aria-pressed="true"] .orn-badge { opacity: 1; }

.orn-glow-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e8a93c;
  box-shadow: 0 0 6px 1px rgba(232, 169, 60, 0.75);
}

/* ---- Tabs ---- */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
  position: sticky;
  top: -18px;
  z-index: 5;
  box-shadow: 0 6px 12px -10px rgba(0, 0, 0, 0.2);
}

.tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-secondary);
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.tab-count {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--holly);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tab-panel { display: flex; flex-direction: column; gap: 14px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: var(--shadow-sm);
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.section-title {
  margin: 0;
  font: 600 15px/1.25 var(--font-serif);
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.section-title::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--gold);
  transform: rotate(45deg);
  flex-shrink: 0;
}

.section-meta {
  font-size: 12px;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tag-soft {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- Param controls ---- */
.param-controls { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-label { font-size: 13px; font-weight: 600; }
.field-hint { font-size: 11.5px; color: var(--ink-muted); text-align: right; }

.field-note {
  margin: 0;
  font-size: 12px;
  color: var(--ink-secondary);
  line-height: 1.4;
}
.field-note code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-sunk);
  padding: 1px 4px;
  border-radius: 4px;
}

.seg-group {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 3px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.seg-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 0;
  font: 600 12.5px/1.2 var(--font-sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.seg-desc {
  margin: 0;
  font-size: 12px;
  color: var(--ink-secondary);
  line-height: 1.42;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
}

.switch-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.switch-label { font-size: 13px; font-weight: 600; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background-color 0.16s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.16s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Palette swatches ---- */
.palette-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.palette-btn {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.palette-btn { position: relative; align-items: flex-start; padding: 10px 10px 9px; }
.palette-btn:hover { border-color: var(--line-strong); }
.palette-btn[aria-pressed="true"] {
  border-color: var(--gold);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--gold);
}
.palette-btn.is-base {
  border-color: var(--gold-line);
  border-style: dashed;
  background: var(--surface);
}
.palette-rec {
  position: absolute;
  top: -7px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--gold);
  color: #1b1407;
  box-shadow: var(--shadow-sm);
}

.palette-dots { display: flex; flex-shrink: 0; margin-top: 1px; }
.palette-dots span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.palette-dots span + span { margin-left: -6px; }

.palette-text { display: flex; flex-direction: column; min-width: 0; }
.palette-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.palette-desc {
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--ink-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Recommended scheme callout ---- */
.rec-callout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 11px 10px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-line);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--gold-soft), transparent 62%),
    var(--surface-subtle);
}
.rec-icon {
  width: 26px;
  height: 26px;
  padding: 5px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff8e6;
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.rec-text { min-width: 0; }
.rec-kicker {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gold);
}
.rec-body { margin: 2px 0 0; font-size: 12.5px; line-height: 1.42; color: var(--ink-secondary); }
.rec-body b { color: var(--ink); font: 600 13.5px/1.3 var(--font-serif); }
.rec-apply {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font: 650 11.5px/1 var(--font-sans);
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.rec-apply:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.rec-applied {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 650;
  color: var(--pine);
  white-space: nowrap;
}
.rec-applied svg { width: 14px; height: 14px; }

/* ---- Per-role filament customiser ---- */
.color-custom {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.color-custom > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  cursor: pointer;
  border-radius: var(--radius-md);
  user-select: none;
}
.color-custom > summary::-webkit-details-marker { display: none; }
.color-custom > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.custom-icon { width: 17px; height: 17px; color: var(--gold); flex-shrink: 0; }
.custom-title { font-size: 13px; font-weight: 600; }
.custom-meta { margin-left: auto; font-size: 11.5px; color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.custom-chevron { width: 16px; height: 16px; color: var(--ink-muted); transition: transform 0.18s ease; flex-shrink: 0; }
.color-custom[open] .custom-chevron { transform: rotate(180deg); }
.color-custom[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius-md) var(--radius-md) 0 0; }

.role-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.role-row { border-radius: 9px; border: 1px solid transparent; transition: border-color 0.15s ease, background-color 0.15s ease; }
.role-row.is-open { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }
.role-btn {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.role-btn:hover { background: var(--surface); }
.role-row.is-open .role-btn:hover { background: transparent; }
.role-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16), 0 0 0 2px var(--surface), 0 0 0 3px var(--line);
  transition: background-color 0.12s ease;
}
.role-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.role-label { font-size: 12.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-name { font-size: 11.5px; color: var(--ink-secondary); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-mod {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 2px 6px;
  border-radius: 999px;
}
.role-chev { width: 16px; height: 16px; color: var(--ink-muted); flex-shrink: 0; display: grid; }
.role-chev svg { width: 16px; height: 16px; transition: transform 0.18s ease; }
.role-row.is-open .role-chev svg { transform: rotate(180deg); }

.role-pick { padding: 2px 8px 9px 40px; display: flex; flex-direction: column; gap: 7px; }
.swatch-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  appearance: none;
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"],
.swatch-custom.is-on {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), 0 0 0 2px var(--surface), 0 0 0 4px var(--gold);
}
.swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 6px;
  height: 11px;
  border: solid var(--ink, #fff);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}
.swatch-custom {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    conic-gradient(from 90deg, #a9232c, #d4a13e, #f4f1ea, #6ca0c4, #24344d, #1e6b47, #a9232c);
}
.swatch-custom.is-on { background: var(--c); }
.swatch-custom::before {
  content: "+";
  position: absolute;
  inset: 7px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font: 700 13px/1 var(--font-sans);
  pointer-events: none;
}
.swatch-custom.is-on::before { content: ""; inset: 9px; opacity: 0.9; }
.swatch-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}
.swatch-custom:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.swatch-caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--ink-secondary); }
.swatch-reset { flex-shrink: 0; }

.custom-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 0 11px 10px; }
.custom-foot .field-note { font-size: 11.5px; color: var(--ink-muted); }
.custom-foot .link-btn { flex-shrink: 0; margin-top: 1px; }

/* ---- Buttons ---- */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font: 600 13.5px/1.1 var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); border: 1px solid var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn-secondary { background: var(--surface-subtle); border: 1px solid var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--line-strong); background: var(--surface); }
.btn-secondary[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.btn-sm { min-height: 30px; padding: 5px 11px; font-size: 12.5px; }
.btn-compact { min-height: 38px; font-size: 13px; }
.btn-primary.is-busy,
.btn-secondary.is-busy { opacity: 0.7; pointer-events: none; }
.btn-primary[aria-disabled="true"],
.btn-secondary[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* Two-line download buttons */
.btn-download {
  justify-content: flex-start;
  gap: 11px;
  padding: 10px 14px;
  white-space: normal;
  text-align: left;
}
.btn-download > svg { width: 20px; height: 20px; flex-shrink: 0; }
.dl-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dl-title { font: 650 13.5px/1.2 var(--font-sans); }
.dl-sub { font: 500 11.5px/1.35 var(--font-sans); opacity: 0.82; }
.btn-secondary.btn-download { min-height: 0; }
.btn-secondary.btn-download > svg { color: var(--gold); }

/* ---- Print plan: spools & plates ---- */
.plan-block { display: flex; flex-direction: column; gap: 7px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.plan-title {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.plan-meta { font-size: 11.5px; color: var(--ink-secondary); font-variant-numeric: tabular-nums; }
.plan-note { margin: 0; font-size: 11.5px; color: var(--ink-muted); line-height: 1.4; }

.spool-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.spool-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  min-width: 0;
}
.spool-slot {
  font: 700 9.5px/1 var(--font-mono);
  color: var(--ink-muted);
  padding-left: 3px;
}
.spool-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), inset 0 0 0 5px rgba(255, 255, 255, 0.14);
}
.spool-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.spool-text b { font-size: 12px; font-weight: 650; white-space: nowrap; }
.spool-meta { font-size: 10.5px; color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.plate-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.plate-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
}
.plate-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 12px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.plate-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plate-name { font-size: 12.5px; color: var(--ink-secondary); line-height: 1.3; }
.plate-name b { color: var(--ink); font-weight: 650; }
.plate-parts { font-size: 11.5px; color: var(--ink-secondary); line-height: 1.38; }
.plate-setting { font-size: 10.5px; color: var(--ink-muted); }
.plate-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.plate-badge {
  font-size: 10px;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  white-space: nowrap;
}
.plate-badge.is-tpu { background: rgba(84, 150, 128, 0.18); color: #3c7c67; }
:root[data-theme="dark"] .plate-badge.is-tpu { color: #7fc4aa; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .plate-badge.is-tpu { color: #7fc4aa; }
}
.plate-weight { font-size: 11px; color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 3px; }

.plan-block-prep { padding-top: 10px; border-top: 1px dashed var(--gold-line); }
.plan-block-prep .plate-row,
.plan-block-prep .spool-chip { background: var(--surface); }

.pill-row { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pill-row li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 550;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}
.pill-row li b { color: var(--ink); font-weight: 650; }

/* ---- Specs ---- */
.spec-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.spec-cell {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.spec-cell.full { grid-column: 1 / -1; }
.spec-cell dt { font-size: 11px; font-weight: 550; color: var(--ink-muted); }
.spec-cell dd { margin: 0; font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.spec-sub { font-size: 11px; color: var(--ink-secondary); line-height: 1.35; }
.spec-empty { grid-column: 1 / -1; font-size: 12px; color: var(--ink-muted); margin: 0; }

/* ---- Parts list ---- */
.link-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--accent);
  font: 600 12px/1 var(--font-sans);
  cursor: pointer;
}
:root[data-theme="dark"] .link-btn { color: var(--gold); }
.link-btn:hover { text-decoration: underline; }

.parts-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.part-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 6px 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid transparent;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.part-row.is-hidden { opacity: 0.5; }
.part-row.is-active { border-color: var(--gold-line); background: var(--gold-soft); }

.part-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.part-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.part-label { font-size: 12.5px; line-height: 1.3; }
.part-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 10.5px; color: var(--ink-muted); }

.chip {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--line);
  color: var(--ink-secondary);
}
.chip-tpu { background: rgba(84, 150, 128, 0.18); color: #3c7c67; }
:root[data-theme="dark"] .chip-tpu { color: #7fc4aa; }
.chip-preview { background: var(--gold-soft); color: var(--gold); }

.part-weight { font-size: 11px; color: var(--ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.eye-btn {
  appearance: none;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  padding: 0;
}
.eye-btn:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.eye-btn svg { width: 17px; height: 17px; }

/* ==========================================================================
   Assembly guide
   ========================================================================== */
.prep-banner {
  border-radius: var(--radius-lg);
  padding: 14px 15px;
  background:
    linear-gradient(135deg, var(--gold-soft), transparent 60%),
    var(--surface);
  border: 1px solid var(--gold-line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prep-head { display: flex; align-items: center; gap: 8px; color: var(--gold); }
.prep-head svg { width: 18px; height: 18px; }
.prep-head h2 { margin: 0; font: 600 15px/1.2 var(--font-serif); color: var(--ink); }

.prep-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; }
.prep-grid > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 8px;
  min-width: 0;
}
.prep-grid dt { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }
.prep-grid dd { margin: 1px 0 0; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.prep-note { margin: 0; font-size: 12px; color: var(--ink-secondary); line-height: 1.45; }
.prep-note b { color: var(--ink); font-weight: 600; }

.guide-toolbar { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 8px; }

.guide-hint { margin: -4px 2px 0; font-size: 11.5px; color: var(--ink-muted); }
kbd {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--ink-secondary);
}

.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.step-card {
  appearance: none;
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 11px;
  padding: 13px 13px 13px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
  font: inherit;
}
.step-card:hover { border-color: var(--line-strong); }
.step-card.is-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), var(--shadow-md);
  background: linear-gradient(180deg, var(--gold-soft), var(--surface) 55%);
}
.step-card.is-done .step-num { background: var(--pine); border-color: var(--pine); color: #fff; }

.step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--gold-line);
  background: var(--surface);
  color: var(--ink);
  font: 600 14px/1 var(--font-serif);
  font-variant-numeric: tabular-nums;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.step-card.is-active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.step-content { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.step-title, .step-summary { display: block; }
.step-title { margin: 4px 0 0; font: 600 15px/1.25 var(--font-serif); }
.step-summary { margin: 0; font-size: 12.5px; color: var(--ink-secondary); line-height: 1.5; }

.step-tip {
  margin: 2px 0 0;
  display: flex;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--tip-bg);
  border: 1px solid var(--tip-line);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
}
.step-tip svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--gold); }
.step-tip b { font-weight: 650; color: var(--gold); margin-right: 2px; }

.step-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 1px; }
.step-chips span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 550;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  color: var(--ink-secondary);
}
.step-chips i { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }

.steps-empty { font-size: 12.5px; color: var(--ink-muted); padding: 10px 4px; }

/* ---- Back-view pin insertion map ---- */
.steps-list li.has-pinmap { display: flex; flex-direction: column; gap: 0; }
.steps-list li.has-pinmap .step-card { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.steps-list li.has-pinmap .pinmap-card {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin: 0;
}

.pinmap-card {
  margin: 0;
  padding: 11px 12px 12px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, var(--gold-soft), transparent 40%),
    var(--surface);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.pinmap-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pinmap-title { display: inline-flex; align-items: center; gap: 7px; font: 600 13.5px/1.25 var(--font-serif); color: var(--ink); min-width: 0; }
.pinmap-title svg { width: 18px; height: 18px; color: var(--gold); flex-shrink: 0; }
.pinmap-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font: 650 11.5px/1 var(--font-sans);
  color: var(--ink);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.pinmap-open:hover { border-color: var(--gold); }
.pinmap-open svg { width: 13px; height: 13px; }
.pinmap-frame {
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: var(--radius-md);
  /* The SVG is drawn for paper: keep a light, print-like mat in both themes. */
  background: #fbf9f4;
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 3px rgba(40, 32, 16, 0.08);
  min-height: 120px;
}
.pinmap-frame img { display: block; width: 100%; max-width: 340px; height: auto; aspect-ratio: auto; }
.pinmap-frame.is-error { background: var(--surface-sunk); }
.pinmap-error { font-size: 12px; color: var(--ink-muted); text-align: center; }
.pinmap-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px 12px; }
.pinmap-legend li { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 550; color: var(--ink-secondary); }
.pinmap-legend i { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); flex-shrink: 0; }
.pinmap-note { margin: 0; font-size: 11px; color: var(--ink-muted); line-height: 1.4; }

.callout-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  font: 650 11.5px/1 var(--font-sans);
  color: var(--gold);
  text-decoration: none;
}
.callout-link:hover { text-decoration: underline; }
.callout-link svg { width: 13px; height: 13px; }

/* ---- Workshop FAQ, AdSense slot & Footer ---- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  overflow: hidden;
}
.faq-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary::after {
  content: "+";
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.faq-item[open] > summary::after { content: "−"; }
.faq-item > p {
  margin: 0;
  padding: 0 11px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-secondary);
}
.faq-item code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-sunk);
  padding: 1px 4px;
  border-radius: 4px;
}

.ad-slot-card {
  gap: 6px;
  padding: 10px 12px;
  align-items: stretch;
}
.ad-slot-label {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.ad-slot-body {
  min-height: 90px;
  width: 100%;
  overflow: hidden;
}

.panel-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  font-size: 11.5px;
  color: var(--ink-muted);
}
.footer-links {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--ink-secondary);
  text-decoration: none;
}
.footer-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* ==========================================================================
   Sparkle click burst layer
   ========================================================================== */
.spark-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.spark {
  position: fixed;
  pointer-events: none;
  font-size: 13px;
  line-height: 1;
  will-change: transform, opacity;
  animation: sparkFly 650ms cubic-bezier(0.16, 0.84, 0.44, 1) forwards;
}

@keyframes sparkFly {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.45) rotate(0deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.25) rotate(var(--rot)); }
}

/* ==========================================================================
   STYLE B: FROSTED SNOW-GLOBE CRYSTAL (data-style="frost")
   ========================================================================== */
:root[data-style="frost"],
:root:not([data-style]) {
  --bg: #eef5fa;
  --stage-bg: #e4eff7;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-subtle: #f4f9fd;
  --surface-sunk: #e4eff7;
  --surface-glass: rgba(246, 251, 255, 0.82);
  --ink: #122631;
  --ink-secondary: #486474;
  --ink-muted: #6f8b9c;
  --line: #cce0ee;
  --line-strong: #a2c7df;
  --accent: #1c6b92;
  --accent-hover: #155575;
  --accent-ink: #f4fbff;
  --accent-soft: rgba(28, 107, 146, 0.1);
  --gold: #257ea8;
  --gold-soft: rgba(56, 152, 200, 0.13);
  --gold-line: rgba(56, 152, 200, 0.42);
  --tip-bg: #eaf5fc;
  --tip-line: rgba(56, 152, 200, 0.36);
  --frost-rim: rgba(70, 158, 206, 0.44);
  --frost-glow: rgba(74, 175, 232, 0.28);
  --frost-spec: rgba(255, 255, 255, 0.75);
  --frost-sheen: rgba(255, 255, 255, 0.55);
  --frost-pill-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(224, 242, 253, 0.92));
  --frost-cta-bg: linear-gradient(135deg, #257ea8, #165678);
  --frost-cta-border: #4ea5cf;
  --frost-badge-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(221, 240, 252, 0.84));
}

@media (prefers-color-scheme: dark) {
  :root[data-style="frost"]:not([data-theme="light"]),
  :root:not([data-style]):not([data-theme="light"]) {
    --bg: #0a141a;
    --stage-bg: #0d1a21;
    --surface: #11212a;
    --surface-subtle: #152833;
    --surface-sunk: #0d1a22;
    --surface-glass: rgba(16, 33, 43, 0.78);
    --ink: #ecf6fc;
    --ink-secondary: #a1bfd0;
    --ink-muted: #7090a3;
    --line: #213c4b;
    --line-strong: #355e74;
    --accent: #7fd4ff;
    --accent-hover: #a5e2ff;
    --accent-ink: #081a24;
    --accent-soft: rgba(127, 212, 255, 0.14);
    --gold: #8ed6fa;
    --gold-soft: rgba(142, 214, 250, 0.14);
    --gold-line: rgba(154, 219, 252, 0.42);
    --tip-bg: rgba(127, 212, 255, 0.09);
    --tip-line: rgba(154, 219, 252, 0.34);
    --frost-rim: rgba(185, 226, 248, 0.38);
    --frost-glow: rgba(135, 210, 252, 0.32);
    --frost-spec: rgba(255, 255, 255, 0.24);
    --frost-sheen: rgba(255, 255, 255, 0.34);
    --frost-pill-bg: linear-gradient(180deg, rgba(160, 215, 245, 0.28), rgba(102, 168, 208, 0.2));
    --frost-cta-bg: linear-gradient(135deg, rgba(132, 204, 240, 0.34), rgba(56, 122, 162, 0.52));
    --frost-cta-border: rgba(206, 238, 255, 0.62);
    --frost-badge-bg: linear-gradient(135deg, rgba(150, 210, 242, 0.16), rgba(16, 34, 44, 0.78));
  }
}

:root[data-style="frost"][data-theme="dark"],
:root:not([data-style])[data-theme="dark"] {
  --bg: #0a141a;
  --stage-bg: #0d1a21;
  --surface: #11212a;
  --surface-subtle: #152833;
  --surface-sunk: #0d1a22;
  --surface-glass: rgba(16, 33, 43, 0.78);
  --ink: #ecf6fc;
  --ink-secondary: #a1bfd0;
  --ink-muted: #7090a3;
  --line: #213c4b;
  --line-strong: #355e74;
  --accent: #7fd4ff;
  --accent-hover: #a5e2ff;
  --accent-ink: #081a24;
  --accent-soft: rgba(127, 212, 255, 0.14);
  --gold: #8ed6fa;
  --gold-soft: rgba(142, 214, 250, 0.14);
  --gold-line: rgba(154, 219, 252, 0.42);
  --tip-bg: rgba(127, 212, 255, 0.09);
  --tip-line: rgba(154, 219, 252, 0.34);
  --frost-rim: rgba(185, 226, 248, 0.38);
  --frost-glow: rgba(135, 210, 252, 0.32);
  --frost-spec: rgba(255, 255, 255, 0.24);
  --frost-sheen: rgba(255, 255, 255, 0.34);
  --frost-pill-bg: linear-gradient(180deg, rgba(160, 215, 245, 0.28), rgba(102, 168, 208, 0.2));
  --frost-cta-bg: linear-gradient(135deg, rgba(132, 204, 240, 0.34), rgba(56, 122, 162, 0.52));
  --frost-cta-border: rgba(206, 238, 255, 0.62);
  --frost-badge-bg: linear-gradient(135deg, rgba(150, 210, 242, 0.16), rgba(16, 34, 44, 0.78));
}

:root[data-style="frost"] .stage-badge,
:root:not([data-style]) .stage-badge {
  background: var(--frost-badge-bg);
  border: 1px solid var(--frost-rim);
  border-radius: 15px;
  box-shadow: inset 0 1px 0 var(--frost-spec), 0 8px 22px rgba(8, 24, 34, 0.18);
}
:root[data-style="frost"] .stage-badge:hover,
:root:not([data-style]) .stage-badge:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 var(--frost-spec), 0 10px 26px var(--frost-glow);
}
:root[data-style="frost"] .badge-emblem-frost,
:root:not([data-style]) .badge-emblem-frost {
  background: var(--gold-soft);
  border: 1px solid var(--frost-rim);
  color: var(--accent);
}
:root[data-style="frost"] .stage-badge:hover .badge-emblem-frost,
:root:not([data-style]) .stage-badge:hover .badge-emblem-frost {
  transform: rotate(90deg) scale(1.08);
}
:root[data-style="frost"] .badge-glint-frost,
:root:not([data-style]) .badge-glint-frost {
  color: var(--accent);
  text-shadow: 0 0 10px var(--frost-glow);
}

/* Frost pills & sheen sweeps */
:root[data-style="frost"] .seg-group,
:root:not([data-style]) .seg-group {
  border-radius: 999px;
  padding: 4px;
  gap: 5px;
}
:root[data-style="frost"] .seg-btn,
:root:not([data-style]) .seg-btn {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  padding: 7px 6px;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s ease, box-shadow 0.2s ease, background 0.18s ease, color 0.18s ease;
}
:root[data-style="frost"] .seg-btn:hover,
:root:not([data-style]) .seg-btn:hover {
  border-color: var(--frost-rim);
  transform: translateY(-1px);
}
:root[data-style="frost"] .seg-btn[aria-pressed="true"],
:root:not([data-style]) .seg-btn[aria-pressed="true"] {
  background: var(--frost-pill-bg);
  border-color: var(--frost-rim);
  color: var(--ink);
  box-shadow: 0 0 14px var(--frost-glow), inset 0 1px 0 var(--frost-spec);
}
:root[data-style="frost"] .seg-btn:active,
:root:not([data-style]) .seg-btn:active {
  transform: scale(0.96);
}

:root[data-style="frost"] .tool-btn,
:root:not([data-style]) .tool-btn,
:root[data-style="frost"] .btn-primary,
:root:not([data-style]) .btn-primary,
:root[data-style="frost"] .btn-secondary,
:root:not([data-style]) .btn-secondary,
:root[data-style="frost"] .step-label-btn,
:root:not([data-style]) .step-label-btn,
:root[data-style="frost"] .rec-apply,
:root:not([data-style]) .rec-apply,
:root[data-style="frost"] .pill-btn,
:root:not([data-style]) .pill-btn,
:root[data-style="frost"] .motion-toggle,
:root:not([data-style]) .motion-toggle {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
:root[data-style="frost"] .btn-download,
:root:not([data-style]) .btn-download {
  border-radius: 16px;
}

:root[data-style="frost"] .btn-primary,
:root:not([data-style]) .btn-primary,
:root[data-style="frost"] .step-label-btn:not(.is-active),
:root:not([data-style]) .step-label-btn:not(.is-active),
:root[data-style="frost"] .pill-primary,
:root:not([data-style]) .pill-primary,
:root[data-style="frost"] .rec-apply,
:root:not([data-style]) .rec-apply {
  background: var(--frost-cta-bg);
  border-color: var(--frost-cta-border);
  color: #f4fbff;
  box-shadow: 0 4px 16px var(--frost-glow), inset 0 1px 0 var(--frost-spec);
}

/* Diagonal frosted-glass sheen sweep on hover */
:root[data-style="frost"] .btn-primary::after,
:root:not([data-style]) .btn-primary::after,
:root[data-style="frost"] .tool-btn::after,
:root:not([data-style]) .tool-btn::after,
:root[data-style="frost"] .seg-btn[aria-pressed="true"]::after,
:root:not([data-style]) .seg-btn[aria-pressed="true"]::after,
:root[data-style="frost"] .step-label-btn::after,
:root:not([data-style]) .step-label-btn::after,
:root[data-style="frost"] .rec-apply::after,
:root:not([data-style]) .rec-apply::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 18%, var(--frost-sheen) 50%, transparent 82%);
  transform: translateX(-135%);
  transition: transform 0.55s ease;
}
:root[data-style="frost"] .btn-primary:hover::after,
:root:not([data-style]) .btn-primary:hover::after,
:root[data-style="frost"] .tool-btn:hover::after,
:root:not([data-style]) .tool-btn:hover::after,
:root[data-style="frost"] .seg-btn[aria-pressed="true"]:hover::after,
:root:not([data-style]) .seg-btn[aria-pressed="true"]:hover::after,
:root[data-style="frost"] .step-label-btn:hover::after,
:root:not([data-style]) .step-label-btn:hover::after,
:root[data-style="frost"] .rec-apply:hover::after,
:root:not([data-style]) .rec-apply:hover::after {
  transform: translateX(135%);
}

:root[data-style="frost"] .btn-primary:hover,
:root:not([data-style]) .btn-primary:hover,
:root[data-style="frost"] .tool-btn:hover,
:root:not([data-style]) .tool-btn:hover,
:root[data-style="frost"] .btn-secondary:hover,
:root:not([data-style]) .btn-secondary:hover,
:root[data-style="frost"] .pill-btn:hover:not(:disabled),
:root:not([data-style]) .pill-btn:hover:not(:disabled),
:root[data-style="frost"] .rec-apply:hover,
:root:not([data-style]) .rec-apply:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 20px var(--frost-glow), inset 0 1px 0 var(--frost-spec);
}
:root[data-style="frost"] .btn-primary:active,
:root:not([data-style]) .btn-primary:active,
:root[data-style="frost"] .tool-btn:active,
:root:not([data-style]) .tool-btn:active,
:root[data-style="frost"] .btn-secondary:active,
:root:not([data-style]) .btn-secondary:active,
:root[data-style="frost"] .pill-btn:active:not(:disabled),
:root:not([data-style]) .pill-btn:active:not(:disabled),
:root[data-style="frost"] .rec-apply:active,
:root:not([data-style]) .rec-apply:active {
  transform: scale(0.96);
}

:root[data-style="frost"] .tool-btn[aria-pressed="true"]:not(.tool-glow):not(.tool-tree),
:root:not([data-style]) .tool-btn[aria-pressed="true"]:not(.tool-glow):not(.tool-tree) {
  background: var(--frost-pill-bg);
  border-color: var(--frost-cta-border);
  color: var(--ink);
  box-shadow: 0 0 14px var(--frost-glow), inset 0 1px 0 var(--frost-spec);
}

:root[data-style="frost"] .card,
:root:not([data-style]) .card,
:root[data-style="frost"] .step-callout,
:root:not([data-style]) .step-callout {
  box-shadow: inset 0 1px 0 var(--frost-spec), var(--shadow-sm);
}
:root[data-style="frost"] .seg-desc,
:root:not([data-style]) .seg-desc {
  background: var(--gold-soft);
  border: 1px solid var(--frost-rim);
  border-radius: 10px;
}
:root[data-style="frost"] .tabs,
:root:not([data-style]) .tabs {
  border-radius: 999px;
}
:root[data-style="frost"] .tab,
:root:not([data-style]) .tab {
  border-radius: 999px;
}
:root[data-style="frost"] .tab[aria-selected="true"],
:root:not([data-style]) .tab[aria-selected="true"] {
  background: var(--frost-pill-bg);
  border-color: var(--frost-rim);
  box-shadow: 0 0 12px var(--frost-glow), inset 0 1px 0 var(--frost-spec);
}
:root[data-style="frost"] .orn-tile[aria-pressed="true"],
:root:not([data-style]) .orn-tile[aria-pressed="true"],
:root[data-style="frost"] .palette-btn[aria-pressed="true"],
:root:not([data-style]) .palette-btn[aria-pressed="true"],
:root[data-style="frost"] .step-card.is-active,
:root:not([data-style]) .step-card.is-active {
  border-color: var(--frost-cta-border);
  box-shadow: 0 0 0 1px var(--frost-cta-border), 0 6px 18px var(--frost-glow), inset 0 1px 0 var(--frost-spec);
}
:root[data-style="frost"] .style-opt[data-ui-style="frost"][aria-pressed="true"],
:root:not([data-style]) .style-opt[data-ui-style="frost"][aria-pressed="true"] {
  background: var(--frost-pill-bg);
  border-color: var(--frost-rim);
  color: var(--ink);
  box-shadow: 0 0 10px var(--frost-glow), inset 0 1px 0 var(--frost-spec);
}

/* ==========================================================================
   STYLE D: NORDIC STITCHED LINEN & HOLLY WOODBLOCK (data-style="nordic")
   ========================================================================== */
:root[data-style="nordic"] {
  --bg: #f5efe1;
  --stage-bg: #ebe2ce;
  --surface: #fcf8ee;
  --surface-subtle: #f4ecdb;
  --surface-sunk: #e8dec9;
  --surface-glass: rgba(252, 248, 238, 0.94);
  --ink: #1b2821;
  --ink-secondary: #4e6156;
  --ink-muted: #7b897f;
  --line: #d9cbb0;
  --line-strong: #c4b08b;
  --pine: #1e6243;
  --holly: #b82630;
  --gold: #b88730;
  --gold-soft: rgba(184, 135, 48, 0.14);
  --gold-line: #c8a263;
  --accent: #1f6545;
  --accent-hover: #175237;
  --accent-ink: #faf6eb;
  --accent-soft: rgba(31, 101, 69, 0.11);
  --tip-bg: #f6eedb;
  --tip-line: #c8a263;
  --linen-bg: #f8f1e1;
  --linen-ink: #1b2821;
  --linen-sub: #4d6256;
  --linen-stitch: #c4984f;
  --wood-neutral-bg: #fcf8ee;
  --wood-neutral-border: #cbb996;
  --wood-neutral-lip: #baa47d;
  --wood-holly-bg: linear-gradient(180deg, #c7303a, #a61e28);
  --wood-holly-border: #e0535c;
  --wood-holly-lip: #6c1017;
  --wood-pine-bg: linear-gradient(180deg, #256e4d, #195138);
  --wood-pine-border: #378762;
  --wood-pine-lip: #0b291c;
}

@media (prefers-color-scheme: dark) {
  :root[data-style="nordic"]:not([data-theme="light"]) {
    --bg: #0e1914;
    --stage-bg: #111f19;
    --surface: #15251e;
    --surface-subtle: #1a2d25;
    --surface-sunk: #0d1813;
    --surface-glass: rgba(20, 35, 28, 0.9);
    --ink: #f2ece0;
    --ink-secondary: #b4c6bc;
    --ink-muted: #7f968a;
    --line: #273e33;
    --line-strong: #3a5b4b;
    --pine: #3fa274;
    --holly: #de434d;
    --gold: #dfb052;
    --gold-soft: rgba(223, 176, 82, 0.15);
    --gold-line: #c89f54;
    --accent: #256e4d;
    --accent-hover: #2d825b;
    --accent-ink: #f7f3e8;
    --accent-soft: rgba(63, 162, 116, 0.16);
    --tip-bg: rgba(246, 239, 224, 0.06);
    --tip-line: #b9914d;
    --linen-bg: #f6efe0;
    --linen-ink: #1b2821;
    --linen-sub: #4f6458;
    --linen-stitch: #c8a263;
    --wood-neutral-bg: #1a2d24;
    --wood-neutral-border: #324d40;
    --wood-neutral-lip: #09120e;
    --wood-holly-bg: linear-gradient(180deg, #c62f39, #9f1b24);
    --wood-holly-border: #e0555e;
    --wood-holly-lip: #5f0d13;
    --wood-pine-bg: linear-gradient(180deg, #277350, #195138);
    --wood-pine-border: #3a8b65;
    --wood-pine-lip: #092216;
  }
}

:root[data-style="nordic"][data-theme="dark"] {
  --bg: #0e1914;
  --stage-bg: #111f19;
  --surface: #15251e;
  --surface-subtle: #1a2d25;
  --surface-sunk: #0d1813;
  --surface-glass: rgba(20, 35, 28, 0.9);
  --ink: #f2ece0;
  --ink-secondary: #b4c6bc;
  --ink-muted: #7f968a;
  --line: #273e33;
  --line-strong: #3a5b4b;
  --pine: #3fa274;
  --holly: #de434d;
  --gold: #dfb052;
  --gold-soft: rgba(223, 176, 82, 0.15);
  --gold-line: #c89f54;
  --accent: #256e4d;
  --accent-hover: #2d825b;
  --accent-ink: #f7f3e8;
  --accent-soft: rgba(63, 162, 116, 0.16);
  --tip-bg: rgba(246, 239, 224, 0.06);
  --tip-line: #b9914d;
  --linen-bg: #f6efe0;
  --linen-ink: #1b2821;
  --linen-sub: #4f6458;
  --linen-stitch: #c8a263;
  --wood-neutral-bg: #1a2d24;
  --wood-neutral-border: #324d40;
  --wood-neutral-lip: #09120e;
  --wood-holly-bg: linear-gradient(180deg, #c62f39, #9f1b24);
  --wood-holly-border: #e0555e;
  --wood-holly-lip: #5f0d13;
  --wood-pine-bg: linear-gradient(180deg, #277350, #195138);
  --wood-pine-border: #3a8b65;
  --wood-pine-lip: #092216;
}

/* Nordic stitched linen stage badge */
:root[data-style="nordic"] .stage-badge {
  background: var(--linen-bg);
  color: var(--linen-ink);
  border: 1px solid rgba(180, 145, 86, 0.45);
  border-radius: 13px;
  padding: 5px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 5px 16px rgba(10, 18, 13, 0.28);
}
:root[data-style="nordic"] .stage-badge:hover {
  transform: translateY(-1.5px) rotate(-0.45deg);
}
:root[data-style="nordic"] .stage-badge-inner {
  border: 1.5px dashed var(--linen-stitch);
  border-radius: 8px;
  padding: 5px 10px;
}
:root[data-style="nordic"] .stage-summary { color: var(--linen-ink); }
:root[data-style="nordic"] .stage-dims { color: var(--linen-sub); }
:root[data-style="nordic"] .badge-emblem-frost,
:root[data-style="nordic"] .badge-glint-frost { display: none; }
:root[data-style="nordic"] .badge-emblem-nordic { display: inline-flex; }
:root[data-style="nordic"] .stage-badge:hover .badge-emblem-nordic {
  transform: scale(1.18) rotate(-8deg);
}

/* Nordic holly-berry section marker */
:root[data-style="nordic"] .section-title::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: none;
  background: radial-gradient(circle at 30% 30%, #f16169, #a81c26);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* Nordic stitched info callouts */
:root[data-style="nordic"] .seg-desc {
  background: var(--surface-subtle);
  border: 1.5px dashed var(--gold-line);
  border-radius: 9px;
}
:root[data-style="nordic"] .rec-callout,
:root[data-style="nordic"] .prep-banner,
:root[data-style="nordic"] .step-tip {
  border: 1.5px dashed var(--gold-line);
}

/* Nordic tactile 3D wooden-toy press buttons */
:root[data-style="nordic"] .seg-group {
  padding: 5px 5px 8px;
  gap: 6px;
  border-radius: 12px;
}
:root[data-style="nordic"] .seg-btn {
  border-radius: 9px;
  padding: 7px 6px;
  border: 1px solid var(--wood-neutral-border);
  background: var(--wood-neutral-bg);
  color: var(--ink-secondary);
  box-shadow: 0 3px 0 var(--wood-neutral-lip);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease, color 0.15s ease;
}
:root[data-style="nordic"] .seg-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--wood-neutral-lip);
  color: var(--ink);
}
:root[data-style="nordic"] .seg-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--wood-neutral-lip);
}
:root[data-style="nordic"] .seg-btn[aria-pressed="true"] {
  background: var(--wood-holly-bg);
  border-color: var(--wood-holly-border);
  color: #fff8ee;
  box-shadow: 0 3px 0 var(--wood-holly-lip);
}
:root[data-style="nordic"] .seg-btn[aria-pressed="true"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--wood-holly-lip);
  color: #fff8ee;
}
:root[data-style="nordic"] .seg-btn[aria-pressed="true"]:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--wood-holly-lip);
}

:root[data-style="nordic"] .btn-primary,
:root[data-style="nordic"] .step-label-btn:not(.is-active),
:root[data-style="nordic"] .pill-primary,
:root[data-style="nordic"] .rec-apply {
  background: var(--wood-pine-bg);
  border-color: var(--wood-pine-border);
  color: #f7f3e8;
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--wood-pine-lip);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s ease;
}
:root[data-style="nordic"] .btn-primary:hover,
:root[data-style="nordic"] .step-label-btn:not(.is-active):hover,
:root[data-style="nordic"] .pill-primary:hover:not(:disabled),
:root[data-style="nordic"] .rec-apply:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 4.5px 0 var(--wood-pine-lip);
  filter: brightness(1.06);
}
:root[data-style="nordic"] .btn-primary:active,
:root[data-style="nordic"] .step-label-btn:not(.is-active):active,
:root[data-style="nordic"] .pill-primary:active:not(:disabled),
:root[data-style="nordic"] .rec-apply:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--wood-pine-lip);
}

:root[data-style="nordic"] .btn-secondary,
:root[data-style="nordic"] .tool-btn,
:root[data-style="nordic"] .motion-toggle,
:root[data-style="nordic"] .step-btn,
:root[data-style="nordic"] .pill-btn:not(.pill-primary) {
  border-radius: 9px;
  border-color: var(--wood-neutral-border);
  background: var(--wood-neutral-bg);
  box-shadow: 0 2.5px 0 var(--wood-neutral-lip);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s ease, color 0.15s ease;
}
:root[data-style="nordic"] .btn-secondary:hover,
:root[data-style="nordic"] .tool-btn:hover,
:root[data-style="nordic"] .motion-toggle:hover:not(:disabled),
:root[data-style="nordic"] .step-btn:hover:not(:disabled),
:root[data-style="nordic"] .pill-btn:not(.pill-primary):hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3.5px 0 var(--wood-neutral-lip);
}
:root[data-style="nordic"] .btn-secondary:active,
:root[data-style="nordic"] .tool-btn:active,
:root[data-style="nordic"] .motion-toggle:active:not(:disabled),
:root[data-style="nordic"] .step-btn:active:not(:disabled),
:root[data-style="nordic"] .pill-btn:not(.pill-primary):active:not(:disabled) {
  transform: translateY(1.5px);
  box-shadow: 0 1px 0 var(--wood-neutral-lip);
}

:root[data-style="nordic"] .tool-btn[aria-pressed="true"]:not(.tool-glow):not(.tool-tree),
:root[data-style="nordic"] .motion-toggle[aria-pressed="true"] {
  background: var(--wood-holly-bg);
  border-color: var(--wood-holly-border);
  color: #fff8ee;
  box-shadow: 0 2.5px 0 var(--wood-holly-lip);
}
:root[data-style="nordic"] .tool-tree[aria-pressed="true"] {
  background: var(--wood-pine-bg);
  border-color: var(--wood-pine-border);
  color: #f7f3e8;
  box-shadow: 0 2.5px 0 var(--wood-pine-lip);
}
:root[data-style="nordic"] .tabs {
  padding: 5px 5px 7px;
  gap: 6px;
}
:root[data-style="nordic"] .tab[aria-selected="true"] {
  background: var(--wood-holly-bg);
  border-color: var(--wood-holly-border);
  color: #fff8ee;
  box-shadow: 0 2.5px 0 var(--wood-holly-lip);
}
:root[data-style="nordic"] .tab[aria-selected="true"] .tab-count {
  background: #f8f1e1;
  color: #9e1b24;
}
:root[data-style="nordic"] .style-opt[data-ui-style="nordic"][aria-pressed="true"] {
  background: var(--wood-holly-bg);
  border-color: var(--wood-holly-border);
  color: #fff8ee;
  box-shadow: 0 2px 0 var(--wood-holly-lip);
}
:root[data-style="nordic"] .orn-tile[aria-pressed="true"],
:root[data-style="nordic"] .palette-btn[aria-pressed="true"],
:root[data-style="nordic"] .step-card.is-active {
  border-color: var(--gold-line);
  box-shadow: 0 3px 0 var(--wood-neutral-lip), 0 0 0 1px var(--gold-line);
}

/* ---- Focus ---- */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

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

/* ==========================================================================
   Tablet & mobile (< 960px)
   ========================================================================== */
@media (max-width: 959px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 42dvh auto minmax(0, 1fr);
    grid-template-areas:
      "stage"
      "motion"
      "panel";
  }

  .stage-top { top: max(8px, env(safe-area-inset-top)); left: 10px; right: 10px; gap: 6px; }
  .stage-badge { padding: 5px 9px; max-width: 48%; }
  :root[data-style="nordic"] .stage-badge { padding: 3px; }
  :root[data-style="nordic"] .stage-badge-inner { padding: 4px 7px; gap: 6px; }
  .badge-emblem { width: 22px; height: 22px; }
  .badge-emblem svg { width: 13px; height: 13px; }
  .badge-glint { display: none; }
  .badge-holly svg { width: 18px; height: 15px; }
  .stage-summary { font-size: 12px; }
  .stage-dims { font-size: 10.5px; }
  .stage-tools { gap: 4px; flex-wrap: nowrap; }
  .tool-btn { height: 32px; width: 32px; padding: 0; }
  .tool-btn span { display: none; }

  .step-callout { bottom: 8px; padding: 9px 9px 9px 10px; gap: 8px; border-radius: 14px; width: calc(100% - 16px); }
  .callout-num { width: 28px; height: 28px; font-size: 13px; }
  .callout-title { font-size: 14px; }
  .callout-summary { font-size: 11.5px; -webkit-line-clamp: 2; }
  .callout-body { gap: 9px; }
  .step-callout { flex-wrap: wrap; row-gap: 6px; }
  .callout-body { flex-basis: 100%; }
  .callout-actions { margin-left: auto; gap: 4px; }
  .callout-kicker { font-size: 10px; }
  .pill-btn { height: 28px; padding: 0 10px; font-size: 12px; }
  .pill-icon { width: 28px; padding: 0; }

  .motion-bar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 12px;
    padding: 8px 12px 9px;
    border-bottom: 1px solid var(--line);
  }
  .motion-walk { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 10px; }
  .motion-walk .motion-head { flex-shrink: 0; }
  .walk-stepper { flex: 1; }
  .motion-item { gap: 3px; }
  .motion-head { min-height: 26px; }
  .motion-toggle { font-size: 11.5px; padding: 5px 7px; }
  .motion-val { font-size: 10.5px; }

  .panel { border-left: none; padding: 12px 12px max(24px, env(safe-area-inset-bottom)); gap: 12px; }
  .panel-header h1 { font-size: 20px; }
  .card { padding: 13px; gap: 12px; }
  .tabs { top: -12px; }
}

@media (max-width: 480px) {
  .motion-walk .motion-label { display: none; }
  .orn-tile { padding: 9px 1px 7px; }
  .orn-tile svg { width: 28px; height: 28px; }
  .orn-tile .orn-name { font-size: 10.5px; }
  .prep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .palette-list { grid-template-columns: minmax(0, 1fr); }
  .rec-callout { grid-template-columns: auto minmax(0, 1fr); }
  .rec-apply, .rec-applied { grid-column: 2; justify-self: start; }
  .role-pick { padding-left: 8px; }
  .custom-foot { flex-direction: column; gap: 4px; }
  .guide-toolbar { grid-template-columns: minmax(0, 1fr); }
  .btn-ghost span { display: none; }
}

/* Very short viewports (phone landscape): natural full-page scroll */
@media (max-width: 959px) and (max-height: 520px) {
  .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    grid-template-rows: 280px auto auto;
  }
  .panel { overflow-y: visible; }
  .tabs { position: static; }
}
