/* =============================================
   CivilsWisdom — Design System CSS
   Full rewrite: editorial briefing aesthetic
   ============================================= */

/* ===========================================
   1. DESIGN TOKENS & RESET
   =========================================== */

:root {
  /* Light theme — warm paper */
  --bg: #f6f1e7;
  --bg-elevated: #fbf7ee;
  --bg-sunken: #efe8d9;
  --ink: #0b1c2c;
  --ink-2: #2a3a4a;
  --ink-3: #5a6676;
  --ink-4: #8a8578;
  --rule: #d9d0bc;
  --rule-strong: #b9ad92;
  --accent: #0b2545;
  --accent-ink: #ffffff;
  --chip-bg: #eee5d0;
  --chip-ink: #2a3a4a;
  --mark: #f5d77a66;

  /* Typography stacks — native system fonts only (no web font downloads) */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --serif: var(--sans); /* legacy alias — headings use the sans stack now */

  /* Type scale */
  --fs-body: 18px;
  --lh-body: 1.65;
  --gap: 24px;
  --col-max: 720px;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elevated: #15181f;
  --bg-sunken: #0a0c10;
  --ink: #ece7dc;
  --ink-2: #c6c1b6;
  --ink-3: #8a8578;
  --ink-4: #5e5a50;
  --rule: #23262d;
  --rule-strong: #323640;
  --chip-bg: #1b1f27;
  --chip-ink: #d4cfc3;
  --mark: #d4a84b33;
}

[data-density="compact"] {
  --fs-body: 16px;
  --lh-body: 1.55;
  --gap: 16px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01","cv11";
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: var(--accent-ink); }

img { max-width: 100%; height: auto; }


/* ===========================================
   2. SHARED COMPONENTS
   =========================================== */

/* ---------- TOPBAR (sticky, glassmorphic) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
}

/* Brand mark + wordmark */
.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: block;
}

.brand-mark .mk-bg { fill: var(--ink); }
.brand-mark .mk-fg { fill: var(--bg); font-family: var(--sans); }
.brand-mark .mk-accent { fill: var(--accent); }
.brand-mark .mk-rule { stroke: var(--bg); stroke-width: 1.2; }

.brand-wm {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  line-height: 1;
}

.brand .dot { color: var(--accent); }

/* Navigation links */
.nav {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  flex: 1;
}

.nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.nav a:hover { background: var(--bg-sunken); color: var(--ink); }
.nav a.active { color: var(--ink); }

/* Topbar meta + live dot */
.topbar-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Buttons */
.btn {
  font: 600 14.5px var(--sans);
  padding: 13px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform .1s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}

.btn-secondary:hover { background: var(--bg-sunken); }

.btn .arrow { font-family: var(--mono); }

.topbar-btn {
  font: 500 13px var(--sans);
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s;
}

.topbar-btn:hover { background: var(--bg-sunken); }

.topbar-cta {
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 8px 14px;
  font-weight: 600;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink-2);
  cursor: pointer;
  transition: color .15s, background .15s;
}

.icon-btn:hover { color: var(--ink); background: var(--bg-sunken); }
.icon-btn.is-on, .icon-btn.bookmarked { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

/* Subnav (topic links) */
.subnav {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.subnav::-webkit-scrollbar { display: none; }

.subnav-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  gap: 2px;
  padding: 0 20px;
}

.subnav a {
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  padding: 12px 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}

.subnav a:hover { color: var(--ink); }
.subnav a.is-active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- FOOTER ---------- */
footer.site {
  padding: 60px 28px 40px;
  border-top: 1px solid var(--rule);
  margin-top: 60px;
  background: var(--bg-sunken);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}

footer h5 {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin: 0 0 14px;
}

footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

footer a { color: var(--ink-2); font-size: 14px; }
footer a:hover { color: var(--ink); }

.footer-brand p {
  font-size: 14px;
  color: var(--ink-3);
  max-width: 36ch;
  margin: 12px 0 0;
}

.footer-bottom {
  max-width: 1280px;
  margin: 40px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---------- TWEAKS PANEL ---------- */
.tweaks-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,.25);
  z-index: 80;
  display: none;
  font-size: 13px;
}

.tweaks-panel.is-open { display: block; }

.tweaks-panel h5 {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tweaks-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  gap: 12px;
}

.tweaks-row label {
  font-size: 12px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
}

.seg {
  display: inline-flex;
  background: var(--bg-sunken);
  border-radius: 6px;
  padding: 2px;
}

.seg button {
  font: 500 11px var(--mono);
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.seg button.is-on {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.swatches { display: flex; gap: 6px; }

.swatches button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color .15s;
}

.swatches button.is-on { border-color: var(--ink); }


/* ===========================================
   3. HOMEPAGE
   =========================================== */

/* Shell */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- HERO ---------- */
.hero {
  padding: 48px 0 40px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.hero-date {
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.hero-date .pill {
  background: var(--ink);
  color: var(--bg);
  padding: 4px 9px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.hero h1 {
  font-family: var(--sans);
  font-size: clamp(28px, 3.4vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0 0 20px;
  text-wrap: balance;
  max-width: 22ch;
}

.hero h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.hero-lede {
  font-size: 18.5px;
  color: var(--ink-2);
  max-width: 46ch;
  margin: 0 0 28px;
  line-height: 1.5;
}

.hero-ctas { display: flex; gap: 10px; flex-wrap: wrap; }

/* Hero — today card */
.today-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}

.today-card > header {
  padding: 12px 18px;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.today-card > header .count {
  color: color-mix(in srgb, var(--bg) 60%, transparent);
}

.today-list { list-style: none; padding: 0; margin: 0; }

.today-list > li {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
  transition: background .15s;
}

.today-list > li:last-child { border: none; }
.today-list > li:hover { background: var(--bg-sunken); }

.today-list .n {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
  letter-spacing: 0.06em;
}

.today-list .t {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  text-wrap: balance;
}

.today-list .meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.today-list .meta .gs {
  padding: 2px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  color: var(--ink-2);
}

.today-list .time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}

.today-card > footer {
  padding: 12px 18px;
  border-top: 1px solid var(--rule);
  background: var(--bg-sunken);
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.today-card > footer a { color: var(--ink); font-weight: 600; }
.today-card > footer a:hover { color: var(--accent); }

/* ---------- SECTION HEADER ---------- */
.section { padding: 72px 0 48px; border-bottom: 1px solid var(--rule); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-head .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.section-head h2 {
  font-family: var(--sans);
  font-size: clamp(26px, 2.6vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0;
  max-width: 20ch;
  text-wrap: balance;
}

.section-head p {
  margin: 0;
  color: var(--ink-3);
  max-width: 42ch;
  font-size: 15px;
}

/* ---------- HOW IT WORKS — centered tree + modern cards ---------- */
.how-section { padding-top: 80px; padding-bottom: 80px; }

.how-head {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 48px;
}
.how-head .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.how-head h2 {
  font-family: var(--sans);
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.08;
  color: var(--ink);
  margin: 0 auto 14px;
  text-wrap: balance;
  max-width: 22ch;
}
.how-head .how-sub {
  font-size: 16.5px;
  color: var(--ink-2);
  margin: 14px auto 0;
  line-height: 1.55;
  max-width: 56ch;
}

.how-tree {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
}

/* Source card (centered, on top) */
.tree-source {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  max-width: 480px;
  text-align: center;
}
.tree-source .tree-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.tree-source .tree-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.35;
}

/* Connecting branches */
.tree-branches {
  display: block;
  width: 100%;
  height: 64px;
  margin: 4px 0 0;
}
.tree-branches path {
  fill: none;
  stroke: var(--rule-strong);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.7;
}

/* Leaves row — 3 modern cards */
.tree-leaves {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.leaf-card {
  position: relative;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg) 100%);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "tag    num"
    "title  num"
    "source source";
  align-items: start;
  column-gap: 14px;
  row-gap: 6px;
  cursor: default;
  transition: transform 0.28s ease, border-color 0.28s ease, box-shadow 0.32s ease;
  overflow: hidden;
}
.leaf-card::after {
  content: '';
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  border-radius: 0 3px 3px 0;
  transition: opacity 0.28s ease;
}
.leaf-card:hover {
  transform: translateY(-2px);
  border-color: var(--rule-strong);
  box-shadow: 0 14px 32px -18px rgba(11, 28, 44, 0.22);
}
.leaf-card:hover::after { opacity: 0.85; }

.leaf-card .leaf-num {
  grid-area: num;
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--rule-strong);
  letter-spacing: -0.03em;
  line-height: 1;
  align-self: start;
  user-select: none;
}
.leaf-card .leaf-tag {
  grid-area: tag;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.leaf-card .leaf-title {
  grid-area: title;
  font-family: var(--sans);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0;
}
.leaf-card .leaf-source {
  grid-area: source;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.leaf-card .leaf-source > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaf-card .leaf-arrow {
  color: var(--ink-3);
  font-size: 14px;
  font-family: var(--sans);
  transition: transform 0.28s ease, color 0.28s ease;
  flex-shrink: 0;
}
.leaf-card:hover .leaf-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* Responsive */
@media (max-width: 880px) {
  .tree-leaves { grid-template-columns: 1fr 1fr; }
  .tree-leaves .leaf-card:nth-child(3) { grid-column: span 2; }
}
@media (max-width: 640px) {
  .how-section { padding-top: 56px; padding-bottom: 56px; }
  .how-head { margin-bottom: 32px; }
  .how-tree { padding: 0 18px; }
  .tree-source { max-width: 100%; }
  .tree-branches { display: none; }
  .tree-leaves {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 16px;
  }
  .tree-leaves .leaf-card:nth-child(3) { grid-column: auto; }
  .leaf-card .leaf-num { font-size: 26px; }
}

/* ---------- TOPICS GRID ---------- */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.topic {
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s, transform .1s;
}

.topic:hover { border-color: var(--accent); transform: translateY(-1px); }

.topic .k {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topic .t {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.2;
}

.topic .c {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 10px;
}

/* ---------- WEEK ARCHIVE ---------- */
.week {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.week-list { border-right: 1px solid var(--rule); }

.week-day {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  background: transparent;
  border-left: 3px solid transparent;
  width: 100%;
  text-align: left;
  color: var(--ink);
  font: inherit;
  transition: background .15s;
}

.week-day:last-child { border-bottom: none; }

.week-day .dm { font-size: 15px; font-weight: 600; }

.week-day .dm small {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.week-day .c {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
}

.week-day.is-active {
  background: var(--bg);
  border-left-color: var(--accent);
}

.week-day.is-active .dm { color: var(--ink); }
.week-day:hover:not(.is-active) { background: var(--bg); }

.week-detail { padding: 20px 24px; }

.week-detail h4 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.week-detail h4 strong { color: var(--ink); }

.week-items { list-style: none; padding: 0; margin: 0; }

.week-items li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule);
  align-items: baseline;
}

.week-items li:last-child { border-bottom: none; }

.week-items .wi-t { font-size: 15px; color: var(--ink); font-weight: 500; }

.week-items .wi-m {
  display: flex;
  gap: 6px;
  align-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}


/* ===========================================
   4. ARTICLE PAGE
   =========================================== */

/* Shell layout */
.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 28px 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 64px;
  align-items: start;
}

.article { min-width: 0; }
.sidebar { position: sticky; top: 96px; }

/* Breadcrumbs */
.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
  padding: 0;
}

.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { opacity: 0.5; }

/* Eyebrow chip + meta */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.eyebrow-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  border-radius: 4px;
}

.eyebrow-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 1px;
}

.eyebrow-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: inline-flex;
  gap: 12px;
  align-items: center;
}

.eyebrow-meta span + span::before {
  content: "\00b7";
  margin-right: 12px;
  color: var(--ink-4);
}

/* Headline + dek */
h1.headline {
  font-family: var(--sans);
  font-size: clamp(32px, 4.2vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--ink);
  text-wrap: balance;
  max-width: 20ch;
}

.dek {
  font-family: var(--serif);
  font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.45;
  color: var(--ink-2);
  max-width: 60ch;
  margin: 0 0 28px;
  font-weight: 500;
  font-style: italic;
}

/* Byline band */
.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--ink-3);
}

