/* Voice Analyzer — calm, respectful, accessible. Light + dark. Phones are first-class (2026-09-13). */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1c2530;
  --muted: #5f6b7a;
  --border: #e4e8ee;
  --accent: #5b6cff;
  --accent-press: #4453e6;
  --danger: #d9455f;
  --ok: #1f9d6b;
  --shadow: 0 1px 3px rgba(20, 30, 50, .06), 0 8px 24px rgba(20, 30, 50, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420; --surface: #171d2b; --text: #e8ecf3; --muted: #9aa6b8;
    --border: #263045; --accent: #7d8bff; --accent-press: #6675ff;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
/* Ensure the `hidden` attribute always wins — flex/grid display rules below (e.g. .user-strip,
   .cancel-banner) otherwise override the UA [hidden]{display:none} and leave elements stuck visible. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* Safe-area padding: opened from the home screen (standalone) the page runs under the notch / home bar. */
.wrap {
  max-width: 560px; margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           max(64px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
button { touch-action: manipulation; }   /* taps respond immediately (no double-tap-zoom wait) */

header h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.02em; }
.tagline { margin: 0; color: var(--muted); }

.recorder {
  margin: 32px 0; padding: 32px 24px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
  text-align: center;
}
.rec-btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 600;
  padding: 14px 34px; border-radius: 999px; transition: background .15s, transform .05s;
}
.rec-btn:hover { background: var(--accent-press); }
.rec-btn:active { transform: translateY(1px); }
.rec-btn.recording { background: var(--danger); }
.rec-btn:disabled { opacity: .6; cursor: default; }
.status { margin: 18px 0 0; color: var(--muted); font-size: 14px; }
.timer { margin-top: 10px; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--danger); }

/* Mic picker + input level. The picker row is for computers; app.js hides it on phones. */
.mic-controls { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.mic-controls label { font-size: .85rem; }
.mic-controls select { max-width: 260px; }
.level-wrap { height: 14px; max-width: 420px; margin: 0 auto 12px; background: rgba(128,128,128,.25); border-radius: 7px; overflow: hidden; }
.level-bar { height: 100%; width: 0%; background: #3ba55d; transition: width .05s linear; }

.results { margin-top: 28px; }
.results h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.cards { display: grid; gap: 10px; }
.card {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.card .label { color: var(--muted); font-size: 14px; }
.card .value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card .value .unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }

/* ---- voice card (13 items, grouped; strings come localised from the backend) ---- */
.card .right { display: flex; align-items: baseline; gap: 10px; }
/* Rating-only rows have no number — the rating itself is the value, so tone it down
   to normal weight or it shouts louder than the measured rows. */
.card .value.rating-only { font-size: 15px; font-weight: 500; color: var(--muted); }
.card .chip {
  font-size: 12px; font-weight: 500; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.card.verdict { flex-direction: column; align-items: flex-start; gap: 4px; }
.card .verdict-value { font-size: 22px; line-height: 1.25; }
.card-group {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; margin: 14px 0 -2px 2px;
}
.card-note { font-size: 12px; color: var(--muted); margin: 12px 2px 0; line-height: 1.5; }

.raw { margin-top: 18px; }
.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.raw pre {
  margin: 10px 0 0; padding: 14px; overflow-x: auto; font-size: 12px; line-height: 1.5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}

/* Progress over time — one small line chart per tracked metric */
.progress { margin-top: 32px; }
.progress h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.progress-hint { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.charts { display: grid; gap: 14px; }
.chart {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 16px 12px; box-shadow: var(--shadow);
}
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.chart-title { color: var(--muted); font-size: 13px; }
.chart-latest { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-latest .unit { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }
/* Delta vs previous session — neutral (direction only, not good/bad: meaning differs per metric) */
.chart-delta { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 8px; }
.chart svg { display: block; width: 100%; height: auto; }
.spark-area { fill: var(--accent); opacity: .10; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.spark-dot-last { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.spark-axis { stroke: var(--border); stroke-width: 1; }
.chart-foot { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-size: 11px; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 6px 0 2px; }

footer { margin-top: 40px; text-align: center; }
.privacy { color: var(--ok); font-size: 13px; margin: 0 0 6px; }
.disclaimer { color: var(--muted); font-size: 12px; margin: 0; }
footer a { color: var(--accent); }

.error { color: var(--danger); }

/* Account / sign-in */
.auth-card {
  margin: 32px 0; padding: 28px 24px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
  text-align: center;
}
.auth-lead { margin: 0 0 18px; font-size: 16px; }
.g-btn-wrap { display: flex; justify-content: center; min-height: 44px; }
.auth-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.user-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 20px 0 0; padding: 10px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; font-size: 14px; color: var(--muted);
}
.user-strip strong { color: var(--text); font-weight: 600; }
.user-actions { display: flex; align-items: center; gap: 6px; }
.link-btn {
  appearance: none; background: none; border: 0; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 14px; padding: 4px 6px; border-radius: 8px;
}
.link-btn:hover { color: var(--accent-press); text-decoration: underline; }
.link-btn.danger { color: var(--danger); font-weight: 700; }
.link-btn.danger:hover { color: var(--danger); }

/* Pending-deletion banner */
.cancel-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 12px 0 0; padding: 12px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--danger);          /* fallback: browsers without color-mix() */
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  font-size: 13px;
}
.cancel-msg { color: var(--danger); font-weight: 700; }

/* Opened inside an app's built-in browser → how to get to a real one */
.inapp-banner {
  margin: 20px 0 0; padding: 14px 16px; border-radius: 12px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--accent);          /* fallback: browsers without color-mix() */
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.inapp-msg { margin: 0 0 12px; }
.inapp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inapp-btn {
  appearance: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  font: inherit; font-size: 14px; font-weight: 600; padding: 0 18px; border-radius: 999px;
}
.inapp-btn.secondary { background: transparent; color: var(--accent); }

/* Legal pages (privacy policy) — same calm surface language, reading-width text */
.legal { max-width: 680px; }
.legal-dates { display: block; margin-top: 6px; font-size: 13px; }
.legal-lead {
  margin: 28px 0 8px; padding: 18px 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.legal h2 { margin: 34px 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.legal ul { margin: 0; padding-left: 20px; }
.legal li { margin-bottom: 10px; }
.legal code { font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.legal-table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.legal-contact { color: var(--muted); }
.legal footer { margin-top: 44px; }
.legal footer a { color: var(--accent); }
/* The table is the one element that can outgrow a narrow phone — let it scroll rather than the page */
@media (max-width: 520px) { .legal-table { display: block; overflow-x: auto; } }

/* ---- Phones ---- */
@media (pointer: coarse) {
  .link-btn { padding: 10px 10px; }                 /* finger-sized tap targets for Sign out / Delete / Undo */
}
@media (max-width: 480px) {
  .wrap { padding-top: max(24px, env(safe-area-inset-top)); }
  header h1 { font-size: 24px; }
  .auth-card, .recorder { margin: 20px 0; padding: 24px 16px; }
  .rec-btn { width: 100%; max-width: 320px; min-height: 54px; font-size: 18px; }
  .user-strip, .cancel-banner { flex-wrap: wrap; }
  .user-who { min-width: 0; overflow-wrap: anywhere; }   /* long e-mail addresses wrap instead of overflowing */
  .card { flex-wrap: wrap; }
  .card .right { margin-left: auto; }
}
