/* ============================================================
   FreeNBLM — design system
   Warm paper, ink text, one restrained accent. Editorial, calm,
   built for reading and listening.
   ============================================================ */

:root {
  --bg: #faf9f6;
  --bg-soft: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #f6f4ef;
  --border: #e9e5db;
  --border-strong: #d8d2c4;
  --ink: #1d2027;
  --ink-2: #3c414d;
  --dim: #6c7280;
  --faint: #9aa1ad;
  --accent: #0f766e;
  --accent-deep: #0b5d56;
  --accent-soft: #e7f3f0;
  --accent-wash: rgba(15, 118, 110, 0.08);
  --amber: #b45309;
  --ok: #15803d;
  --err: #b91c1c;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(29, 32, 39, 0.05), 0 4px 14px -6px rgba(29, 32, 39, 0.08);
  --shadow-md: 0 2px 4px rgba(29, 32, 39, 0.05), 0 14px 34px -16px rgba(29, 32, 39, 0.14);
  --shadow-lg: 0 4px 10px rgba(29, 32, 39, 0.06), 0 28px 60px -24px rgba(29, 32, 39, 0.18);
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --nav-h: 68px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 18px); }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(15, 118, 110, 0.16); color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(29, 32, 39, 0.18); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(29, 32, 39, 0.3); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ============ ambient background (soft light) ============ */

#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.cursor-glow {
  position: fixed; left: 0; top: 0; width: 560px; height: 560px;
  border-radius: 50%; pointer-events: none; z-index: 1;
  background: radial-gradient(circle, rgba(180, 160, 120, 0.08) 0%, rgba(255, 255, 255, 0) 62%);
  transform: translate(-50%, -50%);
}

.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.aurora-blob {
  position: absolute; border-radius: 50%; filter: blur(120px);
  will-change: transform, opacity;
  animation: aurora-drift 34s ease-in-out infinite alternate;
}
.ab-1 { width: 46vw; height: 46vw; left: -12vw; top: -18vw;
  background: radial-gradient(circle at 40% 40%, rgba(214, 205, 186, 0.55), transparent 65%); }
.ab-2 { width: 40vw; height: 40vw; right: -10vw; top: 16vh;
  background: radial-gradient(circle at 60% 40%, rgba(196, 218, 214, 0.5), transparent 65%); animation-delay: -11s; }
.ab-3 { width: 38vw; height: 38vw; left: 30vw; bottom: -20vw;
  background: radial-gradient(circle at 50% 50%, rgba(226, 209, 188, 0.42), transparent 65%); animation-delay: -20s; }
@keyframes aurora-drift {
  from { transform: translate(0, 0) scale(1) rotate(0deg); }
  to { transform: translate(5vw, 4vh) scale(1.1) rotate(6deg); }
}
.aurora-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 120% 90% at 50% 30%, transparent 60%, rgba(244, 242, 236, 0.7) 100%);
}

/* ============ nav ============ */

