/* ════════════════════════════════════════════════════
   LectureScript — Professional Light Theme Stylesheet
   ════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────── */
:root {
  /* Brand / Palette */
  --blue-50:    #eff6ff;
  --blue-100:   #dbeafe;
  --blue-200:   #bfdbfe;
  --blue-500:   #3b82f6;
  --blue-600:   #2563eb;
  --blue-700:   #1d4ed8;
  --blue-800:   #1e40af;

  --green-50:   #f0fdf4;
  --green-100:  #dcfce7;
  --green-600:  #16a34a;
  --green-700:  #15803d;

  --amber-50:   #fffbeb;
  --amber-100:  #fef3c7;
  --amber-500:  #f59e0b;
  --amber-600:  #d97706;
  --amber-700:  #b45309;

  --red-50:     #fef2f2;
  --red-100:    #fee2e2;
  --red-600:    #dc2626;

  --slate-50:   #f8fafc;
  --slate-100:  #f1f5f9;
  --slate-200:  #e2e8f0;
  --slate-300:  #cbd5e1;
  --slate-400:  #94a3b8;
  --slate-500:  #64748b;
  --slate-600:  #475569;
  --slate-700:  #334155;
  --slate-800:  #1e293b;
  --slate-900:  #0f172a;

  /* Semantic */
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     var(--slate-200);
  --border-focus: var(--blue-600);
  --text:       var(--slate-800);
  --text-dark:  var(--slate-900);
  --muted:      var(--slate-500);
  --primary:    var(--blue-600);
  --primary-h:  var(--blue-700);
  --primary-lt: var(--blue-50);

  /* Geometry */
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:     0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.03);
  --shadow-md:  0 4px 16px rgba(15, 23, 42, 0.08);

  /* Spacing */
  --gap:        20px;

  /* Typography */
  --font:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Motion */
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
  --dur:        180ms;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background-color: var(--bg);
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--gap);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--slate-900);
}

.brand-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--slate-900);
}

.nav-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue-800);
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: 999px;
  padding: 3px 12px;
  letter-spacing: 0.01em;
}

/* ── Hero / Header Section ──────────────────────────── */
.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 44px var(--gap) 36px;
  text-align: center;
}

.hero-inner {
  max-width: 680px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(1.8rem, 4.5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 10px;
  color: var(--slate-900);
}

.gradient-text {
  color: var(--primary);
  background: none;
  -webkit-text-fill-color: initial;
}

.hero-sub {
  font-size: clamp(0.92rem, 2.2vw, 1.05rem);
  color: var(--slate-600);
  margin-bottom: 24px;
  line-height: 1.55;
}

/* Step pills */
.step-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.step-pill {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--slate-100);
  color: var(--slate-600);
  border: 1px solid var(--slate-200);
  transition: all var(--dur) var(--ease);
  cursor: default;
  white-space: nowrap;
}

.step-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.step-pill-divider {
  color: var(--slate-400);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ── Main Layout ────────────────────────────────────── */
.main-grid {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px var(--gap) 56px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Card ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: border-color var(--dur) var(--ease);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}

.card-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.card-desc {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Drop zone ──────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius);
  background: var(--slate-50);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  margin-bottom: 16px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--primary);
  background: var(--blue-50);
  outline: none;
}

.drop-zone.dragging {
  border-color: var(--primary);
  background: var(--blue-100);
  transform: scale(0.995);
}

.drop-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.drop-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 4px;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur) var(--ease);
}

.drop-zone:hover .drop-circle {
  border-color: var(--blue-200);
}

.drop-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--slate-800);
}

.drop-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── File Selected View ─────────────────────────────── */
.file-selected {
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.file-thumb {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.file-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.file-size {
  font-size: 0.78rem;
  color: var(--muted);
}

audio {
  width: 100%;
  height: 38px;
  border-radius: var(--radius-sm);
  accent-color: var(--primary);
}

/* ── Icon Button ────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #ffffff;
  color: var(--muted);
  transition: all var(--dur) var(--ease);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
  background: var(--slate-100);
  color: var(--slate-800);
  border-color: var(--slate-300);
}

.icon-btn.danger:hover {
  background: var(--red-50);
  color: var(--red-600);
  border-color: var(--red-100);
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-h);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.btn-outline {
  background: #ffffff;
  color: var(--slate-700);
  border-color: var(--slate-300);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover:not(:disabled) {
  background: var(--slate-50);
  color: var(--slate-900);
  border-color: var(--slate-400);
}

.btn-ghost {
  background: transparent;
  color: var(--slate-600);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--slate-100);
  color: var(--slate-900);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.95rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 6px 13px;
  font-size: 0.8rem;
}

.w-full {
  width: 100%;
}

/* ── Button Group ───────────────────────────────────── */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
}

/* ── Progress ───────────────────────────────────────── */
.progress-wrap {
  padding: 6px 0;
}

.progress-track {
  height: 5px;
  background: var(--slate-200);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 30%;
  background: var(--primary);
  border-radius: 999px;
  animation: slide 1.4s infinite ease-in-out;
  transform-origin: left;
}

@keyframes slide {
  0%   { transform: translateX(-100%) scaleX(0.5); }
  100% { transform: translateX(350%)  scaleX(0.5); }
}

.progress-msg {
  text-align: center;
  font-size: 0.86rem;
  color: var(--slate-600);
  margin-top: 10px;
  font-weight: 500;
}

/* ── Field Labels & Inputs ──────────────────────────── */
.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.label-hint {
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.text-area {
  width: 100%;
  padding: 14px 16px;
  font-size: 0.94rem;
  font-family: var(--font);
  line-height: 1.7;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius);
  resize: vertical;
  outline: none;
  color: var(--text-dark);
  background: #ffffff;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.text-area:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ── Metadata Chips ─────────────────────────────────── */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--slate-600);
}

.chip strong {
  color: var(--slate-900);
  font-weight: 700;
}

/* ── Word Count Bar ─────────────────────────────────── */
.word-count-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.text-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  transition: background var(--dur);
  -webkit-tap-highlight-color: transparent;
}

