:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --ink: #1c2024;
  --ink-soft: #6b7280;
  --accent: #ff8a34;
  --accent-ink: #1c1200;
  --teal: #2fa89c;
  --border: rgba(20, 24, 28, 0.12);
  --danger: #c8412f;
  --danger-bg: rgba(200, 65, 47, 0.08);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 24, 28, 0.04), 0 8px 24px rgba(20, 24, 28, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181c;
    --surface: #1b2126;
    --ink: #f2f0ea;
    --ink-soft: #9aa3ac;
    --accent: #ff9c4d;
    --accent-ink: #1c1200;
    --teal: #3fcbbe;
    --border: rgba(242, 240, 234, 0.1);
    --danger: #ff6b5b;
    --danger-bg: rgba(255, 107, 91, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

/* Author display rules (.card { display: flex } etc.) would otherwise
   override the hidden attribute's UA display:none — enforce it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

h1, h2 {
  font-family: "Space Grotesk", "Inter", sans-serif;
  margin: 0;
}

.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }

.shell {
  width: 100%;
  max-width: 460px;
  padding: env(safe-area-inset-top, 0) 20px calc(env(safe-area-inset-bottom, 0) + 32px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Brand + waveform mark */

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 28px;
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.wave-mark {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  flex-shrink: 0;
}

.wave-mark span {
  width: 4px;
  border-radius: 3px;
  background: var(--accent);
  height: 40%;
}

.wave-mark span:nth-child(1) { height: 55%; background: var(--teal); }
.wave-mark span:nth-child(2) { height: 90%; }
.wave-mark span:nth-child(3) { height: 35%; background: var(--teal); }
.wave-mark span:nth-child(4) { height: 70%; }
.wave-mark span:nth-child(5) { height: 50%; background: var(--teal); }

.wave-mark-lg {
  height: 56px;
  gap: 5px;
  align-self: center;
  margin: 4px 0 6px;
}

.wave-mark-lg span {
  width: 5px;
  background: var(--accent);
}

.wave-mark-lg span:nth-child(3n) { background: var(--teal); }

.wave-mark.is-active span {
  animation: wave 1.1s ease-in-out infinite;
}

.wave-mark.is-active span:nth-child(1) { animation-delay: 0s; }
.wave-mark.is-active span:nth-child(2) { animation-delay: 0.1s; }
.wave-mark.is-active span:nth-child(3) { animation-delay: 0.2s; }
.wave-mark.is-active span:nth-child(4) { animation-delay: 0.3s; }
.wave-mark.is-active span:nth-child(5) { animation-delay: 0.4s; }
.wave-mark.is-active span:nth-child(6) { animation-delay: 0.5s; }
.wave-mark.is-active span:nth-child(7) { animation-delay: 0.6s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .wave-mark.is-active span { animation: none; }
}

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

/* Form elements */

input[type="password"],
input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
}

input:focus-visible,
button:focus-visible,
.drop-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#lock-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  font: inherit;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.98rem;
  padding: 14px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row .btn { flex: 1; }

/* Upload */

.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 32px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.drop-card:hover,
.drop-card.has-file {
  border-color: var(--teal);
  color: var(--ink);
}

.drop-card svg { color: var(--teal); }

#drop-label {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
}

.drop-hint { font-size: 0.78rem; }

.segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.segment {
  flex: 1;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.segment.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(20, 24, 28, 0.12);
}

/* Processing */

#processing-screen {
  align-items: center;
  text-align: center;
  padding: 36px 20px;
}

.status-line {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  margin: 0;
}

.elapsed {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: -8px 0 0;
}

/* Result */

.transcript-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  max-height: 50vh;
  overflow-y: auto;
}

#transcript-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 0.98rem;
}

.transcript-edit {
  width: 100%;
  min-height: 8em;
  resize: vertical;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 1.55;
  font-size: 0.98rem;
  padding: 0;
}

.transcript-edit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 6px;
}

.feedback-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.feedback-buttons {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn-icon:active { transform: scale(0.94); }

.btn-icon[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--surface);
}

.btn-icon#thumbs-down-btn[aria-pressed="true"] {
  border-color: var(--danger);
}

/* Errors */

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
}

@media (min-width: 640px) {
  .shell { padding-top: 40px; }
  .card { padding: 32px 28px; }
}
