/* Zubair Ahmed — portfolio/blog. Shared tokens + components.
   Direction: six selectable worlds (the `[data-theme]` blocks at the end of
   this file). Tokens only — no raw colour outside a `[data-theme]` block.
   The admin picks one theme; every visitor sees it. */
:root {
  /* Type scale, spacing and layout — theme-independent. A theme overrides the
     scale only when its world demands a different one (see the theme blocks,
     which come last so their overrides win at equal specificity). */
  --fs-h1: clamp(36px, 5vw + 8px, 68px);
  --fs-h2: clamp(28px, 3.2vw + 8px, 44px);
  --fs-h3: 22px;
  --fs-lead: clamp(17px, 4.6vw, 19px);
  --fs-body: 16px;
  --fs-meta: 13px;

  --gap-xs: 8px;
  --gap-sm: 12px;
  --gap-md: 20px;
  --gap-lg: 32px;
  --gap-xl: clamp(36px, 6vw, 56px);
  --gap-2xl: clamp(64px, 9vw, 96px);
  --container: 1120px;
  --gutter: 32px;
}

/* Derived tokens resolve per scope, so a subtree carrying its own data-theme
   (the admin theme swatches) recomputes them from its own --accent/--fg. */
[data-theme] {
  --accent-soft: color-mix(in oklch, var(--accent) 14%, transparent);
  --fg-soft:     color-mix(in oklch, var(--fg) 6%, transparent);
  --border-strong: color-mix(in oklch, var(--muted) 70%, var(--border));
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-size: var(--bg-size);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(48px, 8vw, var(--gap-2xl)); }
.section + .section { border-top: 1px solid var(--border); }
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap-md); }
.row { display: flex; align-items: center; gap: var(--gap-md); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-md); }
.row-between .meta { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 640px) { .row-between { flex-wrap: wrap; } }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-md); }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--gap-xl); align-items: start; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: var(--gap-xl); align-items: start; }
@media (max-width: 920px) {
  .grid-2, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.h1, h1 { font-family: var(--font-display); font-size: var(--fs-h1); line-height: 1.05; letter-spacing: -0.02em; margin: 0; }
.h2, h2 { font-family: var(--font-display); font-size: var(--fs-h2); line-height: 1.1; letter-spacing: -0.015em; margin: 0; }
.h3, h3 { font-size: var(--fs-h3); font-weight: 600; line-height: 1.3; letter-spacing: -0.005em; margin: 0; }
.lead   { font-size: var(--fs-lead); line-height: 1.55; color: var(--muted); max-width: 60ch; margin: 0; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--gap-md);
}
.meta { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ─── nav / chrome ──────────────────────────────────────────────── */
.topnav { position: sticky; top: 0; z-index: 30; background: color-mix(in oklch, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topnav-inner { display: flex; align-items: center; gap: var(--gap-md); padding-block: 14px; }
.topnav .logo { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.topnav nav { display: flex; align-items: center; flex: 1; gap: var(--gap-lg); min-width: 0; }
.nav-links { display: flex; align-items: center; gap: var(--gap-lg); margin-inline: auto; }
.nav-links a { font-size: 14px; color: var(--muted); }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--fg); }
.nav-auth { display: flex; align-items: center; gap: var(--gap-sm); }
.topnav .navtools { display: flex; align-items: center; gap: var(--gap-sm); }
.nav-toggle { display: none; }
.icon-close { display: none; }
.nav-open .icon-menu { display: none; }
.nav-open .icon-close { display: block; }
.pagefoot { padding-block: var(--gap-xl); color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }
.pagefoot .row-between { flex-wrap: wrap; gap: var(--gap-md); }
.pagefoot a:hover { color: var(--fg); }
.pagefoot .meta { white-space: normal; flex-shrink: 1; }

@media (max-width: 720px) {
  .topnav nav { position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: var(--gap-xs) var(--gutter) var(--gap-lg);
    transform: translateY(-8px); opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; }
  .topnav.nav-open nav { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-links { flex-direction: column; align-items: stretch; gap: 0; margin: 0; }
  .nav-links a { display: flex; align-items: center; min-height: 44px; font-size: 16px; }
  .nav-links a + a { border-top: 1px solid var(--border); }
  .nav-auth { margin-top: var(--gap-sm); padding-top: var(--gap-md); border-top: 1px solid var(--border); gap: var(--gap-md); }
  .nav-auth .btn { min-height: 44px; padding-inline: 18px; font-size: 14px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
    border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--fg); }
  .nav-toggle:hover { border-color: var(--fg); }
}

/* ─── buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 85%, var(--fg)); border-color: color-mix(in oklch, var(--accent) 85%, var(--fg)); }
.btn-secondary { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--fg); }
.btn-ghost { background: transparent; color: var(--fg); border-color: transparent; padding-inline: 8px; }
.btn-ghost:hover { color: var(--accent); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-arrow::after { content: '→'; transition: transform 0.15s ease; }
.btn-arrow:hover::after { transform: translateX(2px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ─── card / surface ────────────────────────────────────────────── */
@media (pointer: coarse) { .nav-toggle { width: 44px; height: 44px; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; }
.card-flat { background: transparent; border: 0; padding: 0; }
.card-rule { background: transparent; border: 0; border-top: 1px solid var(--fg); padding: 24px 0 0; border-radius: 0; }

.feature .feature-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; color: var(--accent); margin-bottom: var(--gap-md); }
.feature .feature-mark svg { width: 18px; height: 18px; }
.feature h3 { margin-bottom: 6px; }
.feature p  { margin: 0; color: var(--muted); font-size: 15px; }

.quote { font-family: var(--font-display); font-size: clamp(22px, 2.4vw, 30px); line-height: 1.32; letter-spacing: -0.01em; max-width: 30ch; }
.quote-author { color: var(--muted); font-size: 14px; margin-top: var(--gap-md); }
.quote-mark { font-family: var(--font-display); font-size: 120px; line-height: 0.7; color: var(--accent); opacity: 0.18; margin-bottom: -22px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; background: var(--pill-bg); border: 1px solid var(--pill-border); color: var(--accent); border-radius: var(--pill-radius); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.tag { display: inline-flex; align-items: center; padding: 4px 10px; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--pill-radius); font-size: 12px; }
.tag svg { width: 14px; height: 14px; flex: none; stroke-width: 1.6; }
.tag-icon { gap: 7px; padding: 5px 12px 5px 10px; }
a.tag-icon { color: var(--fg); transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease; }
a.tag-icon:hover { border-color: var(--fg); background: var(--fg-soft); }
a.tag-icon:hover svg { color: var(--accent); }
a.tag-icon:active { transform: translateY(1px); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .field-label { font-size: 13px; color: var(--muted); }
.input, .textarea, select.input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--fg); font: inherit; font-size: 15px;
}
.input:focus, .textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; font-family: var(--font-body); }
.field-error { font-size: 12px; color: var(--accent); min-height: 0; margin: 0; }
.stack > .field-error:empty { margin: 0; }