.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: var(--nav-h);
  display: flex; align-items: center;
  transition: background .4s ease, border-color .4s ease, backdrop-filter .4s ease, box-shadow .4s ease;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(250, 249, 246, 0.82);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom-color: var(--border);
  box-shadow: 0 10px 30px -22px rgba(29, 32, 39, 0.35);
}
.nav-inner {
  width: min(1120px, 100%); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; position: relative;
  background: linear-gradient(140deg, var(--accent), var(--accent-deep));
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { display: block; }
.brand-mark.sm { width: 30px; height: 30px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text small { font-size: 10.5px; color: var(--faint); }

.nav-links { display: flex; gap: 4px; }
.nav-link {
  position: relative; color: var(--dim); text-decoration: none; font-size: 14px;
  padding: 8px 14px; border-radius: 10px; transition: color .25s, background .25s;
}
.nav-link::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 4px; height: 2px;
  border-radius: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.nav-link:hover { color: var(--ink); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }
.nav-link.active { color: var(--ink); }

.nav-status {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: #c9c4b8; position: relative; }
.pulse-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid currentColor; opacity: 0; animation: ping 2.4s ease-out infinite;
}
.nav-status.ok { color: var(--ok); }
.nav-status.ok .pulse-dot { background: var(--ok); }
.nav-status.ok .pulse-dot::after { border-color: var(--ok); animation: ping 2.4s ease-out infinite; }
.nav-status.down { color: var(--err); }
.nav-status.down .pulse-dot { background: var(--err); }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 80%, 100% { transform: scale(1.6); opacity: 0; } }

/* ============ layout ============ */

main { position: relative; z-index: 2; max-width: 940px; margin: 0 auto; padding: calc(var(--nav-h) + 8px) 24px 0; }

/* ============ hero ============ */

.hero { text-align: center; padding: 70px 8px 44px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 14px;
  font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 26px;
}
.eyebrow-line { width: 34px; height: 1px; background: linear-gradient(90deg, transparent, var(--border-strong)); }
.eyebrow-line:last-child { background: linear-gradient(90deg, var(--border-strong), transparent); }

.hero-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(40px, 7vw, 70px); line-height: 1.08; letter-spacing: -0.02em;
  margin: 0 0 24px; color: var(--ink);
}
.hero-title .word {
  display: inline-block; opacity: 0;
  transform: translateY(26px) scale(.98); filter: blur(6px);
  transition: opacity .9s var(--ease), transform .9s var(--ease), filter .9s var(--ease);
  will-change: transform, opacity, filter;
}
.hero-title.in .word { opacity: 1; transform: none; filter: blur(0); }
.hero-title .grad {
  background: linear-gradient(105deg, var(--accent) 10%, #3d8f7d 55%, var(--amber) 105%);
  background-size: 200% 200%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: hue-flow 9s ease infinite;
}
@keyframes hue-flow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero-sub {
  color: var(--dim); max-width: 620px; margin: 0 auto 32px;
  font-size: clamp(15.5px, 2vw, 17.5px); line-height: 1.7;
}
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 48px; }

.hero-metrics {
  display: flex; justify-content: center; gap: clamp(22px, 6vw, 64px); flex-wrap: wrap;
  opacity: 0; transform: translateY(16px);
  transition: opacity .9s var(--ease) .5s, transform .9s var(--ease) .5s;
}
.hero.in .hero-metrics { opacity: 1; transform: none; }
.metric { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.metric strong { font-family: var(--font-display); font-size: 27px; font-weight: 600; color: var(--accent-deep); }
.metric span { font-size: 12px; color: var(--faint); letter-spacing: .04em; }

/* ============ buttons ============ */

.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: 0; border-radius: 13px; padding: 12px 22px;
  font-family: var(--font-body); font-size: 15px; font-weight: 600; cursor: pointer;
  text-decoration: none; color: var(--ink); overflow: hidden;
  transition: transform .3s var(--ease), box-shadow .35s ease, background .3s ease, border-color .3s ease, color .3s ease;
  will-change: transform;
}
.btn svg { display: block; }
.btn-lg { padding: 15px 30px; font-size: 16px; border-radius: 15px; }
.btn-primary {
  background: var(--ink); color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); background: #2a2e38; }
.btn-ghost {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--ink);
}
.btn-ghost:hover { background: var(--surface-2); border-color: #c4bda9; transform: translateY(-1px); }
.btn:active { transform: scale(.98); }

.btn-shine { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.btn-shine::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: -30%; width: 42%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-18deg) translateX(-160%);
  transition: transform .7s var(--ease);
}
.btn:hover .btn-shine::before { transform: skewX(-18deg) translateX(480%); }

/* ============ ad slots ============ */

.ad-slot { margin: 30px 0; text-align: center; }
.ad-label { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: var(--faint); }
.ad-placeholder {
  margin-top: 10px; border: 1px dashed var(--border-strong); border-radius: 14px;
  color: var(--faint); font-size: 13px; padding: 24px;
  background: rgba(255, 255, 255, 0.5);
}
/* A-ADS unit wrapper + iframe (inline styles are blocked by the site's CSP) */
.ad-frame { width: 100%; margin: auto; position: relative; }
.ad-frame iframe {
  border: 0; padding: 0; width: 70%; height: auto; overflow: hidden;
  display: block; margin: auto;
}

/* ============ cards ============ */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.generator-section { scroll-margin-top: calc(var(--nav-h) + 20px); }
.status-card, .result-card { margin-top: 18px; animation: card-in .6s var(--ease); }
@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(.995); } to { opacity: 1; transform: none; } }

/* ============ tabs ============ */

.tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 5px; border-radius: 13px;
}
.tab {
  flex: 1; background: transparent; border: 0; color: var(--dim); font-size: 14px; font-weight: 500;
  padding: 11px; border-radius: 9px; cursor: pointer; transition: all .3s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow-sm); }

