/* === TOKENS === */
:root {
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-sunken: #F4F3F9;
  --text: #1A1A2E;
  --text-muted: #5C5C7A;
  --accent:                 #A8438A;   /* orchid magenta */
  --accent-dark:            #86356E;
  --accent-light:           #F6E3EF;
  --accent-secondary:       #2E7F8F;   /* deep cyan */
  --accent-secondary-light: #E0EFF2;
  --warn: #D97706;
  --warn-light: #FDF1E0;
  --ok: #2D7D46;
  --ok-light: #E8F5EC;
  --err: #DC2626;
  --err-light: #FEE8E8;
  --grid-line:              rgba(168, 67, 138, 0.06);
  --border: #E5E3EC;
  --shadow: rgba(40, 30, 90, 0.07);
  --radius: 0.75rem;
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;

  /* light code theme — every code surface uses these (never dark) */
  --code-bg:       #EEF2F5;   /* cool light surface, distinct from the paper --bg */
  --code-bg-soft:  #E1E7EC;   /* tab bar / chips */
  --code-border:   #D3DAE0;
  --code-fg:       #1F2533;   /* near-black code text */
  --code-cm:       #7A8590;   /* comment (grey, italic) */
  --code-kw:       #9C2D6E;   /* keyword (magenta) */
  --code-ty:       #2D6E78;   /* type (teal) */
  --code-fn:       #2F5FA3;   /* function / value name (blue) */
  --code-op:       #B5552A;   /* operator (rust) */
  --code-st:       #3B7A4B;   /* string / literal (green) */
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === LAYOUT === */
.container { max-width: 1040px; margin: 0 auto; padding: 0 1.5rem; }
.wide { max-width: 1040px; }

/* === HEADER === */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
}
header.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px var(--shadow);
}
header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; max-width: 1040px;
}
.wordmark {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 0.95rem; color: var(--text);
}
.wordmark:hover { text-decoration: none; }
.wordmark .mk {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 0.85rem;
}
.wordmark span { opacity: 0.5; font-weight: 400; }
header nav { display: flex; gap: 1.2rem; }
header nav a {
  font-size: 0.85rem; color: var(--text-muted);
  transition: color 0.2s;
}
header nav a:hover { color: var(--accent); text-decoration: none; }
/* scroll progress */
.progress {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  background: var(--accent); width: 0%;
  transition: width 0.1s linear;
}

/* === CHAPTER STRIP === */
.ch-strip {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.ch-strip::-webkit-scrollbar { display: none; }
.ch-strip .container {
  display: flex; align-items: center; gap: 0.4rem;
  padding-top: 0.55rem; padding-bottom: 0.55rem;
  max-width: 1040px;
}
.ch-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.78rem; color: var(--text-muted);
  padding: 0.32rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  transition: all 0.15s ease-out;
  text-decoration: none;
  white-space: nowrap;
}
.ch-pill:hover { color: var(--accent-dark); border-color: var(--accent); text-decoration: none; }
.ch-pill .ch-num {
  font-family: var(--mono); font-weight: 700; font-size: 0.7rem;
  color: var(--accent);
}
.ch-pill .ch-name { font-weight: 500; }
.ch-pill.current {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.ch-pill.current .ch-num { color: rgba(255,255,255,0.75); }
.ch-pill.current:hover { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); }
.ch-divider {
  width: 12px; height: 1px; background: var(--border); flex-shrink: 0;
}
@media (max-width: 767px) {
  .ch-pill .ch-name { display: none; }
  .ch-pill { padding: 0.28rem 0.5rem; }
  .ch-divider { width: 6px; }
}