.byline-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.byline .gs-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  color: var(--ink);
  background: var(--bg-elevated);
}

.byline .gs-chip strong {
  color: var(--accent);
  font-weight: 700;
  margin-right: 4px;
}

.byline-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* TL;DR card */
.tldr {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 20px 24px;
  margin: 0 0 32px;
  max-width: var(--col-max);
  border-radius: 4px;
}

.tldr-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.tldr ul { margin: 0; padding: 0; list-style: none; }

.tldr li {
  padding: 6px 0 6px 20px;
  color: var(--ink);
  border: none;
  position: relative;
}

.tldr li::before { display: none; }

.tldr li::after {
  content: "\2192";
  position: absolute;
  left: 0;
  top: 6px;
  color: var(--accent);
  font-weight: 700;
}

/* Prose */
.prose { max-width: var(--col-max); }

.prose h2 {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink);
  margin: 48px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.prose h2 .num {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 12px;
}

.prose h3 {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 28px 0 10px;
  line-height: 1.25;
}

.prose p { margin: 0 0 16px; color: var(--ink-2); }
.prose p strong { color: var(--ink); }

.prose > ul { list-style: none; padding: 0; margin: 0 0 20px; }

.prose > ul > li {
  position: relative;
  padding: 6px 0 6px 26px;
  color: var(--ink-2);
  border-bottom: 1px dashed var(--rule);
}

.prose > ul > li:last-child { border-bottom: none; }

.prose > ul > li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 16px;
  width: 10px;
  height: 1px;
  background: var(--accent);
}

/* Topic bridges */
.bridges-intro {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 56px 0 20px;
  max-width: var(--col-max);
}

.bridges-intro .rule { flex: 1; height: 1px; background: var(--rule-strong); }

.bridges-intro .label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-weight: 600;
  white-space: nowrap;
}

.bridges-intro .label strong { color: var(--accent); font-weight: 600; }

.bridge {
  position: relative;
  max-width: var(--col-max);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 24px 28px 26px;
  margin: 0 0 20px;
}

.bridge::before {
  content: attr(data-num);
  position: absolute;
  top: -12px;
  left: 20px;
  background: var(--bg);
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.bridge-kicker {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 6px;
}

.bridge h3 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.005em;
}

.bridge p {
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.65;
}

.bridge-facts {
  list-style: none;
  padding: 12px 16px;
  margin: 0 0 14px;
  background: var(--bg-sunken);
  border-radius: 4px;
}

.bridge-facts li {
  position: relative;
  padding: 5px 0 5px 18px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.5;
  border: none;
}

.bridge-facts li::before {
  content: "\25b8";
  position: absolute;
  left: 0;
  top: 5px;
  color: var(--accent);
  font-size: 11px;
}

.bridge-connect {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 2px solid var(--accent);
  font-size: 14.5px;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  border-radius: 0 4px 4px 0;
}

.bridge-connect b {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

/* Key facts card */
.facts-card {
  max-width: var(--col-max);
  margin: 48px 0 0;
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  border-radius: 6px;
  overflow: hidden;
}

.facts-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--ink);
  color: var(--bg);
}

.facts-card header h2 {
  margin: 0;
  border: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: inherit;
  display: block;
}

.facts-card header .mini {
  font-family: var(--mono);
  font-size: 10.5px;
  color: color-mix(in srgb, var(--bg) 60%, transparent);
  letter-spacing: 0.1em;
}

.facts-grid { list-style: none; margin: 0; padding: 0; }

.facts-grid li {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.5;
}

.facts-grid li:last-child { border-bottom: none; }

.facts-grid .num {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.facts-grid .num small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Continue reading nav */
.next {
  max-width: var(--col-max);
  margin: 56px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.next a {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 18px;
  display: block;
  background: var(--bg-elevated);
  transition: border-color .15s;
}

.next a:hover { border-color: var(--rule-strong); }

.next .kicker {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.next .t { font-weight: 600; font-size: 15px; line-height: 1.35; color: var(--ink); }

/* Sidebar */
.toc { font-size: 13.5px; }

.toc .toc-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}

.toc li { counter-increment: toc; }

.toc a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 2px 8px 10px;
  color: var(--ink-3);
  line-height: 1.35;
  border-left: 2px solid transparent;
  transition: color .15s;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
  flex-shrink: 0;
}

.toc a:hover { color: var(--ink); }

.toc a.is-active {
  color: var(--ink);
  border-left-color: var(--accent);
}

.toc a.is-active::before { color: var(--accent); }

.toc .toc-sub {
  padding-left: 36px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.toc .toc-sub a { padding: 5px 2px 5px 10px; }

.side-card {
  margin-top: 32px;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-elevated);
}

.side-card h4 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.side-card .pgs { display: flex; flex-direction: column; gap: 6px; }

.side-card .pg {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: var(--ink-2);
}

.side-card .pg b {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

/* Read progress bar */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  z-index: 50;
  pointer-events: none;
}

.read-progress .bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .1s linear;
}

/* Mobile action bar */
.mobile-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--rule);
  z-index: 35;
  padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
}

.mobile-bar-inner {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
}

.mobile-bar button {
  background: transparent;
  border: none;
  color: var(--ink-2);
  cursor: pointer;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font: 500 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 8px;
}

.mobile-bar button svg { width: 18px; height: 18px; }
.mobile-bar button:hover,
.mobile-bar button.is-on { color: var(--accent); }

