:root {
  --bg: #111418;
  --panel: #1a1f26;
  --border: #2a313b;
  --fg: #e6e9ee;
  --muted: #8a94a3;
  --accent: #4fd1a5;
  --danger: #ff6b6b;
  --meter: #4fd1a5;
  --meter-hot: #ffb347;
  --mono: ui-monospace, Consolas, "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 900px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1rem; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.sub { margin: 0 0 20px; color: var(--muted); }
.muted { color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
.options label { margin-right: 8px; }
.num { width: 5em; }

button {
  background: #262d37;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #062018; border-color: var(--accent); font-weight: 600; }

.controls { margin-bottom: 18px; }
.elapsed { font-family: var(--mono); font-size: 1.3rem; margin-left: auto; }
.state { font-family: var(--mono); font-size: .85rem; padding: 3px 8px; border-radius: 4px; background: #262d37; }
.state.recording { background: var(--danger); color: #fff; }
.state.idle { color: var(--muted); }

.meter-block { margin-bottom: 14px; }
.meter-block.disabled { opacity: .4; }
.meter-head, .meter-foot { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .85rem; }
.meter-head span:first-child { font-weight: 700; }
.meter {
  position: relative;
  height: 14px;
  background: #0c0f13;
  border: 1px solid var(--border);
  border-radius: 3px;
  margin: 4px 0;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--meter) 0%, var(--meter) 75%, var(--meter-hot) 100%);
  transition: width 60ms linear;
}
.meter-peak {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: #fff; left: 0; opacity: .8;
}

table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .85rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
td a { color: var(--accent); }

pre#log {
  margin: 0;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  color: #c3cad4;
}

.reshare { margin-top: 8px; }
.warn { color: var(--meter-hot); font-size: .85rem; }

/* --- Mode cards: simple (mic) and advanced (system audio) side by side --- */
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 720px) { .modes { grid-template-columns: 1fr; } }
.mode { display: flex; flex-direction: column; margin-bottom: 0; }
.mode p { margin: 0 0 10px; }
.mode .steps { margin: 0 0 14px; padding-left: 22px; color: var(--muted); }
.mode .steps li { margin-bottom: 4px; }
.mode .steps b { color: var(--fg); }
.mode .small { font-size: .85rem; margin: 10px 0 0; }
.mode code { font-family: var(--mono); font-size: .85em; }
.mode-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mode-head h2 { margin: 0; font-size: 1.15rem; color: var(--fg); text-transform: none; letter-spacing: 0; }
.badge {
  font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
}
.badge.easy { background: rgba(79, 209, 165, .15); color: var(--accent); border: 1px solid var(--accent); }
.badge.hard { background: rgba(255, 179, 71, .12); color: var(--meter-hot); border: 1px solid var(--meter-hot); }
.mode-simple { border-color: var(--accent); }
.mode-advanced { border-color: #4a4230; }
button.big { margin-top: auto; padding: 12px 16px; font-size: 15px; width: 100%; }
.mode.active { box-shadow: 0 0 0 2px var(--accent) inset; }
.mode.unavailable { opacity: .55; }

.advanced summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.advanced .options { margin-top: 8px; margin-bottom: 0; }
#modeLabel { font-size: .9rem; }

/* --- Transcription panel --- */
.transcript { margin: 0; font-family: inherit; font-size: .95rem; line-height: 1.5; white-space: pre-wrap; max-height: 420px; overflow: auto; color: var(--fg); }
.transcript:empty { display: none; }
.state.working { background: var(--meter-hot); color: #2a1a00; }
.state.done { background: var(--accent); color: #062018; }
.state.error { background: var(--danger); color: #fff; }
.dl-link { color: var(--accent); }
#apiStatus.bad { color: var(--danger); }

/* --- Notes modal --- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-box {
  position: relative; z-index: 1;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: min(820px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.modal-bar h2 { margin: 0; font-size: 1.1rem; color: var(--fg); text-transform: none; letter-spacing: 0; }
.modal-actions { display: flex; gap: 6px; }
.modal-actions button {
  width: 38px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  background: #262d37; border: 1px solid var(--border); border-radius: 8px; color: var(--fg); cursor: pointer;
}
.modal-actions button:hover { border-color: var(--accent); color: var(--accent); }
.modal-actions button.ok { border-color: var(--accent); color: var(--accent); }
.modal-actions svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.modal-body { padding: 24px 28px; overflow: auto; }

/* --- Rendered notes ("document" look) --- */
.notes-doc { color: var(--fg); line-height: 1.6; }
.notes-doc h1, .notes-doc h2, .notes-doc h3, .notes-doc h4 { line-height: 1.3; margin: 1.2em 0 .4em; color: var(--fg); text-transform: none; letter-spacing: 0; font-weight: 700; }
.notes-doc h1 { font-size: 1.5rem; }
.notes-doc h2 { font-size: 1.2rem; }
.notes-doc h3 { font-size: 1.05rem; }
.notes-doc h4 { font-size: .95rem; }
.notes-doc > :first-child { margin-top: 0; }
.notes-doc p { margin: 0 0 .8em; }
.notes-doc ul, .notes-doc ol { margin: 0 0 .8em; padding-left: 1.4em; }
.notes-doc li { margin: .2em 0; }
.notes-doc strong { color: #fff; }
.notes-doc code { font-family: var(--mono); font-size: .9em; background: #0c0f13; padding: 1px 5px; border-radius: 3px; }

.notes-doc table { border-collapse: collapse; width: 100%; margin: 0 0 .9em; font-size: .95em; font-family: inherit; }
.notes-doc th, .notes-doc td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.notes-doc thead th { background: #0c0f13; font-weight: 600; }