/* ============ panes ============ */

.pane { display: none; }
.pane.active { display: block; animation: fade-up .4s var(--ease); }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

textarea {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--ink); border-radius: var(--radius-md); padding: 15px 17px; font-size: 15px;
  font-family: inherit; resize: vertical; line-height: 1.6;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
  background: #fff;
}
.char-count { text-align: right; font-size: 11.5px; color: var(--faint); margin-top: 7px; font-variant-numeric: tabular-nums; }
.char-count.warn { color: var(--err); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md); padding: 38px 20px;
  cursor: pointer; color: var(--dim); transition: all .3s var(--ease); position: relative; overflow: hidden;
  background: var(--bg-soft);
}
.dropzone::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: radial-gradient(400px 200px at 50% 100%, var(--accent-wash), transparent);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.dropzone:hover::before, .dropzone.drag::before { opacity: 1; }
.dz-icon { color: var(--accent); }
.dz-main { color: var(--ink); font-size: 15px; font-weight: 500; }
.dz-main u { text-decoration-color: var(--accent); text-underline-offset: 3px; }
.dz-sub { font-size: 12px; color: var(--faint); }

.file-chip:not([hidden]) {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 14px;
  background: var(--accent-soft); border: 1px solid rgba(15, 118, 110, 0.25);
  color: var(--ink); font-size: 13px; padding: 9px 15px; border-radius: 99px;
  animation: fade-up .4s var(--ease);
}
.file-chip svg { color: var(--accent); }
.file-chip .file-chip-remove { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 14px; padding: 0 2px; display: grid; place-items: center; }
.file-chip .file-chip-remove:hover { color: var(--err); }

.url-field { position: relative; display: flex; align-items: center; }
.url-icon {
  position: absolute; left: 16px; color: var(--faint); display: grid; place-items: center; pointer-events: none;
}
.url-field input {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border); color: var(--ink);
  border-radius: var(--radius-md); padding: 15px 16px 15px 46px; font-size: 15px; font-family: inherit;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.url-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); background: #fff; }

/* ============ output picker ============ */