/* Mobile TOC sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 60;
}

.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--rule);
  border-radius: 16px 16px 0 0;
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.2,.7,.2,1);
  z-index: 65;
  max-height: 75vh;
  overflow-y: auto;
}

.sheet.is-open { transform: translateY(0); }

.sheet .grip {
  width: 36px;
  height: 4px;
  background: var(--rule-strong);
  border-radius: 2px;
  margin: 0 auto 14px;
}


/* ===========================================
   5. TOPIC LISTING PAGE
   =========================================== */

/* Topic header */
.topic-head {
  padding: 32px 0 40px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 56px;
  align-items: end;
}

.topic-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.gs-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  border-radius: 4px;
}

.gs-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 1px;
}

.topic-eyebrow .label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-weight: 500;
}

.topic-head h1 {
  font-family: var(--sans);
  font-size: clamp(40px, 5vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 700;
  margin: 0 0 18px;
  text-wrap: balance;
}

.topic-lede {
  font-size: 18px;
  color: var(--ink-2);
  max-width: 48ch;
  margin: 0;
  line-height: 1.5;
}

/* Stat card */
.stat-card {
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}

.stat-card header {
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}

.stat-row:last-child { border-bottom: none; }

.stat-row .k {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.stat-row .v {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Sticky filter bar */
.filters {
  position: sticky;
  top: 100px;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 20px;
  align-items: center;
}

.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  padding: 2px;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 7px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}

.chip:hover { color: var(--ink); }

.chip.is-on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.chip .n {
  margin-left: 6px;
  color: var(--ink-4);
  font-size: 10.5px;
}

.chip.is-on .n { color: color-mix(in srgb, var(--bg) 60%, transparent); }

.sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  cursor: pointer;
  border: 1px solid transparent;
  padding: 7px 10px;
  border-radius: 6px;
  white-space: nowrap;
  background: transparent;
}

.sort:hover { border-color: var(--rule-strong); color: var(--ink); }
.sort svg { width: 12px; height: 12px; }

/* Month sections */
.month { padding: 36px 0 8px; }

.month-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 4px;
}

.month-head .m-date {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.015em;
  color: var(--ink);
  font-style: italic;
}

.month-head .m-meta {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

.month-head .line { flex: 1; height: 1px; background: var(--rule); }

/* Article grid (2-column with day column) */
.arts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--rule);
}

.art {
  padding: 22px 24px 22px 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 16px;
  align-items: baseline;
  cursor: pointer;
  transition: background .15s;
}

.art:nth-child(2n) {
  padding-left: 24px;
  padding-right: 0;
  border-left: 1px solid var(--rule);
  margin-left: -1px;
}

.art:hover { background: var(--bg-elevated); }

.art .d {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding-top: 4px;
}

.art .d .day {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 4px;
  font-family: var(--sans);
}

.art h3 {
  font-family: var(--sans);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0 0 10px;
  text-wrap: balance;
  color: var(--ink);
}

.art p {
  margin: 0 0 12px;
  font-size: 14.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

.art .tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.art .tags span {
  padding: 3px 7px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
}

.art .tags .gs strong { color: var(--accent); font-weight: 700; }

.art .read {
  font-family: var(--mono);
  color: var(--ink-4);
  padding: 3px 0;
}

/* Pagination */
.pagination {
  padding: 40px 0 80px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--rule);
  margin-top: 20px;
}

.pagination .status {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}


/* ===========================================
   6. AUTH COMPONENTS
   =========================================== */

/* Header auth buttons */
#cw-user-slot {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.cw-login-btn {
  font: 500 13px var(--sans);
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.cw-login-btn:hover {
  background: var(--bg-sunken);
  color: var(--ink);
}

.cw-signup-btn {
  font: 600 13px var(--sans);
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  transition: background .15s;
}

.cw-signup-btn:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
}

/* Modal overlay */
.cw-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Modal box */
.cw-modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 32px 28px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,.25);
  animation: cwModalIn 0.2s ease;
}

@keyframes cwModalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal header + close */
.cw-modal-header {
  margin-bottom: 20px;
}

.cw-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 22px;
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .15s, color .15s;
}

.cw-modal-close:hover {
  background: var(--bg-sunken);
  color: var(--ink);
}

.cw-modal-logo {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 4px;
}

.cw-modal-title {
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 20px;
}

/* Form fields */
.cw-form-group {
  margin-bottom: 16px;
}

.cw-form-group label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.cw-form-group input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  font-family: var(--sans);
  transition: border-color .15s;
  outline: none;
}

.cw-form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.cw-form-group input::placeholder { color: var(--ink-4); }

/* Submit button */
.cw-btn-submit,
.cw-submit-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  font: 600 15px var(--sans);
  cursor: pointer;
  transition: background .15s, transform .1s;
  margin-top: 4px;
}

.cw-btn-submit:hover:not(:disabled),
.cw-submit-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
  transform: translateY(-1px);
}

.cw-btn-submit:disabled,
.cw-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modal switch (login/signup toggle) */
.cw-modal-switch {
  color: var(--accent);
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--sans);
  text-decoration: underline;
}

.cw-modal-switch:hover { opacity: 0.8; }

.cw-modal-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
}

/* Error display */
.cw-modal-error {
  color: #DC2626;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  min-height: 0;
}

.cw-modal-error:empty { display: none; }

/* User menu */
.cw-user-menu { position: relative; }

.cw-user-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: box-shadow .15s;
}

.cw-user-btn:hover {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.cw-user-avatar {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  line-height: 1;
}

.cw-user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,.25);
  z-index: 200;
  padding: 8px 0;
}

.cw-user-dropdown.open { display: block; }

.cw-user-info {
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cw-user-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.cw-user-email { font-size: 12px; color: var(--ink-3); }

.cw-dropdown-divider {
  height: 1px;
  background: var(--rule);
  margin: 4px 0;
}

.cw-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .1s, color .1s;
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--sans);
}

.cw-dropdown-item:hover {
  background: var(--bg-sunken);
  color: var(--ink);
}

.cw-logout-btn { color: #DC2626; }
.cw-logout-btn:hover { background: color-mix(in srgb, #DC2626 6%, var(--bg)); color: #DC2626; }

/* Mobile auth */
.cw-mobile-signup {
  background: var(--ink);
  color: var(--bg) !important;
  border-radius: 8px;
  text-align: center;
  margin-top: 4px;
}

.cw-mobile-signup:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
}

.cw-mobile-logout {
  color: #DC2626 !important;
  background: none;
  border: none;
  font-family: var(--sans);
  cursor: pointer;
}

/* Read indicator */
.cw-read { opacity: 0.55; }
.cw-read .card-title,
.cw-read .t,
.cw-read .wi-t { color: var(--ink-3); }

.cw-read-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  font-size: 11px;
}

/* Bookmark button on article page */
.cw-bookmark-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-2);
  font: 500 13px var(--sans);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.cw-bookmark-btn:hover {
  background: var(--bg-sunken);
  color: var(--ink);
}

.cw-bookmark-btn.bookmarked {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Signup CTA buttons */
.cw-cta-signup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font: 600 14.5px var(--sans);
  border: none;
  cursor: pointer;
  transition: transform .1s;
}

.cw-cta-signup:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
}

.cw-cta-signup:active { transform: translateY(1px); }

/* Signup section (homepage) */
.cw-signup-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 28px;
  text-align: center;
}

.cw-signup-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 40px 32px;
}

.cw-signup-card h2 {
  font-weight: 700;
  font-size: 24px;
  color: var(--ink);
  margin: 0 0 8px;
}

.cw-signup-card p {
  font-size: 15px;
  color: var(--ink-3);
  margin-bottom: 24px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.cw-features-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.cw-feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}

.cw-feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ===========================================
   7. QUIZ PAGE
   =========================================== */

.quiz-container,
.quiz-section {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

/* Listing view */
.quiz-listing { margin-bottom: 28px; }

.quiz-listing-header { margin-bottom: 28px; }

.quiz-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.quiz-subtitle {
  font-size: 14px;
  color: var(--ink-3);
  margin-top: 4px;
}

.quiz-section-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 14px;
}

/* Date grid */
.quiz-date-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.quiz-date-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  text-decoration: none;
  color: inherit;
}

