:root {
  --ink: #1c1915;
  --muted: #6a6357;
  --paper: #f4f0e6;
  --card: #fffdf8;
  --line: #e2d9c8;
  --accent: #0f5f5c;
  --accent-soft: #dcefed;
  --glow: #f5b400;
  --doc: #1c6b38;   --doc-bg: #e5f4ea;
  --std: #1d4e89;   --std-bg: #e7f0fa;
  --prec: #8a5a00;  --prec-bg: #fbf3df;
  --kern: #3d4650;  --kern-bg: #eceff2;
  --hold: #8d2a2a;  --hold-bg: #fdecec;
  --trip: #c0392b;
  --sheet-bg: #ffffff;
  --shadow: 0 1px 3px rgba(40, 30, 10, 0.08);
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ece6da; --muted: #a39b8c; --paper: #15130f; --card: #1f1c17; --line: #3a342a;
    --accent: #4fb3ac; --accent-soft: #1d3634; --glow: #ffcf4d;
    --doc: #7fd39a; --doc-bg: #1b3324; --std: #8db8f0; --std-bg: #1a2a40;
    --prec: #f0c060; --prec-bg: #3a2e12; --kern: #c2c9d1; --kern-bg: #2a2f35;
    --hold: #f08c8c; --hold-bg: #3e1d1d; --trip: #ff6b5b; --sheet-bg: #f8f6f1;
  }
}
:root[data-theme="dark"] {
  --ink: #ece6da; --muted: #a39b8c; --paper: #15130f; --card: #1f1c17; --line: #3a342a;
  --accent: #4fb3ac; --accent-soft: #1d3634; --glow: #ffcf4d;
  --doc: #7fd39a; --doc-bg: #1b3324; --std: #8db8f0; --std-bg: #1a2a40;
  --prec: #f0c060; --prec-bg: #3a2e12; --kern: #c2c9d1; --kern-bg: #2a2f35;
  --hold: #f08c8c; --hold-bg: #3e1d1d; --trip: #ff6b5b; --sheet-bg: #f8f6f1;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { min-height: 100vh; display: flex; flex-direction: column; }
button, select, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.st-muted { color: var(--muted); font-size: 0.85rem; }

.st-top {
  display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: center;
  padding: 12px 22px; background: var(--card); border-bottom: 1px solid var(--line);
}
.st-mark {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; text-decoration: none;
}
.st-title h1 { font-size: 1.1rem; font-weight: 650; }
.st-pick { display: flex; flex-direction: column; font-size: 0.75rem; color: var(--muted); gap: 2px; }
.st-pick select, .st-pick input {
  min-width: 190px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); font-size: 0.95rem;
}
.st-chip {
  margin-left: auto; padding: 4px 10px; border-radius: 999px; font-size: 0.8rem;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.st-ghost {
  border: 1px solid var(--line); background: transparent; border-radius: 6px;
  width: 36px; height: 36px; cursor: pointer;
}

/* progress: the equipment coming alive */
.st-alive {
  display: flex; align-items: center; gap: 16px; padding: 10px 22px;
  background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto;
}
.st-alive svg { flex: none; }
.st-alive .st-count { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.alive-part { transition: fill 0.5s ease, stroke 0.5s ease, opacity 0.5s ease; }
.alive-dot { cursor: pointer; transition: transform 0.2s ease; }
.alive-dot:hover { transform: scale(1.12); }

.st-main {
  flex: 1; display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; gap: 18px;
  padding: 18px 22px; align-items: start;
}
@media (max-width: 980px) { .st-main { grid-template-columns: 1fr; } }

/* the question */
.st-ask {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 22px; box-shadow: var(--shadow); min-height: 420px;
  display: flex; flex-direction: column; gap: 14px;
}
.q-step { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.q-ask { font-size: 1.45rem; line-height: 1.3; font-weight: 600; }
.q-why { font-size: 0.9rem; color: var(--muted); }
.q-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.q-tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; align-items: stretch;
  border: 2px solid var(--line); border-radius: 10px; background: var(--paper);
  padding: 10px; cursor: pointer; text-align: left; transition: border-color 0.15s, transform 0.15s;
}
.q-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.q-tile.on { border-color: var(--accent); background: var(--accent-soft); }
.q-tile .q-key {
  position: absolute; top: 6px; right: 8px; font-size: 0.7rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
}
.q-tile .q-label { font-weight: 650; font-size: 1rem; }
.q-tile .q-draws { font-size: 0.75rem; color: var(--muted); }
.q-tile svg { width: 100%; height: 64px; }
.sk-bubble { fill: var(--card); stroke: var(--ink); stroke-width: 1.3; }
.sk-text { font-size: 9px; fill: var(--ink); font-family: inherit; text-anchor: middle; dominant-baseline: central; }
.sk-line { stroke: var(--muted); stroke-width: 1; fill: none; }
.sk-dash { stroke: var(--muted); stroke-width: 1; fill: none; stroke-dasharray: 3 3; }
.sk-voter { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.3; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 0.68rem; padding: 2px 7px; border-radius: 999px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.document { background: var(--doc-bg); color: var(--doc); }
.chip.standard { background: var(--std-bg); color: var(--std); }
.chip.precedent, .chip.practice, .chip.inferred { background: var(--prec-bg); color: var(--prec); }
.chip.pattern, .chip.engineer, .chip.convention { background: var(--kern-bg); color: var(--kern); }
.chip.hold { background: var(--hold-bg); color: var(--hold); }

.q-more { border-top: 1px dashed var(--line); padding-top: 10px; }
.q-more summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.q-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.q-detail .q-dlabel { min-width: 150px; font-size: 0.85rem; color: var(--muted); }
.pill {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 3px 10px; font-size: 0.82rem; cursor: pointer;
}
.pill.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.q-cond { font-size: 0.8rem; color: var(--muted); }
.q-nav { margin-top: auto; display: flex; gap: 10px; align-items: center; }
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; padding: 8px 16px; cursor: pointer; font-weight: 600;
}
a.btn { text-decoration: none; display: inline-block; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.q-always { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; }
.q-always-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: var(--paper); }
.q-always-row .grow { flex: 1; font-size: 0.88rem; }
.q-needs { font-size: 0.82rem; background: var(--hold-bg); color: var(--hold); padding: 8px 10px; border-radius: 8px; }

/* the drawing */
.st-draw {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 12px;
}
.st-draw-head { display: flex; align-items: baseline; gap: 12px; }
.st-draw-head h2 { font-size: 1rem; }
.st-sheet {
  position: relative; min-height: 360px; border-radius: 8px; overflow: hidden;
  background: var(--sheet-bg); border: 1px solid var(--line); display: grid; place-items: center;
}
.st-sheet svg.drawn { width: 100%; height: auto; max-height: 64vh; display: block; }
.st-sheet::after {
  content: "DRAFT — indicative, not a plant"; position: absolute; right: 10px; bottom: 8px;
  font-size: 0.72rem; color: #8d2a2a; background: rgba(255, 255, 255, 0.85);
  padding: 2px 8px; border-radius: 4px; pointer-events: none;
}
.st-sheet.busy::before {
  content: "drawing…"; position: absolute; left: 10px; top: 8px; font-size: 0.8rem;
  color: var(--accent); animation: pulse 1s infinite alternate;
}
@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }
.glow-new { fill: none; stroke: var(--glow); stroke-width: 5; rx: 8; animation: glow 2.4s ease-out 2; }
@keyframes glow { 0% { stroke-opacity: 0; } 20% { stroke-opacity: 1; } 100% { stroke-opacity: 0.15; } }
.st-consequence { font-size: 0.92rem; min-height: 1.4em; }
.st-consequence .gone { text-decoration: line-through; color: var(--muted); animation: fade 2.5s forwards; }
@keyframes fade { from { opacity: 1; } to { opacity: 0.35; } }

/* the simulator */
.st-sim { border-top: 1px solid var(--line); padding-top: 12px; display: grid; grid-template-columns: 120px 1fr; gap: 16px; }
.st-sim h3 { grid-column: 1 / -1; font-size: 0.95rem; }
.sim-gauge { position: relative; height: 230px; border: 2px solid var(--ink); border-radius: 14px 14px 10px 10px; overflow: hidden; background: var(--paper); }
.sim-fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(var(--accent), var(--accent-soft)); transition: height 0.12s; }
.sim-band {
  position: absolute; left: 0; right: 0;
  background: repeating-linear-gradient(45deg, rgba(141, 42, 42, 0.28) 0 6px, transparent 6px 12px);
  border-top: 1px dashed var(--hold); border-bottom: 1px dashed var(--hold);
}
.sim-band span { position: absolute; right: 4px; top: 2px; font-size: 0.62rem; color: var(--hold); font-weight: 700; }
.sim-range { width: 100%; margin-top: 8px; accent-color: var(--accent); }
.sim-flow { display: flex; flex-direction: column; gap: 10px; }
.sim-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sim-row .lbl { width: 92px; font-size: 0.75rem; color: var(--muted); }
.sim-node {
  border: 2px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 0.8rem;
  background: var(--paper); transition: all 0.2s; cursor: default;
}
.sim-node.leg { cursor: pointer; }
.sim-node.hot { border-color: var(--trip); color: var(--trip); box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15); }
.sim-node.failed { text-decoration: line-through; opacity: 0.5; border-style: dashed; }
.sim-node.tripped { background: var(--trip); color: #fff; border-color: var(--trip); }
.sim-node.hold { border-style: dashed; color: var(--hold); background: var(--hold-bg); }
.sim-valve { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.sim-valve svg { width: 30px; height: 22px; }
.sim-valve .vbody { fill: var(--card); stroke: var(--ink); stroke-width: 1.4; transition: fill 0.4s; }
.sim-valve.acted .vbody { fill: var(--trip); }
.sim-note { font-size: 0.78rem; color: var(--muted); }

.st-keys {
  display: flex; flex-wrap: wrap; gap: 16px; padding: 8px 22px 14px; justify-content: center;
}
kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 5px; font-size: 0.75rem; background: var(--card);
}
.done-card { display: flex; flex-direction: column; gap: 12px; }
.done-card .big { font-size: 1.35rem; font-weight: 650; }
.st-error { color: var(--hold); background: var(--hold-bg); padding: 8px 10px; border-radius: 8px; font-size: 0.85rem; white-space: pre-wrap; }

/* JL-198 T11c: the whole plant — items, confidence meter, data-needs report */
.st-ghost.wide { width: auto; padding: 0 12px; }
.meter { display: flex; height: 18px; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.meter span { display: block; height: 100%; transition: width 0.6s ease; }
.meter .m-stated { background: var(--doc); }
.meter .m-suggested { background: var(--kern); opacity: 0.55; }
.meter .m-hold { background: repeating-linear-gradient(45deg, var(--hold) 0 5px, transparent 5px 10px); }
.meter-key { display: flex; gap: 14px; font-size: 0.78rem; color: var(--muted); flex-wrap: wrap; }
.items { display: flex; flex-direction: column; gap: 6px; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--paper); border-radius: 8px; }
.item-row .grow { flex: 1; }
.needs { display: flex; flex-direction: column; gap: 8px; }
.need { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.need .need-head { display: flex; gap: 8px; align-items: baseline; }
.need .need-n { font-weight: 700; color: var(--accent); min-width: 34px; }
.need .tier { font-size: 0.7rem; padding: 1px 6px; border-radius: 999px; background: var(--kern-bg); color: var(--kern); }
.need .tier.required { background: var(--hold-bg); color: var(--hold); }
.need ul { margin: 4px 0 0 0; padding-left: 18px; font-size: 0.82rem; color: var(--muted); }

/* JL-210: the studio signs a showcase visitor in itself. */
.st-signin { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin-top: 12px; }
.st-signin input { font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line, #ccc); background: var(--card, #fff); color: inherit; }
.st-signin button { font: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer; }

/* JL-210: topics the library cannot draw yet — a quiet, collapsed note on the last screen. */
.q-later { margin: 12px 0; color: var(--muted, #888); font-size: 0.92em; }
.q-later summary { cursor: pointer; }
.q-later ul { margin: 6px 0 0 18px; padding: 0; columns: 2; }
