/* ── Reset & Variables ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f7f5ff;
  --surface:   #ffffff;
  --border:    #e8e4f8;
  --accent:    #7c3aed;
  --accent2:   #ec4899;
  --grad:      linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
  --grad-soft: linear-gradient(135deg, rgba(124,58,237,.08) 0%, rgba(236,72,153,.08) 100%);
  --success:   #10b981;
  --warn:      #f59e0b;
  --error:     #ef4444;
  --muted:     #6b7280;
  --text:      #111827;
  --text-dim:  #374151;
  --card-r:    16px;
  --shadow:    0 2px 16px rgba(124,58,237,.08);
  --shadow-md: 0 4px 24px rgba(124,58,237,.12);

  --easy:   #10b981;
  --medium: #f59e0b;
  --hard:   #ef4444;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  box-shadow: 0 1px 8px rgba(124,58,237,.06);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  max-width: unset;
  margin: unset;
}
.logo { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; font-weight: 800; color: var(--text); }
.logo-icon { font-size: 1.5rem; }
.header-sub { color: var(--muted); font-size: .82rem; margin-top: .1rem; }

/* ── Header nav ──────────────────────────────────────────────────── */
.header-nav {
  display: flex;
  gap: .3rem;
  margin: 0 .5rem;
}
.header-nav .nav-link {
  font-size: .85rem;
  color: var(--muted);
  text-decoration: none;
  padding: .35rem .75rem;
  border-radius: 8px;
  transition: all .2s;
  font-weight: 500;
}
.header-nav .nav-link:hover {
  color: var(--accent);
  background: rgba(124,58,237,.07);
}

/* ── Auth ────────────────────────────────────────────────────────── */
.header-auth { display: flex; align-items: center; margin-left: auto; }

.btn-google-signin {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #fff;
  color: #3c4043;
  border: 1.5px solid #dadce0;
  border-radius: 8px;
  padding: .45rem 1rem;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s;
  white-space: nowrap;
}
.btn-google-signin:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); border-color: #b0b5ba; }

.user-info { display: flex; align-items: center; gap: .6rem; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.user-name {
  font-size: .85rem; color: var(--text); font-weight: 600;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-signout {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: .3rem .75rem;
  font-size: .78rem;
  cursor: pointer;
  font-weight: 600;
  transition: all .2s;
}
.btn-signout:hover { border-color: var(--error); color: var(--error); }

/* ── Live banner ──────────────────────────────────────────────────── */
.live-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: .7rem 1rem;
  background: var(--grad-soft);
  border-bottom: 1px solid rgba(124,58,237,.15);
  font-size: .88rem;
  color: var(--text-dim);
  flex-wrap: wrap;
  text-align: center;
}
.btn-live-banner {
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: .83rem;
  padding: .35rem 1rem;
  border-radius: 20px;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .2s, transform .2s;
}
.btn-live-banner:hover { opacity: .88; transform: translateY(-1px); }

/* ── Main ─────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* ── Controls Row ────────────────────────────────────────────────── */
.controls-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.filter-group { display: flex; flex-direction: column; gap: .3rem; }
.filter-group label {
  font-size: .75rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 700;
}
select {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: .5rem .9rem;
  border-radius: 10px;
  font-size: .9rem;
  cursor: pointer;
  transition: border-color .2s;
  font-weight: 500;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.1); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  padding: .6rem 1.3rem;
  border: none;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124,58,237,.25);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(124,58,237,.35); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-record {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
  border-radius: 10px;
}
.btn-record.recording { border-color: var(--error); color: var(--error); background: rgba(239,68,68,.05); }

.rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--error);
  animation: none;
}
.recording .rec-dot { animation: blink .8s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--card-r);
  padding: 1.5rem 1.7rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--shadow);
}

