/* ==========================================================================
   toolbox — shared design system
   Every tool inherits from the token block below. Change it here, not there.
   Two families only: a system mono for everything functional, a system serif
   with some character for headings. No webfonts, so no layout shift.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* ---- type families -------------------------------------------------- */
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas,
               "Liberation Mono", "DejaVu Sans Mono", monospace;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino,
                  "Book Antiqua", Georgia, ui-serif, serif;

  /* ---- type scale ------------------------------------------------------ */
  --t-xs:   0.6875rem;  /* 11px  — meta, units, footnotes                   */
  --t-sm:   0.78125rem; /* 12.5px — labels, table text                      */
  --t-base: 0.875rem;   /* 14px  — body, inputs                             */
  --t-md:   1rem;       /* 16px  — emphasis                                 */
  --t-lg:   1.25rem;    /* 20px  — section headings                         */
  --t-xl:   1.75rem;    /* 28px  — page title                               */
  --t-2xl:  2.25rem;    /* 36px  — secondary readouts                       */
  --t-huge: clamp(2.75rem, 12vw, 5rem); /* the number that is the point     */

  --lh-tight: 1.12;
  --lh-body:  1.5;

  /* ---- spacing scale (4px grid) --------------------------------------- */
  --s1: 0.25rem;  /*  4px */
  --s2: 0.5rem;   /*  8px */
  --s3: 0.75rem;  /* 12px */
  --s4: 1rem;     /* 16px */
  --s5: 1.5rem;   /* 24px */
  --s6: 2rem;     /* 32px */
  --s7: 3rem;     /* 48px */

  /* ---- geometry -------------------------------------------------------- */
  --r: 2px;              /* the only radius. borders do the work, not shadows */
  --bw: 1px;
  --bw-hard: 2px;
  --measure: 60rem;      /* content max width */
  --tap: 44px;           /* minimum touch target */

  /* ---- palette: light (paper + ink) ------------------------------------ */
  --bg:         #f1f0ec;
  --bg-inset:   #e4e2db;
  --surface:    #fbfaf8;
  --ink:        #15140f;
  --ink-2:      #4b4841;
  --ink-3:      #807c73;
  --rule:       #cbc7bd;
  --rule-hard:  #15140f;
  --accent:     #b83605;
  --accent-ink: #ffffff;
  --accent-wash:#f7e4da;
  --selection:  #f7d2c1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0e0e0d;
    --bg-inset:   #191917;
    --surface:    #151514;
    --ink:        #eceae5;
    --ink-2:      #a3a099;
    --ink-3:      #6e6b64;
    --rule:       #2f2e2b;
    --rule-hard:  #eceae5;
    --accent:     #ff6b2c;
    --accent-ink: #1a0c03;
    --accent-wash:#2b1408;
    --selection:  #4a2410;
  }
}

/* ==========================================================================
   reset — minimal, opinionated
   ========================================================================== */

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

/* The UA rule for [hidden] is display:none at the lowest specificity, so any
   author rule that sets display -- .field, a.btn -- silently beats it and the
   element stays on screen. Several tools toggle .hidden on those exact
   elements, so this has to win outright. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--selection); color: var(--ink); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  margin: 0;
}

p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: var(--rule);
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: var(--bw-hard) solid var(--accent);
  outline-offset: 1px;
}

/* ==========================================================================
   shell — thin bordered bands, no hero, no centred CTA
   ========================================================================== */

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--s4);
}

.topbar {
  border-bottom: var(--bw) solid var(--rule);
  background: var(--surface);
}

.topbar__inner {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  min-height: 46px;
  padding-top: var(--s2);
  padding-bottom: var(--s2);
}

.wordmark {
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark:hover { color: var(--accent); }
.wordmark::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 6px;
  background: var(--accent);
  vertical-align: 0.08em;
}

.topbar__meta {
  margin-left: auto;
  font-size: var(--t-xs);
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

main { padding-block: var(--s5) var(--s7); }

.pagehead { margin-bottom: var(--s5); }
.pagehead h1 { font-size: var(--t-xl); }
.pagehead p {
  margin-top: var(--s2);
  color: var(--ink-2);
  font-size: var(--t-sm);
  max-width: 46ch;
}

.crumb {
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s2);
}
.crumb a { text-decoration-color: var(--rule); }

