:root {
  --ink: #0e1230;
  --muted: #4a5174;
  --cobalt: #2536d8;
  --cobalt-deep: #1a279f;
  --marigold: #ffc62e;
  --marigold-deep: #f0b400;
  --paper: #f3f5fb;
  --surface: #ffffff;
  --check: #e8ebf6;
  --line: #d9ddee;
  --ok: #0b7a53;
  --bad: #b3203a;
  --warn: #7a5200;

  /* System fonts only: nothing is loaded from other websites. */
  --font-display: Bahnschrift, "DIN Alternate", "Avenir Next Condensed", "Roboto Condensed", sans-serif-condensed, "Arial Narrow", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  text-wrap: balance;
}
p { margin: 0; }
a { color: var(--cobalt); }
main { flex: 1 0 auto; }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; }

.wrap { width: min(100% - 32px, 1040px); margin-inline: auto; }
.narrow { max-width: 760px; }
.nowrap { white-space: nowrap; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--marigold);
  color: var(--ink);
  font-weight: 700;
}
.skip:focus { top: 12px; }

/* Header */
.topbar { background: var(--cobalt); color: #fff; }
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 18px;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar a:focus-visible, .footer a:focus-visible { outline-color: var(--marigold); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}
.mark {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: conic-gradient(var(--marigold) 25%, #fff 0 50%, var(--marigold) 0 75%, #fff 0);
}
.topbar nav, .footer nav { display: flex; gap: 22px; }
.topbar nav a:hover { text-decoration: underline; text-underline-offset: 5px; }

/* Hero and converter */
.hero { background: var(--cobalt); color: #fff; padding-block: 28px 72px; }
.hero h1 { font-size: clamp(2.9rem, 9vw, 6.25rem); line-height: 0.95; letter-spacing: -0.01em; }
.hero h1 em { color: var(--marigold); font-style: normal; }
.lede { max-width: 38rem; margin-top: 18px; font-size: 1.2rem; color: #e4e7ff; }

.converter { margin-top: 36px; color: var(--ink); scroll-margin-top: 16px; }

.checker,
.dropzone {
  background-color: var(--surface);
  background-image: conic-gradient(var(--check) 25%, transparent 0 50%, var(--check) 0 75%, transparent 0);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 340px;
  padding: 32px 20px;
  border: 4px solid transparent;
  border-radius: 20px;
  background-size: 40px 40px;
  background-origin: border-box;
  box-shadow: 0 24px 50px -24px rgb(5 10 70 / 0.65);
  text-align: center;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--marigold); }
.dropzone.is-dragging { border-color: var(--marigold); animation: drift 0.8s linear infinite; }
@keyframes drift { to { background-position: 40px 40px; } }

.formats { display: flex; align-items: center; gap: 16px; }
.format {
  padding: 8px 16px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 5vw, 1.9rem);
  font-weight: 700;
}
.format-in { background: var(--ink); color: #fff; }
.format-out { background: var(--marigold); color: var(--ink); }
.arrow { flex: none; color: var(--cobalt); }
.is-dragging .arrow { animation: nudge 0.5s ease-in-out infinite alternate; }
@keyframes nudge { to { transform: translateX(8px); } }

.drop-title { font-family: var(--font-display); font-size: clamp(1.7rem, 5vw, 2.4rem); font-weight: 700; line-height: 1.1; }
.drop-hint { color: var(--muted); font-size: 0.95rem; }

.has-files .dropzone {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  min-height: 0;
  padding: 18px 22px;
  text-align: left;
}
.has-files .formats, .has-files .drop-hint { display: none; }
.has-files .drop-title { font-size: 1.4rem; }

.noscript { margin-top: 16px; padding: 16px; border-radius: 12px; background: var(--marigold); font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 24px;
  border: 2px solid transparent;
  border-radius: 10px;
  font: 700 1rem/1.2 var(--font-body);
  text-decoration: none;
  cursor: pointer;
}
.btn-small { min-height: 40px; padding: 6px 16px; font-size: 0.95rem; }
.btn-primary { background: var(--cobalt); color: #fff; }
.btn-primary:hover { background: var(--cobalt-deep); }
.btn-accent { background: var(--marigold); color: var(--ink); }
.btn-accent:hover:not(:disabled) { background: var(--marigold-deep); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-quiet:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: progress; }

/* Results */
.results { margin-top: 16px; overflow: hidden; border-radius: 20px; background: var(--surface); }
.results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}
.summary { font-weight: 700; }
.results-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.files { margin: 0; padding: 0; list-style: none; }
.file {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.thumb {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-size: 12px 12px;
}
.thumb canvas { display: block; max-width: 100%; max-height: 100%; animation: decode 0.45s ease-out; }
@keyframes decode { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }

.file-name { overflow: hidden; font-family: var(--font-mono); font-size: 0.98rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--muted); font-size: 0.9rem; }
.file-note { color: var(--warn); font-size: 0.9rem; }
.file.is-error .file-meta { color: var(--bad); font-weight: 600; }
.file.is-error .thumb { border-color: var(--bad); }
.file.is-working .thumb { background-size: 12px 12px; animation: shuffle 0.6s linear infinite; }
@keyframes shuffle { to { background-position: 12px 12px; } }

.file-actions { display: flex; align-items: center; gap: 8px; }
.file-remove {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.file-remove:hover { background: var(--paper); color: var(--bad); }

/* Content */
.section { padding-block: 72px; }
.section-alt { background: var(--surface); }
.section h2 { margin-bottom: 28px; font-size: clamp(2rem, 5vw, 3rem); }

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li { padding-top: 18px; border-top: 4px solid var(--cobalt); counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: block;
  color: var(--cobalt);
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
}
.steps h3 { margin-block: 8px; font-size: 1.5rem; }
.steps p { color: var(--muted); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 48px; align-items: start; }
.split p + p { margin-top: 14px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { border-bottom: 3px solid var(--ink); font-family: var(--font-display); font-size: 1.35rem; }
tbody th { font-weight: 700; }

details { border-bottom: 1px solid var(--line); }
details:first-of-type { border-top: 1px solid var(--line); }
summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; flex: none; color: var(--cobalt); font: 700 1.7rem/1 var(--font-mono); }
details[open] summary::after { content: "−"; }
details p { padding: 0 2px 20px; color: var(--muted); }

/* Text pages (privacy, not found) */
.page-head { background: var(--cobalt); color: #fff; padding-block: 28px 48px; }
.page-head h1 { font-size: clamp(2.4rem, 8vw, 4.5rem); }
.page-body { min-height: 45vh; padding-block: 48px 72px; }
.page-body h2 { margin-block: 32px 10px; font-size: 1.7rem; }
.page-body h2:first-child { margin-top: 0; }
.page-body p + p { margin-top: 14px; }
.page-body .btn { margin-top: 24px; }

/* Footer */
.footer { background: var(--ink); color: #c9cdea; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; padding-block: 28px; }
.footer a { color: #fff; }

@media (max-width: 760px) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .hero { padding-bottom: 48px; }
  .section { padding-block: 52px; }
}

@media (max-width: 560px) {
  .topbar-inner { column-gap: 10px; }
  .brand { gap: 8px; font-size: 1.15rem; }
  .topbar nav { gap: 12px; font-size: 0.9rem; }
  .dropzone { min-height: 300px; }
  .has-files .dropzone { justify-content: center; text-align: center; }
  .file { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px 12px; padding-inline: 14px; }
  .thumb { width: 56px; height: 56px; }
  .file-actions { display: contents; }
  .file-remove { grid-column: 3; grid-row: 1; }
  .file-download { grid-column: 1 / -1; }
  .results-actions { width: 100%; }
  .results-actions .btn { flex: 1 1 auto; }
  th, td { padding-inline: 6px; font-size: 0.88rem; }
}

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