/* ── Question Card ───────────────────────────────────────────────── */
.card-meta { display: flex; gap: .6rem; margin-bottom: .9rem; flex-wrap: wrap; }
.badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .25rem .7rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.topic-badge {
  background: rgba(124,58,237,.1);
  color: var(--accent);
  border: 1px solid rgba(124,58,237,.2);
}
.diff-badge[data-diff="fresher"] { background: rgba(16,185,129,.1); color: var(--easy);   border: 1px solid rgba(16,185,129,.25); }
.diff-badge[data-diff="mid"]     { background: rgba(245,158,11,.1); color: var(--medium); border: 1px solid rgba(245,158,11,.25); }
.diff-badge[data-diff="senior"]  { background: rgba(239,68,68,.1);  color: var(--error);  border: 1px solid rgba(239,68,68,.25); }

.question-text { font-size: 1.1rem; font-weight: 600; color: var(--text); line-height: 1.7; }
.hint-text { font-size: .82rem; color: var(--muted); margin-top: .6rem; font-style: italic; }

/* ── Recorder ─────────────────────────────────────────────────────── */
.section-title { font-size: .95rem; font-weight: 700; margin-bottom: .9rem; color: var(--text-dim); }
canvas#waveCanvas {
  width: 100%;
  height: 80px;
  background: var(--grad-soft);
  border-radius: 10px;
  margin-bottom: .8rem;
  display: block;
  border: 1px solid rgba(124,58,237,.12);
}
.recorder-controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.timer { font-variant-numeric: tabular-nums; font-size: 1rem; color: var(--muted); min-width: 3.5rem; font-weight: 700; }
audio { flex: 1; min-width: 200px; accent-color: var(--accent); }

#submitBtn { width: 100%; margin-top: .4rem; padding: .8rem; font-size: 1rem; }

