:root {
  --paper: #FFFFFF;
  --sheet: #FAF8F5;
  --ink: #0A0A0A;
  --ink-soft: #5F5B55;
  --rule: #ECE8E2;
  --rule-strong: #DCD6CD;
  --tang: #0A0A0A;
  --tang-ink: #82633A;
  --tang-wash: #F5EFE6;
  --on-tang: #FFFFFF;
  --good: #1f6b3a;
  --bad: #a3261a;
  --check-a: #ffffff;
  --check-b: #EEEAE4;
  --round: 12px;
  --stack: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --code: #F4F1EC;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  }

:root[data-theme="dark"] {
    --paper: #000000;
    --sheet: #0F0E0D;
    --ink: #FFFFFF;
    --ink-soft: #A8A39C;
    --rule: #24221F;
    --rule-strong: #35322E;
    --tang: #FFFFFF;
    --tang-ink: #C9AE8A;
    --tang-wash: #1C1813;
    --good: #7fd29b;
    --bad: #ff9a8c;
    --check-a: #1A1917;
    --check-b: #111010;
    --on-tang: #000000;
    --code: #171614;
  }

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--stack);
}

h1, h2, h3, p, ul, fieldset, legend { margin: 0; padding: 0; }

fieldset { border: 0; min-width: 0; }

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--tang-ink);
  outline-offset: 2px;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand svg { width: 28px; height: 28px; flex: none; }

.pledge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

.pledge svg { width: 16px; height: 16px; flex: none; color: var(--tang-ink); }

.intro { padding: 56px 0 36px; max-width: 760px; }

.intro h1 {
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.intro h1 em { font-style: normal; color: var(--tang-ink); }

.intro p {
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 18px;
}

.bench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: auto 1fr;
  grid-template-areas: "intake panel" "results panel";
  gap: 24px 28px;
  align-items: start;
}

.intake { grid-area: intake; }
.panel { grid-area: panel; }
.results { grid-area: results; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 44px 24px;
  border: 2px dashed var(--rule-strong);
  border-radius: var(--round);
  background: var(--sheet);
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}

.is-dragging .dropzone {
  border-color: var(--tang);
  background: var(--tang-wash);
}

.dropzone > svg { width: 40px; height: 40px; color: var(--tang-ink); }

.dropzone p { color: var(--ink-soft); }

.notice { margin-top: 10px; color: var(--bad); font-size: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s;
}

.btn:hover { background: var(--tang-wash); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-main {
  border-color: var(--tang);
  background: var(--tang);
  color: var(--on-tang);
}

.btn-main:hover { background: var(--tang); filter: brightness(1.07); }

.btn:disabled {
  border-color: var(--rule-strong);
  background: transparent;
  color: var(--ink-soft);
  filter: none;
  cursor: default;
}

.panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 22px;
  padding: 22px;
  border: 1px solid var(--rule);
  border-radius: var(--round);
  background: var(--sheet);
}

.panel legend, .field > label, .field > .label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.choices { display: flex; flex-wrap: wrap; gap: 6px; }

.choice { position: relative; display: block; cursor: pointer; }

.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice span {
  display: block;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
}

.choice small {
  display: block;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.choice input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.choice input:checked + span small { color: inherit; opacity: 0.75; }

.choice input:focus-visible + span {
  outline: 3px solid var(--tang-ink);
  outline-offset: 2px;
}

.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.field { display: grid; }

.field + .field, .sub { margin-top: 16px; }

.hint { margin-top: 6px; color: var(--ink-soft); font-size: 13px; }

.slider { display: flex; align-items: center; gap: 12px; }

.slider input { flex: 1; min-width: 0; height: 28px; accent-color: var(--tang); }

.slider output {
  min-width: 2.5ch;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.swatch { display: flex; align-items: center; gap: 12px; }

.swatch input {
  width: 52px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--sheet);
  cursor: pointer;
}

.swatch code { font: 14px ui-monospace, Consolas, monospace; color: var(--ink-soft); }

.pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; }

.pair > span { padding-bottom: 9px; color: var(--ink-soft); }

.unit { display: flex; align-items: center; gap: 8px; }

.unit span { color: var(--ink-soft); }

.text, select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}

.unit .text { max-width: 110px; }

.tick {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  cursor: pointer;
}

