/* ---------- Tokens (from viditb.com) ---------- */
:root {
  --bg: #fff;
  --text: #1a1a1a;
  --muted: #888;
  --soft: #666;
  --rule: #e5e5e5;
  --card: rgba(208, 208, 208, 0.25);
  --card-hover: rgba(208, 208, 208, 0.4);
  --pill: rgba(255, 255, 255, 0.4);
  --pill-active: #fff;
  --accent: rgba(25, 125, 165, 1);       /* "bondi" */
  --accent-soft: rgba(158, 196, 253, 0.25); /* "blue" */
  --star: rgba(209, 69, 71, 1);           /* "red" */
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: rgb(20, 20, 20);
    --text: #fff;
    --muted: #999;
    --soft: #aaa;
    --rule: #333;
    --card: rgba(255, 255, 255, 0.06);
    --card-hover: rgba(255, 255, 255, 0.1);
    --pill: rgba(20, 20, 20, 0.5);
    --pill-active: rgba(80, 80, 80, 0.5);
    --accent: rgba(90, 180, 220, 1);
    --accent-soft: rgba(90, 160, 255, 0.16);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --bg: rgb(20, 20, 20); --text: #fff; --muted: #999; --soft: #aaa; --rule: #333;
  --card: rgba(255, 255, 255, 0.06); --card-hover: rgba(255, 255, 255, 0.1);
  --pill: rgba(20, 20, 20, 0.5); --pill-active: rgba(80, 80, 80, 0.5);
  --accent: rgba(90, 180, 220, 1); --accent-soft: rgba(90, 160, 255, 0.16);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 16px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  overflow-x: hidden;
  overflow-wrap: break-word;
}
a { color: inherit; }

.index-container {
  width: 70%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 0;
}

/* ---------- Hero ---------- */
.index-hero { margin-bottom: 24px; }
.index-hero h1 {
  font-size: 3.5rem;
  font-weight: 700;
  margin: 0.67em 0 4px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}
.index-hero-subtitle {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
}
.index-hero .intro {
  font-size: 1rem;
  line-height: 1.5;
  max-width: 68ch;
  margin: 32px 0 32px;
}

/* ---------- Sticky pill nav ---------- */
.nav-rule { width: 100%; border-top: 1px solid var(--rule); }
.fauxHeader { height: 1px; }
.header {
  position: sticky;
  top: 8px;
  z-index: 1000;
  width: fit-content;
  margin: 0 auto;
  padding: 15px;
  border-radius: 22px;
  background: var(--pill);
  transition: box-shadow 0.25s ease-out, backdrop-filter 0.25s ease-out;
}
.header.stuck {
  backdrop-filter: blur(42px);
  -webkit-backdrop-filter: blur(42px);
  box-shadow: var(--shadow);
}
.navGroup { display: flex; justify-content: center; align-items: center; gap: 16px; }
.navGroup a {
  text-decoration: none;
  color: var(--text);
  border-radius: 16px;
  transition: background 0.25s ease-out;
}
.navGroup a.active {
  background: var(--pill-active);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
.glow-button {
  padding: 12px 24px;
  border-radius: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.3s ease-out;
}
.glow-button:hover {
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 255, 255, 0.5), rgba(235, 235, 235, 0));
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.15);
}
@media (prefers-color-scheme: dark) {
  .glow-button:hover { background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(120, 120, 120, 0.5), rgba(0, 0, 0, 0)); }
}

/* ---------- Sections ---------- */
.index-section { margin: 40px 0 50px; scroll-margin-top: 90px; }
.index-section > h2 { font-size: 1.5rem; font-weight: 700; margin: 0 0 4px; }
.section-lede { color: var(--muted); font-size: 0.95rem; margin: 0 0 24px; max-width: 60ch; }

/* ---------- Editorial ----------
   Same grid as All Readings: a 220px label column, a 48px gutter, then a
   reading column capped at a comfortable measure. Spacing steps in 8px. */
