/* Shared primitives for the three concepts. Page-specific CSS lives with each app. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-ui); font-size: var(--t-md); line-height: 1.55; color: var(--ink);
  background: var(--paper); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01'; text-rendering: optimizeLegibility; min-height: 100vh;
}
img, svg, canvas, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--G-soft); color: var(--ink); }
[hidden] { display: none !important; }

/* graph-paper ground, used by every app shell */
.paper-grid {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px;
}

/* type */
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -.02em; line-height: .98; }
.display em, .serif-em { font-style: italic; }
.h1 { font-family: var(--font-display); font-weight: 400; font-size: var(--t-4xl); line-height: 1.02; letter-spacing: -.015em; }
.h2 { font-family: var(--font-display); font-weight: 400; font-size: var(--t-3xl); line-height: 1.05; letter-spacing: -.01em; }
.h3 { font-size: var(--t-xl); font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.h4 { font-size: var(--t-lg); font-weight: 600; letter-spacing: -.005em; line-height: 1.3; }
.lede { font-size: var(--t-lg); color: var(--ink-2); line-height: 1.55; max-width: 60ch; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); }
.mono { font-family: var(--font-mono); font-feature-settings: normal; }
.label {                                   /* mono micro-label, the "instrument" voice */
  font-family: var(--font-mono); font-size: var(--t-2xs); font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.num { font-variant-numeric: tabular-nums; }

/* layout */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.stack > * + * { margin-top: var(--stack, var(--s-4)); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.spacer { flex: 1; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 999; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-4); border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: var(--t-sm); font-weight: 600; letter-spacing: -.005em; white-space: nowrap; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent-btn); color: var(--accent-on); }
.btn-primary:hover { box-shadow: 0 0 0 4px var(--accent-soft); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { box-shadow: 0 0 0 4px var(--accent-soft); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--card); border-color: var(--ink-3); }
.btn-quiet { background: transparent; color: var(--ink-2); padding-inline: var(--s-3); }
.btn-quiet:hover { color: var(--ink); background: var(--accent-soft); }
.btn-lg { height: 50px; padding: 0 var(--s-6); font-size: var(--t-md); border-radius: var(--r-md); }
.btn-sm { height: 32px; padding: 0 var(--s-3); font-size: var(--t-xs); }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }

/* fields */
.field {
  display: flex; align-items: center; gap: var(--s-2); height: 42px; padding: 0 var(--s-3);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field:focus-within { border-color: var(--ink-3); box-shadow: 0 0 0 4px var(--accent-soft); }
.field input, .field select { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: var(--t-md); }
.field input::placeholder { color: var(--ink-3); }

/* surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-flat { background: var(--card-2); border: 1px solid var(--line-2); border-radius: var(--r-md); }
.rule { height: 1px; background: var(--line); border: 0; }

/* chips + pills */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--card);
  font-size: var(--t-xs); font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
button.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: var(--t-2xs); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-risk { background: var(--risk-soft); color: var(--risk); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-mute { background: var(--accent-soft); color: var(--ink-2); }

/* base tiles — the signature element: a nucleotide as a small coloured block */
.base {
  display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 4px;
  font-family: var(--font-mono); font-weight: 500; font-size: .82em; line-height: 1; color: #fff;
  background: var(--ink-3); vertical-align: middle;
}
/* A/C/T use the deeper "-text" shades so the letter clears AA in light (white on #157041 / #1d4fc4 /
   #b4262d) and in dark (near-black on the lighter shades); G stays amber with a dark letter. */
.base[data-b="A"] { background: var(--A-text); } .base[data-b="C"] { background: var(--C-text); }
.base[data-b="G"] { background: var(--G); color: #1a1300; } .base[data-b="T"] { background: var(--T-text); }
:root[data-theme="dark"] .base:not([data-b="G"]) { color: #06100a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .base:not([data-b="G"]) { color: #06100a; } }
.genotype { display: inline-flex; gap: 3px; }

/* evidence meter: 4 cells, filled = strength (data-level="1..4") */
.evidence { display: inline-flex; gap: 2px; vertical-align: middle; }
.evidence i { width: 6px; height: 12px; border-radius: 1.5px; background: var(--line); }
.evidence[data-level="1"] i:nth-child(-n+1),
.evidence[data-level="2"] i:nth-child(-n+2),
.evidence[data-level="3"] i:nth-child(-n+3),
.evidence[data-level="4"] i:nth-child(-n+4) { background: var(--ink-2); }

/* kbd */
kbd { font-family: var(--font-mono); font-size: var(--t-2xs); padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; color: var(--ink-2); background: var(--card); }

/* toast */
.toast-host { position: fixed; z-index: 900; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r-md); font-size: var(--t-sm); box-shadow: var(--shadow-2); animation: toast-in .24s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* theme toggle (theme.js wires any [data-theme-toggle]) */
.theme-toggle { width: 40px; height: 40px; border-radius: var(--r-pill); display: grid; place-items: center; color: var(--ink-2); border: 1px solid var(--line); background: var(--card); }
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.theme-toggle svg { width: 16px; height: 16px; }

/* wordmark: serif name + four base ticks */
.wordmark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.wordmark .ticks { display: grid; grid-template-columns: repeat(2, 7px); gap: 2px; }
.wordmark .ticks i { width: 7px; height: 7px; border-radius: 1.5px; }
.wordmark .ticks i:nth-child(1) { background: var(--A); } .wordmark .ticks i:nth-child(2) { background: var(--C); }
.wordmark .ticks i:nth-child(3) { background: var(--G); } .wordmark .ticks i:nth-child(4) { background: var(--T); }
.wordmark b { font-family: var(--font-display); font-weight: 400; font-size: 25px; letter-spacing: -.01em; line-height: 1; }
.wordmark small { font-family: var(--font-mono); font-size: var(--t-2xs); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding-left: 8px; border-left: 1px solid var(--line); }

/* concept ribbon — every page is a demo, say so once, quietly */
.concept-flag { font-family: var(--font-mono); font-size: var(--t-2xs); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--r-pill); padding: 3px 10px; white-space: nowrap; }

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