
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg:          #FAFBFD;
  --bg2:         #F1F5F9;
  --bg3:         #E2E8F0;
  --ink:         #1A2E4A;
  --ink2:        #475569;
  --ink3:        #64748B;
  --teal:        #2563EB;
  --teal-light:  #DBEAFE;
  --amber:       #B45309;
  --amber-light: #FEF3C7;
  --green:       #16A34A;
  --green-light: #F0FDF4;
  --red:         #B91C1C;
  --red-light:   #FEE2E2;
  --blue:        #1D4ED8;
  --blue-light:  #DBEAFE;
  --purple:      #6D28D9;
  --purple-light:#EDE9FE;
  --code-bg:     #1E2330;
  --code-fg:     #CDD6F4;
  --code-green:  #A6E3A1;
  --code-amber:  #F9E2AF;
  --code-blue:   #89DCEB;
  --code-pink:   #F38BA8;
  --code-mauve:  #CBA6F7;
  --border:      #E2E8F0;
  --radius:      8px;
  --serif:       'Fraunces', Georgia, serif;
  --sans:        'DM Sans', system-ui, sans-serif;
  --mono:        'DM Mono', 'Courier New', monospace;
  --sidebar-w:   240px;
  --tr:          0.15s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.75; -webkit-font-smoothing: antialiased; }

/* ── progress bar ── */
#progress-bar { position: fixed; top: 0; left: 0; height: 2px; background: var(--teal); z-index: 200; width: 0%; transition: width 0.1s linear; }

/* ── top nav ── */
.site-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250,251,253,0.93); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem; height: 56px;
  display: flex; align-items: center; gap: 0.6rem;
}
.nav-brand { font-family: var(--serif); font-weight: 600; font-size: 1rem; color: var(--ink); text-decoration: none; white-space: nowrap; flex-shrink: 0; }
.nav-brand span { color: var(--teal); }
.nav-sep { color: var(--ink3); font-size: 0.9rem; }
.nav-crumb { font-family: var(--sans); font-size: 0.85rem; color: var(--ink3); text-decoration: none; white-space: nowrap; }
.nav-crumb:hover { color: var(--teal); }

/* dropdown */
.nav-dropdown { margin-left: auto; position: relative; }
.nav-links-right { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.nav-dropdown-btn {
  background: var(--teal-light); color: var(--teal);
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
  padding: 0.22rem 0.7rem 0.22rem 0.85rem; border-radius: 999px;
  cursor: pointer; display: flex; align-items: center; gap: 0.3rem;
  border: none; white-space: nowrap;
}
.nav-dropdown-btn::after { content: 'BE'; font-size: 0.65rem; }
.nav-dropdown-menu {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.09);
  min-width: 260px; padding: 0.35rem; z-index: 300;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block; padding: 0.45rem 0.75rem; border-radius: 4px;
  font-family: var(--sans); font-size: 0.82rem; font-weight: 500;
  color: var(--ink2); text-decoration: none; transition: var(--tr);
}
.nav-dropdown-menu a:hover { background: var(--teal-light); color: var(--teal); }
.nav-dropdown-menu a.active { background: var(--teal-light); color: var(--teal); font-weight: 600; }

/* ── layout ── */
#layout { display: flex; min-height: calc(100vh - 56px); }

/* ── sidebar ── */
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: sticky; top: 56px; height: calc(100vh - 56px);
  overflow-y: auto; padding: 1.75rem 0.75rem 2rem 1.25rem;
  border-right: 1px solid var(--border); background: var(--bg2);
  scrollbar-width: thin; scrollbar-color: var(--bg3) transparent;
}
.sidebar-label {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink3); margin-bottom: 0.6rem; padding-left: 0.5rem;
}
#sidebar nav { display: flex; flex-direction: column; gap: 1px; }
#sidebar nav a {
  display: flex; align-items: flex-start; gap: 0.5rem;
  font-family: var(--sans); font-size: 0.81rem; font-weight: 500;
  color: var(--ink2); text-decoration: none;
  padding: 0.38rem 0.5rem; border-radius: 5px;
  transition: var(--tr); line-height: 1.35;
}
#sidebar nav a .snum {
  width: 18px; height: 18px; min-width: 18px;
  background: var(--bg3); color: var(--ink3);
  border-radius: 50%; font-family: var(--mono); font-size: 0.62rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px; transition: var(--tr);
}
#sidebar nav a:hover { background: var(--teal-light); color: var(--teal); }
#sidebar nav a:hover .snum { background: var(--teal-light); color: var(--teal); }
#sidebar nav a.active { background: var(--teal-light); color: var(--teal); }
#sidebar nav a.active .snum { background: var(--teal); color: white; }

