/* Hacker House Goa palette. Flat colors, hard shadows, no gradients.

   Three typefaces, each with one job:
     --display  Fraunces, a variable flare serif. Headings only. Its SOFT and
                WONK axes are what give the page a drawn rather than generated
                feel. (ABC Arizona would sit here, but it is a licensed Dinamo
                family; Fraunces is the closest open-source flare serif.)
     --indic    Noto Serif Devanagari / Gujarati. The answers and the corpus
                passages are the actual content, so they get a real typeface
                instead of whatever the mono stack falls back to.
     --mono     Space Mono. Labels, metrics, ids, timings. Anything where digits
                must align and the value should read as measured data. */
:root {
  --green: #12693c;
  --ink: #07301b;
  --yellow: #ffd91c;
  --pink: #ec0f73;
  --cream: #fdf6dc;
  --muted: #4b6b57;
  --rule: rgba(7, 48, 27, 0.18);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --indic: "Noto Serif Devanagari", "Noto Serif Gujarati", "Kohinoor Devanagari", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--green);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
}

main {
  max-width: 940px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

/* Masthead */
.masthead { margin-bottom: 32px; }

.masthead h1 {
  font-family: var(--display);
  /* WONK 1 keeps the flared, slightly irregular terminals that make this read
     as drawn rather than defaulted. */
  font-variation-settings: "SOFT" 30, "WONK" 1;
  font-weight: 600;
  color: var(--yellow);
  font-size: clamp(42px, 8vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0;
}

.masthead-sub {
  font-family: var(--display);
  font-variation-settings: "SOFT" 20, "WONK" 0;
  font-size: 19px;
  line-height: 1.5;
  margin: 14px 0 0;
  max-width: 52ch;
  color: var(--cream);
  opacity: 0.92;
}

/* Live config, read from /health so the page states what it is actually running. */
.config {
  margin: 14px 0 0;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--yellow);
  opacity: 0.8;
}

/* Cards */
.card {
  background: var(--cream);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 28px;
}

.card-title {
  font-family: var(--display);
  font-variation-settings: "SOFT" 30, "WONK" 1;
  color: var(--green);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
}

.sub {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 10px;
}

/* Ask */
.ask-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 28px;
  align-items: start;
}

.mic-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.mic {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--green);
  border: 3px dashed var(--pink);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s;
}
.mic svg {
  width: 50px;
  height: 50px;
  fill: none;
  stroke: var(--cream);
  stroke-width: 1.8;
  stroke-linecap: round;
}
.mic:hover { transform: scale(1.04); }
.mic:disabled { opacity: 0.45; cursor: not-allowed; }

/* Solid ring plus pulse while capturing. */
.mic.is-recording {
  background: var(--pink);
  border-style: solid;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 12px rgba(236, 15, 115, 0.25); }
}

.mic-label {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
}

.controls { display: flex; flex-direction: column; gap: 16px; }

.field { display: block; }
.field span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--muted);
}

textarea {
  width: 100%;
  font-family: var(--indic);
  font-size: 15px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
  resize: vertical;
}
textarea:focus { outline: 3px solid var(--pink); outline-offset: 2px; }

.toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

.detected { margin: 0; font-size: 13px; color: var(--muted); }
.detected b { font-family: var(--indic); color: var(--green); }

