:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --paper-2: #f8f5ee;
  --ink: #1f1c24;
  --ink-2: #4a4652;
  --muted: #8a8590;
  --line: #e2ddd2;
  --line-2: #cfc8ba;
  --accent: #e2553b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3dc;
  --blue: #3a7bd5;
  --green: #2f9e6e;
  --amber: #e0a23a;
  --red: #d2453a;
  --ocean: #d9e7ee;
  --ocean-dot: #c9dce6;
  --land: #ede5d3;
  --land-dim: #e4ddce;
  --border-geo: #b8ad96;
  --hover: #f3c86b;
  --land-sel: #f3d2c6;
  --shadow: 3px 3px 0 var(--ink);
  --px-font: "Pixelify Sans", ui-monospace, monospace;
  --num-font: "Silkscreen", ui-monospace, monospace;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17151b; --paper: #211e26; --paper-2: #1b1920; --ink: #f2eee6; --ink-2: #c9c3cf; --muted: #8d8796;
    --line: #34303b; --line-2: #45404d; --accent-soft: #3a2420; --ocean: #1c2a33; --ocean-dot: #22333d;
    --land: #3a3542; --land-dim: #2c2833; --border-geo: #5b5466; --hover: #b8913e; --land-sel: #6a3d38; --shadow: 3px 3px 0 #000;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17151b; --paper: #211e26; --paper-2: #1b1920; --ink: #f2eee6; --ink-2: #c9c3cf; --muted: #8d8796;
  --line: #34303b; --line-2: #45404d; --accent-soft: #3a2420; --ocean: #1c2a33; --ocean-dot: #22333d;
  --land: #3a3542; --land-dim: #2c2833; --border-geo: #5b5466; --hover: #b8913e; --land-sel: #6a3d38; --shadow: 3px 3px 0 #000;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .px { font-family: var(--px-font); font-weight: 600; letter-spacing: 0.01em; }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