.ed-row { padding: 32px 0; border-top: 1px solid var(--rule); }
.ed-row:first-child { border-top: none; padding-top: 8px; }
.ed-label { margin: 0 0 16px; }
@media (max-width: 819px) { .ed-label:empty { display: none; } }
.ed-label h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; margin: 0; }
.ed-label h3 {
  font-size: 0.75rem; font-weight: 600; line-height: 1.5; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 0;
}
.ed-main { max-width: 68ch; min-width: 0; }
.editorial-intro p { font-size: 1.05rem; line-height: 1.6; margin: 0 0 16px; }
.editorial-intro p:last-child { margin-bottom: 0; }
.pick + .pick { margin-top: 40px; }
.pick-num {
  font-size: 2.25rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em;
  color: var(--muted); opacity: 0.6; margin: 0 0 16px; font-variant-numeric: tabular-nums;
}
.pick-reading + .pick-reading { margin-top: 16px; }
.pick-title { font-size: 1.15rem; font-weight: 600; line-height: 1.4; margin: 0; }
.pick-title a { color: inherit; text-decoration: none; }
.pick-title a:hover { color: var(--accent); }
.pick-meta { font-size: 0.8rem; line-height: 1.5; color: var(--muted); margin: 4px 0 0; }
.pick-why { font-size: 1rem; line-height: 1.6; color: var(--soft); margin: 16px 0 0; }
.pick-why a, .pick-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.pick-why a:hover, .pick-link:hover { text-decoration: underline; }
@media (min-width: 820px) {
  .ed-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; align-items: start; }
  .ed-label { margin: 0; position: sticky; top: 100px; }
  .ed-label h3 { padding-top: 4px; }
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 24px;
}
.search { position: relative; flex: 1 1 280px; min-width: 0; }
.search input {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 11px 16px 11px 40px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); background: var(--bg); }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
select.sort, .chip-btn {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 10px 16px;
  cursor: pointer;
}
select.sort { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M1 3l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.4'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; }
.chip-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.chip-btn[aria-pressed="false"] { color: var(--muted); }
.chip-btn:focus-visible, select.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.showing { font-size: 0.85rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.clear { font: inherit; font-size: 0.85rem; color: var(--accent); background: none; border: none; cursor: pointer; padding: 4px; }
.clear[hidden] { display: none; }

/* ---------- Views (Editorial / All Readings are separate pages) ---------- */
.view[hidden] { display: none; }

/* ---------- Topic rail (mobile-first: a scrolling row) ---------- */
.layout { display: block; }
.spine { padding: 0 0 16px; margin-bottom: 8px; border-bottom: 1px solid var(--rule); }
.spine h3 { display: none; }
.spine ul { list-style: none; margin: 0; padding: 0 0 4px; display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.spine li { flex: 0 0 auto; }
.spine a {
  display: flex; gap: 8px; align-items: baseline;
  padding: 7px 12px; border-radius: 12px;
  color: var(--muted); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.spine a:hover { color: var(--text); background: var(--card); }
.spine a.on { color: var(--text); background: var(--accent-soft); font-weight: 500; }
.spine a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.spine .rn { font-size: 0.72rem; font-weight: 600; color: var(--accent); min-width: 24px; font-variant-numeric: tabular-nums; }
.spine .nm { font-size: 0.85rem; line-height: 1.3; }
.spine .ct { font-size: 0.72rem; color: var(--muted); margin-left: 4px; }
.spine .clear { margin-top: 8px; }
.list-main { min-width: 0; }

@media (min-width: 820px) {
  .layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; align-items: start; }
  .spine { position: sticky; top: 100px; padding: 0; margin: 0; border-bottom: none; }
  .spine h3 { display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px 12px; }
  .spine ul { flex-direction: column; gap: 2px; overflow: visible; padding: 0; }
  .spine a { white-space: normal; padding: 6px 12px; }
  .spine .ct { margin-left: auto; }
  .sec-head:first-child { padding-top: 0; border-top: none; }
}

/* ---------- Reading list ---------- */
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 40px 0 4px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.sec-head:first-child { margin-top: 0; }
.sec-head h3 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.sec-head .ct { font-size: 0.8rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}
.entry:last-child { border-bottom: none; }
.ttl { font-size: 1.05rem; font-weight: 600; line-height: 1.35; margin: 0; }
.ttl .star { color: var(--star); font-size: 0.8em; margin-right: 6px; vertical-align: 1px; }
.meta { font-size: 0.85rem; color: var(--muted); margin: 2px 0 0; }
.note { font-size: 0.92rem; color: var(--soft); margin: 6px 0 0; max-width: 68ch; }
.note a { color: var(--accent); text-decoration: none; font-weight: 500; }
.note a:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 0.72rem; color: var(--muted); background: var(--card); border-radius: 10px; padding: 2px 9px; }
.tag.core { color: var(--accent); background: var(--accent-soft); }
.side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; padding-top: 2px; }
.read {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: border-bottom 0.25s ease-in-out;
}
.read:hover { border-bottom-color: var(--accent); }
.copy {
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.copy:hover { color: var(--text); }
mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }
.empty button { font: inherit; color: var(--accent); background: none; border: none; cursor: pointer; }

.toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  font-size: 0.85rem; background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 16px;
  opacity: 0; pointer-events: none; transition: all 0.22s; z-index: 1100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.index-footer { margin-top: 60px; padding-top: 20px; border-top: 1px solid var(--rule); }
.footerText { font-size: 0.875rem; color: var(--muted); }

/* ---------- Responsive (same breakpoints as viditb.com) ---------- */
@media (max-width: 1500px) and (min-width: 950px) { .index-container { width: 80%; } }
@media (max-width: 950px) {
  .index-container { width: auto; padding: 24px 16px; }
  .index-hero h1 { font-size: 2.5rem; }
}
@media (max-width: 590px) {
  .index-hero h1 { font-size: 2rem; }
  .glow-button { padding: 10px 16px; }
  .header { padding: 10px; }
  .entry { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; padding-top: 6px; }
  .showing { margin-left: 0; }
  select.sort { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .header, .toolbar, .spine, .copy, .nav-rule { display: none !important; }
  .index-container { width: 100%; }
}

/* ---------- debug.html: draft (unreviewed) summaries ---------- */
.note.draft { border-left: 2px dashed var(--star); padding-left: 10px; }
.note.draft::before {
  content: "Draft"; display: inline-block; margin-right: 8px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--star);
}
