/* Type: SF Pro, weights 400/500, sizes 12/13/14/24, letter-spacing -0.15px.
   Text hierarchy: --c1 primary, --c2 secondary, --c3 tertiary.
   Radii: 8px navigation, 16px cards, pill CTAs. Icons: 14px nav, 20px cards. */
:root {
  --c1: #292929; --c2: #5d5d5d; --c3: #9e9e9e;
  --bg: #fafaf9; --card: #fff; --line: #ebebea; --chip: #f1f1ef; --accent: #ff6600; --sel: #ff660033;
  --font: "SF Pro Text", "SF Pro", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --r-nav: 8px; --r-card: 16px; --r-pill: 999px;
}
:root { --chip-hover: #e6e6e3; --on-c1: #fff; --paper-s: 30%; --paper-l: 95%; color-scheme: light; }
/* Dark theme: same three-step text hierarchy, inverted for a dark background. */
:root[data-theme="dark"] {
  --c1: #ececec; --c2: #b8b8b8; --c3: #8c8c8c;
  --bg: #0f0f0f; --card: #1a1a1a; --line: #2c2c2c; --chip: #222; --chip-hover: #2e2e2e; --on-c1: #0f0f0f;
  --paper-s: 14%; --paper-l: 16%; --sel: #ff660055; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--c1); font: 400 14px/1.5 var(--font); letter-spacing: -0.15px; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, b, strong, th { font-weight: 500; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 500 12px var(--font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; background: var(--card); color: var(--c2); }
.ico { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; height: 64px; display: flex; align-items: center; gap: 24px;
  padding: 0 24px; background: var(--bg); }
.top > * { flex-shrink: 0; }
.logo { font-size: 24px; font-weight: 500; color: var(--c1); }
.logo span { color: var(--accent); }
.search { flex: 1 1 auto; min-width: 0; max-width: 640px; margin: 0 auto; display: flex; }
.search input { flex: 1; min-width: 0; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-right: 0; border-radius: var(--r-nav) 0 0 var(--r-nav); background: var(--card); color: var(--c1); font-size: 14px; outline: none; }
.search input::placeholder { color: var(--c3); }
.search input:focus { border-color: var(--c3); }
.search button { width: 64px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 0 var(--r-nav) var(--r-nav) 0; background: var(--chip); color: var(--c2); }
.search button:hover { color: var(--c1); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: var(--r-nav); background: transparent; color: var(--c2); }
.icon-btn:hover { background: var(--chip); color: var(--c1); }

/* Sidebar */
.side { position: fixed; top: 64px; bottom: 0; left: 0; width: 232px; overflow-y: auto; padding: 8px 12px 40px; }
.side a { display: flex; align-items: center; gap: 20px; height: 40px; padding: 0 14px; border-radius: var(--r-nav); white-space: nowrap; color: var(--c1); font-size: 14px; }
.side a .ico { color: var(--c2); }
.side a:hover { background: var(--chip); }
.side a.on { background: var(--chip); font-weight: 500; }
.side a.on .ico { color: var(--c1); }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 12px 14px; }
main { margin-left: 232px; padding: 8px 32px 80px; outline: none; max-width: 1760px; }
.menu { display: none !important; }
@media (max-width: 900px) {
  .menu { display: grid !important; }
  .top { gap: 12px; padding: 0 12px; }
  .side { transform: translateX(-100%); transition: transform .15s; background: var(--bg); z-index: 9; border-right: 1px solid var(--line); }
  body.nav-open .side { transform: none; }
  main { margin-left: 0; padding: 8px 16px 60px; }
  .search button { width: 48px; }
}

/* Toolbar, filter panel (CTA pill, navigation 8px) */
.page-title { font-size: 24px; font-weight: 500; margin: 16px 0 16px; }
.toolbar { display: flex; align-items: center; gap: 16px; margin: 8px 0 24px; flex-wrap: wrap; }
.pill-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px; border: 0; border-radius: var(--r-pill); background: var(--chip); color: var(--c1); font-size: 14px; font-weight: 500; }
.pill-btn:hover, .pill-btn.on { background: var(--chip-hover); }
.pill-btn .n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--c1); color: var(--on-c1); font-size: 12px; display: grid; place-items: center; }
.sort label { display: flex; align-items: center; gap: 4px; color: var(--c3); font-size: 13px; }
.toolbar select, .filter-panel select { field-sizing: content; font-size: 13px; font-weight: 500; color: var(--c1); background: transparent; border: 0; border-radius: var(--r-nav); padding: 4px; cursor: pointer; }
.toolbar select:hover, .filter-panel select:hover { background: var(--chip); }
.toolbar .count { margin-left: auto; color: var(--c3); font-size: 13px; }
.filter-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 24px; align-items: end; margin: -8px 0 28px; padding: 20px 24px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); }
.filter-panel[hidden] { display: none; }
.filter-panel label { display: flex; flex-direction: column; gap: 4px; }
.filter-panel label span { font-size: 12px; color: var(--c3); }
.filter-panel select { padding: 6px 8px; margin-left: -8px; }
.filter-panel .clear { color: var(--accent); font-size: 13px; font-weight: 500; padding-bottom: 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin: 0 0 24px; color: var(--c3); font-size: 13px; }
.filters label { display: flex; align-items: center; gap: 4px; }
.filters select { field-sizing: content; font-size: 13px; font-weight: 500; color: var(--c1); background: transparent; border: 0; border-radius: var(--r-nav); padding: 4px; cursor: pointer; }
.filters .count { margin-left: auto; }
.views { display: inline-flex; padding: 2px; border-radius: var(--r-pill); background: var(--chip); }
.views button { border: 0; background: transparent; padding: 4px 14px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; color: var(--c2); }
.views button.on { background: var(--card); color: var(--c1); box-shadow: 0 1px 2px #0001; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.topic-tile { display: block; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); }
.topic-tile:hover { border-color: var(--c3); }
.topic-tile h3 { margin: 0; font-size: 14px; }
.topic-tile .n { margin: 2px 0 10px; font-size: 13px; color: var(--c2); }
.topic-tile p { margin: 0; font-size: 12px; color: var(--c3); }

/* Cards (16px) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 40px 16px; }
.card { display: block; border-radius: var(--r-card); outline-offset: 6px; }
.card.sel { outline: 2px solid var(--accent); }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-card); overflow: hidden; background: var(--chip); }
.card:hover .thumb { filter: brightness(.97); }
.thumb .badge { position: absolute; right: 8px; bottom: 8px; background: #000c; color: #fff; font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: 6px; }
.thumb.img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.paper { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 20px 24px;
  background: hsl(var(--h) var(--paper-s) var(--paper-l)); color: var(--c1); }
.thumb.paper .t { font-size: 24px; font-weight: 500; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb.paper .ph { font-size: 13px; color: var(--c2); }
.meta { padding-top: 12px; }
.meta h3 { margin: 0 0 4px; font-size: 14px; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta p { margin: 0; color: var(--c2); font-size: 13px; line-height: 1.5; }
.meta p + p { color: var(--c3); }
.av { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; overflow: hidden; font-size: 13px; font-weight: 500; color: var(--c2); }
.av img { width: 20px; height: 20px; }
.more { display: block; margin: 30px auto; padding: 8px 20px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--card); }
.loading, .empty { color: var(--c3); padding: 40px 0; text-align: center; }

/* List view */
.rows { display: flex; flex-direction: column; gap: 2px; }
.row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 220px 80px 150px; gap: 16px; align-items: center; padding: 14px 12px; border-radius: var(--r-card); }
.row:hover { background: var(--chip); }
.row.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.rtitle { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.rtitle h3 { margin: 0; font-size: 14px; white-space: nowrap; }
.rhost { font-size: 12px; color: var(--c3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row p { margin: 2px 0 0; font-size: 13px; color: var(--c2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .rtop { font-size: 12px; color: var(--c3); }
.rtopics { display: flex; flex-wrap: wrap; gap: 4px; }
.rtopics span { font-size: 12px; padding: 1px 8px; border: 1px solid var(--line); border-radius: var(--r-nav); color: var(--c2); white-space: nowrap; }
.rstat { text-align: right; }
.rstat b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.rstat span { font-size: 12px; color: var(--c3); }
@media (max-width: 1100px) { .row { grid-template-columns: 32px minmax(0, 1fr) 70px 120px; } .rtopics { display: none; } }
@media (max-width: 640px) { .row { grid-template-columns: 32px minmax(0, 1fr) 60px; } .row .rstat:last-child, .row .rtop { display: none; } }

/* Blog page */
.section-title { font-size: 14px; font-weight: 500; margin: 36px 0 8px; }
.blog-head { display: flex; gap: 20px; align-items: flex-start; padding: 36px 0 8px; }
.blog-head .av { width: 48px; height: 48px; }
.blog-head h1 { margin: 0; font-size: 24px; line-height: 1.25; }
.blog-head .sub { color: var(--c3); margin: 4px 0 10px; font-size: 13px; }
.blog-head .about { margin: 0 0 16px; font-size: 14px; color: var(--c2); max-width: 720px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 1px solid var(--line); border-radius: var(--r-pill); padding: 6px 16px; background: transparent; font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; color: var(--c1); }
.btn:hover { background: var(--chip); }
.btn.primary { background: var(--c1); border-color: var(--c1); color: var(--on-c1); }
.btn.following { background: var(--accent); border-color: var(--accent); color: #fff; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 0; }
.tags a { font-size: 12px; padding: 2px 9px; border-radius: var(--r-nav); border: 1px solid var(--line); color: var(--c2); }
.tags a:hover { color: var(--c1); }
.why { margin: 22px 0 6px; padding: 16px 20px; background: var(--chip); border-radius: var(--r-card); max-width: 900px; font-size: 14px; }
.why b { display: block; font-size: 12px; color: var(--accent); margin-bottom: 4px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 56px; }
.cols aside { position: sticky; top: 70px; align-self: start; }
@media (max-width: 1150px) { .cols { grid-template-columns: 1fr; } .cols aside { position: static; } }
.stats { display: flex; gap: 32px; flex-wrap: wrap; margin: 26px 0 0; }
.stat b { display: block; font-size: 24px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat span { color: var(--c3); font-size: 12px; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 56px; margin-top: 16px; max-width: 520px; }
.spark i { flex: 1; background: var(--accent); opacity: .55; border-radius: 3px 3px 0 0; min-height: 1px; }
.spark-axis { display: flex; justify-content: space-between; max-width: 520px; color: var(--c3); font-size: 12px; }

.posts { list-style: none; margin: 0; padding: 0; }
.posts li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.posts .rank { flex: none; width: 26px; color: var(--c3); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; line-height: 1.6; }
.posts .pt { font-size: 14px; font-weight: 500; }
.posts .pt:hover { color: var(--accent); }
.posts .pm { color: var(--c3); font-size: 12px; margin-top: 2px; }
.posts .pm b { color: var(--c2); }
.posts .pm a:hover { text-decoration: underline; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment .cm { font-size: 12px; color: var(--c3); margin-bottom: 4px; }
.comment .cm b { color: var(--c1); }
.comment .ct { white-space: pre-line; overflow-wrap: anywhere; font-size: 13px; color: var(--c2); }
.comment .ct a { color: var(--accent); }
.mini { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: var(--r-card); }
.mini:hover { background: var(--chip); }
.mini h4 { margin: 0; font-size: 14px; }
.mini p { margin: 0; font-size: 12px; color: var(--c3); }

/* About page and dialog */
.prose { max-width: 720px; font-size: 14px; color: var(--c2); }
.prose h1 { font-size: 24px; color: var(--c1); margin: 32px 0 10px; }
.prose h2 { font-size: 14px; color: var(--c1); margin: 28px 0 6px; }
.prose b { color: var(--c1); }
.prose a { color: var(--accent); }
.prose code { font-size: 13px; background: var(--chip); padding: 1px 5px; border-radius: 6px; }
dialog { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); color: var(--c1); padding: 20px 24px; }
dialog::backdrop { background: #0006; }
dialog h3 { margin-top: 0; font-size: 14px; }
dialog td { padding: 4px 14px 4px 0; font-size: 13px; color: var(--c2); }
dialog button { margin-top: 12px; padding: 6px 16px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--chip); font-size: 13px; font-weight: 500; }
.prose li { margin: 6px 0; }
.prose ol { padding-left: 20px; }

@media (max-width: 600px) {
  .top { flex-wrap: wrap; height: auto; padding: 12px 12px; row-gap: 12px; }
  .top > .search { order: 3; flex-basis: 100%; max-width: none; }
  .top > #help-btn { margin-left: auto; }
  .side { top: 116px; }
  .filter-panel { grid-template-columns: 1fr 1fr; padding: 16px; }
  .toolbar { gap: 12px; }
}

/* Theme toggle shows the moon in light mode and the sun in dark mode */
#theme-btn .sun, :root[data-theme="dark"] #theme-btn .moon { display: none; }
:root[data-theme="dark"] #theme-btn .sun { display: block; }
:root[data-theme="dark"] .spark i { opacity: .85; }

/* Like button on post rows */
.posts .pbody { flex: 1; min-width: 0; }
.like { flex: none; align-self: center; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--c3); }
.like svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.like:hover { background: var(--chip); color: var(--c1); }
.like.on { color: var(--accent); }
.like.on svg { fill: currentColor; }

/* History */
.hitem { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-card); }
.hitem:hover { background: var(--chip); }
.hmain { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.hmain div { min-width: 0; }
.hmain h4 { margin: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hmain p { margin: 0; font-size: 12px; color: var(--c3); }
.htime { font-size: 12px; color: var(--c3); white-space: nowrap; }
.hitem .icon-btn { width: 32px; height: 32px; opacity: 0; }
.hitem:hover .icon-btn, .hitem .icon-btn:focus { opacity: 1; }
@media (hover: none) { .hitem .icon-btn { opacity: 1; } }

/* Quiet credit line at the bottom of the sidebar */
.side .credit { margin: 16px 14px 0; font-size: 12px; color: var(--c3); line-height: 1.6; }
.side .credit a { display: inline; height: auto; padding: 0; color: inherit; font-size: inherit; }
.side .credit a:hover { background: none; color: var(--c2); text-decoration: underline; }

/* Favicon from a sprite sheet: 10 x 10 cells of 20px */
.av .fav { width: 20px; height: 20px; background-size: 200px 200px; background-repeat: no-repeat; }

.page-sub { margin: -8px 0 16px; font-size: 13px; color: var(--c2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Pre-rendered home and topic pages are sorted for crawlers; readers with JS see their own order. */
.js main[data-swap] { visibility: hidden; }
