:root {
  --bg: #faf9f5;
  --bg-warm: #f3f1e7;
  --surface: #ffffff;
  --border: #e7e3d4;
  --border-strong: #d8d3c1;
  --text: #1a1915;
  --text-soft: #5a5950;
  --text-muted: #97968d;
  --accent: #d97757;
  --accent-hover: #c4623f;
  --accent-soft: #f3ddcf;
  --accent-tint: #f9ece2;

  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(26, 25, 21, 0.04);
  --shadow: 0 2px 12px -4px rgba(26, 25, 21, 0.08);
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "calt";
}

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

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  transition: border-color var(--transition), color var(--transition);
}
a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ───────────────────── Navigation ───────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem clamp(1.25rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
  border-bottom: none;
}
.nav__brand:hover {
  color: var(--text);
  border-bottom: none;
}
.nav__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.7rem;
  line-height: 1;
}
.nav__tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-soft);
}
@media (max-width: 640px) {
  .nav__tagline { display: none; }
}

/* ───────────────────── Page container ───────────────────── */
.page {
  max-width: 48rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 5rem) clamp(1.25rem, 4vw, 2.5rem) 4rem;
  animation: fadein 0.7s ease 0.05s backwards;
}

/* ───────────────────── Hero ───────────────────── */
.hero {
  margin-bottom: 2.5rem;
}
.hero__eyebrow {
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.hero__title {
  margin: 0 0 1.1rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2rem, 4.5vw, 2.95rem);
  line-height: 1.08;
  letter-spacing: -0.022em;
  max-width: 22ch;
  color: var(--text);
}
.hero__lede {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-soft);
  max-width: 42ch;
}

/* ───────────────────── Card ───────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow-sm);
}

.card + .card,
.card + .meta,
form + .card,
.card--result,
.card + .submit-row {
  margin-top: 1.5rem;
}

/* ───────────────────── Row layout ───────────────────── */
.row {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 1.5rem;
  padding: 0.75rem 0;
  align-items: start;
}
@media (max-width: 720px) {
  .row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
}

.row__label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.label {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
}

.hint {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-soft);
  line-height: 1.45;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

/* ───────────────────── Selects ───────────────────── */
.select-wrap {
  position: relative;
  display: block;
}

select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 2.4rem 0.7rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
select:hover {
  border-color: var(--border-strong);
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
  background: var(--surface);
}
.select-chevron {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.7rem;
  height: 0.45rem;
  color: var(--text-soft);
  pointer-events: none;
}

optgroup {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-warm);
  letter-spacing: 0.04em;
}
optgroup option {
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  padding: 0.35rem 0.5rem;
}

.sites-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
@media (max-width: 520px) {
  .sites-grid { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field__sublabel {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.field__sublabel em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  opacity: 0.75;
}

/* ───────────────────── Text input (access code) ───────────────────── */
.text-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.text-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.text-input::placeholder {
  font-family: var(--sans);
  color: var(--text-muted);
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
  background: var(--surface);
}
.text-input__status {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  align-self: flex-start;
}
.text-input__status[data-state="saved"] { color: var(--text-soft); }
.text-input__status[data-state="error"] { color: var(--accent-hover); }

.label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.lock {
  width: 0.8rem;
  height: 0.8rem;
  color: var(--accent);
}

/* ───────────────────── Segmented control ───────────────────── */
.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
}

.seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.6rem 0.4rem;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  font-family: var(--sans);
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.seg:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}
.seg[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-strong);
}
.seg[aria-checked="true"] .seg__hint {
  color: var(--accent);
}
.seg__primary {
  font-size: 0.92rem;
  font-weight: 500;
}
.seg__hint {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ───────────────────── Brief disclosure ───────────────────── */
.brief {
  padding: 0.75rem 0;
}
.brief > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.3rem 0;
  user-select: none;
}
.brief > summary::-webkit-details-marker { display: none; }
.brief > summary > span:first-child {
  font-family: var(--sans);
  font-weight: 500;
  color: var(--text);
}
.brief__hint {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-soft);
}
.brief__chevron {
  width: 0.7rem;
  height: 0.45rem;
  color: var(--text-muted);
  transition: transform var(--transition);
}
.brief[open] .brief__chevron {
  transform: rotate(180deg);
}
.brief__body {
  margin: 0.85rem 0 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 14rem;
  overflow-y: auto;
}

/* ───────────────────── Buttons ───────────────────── */
.submit-row {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}
.btn svg {
  width: 0.85rem;
  height: 0.85rem;
}

.btn--primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn--primary:active:not(:disabled) {
  transform: translateY(1px);
}
.btn--primary:disabled {
  background: var(--text-muted);
  border-color: var(--text-muted);
  cursor: progress;
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--ghost:hover {
  background: var(--bg-warm);
  border-color: var(--text-soft);
}

.link {
  background: transparent;
  border: none;
  padding: 0.4rem 0;
  margin: 0.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--text-soft);
  cursor: pointer;
  border-bottom: 1px solid var(--border-strong);
  transition: color var(--transition), border-color var(--transition);
  align-self: flex-start;
}
.link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ───────────────────── Result / Plate ───────────────────── */
.card--result {
  padding: 1.5rem clamp(1.25rem, 3vw, 1.75rem);
}

.status {
  margin: 0 0 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.status.error { color: var(--accent-hover); }
.status.success { color: var(--text); }

.spinner {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.plate {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.plate img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.plate[data-caption]::after {
  content: attr(data-caption);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--text-soft);
  line-height: 1.5;
  display: block;
}

/* ───────────────────── Meta (colophon) ───────────────────── */
.meta {
  margin-top: 1.5rem;
  padding: 1.5rem clamp(1.25rem, 3vw, 1.75rem);
  background: transparent;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.meta__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem 1.75rem;
  margin: 0;
}
.meta__grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.meta__grid dt {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.meta__grid dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--text);
}

/* ───────────────────── Errata (BYO key) ───────────────────── */
.errata {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.errata > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.25rem 0;
  user-select: none;
}
.errata > summary::-webkit-details-marker { display: none; }
.errata > summary > span:first-child {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}
.errata > summary > span:first-child::before {
  content: "▸  ";
  color: var(--accent);
  font-size: 0.7em;
  transition: transform 0.2s ease;
  display: inline-block;
}
.errata[open] > summary > span:first-child::before {
  content: "▾  ";
}
.errata__hint {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.errata__body {
  padding: 0.85rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 38rem;
}
.errata__body p {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-soft);
}
.errata__body code {
  font-family: var(--mono);
  font-size: 0.82em;
  color: var(--text);
  background: var(--bg-warm);
  padding: 0.06em 0.4em;
  border-radius: 4px;
}
.errata__field {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.errata__field input {
  flex: 1 1 16rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.errata__field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.errata__status {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ───────────────────── Footer ───────────────────── */
.footer {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem clamp(1.25rem, 4vw, 2.5rem) 3rem;
  display: flex;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ───────────────────── Animations ───────────────────── */
@keyframes fadein {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