.quiz-date-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.quiz-date-card-done { border-color: color-mix(in srgb, #059669 40%, var(--rule)); }
.quiz-date-card-partial { border-color: color-mix(in srgb, #D97706 40%, var(--rule)); }

.quiz-date-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quiz-date-card-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.quiz-date-card-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quiz-date-card-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
}

/* Calendar */
.quiz-calendar {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px;
  max-width: 420px;
}

.quiz-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quiz-cal-month { font-size: 16px; font-weight: 700; color: var(--ink); }

.quiz-cal-nav {
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  color: var(--ink-3);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s;
}

.quiz-cal-nav:hover { border-color: var(--accent); color: var(--accent); }

.quiz-cal-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.quiz-cal-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
}

.quiz-cal-dot { width: 16px; height: 16px; border-radius: 4px; }
.quiz-cal-dot-done { background: color-mix(in srgb, #059669 15%, var(--bg)); border: 1.5px solid #059669; }
.quiz-cal-dot-partial { background: color-mix(in srgb, #D97706 15%, var(--bg)); border: 1.5px solid #D97706; }
.quiz-cal-dot-new { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); border: 1.5px solid var(--accent); }

.quiz-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.quiz-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.quiz-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-3);
  border-radius: 6px;
  position: relative;
}

.quiz-cal-day-empty { visibility: hidden; }
.quiz-cal-day-disabled { opacity: 0.3; }

.quiz-cal-day-clickable {
  cursor: pointer;
  font-weight: 600;
  transition: transform .15s;
}

.quiz-cal-day-clickable:hover { transform: scale(1.12); }

.quiz-cal-day-done {
  background: color-mix(in srgb, #059669 15%, var(--bg));
  color: #059669;
  border: 1.5px solid color-mix(in srgb, #059669 40%, transparent);
}

.quiz-cal-day-partial {
  background: color-mix(in srgb, #D97706 15%, var(--bg));
  color: #D97706;
  border: 1.5px solid color-mix(in srgb, #D97706 40%, transparent);
}

.quiz-cal-day-new {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.quiz-cal-day-today { box-shadow: inset 0 0 0 2px var(--accent); }

/* Quiz taking */
.quiz-taking { margin-bottom: 20px; }
.quiz-taking-header { margin-bottom: 8px; }

.quiz-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  margin-bottom: 16px;
  font: 500 14px var(--sans);
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
}

.quiz-back-btn:hover { opacity: 0.7; }

.quiz-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.quiz-date {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.quiz-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.quiz-progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.quiz-progress-text { font-size: 13px; color: var(--ink-3); }

/* Question card */
.quiz-question,
.quiz-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  transition: border-color .2s;
}

.quiz-card:not(.quiz-card-answered):hover,
.quiz-question:hover { border-color: var(--rule-strong); }
.quiz-card-answered { border-color: var(--rule); }

.quiz-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.quiz-q-number {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  padding: 3px 10px;
  border-radius: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quiz-q-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-q-topic {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
}

/* Difficulty badges */
.quiz-difficulty,
.quiz-q-diff {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 3px;
}

.quiz-difficulty-easy,
.quiz-q-diff-easy { color: #059669; background: color-mix(in srgb, #059669 10%, var(--bg)); }
.quiz-difficulty-medium,
.quiz-q-diff-medium { color: #D97706; background: color-mix(in srgb, #D97706 10%, var(--bg)); }
.quiz-difficulty-hard,
.quiz-q-diff-hard { color: #DC2626; background: color-mix(in srgb, #DC2626 10%, var(--bg)); }

.quiz-q-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  margin-bottom: 20px;
  white-space: pre-line;
}

/* Options */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  width: 100%;
}

.quiz-option:hover:not(.quiz-option-correct):not(.quiz-option-wrong):not(.quiz-option-disabled):not(.correct):not(.wrong) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
}

.quiz-option.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
}

.quiz-option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  background: var(--bg-sunken);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 1px;
}

.quiz-option-text { flex: 1; }
.quiz-option-icon { flex-shrink: 0; margin-top: 2px; }

/* Answered states */
.quiz-option.correct,
.quiz-option-correct {
  border-color: #059669;
  background: color-mix(in srgb, #059669 8%, var(--bg));
  cursor: default;
}

.quiz-option.correct .quiz-option-key,
.quiz-option-correct .quiz-option-key { background: #059669; color: #fff; }

.quiz-option.wrong,
.quiz-option-wrong {
  border-color: #DC2626;
  background: color-mix(in srgb, #DC2626 8%, var(--bg));
  cursor: default;
}

.quiz-option.wrong .quiz-option-key,
.quiz-option-wrong .quiz-option-key { background: #DC2626; color: #fff; }

.quiz-option-disabled { opacity: 0.5; cursor: default; }

/* Explanation */
.quiz-explanation {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.quiz-result {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.quiz-result-correct { background: color-mix(in srgb, #059669 10%, var(--bg)); color: #059669; }
.quiz-result-wrong { background: color-mix(in srgb, #DC2626 10%, var(--bg)); color: #DC2626; }

/* Explanation content */
.quiz-expl-content { margin-bottom: 12px; }
.quiz-expl-content h1 { display: none; }

.quiz-detail-section {
  margin-top: 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}

.quiz-detail-section summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font: 600 13px var(--sans);
  color: var(--ink-2);
  cursor: pointer;
  background: var(--bg-sunken);
  user-select: none;
}

.quiz-detail-section summary:hover { color: var(--accent); }

.quiz-detail-body { padding: 14px 16px; }

/* Scale down headings inside quiz explanations */
.quiz-explanation .article-content h2 {
  font-size: 16px;
  margin-top: 18px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom-width: 1px;
}

.quiz-explanation .article-content h3 {
  font-size: 15px;
  margin-top: 14px;
  margin-bottom: 6px;
}

.quiz-explanation .article-content p {
  font-size: 14px;
  margin-bottom: 10px;
  line-height: 1.7;
}

.quiz-explanation .article-content li {
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.65;
}

.quiz-explanation .article-content ul,
.quiz-explanation .article-content ol {
  margin-bottom: 10px;
  padding-left: 20px;
}

/* Submit / Next buttons */
.quiz-submit-btn,
.quiz-next-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  font: 600 14px var(--sans);
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.quiz-submit-btn:hover,
.quiz-next-btn:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
}

.quiz-submit-btn:active,
.quiz-next-btn:active { transform: translateY(1px); }

.quiz-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Score card */
.quiz-score-card {
  background: var(--bg-elevated);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 32px;
  margin-bottom: 28px;
  text-align: center;
}

.quiz-score-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-bottom: 20px;
}

.quiz-score-ring-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.quiz-score-ring { width: 100%; height: 100%; }

.quiz-score-pct {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.quiz-score-text h2 { font-size: 20px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.quiz-score-text p { font-size: 14px; color: var(--ink-3); margin: 0; }

.quiz-score-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Upgrade prompt */
.quiz-upgrade-prompt,
.quiz-upgrade {
  margin-top: 8px;
  margin-bottom: 20px;
}

.quiz-upgrade-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

/* Quiz stats */
.quiz-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-stats > div {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
}

.quiz-stats .stat-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.quiz-stats .stat-label {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Auth gate */
.quiz-auth-gate {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.quiz-auth-gate h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}

.quiz-auth-gate p {
  font-size: 15px;
  color: var(--ink-3);
  margin: 0 0 20px;
}

/* Loading */
.quiz-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--ink-3);
  font-size: 14px;
}

.quiz-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: quiz-spin 0.7s linear infinite;
}

@keyframes quiz-spin {
  to { transform: rotate(360deg); }
}


/* ===========================================
   8. DASHBOARD
   =========================================== */

.dash-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

.dash-greeting {
  margin-bottom: 24px;
}

.dash-greeting h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
}

.dash-greeting p {
  font-size: 14px;
  color: var(--ink-3);
  margin: 0;
}

/* Today's progress card */
.dash-today-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.dash-progress-ring {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

/* Stat grid */
.dash-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.dash-stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.dash-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  color: var(--accent);
}

.dash-stat-value {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 28px;
  color: var(--ink);
  line-height: 1.1;
}

.dash-stat-label {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Heatmap card */
.dash-heatmap-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}

.dash-heatmap-grid {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dash-heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dash-heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  transition: opacity .15s;
}

.dash-heatmap-cell:hover { opacity: 0.8; }

.dash-heatmap-l0 { background: var(--rule); }
.dash-heatmap-l1 { background: color-mix(in srgb, var(--accent) 30%, var(--bg)); }
.dash-heatmap-l2 { background: color-mix(in srgb, var(--accent) 55%, var(--bg)); }
.dash-heatmap-l3 { background: var(--accent); }

.dash-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
}

.dash-heatmap-legend .dash-heatmap-cell { width: 12px; height: 12px; }

/* Topic card */
.dash-topic-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}

.dash-topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dash-topic-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

/* Filter pills */
.dash-pills {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-sunken);
  border-radius: 6px;
  padding: 2px;
}

.dash-pill {
  font: 500 11px var(--mono);
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.dash-pill:hover { color: var(--ink); }

.dash-pill.active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* Topic list */
.dash-topic-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-topic-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  transition: border-color .15s, background .15s;
}

.dash-topic-row:hover {
  border-color: var(--rule-strong);
  background: var(--bg-sunken);
}

.dash-topic-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--rule);
  overflow: hidden;
}

.dash-topic-bar > div {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}

/* Topic alerts */
.dash-topic-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.dash-topic-alerts > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
}

/* Recent card */
.dash-recent-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}

.dash-recent-list { display: flex; flex-direction: column; }

.dash-recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  transition: background .1s;
}

.dash-recent-item:last-child { border-bottom: none; }

.dash-recent-item:hover {
  background: var(--bg-sunken);
  margin: 0 -24px;
  padding: 12px 24px;
  border-radius: 6px;
}

.dash-recent-item .title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.dash-recent-item .date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
  flex-shrink: 0;
}

/* Auth gate */
.dash-auth-gate {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.dash-auth-gate h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}

.dash-auth-gate p {
  font-size: 15px;
  color: var(--ink-3);
  margin: 0 0 20px;
}


/* ===========================================
   9. BOOKMARKS
   =========================================== */

.bk-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 28px 64px;
}

.bk-header { margin-bottom: 24px; }

.bk-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px;
}

.bk-header p {
  font-size: 14px;
  color: var(--ink-3);
  margin: 0;
}

/* Filters */
.bk-filters {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.bk-date-inputs {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.bk-date-inputs label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.bk-date-inputs input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

.bk-date-inputs input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.bk-quick-btns { display: flex; gap: 8px; }

.bk-quick-btn {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font: 500 13px var(--sans);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.bk-quick-btn:hover { border-color: var(--accent); color: var(--accent); }

.bk-quick-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* Views */
.bk-view-overview { margin-bottom: 24px; }
.bk-view-drilldown { margin-bottom: 24px; }

/* Topic table */
.bk-topic-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}

.bk-topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--rule);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: background .15s;
  width: 100%;
  text-align: left;
  font: inherit;
}

.bk-topic-row:last-child { border-bottom: none; }
.bk-topic-row:hover { background: var(--bg-sunken); }

/* Drilldown */
.bk-drilldown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.bk-drilldown-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.bk-drilldown-list { display: flex; flex-direction: column; }

.bk-drilldown-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font-size: 14px;
  transition: color .15s;
}

