:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #10141d;
  --panel-2: #151a24;
  --line: #2a3040;
  --line-strong: #3b4355;
  --text: #f5f7fb;
  --muted: #9da6b8;
  --accent: #c7ff4a;
  --accent-ink: #111707;
  --blue: #7ab8ff;
  --danger: #ff7e76;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 4%, rgba(122, 184, 255, 0.09), transparent 28rem),
    radial-gradient(circle at 84% 50%, rgba(199, 255, 74, 0.06), transparent 30rem),
    var(--bg);
}

button, input, select { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, .drop-zone:focus-visible {
  outline: 3px solid rgba(199, 255, 74, 0.45);
  outline-offset: 3px;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 16, 0.78);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-size: 1.03rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 1.2rem;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(16, 20, 29, 0.72);
}

.page-nav a {
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.page-nav a:hover,
.page-nav a.is-current {
  color: var(--text);
  background: #202632;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c5ccda;
  font-size: 0.84rem;
}

.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(199, 255, 74, 0.1);
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(36px, 7vw, 84px) 0 46px;
}

.workspace-heading, .result-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(2.5rem, 7vw, 5.6rem);
  line-height: 0.9;
  letter-spacing: -0.065em;
}

.page-intro {
  max-width: 650px;
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.55;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  letter-spacing: -0.025em;
}

.format-label {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.035em;
}

.format-label span { color: var(--accent); }

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.input-panel, .controls-panel, .result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 20, 29, 0.86);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.27);
}

.input-panel { padding: 18px; }

.drop-zone {
  min-height: 318px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px),
    var(--panel-2);
  background-size: 26px 26px;
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.drop-zone:hover, .drop-zone.is-dragging {
  border-color: var(--accent);
  background-color: rgba(199, 255, 74, 0.035);
  transform: translateY(-2px);
}

.drop-icon {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 23px;
}

.wave {
  width: 7px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 24px rgba(199, 255, 74, 0.18);
}
.wave-a, .wave-e { height: 22px; }
.wave-b, .wave-d { height: 42px; }
.wave-c { height: 60px; }

.drop-zone h2 { font-size: clamp(1.22rem, 3vw, 1.6rem); }
.drop-zone p { margin: 8px 0 21px; color: var(--muted); font-size: 0.93rem; }

.choose-button {
  padding: 10px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: #dfe4ed;
  background: #1a202b;
  font-size: 0.88rem;
  font-weight: 700;
}

.file-card {
  min-height: 318px;
  padding: 22px;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
}

.file-meta { display: flex; align-items: center; gap: 14px; }
.file-badge {
  display: grid;
  flex: 0 0 46px;
  height: 46px;
  place-items: center;
  border-radius: 13px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 1.3rem;
}

.file-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy span { color: var(--muted); font-size: 0.82rem; }
.icon-button {
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 1.5rem;
}
.icon-button:hover { color: var(--text); background: rgba(255,255,255,.05); }

audio { width: 100%; margin-top: 66px; filter: invert(0.88) hue-rotate(180deg); }

.convert-button, .download-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 13px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 850;
  transition: transform 150ms ease, filter 150ms ease;
}

.convert-button { width: 100%; margin-top: 14px; padding: 0 18px 0 21px; }
.convert-button:not(:disabled):hover, .download-button:hover { transform: translateY(-2px); filter: brightness(1.06); }
.convert-button:disabled { cursor: not-allowed; color: #6f7785; background: #242a34; }
.button-arrow { font-size: 1.25rem; }

.status { min-height: 22px; padding: 10px 3px 0; color: var(--muted); font-size: 0.84rem; }
.status.is-error { color: var(--danger); }

.controls-panel { padding: 24px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.text-button { border: 0; color: var(--muted); background: transparent; font-size: 0.82rem; }
.text-button:hover { color: var(--text); }

.control-row { display: block; padding: 20px 0; border-bottom: 1px solid var(--line); }
.control-row:last-child { border-bottom: 0; }
.control-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 13px; font-size: 0.9rem; font-weight: 700; }
output { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; }
.control-hint { display: block; margin-top: 7px; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }

input[type="range"] {
  width: 100%;
  height: 5px;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill, 50%), #303746 var(--fill, 50%) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  width: 19px;
  height: 19px;
  appearance: none;
  border: 4px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.dual-range { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dual-range label > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 0.74rem; }
.select-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.select-label { display: block; font-size: 0.9rem; font-weight: 700; }
select { min-width: 118px; padding: 10px 34px 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text); background: #1a202b; }

.result-panel { margin-top: 18px; padding: clamp(22px, 4vw, 34px); }
.result-heading { align-items: center; margin-bottom: 25px; }
.result-heading h2 { font-size: clamp(1.55rem, 4vw, 2.15rem); }
.result-heading p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); }
.download-button { gap: 48px; padding: 0 20px; white-space: nowrap; }
.download-button span { font-size: 1.2rem; }