/* === HERO === */
.hero {
  padding: 4.5rem 0 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
}
.hero::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent-dark);
  background: var(--accent-light);
  padding: 0.35rem 0.8rem; border-radius: 999px;
  margin-bottom: 1.25rem;
  animation: fadeUp 0.6s ease-out both;
}
.hero-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 3rem; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.1;
  margin-bottom: 0.85rem;
  animation: fadeUp 0.6s ease-out 0.08s both;
}
.hero-title em { font-style: italic; color: var(--accent); }
.hero-subtitle {
  font-size: 1.15rem; color: var(--text-muted);
  max-width: 560px; margin: 0 auto 2rem;
  animation: fadeUp 0.6s ease-out 0.16s both;
}
.hero-arrows { animation: fadeUp 0.6s ease-out 0.28s both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === SECTIONS === */
section.lesson { padding: 1rem 0; }
.block { margin: 2.75rem 0; }
h2.sec {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
  scroll-margin-top: 72px;
}
h2.sec .num {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
  color: var(--accent); margin-right: 0.5rem;
  vertical-align: 0.12em;
}
h3.sub { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
p.lead { font-size: 1.05rem; color: var(--text-muted); margin-bottom: 1rem; }
.prose p { margin-bottom: 0.9rem; }
.prose ul { margin: 0.4rem 0 1rem 1.3rem; }
.prose li { margin-bottom: 0.35rem; }

/* inline math-ish */
.m {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--bg-sunken);
  padding: 0.08em 0.38em; border-radius: 4px;
  white-space: nowrap;
}
.m.obj { color: var(--accent-secondary); background: var(--accent-secondary-light); }
.m.mor { color: var(--accent-dark); background: var(--accent-light); }

/* === CALLOUT === */
.callout {
  display: flex; gap: 0.85rem;
  background: var(--accent-light);
  border: 1px solid #e8cfe0;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.callout .ic { font-size: 1.2rem; flex-shrink: 0; line-height: 1.5; }
.callout.warn { background: var(--warn-light); border-color: #f3dcb6; border-left-color: var(--warn); }
.callout strong { color: var(--accent-dark); }
.callout.warn strong { color: var(--warn); }

/* === FIGURE / WIDGET === */
.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px var(--shadow);
}
.widget-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.widget-title {
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 0.45rem;
}
.widget-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.hint { font-size: 0.8rem; color: var(--text-muted); }

svg.diagram { width: 100%; height: auto; display: block; touch-action: none; user-select: none; }
.diagram-wrap { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.5rem; }

/* === BUTTONS / CONTROLS === */
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; align-items: center; }
.btn {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 8px;
  padding: 0.45rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.readout {
  font-family: var(--mono); font-size: 0.85rem;
  color: var(--text-muted); margin-left: auto;
}
select.pick {
  font: inherit; font-family: var(--mono); font-size: 0.85rem;
  padding: 0.3rem 0.5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  cursor: pointer;
}

/* range slider (shared by widgets) */
input[type=range].range {
  -webkit-appearance: none; appearance: none;
  height: 5px; border-radius: 999px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  cursor: pointer; flex: 1 1 140px; min-width: 130px; max-width: 260px;
  vertical-align: middle;
}
input[type=range].range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 3px var(--shadow); cursor: grab;
}
input[type=range].range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 3px var(--shadow); cursor: grab;
}

/* === CODE / LANGUAGE TOGGLE (light theme) === */
.code-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1.5rem 0; }
.code-tabs { display: flex; background: var(--code-bg-soft); border-bottom: 1px solid var(--code-border); }
.code-tab {
  font: inherit; font-size: 0.82rem; font-weight: 500;
  font-family: var(--mono);
  color: var(--text-muted); background: transparent; border: none;
  padding: 0.6rem 1.05rem; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.code-tab:hover { color: var(--text); }
.code-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.code-tab .lang-ic { opacity: 0.9; margin-right: 0.4rem; }
pre.code {
  margin: 0; padding: 1.1rem 1.2rem;
  background: var(--code-bg); color: var(--code-fg);
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.7;
  overflow-x: auto;
}
pre.code .cm { color: var(--code-cm); font-style: italic; } /* comment */
pre.code .kw { color: var(--code-kw); }                     /* keyword */
pre.code .ty { color: var(--code-ty); }                     /* type */
pre.code .fn { color: var(--code-fn); }                     /* function/value name */
pre.code .op { color: var(--code-op); }                     /* operator */
pre.code .st { color: var(--code-st); }                     /* string/literal */
.code-pane { display: none; }
.code-pane.active { display: block; }

/* === QUIZ === */
.quiz-q { margin-bottom: 1.4rem; }
.quiz-q:last-child { margin-bottom: 0; }
.quiz-q .q { font-weight: 600; margin-bottom: 0.6rem; }
.quiz-q .q .qn {
  font-family: var(--mono); color: var(--accent); font-size: 0.85rem; margin-right: 0.4rem;
}
.opt {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 0.92rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.85rem; margin-bottom: 0.5rem;
  cursor: pointer; transition: all 0.12s ease-out;
  display: flex; align-items: center; gap: 0.6rem;
}
.opt:hover:not(.locked) { border-color: var(--accent); background: var(--accent-light); }
.opt .mark { width: 18px; flex-shrink: 0; font-weight: 700; }
.opt.correct { border-color: var(--ok); background: var(--ok-light); color: #1b5e2e; }
.opt.wrong { border-color: var(--err); background: var(--err-light); color: #b91c1c; }
.opt.locked { cursor: default; }
.quiz-fb { font-size: 0.88rem; margin-top: 0.4rem; min-height: 1.2em; color: var(--text-muted); }
.quiz-fb.show.ok { color: var(--ok); }
.quiz-fb.show.no { color: var(--err); }

/* === NEXT / FOOTER === */
.next-card {
  display: flex; align-items: center; gap: 1rem;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light));
  border: 1px solid #e8cfe0; border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin: 2.5rem 0 1rem;
}
.next-card .big { font-size: 1.6rem; }
.next-card .t1 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
.next-card .t2 { font-weight: 600; font-size: 1.05rem; }
.next-card .t3 { font-size: 0.88rem; color: var(--text-muted); }
.next-card .lock { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); }
a.next-card { color: inherit; text-decoration: none; transition: transform 0.2s ease-out, box-shadow 0.2s ease-out; }
a.next-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--shadow); text-decoration: none; }
.next-card .arrow { margin-left: auto; font-size: 1.4rem; color: var(--accent-dark); transition: transform 0.2s ease-out; }
a.next-card:hover .arrow { transform: translateX(4px); }