.ph-img { background: linear-gradient(135deg, var(--accent-soft), var(--fg-soft)), var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); aspect-ratio: 16 / 10; display: grid; place-items: center; color: var(--muted); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; overflow: hidden; }
.ph-img img { width: 100%; height: 100%; object-fit: cover; }
.ph-img.square { aspect-ratio: 1 / 1; }
.ph-img.portrait { aspect-ratio: 3 / 4; }
.ph-img.wide { aspect-ratio: 16 / 9; }
.hero-media { position: relative; }
.hero-media .btn { position: absolute; bottom: 14px; right: 14px; }
@media (max-width: 920px) { .hero-media.is-empty { display: none; } }

.rule { border: 0; border-top: 1px solid var(--border); margin: 0; }
.rule-strong { border: 0; border-top: 1px solid var(--fg); margin: 0; }

.hero { padding-block: clamp(64px, 10vw, 128px); }
.hero-center { text-align: center; max-width: 720px; margin-inline: auto; }
.hero-center .lead { margin-inline: auto; }
.hero h1 { margin-bottom: var(--gap-md); }
.hero .lead { margin-bottom: var(--gap-lg); }
.hero-cta { display: inline-flex; gap: var(--gap-sm); flex-wrap: wrap; }
.hero-center .hero-cta { justify-content: center; }
.hero-split { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--gap-2xl); align-items: center; }
@media (max-width: 920px) { .hero-split { grid-template-columns: 1fr; } }

