/* SelfVoice web app — design system shared with the landing (index.html)
   and the design_ref prototype: cream background, terracotta accent,
   Lora (serif headings/phrases) + Manrope (body). No build step. */

:root {
  --bg:        #F0EEE6;
  --card:      #FAF9F5;
  --border:    #E4E0D5;
  --ink:       #1F1E1D;
  --ink-soft:  #55524B;
  --muted:     #6B675F;
  --muted-2:   #8A867C;
  --faint:     #A8A498;
  --accent:    #D97757;
  --accent-hov:#C8663F;
  --accent-2:  #C9A08A;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Manrope, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}
::selection { background: #D9775733; }
button, textarea, input { font-family: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes sv-fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sv-spin { to { transform: rotate(360deg); } }
@keyframes sv-rec-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes sv-wave { 0%,100% { transform: scaleY(0.18); } 50% { transform: scaleY(1); } }
@keyframes sv-breathe { 0%,100% { transform: scale(0.9); opacity: 0.5; } 50% { transform: scale(1.35); opacity: 0.06; } }
@keyframes sv-core { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* ---------- Header ---------- */
.site-header {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg), var(--bg) 70%, #F0EEE600);
}
.logo {
  font-family: Lora, serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.logo .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }
.lang-switch {
  display: flex; align-items: center; gap: 2px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 30px; padding: 3px;
}
.lang-switch button {
  border: none; border-radius: 24px; padding: 6px 15px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .4s ease, color .4s ease;
  background: transparent; color: var(--muted-2);
}
.lang-switch button.active { background: var(--accent); color: var(--card); }

/* ---------- Layout ---------- */
main {
  width: 100%;
  margin: 0 auto;
  padding: 8px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.screen { width: 100%; max-width: 520px; margin-top: 12px; animation: sv-fade 0.6s ease both; }
.screen--wide { max-width: 620px; }
.screen--narrow { max-width: 440px; }
.center { text-align: center; display: flex; flex-direction: column; align-items: center; }

/* ---------- Typography ---------- */
.kicker {
  font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 18px;
}
.h-hero {
  font-family: Lora, serif; font-weight: 500;
  font-size: clamp(30px, 8vw, 42px); line-height: 1.18;
  margin: 0 0 20px; letter-spacing: -0.01em; text-wrap: balance;
}
.h-q {
  font-family: Lora, serif; font-weight: 500;
  font-size: clamp(24px, 6vw, 32px); line-height: 1.28;
  margin: 0 0 28px; letter-spacing: -0.01em; text-wrap: balance;
}
.h-sec {
  font-family: Lora, serif; font-weight: 500;
  font-size: 30px; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.01em;
}
.subtitle { font-size: 18px; line-height: 1.6; color: var(--ink-soft); margin: 0 auto 32px; max-width: 400px; text-wrap: pretty; }
.lead { font-size: 16px; line-height: 1.55; color: var(--muted); margin: 0 0 28px; max-width: 420px; }
.lead.center { margin-left: auto; margin-right: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 56px; padding: 0 34px; border: none; border-radius: 40px;
  background: var(--accent); color: var(--card);
  font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none;
  transition: transform .5s ease, background .5s ease, opacity .3s ease;
}
.btn:hover { background: var(--accent-hov); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; background: var(--accent); }
.btn--block { width: 100%; }
.btn--tall { height: 58px; font-size: 17px; padding: 0 40px; }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-dark:hover { background: #000; }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 56px; padding: 0 24px; border: 1px solid var(--border); border-radius: 40px;
  background: transparent; color: var(--muted); font-weight: 500; font-size: 16px; cursor: pointer;
  transition: background .4s ease, border-color .4s ease;
}
.btn-outline:hover { background: var(--card); border-color: var(--accent); }
.btn-link {
  background: none; border: none; color: var(--faint); font-size: 14px;
  cursor: pointer; padding: 6px 0; transition: color .3s ease;
}
.btn-link:hover { color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; margin-top: 32px; }
.row .btn { flex: 1; }

/* ---------- Interview ---------- */
.q-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.q-meta .step { color: var(--muted-2); letter-spacing: 0.04em; }
.q-meta .opt { color: var(--faint); }
.progress { height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 44px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .7s cubic-bezier(.4,0,.2,1); }
.field {
  width: 100%; resize: none; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 20px; font-size: 18px; line-height: 1.5; color: var(--ink);
  transition: border-color .4s ease;
}
.field:focus { outline: none; border-color: var(--accent); }
.hint { margin-top: 14px; font-size: 14px; color: var(--accent); min-height: 18px; }

/* ---------- Choice cards (style / count / after-Q2) ---------- */
.choice-list { display: flex; flex-direction: column; gap: 12px; }
.choice {
  text-align: left; display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 20px; cursor: pointer; width: 100%;
  transition: box-shadow .4s ease, border-color .3s ease;
}
.choice:hover { border-color: var(--accent-2); }
.choice.sel { box-shadow: 0 0 0 2px var(--accent); border-color: var(--accent); }
.choice .ic {
  flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 18px;
}
.choice .tt { flex: 1; }
.choice .tt b { display: block; font-weight: 600; font-size: 16px; margin-bottom: 2px; }
.choice .tt span { display: block; font-size: 14px; color: var(--muted-2); }
.choice .chk { flex: none; color: var(--accent); font-size: 18px; }

.seg { display: flex; gap: 10px; }
.seg button {
  flex: 1; height: 60px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--card); color: var(--ink); font-weight: 600; font-size: 18px;
  cursor: pointer; transition: box-shadow .3s ease, border-color .3s ease;
  position: relative;
}
.seg button .sub { display: block; font-size: 11px; font-weight: 500; color: var(--faint); margin-top: 2px; }
.seg button.sel { box-shadow: 0 0 0 2px var(--accent); border-color: var(--accent); }
.label { font-size: 14px; color: var(--muted-2); margin: 26px 0 12px; letter-spacing: 0.02em; }

/* ---------- Loader (generating / assembling) ---------- */
.loader { display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: 72px; }
.spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: sv-spin 1.4s linear infinite; margin-bottom: 36px;
}
.loader h2 { font-family: Lora, serif; font-weight: 500; font-size: 27px; line-height: 1.3; margin: 0 0 10px; letter-spacing: -0.01em; }
.loader .status { font-size: 16px; color: var(--muted); margin: 0 0 34px; min-height: 24px; }
.bar { width: 100%; max-width: 360px; height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }

/* ---------- Record ---------- */
.rec-head { margin-bottom: 24px; }
.dots { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.dots > i { flex: 1; height: 3px; border-radius: 3px; background: var(--border); transition: background .5s ease; }
.dots > i.done { background: var(--accent); }
.dots > i.cur { background: var(--accent-2); }
.counter { font-size: 13px; color: var(--muted-2); letter-spacing: 0.04em; }

.rec-list { display: flex; flex-direction: column; gap: 12px; }
.rec-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start;
  transition: border-color .3s ease;
}
.rec-row.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.rec-row.recd { border-color: var(--accent-2); }
.rec-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: Lora, serif; font-size: 13px; color: var(--faint); margin-top: 6px;
}
.rec-row.recd .rec-num { background: var(--accent); color: var(--card); }
.rec-body { flex: 1; min-width: 0; }
.rec-text { font-family: Lora, serif; font-size: 18px; line-height: 1.45; color: var(--ink); }
.rec-controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.mic {
  flex: none; width: 52px; height: 52px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--card); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px -12px #D9775788; transition: background .3s ease, transform .3s ease;
}
.mic:hover { background: var(--accent-hov); }
.mic:disabled { background: var(--faint); box-shadow: none; cursor: default; }
.mic.rec { animation: sv-core 3.5s ease-in-out infinite; }
.mic .glyph-mic { width: 16px; height: 22px; border-radius: 8px; background: var(--card); position: relative; }
.mic .glyph-stop { width: 18px; height: 18px; border-radius: 5px; background: var(--card); }
.mic-ring { position: relative; flex: none; width: 52px; height: 52px; }
.mic-ring::before, .mic-ring::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--accent); animation: sv-breathe 3.5s ease-in-out infinite;
}
.mic-ring::after { animation-delay: 1.6s; }
.mic-ring .mic { position: relative; z-index: 2; }

