/* DrPeering.net — modernized prototype theme */
:root {
  --bg: #fafaf7;
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #5e5e5e;
  --soft-ink: #3a3a3a;
  --line: #e5e0d8;
  --accent: #0a5fd9;
  --accent-deep: #0746a8;
  --accent-soft: #e7efff;
  --good: #1f7a3a;
  --good-soft: #e3f3e7;
  --warn: #b76b00;
  --warn-soft: #fbf0db;
  --bad: #a1281c;
  --bad-soft: #fbe5e1;
  --code: #f1ede4;
  --gold: #c89328;
  --serif: ui-serif, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --maxw: 1200px;
}
[data-theme="dark"] {
  --bg: #14161a;
  --paper: #1c1f25;
  --ink: #ececec;
  --muted: #9aa0aa;
  --soft-ink: #c5c8cc;
  --line: #2a2e36;
  --accent: #6aa3ff;
  --accent-deep: #88b6ff;
  --accent-soft: #1c2a44;
  --good: #5fc97e;
  --good-soft: #173424;
  --warn: #e6a857;
  --warn-soft: #3a2c14;
  --bad: #f0796a;
  --bad-soft: #3a1d18;
  --code: #262a32;
  --gold: #d9a648;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--code); padding: 1px 5px; border-radius: 3px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.site-header .inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 24px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--sans); font-weight: 700; font-size: 17px;
  color: var(--ink); letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand .mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: white; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: 0;
}
.brand .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }
nav.primary { display: flex; gap: 18px; font-size: 14px; font-weight: 500; }
nav.primary a { color: var(--soft-ink); }
nav.primary a.active, nav.primary a:hover { color: var(--accent); text-decoration: none; }
.header-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.btn-icon {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent); color: white; border: 0;
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: var(--sans);
}
.btn-primary:hover { background: var(--accent-deep); text-decoration: none; color: white; }

/* ---------- Sponsor strip ---------- */
.sponsor {
  max-width: var(--maxw); margin: 16px auto 0; padding: 0 24px;
}
.sponsor-card {
  background: linear-gradient(135deg, color-mix(in oklab, var(--gold) 12%, var(--paper)), var(--paper));
  border: 1px solid color-mix(in oklab, var(--gold) 40%, var(--line));
  border-radius: 10px;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
  font-size: 13px;
}
.sponsor-card .label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--gold);
  padding: 3px 7px; background: color-mix(in oklab, var(--gold) 18%, transparent); border-radius: 4px;
}
.sponsor-card strong { color: var(--ink); }
.sponsor-card .cta { margin-left: auto; color: var(--accent); font-weight: 500; }

