/* Pramaan demo UI.
 *
 * Dark, quiet, and deliberately plain. The interesting thing on screen should
 * be the evidence, not the chrome. No web fonts and no CDN: the demo must run
 * with the network unplugged, which is also the whole point of a local model.
 */

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #1c2333;
  --border:    #2a3240;
  --text:      #e6edf3;
  --muted:     #8b97a8;
  --accent:    #d9a441;   /* pramaan = proof; the colour of a highlighter */
  --accent-dim:#3a2f18;
  --ok:        #3fb950;
  --warn:      #d29922;
  --danger:    #f85149;
  --radius:    12px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Author styles beat the UA's `[hidden] { display: none }` regardless of
 * specificity, so any rule that sets `display` on a hideable element silently
 * un-hides it. The loading and error cards are both flex containers; without
 * this line they render permanently. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
        "Noto Sans Devanagari", "Nirmala UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 780px; margin: 0 auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ───────────────────────────────────────────────────────── header ── */

.top {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.5rem 0 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  font-weight: 650;
}

.devanagari {
  color: var(--accent);
  font-weight: 400;
  margin-left: 0.35rem;
  opacity: 0.85;
}

.tagline { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.94rem; }
.tagline em { color: var(--text); font-style: italic; }

.status { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.18rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill--ok   { color: var(--ok); }
.pill--warn { color: var(--warn); }
.pill--bad  { color: var(--danger); }
.pill--wait { color: var(--muted); }
.pill--plain::before { display: none; }

/* ───────────────────────────────────────────────────────── cards ── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 0.9rem;
}

.card-h {
  margin: 0 0 0.7rem;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.muted { color: var(--muted); font-size: 0.86rem; }

/* ─────────────────────────────────────────────────────────── ask ── */

.ask { padding: 1.5rem 1.4rem 1.4rem; }

.lang-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.lang-row label { flex: none; }

select, input[type="text"] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
}

select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lang-note {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--warn);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  font-size: 0.86rem;
  color: var(--text);
}

/* mic ------------------------------------------------------------- */

.mic-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1.6rem 0 1.1rem;
}

.mic {
  width: 76px; height: 76px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s ease, background .18s ease, border-color .18s ease;
}

.mic:hover:not(:disabled) { background: #232b3d; border-color: #3b4757; }
.mic:active:not(:disabled) { transform: scale(0.96); }

.mic:disabled { opacity: 0.4; cursor: not-allowed; }

.mic svg { width: 30px; height: 30px; fill: currentColor; stroke: currentColor; }
.mic .stop-icon { display: none; }

/* recording state: red, pulsing halo, stop glyph */
.mic.recording {
  background: #3d1418;
  border-color: var(--danger);
  color: #ffb4ae;
  animation: halo 1.6s ease-out infinite;
}
.mic.recording .mic-icon { display: none; }
.mic.recording .stop-icon { display: block; }

@keyframes halo {
  0%   { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.45); }
  70%  { box-shadow: 0 0 0 18px rgba(248, 81, 73, 0); }
  100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .mic.recording { animation: none; box-shadow: 0 0 0 4px rgba(248,81,73,.35); }
  .spinner { animation-duration: 3s; }
}

.mic-meta {
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 0.86rem; color: var(--muted);
  min-height: 1.5rem;
}

.timer {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--danger);
  font-variant-numeric: tabular-nums;
}

/* divider + typed input ------------------------------------------- */

.divider {
  display: flex; align-items: center; gap: 0.8rem;
  color: var(--muted); font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0.2rem 0 1rem;
}
.divider::before, .divider::after {
  content: ""; height: 1px; background: var(--border); flex: 1;
}

.type-row { display: flex; gap: 0.5rem; }
.type-row input { flex: 1; padding: 0.6rem 0.75rem; }