.text-btn:hover {
  background: var(--blue-50);
}

/* ── Timed Segments Panel ───────────────────────────── */
.segments-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--slate-50);
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 14px;
  overscroll-behavior: contain;
}

.seg-row {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
  align-items: flex-start;
  transition: background var(--dur);
}

.seg-row:last-child {
  border-bottom: none;
}

.seg-row:hover {
  background: var(--blue-50);
}

.seg-ts {
  flex-shrink: 0;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 110px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.seg-txt {
  color: var(--slate-800);
}

/* ── Divider ────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

/* ── Results Header ─────────────────────────────────── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.results-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--slate-900);
}

/* ── Accuracy & WER Grid ────────────────────────────── */
.wer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (min-width: 480px) {
  .wer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 640px) {
  .wer-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.wer-stat {
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.wer-stat--primary {
  background: var(--amber-50);
  border-color: var(--amber-100);
}

.wer-stat--success {
  background: var(--green-50);
  border-color: var(--green-100);
}

.wer-stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.wer-stat--primary .wer-stat-val {
  color: var(--amber-700);
}

.wer-stat--success .wer-stat-val {
  color: var(--green-700);
}

.wer-stat-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wer-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--slate-200);
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}

.wer-bar {
  height: 100%;
  background: var(--amber-500);
  border-radius: 999px;
  transition: width 0.5s var(--ease);
}

.wer-bar--success {
  background: var(--green-600);
}

/* Quality Badge */
.wer-quality {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wer-quality.q-excellent {
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid var(--green-100);
}

.wer-quality.q-good {
  background: var(--blue-50);
  color: var(--blue-800);
  border: 1px solid var(--blue-200);
}

.wer-quality.q-fair {
  background: var(--amber-50);
  color: var(--amber-700);
  border: 1px solid var(--amber-100);
}

.wer-quality.q-poor {
  background: var(--red-50);
  color: var(--red-600);
  border: 1px solid var(--red-100);
}

/* ── Comparison Rows ────────────────────────────────── */
.compare-col-labels {
  display: none;
}

@media (min-width: 700px) {
  .compare-col-labels {
    display: grid;
    grid-template-columns: 140px 1fr 1fr 36px;
    gap: 12px;
    padding: 0 0 8px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }
}

.compare-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.compare-row:last-child {
  border-bottom: none;
}

@media (min-width: 700px) {
  .compare-row {
    display: grid;
    grid-template-columns: 140px 1fr 1fr 36px;
    gap: 12px;
    align-items: start;
    flex-direction: unset;
  }
}

.compare-row input,
.compare-row textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 0.88rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  background: #ffffff;
  color: var(--text-dark);
  transition: border-color var(--dur), box-shadow var(--dur);
}

.compare-row input:focus,
.compare-row textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.compare-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compare-field-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: block;
}

@media (min-width: 700px) {
  .compare-field-label {
    display: none;
  }
}

/* ── Comparison Table ───────────────────────────────── */
.compare-results {
  margin-top: 0;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 540px;
  background: #ffffff;
}

thead th {
  background: var(--slate-100);
  padding: 12px 14px;
  text-align: left;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--slate-800);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--slate-50);
}

.td-wer {
  font-weight: 800;
}

.td-acc {
  color: var(--green-700);
  font-weight: 800;
}

.td-err {
  color: var(--red-600);
  font-size: 0.82rem;
  font-style: italic;
}

.td-label {
  font-weight: 700;
  color: var(--slate-900);
}

/* ── Footer ─────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 24px var(--gap);
  font-size: 0.84rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ── Toast Notification ─────────────────────────────── */
.toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--slate-900);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  max-width: calc(100vw - 32px);
  text-align: center;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Utility ────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Scrollbars ─────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

/* ── Mobile Tweaks ──────────────────────────────────── */
@media (max-width: 480px) {
  .card {
    padding: 20px 16px;
  }
  .hero {
    padding: 32px var(--gap) 28px;
  }
  .btn-group {
    flex-direction: column;
  }
  .btn-group .btn {
    width: 100%;
  }
  .wer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .wer-stat-val {
    font-size: 1.35rem;
  }
  .step-pills {
    display: none;
  }
  .navbar .nav-badge {
    display: none;
  }
}
