/* Colour mode (Device, Light or Dark). Dark is the original palette. Device follows the visitor's own setting;
   a choice made in the preview (or kept in this browser) adds .force-light or .force-dark to <html>, see /js/theme.js. */
:root {
  --ink: #0d1117;
  --ink-2: #141a23;
  --line: #2a3340;
  --text: #e6e1d6;
  --muted: #9aa3ad;
  --brass: #c9a96a;
  --brass-dim: #8c7448;
  --brass-hover: #d9bb80;
  --brass-wash: rgba(201, 169, 106, 0.1);
  --danger: #d98b7a;
  --lede: #cfc9bd;
  --prose: #d8d2c6;
  --header-bg: rgba(13, 17, 23, 0.86);
  --overlay: rgba(5, 8, 12, 0.78);
  --shadow: rgba(0, 0, 0, 0.5);
  --serif: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --wrap: 1120px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not(.force-dark) {
    --ink: #f7f3ea; --ink-2: #eee7d9; --line: #d8ccb6; --text: #1a1e25; --muted: #5d636c;
    --brass: #85652a; --brass-dim: #b39966; --brass-hover: #6f5422; --brass-wash: rgba(133, 101, 42, 0.1);
    --danger: #a3432e; --lede: #353a42; --prose: #2a2e35;
    --header-bg: rgba(247, 243, 234, 0.88); --overlay: rgba(40, 34, 24, 0.45); --shadow: rgba(60, 45, 20, 0.18);
    color-scheme: light;
  }
}
:root.force-light {
  --ink: #f7f3ea; --ink-2: #eee7d9; --line: #d8ccb6; --text: #1a1e25; --muted: #5d636c;
  --brass: #85652a; --brass-dim: #b39966; --brass-hover: #6f5422; --brass-wash: rgba(133, 101, 42, 0.1);
  --danger: #a3432e; --lede: #353a42; --prose: #2a2e35;
  --header-bg: rgba(247, 243, 234, 0.88); --overlay: rgba(40, 34, 24, 0.45); --shadow: rgba(60, 45, 20, 0.18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
}
a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--serif); font-size: 22px; letter-spacing: 0.08em; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.nav { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.nav a.plain { color: var(--muted); }
.nav a.plain:hover { color: var(--text); }
.session { display: flex; align-items: center; gap: 12px; min-width: 120px; justify-content: flex-end; font-size: 14px; }
.session .who { color: var(--text); }
.session .placeholder { display: inline-block; width: 100px; height: 14px; background: var(--ink-2); border-radius: 2px; }

/* Buttons */
.btn {
  display: inline-block; font: 500 14px/1 var(--sans); letter-spacing: 0.04em;
  padding: 12px 20px; border-radius: 2px; cursor: pointer;
  border: 1px solid var(--brass); background: var(--brass); color: var(--ink);
}
.btn:hover { background: var(--brass-hover); border-color: var(--brass-hover); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn.ghost { background: transparent; color: var(--brass); }
.btn.ghost:hover { background: var(--brass-wash); }
.textbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.textbtn:hover { color: var(--text); text-decoration: underline; }

/* Type */
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--brass); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(40px, 6vw, 72px); letter-spacing: -0.01em; }
h2 { font-size: clamp(28px, 3.4vw, 40px); }
h3 { font-size: 24px; }
.lede { font-size: 19px; color: var(--lede); max-width: 640px; }
.muted { color: var(--muted); }

/* Hero */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero .wrap { padding-top: 112px; padding-bottom: 112px; position: relative; z-index: 1; }
.hero h1 { max-width: 860px; margin: 18px 0 24px; }
.hero .actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 36px; }
.hero-wave { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; pointer-events: none; }

/* Sections */
section.block { padding: 96px 0; border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 48px; flex-wrap: wrap; }
.section-head p { max-width: 480px; margin: 0; color: var(--muted); }

.principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.principle { background: var(--ink); padding: 36px 32px; }
.principle .num { font-family: var(--mono); color: var(--brass); font-size: 13px; }
.principle h3 { margin: 14px 0 12px; }
.principle p { margin: 0; color: var(--muted); }

/* Field index */
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.field-card { display: flex; flex-direction: column; gap: 14px; background: var(--ink); padding: 34px 32px; color: var(--text); min-height: 220px; transition: background 0.2s; }
.field-card:hover { background: var(--ink-2); text-decoration: none; }
.field-card .top { display: flex; justify-content: space-between; align-items: center; }
.field-card .code { font-family: var(--mono); font-size: 13px; color: var(--brass); letter-spacing: 0.12em; }
.field-card .lock { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.field-card h3 { font-size: 28px; }
.field-card p { margin: 0; color: var(--muted); }
.field-card .go { margin-top: auto; font-size: 14px; color: var(--brass); }
.skeleton { background: var(--ink); padding: 34px 32px; min-height: 220px; }
.skeleton span { display: block; height: 14px; background: var(--ink-2); margin-bottom: 14px; border-radius: 2px; }

/* Access steps */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; counter-reset: s; }
.step { border-top: 1px solid var(--brass-dim); padding-top: 22px; }
.step .num { font-family: var(--mono); font-size: 13px; color: var(--brass); }
.step h3 { margin: 10px 0 8px; font-size: 22px; }
.step p { margin: 0; color: var(--muted); }