footer {
  padding: 2.5rem 0; text-align: center;
  font-size: 0.8rem; color: var(--text-muted);
  border-top: 1px solid var(--border); margin-top: 1rem;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === RESPONSIVE === */
@media (max-width: 767px) {
  .hero { padding: 3rem 0 2rem; }
  .hero-title { font-size: 2.1rem; }
  .hero-subtitle { font-size: 1rem; }
  h2.sec { font-size: 1.4rem; }
  header nav a:not(.nav-keep) { display: none; }
  .readout { margin-left: 0; width: 100%; }
}

/* ============================================================
   CH.1 WIDGET STYLES
   ============================================================ */

/* --- Widget 1 · denoise (dn-) --- */
.dn-stage { display: flex; justify-content: center; }
canvas.dn-canvas {
  width: 100%; max-width: 480px; height: auto;
  aspect-ratio: 280 / 200;
  image-rendering: pixelated;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: #222;
  display: block;
}
.dn-slabel { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); }

/* --- Widget 2 · pipeline (pl-) --- */
.pl-node { cursor: pointer; transition: opacity 0.15s; }
.pl-node:hover { opacity: 0.88; }
.pl-cap {
  margin-top: 0.85rem;
  background: var(--accent-light);
  border: 1px solid #e8cfe0;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.92rem;
}
.pl-cap .pl-cap-title {
  font-weight: 700; color: var(--accent-dark);
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.pl-cap .pl-cap-tag {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent-secondary);
  background: var(--accent-secondary-light);
  padding: 0.1rem 0.45rem; border-radius: 999px;
}

/* --- Widget 3 · latents (lt-) --- */
.lt-grids { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 1.5rem; }
.lt-col { text-align: center; flex: 0 1 auto; }
.lt-col svg { display: block; margin: 0 auto; }
.lt-tag {
  font-family: var(--mono); font-size: 0.78rem; margin-top: 0.5rem;
  color: var(--text-muted);
}
.lt-tag strong { color: var(--text); }
.lt-bars { margin-top: 1.1rem; }
.lt-barrow { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.45rem; }
.lt-barlbl { font-family: var(--mono); font-size: 0.74rem; color: var(--text-muted); width: 4.3rem; flex-shrink: 0; text-align: right; }
.lt-bartrack { flex: 1; height: 16px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.lt-barfill { height: 100%; border-radius: 999px; transition: width 0.3s ease-out; }
.lt-barfill.pix { background: var(--accent); }
.lt-barfill.lat { background: var(--accent-secondary); }

/* --- Section 8 · DiffusionBee mapping table --- */
.bee-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.bee-table th, .bee-table td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.bee-table thead th {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); font-weight: 600;
}
.bee-table tbody tr:last-child td { border-bottom: none; }
.bee-table tbody td:first-child {
  font-family: var(--mono); font-weight: 600; color: var(--accent-dark);
  white-space: nowrap;
}
.bee-table tbody td:nth-child(2) { color: var(--accent-secondary); }
@media (max-width: 600px) { .bee-table { font-size: 0.82rem; } .bee-table th, .bee-table td { padding: 0.45rem 0.4rem; } }

/* == ch02 widget styles == */

/* --- Widget · guidance dial (cfg-) --- */
.cfg-stage { display: flex; justify-content: center; }
canvas.cfg-canvas {
  width: 100%; max-width: 360px; height: auto;
  aspect-ratio: 280 / 180;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: #222;
  display: block;
}
.cfg-sliderrow { margin-top: 0.9rem; }
.cfg-range { width: 100%; max-width: none; flex: none; min-width: 0; display: block; }
.cfg-scale { position: relative; height: 1.15rem; margin-top: 0.35rem; }
.cfg-tick {
  position: absolute; transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.62rem; color: var(--text-muted);
  text-align: center;
}
.cfg-tick::before {
  content: ""; display: block; width: 1px; height: 5px;
  background: var(--border); margin: 0 auto 2px;
}

