:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-2: #f1ece4;
  --ink: #23201c;
  --ink-2: #5d564d;
  --muted: #8a8277;
  --line: #e4ddd2;
  --accent: #b4532a;        /* terracotta */
  --accent-ink: #ffffff;
  --accent-soft: #f6e4da;
  --good: #2f7d4f;
  --good-soft: #e1f1e6;
  --warn: #9a6a00;
  --warn-soft: #fbf0d6;
  --bad: #b23a32;
  --bad-soft: #f8e1df;
  --info: #2e5f8a;
  --info-soft: #e1ecf6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .06), 0 4px 16px rgba(35, 32, 28, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513; --surface: #211e1b; --surface-2: #2a2622; --ink: #f1ebe3; --ink-2: #c9c0b4;
    --muted: #958c80; --line: #37322c; --accent: #e07a4b; --accent-ink: #1b1411; --accent-soft: #3a2519;
    --good: #6cc48f; --good-soft: #1f3327; --warn: #e2b54d; --warn-soft: #362c14; --bad: #ec7b72;
    --bad-soft: #3b1f1c; --info: #7fb0dc; --info-soft: #1c2a37; --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Mukta", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--bad); min-height: 1.2em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.25rem; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.brand.big { font-size: 1.6rem; }
.mark {
  width: 1.4em; height: 1.4em; border-radius: 50%; background: var(--accent); position: relative; flex: none;
  background-image: linear-gradient(var(--accent-ink), var(--accent-ink)), linear-gradient(var(--accent-ink), var(--accent-ink)), linear-gradient(var(--accent-ink), var(--accent-ink));
  background-size: 2px 38%, 2px 62%, 2px 30%; background-repeat: no-repeat;
  background-position: 32% 50%, 50% 50%, 68% 50%;
}
.tabs { display: flex; gap: .25rem; flex: 1; }
.tabs a { color: var(--ink-2); padding: .4rem .8rem; border-radius: 999px; font-weight: 500; }
.tabs a.active { background: var(--ink); color: var(--bg); }
.bottom-tabs { display: none; }

.view { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1.25rem 6rem; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
#camp-list { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1.5rem 0 .75rem; }
.section-head:first-child { margin-top: 0; }

.stat { padding: 1rem 1.1rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--ink-2); font-size: .82rem; }

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center; text-decoration: none;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .7rem; font-size: .875rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: auto; margin: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: .25rem; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .08rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; display: inline-block; }
.live-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--bad); display: inline-block; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* ---------- lists / tables ---------- */
.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list-item { display: flex; gap: .9rem; align-items: center; padding: .8rem 1rem; border-top: 1px solid var(--line); color: inherit; }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { color: var(--muted); font-size: .85rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .6rem; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; border-top: 0; font-size: .8rem; }
.table-wrap { overflow-x: auto; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; }
.progress .p-done { background: var(--good); }
.progress .p-fail { background: var(--bad); }
.progress .p-active { background: var(--warn); }

/* ---------- transcript ---------- */
.transcript { display: flex; flex-direction: column; gap: .5rem; padding: .25rem 0; }
.bubble { max-width: 82%; padding: .55rem .8rem; border-radius: 14px; line-height: 1.45; }
.bubble.assistant { align-self: flex-start; background: var(--accent-soft); border-bottom-left-radius: 4px; }
.bubble.user { align-self: flex-end; background: var(--surface-2); border-bottom-right-radius: 4px; }
.bubble .who { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; }
.bubble.cut { opacity: .7; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
audio { width: 100%; margin-top: .5rem; }

/* ---------- test call ---------- */
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: .9rem; padding: 1.5rem 0 1rem; }
.mic-btn {
  width: 112px; height: 112px; border-radius: 50%; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent);
  transition: box-shadow .12s ease;
}
.mic-btn.on { background: var(--bad); }
.level { width: 220px; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.level > span { display: block; height: 100%; width: 0; background: var(--good); transition: width .08s linear; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: .55rem; align-items: baseline; padding: .3rem 0; }
.checklist .ok { color: var(--good); font-weight: 700; }
.checklist .no { color: var(--bad); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.75rem; box-shadow: var(--shadow); display: grid; gap: .9rem; }

.callout { border-radius: 12px; padding: .7rem .9rem; font-size: .92rem; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.info { background: var(--info-soft); color: var(--info); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .topbar { padding: .6rem 16px; }
  .tabs { display: none; }
  .view { padding: 1rem 16px 6.5rem; }
  .grid.two, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface);
    border-top: 1px solid var(--line); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .bottom-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .75rem; color: var(--muted); gap: .1rem; font-weight: 600; }
  .bottom-tabs a span { font-size: 1.15rem; line-height: 1; }
  .bottom-tabs a.active { color: var(--accent); }
  .stat .value { font-size: 1.6rem; }
  .bubble { max-width: 90%; }
  .hide-sm { display: none; }
}