.log-row-btn { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; text-align: left; }
.log-row { display: grid; grid-template-columns: 120px 1fr 100px; gap: var(--gap-lg); padding: 22px 0; border-top: 1px solid var(--border); align-items: baseline; }
.log-row-btn:hover h3 { color: var(--accent); }
.log-row-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.log-row-btn .dek { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.log-row .meta { color: var(--muted); }
.log-row h3 { font-size: 19px; }
.log-row .pull { text-align: right; }
@media (max-width: 640px) { .log-row { grid-template-columns: 1fr; gap: 6px; } .log-row .pull { text-align: left; } }

/* ─── timeline (experience) ─────────────────────────────────────── */
.timeline { border-top: 1px solid var(--border); }
.timeline-item { display: grid; grid-template-columns: 200px 1fr; gap: var(--gap-lg); padding: var(--gap-xl) 0; border-bottom: 1px solid var(--border); }
.timeline-item .meta { line-height: 1.6; }
.timeline-item .meta p { margin: 0; }
.timeline-item .role { margin-bottom: 4px; color: var(--fg); font-family: var(--font-body); }
.timeline-item .meta p.org { color: var(--muted); font-size: 14px; margin-top: 2px; margin-bottom: var(--gap-sm); }
.timeline-item ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 15px; }
.timeline-item ul li + li { margin-top: 8px; }
.timeline-item ul li::marker { color: var(--accent); }
@media (max-width: 720px) { .timeline-item { grid-template-columns: 1fr; gap: var(--gap-sm); } }

/* ─── skills chips ──────────────────────────────────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* ─── modal / dialog ────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: color-mix(in oklch, var(--fg) 45%, transparent); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; padding: var(--gutter); z-index: 100; }
.modal-overlay.open { display: flex; }
.modal { width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: 0 24px 60px color-mix(in oklch, var(--fg) 18%, transparent); }
.modal.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap-md); margin-bottom: var(--gap-lg); }
.modal-close { background: transparent; border: 0; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { color: var(--fg); background: var(--fg-soft); }

/* ─── auth gate (journal) ───────────────────────────────────────── */
.gate { max-width: 420px; margin: 0 auto; text-align: center; }
.gate .gate-mark { width: 44px; height: 44px; margin: 0 auto var(--gap-lg); border: 1px solid var(--border); border-radius: 12px; display: grid; place-items: center; color: var(--fg); }

/* ─── journal entry ─────────────────────────────────────────────── */
.entry { padding: var(--gap-lg) 0; border-top: 1px solid var(--border); }
.entry:first-child { border-top: 0; }
.entry-body { color: var(--fg); margin-top: 10px; white-space: pre-wrap; }
.entry-body p { margin: 0 0 12px; }
.entry-body .rich-text { max-width: 68ch; }

.admin-actions { margin-top: var(--gap-sm); gap: var(--gap-xs); flex-wrap: wrap; }
.btn-ghost.danger { color: var(--accent); }
.entry .dek { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.post-body { margin: 0 0 22px calc(120px + var(--gap-lg)); max-width: 68ch; }
@media (max-width: 640px) { .post-body { margin-left: 0; } }

/* ─── rich text (reader prose + editor surface) ─────────────────── */
.rich-text, .rich-text-editor .ql-editor {
  white-space: normal;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.rich-text p, .rich-text-editor .ql-editor p { margin: 0 0 12px; }
.rich-text > :last-child, .rich-text-editor .ql-editor > :last-child { margin-bottom: 0; }
.rich-text h2, .rich-text-editor .ql-editor h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: var(--gap-lg) 0 12px;
}
.rich-text h3, .rich-text-editor .ql-editor h3 { font-size: 18px; font-weight: 600; line-height: 1.35; margin: var(--gap-md) 0 8px; }
.rich-text > h2:first-child, .rich-text > h3:first-child,
.rich-text-editor .ql-editor > h2:first-child, .rich-text-editor .ql-editor > h3:first-child { margin-top: 0; }
.rich-text ul, .rich-text ol { margin: 0 0 12px; padding-left: 22px; }
.rich-text li + li { margin-top: 6px; }
.rich-text li::marker { color: var(--accent); }
.rich-text blockquote, .rich-text-editor .ql-editor blockquote {
  margin: 0 0 12px;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--border-strong);
  color: var(--muted);
}
.rich-text a, .rich-text-editor .ql-editor a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.rich-text s, .rich-text strike, .rich-text-editor .ql-editor s { color: var(--muted); }

