:root {
  --bg: #12141a;
  --bg-elev: #1a1d26;
  --bg-card: #1e222c;
  --border: #2a2f3a;
  --text: #e6e4df;
  --muted: #8b909c;
  --gold: #c9a84c;
  --gold-dim: #8a7340;
  --cyan: #4ecdc4;
  --cyan-dim: #2a8a84;
  --iris: #3d9b96;
  --danger: #c46b5a;
  --ok: #6bb88a;
  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
  --radius: 10px;
  --max: 920px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--grain);
  pointer-events: none;
  opacity: 0.45;
  z-index: 9999;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--gold); }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  position: relative;
  z-index: 1;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

nav .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

nav .brand svg { flex-shrink: 0; }

nav .links {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  font-size: 0.875rem;
}

nav .links a { color: var(--muted); }
nav .links a:hover,
nav .links a.active { color: var(--gold); }

.iris {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%,
    #e8f4f3 0%,
    var(--cyan) 18%,
    var(--iris) 38%,
    #1a3a38 55%,
    #0a1214 70%,
    #1a1d26 100%);
  box-shadow: 0 0 0 1px var(--gold-dim), 0 0 12px rgba(78, 205, 196, 0.25);
}

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  color: var(--text);
}

h1 .accent { color: var(--gold); }

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  margin: 1.75rem 0 0.75rem;
  letter-spacing: 0.02em;
}

.lede {
  color: var(--muted);
  font-size: 1rem;
  max-width: 38em;
  margin-bottom: 2rem;
}

.manifesto {
  font-size: 1.05rem;
  color: var(--text);
  max-width: 36em;
  margin-bottom: 2rem;
  border-left: 2px solid var(--gold-dim);
  padding-left: 1.1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: block;
  color: inherit;
}

.card:hover {
  border-color: var(--gold-dim);
  box-shadow: 0 0 24px rgba(201, 168, 76, 0.08);
  color: inherit;
}

.card .tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
  margin-bottom: 0.5rem;
}

.card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.card p {
  font-size: 0.9rem;
  color: var(--muted);
}

.honesty {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-top: 0.5rem;
}

.honesty h2 {
  margin-top: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.honesty dl {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.honesty dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin-bottom: 0.15rem;
}

.honesty dd {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

/* Controls */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1rem;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.control-row:last-child { margin-bottom: 0; }

.control-row label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.control-row .val {
  font-family: var(--mono);
  color: var(--cyan);
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.4);
  border: 2px solid var(--bg);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.zone-bar {
  position: relative;
  height: 8px;
  background: linear-gradient(90deg,
    var(--cyan) 0%,
    var(--ok) 35%,
    var(--gold) 55%,
    var(--danger) 85%);
  border-radius: 4px;
  margin: 0.5rem 0 0.35rem;
}

.zone-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  background: var(--text);
  transform: translateX(-50%);
  pointer-events: none;
}

.zone-sweet {
  position: absolute;
  top: -6px;
  width: 10px;
  height: 20px;
  border: 1.5px solid var(--gold);
  border-radius: 2px;
  background: transparent;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0.9;
}

.zone-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.readouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.readout {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.readout .k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.readout .v {
  font-family: var(--mono);
  font-size: 1.15rem;
  color: var(--cyan);
}

.readout .v.warn { color: var(--danger); }
.readout .v.ok { color: var(--ok); }
.readout .v.gold { color: var(--gold); }

.decision {
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.08), rgba(78, 205, 196, 0.06));
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  font-size: 1rem;
}

.decision .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.decision .text { color: var(--text); }

.formula {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 0.75rem;
}

details.expand {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

details.expand summary {
  cursor: pointer;
  color: var(--cyan-dim);
  list-style: none;
}

details.expand summary::-webkit-details-marker { display: none; }
details.expand summary::before { content: "▸ "; color: var(--gold-dim); }
details.expand[open] summary::before { content: "▾ "; }
details.expand[open] .body {
  margin-top: 0.6rem;
  padding: 0.75rem;
  background: var(--bg-elev);
  border-radius: 6px;
  border: 1px solid var(--border);
  line-height: 1.6;
}

/* Synthesis */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.btn {
  font-family: var(--font);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.btn:hover { border-color: var(--cyan-dim); }
.btn.primary {
  background: rgba(78, 205, 196, 0.12);
  border-color: var(--cyan-dim);
  color: var(--cyan);
}
.btn.primary:hover { background: rgba(78, 205, 196, 0.2); }
.btn.gold {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.btn.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-dim);
}

.canvas-wrap {
  position: relative;
  background: #0c0e12;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

.canvas-caption {
  position: absolute;
  bottom: 0.5rem;
  left: 0.75rem;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  pointer-events: none;
}

.side-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .side-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
  nav .links { margin-left: 0; width: 100%; }
}

.gap-list {
  list-style: none;
}

.gap-list li {
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  color: var(--danger);
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.gap-list li::before {
  content: "UNKNOWN";
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  flex-shrink: 0;
}

.gap-list li.empty {
  color: var(--ok);
  font-family: var(--font);
}
.gap-list li.empty::before { content: "CLEAR"; color: var(--ok); }

.meter-track {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--gold), var(--ok));
  border-radius: 5px;
  transition: width 0.35s ease;
  width: 50%;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

.note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.5rem;
  font-style: italic;
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
