@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap&subset=vietnamese');

:root {
  --paper: #fffdf8;
  --surface: #f5f1e8;
  --ink: #1d2a26;
  --muted: #66716c;
  --line: #ddd8cc;
  --brand: #176b55;
  --brand-soft: #e3f0eb;
  --accent: #c67a3b;
  --shadow: 0 18px 50px rgba(31, 44, 39, .09);
  --content: 760px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.78;
}
a { color: var(--brand); text-decoration-thickness: .08em; text-underline-offset: .18em; }
a:hover { color: #0c4939; }

.reading-progress {
  position: fixed; inset: 0 auto auto 0; z-index: 100;
  width: 0; height: 3px; background: var(--accent);
}
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: 64px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 253, 248, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 750; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; color: #fff; background: var(--brand);
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif; font-size: 18px; font-weight: 800;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.button {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.button:hover { border-color: var(--brand); color: var(--brand); }
.menu-button { display: none; }

.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar {
  position: sticky; top: 64px; height: calc(100vh - 64px); overflow: auto;
  padding: 28px 22px; border-right: 1px solid var(--line); background: var(--surface);
}
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.sidebar h2 { margin: 8px 0 18px; font-family: "Be Vietnam Pro", "Segoe UI", sans-serif; font-size: 21px; line-height: 1.4; letter-spacing: -.015em; }
.chapter-nav { display: grid; gap: 5px; }
.chapter-nav a {
  padding: 9px 11px; border-radius: 9px; color: var(--muted); text-decoration: none;
  font-size: 14px; line-height: 1.4;
}
.chapter-nav a:hover, .chapter-nav a.active { background: #fff; color: var(--brand); }
.chapter-nav a.active { box-shadow: inset 3px 0 var(--brand); }

.main { min-width: 0; }
.hero { padding: 76px 28px 42px; border-bottom: 1px solid var(--line); background: linear-gradient(145deg, #f0f5ef 0%, #fffaf1 78%); }
.hero-inner, .article, .site-footer { width: min(100%, var(--content)); margin: 0 auto; }
.hero h1, .article h1 {
  max-width: 760px; margin: 12px 0 18px;
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif; font-size: clamp(40px, 6vw, 68px); line-height: 1.12; letter-spacing: -.035em; font-weight: 800;
}
.hero p { max-width: 650px; margin: 0; color: var(--muted); font-size: 20px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.pill { padding: 6px 11px; border: 1px solid #cbded6; border-radius: 999px; color: var(--brand); background: rgba(255,255,255,.68); font-size: 13px; }

.article { padding: 54px 28px 80px; }
.article > :first-child { margin-top: 0; }
.article h1 { font-size: clamp(34px, 5vw, 54px); }
.article h2 { margin: 2.6em 0 .65em; font-family: "Be Vietnam Pro", "Segoe UI", sans-serif; font-size: 30px; line-height: 1.35; letter-spacing: -.025em; font-weight: 750; }
.article h3 { margin: 2.1em 0 .55em; font-size: 21px; line-height: 1.35; }
.article p, .article li { max-width: 72ch; }
.article ul, .article ol { padding-left: 1.35em; }
.article li + li { margin-top: .35em; }
.article blockquote {
  margin: 1.8em 0; padding: 16px 20px; border-left: 4px solid var(--brand);
  background: var(--brand-soft); color: #29483f;
}
.article blockquote p { margin: 0; }
.article table { width: 100%; margin: 1.8em 0; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.article th, .article td { padding: 12px 13px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.article th { background: var(--surface); }
.article code { padding: .14em .35em; border-radius: 5px; background: var(--surface); font-size: .9em; }
.article pre { overflow: auto; padding: 18px; border-radius: 12px; background: #17231f; color: #eef7f3; }
.article pre code { padding: 0; background: transparent; }
.article hr { margin: 3em 0; border: 0; border-top: 1px solid var(--line); }
.chapter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 30px; }
.chapter-card { padding: 22px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: #fff; box-shadow: var(--shadow); text-decoration: none; }
.chapter-card:hover { transform: translateY(-2px); border-color: #b7d2c8; }
.chapter-card small { display: block; margin-bottom: 7px; color: var(--brand); font-weight: 800; text-transform: uppercase; }
.chapter-card strong { display: block; font-family: "Be Vietnam Pro", "Segoe UI", sans-serif; font-size: 20px; line-height: 1.45; letter-spacing: -.015em; font-weight: 700; }
.site-footer { padding: 26px 28px 50px; color: var(--muted); border-top: 1px solid var(--line); font-size: 13px; }

body.dark { --paper: #15211d; --surface: #1c2a25; --ink: #edf3ef; --muted: #aebbb5; --line: #34433d; --brand: #7ed0b3; --brand-soft: #213a31; --accent: #e1a267; --shadow: none; }
body.dark .topbar { background: rgba(21, 33, 29, .92); }
body.dark .hero { background: linear-gradient(145deg, #1b3028 0%, #25251f 78%); }
body.dark .chapter-nav a:hover, body.dark .chapter-nav a.active, body.dark .chapter-card { background: #1a2722; }
body.dark .pill { background: #1b2a25; border-color: #365248; }

@media (max-width: 860px) {
  body { font-size: 16px; }
  .topbar { padding: 0 16px; }
  .menu-button { display: inline-flex; }
  .layout { display: block; }
  .sidebar { position: fixed; inset: 64px auto 0 0; z-index: 40; width: min(86vw, 320px); height: auto; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .hero { padding: 55px 20px 34px; }
  .article { padding: 42px 20px 64px; }
  .article table { display: block; overflow-x: auto; }
  .chapter-grid { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .sidebar, .reading-progress, .site-footer { display: none; }
  .layout { display: block; }
  .article { width: 100%; max-width: none; padding: 0; }
  body { color: #111; background: #fff; font-size: 11pt; }
  a { color: inherit; }
}