/* ─── rich text editor ──────────────────────────────────────────── */
/* The editor is a field: structural border at rest, accent border plus an
   accent-soft outline on focus, like every other input in the system. */
.rich-text-editor { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.rich-text-editor:has(.ql-editor:focus) { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.rich-text-editor .rich-text-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.rich-text-editor .rich-text-group { display: flex; align-items: center; gap: 4px; }
.rich-text-editor .rich-text-group + .rich-text-group { padding-left: 8px; border-left: 1px solid var(--border); }
.rich-text-editor .rich-text-btn,
.rich-text-editor select.rich-text-select { min-height: 40px; }
@media (pointer: coarse) {
  .rich-text-editor .rich-text-btn,
  .rich-text-editor select.rich-text-select { min-height: 44px; }
}
.rich-text-editor .rich-text-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; padding: 0 9px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  color: var(--fg); font-size: 13px;
}
.rich-text-editor .rich-text-btn:hover { color: var(--accent); }
.rich-text-editor .rich-text-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.rich-text-editor .rich-text-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.rich-text-editor .rich-text-btn svg { width: 16px; height: 16px; }
/* Block style reads as a field: authored caret, no platform chrome. */
.rich-text-editor .rich-text-block { position: relative; display: inline-flex; align-items: center; }
.rich-text-editor select.rich-text-select {
  appearance: none; -webkit-appearance: none;
  min-width: 132px; padding: 0 30px 0 12px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: inherit; font-size: 13px;
}
.rich-text-editor select.rich-text-select:hover { border-color: var(--fg); }
.rich-text-editor select.rich-text-select:focus { outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent); }
.rich-text-editor select.rich-text-select option { background: var(--surface); color: var(--fg); }
.rich-text-editor .rich-text-caret { position: absolute; right: 9px; width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
.rich-text-editor .rich-text-link-panel { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); background: var(--fg-soft); }
.rich-text-editor .rich-text-link-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; }
.rich-text-editor .rich-text-link-field label { font-size: var(--fs-meta); color: var(--muted); }
.rich-text-editor .rich-text-link-input { width: 100%; min-height: 40px; padding: 0 12px; background: var(--surface); color: var(--fg); border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; font-size: 14px; }
.rich-text-editor .rich-text-link-input:focus { outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent); }
.rich-text-editor .rich-text-link-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rich-text-editor .rich-text-link-actions .rich-text-btn { border-color: var(--border); font-size: 13px; }
.rich-text-editor .rich-text-link-actions .rich-text-btn:hover { border-color: var(--fg); }
.rich-text-editor .rich-text-link-error { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--accent); }
.rich-text-editor .ql-container { height: auto; font-family: var(--font-body); font-size: var(--fs-body); }
.rich-text-editor .ql-editor { height: auto; overflow: visible; min-height: 220px; padding: 14px; outline: none; }
.rich-text-editor .ql-editor.ql-blank::before { left: 14px; right: 14px; color: var(--muted); font-style: normal; }
.rich-text-editor.is-disabled { opacity: 0.6; }

@media (max-width: 640px) {
  .modal-overlay.modal-writing { padding: 12px; }
  .modal-overlay.modal-writing .modal { padding: 16px; }
}

/* ─── auth pill in nav ──────────────────────────────────────────── */
.session-pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.session-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.empty-state { text-align: center; padding: var(--gap-2xl) 0; color: var(--muted); }
.empty-state h3 { color: var(--fg); margin-bottom: 8px; }

