/* =========================================================
   VoiceVault — design system
   ========================================================= */
:root {
  --bg: hsl(232 40% 7%);
  --bg-2: hsl(240 35% 10%);
  --surface: hsl(235 30% 14% / 0.55);
  --surface-2: hsl(235 30% 20% / 0.55);
  --border: hsl(230 40% 80% / 0.09);
  --border-strong: hsl(230 40% 80% / 0.18);
  --text: hsl(228 40% 96%);
  --muted: hsl(228 15% 68%);
  --faint: hsl(228 12% 48%);

  --teal: hsl(168 76% 54%);
  --violet: hsl(262 89% 66%);
  --pink: hsl(320 85% 64%);
  --rec: hsl(352 90% 62%);
  --warn: hsl(38 95% 60%);
  --ok: hsl(150 70% 52%);

  --grad: linear-gradient(135deg, var(--teal), var(--violet));
  --grad-rec: linear-gradient(135deg, hsl(352 90% 62%), hsl(320 85% 60%));

  --radius-lg: 28px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 30px 80px -30px hsl(250 80% 3% / 0.9), 0 0 0 1px var(--border) inset;
  --blur: blur(22px) saturate(140%);

  --font: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 800px at 80% -10%, hsl(262 60% 18%), transparent 60%),
              radial-gradient(900px 700px at -10% 110%, hsl(170 60% 12%), transparent 60%),
              var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
svg { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
code { font-family: var(--mono); font-size: .85em; padding: .1em .4em; border-radius: 6px; background: hsl(0 0% 100% / .07); }
.muted { color: var(--muted); margin: 0; }
[hidden] { display: none !important; }

/* ---------- Background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .45; animation: float 22s var(--ease) infinite alternate; }
.orb-1 { width: 520px; height: 520px; background: hsl(262 89% 50%); top: -160px; right: -120px; }
.orb-2 { width: 460px; height: 460px; background: hsl(168 76% 38%); bottom: -180px; left: -140px; animation-delay: -7s; }
.orb-3 { width: 300px; height: 300px; background: hsl(320 85% 45%); top: 40%; left: 55%; opacity: .22; animation-delay: -13s; }
.grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(hsl(0 0% 100% / .03) 1px, transparent 1px),
                    linear-gradient(90deg, hsl(0 0% 100% / .03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
@keyframes float {
  to { transform: translate3d(-60px, 50px, 0) scale(1.12); }
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  background: linear-gradient(to bottom, hsl(232 40% 7% / .75), hsl(232 40% 7% / .3));
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--text); }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  background: var(--grad); color: var(--bg);
  box-shadow: 0 8px 24px -8px hsl(168 76% 54% / .6);
}
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2.2; }
.brand-name { font-weight: 600; font-size: 1.2rem; letter-spacing: -.01em; }
.brand-name span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.topbar-actions { display: flex; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .45rem .85rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: .85rem; font-weight: 500; color: var(--muted);
  transition: border-color .25s, background .25s, color .25s, transform .2s var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transition: background .3s, box-shadow .3s; }
.chip[data-state="unlocked"] .chip-dot,
.chip[data-state="on"] .chip-dot { background: var(--ok); box-shadow: 0 0 0 4px hsl(150 70% 52% / .18); }
.chip[data-state="locked"] .chip-dot { background: var(--warn); }
.chip[data-state="error"] .chip-dot { background: var(--rec); }
.chip[data-state="busy"] .chip-dot { background: var(--teal); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2.5rem);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(1rem, 2.5vw, 1.75rem);
  align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  padding: clamp(1.25rem, 3vw, 2.25rem);
  animation: rise .7s var(--ease) both;
}
.notes { animation-delay: .08s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

/* ---------- Recorder ---------- */
.recorder { text-align: center; position: relative; overflow: hidden; }
.recorder::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(500px 260px at 50% 62%, hsl(262 89% 66% / .14), transparent 70%);
  transition: background .6s;
}
body.is-recording .recorder::before { background: radial-gradient(520px 280px at 50% 62%, hsl(352 90% 62% / .2), transparent 70%); }

.eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .8rem; border-radius: 999px;
  font-size: .78rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
  color: var(--teal); background: hsl(168 76% 54% / .1); border: 1px solid hsl(168 76% 54% / .25);
}
.recorder h1 {
  font-size: clamp(1.7rem, 3.6vw, 2.5rem); line-height: 1.12; letter-spacing: -.025em;
  font-weight: 600; margin: 1rem 0 .6rem;
}
.recorder h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); max-width: 44ch; margin: 0 auto; font-size: 1rem; }

