/* =========================================================================
   KAG Studio - design system
   Warm cinematic near-black canvas · cream editorial ink · orange as accent.
   Type: Instrument Serif (display) · Space Grotesk (UI) · Space Mono (technical)
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* --- warm dark studio (default chrome) --- */
  --canvas:    #131110;
  --canvas-2:  #1a1715;
  --surface:   #201c19;
  --surface-2: #2a2521;
  --line:      rgba(245, 239, 232, 0.10);
  --line-2:    rgba(245, 239, 232, 0.18);
  --ink:       #f5efe8;
  --ink-dim:   #aba49b;
  --ink-faint: #6f685f;

  --accent:      #ff4500;
  --accent-2:    #ff6a33;
  --accent-soft: rgba(255, 69, 0, 0.13);
  --accent-line: rgba(255, 69, 0, 0.40);

  --ok:   #4ec77f;
  --warn: #f0b429;
  --err:  #ff5b5b;

  /* type */
  --display: "Raleway", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;

  /* motion - tuned by Tweaks (--mo: 0..1 multiplier) */
  --mo: 1;
  --t-fast: calc(150ms * var(--mo));
  --t-base: calc(240ms * var(--mo));
  --t-slow: calc(420ms * var(--mo));
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --rail-w: 248px;
  --maxw: 1480px;
}

/* light studio chrome (Tweak) - neutral greys, not warm */
.studio[data-chrome="light"] {
  --canvas:    #e9e9ea;
  --canvas-2:  #f1f1f2;
  --surface:   #fafafa;
  --surface-2: #ffffff;
  --line:      rgba(20, 20, 22, 0.11);
  --line-2:    rgba(20, 20, 22, 0.22);
  --ink:       #18181a;
  --ink-dim:   #5a5a5e;
  --ink-faint: #9a9a9e;
  --accent-soft: rgba(255, 69, 0, 0.10);
}

html, body { height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

#root { height: 100%; }

::selection { background: var(--accent); color: #fff; }

button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
button:focus { outline: none; }
/* Firefox draws a dotted inner border on focused buttons - kill it. */
button::-moz-focus-inner { border: 0; padding: 0; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
a { color: var(--accent); text-underline-offset: 2px; }

/* =========================================================================
   Studio shell
   ========================================================================= */
.studio {
  height: 100%;
  color: var(--ink);
  display: grid;
  grid-template-rows: auto 1fr;
  position: relative;
  background:
    radial-gradient(130% 100% at 80% -20%, rgba(255,69,0,0.10), transparent 60%),
    var(--canvas);
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.1rem 1.8rem;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 0.7rem; flex-shrink: 0; }
.brand svg { height: 17px; width: auto; display: block; }
.brand .kag {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-left: 0.7rem;
  border-left: 1px solid var(--line-2);
  padding-top: 2px;
}

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.actions-group { display: flex; align-items: center; gap: 0.5rem; }
.menu-btn {
  display: none; width: 40px; height: 34px;
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink-dim); place-items: center;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.menu-btn:hover { color: var(--ink); border-color: var(--line-2); }
.mode-switch {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.mode-switch button {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  color: var(--ink-dim);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.mode-switch button.on { background: var(--ink); color: var(--canvas); }
.mode-switch button:not(.on):hover { color: var(--ink); }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-dim);
  transition: border-color var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { border-color: var(--accent-line); color: var(--accent); }

.import-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 34px; padding: 0 0.85rem;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-dim); font-size: 0.78rem; font-weight: 600;
  text-decoration: none;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.import-btn:hover { border-color: var(--accent-line); color: var(--accent); }

.expert-link {
  display: inline-flex; align-items: center; gap: 0.35rem;
  height: 34px; padding: 0 0.9rem;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-dim); font-size: 0.78rem; font-weight: 600;
  text-decoration: none;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.expert-link:hover { border-color: var(--accent-line); color: var(--accent); }
.expert-toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%);
  z-index: 80; background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 0.6rem 1.1rem; font-size: 0.82rem; font-weight: 500;
  box-shadow: 0 12px 32px -12px rgba(0,0,0,0.6);
  animation: chEnter var(--t-base) var(--ease-out);
}

/* ---- progress rail (top stepper) ---- */
.rail {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}
.rail-step {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  color: var(--ink-faint);
  transition: color var(--t-fast) var(--ease), background var(--t-fast);
  white-space: nowrap;
  position: relative;
}
.rail-step .dot {
  width: 22px; height: 22px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: 0.66rem;
  transition: all var(--t-base) var(--ease);
}
.rail-step .nm {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.rail.compact .nm { display: none; }
@media (max-width: 1400px) { .rail .nm { display: none; } }
.rail-step.current { color: var(--ink); }
.rail-step.current .nm { color: var(--ink); }
.rail-step.current .dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rail-step.done { color: var(--ink-dim); }
.rail-step.done .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.rail-step.jumpable { cursor: pointer; }
.rail-step.jumpable:hover { color: var(--ink); }
.rail-step.jumpable:hover .dot { border-color: var(--accent-line); }
.rail-step.locked { cursor: not-allowed; }
.rail-tick {
  flex: 1;
  height: 1px;
  min-width: 6px;
  max-width: 34px;
  background: var(--line);
}
.rail-tick.filled { background: var(--accent-line); }

/* =========================================================================
   Chapter stage - two columns: ask (left) · device (right)
   ========================================================================= */
.stage {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
@media (max-width: 1040px) {
  .stage { grid-template-columns: 1fr; }
}

/* ghost chapter numeral */
.ghost-num {
  position: absolute;
  left: -1.5vw;
  top: -14vh;
  right: auto;
  bottom: auto;
  font-family: var(--display);
  font-size: 44vh;
  font-weight: 800;
  line-height: 0.7;
  color: var(--ink);
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
  user-select: none;
}

/* ---- ask column ---- */
.ask {
  position: relative;
  z-index: 2;
  overflow-y: auto;
  padding: clamp(1.6rem, 4vh, 3.2rem) clamp(1.6rem, 4vw, 4rem) 7rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.ask::-webkit-scrollbar { width: 8px; }
.ask::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.kicker .ch-of { color: var(--ink-faint); }

.ch-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.2rem, 4.4vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.012em;
  margin: 0.5rem 0 1.05rem;
  text-wrap: balance;
}
.ch-lede {
  color: var(--ink-dim);
  font-size: 1.02rem;
  max-width: 46ch;
  margin-bottom: 2.2rem;
  text-wrap: pretty;
}

/* teaching aside */
.teach {
  border-left: 2px solid var(--accent-line);
  padding: 0.1rem 0 0.1rem 1rem;
  margin: 0 0 2rem;
  color: var(--ink-dim);
  font-size: 0.9rem;
  max-width: 50ch;
}
.teach strong { color: var(--ink); font-weight: 600; }
.teach .more {
  display: inline-flex; align-items: center; gap: 0.3rem;
  color: var(--accent); font-weight: 600; font-size: 0.84rem;
  margin-top: 0.5rem;
}
.teach .more svg { transition: transform var(--t-fast); }
.teach.open .more svg { transform: rotate(90deg); }
.teach .docs-link { margin-left: 1rem; }
.teach .docs-link svg { transition: none; }
.teach .extra {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-base) var(--ease);
}
.teach.open .extra { grid-template-rows: 1fr; }
.teach .extra > div { overflow: hidden; }
.teach .extra p { margin-top: 0.7rem; }

/* ---- form fields ---- */
.field { margin-bottom: 1.7rem; }
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 0.55rem;
}
.field-label .opt { color: var(--ink-faint); text-transform: none; letter-spacing: 0; font-weight: 400; }

.text-input, .select-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.95rem;
  font-size: 0.98rem;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.text-input::placeholder { color: var(--ink-faint); }
.text-input:focus, .select-input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.text-input.mono { font-family: var(--mono); font-size: 0.9rem; }

.select-input {
  -webkit-appearance: none; appearance: none;
  padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23aba49b' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.95rem center;
}

/* segmented option cards */
.seg {
  display: grid;
  gap: 0.6rem;
}
.seg.cols-2 { grid-template-columns: 1fr 1fr; }
.seg.cols-3 { grid-template-columns: repeat(3, 1fr); }
.seg.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .seg.cols-3, .seg.cols-4 { grid-template-columns: 1fr 1fr; } }