.output-picker { margin-top: 24px; }
.picker-label { font-size: 13px; color: var(--dim); margin: 0 0 12px; letter-spacing: .02em; }
.picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; perspective: 1000px; }
.output-opt {
  position: relative; background: var(--bg-soft); border: 1.5px solid var(--border);
  border-radius: 17px; padding: 20px 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; color: var(--dim); font-family: inherit;
  transition: border-color .3s, box-shadow .3s, transform .25s var(--ease-out), background .3s;
  transform-style: preserve-3d; will-change: transform;
  overflow: hidden;
}
.output-opt::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(240px 120px at var(--mx, 50%) var(--my, 0%), var(--accent-wash), transparent);
  opacity: 0; transition: opacity .3s;
}
.output-opt:hover { border-color: rgba(15, 118, 110, 0.55); color: var(--ink); }
.output-opt:hover::before { opacity: 1; }
.output-opt.active {
  border-color: var(--accent); background: #fff; color: var(--accent-deep);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.oo-icon { display: grid; place-items: center; transition: transform .35s var(--ease); }
.output-opt:hover .oo-icon { transform: scale(1.1); }
.oo-title { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.oo-sub { font-size: 11px; opacity: .8; text-align: center; line-height: 1.4; }
.oo-check {
  position: absolute; top: 9px; right: 9px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  opacity: 0; transform: scale(.4) rotate(-30deg); transition: all .35s var(--ease);
}
.output-opt.active .oo-check { opacity: 1; transform: scale(1) rotate(0); }

/* ============ options ============ */

.options { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 24px 0 18px; }
.opt { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: var(--dim); }
.opt-label { font-size: 13px; }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; -webkit-appearance: none;
  background: var(--bg-soft); color: var(--ink); border: 1px solid var(--border);
  border-radius: 11px; padding: 9px 34px 9px 13px; font-size: 13.5px; font-family: inherit; cursor: pointer;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.select-wrap select:hover { border-color: var(--border-strong); }
.select-wrap select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); background: #fff; }
.select-chev { position: absolute; right: 12px; top: 50%; transform: translateY(-55%); color: var(--dim); pointer-events: none; }

.toggle { cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle-track {
  width: 42px; height: 23px; border-radius: 99px; background: var(--border-strong);
  position: relative; transition: background .3s; flex-shrink: 0; border: 1px solid var(--border);
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; transition: transform .3s var(--ease), background .3s;
  box-shadow: 0 1px 3px rgba(29, 32, 39, 0.3);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: transparent; }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(19px); }
.toggle-label { font-size: 13.5px; }

/* ============ generate button ============ */

.btn-generate {
  width: 100%; border: 0; border-radius: 15px; padding: 16px; font-size: 16px; font-weight: 600;
  font-family: var(--font-body);
  background: var(--ink); color: #fff; cursor: pointer; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 11px;
  transition: transform .3s var(--ease), box-shadow .35s ease, background .3s, opacity .3s;
  box-shadow: var(--shadow-sm);
  will-change: transform;
}
.btn-generate:hover:not(:disabled) { background: #2a2e38; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-generate:active:not(:disabled) { transform: scale(.99); }
.btn-generate:disabled { cursor: not-allowed; opacity: .65; }
.btn-spinner:not([hidden]) {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.3); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error, .status-error {
  color: var(--err); font-size: 13.5px; margin: 14px 0 0;
  background: rgba(185, 28, 28, 0.07); border: 1px solid rgba(185, 28, 28, 0.22);
  padding: 11px 15px; border-radius: 12px; animation: fade-up .35s var(--ease);
}
/* rate-limit / queue-full notices read as gentle guidance, not a crash */
.form-error[data-kind="rate"] {
  color: var(--amber);
  background: rgba(180, 83, 9, 0.08);
  border-color: rgba(180, 83, 9, 0.3);
}

/* ============ status card ============ */

.status-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.status-head h2, .result-title h2 { margin: 0 0 3px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.status-sub { margin: 0; color: var(--dim); font-size: 13.5px; }
.queue-info:not([hidden]) {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); border: 1px solid rgba(15, 118, 110, 0.22);
  color: var(--accent-deep); font-size: 12.5px; padding: 8px 14px; border-radius: 99px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.queue-pos { font-weight: 700; }

.cancel-btn {
  padding: 9px 16px; font-size: 13px; color: var(--dim); flex-shrink: 0;
}
.cancel-btn:hover {
  color: var(--err); border-color: rgba(185, 28, 28, 0.4);
  background: rgba(185, 28, 28, 0.05);
}

.stepper { list-style: none; display: flex; gap: 8px; padding: 30px 0 4px; margin: 0; }
.stepper li {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px;
  font-size: 12px; color: var(--faint); position: relative; text-align: center;
  transition: color .4s;
}
.stepper li:not(:last-child)::after {
  content: ""; position: absolute; top: 10px; left: calc(50% + 14px); width: calc(100% - 28px);
  height: 2px; border-radius: 2px; background: var(--border);
  transition: background .5s ease;
}
.step-dot {
  width: 21px; height: 21px; border-radius: 50%; z-index: 1;
  background: var(--surface); border: 2px solid var(--border-strong);
  display: grid; place-items: center; transition: all .4s var(--ease);
  position: relative;
}
.step-dot::after {
  content: "✓"; font-size: 11px; font-weight: 800; color: #fff;
  opacity: 0; transform: scale(.4); transition: all .3s var(--ease);
}
.stepper li.active { color: var(--ink); }
.stepper li.active .step-dot {
  background: var(--accent); border-color: transparent;
  animation: dot-pulse 1.8s ease-out infinite;
}
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.35); }
  70% { box-shadow: 0 0 0 12px rgba(15, 118, 110, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0); }
}
.stepper li.done { color: var(--ok); }
.stepper li.done .step-dot { background: var(--ok); border-color: transparent; }
.stepper li.done .step-dot::after { opacity: 1; transform: scale(1); }
.stepper li.done:not(:last-child)::after { background: rgba(21, 128, 61, 0.4); }
.stepper li.fail .step-dot { background: var(--err); border-color: transparent; }
.stepper li.fail { color: var(--err); }

