/* Shared palette. Literal colours belong only to these token blocks.
   The grounds are the depth tints of the TETIS chart (#E6EEE8 shallow … #040F19 abyss);
   coral (#F0785C) is the overprint: only what a person does or chose is drawn in it. */
:root {
  --binding: #0B2436;
  --binding-ink: #E6EEE8;
  --binding-ink-muted: #9DBDBB;
  --ground: #E6EEE8;
  --sheet: #F8FBF8;
  --sheet-2: #D9E5DE;
  --plate: #EEF3EF;
  --ink: #071928;
  --ink-2: #1D4050;
  --ink-3: #3F5F6A;
  --rule: #BFD0C9;
  --field-border: #5C7F86;
  --action: #F0785C;
  --action-hover: #E5674A;
  --on-action: #040F19;
  --track: #CF4A2A;
  --link: #1F5A66;
  --visited: #5B3A80;
  --focus: #1C6FB5;
  --focus-on-binding: #E6EEE8;
  --pencil: #F5E3A3;
  --pencil-ink: #071928;
  --relief: #A6CAC5;
  --ok: #1E6A3B;
  --ok-bg: #E0F0E3;
  --warn: #7A4E00;
  --warn-bg: #FBEFD3;
  --bad: #A01441;
  --bad-bg: #FBE6EC;
  --info: #1D4050;
  --info-bg: #D9E5DE;
  --number: #55348C;
  --number-bg: #F1EAFB;
  --species: #7A4310;
  --species-bg: #FCEBDD;
  --text-soft: #1D4050;
  --heading: #071928;
  --muted: #3F5F6A;
  --teal: #2F6873;
  --teal-deep: #1A4859;
  --page: #E6EEE8;
  --paper: #F8FBF8;
  --surface: #D9E5DE;
  --line: #5C7F86;
  --button-ink: #FFFFFF;
  --badge: #7A4E00;
  --error: #A01441;
  --error-bg: #FBE6EC;
  --warning: #7A4E00;
  --warning-bg: #FBEFD3;
  --success: #1E6A3B;
  --success-bg: #E0F0E3;
  --neutral: #1D4050;
  --neutral-bg: #D9E5DE;
  --page-top: #E6EEE8;
  --page-mid: #E6EEE8;
  --page-bottom: #E6EEE8;
  --portal-top: #E6EEE8;
  --portal-mid: #E6EEE8;
  --portal-bottom: #E6EEE8;
  --portal-glow: #E6EEE8;
  --teal-soft: #D5E6E1;
  --error-line: #A01441;
  --warning-line: #8A5D00;
  --success-line: #2F7A4A;
  --disabled-ink: #3F5F6A;
  --disabled-bg: #D9E5DE;
  --number-line: #8A62AD;
  --number-shared: #3E2373;
  --number-shared-bg: #DCCBF3;
  --phrase-bg: #E0EBF3;
  --phrase-line: #527FA8;
  --page-glow: rgba(230, 238, 232, 0);
  --shadow-color: rgba(4, 15, 25, .18);
  --shadow-overlay: 0 8px 24px rgba(4, 15, 25, .18), 0 1px 2px rgba(4, 15, 25, .12);
  --grid: rgba(0, 0, 0, 0);
  --ring-aqua: rgba(0, 0, 0, 0);
  --ring-sand: rgba(0, 0, 0, 0);
  --mask: #000000;
  --shadow-active: inset 0 1px 0 rgba(0, 0, 0, .12);
}
:root {
  color-scheme: light dark;
  color: var(--ink);
  background: var(--ground);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Piazzolla", "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", "PT Serif", "DejaVu Serif", Georgia, serif;
  --font-source: "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", "PT Serif", "DejaVu Serif", Georgia, serif;
  --font-id: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-read: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --r-sm: 1px;
  --r-md: 2px;
  --r-lg: 3px;
  --shadow: var(--shadow-overlay);
  --aqua: var(--teal);
  --aqua-strong: var(--teal-deep);
  --sand: var(--warning);
  --panel: var(--paper);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  --binding: #040F19;
  --binding-ink: #E6EEE8;
  --binding-ink-muted: #8FB0B1;
  --ground: #071928;
  --sheet: #0B2436;
  --sheet-2: #113347;
  --plate: #0E2B3D;
  --ink: #D3E0DC;
  --ink-2: #B4CBC8;
  --ink-3: #8FB0B1;
  --rule: #1A4859;
  --field-border: #6A9BA0;
  --action: #F0785C;
  --action-hover: #F7937B;
  --on-action: #040F19;
  --track: #F0785C;
  --link: #93C4BF;
  --visited: #CDB3F0;
  --focus: #7FB8F0;
  --focus-on-binding: #E6EEE8;
  --pencil: #5A4A12;
  --pencil-ink: #F7EBC0;
  --relief: #2F6873;
  --ok: #8DD6A5;
  --ok-bg: #0F3327;
  --warn: #F0C76E;
  --warn-bg: #3A2C10;
  --bad: #FF9DB5;
  --bad-bg: #421A2B;
  --info: #B4CBC8;
  --info-bg: #113347;
  --number: #DCC6FF;
  --number-bg: #33274A;
  --species: #FFCFA0;
  --species-bg: #40301D;
  --text-soft: #B4CBC8;
  --heading: #E6EEE8;
  --muted: #8FB0B1;
  --teal: #7FB0AD;
  --teal-deep: #A5CBC6;
  --page: #071928;
  --paper: #0B2436;
  --surface: #113347;
  --line: #6A9BA0;
  --button-ink: #040F19;
  --badge: #F0C76E;
  --error: #FF9DB5;
  --error-bg: #421A2B;
  --warning: #F0C76E;
  --warning-bg: #3A2C10;
  --success: #8DD6A5;
  --success-bg: #0F3327;
  --neutral: #B4CBC8;
  --neutral-bg: #113347;
  --page-top: #071928;
  --page-mid: #071928;
  --page-bottom: #071928;
  --portal-top: #071928;
  --portal-mid: #071928;
  --portal-bottom: #071928;
  --portal-glow: #071928;
  --teal-soft: #16404A;
  --error-line: #EC8AA5;
  --warning-line: #CDA657;
  --success-line: #69C78C;
  --disabled-ink: #8FB0B1;
  --disabled-bg: #0E2B3D;
  --number-line: #BE96E6;
  --number-shared: #EFE1FF;
  --number-shared-bg: #523E70;
  --phrase-bg: #1A3C5A;
  --phrase-line: #7DAECC;
  --page-glow: rgba(7, 25, 40, 0);
  --shadow-color: rgba(0, 0, 0, .5);
  --shadow-overlay: 0 8px 24px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4);
  --grid: rgba(0, 0, 0, 0);
  --ring-aqua: rgba(0, 0, 0, 0);
  --ring-sand: rgba(0, 0, 0, 0);
  --mask: #000000;
  --shadow-active: inset 0 1px 0 rgba(0, 0, 0, .12);
}
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --binding: #040F19;
    --binding-ink: #E6EEE8;
    --binding-ink-muted: #8FB0B1;
    --ground: #071928;
    --sheet: #0B2436;
    --sheet-2: #113347;
    --plate: #0E2B3D;
    --ink: #D3E0DC;
    --ink-2: #B4CBC8;
    --ink-3: #8FB0B1;
    --rule: #1A4859;
    --field-border: #6A9BA0;
    --action: #F0785C;
    --action-hover: #F7937B;
    --on-action: #040F19;
    --track: #F0785C;
    --link: #93C4BF;
    --visited: #CDB3F0;
    --focus: #7FB8F0;
    --focus-on-binding: #E6EEE8;
    --pencil: #5A4A12;
    --pencil-ink: #F7EBC0;
    --relief: #2F6873;
    --ok: #8DD6A5;
    --ok-bg: #0F3327;
    --warn: #F0C76E;
    --warn-bg: #3A2C10;
    --bad: #FF9DB5;
    --bad-bg: #421A2B;
    --info: #B4CBC8;
    --info-bg: #113347;
    --number: #DCC6FF;
    --number-bg: #33274A;
    --species: #FFCFA0;
    --species-bg: #40301D;
    --text-soft: #B4CBC8;
    --heading: #E6EEE8;
    --muted: #8FB0B1;
    --teal: #7FB0AD;
    --teal-deep: #A5CBC6;
    --page: #071928;
    --paper: #0B2436;
    --surface: #113347;
    --line: #6A9BA0;
    --button-ink: #040F19;
    --badge: #F0C76E;
    --error: #FF9DB5;
    --error-bg: #421A2B;
    --warning: #F0C76E;
    --warning-bg: #3A2C10;
    --success: #8DD6A5;
    --success-bg: #0F3327;
    --neutral: #B4CBC8;
    --neutral-bg: #113347;
    --page-top: #071928;
    --page-mid: #071928;
    --page-bottom: #071928;
    --portal-top: #071928;
    --portal-mid: #071928;
    --portal-bottom: #071928;
    --portal-glow: #071928;
    --teal-soft: #16404A;
    --error-line: #EC8AA5;
    --warning-line: #CDA657;
    --success-line: #69C78C;
    --disabled-ink: #8FB0B1;
    --disabled-bg: #0E2B3D;
    --number-line: #BE96E6;
    --number-shared: #EFE1FF;
    --number-shared-bg: #523E70;
    --phrase-bg: #1A3C5A;
    --phrase-line: #7DAECC;
    --page-glow: rgba(7, 25, 40, 0);
    --shadow-color: rgba(0, 0, 0, .5);
    --shadow-overlay: 0 8px 24px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4);
    --grid: rgba(0, 0, 0, 0);
    --ring-aqua: rgba(0, 0, 0, 0);
    --ring-sand: rgba(0, 0, 0, 0);
    --mask: #000000;
    --shadow-active: inset 0 1px 0 rgba(0, 0, 0, .12);
  }

  :root:not([data-theme="light"]) { color-scheme: dark; }
}

