/* DOE Helper — Design System */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; }
img, svg, video, canvas { max-width: 100%; height: auto; }
img.bg-logo-light, img.bg-logo { max-width: none; }

:root {
  --ink: #111; --fg: #333; --muted: #666; --faint: #999;
  --border: #e5e5e5; --bg: #fafafa; --white: #fff;
  --accent: #5046e5; --accent-light: #eef2ff;
  --teal: #0d9488; --teal-light: #f0fdfa;
  --amber: #d97706; --amber-light: #fffbeb;
  --rose: #e11d48; --rose-light: #fff1f2;
  --green: #16a34a; --green-light: #f0fdf4;
  --mono: 'JetBrains Mono', 'Consolas', monospace;
  --sans: 'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }
body { font: 400 16px/1.65 var(--sans); color: var(--fg); background: var(--white); }
a { color: inherit; text-decoration: none; }
code { font: .85em var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 3px; white-space: pre-wrap; word-break: break-all; }

/* ── NAV ── */
.nav { position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 52px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); }
.nav-inner { max-width: 1000px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; height: 52px; }
.nav-logo { font: 600 .85rem var(--mono); color: var(--ink); display: flex; align-items: center; gap: 8px; }
.nav-logo .dot { width: 7px; height: 7px; background: var(--accent); border-radius: 2px; }
.nav-logo-icon { width: 26px; height: 26px; border-radius: 5px; flex-shrink: 0; }
.nav-links { display: flex; gap: 24px; list-style: none; align-items: center; }
.nav-links a { font-size: .8rem; color: var(--muted); transition: color .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-links .cta { background: var(--ink); color: var(--white) !important; padding: 5px 14px; border-radius: 5px; font-weight: 600; font-size: .75rem; }
.nav-links .cta:hover { background: #000; }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.nav-toggle span { display: block; width: 18px; height: 1.5px; background: var(--ink); margin: 3.5px 0; }

/* ── BACKGROUND LOGO (light pages) ── */
.bg-logo-light {
  position: fixed;
  top: 55%; left: 22%;
  transform: translate(-50%, -50%);
  width: 2000px; height: 2000px;
  opacity: .25;
  pointer-events: none;
  z-index: 0;
}
@media (max-width: 768px) {
  .bg-logo-light { display: none; }
}

/* ── HERO ── */
.hero { padding: 120px 24px 60px; text-align: center; }
.hero h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight: 700; letter-spacing: -.035em; line-height: 1.08; color: var(--ink); margin-bottom: 20px; }
.hero p { font-size: 1.05rem; color: var(--muted); max-width: 480px; margin: 0 auto 36px; line-height: 1.6; }
.hero-actions { display: flex; gap: 10px; justify-content: center; }
.btn { padding: 10px 22px; border-radius: 6px; font: 600 .85rem var(--sans); border: none; cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: #000; }
.btn-ghost { background: none; color: var(--fg); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--ink); }

/* ── SECTION ── */
.section { max-width: 1000px; margin: 0 auto; padding: 100px 24px; }
.section + .section { border-top: 1px solid var(--border); }
.section-label { font: 600 .7rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: 10px; }
.section h2 { font-size: 1.8rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; color: var(--ink); margin-bottom: 40px; }

/* ── CODE ── */
.code-block { background: #1a1a1a; border-radius: 8px; overflow: hidden; margin: 10px 0; font-family: var(--mono); }
.code-header { padding: 7px 14px; background: #222; display: flex; justify-content: space-between; align-items: center; }
.code-header span { font-size: .65rem; color: #555; }
.code-copy { background: none; border: 1px solid #444; color: #666; padding: 2px 8px; border-radius: 3px; font: .6rem var(--mono); cursor: pointer; }
.code-copy:hover { border-color: #888; color: #aaa; }
.code-body { padding: 12px 16px; font-size: .78rem; line-height: 1.7; color: #ccc; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
@media (min-width: 1024px) { .code-body { white-space: pre; word-break: normal; } }
.code-body .prompt { color: #6ec86e; }
.code-body .flag { color: #8b9cf7; }
.code-body .string { color: #e5a64e; }
.code-body .key { color: #5cc8d8; }
.code-body .comment { color: #555; }

/* ── FOOTER ── */
.footer { padding: 16px; text-align: center; font-size: .72rem; color: var(--faint); position: relative; z-index: 1; }
.footer a { color: var(--muted); margin: 0 10px; }
.footer a:hover { color: var(--ink); }

/* ── ANIMATIONS ── */
.fade-up { opacity: 0; transform: translateY(16px); transition: opacity .5s ease, transform .5s ease; }
.fade-up.visible { opacity: 1; transform: translateY(0); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.open { display: flex; flex-direction: column; position: absolute; top: 52px; left: 0; right: 0;
    background: var(--white); padding: 16px 24px; gap: 12px; border-bottom: 1px solid var(--border); }
  .nav-toggle { display: block; }
  .hero { padding: 120px 24px 80px; }
  .section { padding: 64px 24px; }
}

/* ═══════════════════════════════════════════
   CALLOUT / ACCORDION / TABS (shared)
   ═══════════════════════════════════════════ */
.callout { border-radius: 8px; padding: 16px 20px; margin: 16px 0; display: flex; gap: 12px; font-size: .84rem; line-height: 1.55; }
.callout-icon { font-size: 1.1rem; flex-shrink: 0; }
.callout-body { }
.callout h4 { font-size: .82rem; font-weight: 700; margin-bottom: 4px; }
.callout p { font-size: .82rem; margin: 0; }
.callout.info { background: var(--accent-light); border-left: 3px solid var(--accent); }
.callout.info h4 { color: var(--accent); }
.callout.success { background: var(--green-light); border-left: 3px solid var(--green); }
.callout.success h4 { color: var(--green); }
.callout.warning { background: var(--amber-light); border-left: 3px solid var(--amber); }
.callout.warning h4 { color: var(--amber); }
.callout.danger { background: var(--rose-light); border-left: 3px solid var(--rose); }
.callout.danger h4 { color: var(--rose); }

.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab-btn { background: none; border: none; padding: 10px 18px; font: 600 .82rem var(--mono); color: var(--faint);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-btn:hover { color: var(--fg); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.accordion { margin: 16px 0; }
.accordion-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; overflow: hidden; transition: border-color .15s; }
.accordion-item:hover { border-color: #ccc; }
.accordion-header { padding: 14px 18px; cursor: pointer; font: 600 .88rem var(--sans); display: flex; justify-content: space-between; align-items: center; }
.accordion-header:hover { background: var(--bg); }
.accordion-header .arrow { font-size: .65rem; transition: transform .2s; color: var(--accent); }
.accordion-item.open .accordion-header .arrow { transform: rotate(180deg); }
.accordion-item.open { border-color: var(--accent); }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height .3s ease; padding: 0 18px; }
.accordion-item.open .accordion-body { max-height: 2000px; padding: 0 18px 18px; }

/* ═══════════════════════════════════════════
   HOW-TO PAGE
   ═══════════════════════════════════════════ */
.howto-hero {
  padding: 120px 24px 48px; text-align: center;
  background: linear-gradient(135deg, #1e1b4b, #312e81, #4338ca);
  color: var(--white); position: relative;
}
.howto-hero::after {
  content: ''; position: absolute; inset: 0; opacity: .08;
  background-image: radial-gradient(#fff 1px, transparent 1px);
  background-size: 24px 24px;
}
.howto-hero h1 { font-size: 2.2rem; font-weight: 700; letter-spacing: -.03em; margin-bottom: 8px; position: relative; }
.howto-hero p { color: rgba(255,255,255,.6); font-size: .95rem; position: relative; }

.howto-section { max-width: 720px; margin: 0 auto; padding: 48px 24px; border-bottom: 1px solid var(--border); }
.howto-section:last-of-type { border-bottom: none; }
.howto-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.howto-section h2 .step-badge {
  background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 700 .72rem var(--mono); flex-shrink: 0;
}
.howto-section h3 { font-size: .95rem; font-weight: 600; margin: 16px 0 6px; color: var(--ink); }
.howto-section p { font-size: .88rem; color: var(--muted); max-width: 580px; margin-bottom: 10px; }
.howto-section table { width: 100%; border-collapse: collapse; font-size: .82rem; margin: 10px 0; }
.howto-section thead th {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: #fff; padding: 8px 12px; text-align: left;
  font: 600 .68rem var(--mono); text-transform: uppercase; letter-spacing: .04em;
}
.howto-section thead th:first-child { border-radius: 6px 0 0 0; }
.howto-section thead th:last-child { border-radius: 0 6px 0 0; }
.howto-section tbody td { padding: 8px 12px; border-bottom: 1px solid var(--bg); }
.howto-section tbody tr:hover { background: var(--accent-light); }
.howto-section ul, .howto-section ol { margin: 0 0 12px 18px; color: var(--muted); font-size: .85rem; }
.howto-section code { background: var(--accent-light); border: 1px solid #c7d2fe; color: var(--accent); }

/* ═══════════════════════════════════════════
   BOOK PAGE
   ═══════════════════════════════════════════ */
.book-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); max-width: 1160px; margin: 52px auto 0; min-height: 100vh; }
.book-sidebar { position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto;
  background: var(--bg); border-right: 1px solid var(--border); padding: 16px 0; }
.book-sidebar::-webkit-scrollbar { width: 3px; }
.book-sidebar::-webkit-scrollbar-thumb { background: var(--border); }
.sidebar-part { font: 600 .6rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--faint); padding: 12px 18px 3px; }
.sidebar-chapter { display: block; padding: 6px 18px; font-size: .78rem; font-weight: 600; color: var(--muted);
  border-left: 2px solid transparent; transition: all .15s; }
.sidebar-chapter:hover { color: var(--ink); background: var(--white); }
.sidebar-chapter.active { color: var(--accent); border-left-color: var(--accent); background: var(--white); }
.sidebar-section-link { display: block; padding: 3px 18px 3px 32px; font-size: .72rem; color: var(--faint); transition: color .15s; }
.sidebar-section-link:hover { color: var(--ink); }
.sidebar-section-link.active { color: var(--accent); font-weight: 600; }

.book-content { padding: 40px 48px; min-width: 0; overflow-wrap: break-word; }
.book-content h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -.03em; margin-bottom: 4px; color: var(--ink); }
.book-content .chapter-subtitle { font: .88rem var(--mono); color: var(--accent); margin-bottom: 24px; }
.book-content .lead { font-size: .95rem; color: var(--muted); font-style: italic; margin-bottom: 20px; line-height: 1.7;
  border-left: 3px solid var(--accent); padding-left: 16px; }
.book-content h2 { font-size: 1.2rem; font-weight: 700; margin: 36px 0 12px; padding-bottom: 6px;
  border-bottom: 2px solid var(--accent-light); color: var(--ink); }
.book-content h3 { font-size: .95rem; font-weight: 600; color: var(--accent); margin: 24px 0 8px; }
.book-content p { margin-bottom: 12px; color: var(--fg); font-size: .9rem; }
.book-content ul, .book-content ol { margin: 0 0 12px 18px; color: var(--fg); font-size: .9rem; }
.book-content li { margin-bottom: 3px; }
.book-content code { background: var(--accent-light); border: 1px solid #c7d2fe; color: var(--accent); }
.book-content .math {
  background: linear-gradient(135deg, var(--accent-light), #f5f3ff);
  border: 1px solid #c7d2fe; border-radius: 8px; padding: 14px 18px;
  margin: 14px 0; font-family: Georgia, serif; font-size: .95rem; text-align: center;
  overflow-x: auto;
}
.book-content table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .82rem; }
.book-content thead th {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: #fff; padding: 8px 12px; text-align: left;
  font: 600 .68rem var(--mono); text-transform: uppercase; letter-spacing: .04em;
}
.book-content thead th:first-child { border-radius: 6px 0 0 0; }
.book-content thead th:last-child { border-radius: 0 6px 0 0; }
.book-content tbody td { padding: 8px 12px; border-bottom: 1px solid var(--bg); }
.book-content tbody tr:hover { background: var(--accent-light); }

.keypoint-box {
  background: linear-gradient(135deg, var(--accent-light), #f5f3ff);
  border: 1px solid #c7d2fe; border-radius: 8px; padding: 16px 20px; margin: 16px 0;
}
.keypoint-box h4 { font-size: .84rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.keypoint-box p { font-size: .84rem; color: #3730a3; margin: 0; line-height: 1.55; }
.analogy {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #86efac; border-radius: 8px; padding: 16px 20px; margin: 16px 0;
}
.analogy h4 { font-size: .84rem; font-weight: 700; color: #166534; margin-bottom: 6px; }
.analogy p { font-size: .84rem; color: #15803d; margin: 0; line-height: 1.55; }
.warning-box {
  background: linear-gradient(135deg, #fffbeb, #fefce8);
  border: 1px solid #fcd34d; border-radius: 8px; padding: 16px 20px; margin: 16px 0;
}
.warning-box h4 { font-size: .84rem; font-weight: 700; color: #92400e; margin-bottom: 6px; }
.warning-box p { font-size: .84rem; color: #a16207; margin: 0; line-height: 1.55; }
.danger-box {
  background: linear-gradient(135deg, #fff1f2, #fef2f2);
  border: 1px solid #fca5a5; border-radius: 8px; padding: 16px 20px; margin: 16px 0;
}
.danger-box h4 { font-size: .84rem; font-weight: 700; color: #9f1239; margin-bottom: 6px; }
.danger-box p { font-size: .84rem; color: #be123c; margin: 0; line-height: 1.55; }
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.comparison-card { border-radius: 8px; padding: 16px; font-size: .84rem; }
.comparison-card.bad { background: linear-gradient(135deg, #fff1f2, #fef2f2); border: 1px solid #fca5a5; }
.comparison-card.good { background: linear-gradient(135deg, #f0fdf4, #ecfdf5); border: 1px solid #86efac; }
.comparison-card h4 { font-size: .82rem; margin-bottom: 6px; font-weight: 700; }
.visual-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 6px; margin: 12px 0; }
.visual-cell { text-align: center; padding: 8px 4px; border-radius: 6px; font-size: .72rem; font-weight: 600; }
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 2px; }
.chapter-nav { display: flex; justify-content: space-between; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); font: 600 .82rem var(--sans); }
.chapter-nav a { color: var(--accent); transition: color .15s; }
.chapter-nav a:hover { color: #4338ca; }

.sidebar-toggle { display: none; }
.mobile-toc { display: none; }

@media (max-width: 860px) {
  .book-layout { grid-template-columns: 1fr; }
  .book-sidebar { display: none; }
  .book-content { padding: 24px 16px; }
  .sidebar-toggle { display: none !important; }

  .mobile-toc { display: block; margin-bottom: 24px; }
  .mobile-toc-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); font: 600 .85rem var(--sans); color: var(--ink); cursor: pointer;
  }
  .mobile-toc-toggle .arrow { font-size: .65rem; color: var(--accent); transition: transform .2s; }
  .mobile-toc-toggle.open .arrow { transform: rotate(180deg); }
  .mobile-toc-body {
    display: none; border: 1px solid var(--border); border-top: none;
    border-radius: 0 0 8px 8px; padding: 8px 0;
    max-height: 60vh; overflow-y: auto; background: var(--white);
  }
  .mobile-toc-body.open { display: block; }
  .mobile-toc-body .sidebar-part { font: 600 .6rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--faint); padding: 10px 16px 3px; }
  .mobile-toc-body .sidebar-chapter { display: block; padding: 6px 16px; font-size: .78rem; font-weight: 600; color: var(--muted); }
  .mobile-toc-body .sidebar-chapter:hover { color: var(--ink); background: var(--bg); }
  .mobile-toc-body .sidebar-chapter.active { color: var(--accent); }
  .mobile-toc-body .sidebar-section-link { display: block; padding: 3px 16px 3px 28px; font-size: .72rem; color: var(--faint); }
  .mobile-toc-body .sidebar-section-link:hover { color: var(--ink); }
  .mobile-toc-body .sidebar-section-link.active { color: var(--accent); font-weight: 600; }
}
