:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --line: #24303d;
  --ink: #e6edf3;
  --dim: #8b9bab;
  --accent: #4ade80;
  --bad: #f87171;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfcfd; --panel: #fff; --line: #dde4ea; --ink: #101720;
    --dim: #5b6b7b; --accent: #0f9d58; --bad: #c0392b;
  }
}

* { box-sizing: border-box; }

/* The `hidden` attribute is defeated by any rule with more specificity than the browser's
   own `[hidden] { display: none }`, which is a single attribute selector. `#failure` sets
   `display: grid` from an id selector and therefore won every time: an empty red-bordered
   box sat under the recovered image permanently, looking exactly like a failed load. This
   rule stops the whole class of bug rather than that one instance. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header, main, footer { max-width: 60rem; margin: 0 auto; }

header { padding: 3rem 0 1.5rem; }
h1 { margin: 0 0 .6rem; font-size: clamp(1.9rem, 5vw, 2.7rem); letter-spacing: -0.02em; }
.lede { margin: 0; max-width: 44rem; color: var(--dim); font-size: 1.05rem; }

h2 {
  margin: 0 0 .5rem;
  font-size: 1.05rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--dim);
  display: flex; align-items: center; gap: .6rem;
}
.num {
  display: grid; place-items: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--line); color: var(--ink);
  font-size: .8rem; font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- drop zone */

#drop {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--panel);
}
#drop:hover, #drop:focus-visible, #drop.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  outline: none;
}
#drop p { margin: .2rem 0; }
.hint { color: var(--dim); font-size: .87rem; }
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; text-decoration: underline;
}

#loading { margin-top: 1rem; color: var(--dim); }
.spin {
  display: inline-block; width: .8em; height: .8em; margin-right: .4em;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- stages */

.stage {
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.stage-note { color: var(--dim); font-size: .92rem; margin: .3rem 0 1rem; max-width: 46rem; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1.25rem; align-items: start; }
@media (max-width: 700px) { .split { grid-template-columns: 1fr; } }

figure { margin: 0; }
figure img {
  width: 100%; max-width: 260px; aspect-ratio: 1; object-fit: contain;
  background: #0006; border-radius: 10px; display: block;
}
figcaption { margin-top: .45rem; font-size: .85rem; color: var(--dim); }
figcaption.good { color: var(--accent); }
figcaption.bad { color: var(--bad); }

#failure {
  width: 100%; max-width: 260px; aspect-ratio: 1; border-radius: 10px;
  border: 1px solid var(--bad); color: var(--bad);
  display: grid; place-items: center; text-align: center;
  padding: 1rem; font-size: .85rem; line-height: 1.4;
}

/* ---------------------------------------------------------------- oligos */

.oligos-wrap { position: relative; }
#oligos {
  height: 260px; overflow: hidden;
  font: 11px/1.45 var(--mono);
  color: var(--accent);
  background: #0006;
  border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .7rem;
  word-break: break-all;
}
.oligo { opacity: 0; animation: fadein .3s ease forwards; }
@keyframes fadein { to { opacity: 1; } }
.more { color: var(--dim); margin-top: .5rem; }
.fade {
  position: absolute; inset: auto 1px 1px 1px; height: 60px; border-radius: 0 0 10px 10px;
  background: linear-gradient(transparent, var(--panel));
  pointer-events: none;
}

/* ---------------------------------------------------------------- stats */

/* Each label and its value are wrapped together, because a `dl` whose `dt` and `dd` are
   direct grid items flows them independently — the pairs get torn apart across columns
   and a reader ends up matching "erasures" to the wrong number. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.stats > div { min-width: 0; }
.stats dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); }
.stats dd {
  margin: .15rem 0 0; font-variant-numeric: tabular-nums;
  font-size: 1.02rem; font-weight: 600;
}

/* ---------------------------------------------------------------- controls */

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.4rem; }
.controls label { display: block; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .35rem; }
.label-row output { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.controls .hint { display: block; margin-top: .2rem; }

.toggle-block { margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.toggle-head { display: flex; align-items: center; gap: 1rem; }
.toggle-head > span { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--dim);
  padding: .45rem 1.4rem; cursor: pointer; font: inherit; font-weight: 600;
  transition: background .15s, color .15s;
}
.seg button.on { background: var(--accent); color: #06120a; }

/* ---------------------------------------------------------------- caveat */

.caveat {
  margin: 3rem 0 0; padding: 1.5rem;
  border: 1px solid var(--line); border-left: 3px solid var(--dim);
  border-radius: 0 14px 14px 0;
  background: var(--panel);
}
.caveat h2 { margin-bottom: .8rem; }
.caveat p { margin: 0 0 .9rem; color: var(--dim); font-size: .94rem; max-width: 48rem; }
.caveat strong { color: var(--ink); }
.links { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-bottom: 0 !important; }
.links a { color: var(--accent); }

footer { margin-top: 3rem; color: var(--dim); font-size: .84rem; }
