*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #f5f6f8;
  --surface:      #ffffff;
  --primary:      #FF8200;
  --primary-dark: #e07000;
  --text:         #1e293b;
  --muted:        #64748b;
  --border:       #e2e8f0;
  --radius:       8px;
  --shadow:       0 1px 4px rgba(0,0,0,0.08);
}

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

/* ── HEADER ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 2rem;
  position: sticky; top: 0; z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { font-weight: 700; font-size: 1rem; color: var(--primary); letter-spacing: -0.01em; }
.header-logo {
  height: 40px;
  width: auto;
  filter: invert(52%) sepia(99%) saturate(1200%) hue-rotate(1deg) brightness(103%) contrast(104%);
}

main { max-width: 900px; margin: 0 auto; padding: 2rem 1.25rem; }

/* ── TYPOGRAPHY ── */
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem;  font-weight: 600; margin-bottom: 1rem; }
.muted { color: var(--muted); }

/* ── SHARED PAGE WRAPPER ── */
.page { max-width: 640px; margin: 0 auto; }

/* ── INTRO TEXT ── */
.intro-text { margin-bottom: 2rem; }
.intro-text p { color: var(--muted); margin-bottom: 0.6rem; }

/* ── DEMOGRAPHICS FORM ── */
.demo-form {
  background: var(--surface);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.demo-form h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
  margin-bottom: 1.5rem;
}