/* Piazzolla (SIL OFL 1.1, PIAZZOLLA-LICENSE.txt beside the files) sets the wordmark, titles and heads.
   Public portal paths: the login page needs them, and the offline evidence kit never asks for them. */
@font-face {
  font-family: "Piazzolla"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/portal/assets/piazzolla-cyrillic-opsz-normal.9996f22ac1.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Piazzolla"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/portal/assets/piazzolla-latin-opsz-normal.68a923967d.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: "Piazzolla"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url(/portal/assets/piazzolla-cyrillic-wght-italic.afa0f3f09a.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Piazzolla"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url(/portal/assets/piazzolla-latin-wght-italic.e9e5b900ad.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

/* Native controls follow the effective theme; source PDFs keep their own colours. */
body { color: var(--ink); background: var(--ground); font: 400 var(--fs-md)/1.45 var(--font-ui); }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
/* A link under the pointer gets its track line: the underline is drawn in coral. */
a:hover { text-decoration: underline; text-decoration-color: var(--track); }
.source-link:visited, .publication-link:visited, .register__title:visited,
.register__title a:visited, .plate__open:visited { color: var(--visited); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--pencil); color: var(--pencil-ink); }
input, progress { accent-color: var(--link); }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
code, pre, kbd { color: var(--ink); background: var(--sheet-2); }
mark { color: var(--pencil-ink); background: var(--pencil); }
progress { color: var(--link); background: var(--sheet-2); }
progress::-webkit-progress-bar { background: var(--sheet-2); }
progress::-webkit-progress-value { background: var(--link); }
progress::-moz-progress-bar { background: var(--link); }
/* A disabled control is quieter than any live one: muted ink, the plate tint, a hairline edge. */
button:disabled, input:disabled, select:disabled, textarea:disabled {
  color: var(--disabled-ink) !important;
  background: var(--disabled-bg) !important;
  border-color: var(--rule) !important;
  opacity: 1 !important;
  cursor: not-allowed;
}
.theme-menu { position: relative; width: max-content; margin: 0 0 0 auto; flex: none; }
.theme-button, .theme-option {
  font: 400 var(--fs-sm)/1.45 var(--font-ui);
  letter-spacing: normal;
  cursor: pointer;
}
.theme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  width: 40px;
  min-height: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--field-border);
  border-radius: var(--r-md);
  background: var(--sheet);
  color: var(--ink);
}
.theme-button:hover, .theme-option:hover, .theme-option:focus-visible { background: var(--sheet-2); }
.theme-icon, .theme-check {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-options {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-width: min(220px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  padding: 4px;
  border: 1px solid var(--field-border);
  border-radius: var(--r-lg);
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
}
.theme-options[hidden] { display: none; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.theme-label { flex: 1; white-space: nowrap; }
.theme-check { visibility: hidden; color: var(--track); }
.theme-option[aria-checked="true"] .theme-check { visibility: visible; }
.theme-bar { display: flex; margin-bottom: 14px; }
.app-bar .theme-button {
  width: 36px;
  min-height: 36px;
  height: 36px;
  border-color: var(--binding-ink-muted);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--binding-ink);
}
.app-bar .theme-button:hover { border-color: var(--binding-ink); }
@media (max-width: 600px) {
  .theme-option { min-height: 44px; }
  .app-bar .theme-menu .theme-button { min-width: 44px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .theme-button, .theme-option, .theme-options { transition-duration: 0ms; animation: none; }
}