.progress { height: 6px; border-radius: 99px; background: var(--bg-soft); margin-top: 22px; overflow: hidden; position: relative; border: 1px solid var(--border); }
.progress-bar {
  height: 100%; width: 0%; border-radius: 99px; position: relative;
  background: linear-gradient(90deg, var(--accent), #2f9c8a);
  transition: width .7s var(--ease);
}
.progress-shimmer {
  position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.5) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ============ result ============ */

.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.result-title { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; min-width: 0; }
.result-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.ready-badge {
  background: rgba(21, 128, 61, 0.1); color: var(--ok); border: 1px solid rgba(21, 128, 61, 0.3);
  font-size: 12px; padding: 4px 11px; border-radius: 99px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  animation: pop-in .5s var(--ease);
}
.ready-badge svg { display: block; }
@keyframes pop-in { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
.result-actions { display: flex; gap: 10px; }

#resultBody video { width: 100%; margin-top: 22px; border-radius: var(--radius-md); background: #101216; box-shadow: var(--shadow-sm); }
#resultBody audio { width: 100%; margin-top: 22px; }

/* custom audio player — always-visible, theme-matched */
.audioplayer {
  display: flex; align-items: center; gap: 14px; margin-top: 22px;
  padding: 14px 18px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-md); animation: fade-up .5s var(--ease);
}
.ap-play {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink); color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center; position: relative;
  transition: transform .2s var(--ease), background .2s;
  box-shadow: var(--shadow-sm);
}
.ap-play:hover { background: var(--accent); transform: scale(1.05); }
.ap-play:active { transform: scale(.96); }
.ap-play svg { display: block; }
.ap-play .ap-pause { display: none; }
.ap-play.playing .ap-playicon { display: none; }
.ap-play.playing .ap-pause { display: block; }
.ap-track {
  flex: 1; height: 6px; border-radius: 99px; background: var(--border-strong);
  position: relative; cursor: pointer; min-width: 60px;
}
.ap-fill { position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: 99px; background: var(--accent); }
.ap-knob {
  position: absolute; top: 50%; left: 0; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  transform: translate(-50%, -50%); box-shadow: 0 1px 4px rgba(29, 32, 39, 0.25);
  pointer-events: none;
}
.ap-time { font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ap-dl { color: var(--dim); display: grid; place-items: center; padding: 7px; border-radius: 9px; transition: color .2s, background .2s; flex-shrink: 0; }
.ap-dl:hover { color: var(--accent); background: var(--accent-soft); }
.ap-dl svg { display: block; }

/* notes */
.notes-body {
  margin-top: 22px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 22px 26px; font-size: 14.5px; line-height: 1.7;
  animation: fade-up .5s var(--ease);
}
.notes-body > * { opacity: 0; transform: translateY(8px); animation: fade-up .5s var(--ease) forwards; }
.notes-body > *:nth-child(2) { animation-delay: .05s; }
.notes-body > *:nth-child(3) { animation-delay: .1s; }
.notes-body > *:nth-child(4) { animation-delay: .15s; }
.notes-body > *:nth-child(5) { animation-delay: .2s; }
.notes-body > *:nth-child(6) { animation-delay: .25s; }
.notes-body > *:nth-child(7) { animation-delay: .3s; }
.notes-body > *:nth-child(8) { animation-delay: .35s; }
.notes-body > *:nth-child(n+9) { animation-delay: .4s; }
.notes-body h1, .notes-body h2, .notes-body h3 { font-family: var(--font-display); margin: 20px 0 9px; letter-spacing: -0.01em; color: var(--ink); }
.notes-body h2 { border-bottom: 1px solid var(--border); padding-bottom: 7px; }
.notes-body h1:first-child, .notes-body h2:first-child { margin-top: 0; }
.notes-body ul { padding-left: 4px; margin: 9px 0; }
.notes-body li { margin: 5px 0; list-style: none; position: relative; padding-left: 22px; }
.notes-body li::before {
  content: ""; position: absolute; left: 0; top: 9px; width: 7px; height: 7px; border-radius: 2px;
  background: var(--accent);
}
.notes-body strong { color: var(--ink); font-weight: 600; }
.notes-body code { background: var(--accent-soft); padding: 1px 7px; border-radius: 6px; font-size: 13px; color: var(--accent-deep); font-family: ui-monospace, monospace; }
.notes-body blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 5px 15px; color: var(--dim); }
.notes-body hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* mind map */
.mindmap-wrap {
  margin-top: 22px; overflow: auto; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius-md); min-height: 320px;
  animation: fade-up .5s var(--ease);
}
#mindmapSvg { display: block; }
#mindmapSvg .mm-line { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .9s var(--ease); }
#mindmapSvg.mm-ready .mm-line { stroke-dashoffset: 0; }
#mindmapSvg .mm-node { opacity: 0; transform: scale(.85); transform-origin: center; transition: opacity .5s var(--ease), transform .5s var(--ease); }
#mindmapSvg.mm-ready .mm-node { opacity: 1; transform: scale(1); }
#mindmapSvg .mm-node:hover rect { filter: brightness(0.97); }
#mindmapSvg rect { transition: filter .2s; }