/* ── Loading ──────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(247,245,255,.88);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.2rem; z-index: 999;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--muted); font-size: .95rem; font-weight: 600; }

.loading-steps { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.loading-steps .step {
  font-size: .85rem; color: var(--muted);
  padding: .3rem .9rem; border-radius: 20px;
  transition: all .3s ease;
}
.loading-steps .step.active {
  color: var(--accent);
  background: rgba(124,58,237,.1);
  font-weight: 700;
}

.hidden { display: none !important; }

/* ── Overall Score ────────────────────────────────────────────────── */
.overall-row {
  display: flex;
  align-items: center;
  gap: 1.8rem;
  margin-bottom: 1.6rem;
  background: var(--grad-soft);
  border: 1.5px solid rgba(124,58,237,.15);
  border-radius: var(--card-r);
  padding: 1.4rem 1.8rem;
}
.overall-score-wrap { position: relative; width: 90px; flex-shrink: 0; }
.score-ring { width: 90px; height: 90px; transform: rotate(-90deg); }
.ring-bg   { fill: none; stroke: var(--border); stroke-width: 10; }
.ring-fill { fill: none; stroke: url(#scoreGrad); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.score-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; line-height: 1;
}
.score-number { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.score-unit   { font-size: .65rem; color: var(--muted); font-weight: 600; }
.overall-meta h2 { font-size: 1.2rem; margin-bottom: .3rem; font-weight: 800; }
.score-breakdown { color: var(--muted); font-size: .83rem; }

/* ── Results Grid ─────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-bottom: 1.4rem;
}
@media (max-width: 680px) { .results-grid { grid-template-columns: 1fr; } }

.result-card { display: flex; flex-direction: column; gap: 1rem; }
.result-title { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: .4rem; }
.icon { font-size: 1.1rem; }

/* Depth badge */
.depth-row { display: flex; align-items: center; gap: .8rem; }
.depth-badge {
  font-size: .78rem; font-weight: 700; padding: .25rem .8rem;
  border-radius: 20px; text-transform: uppercase;
  background: rgba(124,58,237,.1); color: var(--accent);
  border: 1px solid rgba(124,58,237,.2);
}
.tech-score-pill { font-weight: 800; font-size: .9rem; color: var(--success); }

/* Concepts */
.concepts-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .3rem; }
.covered-label { color: var(--success); }
.missing-label { color: var(--error); margin-top: .6rem; }
.concepts-list { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; }
.concepts-list li { font-size: .78rem; padding: .22rem .6rem; border-radius: 20px; font-weight: 600; }
.covered li { background: rgba(16,185,129,.1); color: var(--success); border: 1px solid rgba(16,185,129,.2); }
.missing li  { background: rgba(239,68,68,.1);  color: var(--error);   border: 1px solid rgba(239,68,68,.2); }

.prose-list { list-style: none; display: flex; flex-direction: column; gap: .35rem; }
.prose-list li { font-size: .875rem; color: var(--text-dim); padding-left: 1.1rem; position: relative; }
.prose-list li::before { content: "›"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

/* Detailed feedback */
.detailed-feedback-wrap { border-top: 1px solid var(--border); padding-top: .8rem; }
.detailed-feedback-wrap summary { cursor: pointer; font-size: .83rem; color: var(--muted); font-weight: 700; }
.detailed-feedback-text { margin-top: .7rem; font-size: .875rem; color: var(--text-dim); line-height: 1.75; white-space: pre-wrap; }

/* ── Gauges ───────────────────────────────────────────────────────── */
.gauge-row { display: flex; gap: 1rem; justify-content: space-around; margin-bottom: .6rem; }
.gauge-item { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.gauge-arc-wrap { position: relative; width: 80px; }
.gauge-svg { width: 80px; overflow: visible; }
.gauge-track { fill: none; stroke: var(--border); stroke-width: 8; stroke-linecap: round; }
.gauge-value { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.gauge-number {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  font-size: .95rem; font-weight: 800; color: var(--text);
}
.gauge-label { font-size: .75rem; color: var(--muted); text-align: center; font-weight: 600; }

/* ── Metrics Grid ─────────────────────────────────────────────────── */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.metric-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: .6rem .8rem;
}
.metric-icon { font-size: 1.1rem; flex-shrink: 0; }
.metric-val { font-size: .95rem; font-weight: 800; color: var(--text); }
.metric-key { font-size: .72rem; color: var(--muted); font-weight: 600; }

.audio-feedback-box {
  font-size: .875rem;
  color: var(--text-dim);
  background: rgba(124,58,237,.05);
  border: 1.5px solid rgba(124,58,237,.12);
  border-radius: 10px;
  padding: .9rem 1.1rem;
  line-height: 1.75;
}

/* ── Transcript / Ideal Answer ────────────────────────────────────── */
.transcript-wrap summary {
  cursor: pointer; font-size: .87rem; color: var(--accent);
  font-weight: 700; padding: .3rem 0;
}
.transcript-wrap summary:hover { opacity: .8; }
.transcript-text {
  margin-top: .8rem; font-size: .875rem;
  color: var(--text-dim); line-height: 1.8; font-style: italic;
}

.try-again-row { text-align: center; margin-top: .4rem; }

/* ── Feedback Banner ──────────────────────────────────────────────── */
.feedback-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 1.8rem 1rem;
  margin-top: 2rem;
  background: var(--grad-soft);
  border-top: 1px solid rgba(124,58,237,.15);
  border-bottom: 1px solid rgba(124,58,237,.15);
  flex-wrap: wrap;
}
.feedback-banner p { font-size: 1rem; color: var(--text); margin: 0; font-weight: 500; }
.btn-feedback {
  display: inline-block;
  padding: .65rem 1.5rem;
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  border-radius: 10px;
  text-decoration: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 2px 12px rgba(124,58,237,.25);
}
.btn-feedback:hover { opacity: .88; transform: translateY(-1px); }

/* ── Footer ───────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.4rem;
  color: var(--muted);
  font-size: .8rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.feedback-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.feedback-link:hover { text-decoration: underline; }
