:root {
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --bg-code: #f4f5f7;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #8c959f;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --warning: #bc4c00;
  --warning-soft: #fff1cf;
  --success: #1a7f37;
  --success-soft: #dafbe1;
  --code: #cf222e;
  --hl-yellow: #fef08a;
  --hl-yellow-strong: #fde047;
  --sidebar-w: 280px;
  --toc-w: 220px;
  --max-content: 720px;
  --header-h: 56px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre {
  font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
  font-size: 0.875em;
}
code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--code);
}

/* ============ layout ============ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  min-height: 100vh;
}
.topbar {
  grid-column: 1 / -1;
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: var(--text);
}
.brand-mark {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, #0969da 0%, #218bff 100%);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; font-weight: 700;
}
.brand-name { font-size: 14px; }
.brand-divider { color: var(--text-muted); font-weight: 400; margin: 0 6px; }
.breadcrumb { color: var(--text-secondary); font-size: 13px; }
.topbar-spacer { flex: 1; }
.topbar-source { font-size: 12px; color: var(--text-muted); }

/* search */
.search-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
}
.search-input {
  width: 100%;
  height: 32px;
  padding: 0 32px 0 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .12s ease, background .12s ease;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}
.search-icon {
  position: absolute;
  left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex; align-items: center;
}
.search-kbd {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
}
.search-input:focus ~ .search-kbd { display: none; }
.search-results {
  position: absolute;
  top: 100%; left: 0; right: 0;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  max-height: 480px;
  overflow-y: auto;
  display: none;
  z-index: 50;
}
.search-results.is-open { display: block; }
.search-result {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover,
.search-result.is-active {
  background: var(--bg-subtle);
  text-decoration: none;
}
.search-result .sr-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 2px;
}
.search-result .sr-snippet {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result .sr-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex; gap: 8px; align-items: center;
}
.search-result mark {
  background: var(--hl-yellow);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
.search-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============ sidebar ============ */
aside.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
}
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 16px 24px 20px;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  padding: 0 8px;
}
.sidebar-nav a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 1px;
  line-height: 1.45;
}
.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-nav a:hover {
  background: var(--bg-subtle);
  text-decoration: none;
  color: var(--text);
}
.sidebar-nav a.active:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.sidebar-nav-item-meta {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0;
}

/* sidebar bottom — current article meta card */
.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding: 14px 16px 16px 20px;
  background: var(--bg-subtle);
  font-size: 12.5px;
}
.sidebar-bottom-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.sidebar-bottom h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 10px;
  line-height: 1.4;
  color: var(--text);
}
.sidebar-bottom .meta-line {
  color: var(--text-secondary);
  margin: 4px 0;
  font-size: 12px;
}
.sidebar-bottom .meta-line strong {
  color: var(--text);
}
.sidebar-bottom-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 6px;
  margin-top: 10px;
}
.sidebar-bottom-source {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: block;
  font-size: 12px;
  color: var(--accent);
}

/* ============ main ============ */
main {
  padding: 48px 32px 96px;
  display: flex;
  justify-content: center;
}
.content {
  width: 100%;
  max-width: var(--max-content);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.eyebrow-tag {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.eyebrow .meta-divider { color: var(--border-strong); }
h1 {
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-weight: 400;
  line-height: 1.55;
}
.meta-row {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  margin-bottom: 40px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  font-size: 13px;
}
.meta-item { color: var(--text-secondary); }
.meta-item strong { color: var(--text); font-weight: 600; }
.meta-row .meta-divider { color: var(--border-strong); }
h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 56px 0 16px;
  letter-spacing: -0.01em;
  scroll-margin-top: 72px;
}
h2:first-of-type { margin-top: 8px; }
h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 28px 0 10px;
  scroll-margin-top: 72px;
}
p { margin: 12px 0; }
ul, ol { padding-left: 22px; margin: 12px 0; }
li { margin: 6px 0; }
li > ul, li > ol { margin: 6px 0; }

/* callout */
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin: 20px 0;
}
.callout.warn { border-left-color: var(--warning); background: var(--warning-soft); }
.callout.note { border-left-color: var(--text-muted); background: var(--bg-subtle); }
.callout-title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  color: var(--accent);
}
.callout.warn .callout-title { color: var(--warning); }
.callout.note .callout-title { color: var(--text-secondary); }
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

/* quote */
blockquote {
  margin: 16px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
  font-style: italic;
}
blockquote p { margin: 6px 0; }

/* table */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-weight: 600;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-strong);
}

/* pros / cons */
.pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}
.pc-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}
.pc-card h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pc-card.pros h4 { color: var(--success); }
.pc-card.cons h4 { color: var(--warning); }
.pc-card ul { padding-left: 18px; margin: 0; }
.pc-card li { margin: 4px 0; font-size: 14px; }

