:root {
  color-scheme: dark;
  --bg: #14161c;
  --bg-elevated: #1c1f28;
  --bg-elevated-2: #262a36;
  --border: #333846;
  --text: #eef0f4;
  --text-dim: #9aa2b1;
  --accent: #7c9dff;
  --accent-dim: #3a4266;
  --danger: #ff6b6b;
  --record: #ff5262;
  --radius: 12px;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 90px;
}

.view.hidden { display: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.topbar h1 {
  font-size: 1.15rem;
  margin: 0;
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--bg-elevated-2);
  color: var(--text);
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--accent); color: #10131c; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.icon { width: 44px; height: 44px; padding: 0; font-size: 1.2rem; border-radius: 50%; }

.doc-list { list-style: none; margin: 0; padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.doc-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
}
.doc-card:active { background: var(--bg-elevated-2); }
.doc-card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.doc-card p { margin: 0; color: var(--text-dim); font-size: 0.85rem; }
.empty-hint { color: var(--text-dim); padding: 40px 20px; text-align: center; }

.form-new-doc {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 16px 24px;
}
.form-new-doc label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--text-dim); }
.form-new-doc input, .form-new-doc textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}
.hint { color: var(--text-dim); font-size: 0.82rem; padding: 0 16px; line-height: 1.4; }
.hint code { background: var(--bg-elevated-2); padding: 1px 5px; border-radius: 4px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px 16px 10px;
  position: sticky;
  top: 58px;
  background: var(--bg);
  z-index: 4;
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 4px;
  font-size: 0.88rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.tab-panel { display: none; padding: 8px 16px 16px; }
.tab-panel.active { display: block; }

.segments { display: flex; flex-direction: column; gap: 2px; }
.segment {
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}
.segment:active { background: var(--bg-elevated); }
.segment .speaker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 3px;
  display: block;
}
.segment .text { line-height: 1.5; }
.segment.current {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.segment .note-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.voice-assignments { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.voice-row { display: flex; flex-direction: column; gap: 6px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.voice-row .name { font-weight: 600; }
.voice-row select {
  background: var(--bg-elevated-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95rem;
}
.voice-row .speed-row { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-dim); }
.voice-row input[type="range"] { flex: 1; }

.notes-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.note-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.note-card .meta { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 0.75rem; margin-bottom: 6px; }
.note-card .transcript { line-height: 1.4; margin-bottom: 8px; }
.note-card .transcript.pending { color: var(--text-dim); font-style: italic; }
.note-card .actions { display: flex; gap: 8px; }
.note-card .actions button { font-size: 0.8rem; padding: 6px 12px; }

.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px max(16px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}
.player-bar.hidden { display: none; }
.player-info { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 0 6px; }
.player-info span:first-child { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-info span:last-child { font-size: 0.72rem; color: var(--text-dim); }
.btn.record { background: var(--record); color: #fff; }
.btn.record.active { animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 98, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(255, 82, 98, 0); }
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 20;
}
.toast.hidden { display: none; }