/* ── main content ── */
#content {
  flex: 1; min-width: 0;
  padding: 3rem 3.5rem 6rem;
  max-width: 1100px;
}

/* ── hero ── */
.hero { margin-bottom: 3.5rem; padding-bottom: 2.5rem; border-bottom: 1px solid var(--border); }
.hero-meta { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tag { font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 20px; letter-spacing: 0.04em; white-space: nowrap; }
.tag-module { background: var(--ink); color: white; }
.tag-theme  { background: var(--teal-light); color: var(--teal); }
.tag-time   { background: var(--bg2); color: var(--ink3); }
.hero h1 { font-family: var(--serif); font-size: clamp(1.9rem,4vw,2.9rem); font-weight: 700; line-height: 1.15; color: var(--ink); margin-bottom: 1rem; }
.hero-sub { font-size: 1.05rem; color: var(--ink2); max-width: 620px; line-height: 1.6; }
.mlo-row { margin-top: 1.5rem; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mlo-label { font-family: var(--mono); font-size: 11px; color: var(--ink3); }
.mlo-badge { font-family: var(--mono); font-size: 11px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 4px; color: var(--ink3); background: var(--bg2); }

/* ── sections ── */
.section { margin-bottom: 4rem; scroll-margin-top: 72px; }
.section-header {
  display: flex; align-items: center; gap: 0.85rem;
  margin-bottom: 1.5rem; padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--teal-light);
}
.section-num {
  width: 32px; height: 32px; border-radius: 7px;
  background: var(--ink); color: white;
  font-family: var(--serif); font-size: 0.9rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.section-header h2 { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--ink); }

/* ── scoped typography (inside #content only) ── */
#content h3 {
  font-family: var(--sans); font-size: 1.05rem; font-weight: 600;
  color: var(--teal); margin: 2rem 0 0.65rem;
  display: flex; align-items: center; gap: 0.5rem;
}
#content h3::before { content: ''; display: block; width: 3px; height: 1em; background: var(--teal); border-radius: 2px; flex-shrink: 0; }
#content h4 { font-family: var(--mono); font-size: 0.82rem; font-weight: 500; margin: 1.5rem 0 0.4rem; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.06em; }
#content p  { margin-bottom: 1.1rem; color: var(--ink2); font-size: 1rem; }
#content p strong, #content li strong { color: var(--ink); font-weight: 600; }
#content ul, #content ol { margin-bottom: 1.1rem; padding-left: 1.75rem; color: var(--ink2); }
#content li { margin-bottom: 0.4rem; }
#content em  { color: var(--ink2); }
#content a   { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
#content blockquote { border-left: 3px solid var(--bg3); padding: 0.25rem 1.25rem; margin: 1.25rem 0; font-style: italic; color: var(--ink3); }
#content code { font-family: var(--mono); font-size: 0.84em; background: var(--bg2); padding: 2px 6px; border-radius: 3px; color: var(--teal); border: none; }

/* ── code blocks ── */
.code-block { background: var(--code-bg); border-radius: var(--radius); overflow: hidden; margin: 1.5rem 0; }
.code-header { background: rgba(255,255,255,0.04); padding: 7px 16px; font-family: var(--mono); font-size: 11px; color: rgba(255,255,255,0.35); border-bottom: 1px solid rgba(255,255,255,0.06); display: flex; align-items: center; gap: 8px; }
.code-dot { width: 10px; height: 10px; border-radius: 50%; }
.code-block pre { padding: 1.25rem 1.5rem; overflow-x: auto; margin: 0; }
#content .code-block pre code { font-family: var(--mono); font-size: 13.5px; line-height: 1.85; color: var(--code-fg); background: none; padding: 0; border: none; }
.cmd  { color: var(--code-green); }
.flag { color: var(--code-amber); }
.arg  { color: var(--code-blue); }
.cmt  { color: rgba(205,214,244,0.38); font-style: italic; }
.out  { color: rgba(205,214,244,0.55); }
.kw   { color: var(--code-mauve); }
.str  { color: var(--code-amber); }
.fn   { color: var(--code-pink); }
.num  { color: var(--code-blue); }

