:root {
  --navy: #0a1628;
  --navy-mid: #112240;
  --navy-light: #1e3a5f;
  --gold: #c9a84c;
  --gold-light: #e8c97a;
  --gold-dark: #a07830;
  --text: #e8eaf0;
  --text-muted: #8899aa;
  --danger: #e05c5c;
  --success: #4caf7a;
  --border: rgba(201,168,76,0.25);
  --radius: 12px;
  --tap: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--navy);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--navy-mid);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-logo {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.1em;
}

.content { flex: 1; overflow-y: auto; padding: 16px; max-width: 640px; margin: 0 auto; width: 100%; }

/* ── Views ── */
.view { display: none; }
.view.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  width: 100%;
}

.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-primary { background: var(--gold); color: var(--navy); }
.btn-secondary { background: var(--navy-light); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--gold); border: 1px solid var(--border); }
.btn-sm { min-height: 36px; font-size: 0.82rem; padding: 0 14px; width: auto; }

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

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* ── Record Button ── */
.record-wrap { display: flex; flex-direction: column; align-items: center; padding: 32px 0 24px; }

.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid var(--gold);
  background: var(--navy-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 0 0 0 rgba(201,168,76,0.4);
}

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

.record-btn.recording {
  background: rgba(224,92,92,0.15);
  border-color: var(--danger);
  box-shadow: 0 0 0 12px rgba(224,92,92,0.15), 0 0 0 24px rgba(224,92,92,0.06);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,92,92,0.3), 0 0 0 0 rgba(224,92,92,0.1); }
  50% { box-shadow: 0 0 0 16px rgba(224,92,92,0.1), 0 0 0 32px rgba(224,92,92,0.04); }
}

.record-btn svg { width: 48px; height: 48px; }

.record-status {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.record-status.live { color: var(--danger); }
.record-status.paused { color: var(--gold); }

/* ── Transcript ── */
.transcript-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 140px;
  max-height: 260px;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript-box .placeholder { color: var(--text-muted); font-style: italic; }

/* ── Drill List ── */
.drill-item {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.drill-item:active { border-color: var(--gold); }

.drill-item.complete { opacity: 0.55; }

.drill-item-info { flex: 1; min-width: 0; }

.drill-item-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drill-item.complete .drill-item-title { text-decoration: line-through; color: var(--text-muted); }

.drill-item-date { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.drill-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  border: 1px solid var(--border);
}

.drill-badge.done { background: rgba(76,175,122,0.15); color: var(--success); border-color: rgba(76,175,122,0.25); }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color 0.15s;
  resize: vertical;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--gold);
}

.form-control::placeholder { color: var(--text-muted); }

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* ── Timeline ── */
.timeline-entry {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.timeline-entry-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.tl-num {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gold);
  background: rgba(201,168,76,0.12);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tl-time-input {
  width: 90px;
  flex-shrink: 0;
}

/* ── Field with Regen ── */
.field-with-regen { position: relative; }
.regen-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  background: rgba(201,168,76,0.12);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--gold);
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.regen-btn:active { background: rgba(201,168,76,0.25); }

/* ── Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,22,40,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(201,168,76,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-msg { color: var(--gold); font-weight: 600; font-size: 1rem; text-align: center; padding: 0 32px; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  z-index: 300;
  transition: transform 0.3s ease;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
}

#toast.show { transform: translateX(-50%) translateY(0); }
#toast.success { border-color: rgba(76,175,122,0.5); color: var(--success); }
#toast.error { border-color: rgba(224,92,92,0.5); color: var(--danger); }

/* ── Settings ── */
.settings-section { margin-bottom: 24px; }

.settings-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.9rem; line-height: 1.7; }

/* ── Nav Tabs ── */
.nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 4px;
}

.nav-tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.nav-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Section divider ── */
.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Misc ── */
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }

input[type="file"] { display: none; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
}

.icon-btn:active { background: rgba(255,255,255,0.06); }

/* ── Progress bar ── */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── Confirm dialog ── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,22,40,0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 250;
  backdrop-filter: blur(4px);
}

.dialog {
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 36px;
  width: 100%;
  max-width: 480px;
}

.dialog h3 { font-size: 1.1rem; margin-bottom: 10px; }
.dialog p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; }
