:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --rec: #e11d48;
  --ok: #16a34a;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 16px;
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --panel: #111827;
  --ink: #e5e7eb;
  --ink-soft: #cbd5e1;
  --muted: #64748b;
  --line: #1f2937;
  --brand: #818cf8;
  --brand-ink: #0b1120;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.lang-select {
  appearance: none;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  max-width: 190px;
}
.icon-btn {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { border-color: var(--brand); }

/* App layout */
.app {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Banner */
.banner {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
}
.banner-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
:root[data-theme="dark"] .banner-error {
  background: #2a1215; color: #fca5a5; border-color: #5b1a20;
}

/* Editor */
.editor-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
}
.status { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  transition: background .2s, box-shadow .2s;
}
.status-dot.live {
  background: var(--rec);
  box-shadow: 0 0 0 0 rgba(225,29,72,.5);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(225,29,72,.5); }
  70% { box-shadow: 0 0 0 10px rgba(225,29,72,0); }
  100% { box-shadow: 0 0 0 0 rgba(225,29,72,0); }
}
.counts { color: var(--muted); }
.dot-sep { margin: 0 6px; }

.editor {
  min-height: 320px;
  padding: 22px;
  font-size: 20px;
  line-height: 1.7;
  color: var(--ink);
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-y: auto;
  max-height: 55vh;
}
.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}
.interim-row {
  padding: 0 22px 16px;
  min-height: 8px;
}
.interim {
  font-size: 20px;
  line-height: 1.7;
  color: var(--muted);
  font-style: italic;
}

/* Mic dock */
.mic-dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 34px;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .08s ease, background .2s;
}
.mic-btn:hover { transform: translateY(-1px); }
.mic-btn:active { transform: translateY(0); }
.mic-btn.recording { background: var(--rec); }
.mic-icon { font-size: 22px; }
.hint { font-size: 13px; color: var(--muted); text-align: center; max-width: 520px; }

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 6px 2px;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.toggle input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.spacer { flex: 1; }
.btn {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.btn:hover { border-color: var(--brand); }
.btn-ghost { color: var(--ink-soft); }

.privacy {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
  margin: 4px 0 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .editor { font-size: 18px; padding: 18px; }
  .interim { font-size: 18px; }
  .app { padding: 16px 14px 32px; }
}