.opt-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast), transform var(--t-fast);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.opt-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.opt-card .t { font-weight: 600; font-size: 0.92rem; }
.opt-card .s { font-size: 0.76rem; color: var(--ink-dim); }
.opt-card.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.opt-card.on .t { color: var(--ink); }
.opt-card .check {
  position: absolute; top: 0.6rem; right: 0.6rem;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  opacity: 0; transform: scale(0.5);
  transition: all var(--t-fast) var(--ease-out);
}
.opt-card.on .check { opacity: 1; transform: scale(1); }

/* swatches */
.swatch-row { display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast);
  position: relative;
}
.swatch:hover { transform: scale(1.08); }
.swatch:focus { outline: none; }
.swatch::-moz-focus-inner { border: 0; }
.swatch:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--line-2), 0 0 0 2px var(--canvas), 0 0 0 3px var(--ink-dim); }
.swatch.on { border-color: var(--ink); transform: scale(1.08); }
.swatch.none {
  background: var(--surface);
  overflow: hidden;
}
.swatch.none::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 2px; height: 150%;
  background: var(--ink-faint);
  transform: translate(-50%, -50%) rotate(45deg);
  transform-origin: center;
}
.swatch.none.on::after { background: var(--ink-dim); }
/* native colour picker disguised as a swatch */
.swatch-picker {
  position: relative;
  overflow: hidden;
  background: conic-gradient(from 0deg, #ff4500, #ffd000, #4ec77f, #2a6fdb, #7a5ae0, #ff4500);
  display: inline-grid; place-items: center;
  cursor: pointer; padding: 0;
}
.swatch-picker::after {
  content: '+';
  color: #fff; font-weight: 700; font-size: 1rem; line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5); pointer-events: none;
}
.swatch-picker.on { box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--accent); }
.cp-trigger-wrap { display: inline-flex; }

/* ===== custom colour picker popover ===== */
.cp-pop {
  position: fixed; z-index: 200;
  width: 248px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 24px 60px -18px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.3);
  animation: cpIn var(--t-fast) var(--ease-out);
  transform-origin: top center;
}
.cp-pop.cp-top { transform-origin: bottom center; }
@keyframes cpIn { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }

