:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d2024;
  --ink-soft: #5c646e;
  --line: #ddd8ce;
  --accent: #1f6f8b;
  --accent-ink: #ffffff;
  --warn: #8a4b1f;
  --ok: #2f6b3a;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* Every size below is in rem, so this one value scales the whole interface.
   Browser default is 16px; 15px reads a little tighter. */
html { font-size: 15px; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

header, main, footer { max-width: 1100px; margin: 0 auto; }

header { padding: 2.5rem 0 1rem; }
h1 { margin: 0 0 .5rem; font-size: 1.9rem; letter-spacing: -.01em; }
.sub { margin: 0; max-width: 62ch; color: var(--ink-soft); }

section {
  margin: 2rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

h2 { margin: 0 0 1rem; font-size: 1.2rem; display: flex; align-items: center; gap: .6rem; }
h3 { margin: 0 0 .35rem; font-size: 1rem; }

.step {
  display: inline-grid;
  place-items: center;
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .85rem;
  font-weight: 600;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  /* Grid items default to min-width:auto, so a long unbreakable filename in the
     status line would push the card past its track and under its neighbor. */
  min-width: 0;
}

.card.dragover { border-color: var(--accent); background: #f2f8fa; }

.hint { margin: .35rem 0; color: var(--ink-soft); font-size: .85rem; }
.hint em { font-style: normal; font-weight: 600; }

.status {
  margin: .6rem 0 0;
  font-size: .85rem;
  color: var(--ink-soft);
  /* Filenames have no spaces to break at. */
  overflow-wrap: anywhere;
}
.status.ok { color: var(--ok); }
.status.error { color: var(--warn); }

.caveat {
  margin: .75rem 0 0;
  padding: .55rem .7rem;
  border-left: 3px solid var(--warn);
  border-radius: 0 4px 4px 0;
  background: rgba(138, 75, 31, .07);
  color: var(--ink-soft);
  font-size: .82rem;
}

/* Some browsers show the whole filename rather than truncating it, and the
   control will grow to fit unless it is pinned to the card's width. */
input[type="file"] { display: block; margin: .6rem 0; width: 100%; max-width: 100%; font-size: .85rem; }

textarea, input[type="text"], input[type="url"], input[type="number"], select {
  width: 100%;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  font-family: inherit;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem;
  resize: vertical;
}

.url-row { display: flex; gap: .5rem; margin-bottom: .5rem; }
.url-row input { flex: 1; min-width: 0; }

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.option {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
}

.option > label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }

/* Score filtering off because the file's scores carry no information. The
   heading and slider recede; the hint explaining why stays fully legible. */
.option.inactive > label,
.option.inactive .slider-row { opacity: .4; }
.option.inactive .slider-row input { cursor: not-allowed; }

.slider-row { display: flex; align-items: center; gap: .75rem; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.slider-row input[type="number"] { width: 5.5rem; flex: none; }

.check {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--ink-soft);
}
.check input { margin-top: .2rem; accent-color: var(--accent); }

button {
  padding: .55rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--surface); color: var(--accent); }

.run-row { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap; }
.run-row button { padding: .65rem 1.4rem; font-size: 1rem; }

.progress {
  height: 5px;
  margin-top: .75rem;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

.summary { margin: 0 0 1rem; }
.summary strong { font-variant-numeric: tabular-nums; }

.downloads { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }

.map-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .6rem;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: .85rem;
}
.map-controls > label { font-weight: 600; }
.map-controls input[type="range"] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.map-controls #map-opacity-value { width: 3.2rem; font-variant-numeric: tabular-nums; }
.map-controls .check { margin: 0; margin-left: auto; }

#map {
  height: 520px;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.table-wrap {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: .85rem; }

th, td {
  padding: .4rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f4f1ea;
  cursor: pointer;
  user-select: none;
  font-size: .8rem;
}
th:hover { color: var(--accent); }
th .arrow { color: var(--accent); }

td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f7f5f0; }

footer {
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: .82rem;
}
footer a { color: var(--accent); }

code {
  padding: .05rem .3rem;
  background: #f0ece3;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --surface: #1e2126;
    --ink: #e8e6e1;
    --ink-soft: #a2a9b3;
    --line: #343941;
    --accent: #5fb0cc;
    --accent-ink: #10262e;
    --warn: #e0a066;
    --ok: #7fc08d;
  }
  th { background: #262a30; }
  tbody tr:hover { background: #22262c; }
  code { background: #262a30; }
  .card.dragover { background: #1b2a30; }
}

/* Source-image override, tucked into a disclosure so it stays out of the way
   until the pixel spaces disagree. */
#source-image-details {
  margin-top: .75rem;
  padding-top: .6rem;
  border-top: 1px dashed var(--line);
  font-size: .85rem;
}
#source-image-details summary { cursor: pointer; color: var(--accent); }
#source-image-details[open] summary { margin-bottom: .4rem; }

.dims-row { display: flex; align-items: center; gap: .4rem; margin: .5rem 0; }
.dims-row input[type="number"] { width: 6rem; }
.dims-row button { padding: .3rem .7rem; font-size: .8rem; }