.bk-drilldown-list a:last-child { border-bottom: none; }
.bk-drilldown-list a:hover { color: var(--accent); }

/* Auth gate */
.bk-auth-gate {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.bk-auth-gate h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}

.bk-auth-gate p {
  font-size: 15px;
  color: var(--ink-3);
  margin: 0 0 20px;
}

/* Undo toast */
.bk-undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  font-size: 14px;
  z-index: 1000;
  transition: all .2s ease;
  white-space: nowrap;
}

.bk-undo-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ===========================================
   10. DATE ARCHIVE, TOPICS INDEX, ARCHIVE INDEX, WEEKLY
   =========================================== */

/* Shared page title bar */
.page-title-bar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 0;
}

.page-title-bar h1 {
  font-size: clamp(26px, 2.6vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 4px;
}

.page-title-bar .page-subtitle {
  font-size: 14px;
  color: var(--ink-3);
}

/* Date archive */
.archive-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}

.archive-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 24px;
}

.archive-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  margin-bottom: 6px;
  transition: border-color .15s;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elevated);
}

.archive-date-row:hover { border-color: var(--accent); }

.archive-date-label { font-weight: 600; font-size: 15px; color: var(--ink); }
.archive-date-count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* Topics index (reuse homepage grid) */
.topic-browse-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 28px 64px;
}

.topic-card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.topic-card {
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .1s;
}

.topic-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.topic-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  color: var(--accent);
}

.topic-card-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}

.topic-card-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 6px;
}

.topic-card-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
  flex: 1;
}

.topic-card-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topic-card-link { font-size: 13px; font-weight: 600; color: var(--accent); }

/* Section headers */
.section-header { text-align: center; margin-bottom: 32px; }
.section-title { font-size: 24px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.section-subtitle { font-size: 15px; color: var(--ink-3); }

/* Archive index — week headers */
.week-preview-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px 64px;
}

.week-preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.week-date-group { margin-bottom: 28px; }

.week-date-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.week-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.week-date-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* Article grid (2-col fallback for old templates) */
.article-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.article-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 20px;
  transition: border-color .15s, transform .1s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.article-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-topic-row { display: flex; flex-wrap: wrap; gap: 5px; }

.topic-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-reading-time {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
}

.card-title {
  font-weight: 700;
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink);
}

.card-description {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-gs-papers { display: flex; gap: 4px; }

.gs-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

.card-read-more { font-size: 13px; font-weight: 600; color: var(--accent); }
.card-date-badge { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }

/* Date group headers */
.date-group-header {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: -4px;
}

.date-group-header:first-child { padding-top: 0; }

/* Weekly page (day-grouped articles) */
.week-article-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.week-article-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  transition: border-color .15s;
  text-decoration: none;
  color: inherit;
}

.week-article-item:hover { border-color: var(--accent); }

.week-article-border {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  align-self: stretch;
  background: var(--accent);
}

.week-article-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.week-article-topic {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: flex-start;
}

.week-article-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.week-article-item:hover .week-article-title { color: var(--accent); }

.week-article-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.week-article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
}

/* Week-view read indicator */
.week-article-item.cw-read { position: relative; }
.week-article-item.cw-read .week-article-title { color: var(--ink-3); }
.week-article-item.cw-read .cw-read-check { top: 10px; right: 10px; }

/* Pagination (alternative compact form) */
.page-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-2);
  font: 500 14px var(--sans);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }

.page-indicator { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 24px;
}

.empty-state-text { font-weight: 700; font-size: 18px; color: var(--ink-3); }

/* Old breadcrumb (for legacy templates) */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { color: var(--ink-4); opacity: 0.5; font-size: 11px; }
.breadcrumb .current { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }

/* Article content (rendered markdown for existing templates) */
.article-content { overflow-wrap: break-word; word-wrap: break-word; }
.article-content img { max-width: 100%; height: auto; border-radius: 6px; }

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  overflow-x: auto;
  display: block;
}

.article-content th,
.article-content td {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  text-align: left;
}

.article-content th {
  background: var(--bg-sunken);
  font-weight: 600;
  color: var(--ink);
}

.article-content code {
  background: var(--bg-sunken);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--ink-2);
  font-family: var(--mono);
}

.article-content pre {
  background: var(--bg-sunken);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

.article-content pre code { background: none; padding: 0; }

.article-content h1 { display: none; }
.article-content .meta-block { display: none; }

.article-content h2 {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink);
  margin: 48px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  line-height: 1.3;
}

.article-content h3 {
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  margin: 28px 0 10px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.article-content h4 {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  margin: 20px 0 6px;
}

.article-content p {
  margin-bottom: 14px;
  color: var(--ink-2);
  line-height: 1.7;
}

.article-content strong { color: var(--ink); font-weight: 600; }

.article-content ul,
.article-content ol {
  margin-bottom: 14px;
  padding-left: 24px;
}

.article-content li {
  margin-bottom: 6px;
  color: var(--ink-2);
  line-height: 1.7;
}

.article-content li strong { color: var(--ink); }

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 20px 0;
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: var(--ink-2);
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 28px 0;
}

/* Key details / connection boxes */
.key-details-box {
  background: var(--bg-sunken);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 12px 0 16px;
}

.key-details-box p { margin-bottom: 6px; font-size: 14px; }
.key-details-box p:last-child { margin-bottom: 0; }
.key-details-box ul { margin-bottom: 6px; padding-left: 20px; }
.key-details-box li { font-size: 14px; margin-bottom: 4px; line-height: 1.6; }

.connection-box {
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
  border-radius: 0 6px 6px 0;
  padding: 14px 18px;
  margin: 8px 0 20px;
}

.connection-box p { margin-bottom: 0; font-size: 15px; color: var(--ink-2); }
.connection-box strong { color: var(--accent); }

/* Old header (for legacy templates that still use .header) */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left { display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 8px; }

.logo {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}

.logo:hover { color: var(--ink); }
.logo-dot { color: var(--accent); }

.header-nav { display: flex; align-items: center; gap: 4px; }

.nav-link {
  padding: 8px 12px;
  border-radius: 8px;
  font: 500 14px var(--sans);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s;
  background: transparent;
  border: none;
  white-space: nowrap;
  text-decoration: none;
}

.nav-link:hover { background: var(--bg-sunken); color: var(--ink); }
.nav-link.active { color: var(--ink); background: var(--bg-sunken); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.dark-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-3);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  line-height: 1;
}

.dark-toggle:hover { background: var(--bg-sunken); color: var(--ink); }

/* Hamburger (mobile) */
.hamburger {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink-2);
  border-radius: 1px;
  transition: all .2s ease;
}

.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

.mobile-menu {
  display: none;
  position: fixed;
  top: 57px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 99;
  padding: 16px 28px;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  border-top: 1px solid var(--rule);
}

.mobile-menu.open { display: flex; }

