/* DramDesk — Japanese semiconductor fab cleanroom aesthetic */
:root {
  --bg: #f4f8f9;
  --bg-elev: #ffffff;
  --ink: #0b1f33;
  --ink-soft: #3a5168;
  --line: #c9d8e0;
  --line-strong: #8aa4b5;
  --cyan: #d7eef2;
  --cyan-deep: #9ec9d4;
  --amber: #ffb020;
  --amber-ink: #8a5a00;
  --ok: #1f7a4c;
  --wait: #b45309;
  --alert: #b42318;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Sora", "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(11, 31, 51, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #e8f6f8 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #fff6e8 0%, transparent 45%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.45;
}
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.035;
  background-image: url("assets/noise.svg");
  z-index: 50;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--ink); }
button, input, select { font: inherit; color: inherit; }

/* —— Airlock strip —— */
.airlock {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #eef6f8 100%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-text { font-size: 0.95rem; }
.airlock-mid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.airlock-right { margin-left: auto; }
.chip {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--cyan);
  color: var(--ink);
  border: 1px solid var(--line);
}
.chip.amber {
  background: #fff1d6;
  border-color: #f0c56a;
  color: var(--amber-ink);
}
.press {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-soft);
}

/* —— Desk split —— */
.desk {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 18px;
  padding: 18px 16px 8px;
  max-width: 1280px;
  margin: 0 auto;
}
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.intro h1 {
  font-family: var(--display);
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}
.lede {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.panel-h {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.live {
  font-family: var(--mono);
  font-size: 0.62rem;
  background: #e8fff2;
  color: var(--ok);
  border: 1px solid #b7e4c7;
  padding: 2px 6px;
  border-radius: 999px;
}

.result-panel {
  border-color: #f0c56a;
  background: linear-gradient(160deg, #fffdf8 0%, #ffffff 55%);
}
.tax-big {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.6rem);
  letter-spacing: -0.04em;
  color: var(--ink);
}
.tax-big::before { content: "$"; font-size: 0.55em; opacity: 0.55; margin-right: 2px; }
.tax-band {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 2px;
}
.tax-sub { margin: 8px 0 0; font-size: 0.86rem; color: var(--ink-soft); }
.guidance {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  background: var(--cyan);
  border: 1px solid var(--line);
}
.guidance.buy { background: #e8fff2; border-color: #b7e4c7; color: var(--ok); }
.guidance.wait { background: #fff4e5; border-color: #f0c56a; color: var(--wait); }
.guidance.hold { background: #f4f6f8; color: var(--ink-soft); }

.split-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.split-metrics > div {
  background: #f7fbfd;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.m-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.m-val { font-weight: 650; font-size: 0.92rem; }

.grid-ctrl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ctrl, .ctrl-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.ctrl.full, .full { grid-column: 1 / -1; }
.ctrl input, .ctrl select {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
}
.ctrl input:focus, .ctrl select:focus {
  outline: 2px solid rgba(255, 176, 32, 0.45);
  border-color: var(--amber);
}
.range-val { font-family: var(--mono); color: var(--amber-ink); }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.seg button {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 600;
}
.seg button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn-row.wrap { flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86rem;
}
.btn:hover { border-color: var(--ink); }
.btn.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn.primary:hover { background: #16324d; }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
  padding-inline: 8px;
}
.btn.ghost:hover { color: var(--ink); }

.saved-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.saved-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbfd;
  font-size: 0.86rem;
}
.saved-list li button {
  margin-left: auto;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.78rem;
}
.tiny { font-size: 0.75rem; color: var(--ok); margin: 8px 0 0; }
.notes-panel summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.notes {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-soft);
  background: #f7fbfd;
  border-radius: 8px;
  padding: 8px;
  max-height: 120px;
  overflow: auto;
}
.muted { opacity: 0.7; }

/* —— Stage column —— */
.stage-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.stage-card, .chart-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.stage-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}
.stage-tools { display: flex; gap: 4px; }
.canvas-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(160deg, #eaf5f7 0%, #f8fbfd 50%, #fff8eb 100%);
  border: 1px solid var(--line);
  aspect-ratio: 16 / 10;
  min-height: 240px;
}
#die-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.stage-hero {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.22;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.stage-cap {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 70px; gap: 8px; align-items: center; font-size: 0.82rem; }
.bar-track {
  height: 12px;
  background: var(--cyan);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0b1f33, #ffb020);
  border-radius: 999px;
  width: 0;
  transition: width 0.35s ease;
}
.bar-row .amt { font-family: var(--mono); font-size: 0.75rem; text-align: right; }
.compare-strip {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.compare-strip .cell {
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  padding: 10px;
  background: #f7fbfd;
}
.compare-strip .cell strong { display: block; font-size: 1.05rem; margin-top: 2px; }
.compare-strip .lbl { font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; color: var(--ink-soft); }

.ref-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.ref-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.ref-card img { width: 100%; height: 120px; object-fit: cover; background: var(--cyan); }
.ref-card h3 {
  margin: 10px 12px 4px;
  font-family: var(--display);
  font-size: 0.92rem;
}
.ref-card p {
  margin: 0 12px 12px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* —— Assumptions strip —— */
.assumptions {
  max-width: 1280px;
  margin: 8px auto 0;
  padding: 0 16px;
}
.assumptions-inner {
  background: #0b1f33;
  color: #e8f1f6;
  border-radius: var(--radius);
  padding: 14px 16px;
}
.assumptions-inner h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.always {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(255,176,32,0.45);
  padding: 2px 6px;
  border-radius: 999px;
}
.assumptions-inner ul {
  margin: 0;
  padding-left: 18px;
  columns: 2;
  gap: 24px;
  font-size: 0.82rem;
  color: #c5d5e0;
}
.assumptions-inner li { break-inside: avoid; margin-bottom: 4px; }

/* —— Dense reference —— */
.dense { padding: 18px 16px 8px; }
.dense-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.dense article {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.dense article.spot-board { grid-column: 1 / -1; }
.dense h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.dense p { margin: 0 0 10px; color: var(--ink-soft); font-size: 0.9rem; }
.cite { font-size: 0.78rem !important; }
.cite a { color: var(--amber-ink); }
.table-wrap { overflow-x: auto; }
.cmp {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.cmp th, .cmp td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.cmp th {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: #f7fbfd;
}
.gloss { margin: 0; }
.gloss dt {
  font-family: var(--display);
  font-weight: 600;
  margin-top: 8px;
}
.gloss dd { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.88rem; }

.site-foot {
  max-width: 1280px;
  margin: 12px auto 28px;
  padding: 0 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.site-foot a { color: var(--ink-soft); }

/* —— Mobile —— */
@media (max-width: 900px) {
  .airlock-mid { display: none; }
  .desk {
    grid-template-columns: 1fr;
    padding-bottom: 0;
  }
  .controls {
    order: 2;
  }
  .stage-col { order: 1; }
  .controls {
    position: relative;
  }
  /* bottom drawer feel */
  .controls .intro { padding-top: 4px; }
  .ref-grid { grid-template-columns: 1fr; }
  .dense-inner { grid-template-columns: 1fr; }
  .assumptions-inner ul { columns: 1; }
  .split-metrics { grid-template-columns: 1fr; }
  .compare-strip { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid-ctrl { grid-template-columns: 1fr; }
  .tax-big { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
}