/* --- Widget · X/Y grid explorer (xy-) --- */
.xy-controls { margin-top: 0; margin-bottom: 0.9rem; }
.xy-lock { display: inline-flex; align-items: center; cursor: pointer; }
.xy-lock input { accent-color: var(--accent); cursor: pointer; }
.xy-grid { display: grid; gap: 5px; align-items: stretch; }
.xy-corner {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
  font-family: var(--mono); font-size: 0.58rem; color: var(--text-muted);
  padding: 0 4px 4px 0; text-align: right; line-height: 1.3;
}
.xy-hd {
  font-family: var(--mono); font-size: 0.64rem; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; text-align: center;
  white-space: nowrap;
}
.xy-hd-y { padding-right: 4px; }
.xy-cell {
  position: relative; cursor: pointer; line-height: 0;
  border-radius: 6px; border: 2px solid transparent;
  transition: border-color 0.12s ease-out;
}
.xy-cell canvas {
  width: 100%; height: auto; display: block;
  border-radius: 4px; border: 1px solid var(--border);
}
.xy-cell:hover { border-color: var(--accent); }
.xy-cell.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
@media (max-width: 600px) {
  .xy-corner { font-size: 0.5rem; }
  .xy-hd { font-size: 0.56rem; }
}

/* == ch03 widget styles == */