.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 500; margin-bottom: 0.35rem; }

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.2rem;
}
fieldset legend { font-size: 0.88rem; font-weight: 600; padding: 0 0.4rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.req { color: #ef4444; }
.opt { color: var(--muted); font-weight: 400; font-size: 0.82rem; }

/* ── BUTTONS ── */
.btn-primary {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.7rem 2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 0.25rem;
}
.btn-primary:hover  { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; transform: none; }

/* ── SURVEY PAGE ── */
.survey-page { max-width: 760px; margin: 0 auto; }

.hidden { display: none !important; }

/* Loading */
.loading-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh; gap: 1rem; color: var(--muted);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section intro */
.section-intro {
  display: flex; align-items: center; justify-content: center;
  min-height: 62vh;
}
.section-intro-inner {
  text-align: center; max-width: 460px;
  background: var(--surface); border-radius: 14px;
  padding: 2.5rem 2rem; box-shadow: var(--shadow);
}
.section-badge {
  display: inline-block;
  background: var(--primary); color: #fff;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.28rem 0.9rem; border-radius: 20px; margin-bottom: 1rem;
}
.section-intro-inner p { color: var(--muted); margin: 0.75rem 0 1.5rem; }

/* Progress */
.progress-bar  { height: 4px; background: var(--border); border-radius: 4px; margin-bottom: 0.4rem; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.35s ease; }
.progress-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 1.4rem; }

/* Question prompt */
.question-prompt { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; }

/* Clips grid */
.clips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.clip-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}
.clip-card.played { border-color: var(--primary); }
.clip-card.clip-error { border-color: #ccc; opacity: 0.6; }
.clip-error-msg { font-size: 0.85rem; color: #888; margin: 0; }
.clip-label { font-weight: 700; font-size: 1rem; color: var(--primary); margin-bottom: 0.6rem; }
.clip-card audio { width: 100%; }

/* Questions block */
.questions-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.q-item + .q-item {
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.q-label { margin-bottom: 0.7rem; font-size: 0.95rem; }

.radio-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.radio-opt {
  display: flex; align-items: center; gap: 0.4rem;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.radio-opt:hover   { border-color: var(--primary); background: rgba(37,99,235,0.04); }
.radio-opt.checked { border-color: var(--primary); background: rgba(37,99,235,0.09); font-weight: 600; }
.radio-opt input   { cursor: pointer; }

/* Nav */
.nav-row { display: flex; justify-content: flex-end; }

/* ── COMPLETE PAGE ── */
.center-page { display: flex; flex-direction: column; align-items: center; padding-top: 3rem; gap: 1.5rem; }
.complete-card {
  text-align: center; max-width: 480px; width: 100%;
  background: var(--surface); border-radius: 14px;
  padding: 2.5rem 2rem; box-shadow: var(--shadow);
}
.check-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: #22c55e; color: #fff;
  font-size: 2rem; line-height: 64px;
  margin: 0 auto 1.25rem;
}
.complete-card p { color: var(--muted); margin-top: 0.75rem; }
.small { font-size: 0.85rem; }

/* ── VOICE SUBMISSION ── */
.voice-card {
  max-width: 560px; width: 100%;
  background: var(--surface); border-radius: 14px;
  padding: 2rem; box-shadow: var(--shadow);
  margin-bottom: 3rem;
}
.voice-card h2 { margin-bottom: 0.4rem; }
.voice-card > .muted { margin-bottom: 1.25rem; }

.sentence-box {
  background: var(--bg); border: 2px solid var(--primary);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.sentence-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.5rem; }
.sentence-text { font-size: 1.1rem; font-style: italic; color: var(--text); line-height: 1.5; }

.consent-label {
  display: flex; align-items: flex-start; gap: 0.6rem;
  font-size: 0.88rem; color: var(--text); margin-bottom: 1.25rem;
  cursor: pointer; line-height: 1.5;
}
.consent-label input { margin-top: 0.2rem; flex-shrink: 0; cursor: pointer; }

.recorder-controls { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }

.btn-record {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface); border: 2px solid var(--primary);
  color: var(--primary); border-radius: var(--radius);
  padding: 0.6rem 1.4rem; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.btn-record:hover:not(:disabled) { background: var(--primary); color: #fff; }
.btn-record:disabled { border-color: var(--border); color: var(--muted); cursor: not-allowed; }
.btn-record.recording { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn-record.recording:hover { background: #dc2626; border-color: #dc2626; }

.rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: currentColor; display: inline-block;
}
.btn-record.recording .rec-dot { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }

.rec-timer { font-size: 0.9rem; font-weight: 600; color: #ef4444; font-variant-numeric: tabular-nums; }

.playback-section { margin-bottom: 1rem; }
.playback-section audio { width: 100%; margin: 0.4rem 0 0.6rem; }
.btn-rerecord {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.35rem 0.9rem;
  font-size: 0.85rem; cursor: pointer; color: var(--muted);
  transition: border-color 0.15s;
}
.btn-rerecord:hover { border-color: var(--primary); color: var(--primary); }

.success-msg { color: #22c55e; font-weight: 600; font-size: 1rem; padding: 1rem 0; }

/* ── ADMIN ── */
.submissions-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }
.submission-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.sub-meta { margin-bottom: 0.25rem; }
.sub-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; padding: 0.2rem 0.6rem;
  border-radius: 20px; margin-right: 0.5rem;
  background: var(--primary); color: #fff;
}
.sub-badge.female { background: #a855f7; }
.sub-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; }
.btn-reject {
  background: none; border: 1px solid #ef4444; color: #ef4444;
  border-radius: var(--radius); padding: 0.4rem 1rem;
  font-size: 0.85rem; cursor: pointer; transition: all 0.15s;
}
.btn-reject:hover { background: #ef4444; color: #fff; }

/* ── RESULTS PAGE ── */
.results-page { max-width: 960px; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.tab {
  padding: 0.45rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer; font-size: 0.88rem;
  transition: all 0.15s;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
.result-table-wrap {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.result-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.result-table th {
  text-align: left; padding: 0.45rem 0.5rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.result-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); }
.result-table tbody tr:last-child td { border-bottom: none; }
.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: var(--border); font-size: 0.72rem; margin-right: 0.4rem;
}
.empty { text-align: center; color: var(--muted); padding: 2rem; font-style: italic; }

.chart-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.chart-wrap { background: var(--surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .form-row, .clips-grid, .results-grid, .chart-row { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}