/* ── callouts ── */
.callout { border-radius: var(--radius); padding: 1.1rem 1.4rem; margin: 1.75rem 0; border-left: 3px solid; }
.callout > *:last-child { margin-bottom: 0; }
.callout-info     { background: var(--teal-light);    border-color: var(--teal);   }
.callout-warning  { background: var(--amber-light);   border-color: var(--amber);  }
.callout-exercise { background: var(--green-light);   border-color: var(--green);  }
.callout-concept  { background: var(--bg2);           border-color: var(--bg3);    }
.callout-insight  { background: var(--purple-light);  border-color: var(--purple); }
.callout-danger   { background: var(--red-light);     border-color: var(--red);    }
.callout-title { font-family: var(--mono); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.6rem; }
.callout-info     .callout-title { color: var(--teal); }
.callout-warning  .callout-title { color: var(--amber); }
.callout-exercise .callout-title { color: var(--green); }
.callout-concept  .callout-title { color: var(--ink3); }
.callout-insight  .callout-title { color: var(--purple); }
.callout-danger   .callout-title { color: var(--red); }
.callout code { background: rgba(0,0,0,0.09); border-color: transparent; }

/* ── term grid ── */
.term-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; margin: 1.25rem 0; }
.term-card { background: var(--bg2); border-radius: var(--radius); padding: 0.9rem 1rem; border: 1px solid var(--border); }
.term-word { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--teal); margin-bottom: 5px; }
.term-def  { font-size: 13px; color: var(--ink2); line-height: 1.55; }

/* ── def list ── */
.def-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1.25rem 0; }
.def-row { display: grid; grid-template-columns: 180px 1fr; border-bottom: 1px solid var(--border); }
.def-row:last-child { border-bottom: none; }
.def-term { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--teal); padding: 0.75rem 1rem; background: var(--bg2); }
.def-body { font-size: 13.5px; color: var(--ink2); padding: 0.75rem 1rem; line-height: 1.55; }
.def-body code { background: var(--bg3); border-color: var(--border); }
@media (max-width: 600px) { .def-row { grid-template-columns: 1fr; } .def-term { border-bottom: 1px solid var(--border); } }

/* ── compare table ── */
.compare-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 14px; }
.compare-table th { background: var(--ink); color: white; font-family: var(--mono); font-size: 12px; font-weight: 500; padding: 10px 14px; text-align: left; }
.compare-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--ink2); vertical-align: top; }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:nth-child(even) td { background: var(--bg2); }
.compare-table td strong { color: var(--ink); }
.compare-table td code { font-size: 0.82em; }

/* ── steps ── */
.steps { list-style: none; padding: 0; counter-reset: step; margin: 1.5rem 0; }
.steps > li { counter-increment: step; display: flex; gap: 1.1rem; margin-bottom: 1.75rem; }
.steps > li:last-child { margin-bottom: 0; }
.step-num { width: 30px; height: 30px; min-width: 30px; border-radius: 50%; background: var(--teal); color: white; font-family: var(--mono); font-size: 12px; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.step-num::before { content: counter(step); }
.step-body { flex: 1; }
.step-body p:last-child { margin-bottom: 0; }

/* ── check list ── */
.check-list { list-style: none; padding: 0; margin: 1rem 0; }
.check-list li { display: flex; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.5rem; font-size: 0.95rem; color: var(--ink2); }
.check-list li::before { content: "✓"; color: var(--green); font-weight: 700; font-size: 0.9rem; margin-top: 1px; flex-shrink: 0; }

/* ── flow ── */
.flow-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 1.5rem 0; }
.flow-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 1rem; font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.flow-box.highlight { background: var(--teal-light); border-color: var(--teal); color: var(--teal); }
.flow-arrow { color: var(--ink3); font-size: 1.1rem; }