.tick input { width: 20px; height: 20px; margin: 0; accent-color: var(--tang); }

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.dock { display: contents; }

.tally { flex: 1 1 220px; font-weight: 600; font-variant-numeric: tabular-nums; }

.tally progress {
  display: block;
  width: 100%;
  max-width: 260px;
  height: 6px;
  margin-top: 8px;
  accent-color: var(--tang);
}

.rows { list-style: none; }

.peek {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  line-height: 0;
  cursor: zoom-in;
}

.peek:disabled { cursor: default; }

.peek:not(:disabled):hover .thumb { border-color: var(--tang); }

.compare {
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 18px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--round);
  background: var(--sheet);
  color: var(--ink);
}

.compare::backdrop { background: rgba(12, 11, 9, 0.72); }

.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.compare-head h2 {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage {
  --cut: 50%;
  position: relative;
  width: min(100%, calc((100vh - 220px) * var(--ratio, 1.5)));
  margin: 0 auto;
  aspect-ratio: var(--ratio, 1.5);
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: repeating-conic-gradient(var(--check-b) 0% 25%, var(--check-a) 0% 50%) 0 0 / 16px 16px;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.stage img, .was {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.was {
  overflow: hidden;
  clip-path: inset(0 calc(100% - var(--cut)) 0 0);
}

.split {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--cut);
  width: 2px;
  margin-left: -1px;
  background: var(--tang);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.tag {
  position: absolute;
  top: 10px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(12, 11, 9, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tag-was { left: 10px; }
.tag-now { right: 10px; }

.compare input[type="range"] {
  display: block;
  width: 100%;
  height: 32px;
  margin: 8px 0 0;
  accent-color: var(--tang);
}

.row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}

.thumb {
  width: 56px;
  height: 56px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: repeating-conic-gradient(var(--check-b) 0% 25%, var(--check-a) 0% 50%) 0 0 / 14px 14px;
}

.name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facts {
  color: var(--ink-soft);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.gain { font-weight: 700; white-space: nowrap; }
.gain.is-less { color: var(--good); }
.is-failed .sizes { color: var(--bad); }

.row.is-stale .meta, .row.is-stale .thumb { opacity: 0.55; }
.row.is-stale .get { visibility: hidden; }

.row .btn { min-height: 40px; padding: 0 14px; }

.remove {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 16px;
  cursor: pointer;
}

.remove:hover { background: var(--tang-wash); color: var(--ink); }

.row > .remove { grid-column: 4; }

.prose {
  margin-top: 88px;
  padding: 56px 0 24px;
  border-top: 1px solid var(--rule);
}

.prose > * { max-width: 720px; }

.prose h2 {
  margin: 48px 0 12px;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.prose h2:first-child { margin-top: 0; }

.prose h3 { margin: 24px 0 4px; font-size: 17px; }

.prose p + p { margin-top: 12px; }

.prose ul { padding-left: 20px; }

.prose li { margin-top: 8px; }

.prose p, .prose li { color: var(--ink-soft); }

.prose strong { color: var(--ink); }

.colophon {
  margin-top: 40px;
  padding: 24px 0 48px;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 14px;
}

@media (max-width: 900px) {
  .bench {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "intake" "panel" "results";
  }
  .panel { position: static; }
  .results-head { justify-content: flex-end; padding-bottom: 10px; }
  .dock {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--rule-strong);
    background: var(--sheet);
  }
  .tally { flex: 1 1 0; min-width: 0; font-size: 14px; line-height: 1.35; }
  .tally progress { margin-top: 6px; }
  .has-items .colophon { padding-bottom: 120px; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .masthead { flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px 0; }
  .intro { padding: 36px 0 28px; }
  .intro p { font-size: 17px; }
  .dropzone { padding: 32px 16px; }
  .panel { padding: 18px 16px; }
  .row { grid-template-columns: 48px minmax(0, 1fr) auto auto; gap: 10px; }
  .thumb { width: 48px; height: 48px; }
  .row .btn { width: 40px; padding: 0; }
  .row .btn span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .dock { gap: 10px; padding-right: 16px; padding-left: 16px; }
  .tally { font-size: 13px; }
  .dock .btn { padding: 0 14px; }
  .zip-long { display: none; }
  .compare { padding: 14px; }
  .prose { margin-top: 56px; padding-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