/* --- Widget 1 · skinny-matrix trick (lr-) --- */
.lr-stats { margin-top: 1rem; }
.lr-barrow { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.lr-barlbl { font-family: var(--mono); font-size: 0.74rem; color: var(--text-muted); width: 4.6rem; flex-shrink: 0; text-align: right; }
.lr-bartrack { flex: 1; height: 16px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.lr-barfill { height: 100%; border-radius: 999px; transition: width 0.25s ease-out; min-width: 2px; }
.lr-barfill.full { background: var(--accent); }
.lr-barfill.lora { background: var(--accent-secondary); }
.lr-num { font-family: var(--mono); font-size: 0.74rem; color: var(--text); width: 5.6rem; flex-shrink: 0; text-align: left; }
.lr-cap {
  margin-top: 0.9rem; font-size: 0.82rem; color: var(--text-muted);
  background: var(--accent-secondary-light);
  border-left: 3px solid var(--accent-secondary);
  border-radius: 0.5rem; padding: 0.55rem 0.8rem;
}
.lr-cap strong { color: var(--accent-secondary); }

/* --- Widget 2 · weight dial (wd-) --- */
.wd-stage { display: flex; justify-content: center; }
canvas.wd-canvas {
  width: 100%; max-width: 420px; height: auto;
  aspect-ratio: 300 / 210;
  border-radius: 0.4rem; border: 1px solid var(--border);
  background: #222; display: block;
}
.wd-controls { margin-top: 0.95rem; }
.wd-sliderrow { display: flex; align-items: center; gap: 0.7rem; }
.wd-range { max-width: none; flex: 1 1 auto; }
.wd-zones {
  position: relative;
  display: flex; gap: 3px; margin: 0.55rem 0 0.2rem;
  font-family: var(--mono); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.wd-zone {
  flex-grow: 0; flex-shrink: 0;
  text-align: center; padding: 0.16rem 0; border-radius: 4px;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.wd-zone.off    { background: #9a9aa6; }
.wd-zone.subtle { background: var(--accent-secondary); }
.wd-zone.good   { background: var(--ok); }
.wd-zone.over   { background: var(--err); }
.wd-tick { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--accent-dark); transform: translateX(-50%); }
.wd-ticklbl {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 3px; font-size: 0.62rem; color: var(--accent-dark); white-space: nowrap;
  letter-spacing: 0; text-transform: none;
}
.wd-controls .readout { display: block; margin-left: 0; margin-top: 1.4rem; }

/* --- Widget 3 · stacking (stk-) --- */
.stk-stage { display: flex; justify-content: center; }
canvas.stk-canvas {
  width: 100%; max-width: 420px; height: auto;
  aspect-ratio: 300 / 210;
  border-radius: 0.4rem; border: 1px solid var(--border);
  background: #222; display: block;
}
.stk-sliders { margin-top: 0.95rem; display: flex; flex-direction: column; gap: 0.55rem; }
.stk-srow { display: flex; align-items: center; gap: 0.7rem; }
.stk-slbl { font-family: var(--mono); font-size: 0.78rem; width: 8.5rem; flex-shrink: 0; }
.stk-slbl.wc { color: var(--accent-secondary); }
.stk-slbl.ink { color: var(--accent-dark); }
.stk-sval { font-family: var(--mono); font-size: 0.78rem; color: var(--text-muted); width: 2.6rem; text-align: right; flex-shrink: 0; }
.stk-meterwrap { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.85rem; }
.stk-mlbl { font-family: var(--mono); font-size: 0.74rem; color: var(--text-muted); width: 4.6rem; flex-shrink: 0; text-align: right; }
.stk-metertrack { position: relative; flex: 1; height: 16px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.stk-meterfill { height: 100%; border-radius: 999px; background: var(--ok); transition: width 0.25s ease-out, background 0.25s ease-out; }
.stk-meterfill.warn { background: var(--err); }
.stk-metermark { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--warn); }

/* == ch04 widget styles == */

/* --- Widget 1 · grade my dataset (ds-) --- */
.ds-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem;
  max-width: 560px; margin: 0 auto;
}
.ds-card {
  position: relative; padding: 0; aspect-ratio: 1 / 1;
  border: 2px solid var(--border); border-radius: 0.5rem;
  overflow: hidden; cursor: pointer; background: var(--bg-sunken);
  transition: border-color 0.12s, opacity 0.15s, filter 0.15s, transform 0.12s;
}
.ds-card svg { display: block; width: 100%; height: 100%; }
.ds-card.on { border-color: var(--accent); }
.ds-card.on:hover { transform: translateY(-1px); }
.ds-card.off { opacity: 0.34; filter: grayscale(0.7); }
.ds-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ds-check {
  position: absolute; top: 5px; right: 5px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 700;
  box-shadow: 0 1px 3px var(--shadow);
}
.ds-card.off .ds-check { background: rgba(30, 20, 40, 0.35); }
.ds-label {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-family: var(--mono); font-size: 0.6rem; color: #fff;
  background: rgba(20, 15, 30, 0.5); padding: 1px 4px;
  text-align: left; letter-spacing: 0.02em;
}
.ds-report { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.ds-badge {
  flex-shrink: 0; width: 66px; height: 66px; border-radius: 14px;
  display: grid; place-items: center;
  font-family: 'Fraunces', Georgia, serif; font-size: 2.2rem; font-weight: 600;
  color: #fff; background: var(--text-muted);
}
.ds-badge.g-a { background: var(--ok); }
.ds-badge.g-b { background: #3f9d5f; }
.ds-badge.g-c { background: var(--warn); }
.ds-badge.g-d { background: #d9622b; }
.ds-badge.g-f { background: var(--err); }
.ds-info { flex: 1; min-width: 220px; }
.ds-metrics {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem;
  font-family: var(--mono); font-size: 0.82rem; color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.ds-metrics b { color: var(--text); }
.ds-flags { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.ds-flags li { padding: 0.22rem 0 0.22rem 1.4rem; position: relative; color: var(--text); }
.ds-flags li::before { content: '⚑'; position: absolute; left: 0; color: var(--warn); }
.ds-flags li.ok::before { content: '✓'; color: var(--ok); }
.ds-advice { margin-top: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }

/* --- Widget 2 · the training run (tr-) --- */
.tr-chartwrap { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.5rem; }
svg.tr-chart { width: 100%; height: auto; display: block; }
.tr-samples { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-top: 0.85rem; }
.tr-tile {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  border-radius: 0.4rem; border: 1px solid var(--border); background: #222;
}
.tr-tile svg { display: block; width: 100%; height: 100%; }
.tr-tile .tr-seedlbl {
  position: absolute; left: 0; bottom: 0;
  font-family: var(--mono); font-size: 0.58rem; color: #fff;
  background: rgba(20, 15, 30, 0.5); padding: 1px 4px;
}
.tr-phase { font-weight: 600; }
.tr-phase.under { color: var(--warn); }
.tr-phase.pocket { color: var(--ok); }
.tr-phase.over { color: var(--err); }

/* --- Widget 3 · your recipe card (rc-) --- */
.rc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.rc-field { display: flex; flex-direction: column; gap: 0.25rem; }
.rc-field.full { grid-column: 1 / -1; }
.rc-field label {
  font-family: var(--mono); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
.rc-input, .rc-field select {
  font: inherit; font-family: var(--mono); font-size: 0.85rem;
  padding: 0.38rem 0.5rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-card); color: var(--text); width: 100%;
}
.rc-textarea {
  font: inherit; font-family: var(--mono); font-size: 0.82rem; line-height: 1.5;
  padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-card); color: var(--text); width: 100%;
  resize: vertical; min-height: 3.4rem;
}
.rc-seedadd { display: flex; gap: 0.4rem; align-items: stretch; }
.rc-seedadd .rc-input { flex: 1; }
.rc-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; }
.rc-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: var(--mono); font-size: 0.76rem;
  background: var(--accent-light); color: var(--accent-dark);
  border: 1px solid #e8cfe0; border-radius: 999px; padding: 0.15rem 0.5rem;
}
.rc-chip button {
  border: none; background: none; color: var(--accent-dark);
  cursor: pointer; font-size: 0.85rem; line-height: 1; padding: 0;
}
.rc-recipe {
  margin: 1rem 0 0; background: var(--code-bg); color: var(--code-fg);
  border: 1px solid var(--code-border); border-radius: var(--radius);
  padding: 1rem 1.1rem; font-family: var(--mono); font-size: 0.82rem;
  line-height: 1.65; overflow-x: auto; white-space: pre;
}
.rc-recipe .k { color: var(--code-kw); }
.rc-recipe .pr { color: var(--code-st); }
.rc-recipe .tw { color: var(--code-op); font-weight: 600; }
@media (max-width: 600px) {
  .rc-grid { grid-template-columns: 1fr; }
}

/* --- finale next-card (series complete) --- */
.next-card.finale { background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light)); }
.next-card.finale .big { font-size: 2.2rem; }
.next-card.finale .t2 { font-family: 'Fraunces', Georgia, serif; font-size: 1.35rem; }

/* == ch05 widget styles == */

/* --- Widget 1 · the strength dial (i2i-) --- */
.i2i-panels { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.9rem; }
.i2i-col { flex: 1 1 200px; max-width: 280px; }
.i2i-plabel {
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 0.4rem; text-align: center;
}
.i2i-frame {
  border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border);
  background: #222; aspect-ratio: 1 / 1;
}
.i2i-frame svg { width: 100%; height: 100%; display: block; }
.i2i-arrow { flex: 0 0 auto; font-size: 1.5rem; color: var(--accent-dark); }
.i2i-zones {
  position: relative; display: flex; gap: 3px; margin: 1rem 0 0.2rem;
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.i2i-zone {
  flex-grow: 0; flex-shrink: 1; flex-basis: 0;
  text-align: center; padding: 0.16rem 0; border-radius: 4px;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.i2i-zone.repaint   { background: var(--ok); }
.i2i-zone.remix     { background: var(--accent-secondary); }
.i2i-zone.rumor     { background: var(--warn); }
.i2i-zone.unrelated { background: var(--err); }
.i2i-tick {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--accent-dark); transform: translateX(-50%);
}
.i2i-sliderrow { margin-top: 0.4rem; }
.i2i-range { width: 100%; max-width: none; flex: none; min-width: 0; display: block; }

/* --- Widget 2 · inpaint the sky (inp-) --- */
.inp-stage { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.5rem; }
.inp-svg {
  width: 100%; height: auto; display: block; aspect-ratio: 240 / 160;
  border-radius: 0.4rem; border: 1px solid var(--border);
  cursor: crosshair; touch-action: none; user-select: none;
}
.inp-cell { transition: fill 0.3s ease-out; }
.inp-presets { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }

/* --- Widget 3 · same bones, different drawing (cn-) --- */
.cn-panels { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 0.7rem; }
.cn-col { flex: 1 1 150px; max-width: 210px; }
.cn-plabel {
  margin-bottom: 0.4rem; min-height: 1.9rem;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); text-align: center;
}
.cn-pick { text-transform: none; letter-spacing: 0; width: 100%; }
.cn-frame {
  border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border);
  background: #222; aspect-ratio: 100 / 130;
}
.cn-frame svg { width: 100%; height: 100%; display: block; }
.cn-wrow { display: flex; align-items: center; gap: 0.7rem; margin-top: 1rem; }
.cn-wlbl { font-family: var(--mono); font-size: 0.78rem; color: var(--text-muted); flex-shrink: 0; }
.cn-range { max-width: none; flex: 1 1 auto; }
@media (max-width: 600px) {
  .cn-col { flex-basis: 30%; }
  .cn-plabel { min-height: 3.2rem; }
}

/* == ch06 widget styles == */

/* --- Widget 1 · the token window (tk-) --- */
.tk-input {
  width: 100%; font-family: var(--mono); font-size: 0.82rem; line-height: 1.55;
  padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); color: var(--text); resize: vertical; min-height: 4.6rem;
}
.tk-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.tk-barwrap { margin: 0.95rem 0 0.2rem; }
.tk-bar { height: 14px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.tk-fill { height: 100%; background: var(--accent-secondary); border-radius: 999px; transition: width 0.2s ease-out, background 0.2s ease-out; }
.tk-fill.over { background: var(--err); }
.tk-barlbls { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.62rem; color: var(--text-muted); margin-top: 0.22rem; }
.tk-chips { display: flex; flex-wrap: wrap; gap: 0.28rem; margin-top: 0.85rem; align-items: center; }
.tk-chip {
  font-family: var(--mono); font-size: 0.74rem; line-height: 1.3;
  padding: 0.12rem 0.45rem; border-radius: 5px;
  background: var(--accent-light); color: var(--accent-dark);
  border: 1px solid #e8cfe0; white-space: nowrap;
}
.tk-chip.two { border-style: dashed; }
.tk-chip .x2 { font-size: 0.55rem; color: var(--accent-secondary); margin-left: 0.1rem; vertical-align: super; }
.tk-chip.cut {
  background: var(--bg-sunken); color: var(--text-muted); border-color: var(--border);
  text-decoration: line-through; opacity: 0.5 !important;
}
.tk-cutmark {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--err); border: 1px dashed var(--err); border-radius: 5px;
  padding: 0.1rem 0.45rem; background: var(--err-light); white-space: nowrap;
}

