:root {
  color-scheme: dark;
  --bg: #070b11;
  --panel: #0d141d;
  --panel-2: #111b26;
  --ink: #f4f7f8;
  --muted: #93a2af;
  --line: #263440;
  --accent: #6ef2c2;
  --accent-dark: #042c23;
  --danger: #ff8f82;
  --shadow: 0 30px 80px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 88% 8%, rgba(110, 242, 194, .09), transparent 26rem),
    linear-gradient(180deg, #081019 0, var(--bg) 32rem);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.topbar, main, footer { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(147, 162, 175, .18);
}
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 27px; height: 22px; display: flex; align-items: end; gap: 3px; }
.brand-mark i { display: block; width: 4px; border-radius: 3px; background: var(--accent); }
.brand-mark i:nth-child(1) { height: 9px; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 13px; }
.brand-mark i:nth-child(4) { height: 21px; }
.privacy-note { color: var(--muted); font-size: .88rem; display: flex; align-items: center; gap: .5rem; }
.privacy-note span { color: var(--accent); font-size: .65rem; }
.topbar-link { color: var(--muted); font-size: .88rem; text-underline-offset: 4px; }
.topbar-link:hover { color: var(--accent); }

.tool-shell { padding: 54px 0 72px; }
.title-row { display: grid; grid-template-columns: 1fr minmax(260px, 420px); align-items: end; gap: 36px; margin-bottom: 28px; }
.eyebrow, .section-number { margin: 0 0 .45rem; color: var(--accent); font-size: .76rem; font-weight: 800; letter-spacing: .17em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2.35rem, 5vw, 4.7rem); line-height: .98; letter-spacing: -.065em; font-weight: 760; }
.lede { margin-bottom: .4rem; color: #bcc7cf; font-size: 1.08rem; max-width: 39ch; }

.workspace { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); min-height: 480px; border: 1px solid var(--line); background: rgba(13, 20, 29, .84); box-shadow: var(--shadow); }
.input-panel, .result-panel { padding: 30px; }
.input-panel { border-right: 1px solid var(--line); }
.dropzone {
  min-height: 245px;
  border: 1.5px dashed #405261;
  background: linear-gradient(135deg, rgba(110, 242, 194, .045), rgba(255,255,255,.01));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .42rem;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background: rgba(110, 242, 194, .08); transform: translateY(-2px); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone strong { font-size: 1.16rem; }
.dropzone > span:not(.upload-icon) { color: var(--muted); }
.pick-link { color: var(--accent) !important; text-decoration: underline; text-underline-offset: 3px; }
.dropzone small { margin-top: .7rem; color: #7f909d; letter-spacing: .09em; font-size: .72rem; }
.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: .6rem; border-radius: 50%; color: var(--accent); background: var(--accent-dark); }
.upload-icon svg, .convert-button svg, .download-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.file-card { min-height: 92px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); background: var(--panel-2); padding: 16px; }
.file-badge { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--accent-dark); color: var(--accent); font-size: 1.25rem; }
.file-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.file-copy strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-copy span { color: var(--muted); font-size: .86rem; }
.icon-button { flex: none; border: 0; background: transparent; color: var(--muted); font-size: 1.55rem; cursor: pointer; }

