/* Hausruf SPA. One stylesheet, no framework — the app is five screens. */

:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1b1c1a;
  --muted: #6a6f6a;
  --line: #e2e1dc;
  --accent: #1f5c3d;
  --accent-ink: #ffffff;
  --warn: #8a5a12;
  --warn-bg: #fdf3e2;
  --bad: #8c2f24;
  --good: #1f5c3d;
  --good-bg: #e9f2ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f24;
    --ink: #eceae4;
    --muted: #9aa0a6;
    --line: #2c3037;
    --accent: #4fae7d;
    --accent-ink: #10241a;
    --warn: #e2b872;
    --warn-bg: #2a2418;
    --bad: #e08b7f;
    --good: #7ed3a5;
    --good-bg: #17251d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 18px; letter-spacing: -.01em; }
.mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 20px;
}
.tagline { color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-link { color: var(--accent); font-size: 14px; font-weight: 600; text-decoration: none; }
.topbar-link:hover { text-decoration: underline; }
.foot a { color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
#identity { display: flex; align-items: center; gap: 8px; }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 24px) 60px;
}

.foot {
  max-width: 860px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 24px) 48px;
  color: var(--muted); font-size: 13px;
}

/* ---- cards & steps ------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; }
.card h3 { margin: 22px 0 8px; font-size: 15px; }
.lede { margin: 0 0 20px; color: var(--muted); }

.steps { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.steps li {
  list-style: none; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
}
.steps li.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.steps li.done { color: var(--accent); border-color: var(--accent); }

/* ---- forms --------------------------------------------------------- */

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; }
.hint { font-weight: 400; color: var(--muted); }

input[type=text], input[type=tel], input[type=email], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; min-width: 0; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button.small { padding: 7px 12px; font-size: 14px; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 24px; flex-wrap: wrap; }

details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-size: 14px; font-weight: 600; }

/* ---- media picker -------------------------------------------------- */

.drop {
  margin-top: 8px; border: 1px dashed var(--line); border-radius: 12px;
  padding: 18px; text-align: center; color: var(--muted); background: var(--bg);
}
.drop.hot { border-color: var(--accent); color: var(--accent); }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 1;
}
.thumb .frames {
  position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; text-align: center;
  background: rgba(0,0,0,.6); color: #fff;
}

/* ---- report -------------------------------------------------------- */

.badge {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.badge.urgent { color: var(--bad); border-color: var(--bad); }
.badge.ok { color: var(--good); border-color: var(--good); background: var(--good-bg); }
.badge.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.bullets { margin: 6px 0 0; padding-left: 20px; }
.bullets li { margin-bottom: 4px; }

.script {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; font-size: 14px;
}
.script .de { font-style: normal; }
.script p { margin: 0 0 8px; }
.script p:last-child { margin: 0; }

.notice {
  border: 1px solid var(--line); border-left: 3px solid var(--warn);
  background: var(--warn-bg); color: var(--warn);
  border-radius: 8px; padding: 10px 14px; font-size: 14px; margin: 16px 0;
}
.notice.bad { border-left-color: var(--bad); color: var(--bad); background: transparent; }
.reanalyse { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.reanalyse button { padding: 6px 14px; font-size: 14px; }

/* ---- choosing who to call (§8a) ------------------------------------ */

.pickbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin: 18px 0 10px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.pickbar label { display: block; margin-bottom: 4px; }
.pickbar select { width: auto; min-width: 72px; }
.pickbar-right { display: flex; align-items: center; gap: 10px; }
button.small { padding: 5px 12px; font-size: 13px; }

/* The rank number doubles as the tick box: position IS the call order. */
.pick { position: relative; display: inline-flex; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pick .rank {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: 50%;
  font-size: 13px; color: var(--muted); background: transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.pick input:checked + .rank { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick input:focus-visible + .rank { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick input:disabled + .rank { opacity: .4; cursor: not-allowed; }
.item.off { opacity: .55; }
.item.off .name { text-decoration: line-through; text-decoration-thickness: 1px; }

.rowbadges { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
.rowbadges .badge { font-size: 11px; padding: 1px 7px; }
.was-called { color: var(--accent); }
.rehearse-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.rehearse-bar .hint { flex: 1 1 240px; }

/* ---- the call timeline (§8b) --------------------------------------- */

.timeline .item { align-items: center; }
.timeline .meta.bad { color: var(--bad); }

/* ---- specialists & results ----------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item .n {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.item .body { flex: 1 1 auto; min-width: 0; }
.item .name { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 13px; }
.item .side { text-align: right; font-size: 13px; white-space: nowrap; }

.item.live .n { border-color: var(--accent); color: var(--accent); }
.item.live .n::after { content: ''; }
.dialling { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

.progress { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.bar { flex: 1 1 auto; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
.count { font-variant-numeric: tabular-nums; font-weight: 600; }

.offer { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.offer.best { border-color: var(--accent); }
.offer.chosen { border-color: var(--accent); background: var(--good-bg); }
.offer .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.offer dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 10px 0 0; font-size: 14px; }
.offer dt { color: var(--muted); }
.offer dd { margin: 0; }

/* ---- test-call modal ----------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; padding: 16px; z-index: 20;
}
.demo-card {
  background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line);
  width: min(560px, 100%); max-height: min(86vh, 720px); overflow: auto; padding: 22px;
  box-shadow: var(--shadow);
}
.demo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.demo-head button { padding: 4px 10px; }
.crib { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 14px 0; font-size: 14px; }
.crib dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; }
.crib dt { color: var(--muted); }
.crib dd { margin: 0; }
.transcript { max-height: 220px; overflow: auto; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.bubble { padding: 8px 12px; border-radius: 12px; font-size: 14px; max-width: 85%; }
.bubble.agent { background: var(--good-bg); align-self: flex-start; }
.bubble.callee { background: var(--bg); border: 1px solid var(--line); align-self: flex-end; }
.demo-empty { color: var(--muted); font-size: 14px; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.live-dot.speaking { background: var(--accent); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .dialling { animation: none; }
}