/* --- Widget 2 · the emphasis dial (em-) --- */
.em-stage { display: flex; justify-content: center; }
canvas.em-canvas {
  width: 100%; max-width: 420px; height: auto; aspect-ratio: 300 / 180;
  border-radius: 0.4rem; border: 1px solid var(--border); background: #222; display: block;
}
.em-prompt {
  font-family: var(--mono); font-size: 0.86rem; color: var(--text-muted);
  text-align: center; margin: 0.85rem 0 0.2rem; word-break: break-word;
}
.em-prompt .em-hl { color: var(--accent-dark); font-weight: 700; background: var(--accent-light); padding: 0.02em 0.3em; border-radius: 4px; }
.em-zones {
  position: relative; display: flex; gap: 3px; margin: 0.85rem 0 0.2rem;
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.em-zone {
  flex-grow: 0; flex-shrink: 1; flex-basis: 0;
  text-align: center; padding: 0.16rem 0; border-radius: 4px;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.em-zone.ignored  { background: #9a9aa6; }
.em-zone.natural  { background: var(--ok); }
.em-zone.dominant { background: var(--warn); }
.em-zone.takeover { background: var(--err); }
.em-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent-dark); transform: translateX(-50%); }
.em-sliderrow { margin-top: 0.4rem; }
.em-range { width: 100%; max-width: none; flex: none; min-width: 0; display: block; }

/* --- Widget 3 · the prompt anatomy builder (pa-) --- */
.pa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem 0.8rem; }
.pa-slot { display: flex; flex-direction: column; gap: 0.22rem; }
.pa-slot label {
  font-family: var(--mono); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
}
.pa-pick { width: 100%; }
.pa-body { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.95rem; align-items: flex-start; }
.pa-preview { flex: 0 0 auto; }
.pa-frame {
  width: 180px; height: 180px; max-width: 46vw; aspect-ratio: 1 / 1;
  border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border); background: #222;
}
.pa-frame svg { width: 100%; height: 100%; display: block; }
.pa-right { flex: 1 1 260px; min-width: 240px; }
.pa-out {
  background: var(--code-bg); color: var(--code-fg);
  border: 1px solid var(--code-border); border-radius: var(--radius);
  padding: 0.8rem 0.9rem; font-family: var(--mono); font-size: 0.82rem; line-height: 1.6;
  word-break: break-word;
}
.pa-out .pa-subj { color: var(--accent-dark); font-weight: 700; }
.pa-orderrow { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.pa-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pa-toggle button {
  font: inherit; font-size: 0.76rem; font-family: var(--mono);
  border: none; background: var(--bg-card); color: var(--text-muted);
  padding: 0.35rem 0.7rem; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.pa-toggle button + button { border-left: 1px solid var(--border); }
.pa-toggle button.on { background: var(--accent); color: #fff; }
.pa-note { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.55rem; }
@media (max-width: 600px) {
  .pa-grid { grid-template-columns: 1fr 1fr; }
}

/* == ch07 widget styles == */

/* --- Widget 1 · identity drift (id-) --- */
.id-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.id-cell {
  border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border);
  background: #222; aspect-ratio: 100 / 120;
}
.id-cell svg { width: 100%; height: 100%; display: block; }
.id-modes {
  display: inline-flex; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden;
}
.id-modes button {
  font: inherit; font-size: 0.82rem; font-weight: 500;
  border: none; border-right: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted);
  padding: 0.42rem 0.7rem; cursor: pointer; transition: all 0.15s ease-out;
}
.id-modes button:last-child { border-right: none; }
.id-modes button:hover:not(.active) { color: var(--accent-dark); background: var(--accent-light); }
.id-modes button.active { background: var(--accent); color: #fff; }
@media (max-width: 560px) {
  .id-modes button { padding: 0.36rem 0.5rem; font-size: 0.72rem; }
}

/* --- Widget 2 · turnaround sheet (ts-) --- */
.ts-sheet {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem;
  background: var(--bg-sunken); padding: 0.5rem; border-radius: 0.5rem;
}
.ts-view { text-align: center; }
.ts-frame {
  border-radius: 0.4rem; overflow: hidden; border: 1px solid var(--border);
  background: #eef1f4; aspect-ratio: 100 / 120;
}
.ts-frame svg { width: 100%; height: 100%; display: block; }
.ts-vlabel {
  font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted); margin-top: 0.28rem;
}
.ts-swatches { display: inline-flex; gap: 0.35rem; align-items: center; }
.ts-swatch {
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  border: 2px solid var(--border); cursor: pointer; transition: box-shadow 0.12s;
}
.ts-swatch.sel { border-color: var(--accent-dark); box-shadow: 0 0 0 2px var(--accent-light); }
.ts-cap {
  margin-top: 0.9rem; font-size: 0.82rem; color: var(--text-muted);
  background: var(--accent-secondary-light); border-left: 3px solid var(--accent-secondary);
  border-radius: 0.5rem; padding: 0.55rem 0.8rem;
}
.ts-cap strong { color: var(--accent-secondary); }
@media (max-width: 520px) {
  .ts-sheet { grid-template-columns: repeat(2, 1fr); }
}

/* --- Widget 3 · assemble a page (cp-) --- */
.cp-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.cp-panel { display: flex; flex-direction: column; gap: 0.4rem; }
.cp-frame {
  position: relative; border-radius: 0.5rem; overflow: hidden;
  border: 2px solid #17141c; background: #222; aspect-ratio: 3 / 4;
}
.cp-svg { position: absolute; inset: 0; }
.cp-svg svg { width: 100%; height: 100%; display: block; }
.cp-bubble {
  position: absolute; top: 6%; right: 6%; width: 42%; max-width: 76px;
  pointer-events: none; opacity: 0; transition: opacity 0.2s ease-out;
}
.cp-bubble.left { right: auto; left: 6%; }
.cp-strip.lettering .cp-bubble { opacity: 1; }
.cp-bubble svg { width: 100%; height: auto; display: block; }
.cp-ctrls { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; }
.cp-ctrls select {
  font: inherit; font-family: var(--mono); font-size: 0.72rem;
  padding: 0.24rem 0.3rem; border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg-card); color: var(--text); cursor: pointer; width: 100%;
}
.cp-toggles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; align-items: center; }
.cp-check {
  margin-top: 0.85rem; font-family: var(--mono); font-size: 0.8rem;
  color: var(--text-muted); line-height: 1.8;
}
.cp-check b { color: var(--ok); }
@media (max-width: 640px) {
  .cp-strip { grid-template-columns: 1fr; max-width: 320px; margin: 0 auto; }
}