.stage { position: relative; margin: 1.75rem 0 1.25rem; display: grid; justify-items: center; }
.visualizer { width: 100%; height: 120px; display: block; }
.record-wrap { position: relative; display: grid; place-items: center; width: 132px; height: 132px; margin-top: -6px; }
.ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid hsl(262 89% 66% / .35);
  animation: ring 3.2s var(--ease) infinite;
}
.ring-2 { animation-delay: 1.6s; }
body.is-recording .ring { border-color: hsl(352 90% 62% / .6); animation-duration: 1.6s; }
body.is-recording .ring-2 { animation-delay: .8s; }
@keyframes ring { from { transform: scale(.8); opacity: .9; } to { transform: scale(1.45); opacity: 0; } }

.record-btn {
  position: relative; width: 104px; height: 104px; border-radius: 50%; border: 0;
  background: var(--grad);
  box-shadow: 0 18px 50px -12px hsl(262 89% 60% / .7), inset 0 2px 0 hsl(0 0% 100% / .35), inset 0 -10px 24px hsl(250 80% 20% / .35);
  display: grid; place-items: center;
  transition: transform .25s var(--ease), box-shadow .3s, background .3s;
}
.record-btn:hover { transform: scale(1.05); }
.record-btn:active { transform: scale(.96); }
.record-icon {
  width: 34px; height: 34px; border-radius: 50%; background: hsl(0 0% 100%);
  box-shadow: 0 4px 14px hsl(250 80% 10% / .35);
  transition: border-radius .3s var(--ease), width .3s var(--ease), height .3s var(--ease);
}
body.is-recording .record-btn { background: var(--grad-rec); box-shadow: 0 18px 50px -12px hsl(352 90% 60% / .8), inset 0 2px 0 hsl(0 0% 100% / .35); }
body.is-recording .record-icon { width: 30px; height: 30px; border-radius: 8px; }
body.is-busy .record-btn { pointer-events: none; }
body.is-busy .record-icon { width: 34px; height: 34px; border-radius: 50%; background: transparent; border: 3px solid hsl(0 0% 100% / .35); border-top-color: #fff; animation: spin .8s linear infinite; box-shadow: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.timer { font-family: var(--mono); font-size: 2rem; letter-spacing: .06em; margin-top: 1.1rem; font-variant-numeric: tabular-nums; color: var(--text); }
body:not(.is-recording) .timer { color: var(--faint); }
.hint { margin: .25rem 0 0; color: var(--muted); font-size: .95rem; min-height: 1.5em; }

.steps { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; justify-content: center; gap: .5rem; flex-wrap: wrap; }
.steps li {
  display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted);
  padding: .4rem .8rem .4rem .45rem; border-radius: 999px; background: hsl(0 0% 100% / .04); border: 1px solid var(--border);
}
.steps span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .75rem; font-weight: 600; background: hsl(0 0% 100% / .08); color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.05rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 500; font-size: .92rem;
  transition: transform .2s var(--ease), background .25s, border-color .25s, box-shadow .25s;
}
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn-primary { background: var(--grad); color: hsl(240 40% 8%); font-weight: 600; box-shadow: 0 10px 30px -12px hsl(168 76% 54% / .7); }
.btn-ghost { background: hsl(0 0% 100% / .05); border-color: var(--border); color: var(--text); }
.btn-ghost:not(:disabled):hover { background: hsl(0 0% 100% / .09); border-color: var(--border-strong); }
.btn-danger { background: var(--rec); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--rec); border-color: hsl(352 90% 62% / .3); }
.btn.is-loading svg { animation: spin 1s linear infinite; }
.link-btn { justify-self: start; padding: 0; border: 0; background: none; color: var(--muted); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--teal); }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  background: hsl(0 0% 100% / .04); border: 1px solid var(--border); color: var(--muted);
  transition: background .2s, color .2s, border-color .2s, transform .2s var(--ease);
}
.icon-btn:not(:disabled):hover { color: var(--text); background: hsl(0 0% 100% / .1); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn.play:not(:disabled):hover { color: var(--teal); }
.icon-btn.danger:not(:disabled):hover { color: var(--rec); border-color: hsl(352 90% 62% / .35); }

/* ---------- Notes ---------- */
.notes-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.notes-head h2 { margin: 0; font-size: 1.4rem; font-weight: 600; letter-spacing: -.01em; }
.notes-actions { display: flex; gap: .5rem; }

.notes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; max-height: min(62vh, 640px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; padding-right: 2px; }
.note {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .9rem;
  padding: .85rem .9rem; border-radius: var(--radius);
  background: hsl(0 0% 100% / .035); border: 1px solid var(--border);
  transition: border-color .25s, background .25s, transform .25s var(--ease);
  animation: rise .45s var(--ease) both;
}
.note:hover { border-color: var(--border-strong); background: hsl(0 0% 100% / .06); }
.note.is-playing { border-color: hsl(168 76% 54% / .5); background: hsl(168 76% 54% / .07); }
.note-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, hsl(168 76% 54% / .18), hsl(262 89% 66% / .18));
  color: var(--teal); border: 1px solid hsl(168 76% 54% / .2);
}
.note-body { min-width: 0; }
.note-title { margin: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .2rem; font-size: .8rem; color: var(--muted); }
.note-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 500; border: 1px solid var(--border);
}
.badge svg { width: 12px; height: 12px; }
.badge.enc { color: var(--teal); background: hsl(168 76% 54% / .08); border-color: hsl(168 76% 54% / .2); }
.badge.cloud { color: hsl(262 89% 76%); background: hsl(262 89% 66% / .1); border-color: hsl(262 89% 66% / .25); }
.badge.local { color: var(--muted); }
.note-actions { display: flex; gap: .35rem; }
@media (max-width: 520px) {
  .note { grid-template-columns: auto 1fr; }
  .note-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

.empty { text-align: center; padding: 2.5rem 1rem; }
.empty p { margin: .2rem 0; }
.empty-icon {
  display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; margin-bottom: .8rem;
  background: hsl(0 0% 100% / .04); border: 1px dashed var(--border-strong); color: var(--faint);
}
.empty-icon svg { width: 28px; height: 28px; }

/* ---------- Player ---------- */
.player {
  position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(720px, calc(100% - 2rem)); z-index: 20;
  display: flex; align-items: center; gap: .9rem;
  padding: .7rem .8rem .7rem 1.1rem; border-radius: 20px;
  background: hsl(235 30% 14% / .85); border: 1px solid var(--border-strong);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 24px 60px -20px hsl(250 80% 3%);
  animation: slideUp .4s var(--ease);
}
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 20px); } }
.player-info { display: grid; min-width: 0; flex: 0 1 200px; }
.player-badge { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--teal); }
.player-title { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player audio { flex: 1; min-width: 0; height: 40px; }
@media (max-width: 560px) { .player { flex-wrap: wrap; } .player audio { flex-basis: 100%; order: 3; } .player-info { flex: 1; } }

/* ---------- Dialog ---------- */
.dialog {
  width: min(440px, calc(100% - 2rem)); padding: 0; border: 1px solid var(--border-strong);
  border-radius: 24px; color: var(--text);
  background: hsl(236 32% 12% / .92);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 40px 100px -30px hsl(250 80% 2%);
  opacity: 0; transform: translateY(12px) scale(.98);
  transition: opacity .25s var(--ease), transform .25s var(--ease), overlay .25s allow-discrete, display .25s allow-discrete;
}
.dialog[open] { opacity: 1; transform: none; }
@starting-style { .dialog[open] { opacity: 0; transform: translateY(12px) scale(.98); } }
.dialog::backdrop { background: hsl(235 50% 3% / .65); backdrop-filter: blur(6px); transition: background .25s, overlay .25s allow-discrete, display .25s allow-discrete; }
.dialog-body { padding: 1.75rem; display: grid; gap: .9rem; }
.dialog-body h3 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.dialog-icon {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px;
  background: var(--grad); color: hsl(240 40% 8%);
}
.dialog-icon svg { width: 26px; height: 26px; stroke-width: 2; }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .4rem; flex-wrap: wrap; }
.spacer { flex: 1; }