[hidden] { display: none !important; }

.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 (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .btn-arrow::after, .topnav nav, a.tag-icon { transition: none; }
}

/* ─── themes ────────────────────────────────────────────────────────
   One block per selectable world. Each block sets the full contract —
   colours, three font stacks, both radii, the three pill tokens, the page
   background layer and color-scheme — because the admin swatches render on
   a subtree carrying their own `data-theme` and would otherwise inherit
   whatever the page is using. Token-only rules are `[data-theme=…]`;
   page-only signature rules add an `html` prefix. These blocks come last so
   their scale overrides beat `:root` at equal specificity. */

/* monocle — the incumbent editorial world. WORLD: a printed critical
   edition (cream paper, serif display, terracotta ink). SIGNATURE: none;
   the paper-and-serif pairing is the whole idea. RISK: bolting a device on
   turns restraint into costume — palette and type only. */
[data-theme="monocle"] {
  --bg:      oklch(98% 0.004 95);
  --surface: oklch(100% 0.002 95);
  --fg:      oklch(20% 0.018 70);
  --muted:   oklch(48% 0.012 70);
  --border:  oklch(90% 0.006 95);
  --accent:  oklch(52% 0.10 28);
  --font-display: 'Iowan Old Style', 'Charter', Georgia, 'Times New Roman', serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --radius: 10px;
  --radius-lg: 16px;
  --pill-bg: var(--accent-soft);
  --pill-border: transparent;
  --pill-radius: 999px;
  --bg-image: none;
  --bg-size: auto;
  color-scheme: light;
}

/* datasheet — WORLD: a component datasheet page (black hairlines, dense
   type, signal-red emphasis on measured values). SIGNATURE: numbered
   sections plus the red rule under each label. RISK: reads as "corporate
   Helvetica" unless the numbered marks and hairline rules do the talking —
   nothing else is allowed to be loud. */
[data-theme="datasheet"] {
  --bg:      oklch(100% 0 0);
  --surface: oklch(97% 0.002 250);
  --fg:      oklch(16% 0 0);
  --muted:   oklch(44% 0.005 250);
  --border:  oklch(80% 0.003 250);
  --accent:  oklch(50% 0.20 27);
  --font-display: 'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', sans-serif;
  --font-body:    'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --radius: 2px;
  --radius-lg: 2px;
  --pill-bg: var(--accent-soft);
  --pill-border: transparent;
  --pill-radius: 2px;
  --bg-image: none;
  --bg-size: auto;
  color-scheme: light;
}
html[data-theme="datasheet"] h1,
html[data-theme="datasheet"] h2 { font-weight: 700; letter-spacing: -0.03em; }
html[data-theme="datasheet"] main { counter-reset: sec; }
html[data-theme="datasheet"] .section:not(.hero) { counter-increment: sec; }
html[data-theme="datasheet"] .section:not(.hero) .eyebrow::before { content: counter(sec) " · "; }
html[data-theme="datasheet"] .eyebrow { display: inline-block; border-bottom: 2px solid var(--accent); padding-bottom: 4px; }
html[data-theme="datasheet"] .section + .section { border-top-color: var(--fg); }
html[data-theme="datasheet"] .topnav { border-bottom: 2px solid var(--fg); }
html[data-theme="datasheet"] .topnav .logo { text-transform: uppercase; letter-spacing: 0.02em; font-size: 16px; font-weight: 700; }

/* soldermask — WORLD: a finished PCB (green mask, ENIG gold, white
   silkscreen). SIGNATURE: the gold connector-finger strip along the page
   foot and the gold timeline rule. RISK: gold everywhere reads as a luxury
   theme; it stays on those two marks. */
