:root {
  --bg: #e6e0d4;
  --ink: #1a1714;
  --muted: #5c564c;
  --card: #f7f3ea;
  --line: #1a1714;
  --accent: #c2310c;
  --accent-ink: #fff8f4;
  --good: #0d6b3a;
  --bad: #9d1c1c;
  --shadow: 4px 4px 0 #1a1714;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --ink: #f4efe6;
    --muted: #b7b0a4;
    --card: #221f1b;
    --line: #d9d0c2;
    --accent: #ff5a36;
    --accent-ink: #1a0905;
    --good: #8ee0b2;
    --bad: #ff9b8e;
    --shadow: 4px 4px 0 #c8bba8;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle, color-mix(in srgb, var(--ink) 14%, transparent) 1px, transparent 1.2px) 0 0 / 18px 18px,
    var(--bg);
}

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

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  z-index: 2;
  text-decoration: none;
}

.skip:focus { top: 12px; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) 16px 48px;
}

.mast {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  align-items: end;
  margin-bottom: 22px;
}

.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(52px, 12vw, 84px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 0.85;
}

.lede {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  max-width: 58ch;
  color: var(--muted);
  text-wrap: pretty;
}

.stamp {
  width: 88px;
  height: 88px;
  margin-bottom: 6px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.15;
  text-transform: uppercase;
  transform: rotate(-12deg);
}

.card {
  background: var(--card);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card + .card,
.stats,
.list-head { margin-top: 18px; }

form { display: flex; flex-direction: column; gap: 8px; }

label { font-weight: 700; font-size: 14px; }

.row { display: flex; gap: 8px; }

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

input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
}

.hint { margin: 0; color: var(--muted); font-size: 13px; }

button, .btn {
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover, .btn:hover { background: color-mix(in srgb, var(--accent) 12%, var(--card)); }

.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.pri:hover { background: color-mix(in srgb, var(--accent) 88%, black); }

button:disabled { opacity: 0.6; cursor: progress; }

.texty {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  justify-content: flex-start;
  font-weight: 600;
}

.texty:hover { background: transparent; }

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

.pri:focus-visible { outline-color: var(--ink); }

.err { color: var(--bad); font-size: 14px; font-weight: 600; margin: 2px 0 0; }

#result { margin-top: 14px; padding-top: 14px; border-top: 1.5px dashed var(--line); }

.out { display: flex; gap: 8px; margin-top: 6px; align-items: start; }

.linkbox {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  user-select: all;
  cursor: text;
}

.meter { display: grid; gap: 6px; margin: 12px 0 6px; }

.meter p {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.meter em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 9ch;
}

.track {
  display: block;
  height: 8px;
  background: color-mix(in srgb, var(--line) 18%, transparent);
}

.track span { display: block; height: 100%; width: 0; background: var(--line); }

.track span.now { background: var(--accent); }

.savings { margin: 0; font-weight: 700; }

.savings.good { color: var(--good); }

.savings.bad { color: var(--muted); font-weight: 600; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1.5px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.stats div { padding: 12px 14px; }

.stats div + div { border-left: 1.5px solid var(--line); }

.stats strong {
  display: block;
  font-family: var(--serif);
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stats span { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.fine { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

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

h2 { margin: 0; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; }

#clear { min-height: 36px; padding: 6px 10px; font-size: 13px; }

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

li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1.5px solid var(--line);
}

li:first-child { border-top: 0; padding-top: 0; }

.host { font-weight: 700; }
.path, .meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }

li button { min-height: 40px; padding: 6px 10px; }

.empty { margin: 0; color: var(--muted); }

#gate-host { color: var(--accent); }

.gate h2 {
  font-family: var(--serif);
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-transform: none;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.full {
  margin: 12px 0 16px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 13px;
  max-width: 62ch;
}

[hidden] { display: none !important; }

html[data-route="go"] #maker { display: none !important; }
html[data-route="go"] #pending { display: block !important; }

@media (max-width: 560px) {
  .mast { grid-template-columns: 1fr; }
  .stamp { width: 72px; height: 72px; margin: 0; transform: none; }
  .row, .out, .actions { flex-direction: column; }
  .row button, .out button, .actions .btn, .actions button { width: 100%; }
  li { grid-template-columns: 1fr 1fr; }
  li > div { grid-column: 1 / -1; }
}

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