a { color: var(--blue); }
code { background: var(--paper-2); padding: 1px 5px; border: 1px solid var(--line); font-size: 12px; }
small { font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.lede { color: var(--ink-2); max-width: 760px; margin: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-between.wrap { flex-wrap: wrap; align-items: flex-start; }
.lbl { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.empty { color: var(--muted); font-size: 13px; margin: 4px 0; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--paper); border-bottom: 2px solid var(--ink); }
.brand { display: flex; align-items: center; gap: 8px; }
.logo-img { width: 28px; height: 28px; object-fit: cover; border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.logo-px { width: 18px; height: 18px; background: var(--accent); box-shadow: inset 0 0 0 4px var(--accent), inset 0 0 0 9px #fff; image-rendering: pixelated; }
.brand-name { font-family: var(--px-font); font-weight: 700; font-size: 20px; letter-spacing: 0.06em; }
.brand-sub { font-family: var(--px-font); color: var(--accent); font-size: 18px; }
.project-name { flex: 1; max-width: 420px; border: 1px solid transparent; background: transparent; font: 600 15px var(--font); color: var(--ink); padding: 6px 8px; }
.project-name:hover, .project-name:focus { border-color: var(--line-2); background: var(--paper-2); outline: none; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.badge { font: 600 11px var(--font); padding: 4px 8px; border: 1.5px solid var(--ink); background: var(--paper-2); white-space: nowrap; }
.badge.live { background: #dff3e8; border-color: var(--green); color: #1d6b47; }
.user-chip { display: flex; align-items: center; gap: 8px; font: 500 13px var(--font); white-space: nowrap; }
.user-chip img { width: 24px; height: 24px; border: 1.5px solid var(--ink); image-rendering: pixelated; background: var(--paper-2); }
.user-chip img:not([src]) { display: none; }
@media (max-width: 900px) { .user-chip > span { display: none; } }
.badge.mock { background: #fff1d6; border-color: var(--amber); color: #8a5a10; }
.banner { background: #fff1d6; color: #6b4a10; border-bottom: 1.5px solid var(--amber); padding: 8px 20px; font-size: 13px; }

/* ---------- buttons & inputs ---------- */
.btn { font: 600 13px var(--font); color: var(--ink); background: var(--paper); border: 1.5px solid var(--ink); padding: 8px 14px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); transition: transform .05s, box-shadow .05s; white-space: nowrap; }
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: 2px 2px 0 var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { box-shadow: none; border-color: transparent; background: transparent; }
.btn.ghost:hover { border-color: var(--line-2); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.icon { width: 30px; padding: 5px 0; text-align: center; }
.btn.danger { color: var(--red); }
input, select, textarea { font: 14px var(--font); color: var(--ink); background: var(--paper); border: 1.5px solid var(--line-2); padding: 7px 9px; width: 100%; border-radius: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 2px 2px 0 var(--accent-soft); }
textarea { resize: vertical; min-height: 64px; }
input[type=range] { padding: 0; border: none; accent-color: var(--accent); background: transparent; box-shadow: none; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: calc(100vh - 54px); }
.stepper { position: sticky; top: 54px; align-self: start; height: calc(100vh - 54px); display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; border-right: 1.5px solid var(--line); background: var(--paper-2); }
.stepper button { display: flex; gap: 10px; align-items: center; text-align: left; padding: 9px 10px; background: transparent; border: 1.5px solid transparent; cursor: pointer; color: var(--ink); font: inherit; }
.stepper button i { font-style: normal; font-family: var(--px-font); width: 26px; height: 26px; display: grid; place-items: center; border: 1.5px solid var(--ink); background: var(--paper); font-size: 14px; flex: none; }
.stepper button b { display: block; font-size: 14px; }
.stepper button small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.stepper button:hover { background: var(--paper); }
.stepper button.active { background: var(--paper); border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.stepper button.active i { background: var(--accent); color: #fff; }
.stepper button.done i { background: var(--ink); color: var(--paper); }
.stepper button:disabled { opacity: .45; cursor: not-allowed; }
.stepper-foot { margin-top: auto; }
.how { font-size: 12px; color: var(--ink-2); border-top: 1.5px dashed var(--line-2); padding-top: 12px; }
.how p { margin: 4px 0 0; }
main { padding: 24px 28px 60px; min-width: 0; }
.step-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
.head-actions { display: flex; gap: 10px; }
.card { background: var(--paper); border: 1.5px solid var(--line-2); padding: 14px 16px; }
.card.tip { font-size: 13px; color: var(--ink-2); background: var(--paper-2); border-style: dashed; }
.empty-state { text-align: center; padding: 48px; }

/* ---------- market ---------- */
.market-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.market-side { display: flex; flex-direction: column; gap: 12px; }
.map-card { padding: 0; border: 2px solid var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.map-wrap { position: relative; height: min(68vh, 660px); min-height: 400px; background: var(--ocean); cursor: grab; overflow: hidden; outline: none; user-select: none; -webkit-user-select: none; }
.map-wrap:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }
.map-wrap.dragging { cursor: grabbing; }
#map { display: block; image-rendering: pixelated; will-change: transform; }

/* crisp labels over the pixel art */
.map-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.map-label { position: absolute; left: 0; top: 0; white-space: nowrap; font: 500 11px/1 var(--px-font); color: var(--ink-2); letter-spacing: .02em;
  text-shadow: 1px 0 var(--land), -1px 0 var(--land), 0 1px var(--land), 0 -1px var(--land), 0 0 4px var(--land); will-change: transform; }
.map-label.lv0 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); }
.map-label.ctx { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  text-shadow: 1px 0 var(--land-dim), -1px 0 var(--land-dim), 0 1px var(--land-dim), 0 -1px var(--land-dim); }
.map-label.sel { color: #fff; font-weight: 700; font-size: 12px;
  text-shadow: 1px 0 #7a2a1a, -1px 0 #7a2a1a, 0 1px #7a2a1a, 0 -1px #7a2a1a, 1px 1px #7a2a1a; }

/* floating controls */
.map-crumbs { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; align-items: center; gap: 2px; max-width: calc(100% - 420px);
  background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); padding: 3px 4px; font: 600 13px var(--font); overflow-x: auto; white-space: nowrap; }
.map-crumbs button { background: none; border: none; padding: 4px 7px; font: inherit; color: var(--blue); cursor: pointer; }
.map-crumbs button:hover { background: var(--paper-2); }
.map-crumbs button.here { color: var(--ink); font-family: var(--px-font); font-size: 14px; }
.map-crumbs .sep { color: var(--muted); }

.map-search { position: absolute; top: 12px; right: 12px; z-index: 4; width: min(380px, calc(100% - 24px)); }
.map-search input { width: 100%; padding: 10px 12px 10px 36px; font: 500 14px var(--font); color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); outline: none; border-radius: 0; }
.map-search input:focus { box-shadow: 3px 3px 0 var(--accent); }
.map-search-ico { position: absolute; left: 12px; top: 13px; width: 14px; height: 14px; pointer-events: none;
  background:
    linear-gradient(var(--ink), var(--ink)) 3px 0 / 6px 2px no-repeat, linear-gradient(var(--ink), var(--ink)) 3px 8px / 6px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 1px 2px / 2px 6px no-repeat, linear-gradient(var(--ink), var(--ink)) 9px 2px / 2px 6px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 10px 10px / 2px 2px no-repeat, linear-gradient(var(--ink), var(--ink)) 12px 12px / 2px 2px no-repeat; }
.search-results { margin-top: 6px; max-height: min(360px, 46vh); overflow: auto; background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 4px; }
.search-results button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: none; border-left: 3px solid transparent;
  background: none; font: inherit; color: var(--ink); cursor: pointer; }
.search-results button > span:not(.on) { flex: 1; min-width: 0; }
.search-results button b { font-weight: 600; }
.search-results button em { color: var(--muted); font-style: normal; font-size: 12px; }
.search-results button small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results button:hover, .search-results button.active { background: var(--paper-2); border-left-color: var(--accent); }
.search-results .on { color: var(--accent); font-weight: 700; }
.search-results .empty { padding: 10px; display: flex; gap: 8px; align-items: center; }
.search-results .empty.small { padding: 6px 10px; font-size: 12px; }
.ty { width: 12px; height: 12px; flex: none; border: 1.5px solid var(--ink); }
.ty0 { background: var(--ink); } .ty1 { background: var(--blue); } .ty2 { background: var(--green); border-radius: 50%; }

.map-ctrl { position: absolute; right: 12px; bottom: 12px; z-index: 3; display: flex; flex-direction: column; border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); background: var(--paper); }
.map-ctrl button { width: 38px; height: 38px; border: none; background: var(--paper); color: var(--ink); font: 700 18px var(--font); cursor: pointer; }
.map-ctrl button + button { border-top: 1.5px solid var(--line-2); }
.map-ctrl button:hover { background: var(--hover); }
.map-ctrl button:active { background: var(--accent); color: #fff; }

.map-explore { position: absolute; left: 50%; bottom: 16px; z-index: 3; transform: translateX(-50%); padding: 10px 16px; font-size: 14px; animation: pop-in .18s ease-out; }
.map-explore:active { transform: translate(calc(-50% + 2px), 2px); }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.map-hint { position: absolute; left: 12px; bottom: 12px; z-index: 2; max-width: calc(100% - 90px); background: rgba(31, 28, 36, .86); color: #fff; padding: 7px 11px;
  font-size: 12px; line-height: 1.4; pointer-events: none; transition: opacity .6s, transform .6s; }
.map-hint b { color: var(--hover); font-weight: 600; }
.map-hint.gone { opacity: 0; transform: translateY(6px); }
.map-explore:not(.hidden) ~ .map-hint { opacity: 0; }

.map-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--paper); padding: 7px 10px; font-size: 12px; line-height: 1.4; max-width: 240px; transform: translate(14px, 14px); box-shadow: 3px 3px 0 rgba(0, 0, 0, .25); }
.map-tip b { font-family: var(--px-font); font-size: 15px; display: block; }
.map-tip .tip-act { opacity: .7; }
.map-loading { position: absolute; left: 50%; top: 64px; z-index: 4; transform: translateX(-50%); background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); padding: 7px 13px; font-size: 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; }

.map-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 7px 12px; font-size: 11px; color: var(--muted); border-top: 1.5px solid var(--line); }
.map-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.map-legend i { width: 10px; height: 10px; border: 1px solid var(--ink); display: inline-block; margin-left: 6px; }
.map-legend i:first-child { margin-left: 0; }
.lg-sel { background: var(--accent); } .lg-in { background: var(--land-sel); } .lg-hover { background: var(--hover); }

@media (max-width: 760px) {
  .map-search { left: 12px; width: auto; }
  .map-crumbs { top: 62px; max-width: calc(100% - 24px); }
  .map-loading { top: 104px; }
  .map-hint { display: none; }
}
.sel-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1.5px solid var(--ink); background: var(--paper-2); }
.sel-item .sw { width: 12px; height: 12px; background: var(--accent); flex: none; }
.sel-item div, .sel-item .sel-go { flex: 1; min-width: 0; }
.sel-item .sel-go { text-align: left; padding: 0; font: inherit; color: var(--ink); }
.sel-item .sel-go:hover b { text-decoration: underline; }
.sel-item b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-item small { display: block; color: var(--muted); font-size: 12px; }
.sel-item button { border: none; background: none; cursor: pointer; }
.sel-item .sel-x { font-size: 16px; color: var(--muted); }
.sel-item .sel-x:hover { color: var(--red); }

/* ---------- product ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid .wide { grid-column: span 3; }
.variants-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 10px; gap: 10px; }
.variants { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(330px, 360px); gap: 14px; overflow-x: auto; padding: 2px 4px 12px 2px; }
.variant { background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.variant-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1.5px solid var(--ink); }
.variant-top input.vname { font: 600 15px var(--px-font); border: 1px solid transparent; padding: 4px 6px; flex: 1; background: transparent; }
.variant-top input.vname:hover, .variant-top input.vname:focus { border-color: var(--line-2); }
.swatch { width: 18px; height: 18px; border: 1.5px solid var(--ink); flex: none; cursor: pointer; padding: 0; }
.ctl-badge { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: var(--ink); color: var(--paper); padding: 2px 6px; }
.variant-body { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.variant-body .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vsec { border-top: 1.5px dashed var(--line); padding-top: 10px; }
.vsec-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ing-row { display: grid; grid-template-columns: 1fr 64px 24px; gap: 4px; margin-bottom: 4px; }
.ing-row input { padding: 5px 7px; font-size: 13px; }
.ing-row button, .linkbtn { border: none; background: none; cursor: pointer; color: var(--muted); font: 600 12px var(--font); padding: 0; }
.linkbtn { color: var(--blue); }
.nut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.nut-grid label { font-weight: 500; font-size: 11px; }
.nut-grid input { padding: 5px 7px; font-size: 13px; }
.sens-row { display: grid; grid-template-columns: 112px 1fr 34px; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 2px; }
.sens-row .track { position: relative; }
.sens-row .ctl-tick { position: absolute; top: -3px; width: 2px; height: 8px; background: var(--ink); opacity: .55; pointer-events: none; }
.sens-row b { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.sens-row b.diff { color: var(--accent); }
.diff-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; font-weight: 600; padding: 2px 7px; border: 1.5px solid var(--line-2); background: var(--paper-2); white-space: nowrap; }
.chip.up { border-color: var(--green); color: var(--green); }
.chip.down { border-color: var(--accent); color: var(--accent); }
.variant-foot { margin-top: auto; display: flex; gap: 6px; padding: 10px 12px; border-top: 1.5px solid var(--line); }

/* ---------- research & panel ---------- */
.research-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.rcard { background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.rcard-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.rcard-h h3 { margin: 0; }
.status { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border: 1.5px solid; white-space: nowrap; }
.status.wait { color: var(--muted); border-color: var(--line-2); }
.status.run { color: var(--blue); border-color: var(--blue); }
.status.ok { color: var(--green); border-color: var(--green); }
.status.err { color: var(--red); border-color: var(--red); }
.steps-log { font: 12px/1.6 ui-monospace, "Cascadia Mono", monospace; color: var(--ink-2); background: var(--paper-2); border: 1px solid var(--line); padding: 8px 10px; max-height: 150px; overflow: auto; }
.steps-log div::before { content: "▸ "; color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--paper-2); border: 1px solid var(--line); padding: 7px 9px; }
.fact b { display: block; font: 400 15px var(--num-font); margin-bottom: 2px; }
.fact small { color: var(--muted); font-size: 11px; }
.segbar { display: flex; height: 16px; border: 1.5px solid var(--ink); }
.segbar i { display: block; height: 100%; }
.seglegend { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-size: 12px; }
.seglegend span { display: flex; gap: 6px; align-items: baseline; }
.seglegend i { width: 10px; height: 10px; flex: none; display: inline-block; transform: translateY(1px); }
.norm-row { display: grid; grid-template-columns: 110px 1fr 30px; gap: 8px; align-items: center; font-size: 12px; }
.norm-bar { height: 8px; background: var(--paper-2); border: 1px solid var(--line-2); position: relative; }
.norm-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink-2); }
.dchips { display: flex; flex-wrap: wrap; gap: 4px; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; }
details p, details li { font-size: 13px; color: var(--ink-2); }
.sources { font-size: 12px; padding-left: 18px; margin: 6px 0 0; }
.sources li { margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; }
.panel-config { margin-top: 14px; }
.slider-row { display: flex; gap: 10px; align-items: center; min-width: 320px; }
.slider-row b { font: 400 18px var(--num-font); min-width: 40px; text-align: right; }
.alloc { display: flex; flex-wrap: wrap; gap: 6px; }
.personas { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.pcard { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: var(--paper); border: 1.5px solid var(--line-2); cursor: pointer; text-align: left; font: inherit; color: var(--ink); }
.pcard:hover { border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.pcard canvas { width: 33px; height: 51px; image-rendering: pixelated; flex: none; background: var(--paper-2); }
.pcard b { display: block; font-size: 13px; }
.pcard small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.35; }

/* ---------- simulate ---------- */
.sim-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.stage-card { padding: 0; border: 2px solid var(--ink); box-shadow: var(--shadow); }
.stage { position: relative; background: #2a2230; }
#room { width: 100%; display: block; image-rendering: pixelated; }
.room-overlay { position: absolute; inset: 0; pointer-events: none; }
.stage-hint { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: rgba(31,28,36,.86); color: #fff; padding: 10px 16px; font-size: 13px; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; color: #1f1c24; border: 1.5px solid #1f1c24; padding: 3px 7px; font-size: 11px; max-width: 190px; line-height: 1.3; box-shadow: 2px 2px 0 rgba(0,0,0,.3); }
.bubble.talk { background: #fff8d8; }
.bubble.sel { border-color: var(--accent); }
.progress { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 2px solid var(--ink); font-size: 13px; font-weight: 600; }
.progress .bar { flex: 1; height: 12px; border: 1.5px solid var(--ink); background: var(--paper-2); }
.progress .bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--accent) 0 6px, #ee7a62 6px 12px); transition: width .3s; }
.sim-side { display: flex; flex-direction: column; gap: 12px; }
.live-bars { display: flex; flex-direction: column; gap: 9px; }
.lbar-h { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; margin-bottom: 3px; }
.lbar-h b { font: 400 14px var(--num-font); }
.lbar { height: 14px; background: var(--paper-2); border: 1.5px solid var(--ink); }
.lbar i { display: block; height: 100%; transition: width .4s; }
.feed-card { flex: 1; }
.feed { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }
.feed-item { font-size: 12.5px; border-left: 3px solid var(--line-2); padding: 2px 0 2px 8px; }
.feed-item small { display: block; color: var(--muted); font-size: 11px; }

/* ---------- results ---------- */
.res-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; margin-bottom: 16px; }
.verdict { background: var(--ink); color: var(--paper); padding: 18px 22px; box-shadow: 4px 4px 0 var(--accent); }
.verdict .kicker { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #bdb6c4; font-weight: 700; }
.verdict h1 { font-size: 30px; margin: 4px 0 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.verdict ul { margin: 0; padding-left: 18px; color: #e6e1ea; }
.verdict li { margin-bottom: 3px; }
.certainty { font: 700 11px var(--font); letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border: 1.5px solid; }
.certainty.clear { color: #7ee0a8; border-color: #7ee0a8; }
.certainty.likely { color: #f3c86b; border-color: #f3c86b; }
.certainty.narrow { color: #f59a86; border-color: #f59a86; }
.res-meta { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; font-size: 12px; color: var(--muted); }
.res-nav { display: flex; gap: 6px; flex-wrap: wrap; position: sticky; top: 54px; z-index: 5; background: var(--bg); padding: 8px 0; margin-bottom: 8px; border-bottom: 1.5px solid var(--line); }
.res-nav a { font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-decoration: none; padding: 4px 10px; border: 1.5px solid var(--line-2); background: var(--paper); }
.res-nav a:hover { border-color: var(--ink); color: var(--ink); }
.rsec { margin: 26px 0 0; scroll-margin-top: 110px; }
.rsec > .rsec-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 10px; }
.rsec-h p { color: var(--ink-2); margin: 2px 0 0; font-size: 13px; max-width: 720px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.kpi-card { background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); }
.kpi-card.win { box-shadow: 4px 4px 0 var(--accent); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1.5px solid var(--ink); gap: 8px; }
.kpi-top b { font-family: var(--px-font); font-size: 15px; display: flex; gap: 7px; align-items: center; }
.kpi-top .sw { width: 12px; height: 12px; display: inline-block; border: 1.5px solid var(--ink); }
.kpi-big { padding: 12px; display: flex; align-items: baseline; gap: 8px; }
.kpi-big b { font: 400 34px/1 var(--num-font); }
.kpi-big small { color: var(--muted); }
.kpi-rows { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 7px; }
.kpi-row { display: grid; grid-template-columns: 1fr auto; font-size: 13px; align-items: baseline; gap: 6px; }
.kpi-row span { color: var(--ink-2); }
.kpi-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.kpi-row em { font-style: normal; font-size: 11.5px; margin-left: 4px; }
.up { color: var(--green); } .down { color: var(--red); }
.ci { color: var(--muted); font-size: 11px; font-family: var(--font); font-weight: 400; }
.info { display: inline-grid; place-items: center; width: 15px; height: 15px; border: 1px solid var(--muted); color: var(--muted); font-size: 10px; font-weight: 700; border-radius: 50%; cursor: help; margin-left: 3px; vertical-align: 1px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
.resmap-wrap { position: relative; height: 380px; background: var(--ocean); border: 2px solid var(--ink); }
.resmap-wrap canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; margin-top: 8px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; display: inline-block; border: 1.5px solid var(--ink); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--paper); }
table.t th, table.t td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; border-bottom: 1.5px solid var(--ink); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button { font: 600 12.5px var(--font); padding: 5px 11px; border: 1.5px solid var(--line-2); background: var(--paper); cursor: pointer; color: var(--ink-2); }
.tabs button.active { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.heat td.cell { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 90px; }
.heat td.cell.best { outline: 2px solid var(--ink); outline-offset: -3px; }
.heat td small { color: var(--muted); }
.jar-wrap { display: flex; flex-direction: column; gap: 10px; }
.jar-row { display: grid; grid-template-columns: 130px 1fr 210px; gap: 10px; align-items: center; font-size: 12.5px; }
.jar-bar { display: flex; height: 18px; border: 1.5px solid var(--ink); }
.jar-bar i { display: block; height: 100%; font-style: normal; font-size: 10.5px; color: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; font-weight: 600; }
.jar-bar .tl { background: #6a9fd8; } .jar-bar .jr { background: #8fc39b; color: #1d3b26; } .jar-bar .tm { background: #e58f78; }
.jar-flag { font-size: 12px; }
.jar-flag.bad { color: var(--red); font-weight: 600; }
.ideal-row { display: grid; grid-template-columns: 130px 1fr 150px; gap: 10px; align-items: center; font-size: 12.5px; margin-bottom: 8px; }
.ideal-track { position: relative; height: 18px; border-bottom: 1.5px solid var(--ink); }
.ideal-track .pt { position: absolute; bottom: -6px; width: 10px; height: 10px; transform: translateX(-50%); border: 1.5px solid var(--ink); }
.ideal-track .best { position: absolute; bottom: -2px; width: 3px; height: 22px; transform: translateX(-50%); background: var(--ink); }
.fixes { display: flex; flex-direction: column; gap: 6px; }
.fix { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 8px 10px; background: var(--paper-2); border-left: 3px solid var(--accent); }
.forecast-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.forecast-controls label { font-weight: 600; }
.forecast-controls .slider-row { min-width: 0; }
.forecast-controls .slider-row b { font-size: 15px; min-width: 52px; }
.fc-bars { display: flex; flex-direction: column; gap: 10px; }
.fc-row { display: grid; grid-template-columns: 170px 1fr 170px; gap: 10px; align-items: center; font-size: 13px; }
.fc-track { position: relative; height: 22px; background: var(--paper-2); border: 1.5px solid var(--ink); }
.fc-track .range { position: absolute; top: 4px; bottom: 4px; opacity: .35; }
.fc-track .mid { position: absolute; top: 0; bottom: 0; }
.fc-row b { font: 400 14px var(--num-font); }
.quotes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.quote { background: var(--paper); border: 1.5px solid var(--line-2); padding: 10px 12px; display: flex; gap: 10px; }
.quote canvas { width: 33px; height: 51px; image-rendering: pixelated; flex: none; }
.quote p { margin: 0 0 4px; font-size: 13px; }
.quote small { color: var(--muted); font-size: 11.5px; display: block; }
.score { font-weight: 700; font-size: 12px; padding: 0 5px; border: 1.5px solid; margin-right: 4px; }
.ask-box { display: grid; grid-template-columns: 1fr 180px 180px auto; gap: 8px; }
.answers { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.conf { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.conf-item { background: var(--paper); border: 1.5px solid var(--line-2); padding: 10px 12px; font-size: 13px; }
.lvl { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; border: 1.5px solid; display: inline-block; margin-bottom: 6px; }
.lvl.moderate { color: var(--green); } .lvl.low { color: var(--amber); } .lvl.indicative { color: var(--red); }
.plan { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.big-num { font: 400 32px/1 var(--num-font); }
.changes td { font-size: 12.5px; }

/* ---------- validate ---------- */
.val-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }
.val-table input { padding: 5px 7px; font-size: 13px; }
.dumbbell { display: flex; flex-direction: column; gap: 12px; }
.db-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: center; font-size: 13px; }
.db-track { position: relative; height: 24px; border-bottom: 1.5px solid var(--line-2); }
.db-track .dot { position: absolute; bottom: -7px; width: 12px; height: 12px; transform: translateX(-50%); border: 1.5px solid var(--ink); }
.db-track .dot.obs { background: var(--ink); }
.db-track .dot.pred { background: var(--paper); }
.db-track .dot.cal { background: var(--accent); }
.db-track .line { position: absolute; bottom: -1.5px; height: 3px; background: var(--line-2); }
.db-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-left: 160px; }

/* ---------- drawer & toast ---------- */
.drawer { position: fixed; inset: 0; background: rgba(20,18,24,.45); z-index: 50; display: flex; justify-content: flex-end; }
.drawer-panel { width: min(560px, 100%); height: 100%; overflow: auto; background: var(--paper); border-left: 2px solid var(--ink); padding: 22px 24px; position: relative; }
.drawer-close { position: absolute; right: 14px; top: 10px; border: none; background: none; font-size: 26px; cursor: pointer; color: var(--ink); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; font-size: 13px; z-index: 60; box-shadow: 3px 3px 0 var(--accent); }
.example-card { width: 100%; text-align: left; padding: 14px; background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); cursor: pointer; margin-bottom: 12px; font: inherit; color: var(--ink); }
.example-card:hover { background: var(--paper-2); }
.example-card b { font-family: var(--px-font); font-size: 17px; display: block; }
.history-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 1.5px solid var(--line-2); background: var(--paper); margin-bottom: 8px; cursor: pointer; font: inherit; color: var(--ink); }
.history-item:hover { border-color: var(--ink); }
.history-item small { color: var(--muted); display: block; }

.px-spin { width: 10px; height: 10px; background: var(--accent); display: inline-block; animation: pxspin 0.8s steps(4) infinite; }
@keyframes pxspin { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .market-grid, .sim-grid, .grid-2, .val-grid, .plan { grid-template-columns: 1fr; }
  .ask-box { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .stepper { position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1.5px solid var(--line); padding: 8px; }
  .stepper button small, .stepper-foot { display: none; }
  main { padding: 16px; }
  .step-head { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .wide { grid-column: span 1; }
  .jar-row, .fc-row, .ideal-row { grid-template-columns: 1fr; }
  .project-name { display: none; }
}
.norm-row b { font-weight: 700; font-variant-numeric: tabular-nums; }
.show-more { grid-column: 1 / -1; justify-self: center; }
.dchips .chip { white-space: normal; font-weight: 500; }
.price-line { font-size: 12.5px; color: var(--ink-2); margin: 0; }

/* ---------- start ---------- */
.start-hero { display: grid; grid-template-columns: minmax(260px, 0.8fr) 1.2fr; gap: 28px; align-items: start; margin: 6px 0 18px; }
.start-hero h1 { font-size: 34px; }
.start-card { background: var(--paper); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--accent); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.start-card textarea { font-size: 15px; min-height: 120px; border-color: var(--line-2); }
.start-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.start-chips button { font: 500 12px var(--font); padding: 5px 9px; border: 1.5px dashed var(--line-2); background: var(--paper-2); color: var(--ink-2); cursor: pointer; text-align: left; }
.start-chips button:hover { border-color: var(--ink); color: var(--ink); }
.btn.big { padding: 11px 18px; font-size: 14px; }
.start-progress { font: 12.5px/1.7 ui-monospace, "Cascadia Mono", monospace; }
.start-progress div::before { content: "▸ "; color: var(--accent); }
.draft-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.draft-variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.draft-v { border: 1.5px solid var(--ink); background: var(--paper); padding: 8px 10px; font-size: 12.5px; }
.draft-v b { display: block; font-size: 13.5px; }
.check-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.check-list li { margin-bottom: 4px; }
.next-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 1100px) { .start-hero, .draft-grid { grid-template-columns: 1fr; } }

/* ---------- town ---------- */
.town-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 2px solid var(--ink); flex-wrap: wrap; }
.town-tabs { margin: 0; }
.town-tabs button small { font-weight: 500; opacity: .75; margin-left: 4px; }
.speed { display: flex; border: 1.5px solid var(--ink); }
.speed button { font: 700 12px var(--font); padding: 4px 10px; border: none; border-right: 1.5px solid var(--ink); background: var(--paper); cursor: pointer; color: var(--ink); }
.speed button:last-child { border-right: none; }
.speed button.active { background: var(--ink); color: var(--paper); }
#town { width: 100%; display: block; image-rendering: pixelated; cursor: pointer; }
.bubble.caption { background: #1f1c24; color: #fff; font-style: italic; }
.town-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; border-top: 1.5px solid var(--line); font-size: 11.5px; color: var(--ink-2); }
.town-legend span { display: flex; align-items: center; gap: 5px; }
.town-legend i { width: 10px; height: 10px; display: inline-block; }
.lg-dots { background: repeating-linear-gradient(90deg, #8a8590 0 2px, transparent 2px 4px); }
.lg-face { background: #5ac05a; border: 1.5px solid #1a1a1a; }
.lg-bag { background: #e2553b; } .lg-rep { background: #2f9e6e; } .lg-no { background: #8a8590; }
.lbar { position: relative; }
.lbar .ci { position: absolute; top: -3px; bottom: -3px; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); opacity: .55; }
.learn { font-size: 12.5px; padding: 6px 8px; border-left: 3px solid var(--line-2); background: var(--paper-2); animation: pop .35s steps(3); }
.learn small { display: block; color: var(--muted); font-size: 10.5px; }
.learn.lead { border-color: var(--blue); } .learn.good { border-color: var(--green); } .learn.warn { border-color: var(--amber); } .learn.seg { border-color: #8a58c0; }
.wom { font-size: 12.5px; padding: 6px 8px; background: var(--paper-2); border: 1px solid var(--line); }
.wom p { margin: 2px 0; }
.wom b { font-weight: 700; }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }
#step-simulate .stage-hint { top: auto; bottom: 12px; transform: translateX(-50%); max-width: 80%; text-align: center; }

/* ---------- data chat ---------- */
.chat-fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; font: 600 14px var(--font); padding: 12px 18px; background: var(--accent); color: #fff; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
.chat-fab::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; background: #fff; box-shadow: 3px 3px 0 rgba(0,0,0,.25); vertical-align: -1px; }
.chat-fab:hover { filter: brightness(1.05); }
.chat-dock { position: fixed; right: 0; top: 54px; bottom: 0; width: min(460px, 100%); z-index: 45; background: var(--paper); border-left: 2px solid var(--ink); display: flex; flex-direction: column; box-shadow: -4px 0 0 rgba(0,0,0,.06); }
body.chat-open main { padding-right: 488px; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 2px solid var(--ink); gap: 8px; }
.chat-head b { display: block; font-family: var(--px-font); font-size: 15px; }
.chat-msgs { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-hello p { font-size: 13px; color: var(--ink-2); }
.chat-sugg { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.chat-sugg button { text-align: left; font: 500 13px var(--font); padding: 8px 10px; border: 1.5px dashed var(--line-2); background: var(--paper-2); cursor: pointer; color: var(--ink); }
.chat-sugg button:hover { border-color: var(--ink); }
.cmsg { font-size: 13.5px; line-height: 1.5; }
.cmsg.user { align-self: flex-end; max-width: 85%; background: var(--ink); color: var(--paper); padding: 8px 12px; }
.cmsg.bot { align-self: stretch; background: var(--paper-2); border: 1.5px solid var(--line-2); padding: 10px 12px; }
.cmsg.bot p { margin: 0 0 6px; }
.cmsg.bot h4 { font-family: var(--px-font); font-size: 14px; margin: 10px 0 4px; }
.cmsg.bot ul, .cmsg.bot ol { margin: 0 0 6px; padding-left: 18px; }
.cmsg.bot li { margin-bottom: 3px; }
.csteps { font-size: 12px; color: var(--ink-2); margin-bottom: 8px; border-bottom: 1px dashed var(--line-2); padding-bottom: 6px; }
.csteps summary { font-weight: 600; font-size: 12px; color: var(--muted); }
.csteps div { padding: 2px 0 2px 10px; border-left: 2px solid var(--line-2); margin: 3px 0; font-family: ui-monospace, "Cascadia Mono", monospace; font-size: 11.5px; }
.csrc { margin-top: 8px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; border-top: 1px dashed var(--line-2); padding-top: 6px; }
.csrc a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-input { display: flex; gap: 8px; padding: 10px 14px; border-top: 2px solid var(--ink); align-items: flex-end; }
.chat-input textarea { min-height: 44px; font-size: 13.5px; }
.chat-foot { padding: 0 14px 10px; color: var(--muted); font-size: 11px; }
@media (max-width: 1100px) { body.chat-open main { padding-right: 28px; } }
