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

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface2: #f4f3ef;
  --border: #e8e5df;
  --border2: #d4cfc6;
  --text: #1a1814;
  --muted: #7a756c;
  --subtle: #a8a39a;
  --ink: #2c2820;
  --accent: #c1440e;
  --accent2: #2a6049;
  --accent3: #1e4a7c;
  --accent-bg: #fdf0eb;
  --accent2-bg: #edf5f1;
  --accent3-bg: #eaf0f8;
  --code-bg: #1e1c18;
  --code-text: #e8e2d8;
  --code-comment: #7a7060;
  --code-keyword: #e8a87c;
  --code-string: #8ec07c;
  --code-type: #83a598;
  --code-fn: #d4b896;
  --sidebar-w: 280px;
  --sans: 'Outfit', sans-serif;
  --serif: 'Lora', Georgia, serif;
  --mono: 'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

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

.sidebar-nav { padding: 0.75rem 0; flex: 1; }

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
  padding: 0.75rem 1.25rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 400;
}

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

.nav-item.active {
  background: var(--accent-bg);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.nav-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
  transition: background 0.15s;
}

.nav-item.active .nav-dot { background: var(--accent); }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── Hero ── */
.hero {
  padding: 4rem 4rem 3rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.hero-title {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 1rem;
  max-width: 700px;
}

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

.hero-body {
  font-size: 16px;
  color: var(--muted);
  max-width: 620px;
  line-height: 1.75;
  margin-bottom: 1.5rem;
}

.hero-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.hero-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
}

/* ── Concept Panel ── */
.concept-panel {
  display: none;
  padding: 3rem 4rem;
  max-width: 900px;
  animation: fadeIn 0.25s ease;
}

.concept-panel.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.concept-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.concept-number {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--subtle);
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.concept-title {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.concept-tagline {
  font-size: 16px;
  color: var(--muted);
  font-style: italic;
  font-family: var(--serif);
}

/* ── Sections ── */
.section { margin-bottom: 2.5rem; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.prose {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.8;
  max-width: 680px;
}

.prose p { margin-bottom: 0.9rem; }
.prose p:last-child { margin-bottom: 0; }

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

/* ── Principle Box ── */
.principle-box {
  background: var(--ink);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
}

.principle-box::before {
  content: '"';
  position: absolute;
  top: -10px; right: 16px;
  font-family: var(--serif);
  font-size: 80px;
  color: rgba(255,255,255,0.06);
  line-height: 1;
}

.principle-label {
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.principle-text {
  font-family: var(--serif);
  font-size: 17px;
  color: rgba(255,255,255,0.92);
  line-height: 1.6;
  font-style: italic;
}

/* ── Code Blocks ── */
.code-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.code-block {
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
}

.code-block.bad { border-top: 3px solid #c0392b; }
.code-block.good { border-top: 3px solid #27ae60; }
.code-block.neutral { border-top: 3px solid #4a90d9; }

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.code-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.code-block.bad .code-label { color: #e07070; }
.code-block.good .code-label { color: #6abf6a; }
.code-block.neutral .code-label { color: #7aabdc; }

.code-icon { font-size: 13px; }

.code-body {
  padding: 1rem;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--code-text);
  white-space: pre;
  overflow-x: auto;
}

.code-body .cm { color: var(--code-comment); font-style: italic; }
.code-body .kw { color: var(--code-keyword); }
.code-body .st { color: var(--code-string); }
.code-body .tp { color: var(--code-type); }
.code-body .fn { color: var(--code-fn); }
.code-body .hl { background: rgba(255,255,255,0.06); display: block; margin: 0 -1rem; padding: 0 1rem; }

.code-single {
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

/* ── Annotation ── */
.annotation {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 0.5rem;
}

.annotation strong { color: var(--ink); }

/* ── Real World Box ── */
.realworld {
  background: var(--accent3-bg);
  border: 1px solid #c5d8ee;
  border-left: 4px solid var(--accent3);
  border-radius: 0 8px 8px 0;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.realworld-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent3);
  margin-bottom: 0.4rem;
}

.realworld-text {
  font-size: 14px;
  color: #1e3a5c;
  line-height: 1.7;
}

/* ── Takeaways ── */
.takeaways {
  background: var(--accent2-bg);
  border: 1px solid #c0ddd2;
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
}

.takeaways-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 0.75rem;
}

.takeaway-item {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
  font-size: 13.5px;
  color: #1a3d2e;
  line-height: 1.55;
  align-items: flex-start;
}

.takeaway-item:last-child { margin-bottom: 0; }

.ta-bullet {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent2);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ── Red Flags ── */
.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.65rem;
}

.flag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.8rem 1rem;
}

.flag-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.flag-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0.4rem;
}

.flag-fix {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent2);
  background: var(--accent2-bg);
  border-radius: 4px;
  padding: 2px 7px;
  display: inline-block;
}

/* ── Toggle tabs ── */
.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Inline code ── */
code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--accent);
}

/* ── Nav arrow ── */
.concept-nav {
  display: flex;
  gap: 0.75rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.nav-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
  text-align: left;
}

.nav-btn:hover { border-color: var(--border2); color: var(--ink); background: var(--surface2); }
.nav-btn.next { justify-content: flex-end; text-align: right; }
.nav-btn-label { font-size: 11px; color: var(--subtle); display: block; margin-bottom: 0.1rem; }
.nav-btn-title { font-weight: 500; color: var(--ink); display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Mobile ── */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; max-width: 100vw; }
  .hero, .concept-panel { padding: 2rem 1.25rem; }
  .code-compare { grid-template-columns: 1fr; }
  .mobile-toggle { display: block; }
  .hero-title { font-size: 28px; }
}