.sitefoot {
  border-top: var(--bw) solid var(--rule);
  margin-top: var(--s7);
  padding-block: var(--s4);
  font-size: var(--t-xs);
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
}

/* ==========================================================================
   index — grouped tool list. one <li> per tool, nothing else.
   ========================================================================== */

.group { margin-bottom: var(--s6); }

.group__head {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  border-bottom: var(--bw-hard) solid var(--rule-hard);
  padding-bottom: var(--s2);
  margin-bottom: 0;
}
.group__head h2 {
  font-size: var(--t-lg);
}
.group__count {
  font-size: var(--t-xs);
  color: var(--ink-3);
  margin-left: auto;
  letter-spacing: 0.06em;
}

.toollist > li { border-bottom: var(--bw) solid var(--rule); }

.toollist a {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: var(--s1) var(--s4);
  align-items: baseline;
  padding: var(--s3) 0;
  text-decoration: none;
  color: inherit;
}
.toollist a:hover { background: var(--accent-wash); }
.toollist a:hover .tool__name { color: var(--accent); }

.tool__name {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.tool__desc { color: var(--ink-2); font-size: var(--t-sm); }

.tool__tags {
  grid-column: 1 / -1;
  font-size: var(--t-xs);
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

@media (max-width: 34rem) {
  .toollist a { grid-template-columns: 1fr; }
}

/* ==========================================================================
   panels + fields
   ========================================================================== */

.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s5);
  align-items: start;
}
@media (max-width: 52rem) {
  .cols { grid-template-columns: 1fr; gap: var(--s4); }
}

.panel {
  border: var(--bw) solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
}
.panel__head {
  border-bottom: var(--bw) solid var(--rule);
  padding: var(--s2) var(--s3);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.panel__body { padding: var(--s3); }

.fieldset { border: 0; margin: 0; padding: 0; }
.fieldset + .fieldset { margin-top: var(--s4); }

.field { display: block; }
.field + .field { margin-top: var(--s3); }

.row {
  display: grid;
  gap: var(--s3);
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
}

.label {
  display: block;
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: var(--s1);
}

input[type="number"],
input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  font: inherit;
  font-size: var(--t-md);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg-inset);
  border: var(--bw) solid var(--rule);
  border-radius: var(--r);
  appearance: none;
}
textarea {
  min-height: 7rem;
  font-size: var(--t-base);
  line-height: 1.6;
  resize: vertical;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  background: var(--surface);
  border-color: var(--accent);
}
/* The native date and time controls bring their own font and their own
   picker button. The box is made to match everything else; the picker is
   left alone, because replacing it would mean replacing the calendar too. */
input[type="date"],
input[type="time"] {
  font-family: var(--font-mono);
  min-width: 0;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.7;
}
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator { opacity: 1; }

@media (prefers-color-scheme: dark) {
  input[type="date"]::-webkit-calendar-picker-indicator,
  input[type="time"]::-webkit-calendar-picker-indicator { filter: grayscale(1) invert(1); }
}

/* strip spinners: the value is typed, not nudged */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--s6);
}

.inputgroup { display: flex; }
.inputgroup > select {
  width: auto;
  flex: 0 0 auto;
  border-right: 0;
  border-radius: var(--r) 0 0 var(--r);
  background-color: var(--bg-inset);
}
.inputgroup > input {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 0 var(--r) var(--r) 0;
}

.hint {
  display: block;
  margin-top: var(--s1);
  font-size: var(--t-xs);
  color: var(--ink-3);
  line-height: 1.45;
}

.check {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--tap);
  cursor: pointer;
  font-size: var(--t-sm);
  color: var(--ink-2);
}
.check input[type="checkbox"] {
  width: 1.05rem; height: 1.05rem;
  min-height: 0;
  flex: 0 0 auto;
  margin: 0;
  appearance: none;
  border: var(--bw-hard) solid var(--ink-3);
  border-radius: 0;
  background: var(--surface);
  display: grid;
  place-content: center;
  cursor: pointer;
}
.check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  width: 0.6rem; height: 0.32rem;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: translateY(-1px) rotate(-45deg);
}

/* ==========================================================================
   buttons
   ========================================================================== */

.btnrow { display: flex; flex-wrap: wrap; gap: var(--s2); }

