*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #FAFAFA;
  --surface:      #F3F4F5;
  --border:       #D4D7DB;
  --ink:          #111418;
  --ink-mid:      #3D454F;
  --ink-muted:    #6B7380;
  --ink-faint:    #9BA3AD;
  --copper-ui:    #B87333;
  --copper:       #A0601E;
  --copper-tint:  #FBF0E6;
  --slate:        #3B5A8A;
  --slate-mid:    #2E4870;
  --slate-light:  #5A7AB0;
  --slate-tint:   #EDF1F8;
  --font-head: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  --font-mono: 'Space Mono', 'SF Mono', 'Courier New', monospace;
  --sidebar-w: 260px;
  --header-h: 56px;
}

body {
  font-family: var(--font-head);
  background: var(--bg);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
header {
  height: var(--header-h);
  background: var(--slate-mid);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--slate);
}

header a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

header img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.header-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
  margin: 0 4px;
}

.header-badge {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.02em;
}

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
aside {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

/* Section toggle */
.section-toggle {
  display: flex;
  gap: 4px;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}

.section-btn {
  flex: 1;
  padding: 6px 8px;
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink-muted);
  transition: all 0.15s;
  text-align: center;
}

.section-btn:hover { color: var(--ink); border-color: var(--ink-faint); }

.section-btn.active-using {
  background: var(--slate-tint);
  border-color: var(--slate-light);
  color: var(--slate-mid);
}

.section-btn.active-setup {
  background: var(--copper-tint);
  border-color: var(--copper-ui);
  color: var(--copper);
}

/* Nav list */
nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
}

.nav-group { margin-bottom: 4px; }

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 10px 16px 4px;
}

.nav-item {
  display: block;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-mid);
  text-decoration: none;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.12s;
}

.nav-item:hover { background: var(--border); color: var(--ink); }

.nav-item.active-using {
  background: var(--slate-tint);
  color: var(--slate-mid);
  border-left-color: var(--slate);
  font-weight: 600;
}

.nav-item.active-setup {
  background: var(--copper-tint);
  color: var(--copper);
  border-left-color: var(--copper-ui);
  font-weight: 600;
}

/* ── Article area ── */
main {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px 80px;
}

/* Loading / error states */
.state-msg {
  color: var(--ink-muted);
  font-size: 14px;
  margin-top: 40px;
  text-align: center;
}

/* ── Markdown prose ── */
.prose { max-width: 720px; }

.prose h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.prose h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 36px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.prose h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-mid);
  margin: 24px 0 8px;
}

.prose p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-mid);
  margin-bottom: 14px;
}

.prose ul, .prose ol {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-mid);
  padding-left: 20px;
  margin-bottom: 14px;
}

.prose li { margin-bottom: 4px; }

.prose a { color: var(--slate); text-decoration: underline; }
.prose a:hover { color: var(--slate-mid); }

.prose code {
  font-family: var(--font-head);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--copper);
}

.prose pre {
  background: var(--ink);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e8eaed;
  font-size: 13px;
}

.prose blockquote {
  border-left: 3px solid var(--slate-light);
  background: var(--slate-tint);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 14px;
  color: var(--slate-mid);
  font-size: 14px;
}

/* Images */
.prose img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 16px 0;
  display: block;
}

/* Videos */
.prose video {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 16px 0;
  display: block;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}

.prose th {
  background: var(--surface);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--ink);
}

.prose td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  color: var(--ink-mid);
}

.prose tr:nth-child(even) td { background: var(--surface); }

/* Section accent on h1 */
.prose.section-setup h1 { color: var(--copper); }
.prose.section-using h1 { color: var(--slate-mid); }

/* Article meta */
.article-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.article-section-label.using { color: var(--slate-light); }
.article-section-label.setup { color: var(--copper-ui); }