.cp-sv {
  position: relative;
  width: 100%; height: 150px;
  border-radius: 9px;
  cursor: crosshair;
  touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.cp-sv-thumb {
  position: absolute; width: 15px; height: 15px;
  border-radius: 50%; border: 2px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.5);
  pointer-events: none;
}
.cp-hue {
  position: relative; height: 13px; margin-top: 12px;
  border-radius: 999px; cursor: pointer; touch-action: none;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.cp-hue-thumb {
  position: absolute; top: 50%; width: 17px; height: 17px;
  border-radius: 50%; background: #fff;
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.5);
  pointer-events: none;
}
.cp-readout { display: flex; gap: 8px; margin-top: 12px; align-items: stretch; }
.cp-hex-wrap {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 0 8px;
}
.cp-hex-chip { width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2); }
.cp-hex {
  flex: 1; min-width: 0; width: 100%;
  background: none; border: none; outline: none;
  font-family: var(--mono); font-size: 0.84rem; padding: 7px 0;
  text-transform: uppercase;
}
.cp-rgb { display: flex; gap: 5px; }
.cp-ch { display: flex; flex-direction: column; align-items: center; width: 38px; }
.cp-ch input {
  width: 100%; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 2px; outline: none;
  font-family: var(--mono); font-size: 0.8rem;
  transition: border-color var(--t-fast);
}
.cp-ch input:focus { border-color: var(--accent-line); }
.cp-ch label { font-size: 0.6rem; color: var(--ink-faint); margin-top: 3px; letter-spacing: 0.08em; }
.cp-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.cp-preset {
  width: 22px; height: 22px; border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
  transition: transform var(--t-fast) var(--ease-out);
}
.cp-preset:hover { transform: scale(1.14); }
.swatch-picker input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: none; padding: 0; background: none;
}

/* toggle */
.toggle-line {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.65rem 0; cursor: pointer; user-select: none;
}
.toggle-line .lab { font-weight: 600; font-size: 0.92rem; }
.toggle-line .sub { font-size: 0.78rem; color: var(--ink-dim); font-weight: 400; margin-top: 1px; }
.tw {
  width: 50px; height: 28px; flex-shrink: 0;
  border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line-2);
  position: relative; transition: background var(--t-base) var(--ease), border-color var(--t-base);
}
.tw::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink-dim);
  transition: transform var(--t-base) var(--ease-out), background var(--t-base);
}
.toggle-line.on .tw { background: var(--accent); border-color: var(--accent); }
.toggle-line.on .tw::after { transform: translateX(22px); background: #fff; }

/* file drop placeholder */
.drop {
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  padding: 1.1rem;
  display: flex; align-items: center; gap: 0.8rem;
  color: var(--ink-dim); font-size: 0.9rem;
  transition: border-color var(--t-fast), background var(--t-fast);
  cursor: pointer;
}
.drop:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); }
.drop .ic { color: var(--accent); flex-shrink: 0; }
.drop.filled { border-style: solid; border-color: var(--line-2); color: var(--ink); }
.drop .stripe-mini {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  background-image: repeating-linear-gradient(45deg, var(--surface-2) 0 6px, var(--surface) 6px 12px);
}

.hint {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: 0.5rem;
  line-height: 1.5;
  max-width: 68ch;
}
.hint code, .inline-code {
  font-family: var(--mono); font-size: 0.82em;
  background: var(--surface); padding: 0.05em 0.35em; border-radius: 4px;
  color: var(--ink-dim); overflow-wrap: anywhere;
}

/* row helpers */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.inline-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 1.6rem 0; }

/* =========================================================================
   Stage device column
   ========================================================================= */
