:root {
  --ink: #1c2b29;
  --ink-soft: #50615e;
  --muted: #7d8a87;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #fbfcfc;
  --teal: #145450;
  --teal-600: #0f6b65;
  --teal-700: #0c4a46;
  --clay: #c2603f;
  --clay-600: #ad5236;
  --border: #e3eae8;
  --border-strong: #cdd8d5;
  --ok: #2f8f6b;
  --err: #c0533c;
  --pending: #c79a3a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 40, 38, 0.04), 0 8px 24px rgba(16, 40, 38, 0.06);
  --shadow-lg: 0 2px 6px rgba(16, 40, 38, 0.06), 0 18px 50px rgba(16, 40, 38, 0.10);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--teal-600);
  outline-offset: 2px;
  border-radius: 4px;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--teal-700);
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #e7efed 0%, var(--bg) 60%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 34px;
  text-align: center;
}
.login-mark {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  display: block;
  border-radius: 16px;
}
.login-card .wordmark { font-size: 30px; margin: 0 0 6px; }
.login-tag { color: var(--ink-soft); margin: 0 0 28px; font-size: 15px; }
.btn-primary {
  width: 100%;
  border: none;
  background: var(--teal);
  color: #fff;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background .15s ease;
}
.btn-primary:hover { background: var(--teal-600); }
.login-note { margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.error {
  margin: 0 0 18px;
  padding: 10px 12px;
  background: #fbeeea;
  border: 1px solid #f0d2c8;
  color: var(--err);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  text-align: left;
}

/* ---------- App shell ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar .wordmark { font-size: 21px; }
.topbar-mark { width: 26px; height: 26px; border-radius: 7px; display: block; }
.spacer { flex: 1; }
.user-email { color: var(--ink-soft); font-size: 13.5px; }
.btn-ghost {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--teal-600); color: var(--teal-700); }

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 22px 60px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: start;
}

/* ---------- History ---------- */
.history {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky; top: 84px;
}
.history h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 2px 0 12px; font-weight: 700;
}
.history ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.history-empty { color: var(--muted); font-size: 13.5px; padding: 6px 2px; }
.history-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--ink-soft);
  transition: background .12s;
}
.history-item:hover { background: var(--surface-2); }
.history-item.active { background: #eaf2f0; color: var(--teal-700); font-weight: 600; }
.hi-label { flex: 1; }
.hi-status { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }
.dot.pending { background: var(--pending); }

/* ---------- Recorder ---------- */
.content { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.recorder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 28px 34px;
  text-align: center;
}
.record-btn {
  width: 168px; height: 168px;
  margin: 4px auto 20px;
  border-radius: 50%;
  border: none;
  background: var(--teal);
  color: #fff;
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 10px 30px rgba(20, 84, 80, 0.28);
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
}
.record-btn::before {
  content: "";
  position: absolute; inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(20, 84, 80, 0.18);
}
.record-btn:hover { transform: translateY(-1px); background: var(--teal-600); }
.record-btn:active { transform: translateY(0); }
.record-glyph {
  width: 46px; height: 46px; border-radius: 14px;
  background: #fff;
  transition: all .2s ease;
}
.record-icon {
  position: absolute;
  font-variant-numeric: tabular-nums;
  font-size: 26px; font-weight: 600;
  color: #fff; letter-spacing: .02em;
}
.record-btn.is-recording { background: var(--clay); box-shadow: 0 10px 34px rgba(194, 96, 63, 0.34); }
.record-btn.is-recording::before { border-color: rgba(194, 96, 63, 0.30); animation: pulse 1.8s ease-out infinite; }
.record-btn.is-recording .record-glyph { width: 30px; height: 30px; border-radius: 6px; }
.record-btn.is-recording:hover { background: var(--clay-600); }
.record-btn.is-busy { background: var(--teal-700); pointer-events: none; }
.record-btn.is-busy .record-glyph {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.35); border-top-color: #fff; background: transparent;
  animation: spin .9s linear infinite;
}
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.18); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.rec-status { font-family: var(--serif); font-size: 22px; color: var(--ink); margin: 0 0 4px; }
.rec-sub { color: var(--ink-soft); font-size: 14px; margin: 0; max-width: 360px; margin-inline: auto; }

/* ---------- Note ---------- */
.note-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.note-status { color: var(--ink-soft); font-size: 14px; margin: 0 0 14px; }
.note-text {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  resize: vertical;
  background: var(--surface-2);
}
.note-text:focus { background: #fff; border-color: var(--teal-600); outline: none; box-shadow: 0 0 0 3px rgba(15,107,101,.12); }
.note-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.btn-download {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  transition: background .15s;
}
.btn-download.alt { background: var(--surface); color: var(--teal-700); }
.btn-download:hover { background: var(--teal-600); color: #fff; }
.btn-link {
  border: none; background: none; color: var(--ink-soft);
  font-size: 13.5px; text-decoration: underline; text-underline-offset: 2px; padding: 8px;
}
.btn-link:hover { color: var(--teal-700); }
.transcript-wrap { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.transcript {
  width: 100%; min-height: 120px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px; color: var(--ink-soft);
  background: var(--surface-2); resize: vertical; line-height: 1.55;
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; padding: 18px 14px 50px; gap: 18px; }
  .history { position: static; order: 2; }
  .content { order: 1; }
  .record-btn { width: 150px; height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

[hidden] { display: none !important; }