/* ── accordion ── */
.qa-list { margin: 1.25rem 0; }
details { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
details[open] { border-color: var(--teal); }
summary { font-family: var(--sans); font-weight: 600; font-size: 0.95rem; padding: 0.85rem 1.1rem; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.75rem; color: var(--ink); user-select: none; }
summary::before { content: "+"; font-family: var(--mono); font-size: 1.1rem; color: var(--teal); font-weight: 400; width: 18px; flex-shrink: 0; }
details[open] summary::before { content: "−"; }
.qa-answer { padding: 0.85rem 1.1rem 1rem; color: var(--ink2); font-size: 0.95rem; border-top: 1px solid var(--border); }
.qa-answer p:last-child { margin-bottom: 0; }

/* ── pagination ── */
.pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.page-btn { display: flex; flex-direction: column; padding: 1rem 1.25rem; background: var(--bg2); border-radius: var(--radius); text-decoration: none; transition: var(--tr); border: 1px solid var(--border); }
.page-btn:hover { background: var(--teal-light); border-color: var(--teal); }
.page-btn.next { text-align: right; }
.page-dir { font-family: var(--mono); font-size: 11px; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.page-title { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ink); }
.page-btn.disabled { opacity: 0.3; pointer-events: none; }

/* ── section fade-in ── */
.section { opacity: 0; transform: translateY(14px); animation: fadeUp 0.4s ease forwards; }
@keyframes fadeUp { to { opacity: 1; transform: none; } }
.section:nth-child(1)  { animation-delay: 0.04s; }
.section:nth-child(2)  { animation-delay: 0.08s; }
.section:nth-child(3)  { animation-delay: 0.12s; }
.section:nth-child(4)  { animation-delay: 0.16s; }
.section:nth-child(5)  { animation-delay: 0.20s; }
.section:nth-child(6)  { animation-delay: 0.24s; }
.section:nth-child(7)  { animation-delay: 0.28s; }
.section:nth-child(8)  { animation-delay: 0.32s; }
.section:nth-child(9)  { animation-delay: 0.36s; }
.section:nth-child(10) { animation-delay: 0.40s; }
.section:nth-child(11) { animation-delay: 0.44s; }
.section:nth-child(12) { animation-delay: 0.48s; }

/* ── footer ── */
footer { border-top: 1px solid var(--border); padding: 2.5rem 2rem; text-align: center; color: var(--ink3); font-size: 13px; line-height: 1.7; }

/* ── responsive ── */
@media (max-width: 960px) { #sidebar { display: none; } #content { padding: 2rem 1.5rem 4rem; } }
@media (max-width: 600px)  { #content { padding: 1.5rem 1rem 3rem; } .hero h1 { font-size: 2rem; } }

/* ── index page ── */
.index-hero { padding: 5rem 2rem 3rem; max-width: 1100px; margin: 0 auto; border-bottom: 1px solid var(--border); }
.index-hero h1 { font-family: var(--serif); font-size: clamp(2.2rem,5vw,3.8rem); font-weight: 700; line-height: 1.12; margin-bottom: 1.25rem; }
.index-hero h1 em { color: var(--teal); font-style: normal; }
.index-hero .lead { font-size: 1.15rem; color: var(--ink2); max-width: 580px; line-height: 1.65; margin-bottom: 1.5rem; }
.index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 1.25rem; padding: 3rem 2rem; max-width: 1100px; margin: 0 auto; }
.module-card { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; text-decoration: none; transition: all 0.2s; display: flex; flex-direction: column; }
.module-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,0.08); border-color: var(--teal); }
.card-num { font-family: var(--mono); font-size: 11px; color: var(--ink3); margin-bottom: 8px; }
.card-title { font-family: var(--serif); font-size: 1.05rem; font-weight: 700; color: var(--ink); margin-bottom: 8px; line-height: 1.3; }
.card-desc  { font-size: 13px; color: var(--ink3); line-height: 1.55; flex: 1; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 1rem; }
.card-theme { font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.card-time  { font-family: var(--mono); font-size: 11px; color: var(--ink3); }
.card-lang  { font-family: var(--mono); font-size: 11px; color: var(--ink3); }
.theme-gray   { background: #F1EFE8; color: #5F5E5A; }
.theme-teal   { background: #CCFBF1; color: #0F766E; }
.theme-purple { background: #EDE9FE; color: #6D28D9; }
.theme-blue   { background: #DBEAFE; color: #1D4ED8; }
.theme-amber  { background: #FEF3C7; color: #92400E; }
.theme-coral  { background: #FFE4E6; color: #9F1239; }