.script-details { margin-top: 20px; }
.script-details summary {
  cursor: pointer; color: var(--dim); font-size: 13.5px; font-weight: 500;
  list-style: none; display: inline-flex; align-items: center; gap: 8px; transition: color .2s;
}
.script-details summary::-webkit-details-marker { display: none; }
.script-details summary::before { content: "▸"; transition: transform .3s var(--ease); color: var(--accent); }
.script-details[open] summary::before { transform: rotate(90deg); }
.script-details summary:hover { color: var(--ink); }
.script-details pre {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 17px; font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; color: var(--dim);
  font-family: inherit; max-height: 330px; overflow: auto; margin: 14px 0 0;
}

/* ============ recent ============ */

.recent { margin-top: 44px; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.recent-head h2 { font-family: var(--font-display); font-size: 21px; margin: 0; }
.recent-hint { font-size: 11.5px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 13px; }
.recent-item {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 17px; cursor: pointer; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
}
.recent-item::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(240px 120px at 50% 0%, var(--accent-wash), transparent);
  opacity: 0; transition: opacity .3s;
}
.recent-item:hover { transform: translateY(-3px); border-color: rgba(15, 118, 110, 0.45); box-shadow: var(--shadow-sm); }
.recent-item:hover::after { opacity: 1; }
.recent-item h3 { margin: 0 0 5px; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item p { margin: 0; font-size: 12px; color: var(--faint); }
.recent-item .ri-icon { color: var(--accent); display: inline-grid; place-items: center; margin-right: 6px; vertical-align: -2px; }
.recent-item .ri-icon svg { display: block; }

/* ============ how it works ============ */

.how { padding: 70px 0 20px; }
.how-head { text-align: center; max-width: 640px; margin: 0 auto 40px; }
.how-head h2 { font-family: var(--font-display); font-size: clamp(27px, 4vw, 36px); margin: 0 0 12px; letter-spacing: -0.01em; color: var(--ink); }
.how-head p { color: var(--dim); font-size: 15.5px; margin: 0; }
.how-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.step { padding: 24px 20px; text-align: left; }
.step-num { font-size: 12px; font-weight: 700; color: var(--faint); letter-spacing: .14em; }
.step-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 14px 0 12px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-deep); }
.step h3 { font-size: 16px; font-weight: 700; margin: 0 0 7px; }
.step p { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.6; }
.step svg { display: block; }

/* ============ footer ============ */

.footer { padding: 36px 0 60px; text-align: center; }
.footer-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.footer-brand strong { font-size: 15px; }
.footer-brand small { display: block; font-size: 11px; color: var(--faint); }
.footer-note { color: var(--faint); font-size: 12.5px; margin: 0; }

/* ============ toast ============ */

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--ink); border: 1px solid rgba(255, 255, 255, 0.12); color: #fff;
  padding: 13px 22px; border-radius: 14px; font-size: 14px; z-index: 200;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .4s var(--ease), transform .4s var(--ease);
  font-variant-numeric: tabular-nums;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ scroll reveal ============ */