.stage-device {
  position: relative;
  z-index: 1;
  border-left: 1px solid var(--line);
  background:
    radial-gradient(80% 60% at 50% 30%, rgba(255,255,255,0.018), transparent 70%),
    var(--canvas-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 2rem;
}
@media (max-width: 1040px) {
  /* Guided flow: whole stage scrolls as one - sizeable preview on top that
     you scroll past to reach the full-width form. Nav sticks to the bottom. */
  .stage { display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .stage-device {
    order: -1;
    display: block;
    text-align: center;
    border-left: none; border-top: none;
    border-bottom: 1px solid var(--line);
    min-height: 0; height: auto;
    padding: 1rem 1rem 1.3rem;
    flex: none;
  }
  .stage-device .device-caption { position: static; display: flex; align-items: center; width: 100%; margin-bottom: 0.8rem; }
  .peek-toggle { display: inline-flex; align-items: center; }
  .stage-device .device-fit { transform: none !important; }
  /* portrait: larger, centred */
  .stage-device .device-wrap { margin: 0 auto; zoom: 0.82; }
  /* landscape: fill the width, centred */
  .stage-device .device-wrap:has(.device.tablet) { zoom: 0.74; }
  .stage-device.collapsed .device-wrap { display: none; }
  .ask { flex: none; overflow: visible; padding-bottom: 1.5rem; }
}

/* Intermediate: before the rail crams against the action buttons, drop it
   to its own full-width row (actions stay inline until the phone breakpoint). */
@media (max-width: 1240px) {
  .topbar { flex-wrap: wrap; gap: 0.7rem 1.2rem; }
  .brand { order: 1; }
  .topbar-actions { order: 2; margin-left: auto; }
  .rail {
    order: 3; width: 100%; flex-basis: 100%; flex-grow: 0;
    overflow-x: auto; gap: 0.12rem; padding-bottom: 2px;
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { height: 0; }
  .rail .nm { display: inline; }            /* room on the dedicated row */
  .rail-tick { max-width: 28px; }
}

/* Narrow: rail gets its own row, actions collapse into a menu. */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 0.7rem 1rem; padding: 0.9rem 1.1rem; }
  .brand { order: 1; }
  .topbar-actions { order: 2; margin-left: auto; position: relative; }
  .menu-btn { display: grid; }
  .actions-group {
    display: none; position: absolute; top: calc(100% + 8px); right: 0;
    flex-direction: column; align-items: stretch; gap: 0.25rem;
    background: var(--surface-2); border: 1px solid var(--line-2);
    border-radius: 12px; padding: 0.5rem; min-width: 200px; z-index: 60;
    box-shadow: 0 18px 44px -18px rgba(0,0,0,0.55);
  }
  .actions-group.open { display: flex; animation: chEnter var(--t-fast) var(--ease-out); }
  .actions-group .import-btn, .actions-group .expert-link {
    justify-content: flex-start; height: 40px; border-color: transparent; width: 100%;
  }
  .actions-group .import-btn:hover, .actions-group .expert-link:hover { background: var(--surface); color: var(--ink); }
  .actions-group .icon-btn { width: 100%; height: 40px; border-color: transparent; border-radius: 12px; justify-items: start; padding-left: 0.9rem; }
  .actions-group .icon-btn:hover { background: var(--surface); color: var(--ink); }
  .rail {
    order: 3; width: 100%; flex-basis: 100%;
    overflow-x: auto; gap: 0.1rem; padding-bottom: 2px;
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { height: 0; }
  .rail-step { padding: 0.25rem 0.4rem; }
  .rail .nm { display: none; }                  /* compact: dots only... */
  .rail-step.current .nm { display: inline; }   /* ...show current label for context */
}

/* Phone: adaptive bottom nav. */
@media (max-width: 600px) {
  .stage-nav { gap: 0.5rem; padding: 0.8rem 1rem; }
  .stage-nav .btn { padding: 0.6rem 0.85rem; font-size: 0.84rem; }
  .stage-nav .btn-primary { min-width: 0; max-width: 56vw; overflow: hidden; text-overflow: ellipsis; }
  .stage-nav .skip-review { display: none; }
  .ghost-num { display: none; }
}
.device-caption {
  position: absolute;
  top: 1.2rem; left: 1.4rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex; align-items: center; gap: 0.5rem;
}
.device-caption .live {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 rgba(78,199,127,0.5);
  animation: livepulse 2.4s var(--ease) infinite;
}
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 rgba(78,199,127,0.45); }
  70% { box-shadow: 0 0 0 7px rgba(78,199,127,0); }
  100% { box-shadow: 0 0 0 0 rgba(78,199,127,0); }
}

/* ---- device frame ---- */
.device-fit {
  display: inline-block;
  transform-origin: center;
  transition: transform var(--t-base) var(--ease);
  will-change: transform;
}
.device-wrap {
  transition: width var(--t-slow) var(--ease), height var(--t-slow) var(--ease);
}
.device {
  position: relative;
  background: #5a5a5a;
  border-radius: 38px;
  padding: 9px;
  box-shadow:
    0 1px 0 0.5px rgba(255,255,255,0.12) inset,
    0 40px 80px -30px rgba(0,0,0,0.8),
    0 0 0 1px rgba(0,0,0,0.4);
  transition: width var(--t-slow) var(--ease), height var(--t-slow) var(--ease), border-radius var(--t-slow) var(--ease);
}
.device.tablet { border-radius: 28px; padding: 11px; }
.device-screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 30px;
  overflow: hidden;
  background: #000;
}
.device.tablet .device-screen { border-radius: 19px; }

/* status bar */
.kiosk-statusbar {
  position: absolute; top: 0; left: 0; right: 0;
  height: 26px; z-index: 6;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  font-size: 11px; font-weight: 600;
  pointer-events: none;
}
.kiosk-statusbar .right { display: flex; gap: 5px; align-items: center; }

/* wallpaper layer */
.kiosk-bg {
  position: absolute; inset: 0; z-index: 0;
  transition: background var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease);
  background-size: cover; background-position: center;
}
.kiosk-bg.fade-in { animation: wpfade var(--t-slow) var(--ease); }
@keyframes wpfade { from { transform: scale(1.04); } to { transform: none; } }

/* banner strip */
.kiosk-banner {
  position: absolute; top: 26px; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center;
  padding: 6px 12px; height: 0; overflow: hidden;
  transition: height var(--t-base) var(--ease), padding var(--t-base) var(--ease);
}
.kiosk-banner.show { height: 30px; }
.kiosk-banner .pill {
  font-size: 11px; font-weight: 600;
  max-width: calc(100% - 30px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(0,0,0,0.32); color: #fff;
  backdrop-filter: blur(3px);
}
.kiosk-gear {
  position: absolute; top: 30px; right: 10px; z-index: 7;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.28); color: #fff;
  backdrop-filter: blur(3px);
  opacity: 0; transform: scale(0.6);
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out);
  cursor: pointer;
}
.kiosk-gear.show { opacity: 1; transform: scale(1); }

/* app grid */
.kiosk-grid {
  position: absolute; z-index: 3;
  inset: 0;
  padding: 44px 12px 16px;
  display: grid;
  gap: 4px;
  transition: padding var(--t-base) var(--ease);
}
.kiosk-cell {
  position: relative;
  border-radius: 9px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
}
.kiosk-cell.empty-outline {
  border: 1px dashed rgba(255,255,255,0.14);
}
.kiosk-cell.drop-ok { border: 1px dashed var(--accent); background: var(--accent-soft); }
.kiosk-tile {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  animation: tilein var(--t-base) var(--ease-out);
}
@keyframes tilein { from { transform: scale(0.55); } to { transform: none; } }
.kiosk-icon {
  border-radius: 22%;
  display: grid; place-items: center;
  font-weight: 700; color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  overflow: hidden;
}
.kiosk-icon.folder {
  background: rgba(242,242,242,0.85);
  border-radius: 50%;
  padding: 0;
  display: grid; place-items: center;
}
.folder-mini { display: grid; place-items: center; }
.kiosk-label {
  font-size: 8px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.25;
}

