:root {
  --bg: #0b1020;
  --bg-2: #121a30;
  --card: #161c2e;
  --card-2: #1d2540;
  --line: #2a3350;
  --text: #e8ebf4;
  --muted: #9aa5c4;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2b55 0, transparent 60%), var(--bg);
  background-color: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }

.app-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: linear-gradient(var(--bg) 60%, transparent);
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px var(--accent);
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px calc(var(--safe-bottom) + 28px);
}

/* ---- stage / mic ---- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 0 10px;
}

.mic {
  --size: 116px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: none;
  color: #fff;
  background: radial-gradient(circle at 30% 25%, #7c83ff, var(--accent) 55%, #4f46e5);
  box-shadow: 0 12px 40px rgba(99,102,241,.45), inset 0 2px 8px rgba(255,255,255,.25);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease;
}
.mic:active { transform: scale(.96); }
.mic.listening {
  background: radial-gradient(circle at 30% 25%, #67e8f9, var(--accent-2) 55%, #0891b2);
  animation: pulse 1.4s ease-out infinite;
}
.mic.thinking { animation: spin 1s linear infinite; opacity: .85; }
.mic:disabled { filter: grayscale(.6); opacity: .5; cursor: not-allowed; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,211,238,.55), 0 12px 40px rgba(34,211,238,.4); }
  70%  { box-shadow: 0 0 0 26px rgba(34,211,238,0), 0 12px 40px rgba(34,211,238,.25); }
  100% { box-shadow: 0 0 0 0 rgba(34,211,238,0), 0 12px 40px rgba(34,211,238,.25); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint { color: var(--muted); margin: 14px 0 4px; font-size: 14px; }
.transcript { min-height: 24px; margin: 4px 0; font-size: 17px; }
.transcript.interim { color: var(--muted); }

.bubble {
  margin: 12px auto 0;
  max-width: 90%;
  background: var(--card-2);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  text-align: left;
  white-space: pre-wrap;
}
.bubble.err { border-color: var(--danger); color: #fecaca; }

/* ---- composer ---- */
.composer {
  display: flex;
  gap: 8px;
  margin: 18px 0 6px;
}
.composer input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
}
.composer input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.send {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  width: 46px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
}

/* ---- notes ---- */
.notes { margin-top: 22px; }
.notes-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.notes-head h2 { font-size: 15px; margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.count {
  font-size: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 1px 8px;
  border-radius: 999px;
  color: var(--muted);
}
.badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-left: auto;
}
.badge.on { color: #6ee7b7; border-color: #1f5c46; }
.badge.off { color: #fca5a5; border-color: #5c2b2b; }

.note-list { display: grid; gap: 10px; }
.note {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s ease, transform .1s ease;
}
.note:active { transform: scale(.995); }
.note:hover { border-color: #3a4570; }
.note .n-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.note h3 { margin: 0 0 6px; font-size: 16px; }
.note .n-body { color: var(--muted); font-size: 14px; white-space: pre-wrap; max-height: 5.4em; overflow: hidden; }
.note .n-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.tag {
  font-size: 11px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: #c7d0f0;
  padding: 1px 8px;
  border-radius: 999px;
}
.time { font-size: 11px; color: #6b769c; margin-left: auto; }
.del {
  border: none; background: transparent; color: #6b769c;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px;
}
.del:hover { color: var(--danger); }
.empty { color: #6b769c; font-size: 14px; text-align: center; padding: 20px 0; }

/* ---- dialogs ---- */
.dlg {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 18px;
  padding: 0;
  width: min(92vw, 460px);
}
.dlg::backdrop { background: rgba(3,6,16,.6); backdrop-filter: blur(2px); }
.dlg form { padding: 20px; }
.dlg h2 { margin: 0 0 14px; font-size: 18px; }
.dlg label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.dlg label.row { display: flex; align-items: center; gap: 8px; color: var(--text); }
.dlg input[type=text], .dlg input[type=password], .dlg select, .dlg textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.dlg textarea { resize: vertical; }
.fine { font-size: 12px; color: #7f8ab0; margin: 8px 0 0; }
.fine code { background: var(--card); padding: 1px 5px; border-radius: 5px; }

.dlg-actions { display: flex; gap: 8px; margin-top: 16px; }
.dlg-close { display: flex; justify-content: flex-end; margin: 18px 0 0; padding: 0; }
.dlg-close.spread { justify-content: flex-end; align-items: center; }
.dlg-close .spacer { flex: 1; }

button.primary, button.ghost {
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
}
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; }
button.ghost { background: var(--card); color: var(--text); }
button.ghost.danger { color: var(--danger); border-color: #4a2740; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 20px);
  transform: translateX(-50%);
  background: #0f1526;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 20;
  max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

[hidden] { display: none !important; }