.field { display: grid; gap: .4rem; font-size: .88rem; color: var(--muted); }
.field input {
  font: inherit; font-size: 1rem; color: var(--text);
  padding: .75rem .9rem; border-radius: var(--radius-sm);
  background: hsl(0 0% 100% / .05); border: 1px solid var(--border-strong);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px hsl(168 76% 54% / .15); background: hsl(0 0% 100% / .07); }
.error { margin: 0; min-height: 1.2em; color: var(--rec); font-size: .88rem; }
.error:empty { min-height: 0; }
.callout { margin: 0; padding: .7rem .85rem; border-radius: var(--radius-sm); font-size: .85rem; color: hsl(38 95% 75%); background: hsl(38 95% 60% / .08); border: 1px solid hsl(38 95% 60% / .25); }
.status-line { margin: 0; font-size: .88rem; display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.status-line::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status-line[data-state="ok"]::before { background: var(--ok); }
.status-line[data-state="error"]::before { background: var(--rec); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 5rem; right: 1rem; z-index: 50; display: grid; gap: .5rem; width: min(360px, calc(100% - 2rem)); }
.toast {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .8rem 1rem; border-radius: 14px; font-size: .9rem;
  background: hsl(236 32% 14% / .92); border: 1px solid var(--border-strong);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 18px 40px -16px hsl(250 80% 3%);
  animation: toastIn .35s var(--ease) both;
}
.toast.out { animation: toastOut .3s var(--ease) forwards; }
.toast::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: .45rem; border-radius: 50%; background: var(--teal); }
.toast.error::before { background: var(--rec); }
.toast.warn::before { background: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 1rem 1rem 6rem; color: var(--faint); font-size: .8rem; }
.noscript { text-align: center; color: var(--warn); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