button[type="submit"], .btn {
  background: var(--accent);
  color: #1a1206;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
button[type="submit"]:hover { background: #e8b95a; }
button[type="submit"]:disabled { opacity: .5; cursor: not-allowed; }

/* ─────────────────────────────────────────────── loading / error ── */

.loading, .error { display: flex; gap: 1rem; align-items: flex-start; }
.loading strong, .error strong { display: block; margin-bottom: 0.15rem; }
.loading p, .error p { margin: 0.1rem 0 0; }

.spinner {
  width: 22px; height: 22px; flex: none; margin-top: 2px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error { border-color: #5c2b2b; background: #1e1416; }
.error-mark {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  background: var(--danger);
  color: #1e1416;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
}
.error p { font-size: 0.92rem; }

/* ──────────────────────────────────────────────────────── result ── */

.heard-text {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.55;
}
.heard-meta { margin: 0.5rem 0 0; font-family: var(--mono); font-size: 0.78rem; }

.answer-text {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.6;
}

.answer--refuse .answer-text { color: var(--warn); }
.answer--refuse { border-color: #4a3c17; }

.refusal-note { margin: 0.7rem 0 0; }
.speech-note { margin: 0.7rem 0 0; font-size: 0.8rem; }

/* The verified English original, shown beneath a translated answer.
   Deliberately quieter than the answer above it but not hidden: it is the
   text the grounding guard actually checked, and a reader must be able to
   compare the two without expanding anything. */
.original {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--line, #2a2a2a);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 6px 6px 0;
}

.original-h {
  margin: 0 0 0.4rem;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.original-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
}

/* listen button ---------------------------------------------------- */

.card-h .listen { margin-left: auto; }

.listen {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.listen:hover { background: #232b3d; border-color: #3b4757; }

.listen.speaking {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* A quiet pulse while audio is playing — the only cue that something is
 * happening, since the answer text itself does not change. */
.listen.speaking .listen-glyph { animation: pulse 1.3s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .listen.speaking .listen-glyph { animation: none; }
}

/* citations -------------------------------------------------------- */

.evidence-lede { margin: 0 0 0.85rem; }

.cites { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.65rem; }

.cite {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
  padding: 0.75rem 0.9rem;
}

.cite--supporting {
  border-left-color: var(--accent);
  background: #1d2231;
}

.cite-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--muted);
}

.rank {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 5px;
  background: var(--border);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
}
.cite--supporting .rank { background: var(--accent); color: #1a1206; }

.tag {
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tag--supporting {
  border-color: var(--accent);
  color: var(--accent);
}

.snippet {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #c9d4e0;
  max-height: 7.5rem;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

/* the actual point of the whole product: the span that was quoted */
mark {
  background: var(--accent-dim);
  color: var(--text);
  border-bottom: 2px solid var(--accent);
  border-radius: 2px;
  padding: 0.05em 0.1em;
}

.no-url { margin: 0.9rem 0 0; font-size: 0.8rem; }

/* timings ---------------------------------------------------------- */

.bars { display: grid; gap: 0.4rem; }

.bar-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr 5.5rem;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.82rem;
}
.bar-row .label { color: var(--muted); }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 9px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-fill--outside { background: #495a70; }
.bar-row .val { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

.timings .muted { margin: 0.85rem 0 0; }

/* caveat ----------------------------------------------------------- */

.caveat { border-color: #3a3524; background: #17160f; margin-top: 1.6rem; }
.caveat p { margin: 0 0 0.7rem; font-size: 0.9rem; line-height: 1.6; }
.caveat p:last-child { margin-bottom: 0; }
.caveat strong { color: var(--accent); font-weight: 600; }

/* ───────────────────────────────────────────────────────── footer ── */

footer {
  max-width: 780px;
  margin: 1.5rem auto 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: var(--mono);
  flex-wrap: wrap;
}
footer a { color: var(--muted); }

@media (max-width: 560px) {
  .bar-row { grid-template-columns: 6.5rem 1fr 4.6rem; font-size: 0.76rem; }
  .top { padding-top: 1.5rem; }
}

/* The English query a non-English question was searched with. Collapsed by
   default: it explains a result rather than being one. */
.normq {
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
}

.normq > summary {
  cursor: pointer;
  color: var(--muted, #8a8a8a);
  user-select: none;
}

.normq-text {
  margin: 0.45rem 0 0;
  padding-left: 0.8rem;
  border-left: 2px solid var(--line, #2a2a2a);
  font-family: var(--mono);
  font-size: 0.8rem;
}