.mobile-menu .nav-link {
  padding: 12px 16px;
  font-size: 16px;
  border-radius: 8px;
  width: 100%;
  text-align: left;
}

/* Topic nav (pills) — legacy support */
.topic-nav {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}

.topic-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.topic-nav-inner::-webkit-scrollbar { display: none; }

.topic-pill {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-2);
  font: 500 13px var(--sans);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}

.topic-pill:hover { border-color: var(--accent); color: var(--accent); }
.topic-pill.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.topic-pill-count {
  display: inline-block;
  margin-left: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-4);
}

.topic-pill.active .topic-pill-count { color: color-mix(in srgb, var(--bg) 60%, transparent); }

/* Landing hero (legacy) */
.landing-hero {
  max-width: 1280px;
  margin: 0 auto;
  padding: 64px 28px 48px;
  text-align: center;
}

.landing-hero-title {
  font-weight: 700;
  font-size: clamp(34px, 4.6vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 16px;
}

.landing-hero-title .accent { color: var(--accent); }

.landing-hero-sub {
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 600px;
  margin: 0 auto 32px;
}

.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font: 600 15px var(--sans);
  border: none;
  cursor: pointer;
  transition: transform .1s;
  text-decoration: none;
}

.cta-primary:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
  color: var(--bg);
  transform: translateY(-1px);
}

.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.stat-item { font-size: 14px; color: var(--ink-3); font-weight: 500; }
.stat-item strong { color: var(--accent); font-weight: 700; }
.stat-divider { width: 4px; height: 4px; border-radius: 50%; background: var(--rule); }

/* Hero card (legacy) */
.hero-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 28px 28px 28px 32px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: block;
  color: inherit;
  transition: border-color .15s;
}

.hero-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.hero-card:hover { border-color: var(--accent); }

/* Old article layout (sidebar + content) */
.article-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 40px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 80px;
  align-items: start;
}

.article-sidebar {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.article-sidebar::-webkit-scrollbar { width: 4px; }
.article-sidebar::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

.article-main { max-width: 720px; min-width: 0; }

.toc-header {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.toc-list { list-style: none; display: flex; flex-direction: column; gap: 1px; padding: 0; margin: 0; }

.toc-list li a {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-3);
  font-weight: 500;
  padding: 5px 0 5px 12px;
  border-left: 2px solid transparent;
  transition: color .15s, border-color .15s;
  text-decoration: none;
}

.toc-list li a:hover { color: var(--accent); border-left-color: var(--accent); }
.toc-list li a.toc-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-list li a.toc-h3 { padding-left: 24px; font-size: 12px; }

.toc-mobile {
  display: none;
  background: var(--bg-sunken);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 28px;
}

.toc-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.toc-toggle-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toc-toggle-icon { font-size: 10px; color: var(--ink-3); transition: transform .2s ease; }
.toc-toggle-icon.collapsed { transform: rotate(-90deg); }

.toc-list-mobile {
  list-style: none;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
}

.toc-list-mobile.hidden { display: none; }

.toc-list-mobile li a {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  display: block;
  padding: 3px 0;
  text-decoration: none;
}

.toc-list-mobile li a:hover { text-decoration: underline; }

/* Old article header */
.back-link-bar { max-width: 1280px; margin: 0 auto; padding: 16px 28px 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--accent); }
.back-link:hover { opacity: 0.8; }

.article-header { max-width: 1280px; margin: 0 auto; padding: 32px 28px 0; }
.article-header-inner { max-width: 720px; margin-left: 240px; padding-left: 40px; }

.article-page-title {
  font-weight: 700;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.2;
  color: var(--ink);
  letter-spacing: -0.015em;
  margin-bottom: 16px;
}

.article-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.article-meta-date { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.article-meta-reading { font-family: var(--mono); font-size: 12px; color: var(--ink-3); padding-left: 8px; border-left: 1px solid var(--rule); }

.article-meta-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-topic { background: color-mix(in srgb, var(--accent) 8%, var(--bg)); color: var(--accent); }
.badge-relevance { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); border: 1px solid var(--accent); }

.article-divider { width: 48px; height: 3px; background: var(--accent); border-radius: 2px; margin-bottom: 8px; }

/* Grid section (legacy) */
.grid-section { max-width: 1280px; margin: 0 auto; padding: 0 28px 60px; }
.grid-section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.grid-section-title { font-weight: 700; font-size: 18px; color: var(--ink); }
.grid-count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* Footer (legacy class) */
.footer {
  border-top: 1px solid var(--rule);
  background: var(--bg-sunken);
}

.footer .footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer .footer-brand { font-weight: 700; font-size: 14px; color: var(--ink); }
.footer .footer-brand span { color: var(--accent); }

