:root {
  --paper: #f3efe6;
  --ink: #1d1916;
  --muted: #5e564c;
  --line: #d9d0c3;
  --card: #fffdf8;
  --red: #b4332a;
  --red-ink: #7d241d;
  --ok: #1d5c40;
  --ok-bg: #e5f2ea;
  --bad: #8d2a24;
  --bad-bg: #f8e6e3;
  --shadow: 0 1px 0 rgba(29, 25, 22, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: clip;
  background:
    linear-gradient(90deg, rgba(180, 51, 42, 0.9), rgba(180, 51, 42, 0.9)) 0 0 / 100% 6px no-repeat,
    var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  line-height: 1.45;
}

button, input { font: inherit; }

a { color: var(--red-ink); }

.top, main {
  width: min(920px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  margin: 0 auto;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 0 8px;
}

.brand {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 650;
}

.brand span { color: var(--muted); letter-spacing: 0.08em; margin-left: 0.6rem; }

.lang { display: flex; gap: 4px; }

.lang button, .ghost, #measure, #record {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

.lang button[aria-pressed="true"], #measure, #record {
  background: var(--ink);
  color: var(--paper);
}

#record:disabled, #measure:disabled { opacity: 0.45; cursor: not-allowed; }

.ghost { font-family: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif; font-size: 0.85rem; }

h1 {
  margin: 0.2rem 0 0.6rem;
  font-size: clamp(2rem, 4vw, 3.15rem);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.05;
  max-width: 12ch;
}

.tags, .cite, .quiet, .label {
  font-family: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin: 18px 0 0;
  color: var(--red);
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  font-weight: 700;
}

.tags a { color: inherit; text-decoration: none; }
.tags a:hover { text-decoration: underline; }

.cite {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.pipeline {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0;
  margin: 28px 0;
}

.pipeline li {
  border-top: 1px solid var(--ink);
  padding-top: 8px;
  font-family: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif;
}

.pipeline span {
  display: block;
  color: var(--red);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 22px;
  margin-bottom: 16px;
}

.panel-head, .fields {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

h2 { margin: 0; font-size: 1.45rem; font-weight: 560; }

figure { margin: 18px 0 0; }

img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: white;
  border-radius: 12px;
}

figcaption, .quiet, .scope { color: var(--muted); font-size: 0.92rem; }

.shot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 24px;
  align-items: end;
  margin-top: 16px;
}

.bits {
  list-style: none;
  display: flex;
  gap: 6px;
  padding: 0;
  margin: 0;
}

.bits li {
  width: 2rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1rem;
}

.bits li small {
  display: none;
}

.value {
  margin: 0;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
}

.label {
  margin: 0 0 6px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.fields { align-items: stretch; margin-top: 16px; }

label { flex: 1; display: flex; flex-direction: column; gap: 6px; }

label span { font-family: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif; font-size: 0.92rem; }

input[type="text"], input[type="number"], .tamper {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
}

input:focus, button:focus-visible, .tamper:focus {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.fingerprint { margin: 16px 0; }

pre {
  margin: 0 0 12px;
  padding: 0.75rem 0.85rem;
  overflow-x: auto;
  background: #221e1b;
  color: #f6f1e8;
  border-radius: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.4;
}

.error { min-height: 1.2em; color: var(--bad); font-family: ui-sans-serif, sans-serif; }

.ledger-table, .card-list { width: 100%; border-collapse: collapse; margin-top: 12px; }

.ledger-table th, .ledger-table td {
  text-align: left;
  vertical-align: top;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.ledger-table th {
  font-family: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.hash {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  word-break: break-all;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-family: ui-sans-serif, sans-serif;
  font-size: 0.78rem;
  white-space: nowrap;
}

.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.empty {
  font-family: ui-sans-serif, sans-serif;
  color: var(--muted);
}

.scope {
  margin: 8px 0 48px;
  max-width: 78ch;
}

.selftest { display: none; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; row-gap: 10px; }
  .lang { flex: none; }
  .pipeline, .fields, .shot, .panel-head { grid-template-columns: 1fr; display: grid; }
  .panel-head { justify-items: start; }
  .bits { flex-wrap: wrap; }
  .ledger-table thead { display: none; }
  .ledger-table tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .ledger-table td {
    display: block;
    border: 0;
    padding: 4px 0;
  }
  .ledger-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-family: ui-sans-serif, sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
}
