:root {
  --bg: #EDF1EE;
  --surface: #FFFFFF;
  --soft: #E2E9E5;
  --ink: #14302A;
  --muted: #5D706A;
  --line: #D2DCD7;
  --leaf: #2E6A56;
  --leaf-ink: #FFFFFF;
  --haldi: #E2A11B;
  --haldi-ink: #2B1F00;
  --danger: #B4372C;
  --font: 'Mukta', 'Noto Sans Devanagari', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1C19;
    --surface: #152824;
    --soft: #1B322D;
    --ink: #E5EEEA;
    --muted: #98ACA5;
    --line: #28433C;
    --leaf: #5DAA8B;
    --leaf-ink: #0B1A16;
    --haldi: #EFB43C;
    --haldi-ink: #231900;
    --danger: #F08A7E;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 8.5vw, 3.4rem); line-height: 1.06; max-width: 15ch; }
h2 { font-size: clamp(1.5rem, 5.5vw, 2rem); line-height: 1.15; }
h3 { font-size: 1.15rem; line-height: 1.3; font-weight: 700; }
:lang(hi) h1 { line-height: 1.22; }
:lang(hi) h2 { line-height: 1.3; }
p { margin: 0; }
a { color: var(--leaf); font-weight: 500; }

.screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 28px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.screen.centered { justify-content: center; align-items: center; text-align: center; padding-top: 40px; }
.screen.centered > p, .screen.centered .card { max-width: 46ch; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.mark { width: 18px; height: 18px; border-radius: 50%; background: var(--haldi); box-shadow: 6px 0 0 -2px var(--leaf); }

.lang { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; flex: none; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.ghost.icon { width: 40px; padding: 0; display: inline-grid; place-items: center; }
@media (max-width: 420px) { .talk .brand-name { display: none; } }
.lang button {
  border: 0; background: transparent; color: var(--muted);
  font: 500 15px/1 var(--font); padding: 8px 14px; border-radius: 999px; cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--surface); color: var(--ink); }

/* ---------- Welcome ---------- */
.welcome { display: flex; flex-direction: column; gap: 18px; padding-top: 12px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 44ch; }
.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
input, textarea, select {
  font: 400 17px/1.4 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--haldi);
  outline-offset: 2px;
}
.hint { font-size: 0.92rem; color: var(--muted); }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 500; min-height: 0; }
.error:empty { display: none; }
.notice { background: var(--soft); border-radius: 12px; padding: 10px 14px; font-size: 0.95rem; }

.how {
  list-style: none; counter-reset: how; margin: 10px 0 0; padding: 18px 0 0;
  border-top: 1.5px solid var(--line); display: grid; gap: 10px; color: var(--muted);
}
.how li { counter-increment: how; display: grid; grid-template-columns: 30px 1fr; align-items: baseline; }
.how li::before { content: counter(how); font-weight: 800; color: var(--leaf); font-size: 1.1rem; }

/* ---------- Buttons ---------- */
button { font-family: var(--font); cursor: pointer; }
.primary, .secondary, .ghost {
  border-radius: 999px;
  font: 700 17px/1 var(--font);
  min-height: 54px;
  padding: 0 24px;
  border: 1.5px solid transparent;
}
.primary { background: var(--haldi); color: var(--haldi-ink); }
.secondary { background: var(--leaf); color: var(--leaf-ink); }
.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.small { min-height: 40px; padding: 0 16px; font-size: 15px; }
button:disabled { opacity: 0.55; cursor: default; }

/* ---------- Conversation ---------- */
.talk { height: 100%; min-height: 0; gap: 10px; padding-bottom: 14px; }
.progress { height: 4px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--leaf); transition: width 400ms ease; }

.stage { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0 6px; }
.status { font-weight: 500; text-align: center; min-height: 1.6em; }
.link-btn {
  background: none; border: 0; padding: 6px 10px; color: var(--leaf);
  font: 500 15px/1.3 var(--font); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.bubble.hint { background: transparent; border: 1.5px dashed var(--line); color: var(--muted); }
.interim { color: var(--muted); text-align: center; min-height: 1.4em; max-width: 36ch; font-size: 0.95rem; }

.orb {
  --level: 0;
  position: relative;
  width: min(46vw, 200px);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  flex: none;
}
.orb::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--line);
  transform: scale(calc(1 + var(--level) * 0.3));
  transition: transform 90ms linear, border-color 250ms;
}
.orb-core {
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: 2.4rem;
  font-weight: 800;
  transition: background 250ms, color 250ms;
}
.orb.static { width: 140px; }