/* autostart countdown dialog */
.kiosk-dialog {
  position: absolute; inset: 0; z-index: 9;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.kiosk-dialog .box {
  background: #242424; color: #fff;
  border-radius: 14px; padding: 20px 16px 18px; width: 78%;
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,0.8);
  animation: popScale var(--t-base) var(--ease-out);
}
@keyframes popScale { from { transform: scale(0.9); } to { transform: none; } }
.as-icon { border-radius: 22%; display: grid; place-items: center; color: #fff; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,0.35); overflow: hidden; }
.as-title { font-size: 13px; font-weight: 700; margin-top: 12px; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.as-count { font-size: 11px; color: #cfcfcf; margin-top: 5px; white-space: nowrap; }
.as-cancel {
  margin-top: 14px; font-size: 11px; font-weight: 600; color: #fff;
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 5px 22px; background: transparent;
}
.kiosk-dialog .cnt {
  font-family: var(--mono); font-size: 30px; font-weight: 700;
  color: var(--accent-2);
}
.kiosk-dialog .msg { font-size: 11px; margin: 6px 0 12px; opacity: 0.85; }
.kiosk-dialog .cancel {
  font-size: 11px; font-weight: 600; color: #fff;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 8px;
  padding: 5px 14px;
}

/* settings popup */
.kiosk-settings {
  position: absolute; top: 56px; right: 10px; z-index: 8;
  background: #1f1f1f; color: #fff;
  border-radius: 12px; padding: 6px; min-width: 120px;
  box-shadow: 0 16px 40px -16px rgba(0,0,0,0.8);
  animation: popin var(--t-fast) var(--ease-out);
  transform-origin: top right;
}
@keyframes popin { from { transform: scale(0.9); } to { transform: none; } }
.kiosk-settings .item {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; padding: 6px 8px; border-radius: 7px;
}
.kiosk-settings .item:hover { background: rgba(255,255,255,0.08); }
.kiosk-settings .item .gd { width: 7px; height: 7px; border-radius: 2px; background: var(--accent); }

/* open folder overlay */
.kiosk-folder-overlay {
  position: absolute; inset: 0; z-index: 9;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(3px);
}
.kiosk-folder-sheet {
  width: 80%; max-width: 220px; border-radius: 24px;
  padding: 16px 16px 18px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.85);
  animation: popScale var(--t-base) var(--ease-out);
}
.kfs-title { font-size: 12px; font-weight: 700; text-align: center; margin-bottom: 12px; }
.kfs-grid { display: grid; gap: 12px 8px; justify-items: center; }
.kfs-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kfs-ic {
  width: 36px; height: 36px; border-radius: 22%;
  display: grid; place-items: center; color: #fff;
  font-size: 17px; font-weight: 700; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.kfs-lab { font-size: 9px; max-width: 50px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* mobile preview peek toggle (hidden on desktop) */
.peek-toggle {
  display: none;
  margin-left: auto;
  font-family: var(--ui);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

/* empty grid hint */
.kiosk-empty {
  position: absolute; inset: 44px 12px 16px; z-index: 2;
  display: grid; place-items: center; text-align: center;
  color: rgba(255,255,255,0.5); font-size: 11px;
  font-family: var(--mono); letter-spacing: 0.05em;
}

/* =========================================================================
   Footer nav
   ========================================================================= */
.stage-nav {
  position: absolute; bottom: 0; left: 0;
  width: 50%;
  z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem clamp(1.6rem, 4vw, 4rem);
  background: linear-gradient(to top, var(--canvas) 60%, transparent);
}
@media (max-width: 1040px) {
  .stage-nav {
    position: sticky; bottom: 0; left: auto;
    order: 1; width: 100%; flex: none;
    background: linear-gradient(to top, var(--canvas) 80%, color-mix(in srgb, var(--canvas) 80%, transparent));
    backdrop-filter: blur(2px);
    border-top: 1px solid var(--line);
  }
}
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 0.9rem; white-space: nowrap;
  padding: 0.7rem 1.3rem; border-radius: 10px;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { color: var(--ink-dim); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-2); }
.btn-text { color: var(--ink-dim); }
.btn-text:hover { color: var(--accent); }
.nav-spacer { flex: 1; }
.skip-review {
  font-size: 0.8rem; font-weight: 600; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 0.35rem;
  transition: color var(--t-fast);
}
.skip-review:hover { color: var(--accent); }

/* chapter transition - transform-only so content is never left invisible */
.ch-enter { animation: chEnter var(--t-base) var(--ease-out); }
@keyframes chEnter {
  from { transform: translateY(22px); }
  to { transform: none; }
}
.stagger > * { animation: chEnter var(--t-slow) var(--ease-out) backwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: calc(45ms * var(--mo)); }
.stagger > *:nth-child(3) { animation-delay: calc(90ms * var(--mo)); }
.stagger > *:nth-child(4) { animation-delay: calc(135ms * var(--mo)); }
.stagger > *:nth-child(5) { animation-delay: calc(180ms * var(--mo)); }
.stagger > *:nth-child(n+6) { animation-delay: calc(220ms * var(--mo)); }

/* =========================================================================
   Review chapter
   ========================================================================= */
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 1.5rem; }
@media (max-width: 560px) { .review-grid { grid-template-columns: 1fr; } }
.review-cell {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 0.85rem 1rem; cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.review-cell:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.review-cell .k {
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 0.3rem;
  display: flex; justify-content: space-between; align-items: center;
}
.review-cell .v { font-size: 0.95rem; font-weight: 600; }
.review-cell .v.mono { font-family: var(--mono); font-weight: 400; font-size: 0.82rem; word-break: break-all; }
.review-cell .edit { opacity: 0; color: var(--accent); transition: opacity var(--t-fast); }
.review-cell:hover .edit { opacity: 1; }

/* build sim */
.build-stage {
  position: absolute; inset: 0; z-index: 40;
  background: var(--canvas);
  display: grid; place-items: center;
  animation: chEnter var(--t-base) var(--ease);
}
.build-inner { width: min(560px, 90vw); text-align: center; }
.build-status {
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-dim);
  display: inline-flex; align-items: center; gap: 0.6rem; margin-bottom: 1.4rem;
}
.build-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.05em;
}
.build-badge.queued { background: rgba(171,164,155,0.14); color: var(--ink-dim); }
.build-badge.building { background: rgba(240,180,41,0.14); color: var(--warn); }
.build-badge.done { background: rgba(78,199,127,0.16); color: var(--ok); }
.build-title {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2.2rem, 5.5vw, 3.4rem); line-height: 1.05; letter-spacing: -0.012em; margin-bottom: 0.7rem;
}
.build-sub { color: var(--ink-dim); margin: 0.2rem 0 2rem; }
.spinner {
  width: 13px; height: 13px; border: 2px solid currentColor;
  border-top-color: transparent; border-radius: 50%;
  display: inline-block; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.build-bar {
  height: 4px; border-radius: 4px; background: var(--surface);
  overflow: hidden; margin: 0 auto 2rem; width: 100%;
}
.build-bar .fill {
  height: 100%; background: var(--accent);
  border-radius: 4px; transition: width var(--t-slow) var(--ease);
}
.build-log {
  font-family: var(--mono); font-size: 0.74rem; color: var(--ink-faint);
  text-align: left; max-width: 420px; margin: 0 auto 2rem;
  min-height: 84px;
}
.build-log div { animation: chEnter var(--t-fast) var(--ease-out); padding: 2px 0; }
.build-log .ok { color: var(--ok); }

/* update code reveal */
.code-card {
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: 16px; padding: 1.4rem 1.5rem;
  text-align: left; margin: 0 auto 1.5rem; max-width: 460px;
  animation: chEnter var(--t-base) var(--ease-out);
}
.code-card .lbl {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.5rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.code-card .code-row { display: flex; gap: 0.5rem; align-items: stretch; }
.code-val {
  flex: 1; min-width: 0; font-family: var(--mono);
  font-size: clamp(0.85rem, 3.4vw, 1.05rem); font-weight: 700;
  background: var(--canvas); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 0.6rem 0.85rem; letter-spacing: 0.04em;
  display: flex; align-items: center;
  /* the 32-char update code is one unbreakable token - let it wrap so it can't
     force the card (and the whole overlay) wider than the viewport */
  word-break: break-all;
}
.code-card .warn-line { font-size: 0.82rem; color: var(--ink-dim); margin-top: 0.6rem; }

.download-row { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; }

/* confetti dot burst */
.burst { position: absolute; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; }

/* =========================================================================
   Classic single-page mode
   ========================================================================= */
.classic {
  position: relative;
  grid-row: 2;
  min-height: 0;
  overflow-y: auto; background: var(--canvas);
  animation: chEnter var(--t-base) var(--ease);
}
.classic-inner { max-width: 680px; margin: 0 auto; padding: 2.4rem 1.5rem 5rem; }
.classic h2 {
  font-family: var(--display); font-weight: 600; font-size: 2.2rem;
  letter-spacing: -0.025em; margin-bottom: 0.3rem;
}
.classic-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 1.4rem 1.5rem; margin-top: 1.1rem;
}
.classic-card > .field-label:first-child { margin-top: 0; }
.classic-sec-title {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.9rem;
}

/* =========================================================================
   Documentation slide-over
   ========================================================================= */
.docs-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}
.docs-scrim.open { opacity: 1; pointer-events: auto; }
.docs-panel {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(620px, 94vw);
  background: var(--canvas-2);
  border-left: 1px solid var(--line-2);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-base) var(--ease-out);
  box-shadow: -30px 0 80px -30px rgba(0,0,0,0.7);
}
.docs-panel.open { transform: none; }
.docs-head {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.docs-title {
  font-family: var(--display); font-weight: 600; font-size: 1.25rem;
  letter-spacing: -0.02em; flex-shrink: 0;
}
.docs-search { flex: 1; padding: 0.5rem 0.8rem; font-size: 0.88rem; }
.docs-close {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px;
  display: grid; place-items: center; color: var(--ink-dim);
  border: 1px solid var(--line);
}
.docs-close:hover { color: var(--ink); border-color: var(--line-2); }
.docs-body-wrap { display: flex; min-height: 0; flex: 1; }
.docs-nav {
  width: 168px; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--line); padding: 0.8rem 0.6rem;
  display: flex; flex-direction: column; gap: 1px;
}
.docs-nav button {
  text-align: left; font-size: 0.8rem; font-weight: 500;
  color: var(--ink-dim); padding: 0.4rem 0.6rem; border-radius: 7px;
  transition: color var(--t-fast), background var(--t-fast);
}
.docs-nav button:hover { color: var(--ink); background: var(--surface); }
@media (max-width: 620px) { .docs-nav { display: none; } }
.docs-body {
  flex: 1; overflow-y: auto; padding: 1.4rem 1.6rem 4rem;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.docs-empty { color: var(--ink-dim); }
.docs-section { margin-bottom: 2rem; scroll-margin-top: 12px; }
.docs-section h3 {
  font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 0.7rem;
}
.docs-section h4 {
  font-size: 0.9rem; font-weight: 700; color: var(--ink);
  margin: 1.1rem 0 0.4rem;
}
.docs-section p, .docs-section li {
  font-size: 0.9rem; color: var(--ink-dim); line-height: 1.6; margin-bottom: 0.5rem;
}
.docs-section strong { color: var(--ink); font-weight: 600; }
.docs-section ul { padding-left: 1.2rem; margin-bottom: 0.6rem; }
.docs-section li { margin-bottom: 0.3rem; }
.docs-section code {
  font-family: var(--mono); font-size: 0.8em;
  background: var(--surface); padding: 0.05em 0.35em; border-radius: 4px; color: var(--ink);
}

/* =========================================================================
   Reduced motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* small screens: hide device caption text crowding */
@media (max-width: 680px) {
  .rail .nm { display: none; }
  .ghost-num { display: none; }
}

/* =========================================================================
   Apps & Folders editor
   ========================================================================= */
.armed-hint {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 9px; padding: 0.55rem 0.8rem; margin-bottom: 0.7rem;
  font-size: 0.85rem; color: var(--ink);
  animation: chEnter var(--t-fast) var(--ease-out);
}
.armed-hint button { margin-left: auto; color: var(--accent); font-weight: 600; font-size: 0.82rem; }

.palette { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.pal-chip {
  position: relative;
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.4rem 0.7rem 0.4rem 0.45rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  transition: border-color var(--t-fast), transform var(--t-fast) var(--ease-out), background var(--t-fast);
  cursor: grab;
}
.pal-chip:hover { border-color: var(--line-2); transform: translateY(-1px); }
.pal-chip:active { cursor: grabbing; }
.pal-chip.armed { border-color: var(--accent); background: var(--accent-soft); }
.pal-chip.placed { opacity: 0.55; }
.pchip-ic {
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center; color: #fff; font-size: 13px; flex-shrink: 0;
}
.app-glyph { display: block; }
.app-glyph [stroke] { vector-effect: non-scaling-stroke; }
.app-mono { font-weight: 700; line-height: 1; }
.pchip-lab { font-size: 0.82rem; font-weight: 600; }
.pchip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.rows-list { display: flex; flex-direction: column; gap: 0.4rem; }
.edit-row {
  display: grid;
  grid-template-columns: 1fr 56px 56px 1fr 32px;
  gap: 0.4rem; align-items: center;
}
.edit-row.slim { grid-template-columns: 1fr 1fr 32px; }
.edit-row.conflict .text-input,
.edit-row.conflict .select-input { border-color: var(--err); box-shadow: 0 0 0 1px rgba(255,91,91,0.35); }
.edit-row .text-input, .edit-row .select-input { padding: 0.5rem 0.6rem; font-size: 0.86rem; }
.select-input.compact { padding: 0.5rem 1.6rem 0.5rem 0.55rem; background-position: right 0.5rem center; font-size: 0.82rem; }
@media (max-width: 560px) {
  .edit-row { grid-template-columns: 1fr 1fr; grid-auto-rows: auto; }
}

.x-btn {
  width: 32px; height: 32px; border-radius: 7px;
  border: 1px solid var(--line); color: var(--ink-faint);
  font-size: 1.1rem; line-height: 1;
  display: grid; place-items: center;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.x-btn:hover { color: var(--err); border-color: var(--err); background: rgba(255,91,91,0.08); }

.add-btn {
  width: 100%; margin-top: 0.5rem;
  border: 1px dashed var(--line-2); border-radius: 10px;
  padding: 0.6rem; color: var(--ink-dim); font-weight: 600; font-size: 0.88rem;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.add-btn:hover:not(:disabled) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); }
.add-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.add-btn.slim { padding: 0.4rem; font-size: 0.8rem; margin-top: 0.35rem; }

.folder-card {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 0.8rem; background: rgba(255,255,255,0.02);
}
.studio[data-chrome="light"] .folder-card { background: rgba(0,0,0,0.02); }
.folder-card.conflict { border-color: var(--err); box-shadow: 0 0 0 1px rgba(255,91,91,0.3); }
.folder-top {
  display: grid; grid-template-columns: 1fr 56px 56px 32px;
  gap: 0.4rem; align-items: center; margin-bottom: 0.6rem;
}
.folder-apps { display: flex; flex-direction: column; gap: 0.35rem; }
.folder-bg { margin-top: 0.7rem; }
.fb-label {
  display: block; font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-dim); margin-bottom: 0.4rem;
}
.fb-label .opt { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-faint); }
.folder-bg .swatch { width: 28px; height: 28px; border-radius: 7px; }
@media (max-width: 560px) { .folder-top { grid-template-columns: 1fr 1fr; } }

