:root {
  color-scheme: light dark;
  --bg: #fdfdfc;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --rule: #e2e2dd;
  --panel: #f6f6f2;
  --link: #1a5fb4;
  --on-link: #ffffff;
  --ok: #26a269;
  --bad: #c01c28;
  --measure: 52rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --fg: #e8e8e3;
    --muted: #9a9a93;
    --rule: #33332f;
    --panel: #1e1e1c;
    --link: #78aeed;
    --on-link: #0d1b2a;
    --ok: #57e389;
    --bad: #f66151;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: calc(var(--measure) + 2rem);
  padding: 0 1rem;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--link); }

.top { padding: 1.25rem 0 0; font-size: 0.9rem; }
.back { text-decoration: none; }

h1 { font-size: 1.9rem; margin: 1.5rem 0 0.25rem; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.75rem; }
.lede { color: var(--muted); margin: 0 0 1.5rem; max-width: 40rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 0.6rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: 0.75rem 1rem;
}

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
label[hidden] { display: none; }

select, input[type="text"], input[type="number"] {
  font: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  padding: 0.4rem 0.5rem;
  min-width: 0;
}

.error { color: var(--bad); margin: 0.75rem 0 0; font-size: 0.9rem; }

.drop {
  position: relative;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.2rem;
  min-height: 8rem;
  padding: 1.5rem 1rem;
  border: 2px dashed var(--rule);
  border-radius: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--link); background: var(--panel); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-title { font-size: 1.05rem; color: var(--fg); font-weight: 600; }
.drop-sub { font-size: 0.85rem; }

.files { list-style: none; padding: 0; margin: 1rem 0; }
.files:empty { display: none; }

.file {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.file:first-child { border-top: 1px solid var(--rule); }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-info { font-size: 0.85rem; color: var(--muted); }
.file-info .bad { color: var(--bad); }
.file-info .good { color: var(--ok); }
.file-actions { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 0.5rem; align-items: center; }
.file progress { grid-column: 1 / -1; width: 100%; height: 0.35rem; }
.file details { grid-column: 1 / -1; font-size: 0.8rem; color: var(--muted); }
.file pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 12rem; overflow: auto; }

progress { appearance: none; border: 0; border-radius: 1rem; background: var(--rule); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--rule); }
progress::-webkit-progress-value { background: var(--link); }
progress::-moz-progress-bar { background: var(--link); }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 1rem 0 2rem; }
.engine { font-size: 0.85rem; color: var(--muted); margin-left: auto; }

button, .button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.4rem;
  border: 1px solid var(--link);
  background: transparent;
  color: var(--link);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button.primary { background: var(--link); color: var(--on-link); }
button.quiet, button.icon { border-color: var(--rule); color: var(--muted); }
button.icon { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
button:disabled { opacity: 0.45; cursor: default; }
.file .button { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

.bottom {
  border-top: 1px solid var(--rule);
  padding: 1rem 0 2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 30rem) {
  .file { grid-template-columns: 1fr; }
  .file-actions { grid-row: auto; grid-column: 1; }
  .engine { margin-left: 0; width: 100%; }
}