[data-mode="listening"] .orb::before { border-color: var(--haldi); }
[data-mode="hearing"] .orb::before { border-color: var(--haldi); }
[data-mode="hearing"] .orb-core { background: var(--haldi); color: var(--haldi-ink); box-shadow: none; }
[data-mode="thinking"] .orb::before,
[data-mode="transcribing"] .orb::before,
.orb[data-mode="thinking"]::before { border: 3px dashed var(--leaf); animation: spin 3s linear infinite; }
[data-mode="speaking"] .orb::before { border-color: var(--leaf); animation: breathe 1.4s ease-in-out infinite; }
[data-mode="speaking"] .orb-core { background: var(--leaf); color: var(--leaf-ink); box-shadow: none; }
[data-mode="paused"] .orb-core, [data-mode="typing"] .orb-core { background: var(--soft); color: var(--muted); }
.orb[data-mode="done"] .orb-core { background: var(--leaf); color: var(--leaf-ink); box-shadow: none; }
.orb[data-mode="done"]::before { border-color: var(--leaf); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .orb::before { animation: none !important; transition: none; }
}

.transcript {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 2px;
  scroll-behavior: smooth;
}
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.assistant { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 4px; }
.bubble.user { align-self: flex-end; background: var(--leaf); color: var(--leaf-ink); border-bottom-right-radius: 4px; }

.controls { display: flex; flex-direction: column; gap: 10px; }
.controls .row { display: flex; gap: 8px; }
.controls .row .ghost { flex: 0 0 auto; padding: 0 14px; font-size: 16px; }
.controls .row .secondary { flex: 1; padding: 0 14px; font-size: 16px; white-space: nowrap; min-width: 0; }
.type-row { display: flex; gap: 8px; }
.type-row input { flex: 1; }

/* ---------- Generating / result ---------- */
.card { background: var(--surface); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.frame {
  background: var(--surface);
  border-radius: 22px;
  padding: 8px;
  border: 1.5px solid var(--line);
}
.frame iframe { display: block; width: 100%; height: 72vh; min-height: 520px; border: 0; border-radius: 16px; background: #fff; }
@media (min-width: 760px) {
  .frame { width: 430px; align-self: center; }
  .frame iframe { height: 760px; }
}
.connect .primary { align-self: flex-start; }
.chips { border: 0; padding: 0; margin: 0; min-width: 0; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-grid button {
  font: 500 15px/1.2 var(--font); color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 14px; cursor: pointer;
}
.chip-grid button[aria-pressed="true"] { background: var(--leaf); color: var(--leaf-ink); border-color: var(--leaf); }
.eyebrow { font-weight: 700; font-size: 0.9rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--leaf); margin-bottom: -8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chips legend { font-weight: 500; margin-bottom: 8px; padding: 0; }
.chips #when-options { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span { display: inline-block; padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--line); cursor: pointer; }
.chips input:checked + span { background: var(--leaf); color: var(--leaf-ink); border-color: var(--leaf); }
.chips input:focus-visible + span { outline: 3px solid var(--haldi); outline-offset: 2px; }

.link-row { display: flex; gap: 8px; width: 100%; max-width: 460px; }
.link-row input { flex: 1; font-size: 15px; }

/* ---------- Admin ---------- */
.admin { max-width: 1000px; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; text-align: left;
  background: var(--surface); border: 1.5px solid transparent; border-radius: 14px; padding: 12px 16px; color: var(--ink);
  font: inherit;
}
.admin-row:hover { border-color: var(--line); }
.admin-row .meta { color: var(--muted); font-size: 0.92rem; grid-column: 1 / -1; }
.pill { font-size: 0.82rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--soft); align-self: start; white-space: nowrap; }
.pill.ready { background: var(--leaf); color: var(--leaf-ink); }
.pill.hot { background: var(--haldi); color: var(--haldi-ink); }
.pill.failed { background: var(--danger); color: #fff; }
.admin-detail { display: grid; gap: 14px; }
.admin-detail section { background: var(--surface); border-radius: 16px; padding: 16px 18px; display: grid; gap: 8px; }
.admin-detail ul { margin: 0; padding-left: 20px; }
.table-wrap { overflow-x: auto; }
.admin-detail table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.admin-detail th, .admin-detail td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-detail .frame iframe { height: 640px; min-height: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input { max-width: 280px; }

/* Prototype build progress */
.gp { width: min(100%, 46ch); display: grid; gap: 12px; margin: 6px 0 4px; text-align: left; }
.gp-track { height: 10px; border-radius: 999px; background: var(--soft); overflow: hidden; border: 1px solid var(--line); }
.gp-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--leaf), var(--haldi)); transition: width .6s ease; }
.gp-meta { display: flex; justify-content: space-between; gap: 12px; font-size: .95rem; color: var(--muted); }
.gp-meta span:first-child { color: var(--ink); font-weight: 500; }
.gp-steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.gp-steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .95rem; }
.gp-steps .gp-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 12px; }
.gp-steps li.active { color: var(--ink); font-weight: 500; }
.gp-steps li.active .gp-dot { border-color: var(--leaf); border-style: dashed; animation: spin 2s linear infinite; }
.gp-steps li.done { color: var(--ink); }
.gp-steps li.done .gp-dot { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.gp-steps li.done .gp-dot::before { content: "✓"; line-height: 1; }
.gp.is-done .gp-bar { width: 100% !important; }
@media (prefers-reduced-motion: reduce) { .gp-steps li.active .gp-dot { animation: none; } }