.rec-status { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.rec-status .rdot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: sv-rec-dot 1.2s ease-in-out infinite; }
.rec-status .timer { color: var(--muted-2); font-variant-numeric: tabular-nums; }
.wave { display: inline-flex; align-items: center; gap: 3px; height: 22px; }
.wave > span { width: 3px; height: 20px; border-radius: 3px; background: var(--accent); opacity: .75; transform-origin: center; animation: sv-wave .9s ease-in-out infinite; }
.tag-ok { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.tag-ok .chk { color: var(--accent); }
.mini {
  height: 40px; padding: 0 16px; border: 1px solid var(--border); border-radius: 40px;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: background .3s ease, border-color .3s ease;
}
.mini:hover { background: var(--bg); border-color: var(--accent); }
.mini .ic { color: var(--accent); }

.sticky-cta { position: sticky; bottom: 0; padding: 18px 0 6px; margin-top: 24px; background: linear-gradient(#F0EEE600, var(--bg) 40%); }

/* ---------- Done / player ---------- */
.player-card { background: var(--card); border: 1px solid var(--border); border-radius: 22px; padding: 24px; text-align: left; }
.player-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.player-top .ic { flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 22px; }
.player-top .tt b { display: block; font-weight: 600; font-size: 16px; margin-bottom: 3px; }
.player-top .tt span { display: block; font-size: 13px; color: var(--muted-2); }
audio { width: 100%; margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 14px 24px; border-radius: 40px;
  font-size: 14px; z-index: 50; animation: sv-fade .4s ease both;
  box-shadow: 0 12px 30px -12px #1F1E1D66; max-width: calc(100% - 40px); text-align: center;
}

/* ---------- Notice / resume banner ---------- */
.notice {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 20px; margin-bottom: 20px; text-align: left;
}
.notice p { margin: 0 0 14px; font-size: 15px; color: var(--ink-soft); line-height: 1.5; }
.notice .row { margin-top: 0; }

@media (max-width: 420px) {
  .site-header { padding: 16px; }
  main { padding: 8px 16px 40px; }
  .btn, .btn-outline { padding: 0 22px; }
  .row { gap: 10px; }
}