.reveal {
  opacity: 0; transform: translateY(22px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
  transition-delay: var(--d, 0ms);
}
.reveal.in { opacity: 1; transform: none; }
.how-grid .reveal, .step[data-delay] { transition-delay: var(--d, 0ms); }

/* ============ responsive ============ */

@media (max-width: 820px) {
  .picker-grid { grid-template-columns: repeat(2, 1fr); }
  .how-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
}
@media (max-width: 560px) {
  .card { padding: 20px; }
  .options { flex-direction: column; align-items: stretch; }
  .result-actions { width: 100%; }
  .result-actions .btn { flex: 1; }
  .hero { padding-top: 44px; }
  .result-title h2 { max-width: 100%; white-space: normal; }
  .how-grid { grid-template-columns: 1fr; }
  .audioplayer { flex-wrap: wrap; }
}

/* ============ reduced motion ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
  .hero-title .word, .hero-metrics, .reveal { opacity: 1; transform: none; filter: none; }
  #stars, .cursor-glow { display: none; }
}

/* ============ public library ============ */

.library-view {
  width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px 96px;
  animation: card-in .5s ease both;
}
.lib-head { text-align: center; padding: 64px 0 28px; }
.lib-head h2 {
  font-family: var(--font-display); font-size: clamp(27px, 4vw, 38px);
  color: var(--ink); letter-spacing: -0.02em; margin: 0 0 8px;
}
.lib-head p { color: var(--dim); margin: 0 auto 26px; max-width: 560px; font-size: 15px; }
.lib-search { display: flex; gap: 10px; max-width: 520px; margin: 0 auto 18px; }
.lib-search input {
  flex: 1; min-width: 0; padding: 13px 18px; border-radius: 13px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 14px; outline: none;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.lib-search input::placeholder { color: var(--faint); }
.lib-search input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash);
}
.lib-filters { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 34px; }
.lib-filter {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--dim); font: inherit; font-size: 13px;
  cursor: pointer; transition: all .2s ease;
}
.lib-filter:hover { border-color: rgba(15, 118, 110, 0.5); color: var(--ink); }
.lib-filter.active {
  background: var(--ink); color: #fff; border-color: transparent; font-weight: 600;
}

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.lib-card {
  position: relative; border-radius: 17px; overflow: hidden; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
}
.lib-card:hover {
  transform: translateY(-4px); border-color: rgba(15, 118, 110, 0.5);
  box-shadow: var(--shadow-md);
}
.lib-cover {
  height: 124px; display: flex; align-items: center; justify-content: center;
  color: #fff; position: relative;
}
.lib-cover svg { display: block; }
.lib-cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(29, 32, 39, 0) 55%, rgba(29, 32, 39, 0.35));
}
.cover-notes { background: linear-gradient(135deg, #2f8f83, #134e4a); }
.cover-podcast { background: linear-gradient(135deg, #4a5568, #1f2937); }
.cover-mindmap { background: linear-gradient(135deg, #b45309, #7c3d03); }
.cover-video { background: linear-gradient(135deg, #6d5bb8, #2d2352); }
.lib-card h3 {
  margin: 14px 16px 6px; font-size: 15px; font-weight: 700;
  color: var(--ink); line-height: 1.35;
}
.lib-meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 16px 16px; font-size: 12px; color: var(--faint);
}
.badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent-deep); border: 1px solid rgba(15, 118, 110, 0.25);
}
.badge.notes, .badge.mindmap {
  background: rgba(180, 83, 9, 0.1); color: #92400e; border-color: rgba(180, 83, 9, 0.28);
}
.badge.video { background: rgba(109, 91, 184, 0.1); color: #5b4a9e; border-color: rgba(109, 91, 184, 0.28); }
.lib-empty, .lib-loading { text-align: center; color: var(--faint); padding: 60px 0; font-size: 14px; }

.lib-detail { animation: card-in .5s ease both; }
.lib-detail-head { padding: 36px 0 8px; }
.lib-detail-head h2 {
  font-family: var(--font-display); font-size: clamp(22px, 3.4vw, 34px);
  color: var(--ink); margin: 0 0 10px; letter-spacing: -0.02em;
}
.lib-detail-head h2 svg { vertical-align: -4px; margin-right: 8px; color: var(--accent); }
.lib-detail-meta {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  color: var(--dim); font-size: 13px;
}
.lib-detail-actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }
.lib-player {
  margin: 22px 0; border-radius: 17px; overflow: hidden;
  background: #101216; border: 1px solid var(--border);
}
.lib-player video, .lib-player audio { width: 100%; display: block; }
.lib-player .audioplayer { margin: 0; border: 0; background: #f4f2ec; border-radius: 0; }
.lib-excerpt {
  color: var(--ink-2); font-size: 15px; line-height: 1.65; max-width: 720px;
  margin: 18px 0 8px;
}
.lib-pub { margin: 16px 0 0; color: var(--accent-deep); font-size: 14px; }
.lib-pub a { color: var(--accent); text-decoration: underline; }
.btn-danger {
  background: rgba(185, 28, 28, 0.08); color: var(--err);
  border: 1px solid rgba(185, 28, 28, 0.3);
}
.btn-danger:hover { background: rgba(185, 28, 28, 0.14); }
.detail-block { margin-top: 18px; }
.detail-block summary { cursor: pointer; color: var(--dim); font-size: 14px; }