.controls { margin: 27px 0 22px; }
.controls label { display: flex; justify-content: space-between; font-size: .86rem; font-weight: 700; }
.controls output { color: var(--accent); font-weight: 650; }
.controls input { width: 100%; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; color: #70808d; font-size: .75rem; }
.convert-button, .download-button {
  width: 100%; min-height: 54px; border: 1px solid var(--accent); background: var(--accent); color: #05130f;
  display: flex; align-items: center; justify-content: center; gap: .7rem; font-weight: 800; cursor: pointer; transition: filter .2s, transform .2s;
  text-decoration: none;
}
.convert-button:hover:not(:disabled), .download-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.convert-button:disabled { background: #1c2932; color: #64727d; border-color: #2a3944; cursor: not-allowed; }
.microcopy { margin: .8rem 0 0; text-align: center; color: #758692; font-size: .78rem; }

.result-panel { min-width: 0; background: linear-gradient(150deg, rgba(17,27,38,.95), rgba(8,14,21,.94)); }
.result-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.result-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.025em; }
.status { flex: none; padding: .38rem .65rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .72rem; }
.status.ready { border-color: rgba(110, 242, 194, .45); background: rgba(110, 242, 194, .08); color: var(--accent); }
.empty-state { min-height: 340px; display: grid; align-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-state p { max-width: 38ch; }
.empty-roll { width: min(340px, 80%); height: 120px; position: relative; display: flex; align-items: end; justify-content: space-around; border: 1px solid var(--line); background: repeating-linear-gradient(0deg, transparent 0 23px, rgba(147,162,175,.09) 24px); margin-bottom: 22px; overflow: hidden; }
.empty-roll::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(110,242,194,.08), transparent); transform: translateX(-100%); animation: sweep 3.4s infinite; }
.empty-roll span { width: 13%; height: 6px; margin-bottom: calc(var(--n, 1) * 15px); background: #344550; }
.empty-roll span:nth-child(2) { --n: 3; }
.empty-roll span:nth-child(3) { --n: 2; }
.empty-roll span:nth-child(4) { --n: 4; }
.empty-roll span:nth-child(5) { --n: 1.6; }
@keyframes sweep { to { transform: translateX(100%); } }

.progress-wrap { padding: 130px 10px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--muted); font-size: .88rem; }
.progress-label strong { color: var(--ink); }
.progress-track { height: 5px; background: #21303a; overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .15s linear; }

.result-content { padding-top: 24px; }
#piano-roll { display: block; width: 100%; height: 250px; border: 1px solid var(--line); background: #080e15; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0 20px; border: 1px solid var(--line); }
.stats div { padding: 13px 16px; }
.stats div + div { border-left: 1px solid var(--line); }
.stats dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.stats dd { margin: .2rem 0 0; font-size: 1.05rem; font-weight: 750; }
.result-actions { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; }
.text-button { border: 0; padding: .8rem 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.review-note { margin: 18px 0 0; padding-left: 14px; border-left: 2px solid var(--accent); color: #9eacb6; font-size: .82rem; }
.review-note strong { color: var(--ink); }
.error-state { margin-top: 90px; padding: 20px; border: 1px solid rgba(255,143,130,.45); color: var(--danger); background: rgba(255,143,130,.06); }
.error-state p { margin: .35rem 0 0; color: #c3a29e; }

.content-grid { padding: 76px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 46px; }
.content-grid h2, .faq h2 { margin-bottom: 1rem; font-size: 1.55rem; line-height: 1.15; letter-spacing: -.035em; }
.content-grid p:not(.section-number) { color: #9cabb6; }
.content-grid article p:last-child { margin-bottom: 0; }

.faq { padding: 74px 0; display: grid; grid-template-columns: .6fr 1.4fr; gap: 70px; border-top: 1px solid var(--line); }
.faq-list { border-top: 1px solid var(--line); }
details { border-bottom: 1px solid var(--line); }
summary { padding: 20px 35px 20px 0; cursor: pointer; font-weight: 720; list-style: none; position: relative; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 4px; color: var(--accent); font-size: 1.3rem; font-weight: 400; }
details[open] summary::after { content: "−"; }
details p { padding: 0 38px 18px 0; margin: 0; color: #9cabb6; }

footer { padding: 34px 0 46px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font-size: .84rem; }
.footer-brand { color: var(--ink); }
footer p { margin: 0; }

.article-page { width: min(100% - 40px, 820px); padding: 72px 0 96px; }
.article-page .article-kicker { color: var(--accent); font-size: .76rem; font-weight: 800; letter-spacing: .17em; }
.article-page h1 { margin-bottom: 1.4rem; font-size: clamp(2.5rem, 7vw, 5.2rem); }
.article-page .article-answer { color: #d9e1e6; font-size: 1.22rem; line-height: 1.75; }
.article-page h2 { margin: 3.4rem 0 1.15rem; padding-top: 1.4rem; border-top: 1px solid var(--line); font-size: 1.9rem; letter-spacing: -.035em; }
.article-page h3 { margin: 2.4rem 0 .85rem; font-size: 1.28rem; letter-spacing: -.02em; }
.article-page p, .article-page li { color: #aebbc4; line-height: 1.78; }
.article-page strong { color: var(--ink); }
.article-page ul, .article-page ol { padding-left: 1.3rem; }
.article-page li + li { margin-top: .45rem; }
.article-cta { margin-top: 4rem; padding: 28px; border: 1px solid var(--line); background: var(--panel); }
.article-cta p { margin-bottom: 1rem; }
.article-cta a { color: var(--accent); font-weight: 800; text-underline-offset: 4px; }

[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(110, 242, 194, .55); outline-offset: 3px; }

@media (max-width: 820px) {
  .title-row, .workspace, .content-grid, .faq { grid-template-columns: 1fr; }
  .title-row { gap: 16px; }
  .workspace { min-height: auto; }
  .input-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .empty-state { min-height: 280px; }
  .content-grid, .faq { gap: 36px; }
}

@media (max-width: 540px) {
  .topbar, main, footer { width: min(100% - 24px, 1180px); }
  .topbar { height: 62px; }
  .privacy-note { font-size: 0; }
  .privacy-note span { font-size: .7rem; }
  .privacy-note::after { content: "Local only"; font-size: .78rem; }
  .topbar-link { font-size: .78rem; }
  .tool-shell { padding: 34px 0 52px; }
  h1 { font-size: 2.45rem; }
  .lede { font-size: .98rem; }
  .input-panel, .result-panel { padding: 18px; }
  .dropzone { min-height: 220px; }
  .result-head { align-items: end; }
  .result-head h2 { font-size: 1.15rem; }
  .status { white-space: nowrap; }
  #piano-roll { height: 210px; }
  .stats div { padding: 10px; }
  .stats dd { font-size: .9rem; }
  .result-actions { grid-template-columns: 1fr; }
  .text-button { width: 100%; }
  .content-grid { padding: 56px 0; }
  .faq { padding: 56px 0; }
  footer { align-items: start; gap: 24px; }
  footer p { max-width: 22ch; text-align: right; }
  .article-page { width: min(100% - 28px, 820px); padding: 48px 0 72px; }
  .article-page h1 { font-size: 2.55rem; }
  .article-page .article-answer { font-size: 1.08rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