.piano-roll-wrap { min-height: 240px; display: grid; grid-template-columns: 42px 1fr; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #0a0d13; }
.roll-labels { display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 16px 0; border-right: 1px solid var(--line); color: #687184; font-size: 0.58rem; letter-spacing: 0.12em; writing-mode: vertical-rl; }
#pianoRoll { display: block; width: 100%; height: 240px; }

.truth-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-top: 18px;
  padding: 21px 4px;
  color: var(--muted);
  font-size: 0.84rem;
}
.truth-strip p { max-width: 650px; margin: 0; line-height: 1.6; }
.truth-strip strong { color: var(--text); }
.fact-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.fact-list span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: #c0c7d4; white-space: nowrap; }

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(20px, 5vw, 72px) 34px;
  border-top: 1px solid var(--line);
  color: #717a8d;
  font-size: 0.76rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
}

.footer-links a,
.prose-card a {
  color: #cbd3e1;
  text-underline-offset: 3px;
}

.footer-links a:hover,
.prose-card a:hover { color: var(--accent); }

.content-shell {
  width: min(820px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(42px, 8vw, 88px) 0;
}

.prose-card {
  padding: clamp(24px, 5vw, 52px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 20, 29, 0.9);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.27);
}

.prose-card h1 {
  margin-bottom: 24px;
  font-size: clamp(2.5rem, 7vw, 4.8rem);
}

.prose-card h2 {
  margin: 34px 0 10px;
  font-size: 1.3rem;
}

.prose-card p,
.prose-card li {
  color: #c1c8d5;
  font-size: 1rem;
  line-height: 1.75;
}

.prose-card p { margin-bottom: 14px; }
.prose-card ul { padding-left: 1.25rem; }
.prose-card strong { color: var(--text); }
.prose-card .updated { color: var(--muted); font-size: 0.86rem; }
.contact-link { font-size: clamp(1rem, 4vw, 1.25rem); overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .topbar { height: auto; min-height: 74px; flex-wrap: wrap; gap: 10px 16px; padding-block: 12px; }
  .page-nav { order: 3; width: 100%; overflow-x: auto; }
  .page-nav a { flex: 1 0 auto; text-align: center; }
  .privacy-pill { font-size: 0; padding: 10px; }
  .privacy-dot { width: 8px; height: 8px; }
  .app-shell { width: min(100% - 24px, 680px); padding-top: 38px; }
  .workspace-heading { align-items: flex-start; flex-direction: column; gap: 15px; }
  .tool-grid { grid-template-columns: 1fr; }
  .controls-panel { order: 2; }
  .drop-zone, .file-card { min-height: 270px; }
  .result-heading, .truth-strip { align-items: flex-start; flex-direction: column; }
  .download-button { width: 100%; }
  .fact-list { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .topbar { min-height: 64px; padding-inline: 14px; }
  .app-shell { width: calc(100% - 20px); padding-top: 30px; }
  h1 { font-size: 3rem; }
  .input-panel { padding: 10px; }
  .drop-zone { min-height: 240px; padding: 30px 14px; }
  .controls-panel { padding: 19px; }
  .dual-range { grid-template-columns: 1fr; }
  .select-row { align-items: flex-start; flex-direction: column; }
  select { width: 100%; }
  .piano-roll-wrap { grid-template-columns: 30px 1fr; }
  footer { align-items: flex-start; flex-direction: column; padding-inline: 14px; }
  .footer-links { justify-content: flex-start; }
  .content-shell { width: calc(100% - 20px); padding-block: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
