:root {
  --bg: #f4f1ea;
  --text: #171717;
  --accent: #7a1f1f;
  --bluegrey: #2f3e46;
  --line: #d3cdc2;
  --paper: #fffdf7;
  --muted: #68635b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a { color: inherit; }

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px clamp(18px, 5vw, 64px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  min-width: 230px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.nav,
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.nav a,
.site-footer a {
  text-decoration: none;
  color: var(--bluegrey);
  font-weight: 700;
  font-size: 0.94rem;
}

.nav a:hover,
.site-footer a:hover { color: var(--accent); text-decoration: underline; }

.hero,
.page,
.panel,
.metrics {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
}

.hero {
  padding: clamp(56px, 8vw, 108px) 0;
  border-bottom: 4px solid var(--text);
}

.page,
.panel {
  padding: clamp(32px, 5vw, 68px) 0;
}

.narrow { max-width: 820px; }

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  font-size: 0.78rem;
}

h1,
h2,
h3,
legend {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.08;
}

h1 {
  max-width: 980px;
  margin: 0 0 22px;
  font-size: clamp(2.8rem, 7.5vw, 6.8rem);
}

.page h1 { font-size: clamp(2.4rem, 5vw, 4.8rem); }

h2 { margin-top: 34px; font-size: clamp(1.55rem, 3vw, 2.4rem); }

.lede {
  max-width: 850px;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.formula {
  display: inline-block;
  padding: 12px 14px;
  background: var(--text);
  color: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.global-index {
  display: grid;
  gap: 4px;
  width: min(520px, 100%);
  margin-top: 18px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
}

.global-index span {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
}

.global-index strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 7vw, 5.6rem);
  line-height: 1;
}

.global-index small {
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button,
button {
  display: inline-block;
  border: 1px solid var(--text);
  background: transparent;
  color: var(--text);
  padding: 11px 15px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.button:hover,
button:hover {
  background: var(--text);
  border-color: var(--text);
  color: white;
}

.intro-panel,
.notice,
.messages {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 18px;
}

.upload-counter {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0 18px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
}

.upload-counter strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

.upload-counter span {
  color: var(--muted);
  font-weight: 800;
}

.messages {
  width: min(1160px, calc(100% - 36px));
  margin: 18px auto 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 26px 0;
}

.metrics.flush { width: 100%; }

.metrics article {
  background: var(--paper);
  border-top: 4px solid var(--accent);
  padding: 18px;
}

.metrics span {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 1;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.contrast-grid,
.definition-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.contrast-grid div,
.definition-list article {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px;
}

.contrast-grid div:nth-child(odd) {
  border-left: 5px solid var(--bluegrey);
}

.contrast-grid div:nth-child(even) {
  border-left: 5px solid var(--accent);
}

.contrast-grid span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.76rem;
}

.contrast-grid strong {
  display: block;
  margin-top: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1.2;
}

.grid > div,
.list-item,
fieldset,
.notice {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px;
}

.list {
  display: grid;
  gap: 12px;
}

.list-item {
  display: grid;
  gap: 6px;
  text-decoration: none;
}

.list-item span,
.list-item small,
.hint,
.small,
.empty {
  color: var(--muted);
}

.search {
  display: flex;
  gap: 10px;
  margin: 22px 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px;
  font: inherit;
}

textarea { min-height: 116px; resize: vertical; }

.case-form {
  display: grid;
  gap: 18px;
}

fieldset {
  margin: 0;
}

legend {
  padding: 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  font-weight: 750;
}

.field.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field.checkbox input { width: auto; }

.field small {
  color: var(--muted);
  font-weight: 400;
}

.error {
  color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.facts div {
  background: var(--paper);
  border-top: 3px solid var(--bluegrey);
  padding: 14px;
}

.facts dt {
  color: var(--muted);
  font-weight: 800;
}

.facts dd { margin: 0; }

.plain {
  padding-left: 1.2rem;
}

.plain li { margin-bottom: 8px; }

.case-stamp {
  display: inline-block;
  margin: 0 0 18px;
  padding: 8px 12px;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(-1deg);
}

.analysis-questions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 20px;
}

.analysis-questions span {
  background: var(--paper);
  border-top: 3px solid var(--accent);
  padding: 12px;
  font-weight: 800;
}

.micro-formula {
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.refrain,
.formula-stack {
  display: grid;
  gap: 8px;
  margin: 22px 0;
}

.refrain p,
.formula-stack p {
  margin: 0;
  background: var(--text);
  color: var(--paper);
  padding: 12px 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  line-height: 1.15;
}

.compact-refrain p {
  font-size: 1.1rem;
}

.definition-list h3 {
  margin-top: 0;
  color: var(--accent);
}

.big-questions {
  display: grid;
  gap: 10px;
  padding-left: 0;
  list-style: none;
  counter-reset: questions;
}

.big-questions li {
  counter-increment: questions;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 14px;
  font-weight: 850;
}

.big-questions li::before {
  content: counter(questions) ". ";
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
}

.article {
  max-width: 920px;
}

.article h2 {
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.article p {
  max-width: 820px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
}

th,
td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

th {
  background: #ebe6dc;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag-cloud span {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 8px 10px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.key-source {
  margin: 20px 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  padding: 22px;
}

.source-grid article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--bluegrey);
  padding: 18px;
}

.source-grid h3 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.site-footer {
  margin-top: 60px;
  padding: 28px clamp(18px, 5vw, 64px);
  background: var(--text);
  color: var(--paper);
}

.site-footer a { color: var(--paper); }

.site-footer .small { color: #d6d0c8; max-width: 900px; }

@media (max-width: 880px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .metrics,
  .grid.five,
  .contrast-grid,
  .definition-list,
  .analysis-questions,
  .source-grid,
  .form-grid,
  .facts { grid-template-columns: 1fr; }
  .search { flex-direction: column; }
}