[data-theme="soldermask"] {
  --bg:      oklch(26% 0.05 152);
  --surface: oklch(30% 0.055 152);
  --fg:      oklch(96% 0.01 100);
  --muted:   oklch(78% 0.025 140);
  --border:  oklch(40% 0.05 150);
  --accent:  oklch(80% 0.13 85);
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --fs-h1: clamp(32px, 4.4vw + 8px, 58px);
  --fs-h2: clamp(26px, 3vw + 8px, 40px);
  --radius: 4px;
  --radius-lg: 6px;
  --pill-bg: transparent;
  --pill-border: var(--accent);
  --pill-radius: 4px;
  --bg-image: none;
  --bg-size: auto;
  color-scheme: dark;
}
html[data-theme="soldermask"] h1,
html[data-theme="soldermask"] h2 { text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
html[data-theme="soldermask"] .eyebrow,
html[data-theme="soldermask"] .tag { color: var(--fg); }
html[data-theme="soldermask"] .tag { border-color: var(--muted); }
html[data-theme="soldermask"] .timeline,
html[data-theme="soldermask"] .log-row:first-child { border-top: 2px solid var(--accent); }
html[data-theme="soldermask"] .feature-mark,
html[data-theme="soldermask"] .gate-mark { border-color: var(--accent); }
html[data-theme="soldermask"] .pagefoot {
  border-top: 0;
  background: repeating-linear-gradient(90deg, var(--accent) 0 22px, transparent 22px 30px) top / 100% 5px no-repeat;
  padding-top: calc(var(--gap-xl) + 5px);
}

/* phosphor — WORLD: an amber serial console during boot. SIGNATURE: the
   block cursor after the hero heading and dmesg brackets on log dates.
   RISK: glow, scanlines and blur are the CRT cliché; type and brackets
   carry it and no effect is added. */
[data-theme="phosphor"] {
  --bg:      oklch(13% 0.006 60);
  --surface: oklch(17% 0.008 60);
  --fg:      oklch(88% 0.10 82);
  --muted:   oklch(66% 0.09 78);
  --border:  oklch(30% 0.03 75);
  --accent:  oklch(80% 0.17 72);
  --font-display: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --font-body:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --fs-body: 15px;
  --radius: 0;
  --radius-lg: 0;
  --pill-bg: transparent;
  --pill-border: var(--accent);
  --pill-radius: 0;
  --bg-image: none;
  --bg-size: auto;
  color-scheme: dark;
}
html[data-theme="phosphor"] h1,
html[data-theme="phosphor"] h2 { font-weight: 600; letter-spacing: 0; }
html[data-theme="phosphor"] .hero h1::after { content: "▮"; display: inline-block; margin-left: 0.12em; animation: zam-blink 1.1s steps(1) infinite; }
@keyframes zam-blink { 50% { opacity: 0; } }
html[data-theme="phosphor"] .eyebrow::before { content: "> "; }
html[data-theme="phosphor"] .log-row .meta::before { content: "[ "; }
html[data-theme="phosphor"] .log-row .meta::after { content: " ]"; }
html[data-theme="phosphor"] .section + .section { border-top-style: dashed; }
html[data-theme="phosphor"] ::selection { background: var(--accent); color: var(--bg); }
@media (prefers-reduced-motion: reduce) { html[data-theme="phosphor"] .hero h1::after { animation: none; } }

/* blueprint — WORLD: a cyanotype schematic sheet (Prussian blue, white
   line work, drafting grid). SIGNATURE: drawn line work — transparent
   cards, white section rules, a title block in the page foot. RISK: the
   grid is decorative the moment it has nothing to measure; here it is the
   sheet itself, and everything printed on it is a line, not a fill. */
[data-theme="blueprint"] {
  --bg:      oklch(33% 0.09 255);
  --surface: oklch(37% 0.085 255);
  --fg:      oklch(97% 0.01 240);
  --muted:   oklch(82% 0.04 240);
  --border:  oklch(50% 0.07 252);
  --accent:  oklch(88% 0.09 200);
  --grid: oklch(100% 0 0 / 0.07);
  --font-display: 'Bahnschrift', 'DIN Alternate', 'Roboto Condensed', 'Arial Narrow', 'Helvetica Neue', sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --fs-h1: clamp(32px, 4.2vw + 8px, 56px);
  --fs-h2: clamp(26px, 3vw + 8px, 40px);
  --radius: 2px;
  --radius-lg: 2px;
  --pill-bg: transparent;
  --pill-border: var(--accent);
  --pill-radius: 2px;
  --bg-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  --bg-size: 24px 24px;
  color-scheme: dark;
}
html[data-theme="blueprint"] h1,
html[data-theme="blueprint"] h2 { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; line-height: 1.1; }
html[data-theme="blueprint"] .card { background: transparent; border-color: var(--fg); }
html[data-theme="blueprint"] .section + .section,
html[data-theme="blueprint"] .topnav { border-color: var(--fg); }
html[data-theme="blueprint"] .pagefoot { border-top: 0; }
html[data-theme="blueprint"] .pagefoot .row-between { border: 1px solid var(--fg); padding: var(--gap-md); }
html[data-theme="blueprint"] .pagefoot .meta { color: var(--fg); }
html[data-theme="blueprint"] .pagefoot .row-between::after { content: "SHEET 1 / 1"; order: 3; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; }

/* quadrille — WORLD: green engineering quadrille paper, graphite pencil,
   ballpoint-blue ink. SIGNATURE: the slightly rotated ink stamp on each
   section label and blue log dates. RISK: novelty handwriting; the ink is
   in the stamp and the accent only, and body copy stays graphite. */
[data-theme="quadrille"] {
  --bg:      oklch(95.5% 0.02 150);
  --surface: oklch(98.5% 0.008 150);
  --fg:      oklch(27% 0.01 250);
  --muted:   oklch(50% 0.015 240);
  --border:  oklch(84% 0.03 150);
  --accent:  oklch(46% 0.17 262);
  --grid: oklch(90% 0.03 150);
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --pill-bg: var(--accent-soft);
  --pill-border: transparent;
  --pill-radius: 999px;
  --bg-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  --bg-size: 20px 20px;
  color-scheme: light;
}
html[data-theme="quadrille"] h1 { font-weight: 500; letter-spacing: -0.01em; }
html[data-theme="quadrille"] h2 { font-weight: 500; }
html[data-theme="quadrille"] .eyebrow { display: inline-block; border: 1.5px solid var(--accent); border-radius: 3px; padding: 3px 8px 2px; transform: rotate(-1.5deg); }
html[data-theme="quadrille"] .log-row .meta,
html[data-theme="quadrille"] .timeline-item .meta { color: var(--accent); }

/* ─── admin: appearance picker ──────────────────────────────────── */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-md); border: 0; padding: 0; margin: 0; min-width: 0; }
@media (max-width: 920px) { .theme-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .theme-grid { grid-template-columns: 1fr; } }
.theme-card { display: grid; gap: var(--gap-sm); cursor: pointer; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 10px 16px; background: var(--surface); transition: border-color 0.15s ease; }
.theme-card:hover { border-color: var(--fg); }
.theme-card:has(:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-card:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-swatch { display: grid; grid-template-rows: auto 1fr auto; gap: 10px; aspect-ratio: 16 / 10; padding: 14px; background-color: var(--bg); background-image: var(--bg-image); background-size: var(--bg-size); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.theme-swatch .sw-bar { height: 5px; width: 38%; background: var(--fg); opacity: 0.85; }
.theme-swatch .sw-display { font-family: var(--font-display); font-size: 30px; line-height: 1; letter-spacing: -0.02em; align-self: end; overflow-wrap: anywhere; }
.theme-swatch .sw-row { display: flex; gap: 6px; align-items: center; }
.theme-swatch .sw-btn { width: 44px; height: 14px; background: var(--accent); border-radius: var(--radius); }
.theme-swatch .sw-pill { padding: 0 6px; height: 14px; border-radius: var(--pill-radius); background: var(--pill-bg); border: 1px solid var(--pill-border); font: 8px/12px var(--font-mono); color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.theme-swatch .sw-meta { margin-left: auto; font: 9px/1 var(--font-mono); color: var(--muted); }
.theme-card .theme-dek { margin: 0; padding-inline: 6px; color: var(--muted); font-size: 13px; }
.theme-status { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); text-align: right; }
@media (prefers-reduced-motion: reduce) { .theme-card { transition: none; } }