.btn {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 24px;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.btn:active { transform: translate(4px, 4px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-pink { background: var(--pink); color: var(--cream); }

/* Answer */
.answer-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.answer-head .tiers { margin-right: auto; }

/* Two-tier answer track. Tier 1 is local and inside the budget; tier 2 is the
   optional LLM rewrite and sits outside it. */
.tiers { display: flex; align-items: center; gap: 10px; }

.tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  background: #fff;
  color: #9bb0a3;
}
.tier b { font-family: var(--display); font-variation-settings: "WONK" 1; font-size: 15px; }
.tier em { font-style: normal; opacity: 0.75; }
.tier[data-state="done"] { background: var(--green); color: var(--yellow); }
.tier[data-state="pending"] { background: var(--yellow); color: var(--ink); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.55; } }

.tier-link { width: 18px; height: 2px; background: var(--ink); }

/* The 200ms budget, drawn to scale. */
.budget { margin: 0 0 18px; }

.budget-bar {
  height: 18px;
  border: 3px solid var(--ink);
  background: #fff;
  overflow: hidden;
}
.budget-bar i { display: block; height: 100%; background: var(--green); transition: width 0.3s; }
.budget-bar i.is-over { background: var(--pink); }

.budget-legend { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.budget-legend b { color: var(--ink); }
.budget-legend .over { color: var(--pink); font-weight: 700; }

.tag {
  background: var(--green);
  color: var(--yellow);
  border: 2px solid var(--ink);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}
.tag-pink { background: var(--pink); color: var(--cream); }
.tag-quiet { background: #fff; color: var(--green); font-family: var(--indic); }

.transcript {
  border-left: 6px solid var(--pink);
  padding-left: 14px;
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}
.transcript b { color: var(--ink); }

.answer {
  font-family: var(--indic);
  font-size: 18px;
  line-height: 1.85;
  margin: 0 0 8px;
}

/* The passage's original English, shown under the answer. Set apart so it
   never reads as part of the answer itself. */
.answer-en {
  font-family: var(--display);
  font-variation-settings: "SOFT" 20, "WONK" 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  border-left: 3px solid var(--rule);
  padding-left: 14px;
  margin: 0 0 8px;
}
.answer-en b {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.source-en {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--rule);
  font-family: var(--display);
  font-size: 14px;
  color: var(--muted);
}

/* A refusal must not be mistakable for an answer. */
.refusal {
  background: var(--pink);
  color: var(--cream);
  border: 3px solid var(--ink);
  padding: 14px 16px;
  margin: 0 0 8px;
  font-size: 15px;
}
.refusal { font-family: var(--indic); }
.refusal b {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}

/* Stage timings */
.stages { display: flex; flex-direction: column; gap: 6px; }

.stage { display: grid; grid-template-columns: 150px 1fr 72px; gap: 10px; align-items: center; font-size: 13px; }
/* Both are spans, so they need an explicit box: width and height do not
   apply to inline elements. */
.stage-bar { display: block; height: 14px; border: 2px solid var(--ink); background: #fff; }
.stage-fill { display: block; height: 100%; background: var(--yellow); }
.stage-fill.is-slow { background: var(--pink); }
.stage-ms { text-align: right; font-weight: 700; }

/* Sources */
.sources { display: flex; flex-direction: column; gap: 10px; }

.source {
  border: 2px solid var(--ink);
  background: #fff;
  padding: 12px 14px;
  font-family: var(--indic);
  font-size: 15px;
  line-height: 1.7;
}
.source-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 4px;
}
.source-head .cited { color: var(--pink); }

/* How it works */
.lede { margin: -8px 0 22px; max-width: 66ch; color: var(--muted); }

.diagram { overflow-x: auto; }
.diagram svg { display: block; width: 100%; min-width: 700px; height: auto; }

.d-node rect {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 2.5;
}
.d-node text {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
  text-anchor: middle;
}
.d-node .d-sub { font-size: 11px; font-weight: 400; fill: var(--muted); }

/* The two stages doing the real work. */
.d-accent rect { fill: var(--yellow); }
/* Anything on the network, and so outside the measured window. */
.d-outside rect { fill: #eee7cd; stroke-dasharray: 6 4; }
.d-outside text { fill: var(--muted); }
.d-decline rect { fill: var(--pink); }
.d-decline text, .d-decline .d-sub { fill: var(--cream); }

.d-budget {
  fill: rgba(18, 105, 60, 0.07);
  stroke: var(--green);
  stroke-width: 2.5;
}

.diagram line { stroke: var(--ink); stroke-width: 2.5; }
.diagram .d-divider { stroke: var(--rule); stroke-width: 2; stroke-dasharray: 7 5; }

.d-phase {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  fill: var(--muted);
}
.d-onlight { fill: var(--green); }
.d-note { font-family: var(--mono); font-size: 11px; fill: var(--muted); }

/* Measured results */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.metric { border-top: 3px solid var(--ink); padding-top: 14px; }

.metric-label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-value {
  margin: 6px 0 2px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--green);
  /* Tabular digits keep the three latency percentiles from shifting around. */
  font-variant-numeric: tabular-nums;
}
.metric-value small { font-size: 16px; font-weight: 400; }

.metric-note { margin: 0; font-size: 13px; color: var(--muted); }

/* Latency is three numbers, not one. Stacking keeps them readable in a narrow
   column and matches how the requirement asks for them. */
.metric-stack { display: flex; flex-direction: column; gap: 2px; font-size: 21px; }
.metric-stack span { display: flex; gap: 10px; align-items: baseline; }
.metric-stack b {
  min-width: 3.4em;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
}
.metric-stack small { font-size: 13px; font-weight: 400; }

/* Names the artifact each number came from, so nothing looks conjured. */
/* Live session counters. Deliberately quieter than .metric above: these are a
   handful of demo queries, not a benchmark, and should not read like one. */
.session {
  margin-top: 22px;
  padding: 16px 18px;
  border: 2px solid var(--rule);
  border-radius: 4px;
}

.session-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.session-row {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
}

.session-stat { display: flex; gap: 7px; align-items: baseline; }

.session-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.session-value {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
}

.session-stat small { font-size: 11px; color: var(--muted); }

.session-note { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

.provenance {
  margin: 24px 0 0;
  padding-top: 14px;
  border-top: 2px solid var(--rule);
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}

/* Footer */
footer {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 2px solid rgba(253, 246, 220, 0.28);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 24px;
}

.credit {
  font-family: var(--display);
  font-variation-settings: "SOFT" 30, "WONK" 1;
  font-size: 18px;
  margin: 0;
  color: var(--cream);
}
.credit strong { color: var(--yellow); font-weight: 600; }

.dataset { margin: 0; font-size: 13px; color: var(--cream); opacity: 0.8; }
.dataset a { color: var(--yellow); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.dataset a:hover { color: var(--pink); }

@media (max-width: 720px) {
  .ask-grid { grid-template-columns: 1fr; }
  .mic { width: 120px; height: 120px; }
  .stage { grid-template-columns: 110px 1fr 64px; }
}