.btn {
  font: inherit;
  font-size: var(--t-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  min-height: var(--tap);
  padding: 0 var(--s4);
  color: var(--ink);
  background: var(--surface);
  border: var(--bw-hard) solid var(--rule-hard);
  border-radius: var(--r);
  cursor: pointer;
  transition: background-color 80ms linear, color 80ms linear;
}
.btn:hover { background: var(--accent-wash); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"],
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover { filter: brightness(1.1); background: var(--accent); }
.btn--quiet {
  border-color: var(--rule);
  color: var(--ink-2);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ==========================================================================
   readout — the number is the point
   ========================================================================== */

.readout {
  border: var(--bw-hard) solid var(--rule-hard);
  border-radius: var(--r);
  background: var(--surface);
}
.readout__head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: var(--bw) solid var(--rule);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.readout__body { padding: var(--s4) var(--s3) var(--s3); }

.figure {
  font-size: var(--t-huge);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.figure--live { color: var(--accent); }

.figure__sub {
  margin-top: var(--s3);
  font-size: var(--t-sm);
  color: var(--ink-2);
}

.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  border-top: var(--bw) solid var(--rule);
}
.stat {
  padding: var(--s3);
  border-right: var(--bw) solid var(--rule);
}
.stat:last-child { border-right: 0; }
.stat__k {
  display: block;
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.stat__v {
  display: block;
  margin-top: var(--s1);
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
@media (max-width: 30rem) {
  .stat { border-right: 0; border-bottom: var(--bw) solid var(--rule); }
  .stat:last-child { border-bottom: 0; }
  .stat__v { font-size: var(--t-xl); }
}

/* live pulse — a state change, not decoration */
.dot {
  width: 7px; height: 7px;
  flex: 0 0 auto;
  background: var(--ink-3);
  border-radius: 50%;
}
.dot--on { background: var(--accent); }

/* ==========================================================================
   notes — clamps and assumptions, stated not hidden
   ========================================================================== */

.notes:empty { display: none; }
.notes { margin-top: var(--s3); display: grid; gap: var(--s1); }

.note {
  font-size: var(--t-xs);
  line-height: 1.45;
  color: var(--ink);
  background: var(--accent-wash);
  border-left: var(--bw-hard) solid var(--accent);
  padding: var(--s2) var(--s3);
}

.assumption {
  font-size: var(--t-xs);
  color: var(--ink-2);
  border-top: var(--bw) solid var(--rule);
  margin-top: var(--s4);
  padding-top: var(--s3);
}
.assumption b { color: var(--ink); font-weight: 600; }

/* ==========================================================================
   misc
   ========================================================================== */

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.errpage { padding-block: var(--s7); }
.errpage .code {
  font-family: var(--font-display);
  font-size: clamp(4rem, 18vw, 8rem);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--accent);
}

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

/* long currency strings must not overflow the readout */
.figure--long { font-size: clamp(1.75rem, 7.5vw, 3rem); letter-spacing: -0.03em; }

.readout + .btnrow { margin-top: var(--s3); }
.errpage__msg { font-size: var(--t-base); margin-top: var(--s3); }

/* ==========================================================================
   popout - full-viewport presentation mode.

   Deliberately outside the theme: always white on black, in both colour
   schemes, so a tool can be shown or screenshotted on its own with none of
   the surrounding site visible. Generic - any tool with one headline figure
   can reuse it. Put nothing in here that explains what the tool is doing.
   ========================================================================== */

.popout[hidden] { display: none; }

.popout {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s6);
  padding: var(--s5);
}

body.popout-open { overflow: hidden; }

.popout__figure {
  font-family: var(--font-mono);
  font-size: clamp(3.25rem, 21vw, 13rem);
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #fff;
}

.popout__controls { display: flex; gap: var(--s3); }

/* Override the accent entirely inside the popout. */
.popout .btn,
.popout .btn--primary,
.popout .btn--quiet {
  background: transparent;
  color: #fff;
  border-color: #fff;
  min-width: 7.5rem;
}
.popout .btn:hover,
.popout .btn--primary:hover,
.popout .btn--quiet:hover {
  background: #fff;
  color: #000;
  filter: none;
}

/* Present but not advertised. */
.popout__close {
  position: absolute;
  top: var(--s2);
  right: var(--s2);
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  background: none;
  border: 0;
  border-radius: var(--r);
  color: #3a3a3a;
  font-family: var(--font-mono);
  font-size: var(--t-lg);
  line-height: 1;
  cursor: pointer;
  transition: color 80ms linear;
}
.popout__close:hover { color: #fff; }
.popout__close:focus-visible { outline: var(--bw-hard) solid #fff; }

/* Longer clock strings (hours present) need to step down on narrow screens. */
.popout__figure--long { font-size: clamp(2rem, 12.5vw, 8rem); letter-spacing: -0.04em; }

/* ==========================================================================
   results - a dense list of derived values under a group heading.
   Generic: any tool producing many comparable outputs at once can use it.
   ========================================================================== */

.results__row {
  display: grid;
  grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto;
  gap: var(--s1) var(--s4);
  align-items: baseline;
  padding: var(--s2) 0;
  border-bottom: var(--bw) solid var(--rule);
}
.results__row:last-child { border-bottom: 0; }

.results__n {
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.results__label { font-size: var(--t-base); }
.results__def {
  font-size: var(--t-xs);
  color: var(--ink-3);
  text-align: right;
  white-space: nowrap;
}

.results__row--best { background: var(--accent-wash); }
.results__row--best .results__n { color: var(--accent); }

@media (max-width: 40rem) {
  .results__row { grid-template-columns: minmax(0, 7rem) minmax(0, 1fr); }
  .results__def { grid-column: 1 / -1; text-align: left; }
}

/* ==========================================================================
   code + text panes
   ========================================================================== */

.code-block {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  color: var(--ink);
}
.code-block--wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.pane {
  border: var(--bw) solid var(--rule);
  border-radius: var(--r);
  background: var(--bg-inset);
  padding: var(--s3);
  font-family: var(--font-mono);
  font-size: var(--t-base);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 6rem;
  max-height: 26rem;
  overflow-y: auto;
}
.pane:empty::after {
  content: "Nothing to show yet.";
  color: var(--ink-3);
  font-size: var(--t-sm);
}

/* regex matches. The underline carries the meaning as well as the tint, so
   the highlight survives a colour-blind reader and a monochrome screenshot. */
mark.hit {
  background: var(--accent-wash);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}
mark.hit--even { background: transparent; box-shadow: inset 0 -2px 0 var(--ink-3); }
mark.hit--empty { box-shadow: inset 2px 0 0 var(--accent); padding-left: 1px; }

.checkrow { display: flex; flex-wrap: wrap; gap: 0 var(--s4); }

/* ==========================================================================
   diff
   Added lines take the accent; removed lines are muted rather than a second
   hue, keeping the one-accent rule. The +/- gutter carries the meaning on
   its own, so nothing here depends on colour.
   ========================================================================== */

.diff {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  line-height: 1.6;
  border-top: var(--bw) solid var(--rule);
  overflow-x: auto;
}
.diff__row {
  display: grid;
  grid-template-columns: 3rem 3rem 1.25rem minmax(0, 1fr);
  gap: 0 var(--s2);
  padding: 1px var(--s2) 1px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.diff__ln {
  color: var(--ink-3);
  font-size: var(--t-xs);
  text-align: right;
  user-select: none;
}
.diff__sig { color: var(--ink-3); user-select: none; }

.diff__row--add {
  background: var(--accent-wash);
  box-shadow: inset 3px 0 0 var(--accent);
}
.diff__row--add .diff__sig { color: var(--accent); }

.diff__row--del {
  background: var(--bg-inset);
  box-shadow: inset 3px 0 0 var(--ink-3);
  color: var(--ink-2);
}

.diff__gap {
  padding: var(--s1) var(--s3);
  color: var(--ink-3);
  font-size: var(--t-xs);
  background: var(--bg-inset);
  border-block: var(--bw) solid var(--rule);
}

/* ==========================================================================
   privacy callout - for tools handling material that must not leave the tab
   ========================================================================== */

.shield {
  border: var(--bw-hard) solid var(--rule-hard);
  border-radius: var(--r);
  padding: var(--s3);
  font-size: var(--t-sm);
  line-height: 1.5;
  margin-bottom: var(--s4);
}
.shield b { color: var(--accent); }

/* ==========================================================================
   dropzone - a file input that also accepts a drag.

   The <input type="file"> inside stays visible and stays functional: it is
   the whole fallback if tool.js is missing, so it must never be display:none.
   tool.js only adds the drag handling and click-anywhere-to-pick.
   ========================================================================== */

.drop {
  border: var(--bw-hard) dashed var(--rule);
  border-radius: var(--r);
  background: var(--bg-inset);
  padding: var(--s5) var(--s4);
  text-align: center;
  cursor: pointer;
  transition: border-color 80ms linear, background-color 80ms linear;
}
.drop:hover { border-color: var(--ink-3); }
.drop--over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-wash);
}

.drop__hint {
  font-size: var(--t-sm);
  color: var(--ink-2);
  margin-bottom: var(--s3);
}

input[type="file"] {
  font: inherit;
  font-size: var(--t-sm);
  color: var(--ink-2);
  max-width: 100%;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: var(--t-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: var(--s3);
  padding: var(--s2) var(--s3);
  color: var(--ink);
  background: var(--surface);
  border: var(--bw-hard) solid var(--rule-hard);
  border-radius: var(--r);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--accent-wash); }

/* ==========================================================================
   key/value list - denser than .results__row, for many small labelled facts
   (metadata tags, generated files). Generic; any tool can use it.
   ========================================================================== */

.kv { border-top: var(--bw) solid var(--rule); }
.kv:empty { display: none; }

/* a group heading inside a kv list */
.kv__row--head {
  background: var(--bg-inset);
  border-bottom-color: var(--rule-hard);
}
.kv__row--head .kv__k { color: var(--ink); font-weight: 600; }

.kv__row {
  display: grid;
  grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
  gap: var(--s1) var(--s4);
  align-items: baseline;
  padding: var(--s2) 0;
  border-bottom: var(--bw) solid var(--rule);
}
.kv__k {
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.kv__v { font-size: var(--t-sm); overflow-wrap: anywhere; }
.kv__v--strong { color: var(--accent); font-size: var(--t-md); font-weight: 600; }

.kv__row--flag { background: var(--accent-wash); }

@media (max-width: 34rem) {
  .kv__row { grid-template-columns: 1fr; }
}

/* ==========================================================================
   image preview

   The checkerboard is the same in light and dark on purpose: it stands for
   transparency, not for the page background, and an alpha channel that looks
   different in the two schemes would be misread as a change in the image.
   ========================================================================== */

.preview {
  display: grid;
  place-items: center;
  min-height: 10rem;
  padding: var(--s3);
  border: var(--bw) solid var(--rule);
  border-radius: var(--r);
  overflow: auto;
}
.preview img, .preview canvas, .preview video {
  display: block;
  max-width: 100%;
  max-height: 22rem;
}

.checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d5d2ca 25%, transparent 25%, transparent 75%, #d5d2ca 75%),
    linear-gradient(45deg, #d5d2ca 25%, transparent 25%, transparent 75%, #d5d2ca 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

/* generated icons, shown at their true pixel size so the downscale is honest */
.tiles { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: flex-end; }
.tile { display: grid; justify-items: center; gap: var(--s1); }
.tile img { display: block; image-rendering: pixelated; }
.tile__k {
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* ==========================================================================
   progress - for the one kind of tool that cannot answer instantly.

   A bar and a sentence, never a spinner: a spinner says only that something
   is happening, and every tool here would rather say how much of it is done.
   The <progress> element carries the value, so nothing sets an inline style.
   ========================================================================== */

.meterrow {
  display: grid;
  gap: var(--s2);
  margin-top: var(--s4);
}

.meter {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border: var(--bw) solid var(--rule);
  border-radius: var(--r);
  background: var(--bg-inset);
  color: var(--accent);            /* the fallback bar colour in older engines */
}
.meter::-webkit-progress-bar { background: var(--bg-inset); }
.meter::-webkit-progress-value { background: var(--accent); }
.meter::-moz-progress-bar { background: var(--accent); }

/* ==========================================================================
   path overlay - two renderings of the same shape, stacked.

   The optimized path is dashed and thinner as well as accented, so a
   divergence is visible without relying on colour at all.
   ========================================================================== */

.pathview {
  display: block;
  width: 100%;
  height: auto;
  border: var(--bw) solid var(--rule);
  border-radius: var(--r);
  background: var(--bg-inset);
}
.pathview__before {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}
.pathview__after {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
}

/* An <a> used as a button needs the box model a <button> gets for free. */
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
a.btn:hover { color: var(--ink); }
a.btn--primary, a.btn--primary:hover { color: var(--accent-ink); }

/* The colour well is a native control; only its box needs to match. */
input[type="color"] {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s1);
  background: var(--bg-inset);
  border: var(--bw) solid var(--rule);
  border-radius: var(--r);
  cursor: pointer;
}