/* ---------- Generic container ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Home hero ---------- */
.hero { padding: 56px 24px 36px; }
.hero-inner { max-width: var(--maxw); margin: 0 auto; display: grid; grid-template-columns: 1.5fr 1fr; gap: 48px; align-items: center; }
@media (max-width: 800px) { .hero-inner { grid-template-columns: 1fr; gap: 24px; } }
.hero h1 { font-family: var(--sans); font-size: 44px; line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 12px; }
.hero .lede { font-family: var(--serif); font-size: 19px; color: var(--soft-ink); margin: 0 0 20px; line-height: 1.55; }
.hero .cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .book-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; text-align: center; box-shadow: 0 20px 50px -30px rgba(0,0,0,0.25);
}
.hero .book-cover {
  height: 240px;
  background: linear-gradient(135deg, #1a3a7a, #0746a8 60%, #0a5fd9);
  border-radius: 8px; margin: 0 auto 14px;
  max-width: 180px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  color: white; padding: 20px 16px; text-align: center;
  font-family: var(--serif);
}
.hero .book-cover .t1 { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.7; margin-bottom: 10px; }
.hero .book-cover .t2 { font-size: 19px; font-weight: 600; line-height: 1.15; margin-bottom: 10px; }
.hero .book-cover .t3 { font-size: 11px; opacity: 0.85; }
.hero .book-card h3 { margin: 0 0 4px; font-family: var(--sans); font-size: 14px; }
.hero .book-card p { margin: 0 0 12px; font-size: 12px; color: var(--muted); }

/* ---------- Home sections ---------- */
.section { padding: 40px 24px; max-width: var(--maxw); margin: 0 auto; }
.section h2 { font-family: var(--sans); font-size: 26px; margin: 0 0 20px; letter-spacing: -0.01em; }
.section .sub { font-size: 14px; color: var(--muted); margin: -16px 0 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px;
}
.card h3 { font-family: var(--sans); margin: 0 0 8px; font-size: 16px; }
.card p { margin: 0 0 12px; font-size: 14px; color: var(--soft-ink); }
.card .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.card a.more { font-size: 13px; font-weight: 500; }

/* ---------- AdSense placeholder ---------- */
.ad-slot {
  border: 1px dashed color-mix(in oklab, var(--accent) 45%, var(--line));
  background: color-mix(in oklab, var(--accent) 5%, transparent);
  border-radius: 8px; padding: 22px 18px; text-align: center;
  font-family: var(--sans); font-size: 12px; color: var(--muted);
  margin: 28px 0;
}
.ad-slot .tag { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 4px; }

/* ---------- Article (chapter) layout ---------- */
.doc {
  max-width: var(--maxw); margin: 0 auto; padding: 24px 24px 80px;
  display: grid; grid-template-columns: 220px 1fr 320px; gap: 32px;
}
@media (max-width: 1100px) {
  .doc { grid-template-columns: 1fr; }
  .toc, .rail { display: none; }
}
.toc { position: sticky; top: 80px; align-self: start; font-family: var(--sans); font-size: 13px; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 6px; }
.toc h5 { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.toc a { display: block; padding: 4px 0; color: var(--soft-ink); border-left: 2px solid transparent; padding-left: 10px; margin-left: -10px; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc a.active { border-left-color: var(--accent); color: var(--accent); font-weight: 500; }
.toc .toc-group { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 14px 0 4px; font-weight: 600; }

.article {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 40px 56px; font-family: var(--serif); font-size: 18px; line-height: 1.7;
}
@media (max-width: 700px) { .article { padding: 28px 22px; font-size: 17px; } }
.article-meta { display: flex; gap: 12px; align-items: center; font-family: var(--sans); font-size: 13px; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.article-meta .pill { background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 100px; font-weight: 600; font-size: 11px; letter-spacing: 0.04em; }
.article h1 { font-family: var(--sans); font-size: 36px; line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.01em; }
.article .lede { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 18px; margin: 0 0 24px; }
.article h2 { font-family: var(--sans); font-size: 22px; margin: 36px 0 12px; letter-spacing: -0.005em; }
.article h3 { font-family: var(--sans); font-size: 17px; margin: 28px 0 8px; color: var(--muted); }
.article p { margin: 0 0 16px; }
.article ul, .article ol { margin: 0 0 16px; padding-left: 24px; }
.article ul li, .article ol li { margin-bottom: 8px; }

.article-nav { display: flex; justify-content: space-between; margin: 40px 0 0; padding-top: 24px; border-top: 1px solid var(--line); font-family: var(--sans); font-size: 13px; }
.article-nav a { color: var(--soft-ink); }
.article-nav .arrow { color: var(--muted); }

/* AI summary card */
.ai-summary {
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent) 25%, transparent);
  border-radius: 10px; padding: 18px 20px; margin-bottom: 28px;
  font-family: var(--sans); font-size: 14px; line-height: 1.55;
}
.ai-summary header { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.ai-summary .regen { margin-top: 10px; font-size: 12px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-family: var(--sans); }
.ai-summary .regen:hover { background: var(--paper); }

/* Annotations */
.annot {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  padding: 10px 14px; margin: 18px 0; border-radius: 0 6px 6px 0;
  font-family: var(--sans); font-size: 13px; line-height: 1.5;
}
.annot.confirmed { border-color: var(--good); background: var(--good-soft); }
.annot.outdated  { border-color: var(--bad);  background: var(--bad-soft); }
.annot header { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.75; margin-bottom: 4px; }

/* Predictions table */
.predictions { font-family: var(--sans); margin: 28px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 14px; }
.predictions .ph { display: grid; grid-template-columns: 1fr 140px; background: var(--code); padding: 10px 16px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.predictions .row { display: grid; grid-template-columns: 1fr 140px; padding: 14px 16px; border-top: 1px solid var(--line); align-items: start; }
.predictions .row p { margin: 0; line-height: 1.45; }
.predictions .row .label { padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-align: center; }
.label.confirmed { background: var(--good-soft); color: var(--good); }
.label.partial   { background: var(--warn-soft); color: var(--warn); }
.label.outdated  { background: var(--bad-soft); color: var(--bad); }

/* Figure */
.figure { margin: 24px 0; padding: 18px; background: var(--code); border-radius: 8px; text-align: center; font-family: var(--sans); }
.figure .placeholder { height: 120px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 10%, var(--paper)), color-mix(in oklab, var(--accent) 25%, var(--paper))); border-radius: 6px; color: var(--accent); font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.figure .caption { font-size: 12px; color: var(--muted); }
.figure.wide .placeholder { height: 180px; }

/* ---------- Right rail ---------- */
.rail { position: sticky; top: 80px; align-self: start; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 100px); }
.rail .buy-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.rail .buy-card h4 { font-family: var(--sans); margin: 0 0 4px; font-size: 14px; }
.rail .buy-card p { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.rail .buy-card .actions { display: flex; flex-direction: column; gap: 6px; }
.rail .buy-card .actions a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 12px; color: var(--ink); font-weight: 500;
}
.rail .buy-card .actions a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.rail .buy-card .actions a .price { color: var(--muted); font-weight: 400; }

/* Chat */
.chat {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  height: 480px; font-family: var(--sans);
}
.chat header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.chat header .dot { width: 8px; height: 8px; background: var(--good); border-radius: 50%; box-shadow: 0 0 0 3px var(--good-soft); }
.chat header h6 { margin: 0; font-size: 14px; font-weight: 600; }
.chat header .sub { margin-left: auto; font-size: 11px; color: var(--muted); }
.chat-body { flex: 1; overflow-y: auto; padding: 14px 14px 4px; }
.msg { font-size: 13.5px; line-height: 1.5; margin-bottom: 14px; max-width: 92%; }
.msg.user { margin-left: auto; background: var(--accent-soft); padding: 8px 12px; border-radius: 12px 12px 2px 12px; }
.msg.assistant { background: transparent; }
.msg.assistant cite { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); font-style: normal; }
.typing { font-size: 12px; color: var(--muted); padding: 0 4px 8px; height: 18px; }
.chat-input { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; background: var(--bg); }
.suggest { border: 1px solid var(--line); background: var(--paper); border-radius: 100px; padding: 5px 10px; font-size: 11.5px; color: var(--ink); cursor: pointer; font-family: var(--sans); }
.suggest:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { background: var(--paper); border-top: 1px solid var(--line); margin-top: 60px; }
.site-footer .inner { max-width: var(--maxw); margin: 0 auto; padding: 36px 24px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; font-size: 13px; }
@media (max-width: 800px) { .site-footer .inner { grid-template-columns: 1fr 1fr; } }
.site-footer h6 { font-family: var(--sans); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.site-footer a { color: var(--soft-ink); display: block; padding: 3px 0; }
.site-footer a:hover { color: var(--accent); }
.site-footer .colophon { font-size: 12px; color: var(--muted); margin-top: 12px; }
.legal { max-width: var(--maxw); margin: 0 auto; padding: 16px 24px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* TOC page list */
.toc-page-list { font-family: var(--sans); display: flex; flex-direction: column; gap: 2px; margin: 24px 0; }
.toc-page-list a { display: flex; padding: 10px 14px; border-radius: 8px; color: var(--ink); border: 1px solid transparent; }
.toc-page-list a:hover { background: var(--paper); border-color: var(--line); text-decoration: none; }
.toc-page-list a .num { width: 60px; color: var(--muted); font-size: 12px; }
.toc-page-list a .title { flex: 1; }
.toc-page-list a .read { font-size: 11px; color: var(--muted); }
.toc-page-list .group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 18px 14px 4px; font-weight: 700; }
