:root {
  --bg: #14171f;
  --surface: #1c2333;
  --surface-2: #232c42;
  --text: #e8ebf5;
  --text-dim: #9aa3bd;
  --accent: #4f7cff;
  --accent-2: #6fe3c0;
  --error: #ff6b6b;
  --border: #2c3550;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { color: var(--text); text-decoration: none; font-weight: 600; }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav a { color: var(--text-dim); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }

h1 { font-size: 1.4rem; margin: 1rem 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
.hint { color: var(--text-dim); font-size: 0.85rem; font-weight: normal; }

a { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1rem 0;
}

label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.9rem; color: var(--text-dim); }
input[type="text"], input[type="password"], input[type="date"], input[type="color"], select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
input[type="file"] { width: 100%; margin-top: 0.25rem; color: var(--text); }
input[type="color"] { padding: 0.25rem; height: 2.75rem; }

button, .btn {
  display: inline-block;
  font-size: 1rem;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
button.secondary { background: transparent; }
button:disabled { opacity: 0.5; cursor: default; }
button.link-btn, .link-btn {
  background: none; border: none; color: var(--accent-2); padding: 0; font-size: 0.9rem;
}
.inline-form { display: inline; }

.error { color: var(--error); }
.notice { color: var(--text-dim); }

.login-card { max-width: 360px; margin: 3rem auto; text-align: center; }
.login-card button { width: 100%; margin-top: 1rem; }

/* ---------------------------------------------------------- progress bars */
.progress-wrap { margin-top: 0.75rem; }
.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar.small { height: 6px; margin-top: 0.35rem; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s ease; }
.progress-fill.error { background: var(--error); }

/* -------------------------------------------------------------- dashboard */
.dashboard-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ws-status { font-size: 0.8rem; color: var(--text-dim); }
.ws-status.ws-connected::before { content: "● "; color: var(--accent-2); }
.ws-status.ws-reconnecting::before, .ws-status.ws-disconnected::before { content: "● "; color: var(--error); }

.class-group h2 { display: flex; align-items: center; gap: 0.5rem; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.recording-rows { display: flex; flex-direction: column; gap: 0.5rem; }
.recording-row {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
}
.recording-row-main { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.recording-row .title { font-weight: 500; }

.status-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.status-badge.status-done { background: rgba(111, 227, 192, 0.15); color: var(--accent-2); }
.status-badge.status-error { background: rgba(255, 107, 107, 0.15); color: var(--error); }
.status-badge.status-transcribing, .status-badge.status-generating_notes { background: rgba(79, 124, 255, 0.15); color: var(--accent); }

.empty-state { color: var(--text-dim); text-align: center; margin-top: 3rem; }

/* --------------------------------------------------------------- classes */
.classes-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.class-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.class-row-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.class-row .class-name { flex: 1; }
.class-row .context-input { margin-top: 0.25rem; }
.class-row .save-context-btn { margin-top: 0.5rem; }
.class-row .save-status { margin-left: 0.6rem; color: var(--accent-2); }
.badge { font-size: 0.7rem; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 0.1rem 0.5rem; }

textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
}

/* ------------------------------------------------------------- recording */
.status-panel.status-error { border-color: var(--error); }
audio { margin: 1rem 0; }

.notes-header { display: flex; align-items: center; justify-content: space-between; }
.notes-header h2 { margin: 0; }

.notes-content h2, .notes-content h3, .notes-content h4 { margin-top: 1rem; }
.notes-content ul { padding-left: 1.25rem; }
.notes-content .katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; margin: 0.5rem 0; }
.notes-content .katex { font-size: 1.05em; }

.notes-edit-wrap textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  min-height: 60vh;
}
.notes-edit-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }

.timestamp-link {
  color: var(--accent-2);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px dotted currentColor;
  cursor: pointer;
}
.timestamp-link:hover { text-decoration: none; border-bottom-style: solid; }

.todos-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.todo-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}
.todo-type { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--accent-2); margin-right: 0.5rem; }
.todo-due, .todo-source { color: var(--text-dim); font-size: 0.8rem; margin-left: 0.5rem; }

.outputs-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.outputs-list > li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}
.outputs-list a { text-decoration: none; }
.outputs-list .transcript-content { margin-top: 0.6rem; max-height: 24rem; overflow-y: auto; }

.transcript-segment { margin: 0.4rem 0; }
.transcript-segment .timestamp { color: var(--text-dim); font-size: 0.8rem; margin-right: 0.4rem; font-variant-numeric: tabular-nums; }
.transcript-segment.low-confidence { background: rgba(255, 193, 7, 0.08); border-radius: 6px; padding: 0.15rem 0.3rem; }

@media (min-width: 640px) {
  .container { padding: 2rem 1.5rem 4rem; }
}