/* == ch08 widget styles == */

/* --- Widget 1 · three kinds of bigger (up-) --- */
.up-panels { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 1.1rem; }
.up-col { display: flex; flex-direction: column; align-items: center; }
.up-col.src { flex: 0 0 auto; }
.up-col.out { flex: 1 1 260px; max-width: 340px; }
.up-plabel {
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 0.4rem; text-align: center;
}
.up-frame {
  border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border);
  background: #222; aspect-ratio: 1 / 1; position: relative;
}
.up-frame svg { width: 100%; height: 100%; display: block; }
.up-frame.small { width: 92px; }
.up-frame.big { width: 100%; cursor: crosshair; touch-action: none; }
.up-lens {
  position: absolute; width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid var(--accent); box-shadow: 0 3px 12px var(--shadow);
  overflow: hidden; pointer-events: none; transform: translate(-50%, -50%);
  background: #222; display: none; z-index: 3;
}
.up-lens.on { display: block; }
.up-lens svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.up-switch { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* --- Widget 2 · the two-pass dial (tp-) --- */
.tp-flow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.7rem; }
.tp-col { display: flex; flex-direction: column; align-items: center; }
.tp-col.thumb { flex: 0 0 auto; }
.tp-col.out { flex: 1 1 220px; max-width: 300px; }
.tp-plabel {
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 0.4rem; text-align: center;
}
.tp-frame {
  border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border);
  background: #222; aspect-ratio: 1 / 1; position: relative;
}
.tp-frame svg { width: 100%; height: 100%; display: block; }
.tp-frame.small { width: 84px; }
.tp-arrow { flex: 0 0 auto; font-size: 1.4rem; color: var(--accent-dark); }
.tp-badge {
  position: absolute; top: 6px; left: 6px; font-family: var(--mono);
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #fff; background: var(--err); padding: 0.12rem 0.4rem; border-radius: 4px;
  display: none;
}
.tp-badge.on { display: block; }
.tp-factors { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }
.tp-sliderrow { margin-top: 0.7rem; }
.tp-range { width: 100%; max-width: none; flex: none; min-width: 0; display: block; }
.tp-cost { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.7rem; }
.tp-costlbl { font-family: var(--mono); font-size: 0.72rem; color: var(--text-muted); width: 4rem; flex-shrink: 0; text-align: right; }
.tp-costtrack { flex: 1; height: 14px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.tp-costfill { height: 100%; border-radius: 999px; background: var(--warn); transition: width 0.3s ease-out; }

/* --- Widget 3 · the tile inspector (tl-) --- */
.tl-stage { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.5rem; }
.tl-svg {
  width: 100%; height: auto; display: block; aspect-ratio: 300 / 200;
  border-radius: 0.4rem; border: 1px solid var(--border);
}
.tl-row { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.6rem; }
.tl-lbl { font-family: var(--mono); font-size: 0.76rem; color: var(--text-muted); flex-shrink: 0; width: 6.2rem; text-align: right; }
.tl-range { max-width: none; flex: 1 1 auto; min-width: 0; }