/* Footer */
.site-footer { padding: 48px 0 64px; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }

/* Forms */
.panel-page { min-height: calc(100vh - 64px); display: flex; align-items: center; padding: 64px 0; }
.panel { width: 100%; max-width: 460px; margin: 0 auto; border: 1px solid var(--line); background: var(--ink-2); padding: 40px 36px; }
.panel h1 { font-size: 40px; margin: 12px 0 10px; }
.panel p.intro { color: var(--muted); margin: 0 0 28px; }
.panel form { display: grid; gap: 16px; }
.panel label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); letter-spacing: 0.03em; }
.panel input {
  font: 16px var(--sans); color: var(--text); background: var(--ink);
  border: 1px solid var(--line); border-radius: 2px; padding: 12px 14px;
}
.panel input:focus { outline: none; border-color: var(--brass); }
.panel .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel .error { color: var(--danger); font-size: 14px; min-height: 0; margin: 0; }
.panel .error:empty { display: none; }
.panel .switch { margin-top: 22px; font-size: 14px; color: var(--muted); text-align: center; }
.notice { border-left: 2px solid var(--brass); padding: 4px 0 4px 18px; color: var(--lede); }
[hidden] { display: none !important; }

/* Dossier */
.dossier-head { padding: 88px 0 56px; border-bottom: 1px solid var(--line); }
.dossier-head h1 { margin: 16px 0 18px; font-size: clamp(36px, 5vw, 60px); }
.meta { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 28px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.meta b { color: var(--brass); font-weight: 400; }
.dossier-body { padding: 56px 0 96px; }
.prose { max-width: 720px; font-size: 18px; color: var(--prose); }
.prose h2 { font-size: 30px; margin: 48px 0 14px; color: var(--text); }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 12px; }
.prose strong { color: var(--text); font-weight: 600; }
.gate { max-width: 620px; padding: 72px 0 120px; }
.gate h2 { margin-bottom: 14px; }
.gate p { color: var(--muted); }
.gate .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.back { font-size: 14px; color: var(--muted); }

/* Account */
.grants { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.grants li { background: var(--ink); padding: 16px 20px; display: flex; justify-content: space-between; gap: 12px; }

@media (max-width: 860px) {
  .principles, .steps { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .nav a.plain.hide-sm { display: none; }
  .hero .wrap { padding-top: 80px; padding-bottom: 80px; }
  section.block { padding: 72px 0; }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  .panel { padding: 32px 20px; border-left: 0; border-right: 0; }
  .panel .row2 { grid-template-columns: 1fr; }
  .session .who { display: none; }
}
/* Consent popup */
.consent { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--overlay); }
.consent.docked { inset: auto 0 0 0; background: none; padding: 0; }
.consent-box { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--ink-2); border: 1px solid var(--brass-dim); padding: 32px 30px; box-shadow: 0 20px 60px var(--shadow); }
.consent.docked .consent-box { max-width: none; max-height: 60vh; border-width: 1px 0 0; padding: 24px max(24px, calc((100vw - 1072px) / 2)); }
.consent-box h2 { font-size: 30px; margin: 10px 0 12px; }
.consent-box p { color: var(--lede); margin: 0 0 14px; }
.consent-box .small { font-size: 14px; color: var(--muted); }
.consent-check { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; font-size: 15px; cursor: pointer; }
.consent-check input { margin-top: 5px; accent-color: var(--brass); width: 16px; height: 16px; flex: none; }
.consent .details { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 4px; }
.consent-hint { color: var(--danger) !important; font-size: 14px; }
.consent-hint:empty { display: none; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }
.consent-lock, .consent-lock body { overflow: hidden; }
.site-footer .textbtn { font-size: 14px; }
@media (max-width: 520px) {
  .consent-box { padding: 24px 18px; }
  .consent-actions .btn { flex: 1 1 auto; text-align: center; }
}

/* Passwordless login */
.recaptcha-note { margin-top: 28px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.recaptcha-note a { color: inherit; text-decoration: underline; }
.grecaptcha-badge { visibility: hidden; }
.captcha-slot { margin: 6px 0 14px; min-height: 78px; }
.btn.google { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border-color: #dadce0; }
.btn.google:hover { background: #f2f2f2; }
.or { display: flex; align-items: center; gap: 12px; margin: 22px 0 6px; color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line, rgba(255,255,255,.12)); }

/* Light mode: the wave in the hero is drawn in the original brass; keep it faint on paper. */
@media (prefers-color-scheme: light) { :root:not(.force-dark) .hero-wave { opacity: 0.8; } }
:root.force-light .hero-wave { opacity: 0.8; }
.preview-note { border-left: 2px solid var(--brass); padding: 4px 0 4px 18px; color: var(--muted); font-size: 15px; }

/* Odd number of research fields: last card spans the row */
.fields > .field-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
