:root {
  --green: #059669;
  --green-dark: #047857;
  --red: #dc2626;
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1c1f1d;
  --muted: #6b726e;
  --line: #e3e6e3;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111412; --card: #1b1f1c; --text: #eef1ee; --muted: #9aa39d; --line: #2b302c; }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
header { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: inherit; text-decoration: none; }
.brand img { border-radius: 7px; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.35rem; margin: 4px 0 12px; line-height: 1.3; }
h2 { font-size: 1rem; margin: 24px 0 8px; color: var(--muted); font-weight: 600; }
a { color: var(--green); }
.muted { color: var(--muted); font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px;
}
button.primary, .btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
button.danger { color: var(--red); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
textarea, input[type=text], input[type=password] {
  width: 100%; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 70px; }
.qlist a { display: block; color: inherit; text-decoration: none; }
.qlist .card:active { background: var(--line); }

/* recorder */
.recorder { text-align: center; padding: 20px 14px; }
.recbtn {
  width: 132px; height: 132px; border-radius: 50%; border: 6px solid var(--line); background: var(--red);
  color: #fff; font-weight: 700; font-size: 1.05rem; justify-content: center; margin: 4px auto 10px;
  box-shadow: 0 6px 18px rgba(220, 38, 38, .3); transition: transform .1s;
}
.recbtn:active { transform: scale(.96); }
.recbtn.on { border-radius: 28px; background: #7f1d1d; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(220, 38, 38, .12); } }
.timer { font: 600 1.6rem ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px auto 0; max-width: 240px; }
.meter div { height: 100%; width: 0; background: var(--green); transition: width .08s; }

/* answers */
.answer audio { width: 100%; margin: 8px 0 4px; }
.answer .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.answer .label { border: none; padding: 2px 0; font-weight: 600; background: transparent; }
.transcript p { margin: 6px 0; }
.voice { font-weight: 600; font-size: .8rem; padding: 1px 7px; border-radius: 99px; margin-right: 6px; color: #fff; }
.v-A { background: #0f766e; } .v-B { background: #b45309; } .v-C { background: #6d28d9; }
.v-D { background: #be185d; } .v-E { background: #1d4ed8; }
.status { font-size: .85rem; color: var(--muted); }
.status.failed { color: var(--red); }
.spin { display: inline-block; width: .8em; height: .8em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: r .8s linear infinite; vertical-align: -1px; }
@keyframes r { to { transform: rotate(360deg); } }
.actions { margin-top: 8px; }
.actions button { padding: 5px 10px; font-size: .85rem; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1c1f1d; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: opacity .2s; max-width: 90vw;
}
#toast.show { opacity: .95; }