/* spec grid */
.specs {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0;
  font-size: 14px;
}
.specs > div {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.specs > div:nth-last-child(-n+2) { border-bottom: none; }
.specs .label {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
}

/* ============ right TOC ============ */
aside.toc {
  padding: 64px 24px 32px 8px;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  font-size: 13px;
}
.toc-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}
.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  padding: 4px 0 4px 10px;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}
.toc-list a:hover { color: var(--text); text-decoration: none; }
.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.toc-list .lvl-3 a { padding-left: 22px; font-size: 12.5px; color: var(--text-muted); }

/* footer */
footer.page-footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  display: flex; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}

/* pills (with spacing) */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: nowrap;
}
.pill-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 8px;
  padding: 0 6px;
}

/* ============ archive (right rail) ============ */
aside.archive {
  padding: 48px 24px 32px 8px;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  font-size: 13px;
}
.archive-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}
.archive-group {
  margin-bottom: 18px;
}
.archive-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
  padding-left: 10px;
  position: relative;
}
.archive-list {
  list-style: none;
  padding: 0; margin: 0;
  border-left: 1px solid var(--border);
}
.archive-list li { margin: 0; }
.archive-list a {
  display: block;
  padding: 5px 10px 5px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-secondary);
}
.archive-list a:hover {
  color: var(--text);
  background: var(--bg-subtle);
  text-decoration: none;
}
.archive-list a .date {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.archive-list a .title {
  display: block;
  font-weight: 500;
}

/* ============ hub (index) page ============ */
.hub-hero {
  text-align: left;
  margin-bottom: 40px;
}
.hub-hero h1 { font-size: 42px; }
.hub-hero .subtitle { font-size: 18px; max-width: 580px; }
.article-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.article-card {
  display: block;
  padding: 24px 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.article-card:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
  transform: translateY(-1px);
}
.article-card-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.article-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text);
}
.article-card p {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.55;
}
.article-card .tag-list {
  display: flex; flex-wrap: wrap; gap: 6px 6px;
}

/* ============ highlight feature ============ */
mark.hl {
  background: var(--hl-yellow);
  padding: 1px 0;
  cursor: pointer;
  border-radius: 1px;
  transition: background .12s ease;
}
mark.hl:hover { background: var(--hl-yellow-strong); }

#hl-toolbar {
  position: fixed;
  display: none;
  z-index: 100;
  background: transparent;
}
#hl-mark-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  transition: background .12s ease, transform .12s ease;
}
#hl-mark-btn:hover {
  background: var(--hl-yellow);
  transform: scale(1.05);
}

#hl-remove-btn {
  position: fixed;
  display: none;
  z-index: 101;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid #fecaca;
  color: #dc2626;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  cursor: pointer;
  align-items: center; justify-content: center;
  padding: 0;
  transition: transform .12s ease, background .12s ease;
}
#hl-remove-btn.is-visible { display: flex; }
#hl-remove-btn:hover {
  background: #fef2f2;
  transform: scale(1.1);
}

#hl-panel-btn {
  position: fixed;
  right: 24px; bottom: 24px;
  z-index: 99;
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-secondary);
  font-family: inherit;
}
#hl-panel-btn:hover { background: var(--bg-subtle); }
.hl-badge {
  display: inline-flex;
  min-width: 18px; height: 18px;
  align-items: center; justify-content: center;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 0 6px;
}
.hl-badge.empty { background: var(--text-muted); }

#hl-panel {
  position: fixed;
  right: 24px; bottom: 70px;
  z-index: 100;
  width: 340px;
  max-height: 60vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#hl-panel.is-open { display: flex; }
#hl-panel header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.hl-list {
  list-style: none;
  margin: 0; padding: 0;
  overflow-y: auto;
  flex: 1;
}
.hl-list li {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
  margin: 0;
  display: flex; gap: 8px;
  color: var(--text-secondary);
}
.hl-list li:hover { background: var(--bg-subtle); }
.hl-list li .hl-quote {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  border-left: 2px solid var(--hl-yellow-strong);
  padding-left: 8px;
}
.hl-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
#hl-panel footer {
  display: flex; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
#hl-panel footer button {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}
#hl-panel footer button:hover { background: var(--bg-subtle); color: var(--text); }
.hl-panel-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
}
.hl-panel-close:hover { color: var(--text); }

/* ============ responsive ============ */
@media (max-width: 1080px) {
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
  aside.toc, aside.archive { display: none; }
  .search-wrap { width: 200px; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  aside.sidebar { display: none; }
  main { padding: 32px 20px 80px; }
  h1 { font-size: 28px; }
  .pros-cons { grid-template-columns: 1fr; }
  .specs { grid-template-columns: 1fr; }
  .specs .label { border-right: none; border-bottom: 1px solid var(--border); }
  #hl-panel { right: 12px; left: 12px; width: auto; }
}