/* =========================================================================
   Behavior panels
   ========================================================================= */
.managed-card {
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255,255,255,0.025); padding: 0.5rem 0.95rem 0.85rem;
  margin-bottom: 1rem;
}
.studio[data-chrome="light"] .managed-card { background: rgba(0,0,0,0.025); }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
@media (max-width: 560px) { .panel-grid { grid-template-columns: 1fr; } }
.panel-chip {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 9px;
  font-size: 0.88rem; font-weight: 500; text-align: left;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.panel-chip:hover { border-color: var(--line-2); }
.panel-chip.on { border-color: var(--accent-line); background: var(--accent-soft); }
.pc-box {
  width: 17px; height: 17px; border-radius: 5px; flex-shrink: 0;
  border: 1px solid var(--line-2); display: grid; place-items: center;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.panel-chip.on .pc-box { background: var(--accent); border-color: var(--accent); }

/* admin escape */
.ae-body { animation: chEnter var(--t-base) var(--ease-out); }
.pw-wrap { position: relative; }
.pw-wrap .text-input { padding-right: 3.4rem; }
.pw-eye {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  font-size: 0.74rem; font-weight: 600; color: var(--ink-dim);
  padding: 0.25rem 0.4rem; border-radius: 6px;
  transition: color var(--t-fast), background var(--t-fast);
}
.pw-eye:hover { color: var(--accent); }
.err-hint { color: var(--err); }

/* =========================================================================
   Classic mode layout
   ========================================================================= */
.classic-2col {
  display: grid; grid-template-columns: 1fr 320px; gap: 2.4rem;
  align-items: start; max-width: 1100px;
}
@media (max-width: 900px) { .classic-2col { grid-template-columns: 1fr; } }
.classic-main { min-width: 0; }
.classic-aside { position: sticky; top: 1.5rem; display: flex; flex-direction: column; align-items: center; }
@media (max-width: 900px) { .classic-aside { position: static; margin-top: 1.5rem; } }
.classic-sec-title .cn {
  font-family: var(--display); color: var(--accent); font-weight: 700;
  font-size: 1.3rem; margin-right: 0.35rem; vertical-align: -2px;
}
.classic .kicker { margin-bottom: 0.3rem; }

/* confetti */
@keyframes burst {
  0% { transform: translate(0,0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---- studio port additions ---- */

/* Entrance animations should fire only when the chapter (step) changes, not on
   every click/input/selection. app.js adds .no-anim to the studio root on
   same-step rebuilds, and to the device on live refreshes; these are the only
   entrance-animated descendants that would otherwise replay. */
.no-anim .stagger > *,
.no-anim .kiosk-tile,
.no-anim .ae-body { animation: none !important; }

/* Real Google Play app icon, swapped in over the placeholder glyph. */
.app-real { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* Wallpaper/background cross-fade, played only when the background changes. */
@keyframes bgfade { from { opacity: 0.35; } to { opacity: 1; } }

/* Package typeahead dropdown (sysapps-backed). */
.pkg-typeahead {
  position: fixed; z-index: 200; max-height: 282px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 16px 44px -14px rgba(0,0,0,0.65); padding: 4px;
}
.pkg-row { padding: 0.4rem 0.55rem; border-radius: 7px; cursor: pointer; }
.pkg-row.active { background: var(--accent-soft); }
.pkg-row-main { display: flex; align-items: center; gap: 0.45rem; }
.pkg-row-n { font-size: 0.85rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pkg-row-sys { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; flex: 0 0 auto; }
.pkg-row-p { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pkg-row-d { font-size: 0.64rem; color: var(--ink-faint); }

/* =========================================================================
   Intro / step 0 - warm landing
   ========================================================================= */
/* Intro topbar has no rail; keep the brand hard-left, actions hard-right. */
.topbar.intro-bar .topbar-actions { margin-left: auto; }

.intro {
  position: relative;
  z-index: 2;
  overflow: hidden auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1.8rem, 6vh, 4.5rem) clamp(1.4rem, 5vw, 3rem) 5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.intro::-webkit-scrollbar { width: 8px; }
.intro::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

/* .intro-ghost inherits .ghost-num positioning (top: -14vh, 44vh) so the landing
   numeral sits at the same height as the chapter numerals. */

.intro-body {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 760px;
  animation: chEnter var(--t-base) var(--ease-out);
}
.no-anim .intro-body { animation: none !important; }

.intro-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--accent);
}
.intro-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0.5rem 0 1.1rem;
  text-wrap: balance;
}
.intro-lede {
  color: var(--ink-dim);
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  max-width: 56ch;
  text-wrap: pretty;
}
.intro-sub { color: var(--ink-faint); font-size: 0.9rem; margin-top: 0.6rem; }

.intro-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 2rem 0 0.5rem;
}
.intro-start { padding: 0.85rem 1.6rem; font-size: 0.98rem; }

.intro-section { margin-top: 2.6rem; }
.intro-sec-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 1rem;
}

.intro-journey {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.4rem;
}
@media (max-width: 620px) { .intro-journey { grid-template-columns: 1fr; } }
.intro-jstep {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.intro-jnum {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  flex: 0 0 1.6rem;
}
.intro-jtext { display: flex; flex-direction: column; }
.intro-jname { font-weight: 600; font-size: 0.95rem; }
.intro-jdesc { color: var(--ink-dim); font-size: 0.82rem; }

.intro-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
@media (max-width: 560px) { .intro-notes { grid-template-columns: 1fr; } }
.intro-note {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.intro-note strong { font-weight: 600; font-size: 0.92rem; }
.intro-note span { color: var(--ink-dim); font-size: 0.84rem; }

/* brand doubles as a "home" control once you're past the landing */
.brand-home { cursor: pointer; }
.brand-home:hover .kag { color: var(--ink); }

