:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #211f1b;
  --muted: #6f6a61;
  --line: #ded8cd;
  --accent: #116a6b;
  --accent-dark: #0c4d4e;
  --danger: #b42318;
  --focus: #d59d2f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  align-items: stretch;
}

.interview-panel,
.recording-panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px 24px 12px;
}

.interview-panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 22px;
}

.recording-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.status-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.status-pill,
.counter {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.status-pill {
  background: #e8f2ef;
  color: var(--accent-dark);
  font-weight: 700;
}

.status-pill.recording {
  background: #fde8e6;
  color: var(--danger);
}

.counter {
  border: 1px solid var(--line);
  color: var(--muted);
}

.question-area {
  max-width: 760px;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: center;
  justify-content: space-between;
}

.recovery-bar {
  min-height: 34px;
}

.active-recovery-code {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.active-recovery-code[hidden],
.recovery-bar[hidden] {
  display: none;
}

.recovery-code-copy {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 2px 10px;
  align-items: baseline;
}

.recovery-code-copy > span:first-child {
  grid-column: 1;
  grid-row: 1;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.recovery-code-copy code {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  overflow-wrap: anywhere;
  white-space: nowrap;
  color: var(--accent-dark);
  font-size: 0.95rem;
  font-weight: 800;
}

.recovery-hint {
  grid-column: 1;
  grid-row: 2;
  color: var(--muted);
  font-size: 0.8rem;
}

.recovery-hint.copied {
  color: var(--accent-dark);
  font-weight: 700;
}

.compact-button,
.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fffdf9;
  color: var(--accent-dark);
  font-weight: 750;
  cursor: pointer;
}

.compact-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.text-button {
  border-color: transparent;
  padding-left: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.language-control {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.language-control label {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 36px 0 12px;
  background: #fffdf9;
  color: var(--ink);
  cursor: pointer;
}

.switch-control {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf9;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.switch-control input:checked + .switch-track {
  border-color: var(--accent);
  background: var(--accent);
}

.switch-control input:checked + .switch-track .switch-thumb {
  background: white;
  transform: translateX(20px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.switch-control:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.58;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.helper-text {
  max-width: 660px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.transcript-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
}

.transcript-area label,
.downloads h2 {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.section-label-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.transcript-status {
  color: var(--muted);
  font-size: 0.86rem;
}

.transcript-box {
  overflow: auto;
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbfa;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
}

.transcript-box[contenteditable="true"] {
  background: #fffdf9;
}

.transcript-box .interim {
  color: var(--muted);
}

.transcript-box:focus,
select:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button {
  min-width: 0;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  white-space: normal;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.secondary-button {
  background: #211f1b;
  color: white;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.video-frame {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 8px;
  background: #151412;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recording-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(33, 31, 27, 0.82);
  color: white;
  font-size: 0.86rem;
  font-weight: 800;
}

.recording-badge[hidden] {
  display: none;
}

.recording-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff4d3d;
}

.downloads {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.downloads h2 {
  margin: 0 0 10px;
}

.downloads ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.downloads a,
.saved-file-name {
  display: block;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffdf9;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(33, 31, 27, 0.52);
}

.modal-backdrop[hidden] {
  display: none;
}

.intro-modal {
  display: grid;
  gap: 22px;
  width: min(100%, 560px);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(33, 31, 27, 0.24);
}

.recovery-modal {
  display: grid;
  gap: 16px;
  width: min(100%, 480px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(33, 31, 27, 0.24);
}

.recovery-modal-copy {
  display: grid;
  gap: 8px;
}

.recovery-modal h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.recovery-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.recovery-modal label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.recovery-modal input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fffdf9;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0;
  text-transform: uppercase;
}

.recovery-modal .form-error {
  min-height: 1.4em;
  color: var(--danger);
  font-size: 0.9rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.intro-modal h2 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.intro-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.intro-copy {
  display: grid;
  gap: 14px;
}

.intro-consent {
  display: grid;
  gap: 6px;
}

.intro-consent label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.intro-consent input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.intro-voice-help {
  display: grid;
  gap: 6px;
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}

.intro-voice-help h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.intro-language-control {
  display: grid;
  grid-template-columns: max-content minmax(0, 220px);
  align-items: center;
  gap: 10px;
}

.intro-language-control select {
  width: 100%;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    width: min(100% - 20px, 680px);
    padding: 10px 0;
  }

  .interview-panel,
  .recording-panel {
    padding: 18px;
  }

  .recording-panel {
    order: -1;
    overflow: visible;
  }

  .downloads {
    overflow: visible;
  }

  .video-frame {
    aspect-ratio: 16 / 10;
  }

  .recovery-code-copy {
    grid-template-columns: 1fr;
  }

  .recovery-code-copy code {
    grid-column: 1;
    grid-row: auto;
    white-space: normal;
  }

  .recovery-hint {
    grid-column: 1;
    grid-row: auto;
  }

  .controls button {
    width: 100%;
  }
}

@media (max-width: 1040px) {
  .controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .intro-modal {
    padding: 20px;
  }

  .intro-language-control {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }
}
