:root {
  --ink: #16130f;
  --cream: #fff5dd;
  --cream-2: #ffeec2;
  --pink: #ff4d9d;
  --lime: #c4f000;
  --blue: #2b59ff;
  --yellow: #ffce2b;
  --white: #fffdf6;
  --red: #ff4646;
  --green: #14b85b;

  --border: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-lg: 10px 10px 0 var(--ink);
  --radius: 22px;

  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over component display rules (e.g. flex). */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 77, 157, 0.22), transparent 40%),
    radial-gradient(circle at 88% 12%, rgba(43, 89, 255, 0.18), transparent 38%),
    radial-gradient(circle at 78% 88%, rgba(196, 240, 0, 0.28), transparent 42%),
    radial-gradient(circle at 22% 92%, rgba(255, 206, 43, 0.22), transparent 40%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Subtle film grain for depth */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.6rem 1.5rem 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}
.logo-flac { background: var(--pink); }
.logo-mp3 { background: var(--lime); }
.logo-flac, .logo-mp3 {
  padding: 0.1rem 0.55rem;
  border: var(--border);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--ink);
}
.logo-bolt { transform: rotate(-8deg); animation: bolt 2.4s ease-in-out infinite; }
@keyframes bolt {
  0%, 100% { transform: rotate(-8deg) scale(1); }
  50% { transform: rotate(8deg) scale(1.18); }
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.45rem 0.8rem;
  border: var(--border);
  border-radius: 999px;
  background: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
}

/* ---------- Layout ---------- */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

/* ---------- Hero ---------- */
.hero { text-align: center; margin: 2.2rem 0 2.6rem; }
.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}
.hero-title .hl {
  background: var(--yellow);
  padding: 0 0.3rem;
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--ink);
  display: inline-block;
  transform: rotate(-1.5deg);
}
.hero-sub {
  max-width: 48ch;
  margin: 0 auto;
  font-size: 1.08rem;
  line-height: 1.55;
  color: #443c30;
}

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative;
  border: 4px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  padding: 2.6rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}
.dropzone:hover { transform: translate(-2px, -2px); box-shadow: 13px 13px 0 var(--ink); }
.dropzone:focus-visible { outline: 4px solid var(--blue); outline-offset: 4px; }
.dropzone.is-drag {
  background: var(--cream-2);
  border-style: solid;
  transform: rotate(-1deg) scale(1.01);
  box-shadow: 14px 14px 0 var(--pink);
}

.dz-icon { margin-bottom: 1rem; }
.dz-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
  margin: 0.2rem 0 0.3rem;
}
.dz-hint { margin: 0 0 1.3rem; color: #6b6052; font-size: 0.95rem; }
.dz-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

/* Equalizer animation */
.eq { display: inline-flex; align-items: flex-end; gap: 5px; height: 46px; }
.eq i {
  width: 9px;
  height: 100%;
  background: var(--ink);
  border-radius: 4px;
  transform-origin: bottom;
  animation: eq 1s ease-in-out infinite;
}
.eq i:nth-child(1) { background: var(--pink); animation-delay: -0.0s; }
.eq i:nth-child(2) { background: var(--blue); animation-delay: -0.2s; }
.eq i:nth-child(3) { background: var(--yellow); animation-delay: -0.4s; }
.eq i:nth-child(4) { background: var(--lime); animation-delay: -0.6s; }
.eq i:nth-child(5) { background: var(--pink); animation-delay: -0.8s; }
@keyframes eq {
  0%, 100% { transform: scaleY(0.25); }
  50% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
  .eq i, .logo-bolt { animation: none; }
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.7rem 1.3rem;
  border: var(--border);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: var(--shadow); filter: grayscale(0.4); }
.btn--pink { background: var(--pink); color: #fff; }
.btn--blue { background: var(--blue); color: #fff; }
.btn--lime { background: var(--lime); }
.btn--yellow { background: var(--yellow); }
.btn--ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn--ghost:hover { background: var(--white); box-shadow: 4px 4px 0 var(--ink); }
.btn--lg { font-size: 1.15rem; padding: 0.9rem 1.8rem; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin: 1.8rem 0 1rem;
  padding: 1.1rem 1.3rem;
  background: var(--cream-2);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.control-block { display: flex; align-items: center; gap: 0.8rem; }
.control-label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}
.quality-pills { display: inline-flex; border: var(--border); border-radius: 999px; overflow: hidden; background: var(--white); }
.pill {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.45rem 0.85rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-right: 2px solid var(--ink);
  transition: background 0.12s ease;
}
.pill:last-child { border-right: none; }
.pill:hover { background: var(--cream-2); }
.pill.is-active { background: var(--lime); font-weight: 600; }
.control-actions { display: flex; gap: 0.7rem; align-items: center; }

/* ---------- Banner ---------- */
.banner {
  margin: 1rem 0;
  padding: 0.9rem 1.2rem;
  border: var(--border);
  border-radius: 14px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  background: var(--white);
}
.banner.is-info { background: #e8f0ff; }
.banner.is-warn { background: #fff3cf; }
.banner.is-error { background: #ffe0e0; }
.banner.is-busy { background: var(--cream-2); }

/* ---------- File list ---------- */
.filelist { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 0.6rem; }
.file-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--white);
  border: var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop 0.25s ease;
}
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.file-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--cream-2);
}
.file-card[data-state="done"] .file-dot { background: var(--green); }
.file-card[data-state="error"] .file-dot { background: var(--red); }
.file-card[data-state="converting"] .file-dot { background: var(--yellow); animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.file-main { min-width: 0; }
.file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta { font-family: var(--font-mono); font-size: 0.78rem; color: #6b6052; margin-top: 0.15rem; }
.file-meta .arrow { color: var(--pink); font-weight: 700; }

.progress {
  grid-column: 1 / -1;
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(45deg, var(--lime) 0 10px, var(--blue) 10px 20px);
  transition: width 0.2s ease;
}
.file-card[data-state="done"] .progress > span { background: var(--green); width: 100% !important; }
.file-card[data-state="error"] .progress > span { background: var(--red); }

.file-action { display: flex; gap: 0.4rem; align-items: center; }
.icon-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  border: var(--border);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.icon-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.icon-btn--dl { background: var(--lime); }
.icon-btn--rm { background: var(--white); }

/* ---------- Download bar ---------- */
.download-bar { text-align: center; margin-top: 1.8rem; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 700px;
  margin: 2rem auto 0;
  padding: 1.6rem 1.5rem 2.5rem;
  text-align: center;
  color: #5a5142;
  font-size: 0.92rem;
  line-height: 1.6;
}
.footer-meta { font-family: var(--font-mono); font-size: 0.8rem; margin-top: 0.4rem; opacity: 0.7; }

@media (max-width: 560px) {
  .controls { flex-direction: column; align-items: stretch; }
  .control-actions { justify-content: space-between; }
  .file-card { grid-template-columns: auto 1fr; }
  .file-action { grid-column: 1 / -1; justify-content: flex-end; }
}
