:root {
  --bg: #f6f5f1;
  --bg-soft: #efede7;
  --surface: #ffffff;
  --text: #18202b;
  --muted: #5b6573;
  --line: #e4e1d9;
  --line-strong: #d3cfc4;
  --accent: #1d4999;   /* econlinguistics.org logo blue */
  --accent-ink: #ffffff;
  --accent-soft: #e6edf5;
  --rust: #a4452a;
  --mark-lo: #fde9b8;
  --mark-hi: #f5a33a;
  --warn: #8a5300;
  --warn-bg: #fff4dd;
  --error: #a3271f;
  --bar: #1d4999;
  --series-1: #2a78d6;   /* earnings calls */
  --series-2: #eb6834;   /* presidents */
  --series-3: #1baf7a;   /* sports */
  --grid: #e8ebef;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(24, 32, 43, .04), 0 8px 24px rgba(24, 32, 43, .05);
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 84px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
code, pre { font-family: var(--mono); font-size: .86em; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: -.005em; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 20; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row.gap { gap: 10px; flex-wrap: wrap; }
.row.top { align-items: baseline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header + tabs */
.site-header { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: 8px 20px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.18rem; color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { display: block; width: 30px; height: 30px; }
.small-mark { display: inline-block; width: 20px; height: 20px; vertical-align: -5px; margin-right: 4px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { position: relative; color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 500; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; transition: background .15s, color .15s; }
.tabs a:hover { color: var(--text); background: var(--bg-soft); }
.tabs a[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }

/* page sections */
.tab-panel { padding-bottom: 24px; }
.hero { padding: 56px 0 8px; }
.eyebrow { margin: 0 0 12px; color: var(--rust); font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow i { font-style: normal; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); line-height: 1.08; margin: 0 0 16px; max-width: 820px; }
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { font-size: 1.12rem; line-height: 1.6; color: var(--muted); max-width: 760px; margin: 0; }
.page-head { padding: 44px 0 4px; }
.page-head h1 { font-size: clamp(1.8rem, 3.6vw, 2.4rem); line-height: 1.12; margin: 0 0 10px; }
.section-head { margin: 48px 0 6px; }
.section-head h2 { font-size: 1.7rem; margin: 0 0 4px; }
.section-head p { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin-block: 20px; }
.card h2 { margin: 0 0 12px; font-size: 1.4rem; }
.card h3 { margin: 0 0 8px; font-size: 1.12rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.analyzer { margin-top: 28px; padding: 26px; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 5px 13px; font: inherit; font-size: .88rem; cursor: pointer; transition: border-color .15s, background .15s; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.kbd-hint { margin-right: 4px; }

textarea, input[type=search], select {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--text);
  font: inherit; padding: 13px 15px; }
textarea { resize: vertical; min-height: 190px; margin: 14px 0 12px; line-height: 1.55; }
textarea:focus, input:focus, select:focus, .drop:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select { width: auto; padding: 7px 10px; font-size: .9rem; }

.btn { border-radius: 999px; padding: 10px 20px; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--bg-soft); }
.link { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.error { color: var(--error); margin: 10px 0 0; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 14px 0 0; }

/* results */
.results-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
.results-grid > *, .header-row > * { min-width: 0; }
.results-grid .card { margin-block: 20px 0; }
.headline .big-number { font-family: var(--serif); font-size: 3.2rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.05; margin-top: 6px; }
.pct-line { margin: 4px 0 10px; color: var(--muted); }
.pct-line strong { color: var(--text); }
.sub-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.sub-metrics div { display: flex; flex-direction: column; gap: 2px; font-size: .88rem; }
.sub-metrics strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.measures { display: grid; gap: 14px; margin-top: 10px; }
.measure { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
.measure .name { font-weight: 600; }
.measure .val { font-variant-numeric: tabular-nums; }
.measure .mini { grid-column: 1 / -1; display: block; width: 100%; height: 34px; overflow: visible; }
.mini .area { fill: var(--series-1); fill-opacity: .14; stroke: var(--series-1); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.mini .base { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.mini .you { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.measure .desc { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }
.measure .desc a { color: inherit; }

.highlight { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; max-height: 340px; overflow: auto;
  line-height: 1.9; background: var(--bg); margin: 10px 0; overflow-wrap: anywhere; }
mark { border-radius: 4px; padding: 1px 0; color: var(--text); box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.legend { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.lo { background: var(--mark-lo); }
.swatch.hi { background: var(--mark-hi); }
.top-terms { display: flex; flex-wrap: wrap; gap: 8px; }
.top-terms span { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: .85rem; }

/* research */
h3.sub { margin: 22px 0 10px; font-family: var(--sans); font-size: .78rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; }
.paper-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.paper { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.paper.featured { border-top: 3px solid var(--accent); }
.paper h4 { margin: 2px 0 0; font-size: 1.12rem; line-height: 1.35; }
.paper h4 a { color: var(--text); text-decoration: none; }
.paper h4 a:hover { color: var(--accent); text-decoration: underline; }
.venue { margin: 0; font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.badge { display: inline-block; background: var(--accent-soft); color: var(--accent); font-weight: 600; border-radius: 999px; padding: 2px 10px; }
.badge.muted-badge { background: var(--bg-soft); color: var(--muted); }
.authors { margin: 0; color: var(--muted); font-size: .92rem; }
.note { margin: 0; font-size: .93rem; }
.paper details summary { cursor: pointer; color: var(--accent); font-size: .88rem; }
.paper details p { font-size: .9rem; color: var(--muted); }
.cite-row { margin: auto 0 0; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line-strong); background: transparent; color: var(--text); border-radius: 999px; padding: 3px 11px;
  font: inherit; font-size: .8rem; cursor: pointer; }
.pill:hover { border-color: var(--accent); color: var(--accent); }

/* data */
.dl-form fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.dl-form legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.legend-actions { font-weight: 400; margin-left: 6px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.choice-row label, .choice-grid label { display: inline-flex; gap: 7px; align-items: center; }
.choice-row label.off { color: var(--muted); }
.choice-row select { width: auto; margin-left: 6px; }
.dl-foot { border-top: 1px solid var(--line); padding-top: 14px; }
.dl-foot p { margin: 0; }
.notes { color: var(--muted); font-size: .92rem; }
.notes p { max-width: 820px; }

/* glossary */
.prose p { max-width: 820px; }
.prose h3 { margin-top: 18px; }
.formula { font-family: var(--serif); font-size: 1.05rem; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; margin-top: 12px; }
.table-wrap.plain { max-height: none; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; background: var(--surface); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
#mtable td:first-child { font-weight: 600; white-space: nowrap; }
#mtable td:last-child a { white-space: nowrap; }
input[type=search] { margin-top: 6px; }

/* api */
.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 26px; text-align: center; margin-top: 12px; background: var(--bg); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.endpoints { display: grid; gap: 2px; margin: 14px 0 6px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ep { padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ep:last-child { border-bottom: 0; }
.ep code { font-weight: 600; }
.ep p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.method { display: inline-block; min-width: 50px; text-align: center; font: 700 .72rem/1.9 var(--mono); border-radius: 6px; margin-right: 8px; padding: 0 6px; }
.method.get { background: var(--accent-soft); color: var(--accent); }
.method.post { background: color-mix(in srgb, var(--rust) 16%, transparent); color: var(--rust); }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; overflow-x: auto; line-height: 1.5; }

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; margin-top: 40px; }
.footer-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 20px; padding: 18px 0 36px; }
.footer p { margin: 0; }

@media (max-width: 820px) {
  .results-grid, .paper-grid { grid-template-columns: 1fr; }
  .headline .big-number { font-size: 2.5rem; }
  .hero { padding-top: 36px; }
}
@media (max-width: 560px) {
  .header-row { padding: 8px 0; }
  .tabs { width: 100%; }
  .card, .analyzer { padding: 18px; }
  .paper { padding: 18px; }
  .kbd-hint { display: none; }
  .sub-metrics { grid-template-columns: 1fr; }
  #mtable td:last-child a { white-space: normal; }
}

/* comparison chart */
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--muted); margin: 8px 0 2px; }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .line { width: 16px; height: 2px; border-radius: 1px; display: inline-block; }
.chart-legend .line.you { height: 0; border-top: 2px dashed var(--text); background: none; }
.chart-wrap { position: relative; }
.dist { width: 100%; height: auto; display: block; touch-action: none; outline: none; }
.dist:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.dist .curve { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dist .base { stroke: var(--line); stroke-width: 1; }
.dist .axis { fill: var(--muted); font-size: 11px; }
.dist .dlabel { fill: var(--muted); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.dist .you { stroke: var(--text); stroke-width: 2; stroke-dasharray: 4 3; }
.dist .you-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.dist .cross { stroke: var(--muted); stroke-width: 1; }
.chart-tip { position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: .8rem; box-shadow: 0 4px 16px rgba(16,24,40,.12); min-width: 190px; z-index: 2; }
.chart-tip .head { margin-bottom: 4px; }
.chart-tip .tr { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.chart-tip .tr .line { width: 12px; height: 2px; border-radius: 1px; display: inline-block; flex: none; }
.chart-tip strong { font-variant-numeric: tabular-nums; }
.table-view summary { cursor: pointer; color: var(--accent); font-size: .85rem; margin-top: 8px; }
.table-view table { margin-top: 8px; }
caption { caption-side: top; text-align: left; color: var(--muted); font-size: .8rem; padding-bottom: 6px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface);
  padding: 8px 14px; border-radius: 8px; font-size: .88rem; z-index: 10; }
#endpoints h3 { margin-top: 26px; }