.footer-links { display: flex; align-items: center; gap: 20px; }
.footer-links a { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.footer-links a:hover { color: var(--ink); }
.footer-text { font-size: 13px; color: var(--ink-4); }

/* Dashboard (legacy class) */
.dashboard-section { max-width: 860px; margin: 0 auto; padding: 32px 28px 60px; }
.dash-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.dash-title { font-weight: 700; font-size: 24px; color: var(--ink); margin: 0; line-height: 1.2; }
.dash-subtitle { font-size: 14px; color: var(--ink-3); margin: 4px 0 0; }

/* Old dashboard cards (legacy) */
.dash-today { background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: 8px; padding: 24px; margin-bottom: 20px; }
.dash-today-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.dash-today-label { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px; }
.dash-today-numbers { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.dash-today-read { font-family: var(--mono); font-size: 40px; font-weight: 700; color: var(--accent); line-height: 1; }
.dash-today-sep { font-size: 16px; color: var(--ink-3); }
.dash-today-total { font-family: var(--mono); font-size: 40px; font-weight: 700; color: var(--ink); line-height: 1; opacity: 0.35; }
.dash-today-unit { font-size: 14px; color: var(--ink-3); }
.dash-today-ring-wrap { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.dash-today-ring { width: 80px; height: 80px; }
.dash-today-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--accent); }
.dash-today-cta { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.dash-today-cta:hover { text-decoration: underline; }

.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.dash-card { background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: 8px; padding: 20px; display: flex; align-items: flex-start; gap: 14px; }
.dash-card-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: color-mix(in srgb, var(--accent) 10%, var(--bg)); color: var(--accent); }
.dash-card-body { min-width: 0; }
.dash-card-title { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.dash-card-value { font-family: var(--mono); font-weight: 700; font-size: 28px; color: var(--ink); line-height: 1.1; }
.dash-card-sub { font-size: 12px; color: var(--ink-4); margin-top: 2px; }

.dash-section-card { background: var(--bg-elevated); border: 1px solid var(--rule); border-radius: 8px; padding: 24px; margin-bottom: 20px; }
.dash-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.dash-section-title { font-weight: 700; font-size: 16px; color: var(--ink); margin: 0; display: flex; align-items: center; gap: 8px; }
.dash-section-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

.dash-filter-row { margin-bottom: 16px; }
.dash-filter-pills { display: inline-flex; gap: 4px; background: var(--bg-sunken); border-radius: 6px; padding: 2px; }
.dash-topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.dash-topic-alert { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: color-mix(in srgb, var(--accent) 4%, var(--bg)); border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.dash-topic-alert strong { color: var(--ink); }

.dash-topic-info { display: flex; align-items: center; gap: 10px; }
.dash-topic-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dash-topic-name { font-size: 14px; font-weight: 600; color: var(--ink); flex: 1; }
.dash-topic-count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.dash-topic-bar-bg { height: 6px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.dash-topic-bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }

/* Heatmap legacy classes */
.dash-heatmap-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dash-heatmap-loading { text-align: center; padding: 24px; color: var(--ink-3); font-size: 14px; }
.dash-heatmap-labels { display: flex; flex-direction: column; gap: 3px; padding-right: 4px; }
.dash-heatmap-labels span { height: 14px; line-height: 14px; font-size: 10px; color: var(--ink-4); text-align: right; min-width: 24px; }
.dash-heatmap-empty { background: transparent; }
.dash-heatmap-future { background: var(--bg-sunken); opacity: 0.3; }
.dash-heatmap-months { display: flex; gap: 3px; margin-top: 6px; }
.dash-heatmap-month { width: 14px; font-size: 10px; color: var(--ink-4); white-space: nowrap; overflow: visible; }
.dash-heatmap-legend-label { font-size: 11px; color: var(--ink-4); padding: 0 2px; }

/* Recent reading legacy */
.dash-recent-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dash-recent-title { font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-recent-date { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.dash-recent-topic { font-family: var(--mono); font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 3px; white-space: nowrap; flex-shrink: 0; }

/* Bookmarks legacy classes */
.bk-title { font-size: 24px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.bk-subtitle { font-size: 14px; color: var(--ink-3); margin: 0; }
.bk-filter-dates { display: flex; gap: 16px; margin-bottom: 12px; }
.bk-date-field { flex: 1; }
.bk-date-field label { display: block; font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.bk-date-input { width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 6px; font-size: 14px; color: var(--ink); background: var(--bg); }
.bk-date-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.bk-quick-filters { display: flex; gap: 8px; }

.bk-topic-left { display: flex; align-items: center; gap: 10px; }
.bk-topic-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bk-topic-name { font-size: 15px; color: var(--ink); font-weight: 500; }
.bk-topic-right { display: flex; align-items: center; gap: 8px; }
.bk-topic-count { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--ink); }
.bk-topic-all { background: var(--bg-sunken); }

.bk-back-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; border: none; background: none; color: var(--accent); font: 500 14px var(--sans); cursor: pointer; }
.bk-back-btn:hover { text-decoration: underline; }

.bk-date-group { margin-bottom: 20px; }
.bk-date-label { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 0 8px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; }
.bk-article-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--rule); gap: 12px; }
.bk-article-row:last-child { border-bottom: none; }
.bk-article-link { font-size: 14px; color: var(--ink); text-decoration: none; line-height: 1.4; flex: 1; }
.bk-article-link:hover { color: var(--accent); }
.bk-remove-btn { flex-shrink: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border: none; background: none; color: var(--ink-3); cursor: pointer; border-radius: 4px; transition: background .15s, color .15s; }
.bk-remove-btn:hover { background: color-mix(in srgb, #DC2626 8%, var(--bg)); color: #DC2626; }

.bk-empty { text-align: center; padding: 48px 24px; color: var(--ink-3); }
.bk-empty p { margin: 8px 0 0; font-size: 15px; }

.bk-undo-text { display: flex; align-items: center; gap: 6px; }
.bk-undo-btn { padding: 4px 12px; border: none; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font: 600 13px var(--sans); cursor: pointer; transition: background .15s; }
.bk-undo-btn:hover { opacity: 0.9; }


/* ===========================================
   11. RESPONSIVE
   =========================================== */

@media (max-width: 1024px) {
  /* Homepage */
  .hero { grid-template-columns: 1fr; gap: 36px; padding: 36px 0 32px; }
  .how-grid { grid-template-columns: 1fr; }
  .topics-grid { grid-template-columns: repeat(3, 1fr); }
  .topic-card-grid { grid-template-columns: repeat(3, 1fr); }
  .week { grid-template-columns: 1fr; }
  .week-list {
    border-right: none;
    border-bottom: 1px solid var(--rule);
    display: flex;
    overflow-x: auto;
  }
  .week-day {
    border-bottom: none;
    border-right: 1px solid var(--rule);
    border-left: none;
    border-top: 3px solid transparent;
    flex: 0 0 auto;
    min-width: 140px;
  }
  .week-day.is-active { border-left: none; border-top-color: var(--accent); }

  /* Article page */
  .shell { grid-template-columns: 1fr; gap: 0; padding: 28px 22px 120px; }
  .sidebar { display: none; }

  /* Topic page */
  .topic-head { grid-template-columns: 1fr; gap: 28px; padding: 28px 0 32px; align-items: start; }
  .arts { grid-template-columns: 1fr; }
  .art:nth-child(2n) { padding-left: 0; padding-right: 0; border-left: none; margin-left: 0; }
  .art { padding: 20px 0; }

  /* Footer */
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 32px; }

  /* Article layout (legacy) */
  .article-header-inner { margin-left: 0; padding-left: 0; max-width: 100%; }
  .article-layout { grid-template-columns: 1fr; gap: 0; }
  .article-sidebar { display: none; }
  .toc-mobile { display: block; }

  /* Dashboard */
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-topic-list { grid-template-columns: 1fr; }
  .dash-topic-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  /* Topbar */
  .topbar-inner { padding: 12px 16px; gap: 10px; }
  .nav { display: none; }
  .topbar-meta .txt { display: none; }
  .brand { font-size: 20px; }
  .topbar-cta { display: none; }
  .subnav-inner { padding: 0 12px; }

  /* Legacy header */
  .header-nav { display: none; }
  .hamburger { display: flex; }
  .header-inner { padding: 12px 16px; }
  .logo { font-size: 20px; }

  /* Main */
  main { padding: 0 18px; }

  /* Homepage */
  .hero { padding: 28px 0 24px; gap: 28px; }
  .hero h1 { font-size: 28px; max-width: none; letter-spacing: -0.02em; }
  .hero-lede { font-size: 16px; }
  .hero-ctas .btn { flex: 1; justify-content: center; padding: 14px 16px; }

  .today-list > li { grid-template-columns: 28px 1fr; padding: 12px 14px; }
  .today-list > li .time { grid-column: 2; margin-top: 4px; font-size: 10.5px; }

  .section { padding: 48px 0 36px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 20px; }
  .section-head h2 { font-size: 26px; }

  .feature { padding: 20px; min-height: 0; }
  .feature h3 { font-size: 20px; }

  .topics-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .topic-card-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .topic { padding: 14px; }

  .week-day { min-width: 120px; padding: 12px 14px; }
  .week-detail { padding: 18px; }

  /* Article page */
  .shell { padding: 22px 18px 140px; }
  .crumbs { font-size: 10.5px; gap: 6px; margin-bottom: 16px; }
  h1.headline { font-size: 30px; max-width: none; }
  .dek { font-size: 17px; }
  .byline { padding: 12px 0; gap: 10px 14px; }
  .byline-actions { width: 100%; margin-left: 0; order: 99; }
  .byline-tags {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    margin: 0 -18px;
    padding-left: 18px;
    padding-right: 18px;
    scrollbar-width: none;
  }
  .byline-tags::-webkit-scrollbar { display: none; }
  .byline .gs-chip { white-space: nowrap; flex-shrink: 0; }
  .prose h3 { font-size: 19px; }
  .bridge { padding: 22px 18px 20px; }
  .bridge h3 { font-size: 18px; }
  .facts-grid li { grid-template-columns: 56px 1fr; gap: 14px; padding: 12px 16px; font-size: 14.5px; }
  .next { grid-template-columns: 1fr; }
  .mobile-bar { display: block; }

  /* Topic page */
  .topic-head { padding: 20px 0 26px; }
  .topic-head h1 { font-size: 36px; }
  .topic-lede { font-size: 16px; }
  .filters { top: 52px; padding: 12px 0; }
  .sort { display: none; }
  .month { padding: 28px 0 4px; }
  .month-head .m-date { font-size: 22px; }
  .art { grid-template-columns: 52px 1fr; gap: 12px; padding: 18px 0; }
  .art h3 { font-size: 17px; }
  .art p { font-size: 14px; }

  /* Footer */
  .footer-inner { grid-template-columns: 1fr; gap: 28px; }
  .footer-bottom { flex-direction: column; gap: 10px; padding: 0 18px 20px; }
  .footer .footer-inner { flex-direction: column; gap: 12px; text-align: center; padding: 24px 16px; }
  .footer-links { gap: 16px; }

  /* Tweaks panel */
  .tweaks-panel { left: 12px; right: 12px; bottom: 12px; width: auto; }

  /* Auth */
  .cw-login-btn { padding: 5px 10px; font-size: 12px; }
  .cw-signup-btn { padding: 5px 10px; font-size: 12px; }
  .cw-modal { padding: 24px 20px; }
  .cw-features-row { flex-direction: column; gap: 16px; }

  /* Quiz */
  .quiz-section,
  .quiz-container { padding: 20px 18px 48px; }
  .quiz-date-grid { grid-template-columns: 1fr; }
  .quiz-header { flex-direction: column; gap: 8px; }
  .quiz-card,
  .quiz-question { padding: 18px 16px; }
  .quiz-option { padding: 12px 14px; }
  .quiz-score-inner { flex-direction: column; gap: 16px; }
  .quiz-score-card { padding: 24px 18px; }
  .quiz-stats { grid-template-columns: 1fr; }

  /* Dashboard */
  .dashboard-section { padding: 20px 18px 48px; }
  .dash-page { padding: 20px 18px 48px; }
  .dash-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-today-card { flex-direction: column; align-items: flex-start; }
  .dash-stat-card { padding: 16px; gap: 10px; }
  .dash-stat-icon { width: 36px; height: 36px; }
  .dash-stat-value { font-size: 24px; }
  .dash-heatmap-cell { width: 12px; height: 12px; }

  /* Bookmarks */
  .bk-page { padding: 20px 18px 48px; }
  .bk-date-inputs,
  .bk-filter-dates { flex-direction: column; gap: 10px; }
  .bk-quick-btns,
  .bk-quick-filters { flex-wrap: wrap; }
  .bk-quick-btn { flex: none; }

  /* Legacy article */
  .back-link-bar { padding: 12px 16px 0; }
  .article-header { padding: 24px 16px 0; }
  .article-page-title { font-size: 26px; }
  .article-layout { padding: 20px 16px 60px; }
  .article-content h2 { font-size: 12px; margin-top: 32px; }
  .article-content h3 { font-size: 17px; margin-top: 24px; }
  .article-content p { font-size: 15px; margin-bottom: 12px; }
  .article-content li { font-size: 14px; }

  /* Legacy landing */
  .landing-hero { padding: 40px 16px 32px; }
  .landing-hero-title { font-size: 30px; }
  .landing-hero-sub { font-size: 15px; }
  .stats-bar { gap: 12px; }
  .stat-item { font-size: 13px; }

  /* Legacy cards */
  .article-grid { grid-template-columns: 1fr; gap: 12px; }
  .article-card { padding: 20px; }
  .card-title { font-size: 16px; }

  .hero-card { padding: 24px 24px 24px 28px; }

  /* Legacy sections */
  .grid-section { padding: 0 16px 48px; }
  .week-preview-section,
  .topic-browse-section { padding-left: 18px; padding-right: 18px; }
  .page-title-bar { padding: 16px 18px 0; }
  .archive-section { padding: 16px 18px 48px; }

  /* Undo toast */
  .bk-undo-toast { left: 16px; right: 16px; transform: translateX(0) translateY(20px); }
  .bk-undo-toast.visible { transform: translateX(0) translateY(0); }
}

@media (max-width: 480px) {
  .landing-hero-title { font-size: 26px; }
  .cta-primary { padding: 10px 20px; font-size: 14px; width: 100%; justify-content: center; }
  .hero h1 { font-size: 24px; }
  h1.headline { font-size: 26px; }
  .article-page-title { font-size: 22px; }
  .topic-head h1 { font-size: 30px; }
  .cw-login-btn { display: none; }
}

/* =============================================
   JOIN BLOCK — centered head + hover-expand cards
   ============================================= */
.join {
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--rule);
  padding: 72px 0 64px;
}
.join-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Centered head --- */
.join-head {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 40px;
}
.join-head .kicker {
  font-family: var(--mono); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  margin-bottom: 18px;
}
.join-head .kicker .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #1a4d2e;
  box-shadow: 0 0 0 3px color-mix(in srgb, #1a4d2e 22%, transparent);
}
.join-head .kicker strong { font-weight: 700; color: var(--ink); letter-spacing: 0.1em; }
.join-head h2 {
  font-family: var(--sans);
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.08;
  margin: 0 0 14px;
  color: var(--ink);
  text-wrap: balance;
}

/* Curvy stroke under a single highlighted word in the title */
.hl-word {
  position: relative;
  display: inline-block;
  white-space: nowrap;
}
.hl-stroke {
  position: absolute;
  left: -3%; right: -3%;
  bottom: -0.16em;
  width: 106%;
  height: 0.34em;
  pointer-events: none;
  overflow: visible;
}
.hl-stroke path {
  stroke: var(--accent);
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.join-head .lede {
  font-size: 16.5px;
  color: var(--ink-2);
  margin: 0;
  line-height: 1.55;
}

/* --- Hover-expand benefit cards --- */
.benefits {
  display: flex;
  gap: 14px;
  width: 100%;
  margin-bottom: 40px;
}
.benefit {
  flex: 1 1 0;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 20px 20px 22px;
  display: flex;
  flex-direction: column;
  cursor: default;
  position: relative;
  overflow: hidden;
  transition:
    flex-grow 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    background-color 0.3s ease;
}
.benefits:hover .benefit { flex-grow: 0.78; }
.benefits .benefit:hover {
  flex-grow: 2.6;
  border-color: var(--rule-strong);
  background: var(--bg);
  box-shadow: 0 6px 28px -10px rgba(11, 28, 44, 0.18);
}
.benefit .b-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.benefit .b-num {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.14em;
}
.benefit .b-icon {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--ink);
}
.benefit .b-icon svg {
  width: 18px; height: 18px;
  stroke: currentColor; stroke-width: 1.6; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.benefit h4 {
  font-family: var(--sans);
  font-size: 16px; font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.benefit .b-summary {
  margin: 0;
  font-size: 13.5px; line-height: 1.5;
  color: var(--ink-3);
}

/* Preview area — zero height when collapsed, expands smoothly on hover.
   Card height grows naturally from 0 to its content size; opacity fades in. */
.benefit .b-preview {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(6px);
  transition: max-height 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              margin-top 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
              opacity 0.32s ease 0.1s,
              transform 0.4s ease 0.1s;
  pointer-events: none;
  font-family: var(--sans);
}
.benefit:hover .b-preview {
  max-height: 360px;
  margin-top: 14px;
  opacity: 1;
  transform: translateY(0);
}

/* Generic preview row */
.b-preview .prev-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--bg-sunken);
  margin-bottom: 6px;
  color: var(--ink-2);
  line-height: 1.3;
}
.b-preview .prev-bm { color: var(--accent); font-weight: 700; }
.b-preview .prev-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-preview .prev-chip {
  font-family: var(--mono); font-size: 9.5px;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 2px 7px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-3);
}

/* Read-tracking variant */
.b-preview .prev-check {
  width: 16px; height: 16px;
  display: inline-grid; place-items: center;
  font-size: 11px;
  color: var(--ink-4);
  border-radius: 50%;
}
.b-preview .prev-check-done {
  background: color-mix(in srgb, #1a4d2e 16%, transparent);
  color: #1a4d2e;
  font-weight: 700;
}
.b-preview .prev-done .prev-label { color: var(--ink-2); }

/* Quiz variant */
.b-preview .prev-q {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.4;
}
.b-preview .prev-opt {
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin-bottom: 5px;
  color: var(--ink-2);
  line-height: 1.3;
}
.b-preview .prev-opt.prev-correct {
  border-color: #1a4d2e;
  background: color-mix(in srgb, #1a4d2e 10%, transparent);
  color: #1a4d2e;
  font-weight: 600;
}

/* Dashboard variant */
.b-preview .prev-stats {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.b-preview .prev-stats strong { color: var(--accent); font-weight: 700; }
.b-preview .prev-heatmap {
  width: 100%;
  height: auto;
  margin-bottom: 12px;
  display: block;
}
.b-preview .prev-heatmap rect {
  fill: var(--rule);
}
.b-preview .prev-heatmap rect[data-l="1"] { fill: color-mix(in srgb, var(--accent) 25%, var(--bg-sunken)); }
.b-preview .prev-heatmap rect[data-l="2"] { fill: color-mix(in srgb, var(--accent) 50%, var(--bg-sunken)); }
.b-preview .prev-heatmap rect[data-l="3"] { fill: color-mix(in srgb, var(--accent) 75%, var(--bg-sunken)); }
.b-preview .prev-heatmap rect[data-l="4"] { fill: var(--accent); }
.b-preview .prev-bar {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px;
  margin-bottom: 5px;
  color: var(--ink-3);
}
.b-preview .prev-bar-label {
  width: 64px; flex-shrink: 0;
  font-family: var(--mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.b-preview .prev-bar-track {
  flex: 1; height: 5px;
  background: var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.b-preview .prev-bar-fill {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

/* --- Centered footer (CTA, meta, signin) --- */
.join-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.join-foot .btn-primary { padding: 14px 26px; font-size: 14.5px; }
.join-meta {
  display: flex; gap: 18px; flex-wrap: wrap;
  justify-content: center;
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-4);
}
.join-meta span { display: inline-flex; align-items: center; gap: 6px; }
.join-meta svg { width: 11px; height: 11px; stroke: currentColor; stroke-width: 2.2; fill: none; }
.join-signin {
  margin-top: 4px;
  font-size: 14px; color: var(--ink-3);
}
.join-signin button {
  color: var(--ink); font-weight: 600; text-decoration: none;
  border-bottom: 1px solid var(--rule-strong); padding: 0 0 1px;
  background: none; border-top: 0; border-left: 0; border-right: 0;
  font-size: 14px; cursor: pointer; font-family: var(--sans);
}
.join-signin button:hover { color: var(--accent); border-color: var(--accent); }

/* Responsive */
@media (max-width: 1024px) {
  .benefits { flex-wrap: wrap; }
  .benefit { flex: 1 1 calc(50% - 7px); min-height: 280px; }
  .benefits:hover .benefit { flex-grow: 1; } /* disable hover-expand on tablet */
  .benefits .benefit:hover { flex-grow: 1; box-shadow: none; }
}
@media (max-width: 640px) {
  .join { padding: 48px 0; }
  .join-inner { padding: 0 18px; }
  .join-head { margin-bottom: 28px; }
  .join-head h2 { font-size: 26px; }
  .join-head .lede { font-size: 15px; }
  .benefits { flex-direction: column; gap: 10px; }
  .benefit { flex: 1 1 auto; min-height: 0; padding: 18px; }
  .benefit .b-preview { opacity: 1; transform: none; }
}
