:root {
  --paper: #f5f1e8;
  --paper-2: #ebe5d8;
  --ink: #132827;
  --ink-2: #35504d;
  --forest: #143f3b;
  --teal: #0e6e68;
  --mint: #9bd5c3;
  --lime: #c9ee48;
  --coral: #ef6b57;
  --amber: #f4b942;
  --blue: #4f77c7;
  --white: #fffdf8;
  --line: rgba(19, 40, 39, .17);
  --shadow: 0 24px 70px rgba(19, 40, 39, .12);
  --radius: 8px;
  --font: Geist, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(19, 40, 39, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 40, 39, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: var(--font);
  line-height: 1.5;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { outline-offset: 3px; }
:focus-visible { outline: 3px solid #2c5fc0; }
a { color: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 50;
  transform: translateY(-160%);
  padding: 10px 14px;
  color: var(--white);
  background: var(--forest);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 241, 232, .92);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; width: max-content; font-weight: 850; text-decoration: none; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 4px); align-items: end; gap: 3px; width: 20px; height: 20px; }
.brand-mark i { display: block; background: var(--teal); }
.brand-mark i:nth-child(1) { height: 9px; }
.brand-mark i:nth-child(2) { height: 17px; background: var(--coral); }
.brand-mark i:nth-child(3) { height: 13px; background: var(--blue); }
.site-header nav { display: flex; gap: 24px; }
.site-header nav a { color: var(--ink-2); font-size: .88rem; font-weight: 700; text-decoration: none; }
.site-header nav a:hover { color: var(--teal); }
.local-status { justify-self: end; padding: 6px 10px; border: 1px solid var(--teal); color: var(--teal); font-size: .78rem; font-weight: 800; text-transform: uppercase; }

main { width: 100%; max-width: 100%; overflow-x: hidden; }
.workspace-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, .5fr);
  gap: clamp(36px, 6vw, 100px);
  align-items: end;
  min-height: 580px;
  padding: clamp(72px, 10vw, 150px) 5vw 80px;
  background:
    radial-gradient(circle at 88% 12%, rgba(201, 238, 72, .28), transparent 24%),
    radial-gradient(circle at 10% 90%, rgba(79, 119, 199, .14), transparent 30%);
}
.hero-copy { max-width: 68rem; }
.eyebrow { margin: 0 0 12px; color: var(--teal); font-size: .78rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: break-word; }
h1 { max-width: 68rem; margin: 0; font-size: clamp(2.5rem, 5vw, 4.9rem); line-height: .98; letter-spacing: 0; }
.lede { max-width: 780px; margin: 26px 0 0; color: var(--ink-2); font-size: clamp(1rem, 1.5vw, 1.24rem); }
.hero-actions, .button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.principle-panel { position: relative; padding: 34px; color: var(--white); background: var(--forest); box-shadow: var(--shadow); }
.principle-panel::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(255,255,255,.2); pointer-events: none; }
.principle-panel h2 { margin: 42px 0 12px; font-size: clamp(1.5rem, 2.5vw, 2.25rem); line-height: 1.05; }
.principle-panel p { color: #d5e6e1; }
.principle-index { position: absolute; top: 24px; right: 28px; color: var(--lime); font-weight: 900; }
.plain-list { display: grid; gap: 8px; margin: 24px 0 0; padding: 0; list-style: none; }
.plain-list li { position: relative; padding-left: 18px; font-size: .9rem; }
.plain-list li::before { content: ""; position: absolute; left: 0; top: .62em; width: 7px; height: 7px; background: var(--lime); }

.metric-ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(1400px, 92vw);
  margin: -28px auto 48px;
  color: var(--white);
  background: var(--ink);
  box-shadow: var(--shadow);
}
.metric-ribbon article { min-width: 0; padding: 22px 24px; border-right: 1px solid rgba(255,255,255,.16); }
.metric-ribbon article:last-child { border-right: 0; }
.metric-ribbon span, .metric-ribbon small { display: block; color: #bad0ca; font-size: .75rem; }
.metric-ribbon strong { display: block; margin: 5px 0 2px; color: var(--lime); font-size: clamp(1.4rem, 3vw, 2.25rem); line-height: 1; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 16px;
  width: min(1400px, 92vw);
  margin: 0 auto;
}
.panel { min-width: 0; padding: 26px; border: 1px solid var(--line); background: rgba(255, 253, 248, .88); box-shadow: 0 12px 32px rgba(19, 40, 39, .05); }
.input-panel { grid-column: span 7; }
.method-panel { grid-column: span 5; }
.evidence-panel, .coverage-panel, .regional-panel { grid-column: span 4; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.panel-heading h2 { margin: 0; font-size: clamp(1.3rem, 2vw, 1.9rem); line-height: 1.1; }
.panel label { display: grid; gap: 7px; color: var(--ink-2); font-size: .82rem; font-weight: 760; }
.panel input, .panel select, .panel textarea, .target-card input, .target-card select, .survey-controls input, .survey-controls select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #9aaba6;
  border-radius: 2px;
  color: var(--ink);
  background: var(--white);
}
textarea { resize: vertical; }
.hint { color: #607671; font-weight: 550; }
.aggregate-form { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.span-two { grid-column: span 2; }
.import-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0; }
.import-row span { color: var(--ink-2); font-size: .8rem; }
.file-button { position: relative; display: inline-flex !important; align-items: center; min-height: 42px; padding: 0 14px; border: 1px solid var(--ink); cursor: pointer; }
.file-button input { position: absolute; width: 1px !important; height: 1px; min-height: 0 !important; clip: rect(0 0 0 0); }
.notice { margin: 0 0 18px; padding: 13px; border-left: 4px solid var(--amber); background: #fff5d4; font-size: .84rem; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.source-table-wrap { max-height: 340px; overflow: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
caption { padding: 10px; text-align: left; font-weight: 800; }
th, td { padding: 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--paper-2); }
.table-action { width: 32px; height: 32px; border: 0; color: #a42e24; background: transparent; cursor: pointer; }
.empty-cell { padding: 34px; color: var(--ink-2); text-align: center; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: 2px; font-weight: 820; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease; }
.button:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(19,40,39,.14); }
.button.primary { color: var(--ink); background: var(--lime); border-color: #91ad20; }
.button.secondary { color: var(--ink); background: transparent; border-color: var(--ink); }
.button.dark { width: 100%; color: var(--white); background: var(--forest); }
.button.light { color: var(--ink); background: var(--white); }
.button.danger { color: #7c2019; background: #ffe2dd; border-color: #d35448; }
.button.small { min-height: 36px; padding: 7px 10px; font-size: .78rem; }
.icon-button { flex: 0 0 auto; width: 36px; height: 36px; border: 1px solid var(--ink); border-radius: 50%; background: transparent; font-weight: 900; cursor: pointer; }

fieldset { margin: 16px 0; padding: 0; border: 0; }
legend { margin-bottom: 7px; color: var(--ink-2); font-size: .82rem; font-weight: 760; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: grid; place-items: center; min-height: 42px; color: var(--ink); cursor: pointer; }
.segmented label + label { border-left: 1px solid var(--ink); }
.segmented input:checked + span { color: var(--white); background: var(--teal); }
.range-label { margin: 16px 0; }
input[type="range"] { min-height: 24px; padding: 0; accent-color: var(--teal); }
output { color: var(--teal); font-weight: 900; }
.status-chip { padding: 5px 8px; border: 1px solid var(--teal); color: var(--teal); font-size: .72rem; font-weight: 850; text-transform: uppercase; }

.bar-list, .region-list { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 1fr) 3fr auto; gap: 10px; align-items: center; }
.bar-row span { overflow: hidden; font-size: .78rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: var(--paper-2); }
.bar-track i { display: block; width: var(--width, 0%); height: 100%; background: var(--color, var(--teal)); transition: width .45s ease; }
.bar-row strong { min-width: 32px; font-variant-numeric: tabular-nums; text-align: right; }
.callout { margin-top: 22px; padding: 15px; border-left: 4px solid var(--blue); background: #e6ecfa; color: #213761; font-size: .86rem; }
.control-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.confidence-visual { margin: 34px 0 20px; }
.confidence-track { position: relative; height: 14px; background: linear-gradient(90deg, var(--paper-2), var(--mint)); }
.confidence-track span { position: absolute; left: 0; width: 0; height: 100%; background: rgba(14,110,104,.45); transition: left .35s ease, width .35s ease; }
.confidence-track i { position: absolute; top: -6px; left: 0; width: 4px; height: 26px; background: var(--coral); transition: left .35s ease; }
.confidence-labels { display: flex; justify-content: space-between; gap: 10px; margin-top: 9px; font-size: .74rem; }
.confidence-labels strong { color: var(--teal); }
.coverage-panel > p { color: var(--ink-2); font-size: .84rem; }

.chapter { padding: clamp(110px, 14vw, 200px) 5vw; }
.chapter-intro { max-width: 900px; margin-bottom: 56px; }
.chapter-intro h2, .sticky-title h2, .survey-copy h2 { max-width: 58rem; margin: 0; font-size: clamp(2.2rem, 4.5vw, 4.3rem); line-height: 1; }
.chapter-intro > p:last-child, .sticky-title > p:last-child, .survey-copy > p { max-width: 680px; color: var(--ink-2); font-size: 1.05rem; }
.bias-chapter { color: var(--white); background: var(--forest); }
.bias-chapter .eyebrow { color: var(--lime); }
.bias-chapter .chapter-intro > p:last-child { color: #c9dcd6; }
.bias-layout { display: grid; grid-template-columns: minmax(280px, .7fr) minmax(0, 1.3fr); gap: 16px; }
.bias-layout .panel { color: var(--ink); }
.bias-controls { display: grid; gap: 20px; }
.bias-chart { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; align-items: end; min-height: 260px; padding: 30px 10px 0; border-bottom: 1px solid var(--line); }
.bias-column { display: grid; grid-template-rows: 1fr auto; gap: 10px; align-items: end; height: 220px; }
.bias-column i { display: block; height: var(--height); min-height: 8px; background: var(--color); transition: height .4s ease; }
.bias-column span { min-height: 40px; font-size: .73rem; font-weight: 760; text-align: center; }
.bias-reading { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; margin-top: 24px; }
.bias-reading strong { padding: 7px 10px; color: #622019; background: #ffe2dd; white-space: nowrap; }
.bias-reading p { margin: 0; color: var(--ink-2); }

.target-chapter { background: var(--paper-2); }
.target-grid { display: grid; grid-template-columns: 1.1fr 1.2fr .7fr; gap: 0; border: 1px solid var(--ink); }
.target-card { min-width: 0; min-height: 380px; padding: 34px; border-right: 1px solid var(--ink); }
.target-card:last-child { border-right: 0; }
.target-card label { display: grid; gap: 7px; margin-bottom: 18px; font-size: .82rem; font-weight: 760; }
.dark-card { color: var(--white); background: var(--ink); }
.dark-card input, .dark-card select { border-color: #79908a; }
.result-card { display: flex; flex-direction: column; justify-content: center; background: var(--lime); }
.result-card > span, .survey-card > span { font-size: .78rem; font-weight: 850; text-transform: uppercase; }
.result-card > strong { margin: 8px 0; font-size: clamp(3.4rem, 7vw, 7rem); line-height: .9; }
.result-card h3, .survey-card h3 { font-size: 1.5rem; }
.target-meter { height: 12px; background: rgba(19,40,39,.2); }
.target-meter i { display: block; width: 0; height: 100%; background: var(--forest); transition: width .45s ease; }
.survey-card { display: flex; flex-direction: column; justify-content: end; background: var(--white); }
.text-link { margin-top: 18px; color: var(--teal); font-weight: 850; }

.methodology-chapter { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); gap: 8vw; align-items: start; }
.sticky-title { position: sticky; top: 120px; }
.method-stack { display: grid; gap: 18px; padding-top: 20px; }
.method-card { position: sticky; top: calc(110px + var(--offset, 0px)); min-height: 280px; padding: 40px; border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow); }
.method-card:nth-child(2) { --offset: 18px; background: #e8f1ee; }
.method-card:nth-child(3) { --offset: 36px; background: #edf0f9; }
.method-card:nth-child(4) { --offset: 54px; background: #fff0e9; }
.method-card span { color: var(--teal); font-size: .75rem; font-weight: 900; text-transform: uppercase; }
.method-card h3 { margin: 42px 0 12px; font-size: 1.8rem; }
.method-card p { color: var(--ink-2); }

.operations-chapter { padding-top: 80px; background: var(--forest); }
.operations-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.privacy-panel, .scenarios-panel { background: var(--white); }
.check-list { display: grid; gap: 10px; }
.check-list label { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 11px; border: 1px solid var(--line); }
.check-list input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--teal); }
.scenario-list { display: grid; gap: 10px; min-height: 190px; }
.scenario-item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 12px; border: 1px solid var(--line); }
.scenario-item span { font-size: .8rem; }
.scenario-item button { min-height: 34px; border: 1px solid var(--ink); background: transparent; cursor: pointer; }
.empty-state { color: var(--ink-2); }

.survey-chapter { display: grid; grid-template-columns: 1fr 1fr; gap: 8vw; color: var(--white); background: var(--ink); }
.survey-chapter .eyebrow { color: var(--lime); }
.survey-copy > p { color: #c9dcd6; }
.survey-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 36px; }
.survey-controls label { display: grid; gap: 7px; color: #c9dcd6; font-size: .78rem; font-weight: 750; }
.survey-output { align-self: center; padding: 36px; color: var(--ink); background: var(--white); }
.survey-number { display: grid; margin-bottom: 30px; }
.survey-number span { color: var(--ink-2); font-weight: 750; }
.survey-number strong { color: var(--teal); font-size: clamp(3.5rem, 8vw, 7rem); line-height: 1; }
.survey-output ol { display: grid; gap: 15px; padding-left: 22px; }
.survey-output li { padding-left: 8px; }
.survey-output li strong, .survey-output li span { display: block; }
.survey-output li span { color: var(--ink-2); font-size: .86rem; }

.glossary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.glossary-grid details { min-height: 110px; padding: 22px; border: 1px solid var(--line); background: rgba(255,253,248,.8); }
.glossary-grid summary { font-weight: 850; cursor: pointer; }
.glossary-grid p { color: var(--ink-2); font-size: .88rem; }

footer { display: flex; justify-content: space-between; gap: 40px; padding: 50px 5vw; color: var(--white); background: #0b201e; }
footer p { color: #9eb5af; }
footer a { align-self: center; color: var(--lime); }

dialog { width: min(640px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--ink); color: var(--ink); background: var(--white); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 27, 25, .72); backdrop-filter: blur(4px); }
dialog form { padding: 28px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
dialog textarea { width: 100%; padding: 12px; border: 1px solid #82928e; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1050px) {
  .site-header { grid-template-columns: 1fr auto; }
  .site-header nav { display: none; }
  .workspace-hero { grid-template-columns: 1fr; min-height: auto; }
  .principle-panel { max-width: 660px; }
  .metric-ribbon { grid-template-columns: repeat(2, 1fr); }
  .metric-ribbon article:nth-child(2) { border-right: 0; }
  .metric-ribbon article:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.16); }
  .input-panel, .method-panel { grid-column: span 12; }
  .evidence-panel, .coverage-panel, .regional-panel { grid-column: span 4; }
  .target-grid { grid-template-columns: 1fr 1fr; }
  .target-card { border-bottom: 1px solid var(--ink); }
  .survey-card { grid-column: span 2; min-height: 250px; border-bottom: 0; }
  .methodology-chapter { grid-template-columns: 1fr; }
  .sticky-title { position: static; }
}

@media (max-width: 760px) {
  .site-header { min-height: 62px; padding: 0 18px; }
  .brand span:last-child { font-size: .86rem; }
  .local-status { font-size: .68rem; }
  .workspace-hero { padding: 72px 20px 60px; }
  h1 { font-size: clamp(2.45rem, 13vw, 4rem); }
  .principle-panel { padding: 28px; }
  .metric-ribbon { width: 100%; margin: 0; }
  .metric-ribbon article { padding: 18px; }
  .tool-grid { width: calc(100% - 24px); margin-top: 28px; }
  .input-panel, .method-panel, .evidence-panel, .coverage-panel, .regional-panel { grid-column: span 12; }
  .panel { padding: 20px; }
  .aggregate-form, .control-pair { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .source-table-wrap { overflow-x: auto; }
  table { min-width: 620px; }
  .chapter { padding: 100px 20px; }
  .bias-layout, .operations-grid, .survey-chapter { grid-template-columns: 1fr; }
  .bias-reading { grid-template-columns: 1fr; }
  .target-grid { grid-template-columns: 1fr; }
  .target-card { min-height: auto; border-right: 0; border-bottom: 1px solid var(--ink); }
  .survey-card { grid-column: auto; }
  .method-card { position: static; min-height: 0; padding: 28px; }
  .survey-controls { grid-template-columns: 1fr; }
  .glossary-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; padding: 40px 20px; }
  footer a { align-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
