/* Self-hosted Lato 2.0 (SIL Open Font License v1.1 — see /fonts/OFL.txt) */
@font-face {
  font-family: "Lato";
  src: local("Lato Regular"), local("Lato-Regular"), url("fonts/Lato-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: local("Lato Italic"), local("Lato-Italic"), url("fonts/Lato-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: local("Lato Medium"), local("Lato-Medium"), url("fonts/Lato-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: local("Lato Semibold"), local("Lato-Semibold"), url("fonts/Lato-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: local("Lato Bold"), local("Lato-Bold"), url("fonts/Lato-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lato";
  src: local("Lato Bold Italic"), local("Lato-BoldItalic"), url("fonts/Lato-BoldItalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* Self-hosted Maple Mono (SIL Open Font License v1.1 — see /fonts/OFL.txt) */
@font-face {
  font-family: "Maple Mono";
  src: local("Maple Mono Regular"), local("MapleMono-Regular"), local("Maple Mono"), url("fonts/MapleMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono";
  src: local("Maple Mono Italic"), local("MapleMono-Italic"), url("fonts/MapleMono-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono";
  src: local("Maple Mono Medium"), local("MapleMono-Medium"), url("fonts/MapleMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono";
  src: local("Maple Mono SemiBold"), local("MapleMono-SemiBold"), url("fonts/MapleMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono";
  src: local("Maple Mono Bold"), local("MapleMono-Bold"), url("fonts/MapleMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono";
  src: local("Maple Mono Bold Italic"), local("MapleMono-BoldItalic"), url("fonts/MapleMono-BoldItalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font-sans: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Maple Mono", "Maple Mono NF", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --bg: #fbfbfc;
  --surface: #f2f4f7;
  --rule: #e4e7ee;
  --rule-strong: #cfd5e2;
  --fg: #11151c;
  --body: #252b36;
  --muted: #636d80;
  --primary: #1d4ed8;
  --primary-tint: rgba(29, 78, 216, 0.06);
  --link: #1d4ed8;
  --success: #157347;
  --warning: #a15c07;
  --warning-tint: rgba(180, 100, 10, 0.065);
  --warning-rule: rgba(180, 100, 10, 0.28);
  --error: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1116;
    --surface: #161b23;
    --rule: #212834;
    --rule-strong: #2f394a;
    --fg: #eef1f6;
    --body: #cfd6e3;
    --muted: #8894a8;
    --primary: #6ba6ff;
    --primary-tint: rgba(107, 166, 255, 0.09);
    --link: #7cb3ff;
    --success: #4ade80;
    --warning: #f5b73b;
    --warning-tint: rgba(245, 183, 59, 0.08);
    --warning-rule: rgba(245, 183, 59, 0.3);
    --error: #f87171;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #161b23;
  --rule: #212834;
  --rule-strong: #2f394a;
  --fg: #eef1f6;
  --body: #cfd6e3;
  --muted: #8894a8;
  --primary: #6ba6ff;
  --primary-tint: rgba(107, 166, 255, 0.09);
  --link: #7cb3ff;
  --success: #4ade80;
  --warning: #f5b73b;
  --warning-tint: rgba(245, 183, 59, 0.08);
  --warning-rule: rgba(245, 183, 59, 0.3);
  --error: #f87171;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }

html,
body {
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 28px 56px;
}

code,
pre {
  font-family: var(--font-mono);
}

code {
  font-size: 12.5px;
  color: var(--fg);
  background: var(--surface);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Minimal Top Masthead — Full-Bleed Hairline Rule */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 18px 0 14px;
  margin-bottom: 0;
  position: relative;
}
.site-nav::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -100vw;
  right: -100vw;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}

.site-brand {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-brand:hover { color: var(--primary); }

.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 18px;
  font-variant-numeric: tabular-nums;
}

.nav-link {
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: none;
}
.nav-link:hover { color: var(--fg); }
.nav-link-active {
  color: var(--fg);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1.5px;
}

/* Quiet Plain-Text Controls */
.text-action {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.text-action:hover {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-action-accent {
  color: var(--link);
  font-weight: 600;
}
.text-action-accent:hover { color: var(--primary); }

/* Issue & Page Masthead — Full-Bleed Horizontal Bands */
.masthead-special {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 15px;
  text-decoration: none;
  color: var(--body);
}
.masthead-special:hover .special-banner-title {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.masthead-special:hover .special-banner-cta {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.special-banner-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warning);
}

.special-banner-date {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}
.special-banner-date::before {
  content: "·";
  margin-right: 8px;
  opacity: 0.6;
}

.special-banner-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--fg);
}

.special-banner-blurb {
  font-size: 13.5px;
  color: var(--muted);
}

.special-banner-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--warning);
  white-space: nowrap;
}

.note-special-crumb {
  font-size: 13px;
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.issue-masthead,
.issue-header,
.note-masthead {
  padding: 24px 0 22px;
  margin-bottom: 0;
  position: relative;
}
.issue-masthead::after,
.issue-header::after,
.note-masthead::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -100vw;
  right: -100vw;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.eyebrow-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.issue-select {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--rule-strong);
  padding: 0 2px 1px;
  cursor: pointer;
}

h1 {
  margin: 0 0 6px;
  font-size: 25px;
  line-height: 1.24;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.015em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
  max-width: 68ch;
}

/* Two-Column Editorial Layout — Continuous Boundary-to-Boundary Grid */
.editorial-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  gap: 0;
  align-items: stretch;
}

.col-primary {
  min-width: 0;
}

.col-rail {
  padding: 0 0 24px 28px;
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.note-rail-sticky {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
}

/* Right Rail Sections — Touch Vertical Divider on Left & Viewport on Right */
.rail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 0 20px 28px;
  margin-left: -28px;
  position: relative;
}
.rail-section::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: -100vw;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}
.rail-section:last-child {
  padding-bottom: 0;
}
.rail-section:last-child::after {
  display: none;
}

.rail-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.rail-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg);
}

.rail-stat {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rail-caption {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.rail-highlights {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
  line-height: 1.48;
  color: var(--body);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.highlight-jump-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
}
.highlight-jump-btn:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.highlight-archive-link {
  color: var(--body);
  text-decoration: none;
}
.highlight-archive-link:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.highlight-cards {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 6px;
}

.rail-notes,
.rail-pulse-list {
  display: flex;
  flex-direction: column;
}

.rail-note-item,
.rail-pulse-item {
  padding: 10px 0 10px 28px;
  margin-left: -28px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}
.rail-note-item::before,
.rail-pulse-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: -100vw;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}
.rail-note-item:first-child,
.rail-pulse-item:first-child {
  padding-top: 2px;
}
.rail-note-item:first-child::before,
.rail-pulse-item:first-child::before {
  display: none;
}
.rail-notes-extra .rail-note-item:first-child {
  padding-top: 10px;
}
.rail-notes-extra .rail-note-item:first-child::before {
  display: block;
}
.rail-more-btn {
  align-self: flex-start;
  font-size: 12px;
  margin-top: 2px;
}

.rail-note-title,
.rail-pulse-link {
  font-size: 13px;
  line-height: 1.38;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}
.rail-note-title:hover,
.rail-pulse-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.rail-note-desc,
.rail-pulse-note {
  font-size: 12px;
  line-height: 1.42;
  color: var(--muted);
}

.rail-pulse-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.rail-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.rail-toc {
  margin: 0;
  padding-left: 15px;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rail-toc a {
  color: var(--muted);
  text-decoration: none;
}
.rail-toc a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Baseline Underline Tab Bar + Flush Search */
.tab-bar {
  padding: 8px 32px 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  position: relative;
}
.tab-bar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -100vw;
  right: 0;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 0 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn[aria-selected="true"] {
  color: var(--fg);
  font-weight: 700;
  border-bottom-color: var(--primary);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 3px;
}

.tab-tools {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.search-inline {
  width: 165px;
  max-width: 100%;
  padding: 4px 0 6px;
  font: inherit;
  font-size: 13px;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  outline: none;
}
.search-inline::placeholder { color: var(--muted); }
.search-inline:focus { border-bottom-color: var(--primary); }

/* Quiet Inline Filter Strip */
.filter-strip {
  padding: 10px 32px 9px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  font-size: 13px;
  position: relative;
}
.filter-strip::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -100vw;
  right: 0;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}
#notesFilterBar {
  padding-right: 0;
}
#notesFilterBar::after {
  right: -100vw;
}

.filter-prefix {
  color: var(--muted);
  font-size: 12.5px;
}

.filter-btn {
  background: none;
  border: none;
  padding: 2px 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.filter-btn:hover { color: var(--fg); }
.filter-btn.filter-active {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
}

/* Primary Reading Ledger Entries */
.entries-list {
  display: flex;
  flex-direction: column;
}

.entry {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0 12px;
  padding: 22px 32px 22px 0;
  position: relative;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.entry + .entry::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100vw;
  right: 0;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}
.entry.is-first-visible::before,
.section-divider + .entry::before {
  display: none;
}

.archive-entry {
  grid-template-columns: 92px minmax(0, 1fr);
  padding-right: 0;
}
.archive-entry .entry-main {
  max-width: 720px;
}
.archive-entry + .archive-entry::before {
  right: -100vw;
}

.entry-highlight {
  background: var(--primary-tint);
  box-shadow: -100vw 0 0 0 var(--primary-tint);
}

.entry-rail {
  padding-top: 2px;
}

.id-label {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.id-label:hover { color: var(--primary); }
.id-label-extra { color: var(--warning); }

.entry-main {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
}

.entry-title-btn {
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  flex: 1;
}
.entry-title-btn:hover h2 { color: var(--primary); }

.entry h2 {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.archive-title-link {
  color: var(--fg);
  text-decoration: none;
}
.archive-title-link:hover { color: var(--primary); }

.entry-actions {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-shrink: 0;
}

/* Muted Metadata + Semantic Text Flags */
.meta-line {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.meta-item::before {
  content: "·";
  margin: 0 6px;
  color: var(--muted);
  opacity: 0.65;
}

.flag { color: var(--muted); }
.flag-ok { color: var(--success); font-weight: 600; }
.flag-warn { color: var(--warning); font-weight: 600; }
.flag-err { color: var(--error); font-weight: 600; }

/* Summary & Flush Take-home Block (No Indent, No Left Border) */
.summary {
  margin: 2px 0 0;
  color: var(--body);
}

.takehome {
  margin: 2px 0 0;
  color: var(--body);
}
.takehome strong {
  color: var(--fg);
  font-weight: 700;
}

/* Inline Linked Note Reference */
.linked-notes-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.linked-note-line {
  font-size: 13.5px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.linked-note-arrow {
  color: var(--muted);
  font-family: var(--font-mono);
}

.linked-note-desc { color: var(--muted); }

/* Expanded Details with Hanging Side-Labels */
.details {
  margin-top: 8px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  position: relative;
}
.details::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: -32px;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}

.detail-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 4px 14px;
  align-items: baseline;
}

.detail-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.detail-label-warn { color: var(--warning); }

.details p {
  margin: 0;
  font-size: 14.5px;
  color: var(--body);
}

/* Inline Source Links & Cross-Links */
.entry-foot {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 16px;
  font-size: 13px;
}

.inline-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.inline-link {
  color: var(--link);
  text-decoration: none;
}
.inline-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.inline-links .inline-link + .inline-link::before {
  content: "·";
  margin: 0 7px;
  color: var(--muted);
  opacity: 0.6;
  display: inline-block;
  text-decoration: none;
}

.muted-link { color: var(--muted); }
.muted-link:hover { color: var(--fg); }

.cross-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.cross-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--link);
  text-decoration: none;
  cursor: pointer;
}
.cross-link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pulse-metrics {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pulse-metric-link {
  color: var(--muted);
  text-decoration: none;
}
.pulse-metric-link:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pulse-metrics .pulse-metric-link + .pulse-metric-link::before {
  content: "·";
  margin: 0 4px;
  opacity: 0.55;
  display: inline-block;
  text-decoration: none;
}

.section-divider {
  padding: 14px 32px 12px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warning);
  position: relative;
}
.section-divider-active {
  color: var(--primary);
}
.section-divider-muted {
  color: var(--muted);
}
.section-divider::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100vw;
  right: 0;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}
.section-divider.is-first-visible::before {
  display: none;
}
.section-divider::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -100vw;
  right: 0;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}

.empty-msg {
  padding: 32px 32px 32px 0;
  color: var(--muted);
  font-size: 14.5px;
}

/* Archive & Long-Form Note Prose */
.issue-pager {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  margin: 0;
  font-size: 13px;
  position: relative;
}
.issue-pager::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -100vw;
  right: -100vw;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}

.highlights-list {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-title {
  font-size: 26px;
  line-height: 1.24;
  margin: 6px 0 0;
  max-width: 34ch;
}

.note-lead {
  font-size: 15.5px;
  margin-top: 8px;
  max-width: 66ch;
}

.prose {
  padding: 26px 36px 36px 0;
  font-size: 15.5px;
  line-height: 1.68;
  color: var(--body);
}
.prose h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--fg);
  margin: 28px 0 8px;
  letter-spacing: -0.01em;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin: 20px 0 6px;
}
.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre,
.prose table {
  margin: 0 0 15px;
}
.prose a { color: var(--link); }
.prose blockquote {
  padding-left: 14px;
  border-left: 2px solid var(--rule-strong);
  color: var(--muted);
}
.prose pre {
  padding: 13px 15px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--rule);
  overflow-x: auto;
  font-size: 13px;
}
.prose pre code {
  background: none;
  padding: 0;
}
:root[data-theme="light"] .prose pre.giallo { color-scheme: light !important; }
:root[data-theme="dark"] .prose pre.giallo { color-scheme: dark !important; }

/* MathJax SVG Equations */
.math-display,
mjx-container[jax="SVG"][display="true"] {
  margin: 16px 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}
mjx-container[jax="SVG"] svg {
  vertical-align: middle;
}

/* Technical Note Figures (texit / TikZ SVGs) & Lightbox */
.note-figure {
  margin: 20px 0 22px;
}
.note-figure img.diagram-svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: #ffffff;
}
.note-figure img.is-zoomable {
  cursor: zoom-in;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.note-figure img.is-zoomable:hover,
.note-figure img.is-zoomable:focus-visible {
  border-color: var(--primary);
  outline: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .note-figure img.diagram-svg,
  :root:not([data-theme="light"]) .figure-lightbox img.diagram-svg {
    filter: invert(0.92) hue-rotate(180deg) saturate(1.12);
    border-color: var(--rule-strong);
  }
  :root:not([data-theme="light"]) dialog.figure-lightbox {
    background: #141414;
  }
  :root:not([data-theme="light"]) dialog.figure-lightbox::backdrop {
    background: #141414;
  }
  :root:not([data-theme="light"]) .figure-lightbox-bar {
    background: rgba(28, 33, 43, 0.86);
  }
}
:root[data-theme="dark"] .note-figure img.diagram-svg,
:root[data-theme="dark"] .figure-lightbox img.diagram-svg {
  filter: invert(0.92) hue-rotate(180deg) saturate(1.12);
  border-color: var(--rule-strong);
}
:root[data-theme="dark"] dialog.figure-lightbox {
  background: #141414;
}
:root[data-theme="dark"] dialog.figure-lightbox::backdrop {
  background: #141414;
}
:root[data-theme="dark"] .figure-lightbox-bar {
  background: rgba(28, 33, 43, 0.86);
}
.note-figure figcaption {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.48;
  color: var(--muted);
}

html:has(dialog.figure-lightbox[open]) {
  overflow: hidden;
}
dialog.figure-lightbox {
  border: none;
  padding: 0;
  margin: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  background: #ffffff;
  color: var(--fg);
  cursor: zoom-out;
  overflow: hidden;
}
dialog.figure-lightbox::backdrop {
  background: #ffffff;
}
.figure-lightbox-bar {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 5px 4px 12px;
  border-radius: 999px;
  background: rgba(242, 244, 247, 0.88);
  border: 1px solid var(--rule-strong);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  user-select: none;
}
.figure-lightbox-close {
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--fg);
  border-radius: 999px;
  width: 24px;
  height: 24px;
  line-height: 1;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.figure-lightbox-close:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.figure-lightbox-stage {
  width: 100vw;
  height: 100vh;
  overflow: auto;
  display: flex;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: zoom-out;
  -webkit-overflow-scrolling: touch;
}
.figure-lightbox-stage::-webkit-scrollbar {
  display: none;
}
.figure-lightbox-stage.is-zoomed {
  cursor: grab;
}
.figure-lightbox-stage.is-zoomed.is-dragging {
  cursor: grabbing;
  user-select: none;
}
.figure-lightbox-stage img {
  display: block;
  margin: auto;
  flex-shrink: 0;
  max-width: none;
  border: none;
  border-radius: 0;
  background: transparent;
  user-select: none;
  -webkit-user-drag: none;
}
.figure-lightbox-caption {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(88vw, 920px);
  z-index: 2;
  text-align: left;
  pointer-events: auto;
}
.figure-lightbox-caption figcaption {
  margin: 0;
  font-size: 13px;
  line-height: 1.48;
  color: var(--muted);
}
.figure-lightbox-caption figcaption a {
  color: var(--link);
}
dialog.figure-lightbox.is-zoomed .figure-lightbox-caption {
  display: none;
}
@media (max-width: 600px) {
  .figure-lightbox-bar {
    top: 10px;
    right: 10px;
    font-size: 10px;
    padding: 3px 4px 3px 9px;
    gap: 7px;
  }
  .figure-lightbox-caption {
    bottom: 12px;
    width: 92vw;
  }
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.prose th,
.prose td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
.prose th {
  color: var(--fg);
  font-weight: 700;
  border-bottom-color: var(--rule-strong);
}

.site-footer {
  margin-top: 0;
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  position: relative;
}
.site-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100vw;
  right: -100vw;
  height: 1px;
  background: var(--rule);
  pointer-events: none;
}

.footer-right {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

#toast {
  color: var(--success);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#toast.toast-visible { opacity: 1; }

/* Responsive Stack Below 940px */
.toc-mobile { display: none; }

@media (max-width: 940px) {
  /* Phone/tablet: slim sticky "Contents" bar replaces the rail TOC */
  .toc-mobile {
    display: block;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    box-shadow: 0 0 0 100vmax var(--bg);
    clip-path: inset(0 -100vmax);
  }
  .toc-mobile summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 0;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .toc-mobile summary::-webkit-details-marker { display: none; }
  .toc-chevron {
    width: 18px;
    height: 18px;
    color: var(--muted);
    flex-shrink: 0;
    transition: transform 0.15s ease;
  }
  .toc-mobile[open] .toc-chevron { transform: rotate(180deg); }
  .toc-mobile .rail-toc {
    padding: 0 0 12px 15px;
    max-height: 60vh;
    overflow-y: auto;
  }
  .rail-toc-section { display: none; }
  .prose h2,
  .prose h3 { scroll-margin-top: 48px; }

  .editorial-columns {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .tab-bar,
  .filter-strip,
  .entry,
  .section-divider,
  .prose,
  .empty-msg {
    padding-right: 0;
  }
  .tab-bar::after,
  .filter-strip::after,
  .entry + .entry::before,
  .section-divider::before,
  .section-divider::after,
  .details::before {
    right: -100vw;
  }
  .entry-highlight {
    box-shadow: -100vw 0 0 0 var(--primary-tint), 100vw 0 0 0 var(--primary-tint);
  }
  .col-rail {
    padding-left: 0;
    border-left: none;
    position: relative;
  }
  .col-rail::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100vw;
    right: -100vw;
    height: 1px;
    background: var(--rule-strong);
    pointer-events: none;
  }
  .rail-section,
  .rail-note-item,
  .rail-pulse-item {
    margin-left: 0;
    padding-left: 0;
  }
  .rail-section::after,
  .rail-note-item::before,
  .rail-pulse-item::before {
    left: -100vw;
  }
  .note-rail-sticky {
    position: static;
  }
}

@media (max-width: 600px) {
  .wrap {
    padding: 0 16px 48px;
  }
  /* Title gets the full width; Deep Dive / Details / Copy prompt move to their own row */
  .entry-head {
    flex-direction: column;
    gap: 4px;
  }
  .entry-actions {
    flex-wrap: wrap;
    gap: 4px 16px;
  }
  .entry,
  .archive-entry {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 0 8px;
  }
  .detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
