
/* ── LOCAL FONTS (no CDN) ──────────────────────────────────── */
@font-face {
  font-family: 'Oswald';
  src: url('fonts/Oswald-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Oswald';
  src: url('fonts/Oswald-600.woff2') format('woff2');
  font-weight: 600 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'PT Sans';
  src: url('fonts/PTSans-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/IBMPlexMono-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* ── PALETTE (aligned with home.css / forum.css) ───────────── */
:root {
  --g0:  #000;
  --g1:  rgb(8,8,8);
  --g2:  rgb(15,15,15);
  --g3:  rgb(23,23,23);
  --g4:  rgb(31,31,31);
  --g5:  rgb(41,41,41);
  --g6:  rgb(48,48,48);
  --g7:  rgb(56,56,56);
  --g8:  rgb(64,64,64);
  --g9:  rgb(71,71,71);
  --g10: rgb(79,79,79);
  --g11: rgb(87,87,87);
  --g12: rgb(94,94,94);
  --g13: rgb(105,105,105);
  --g14: rgb(112,112,112);
  --g16: rgb(128,128,128);
  --g18: rgb(143,143,143);
  --g20: rgb(158,158,158);
  --g22: rgb(176,176,176);
  --g24: rgb(191,191,191);
  --g26: rgb(207,207,207);
  --g28: rgb(222,222,222);
  --g30: rgb(240,240,240);
  --g32: #fff;

  --red:    #d60000;
  --yellow: #ffd800;

  --topbar-h:  40px;
  --sidebar-w: 230px;

  --fh: 'Oswald', 'Arial Narrow', Arial, sans-serif;
  --fb: 'PT Sans', 'Segoe UI', system-ui, sans-serif;
  --fm: 'IBM Plex Mono', 'Consolas', 'Courier New', monospace;

  /* Legacy aliases (same values) */
  --font-head: var(--fh);
  --font-body: var(--fb);
  --font-mono: var(--fm);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--g3);
  color: var(--g22);
  font-family: var(--fb);
  font-size: 15px;
  line-height: 1.6;
}

::-webkit-scrollbar { width: 8px; height: 8px; background: none; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.site-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--g10);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 8px;
  border-bottom: 1px solid var(--g8);
  z-index: 100;
}

.tb-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: calc(var(--topbar-h) - 8px);
  text-decoration: none;
}
.tb-logo-img { height: 22px; width: auto; display: block; }
.tb-logo-text {
  font-family: var(--fh);
  font-size: 14px;
  font-weight: 700;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.tb-sep {
  flex-shrink: 0;
  width: 1px;
  height: 18px;
  background: var(--g8);
  margin: 0 4px;
}
.tb-nav {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 100%;
}
.tb-nav-item { position: relative; display: flex; align-items: center; }
.tb-nav-link {
  display: flex;
  align-items: center;
  height: calc(var(--topbar-h) - 10px);
  padding: 0 12px;
  font-family: var(--fh);
  font-size: 12px;
  font-weight: 600;
  color: var(--g24);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  border-radius: 3px;
}
.tb-nav-link:hover { background: var(--g8); color: var(--g28); }
.tb-nav-link.is-active { background: var(--g8); color: var(--yellow); }

.tb-spacer { flex: 1; }

#search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  height: 28px;
  padding: 0 12px;
  margin-right: 6px;
  background: var(--g7);
  border: 1px solid var(--g9);
  border-radius: 3px;
  transition: background 0.1s, border-color 0.1s;
}
#search-wrap:focus-within {
  background: var(--g6);
  border-color: var(--g12);
}
#search-input {
  width: 300px;
  min-width: 180px;
  background: none;
  border: none;
  color: var(--g26);
  font-family: var(--fb);
  font-size: 14px;
  line-height: 1.2;
  padding: 0;
  outline: none;
  height: 100%;
  border-radius: 0;
}
#search-input::placeholder { color: var(--g14); }
#search-input:focus { background: none; }

.search-icon {
  color: var(--g16);
  font-size: 12px;
  flex-shrink: 0;
  position: static;
  transform: none;
  pointer-events: none;
  line-height: 1;
}
#search-wrap:focus-within .search-icon { color: var(--yellow); }

#search-drop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  min-width: 100%;
  background: var(--g4);
  border: 1px solid var(--g8);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  max-height: 320px;
  overflow-y: auto;
  z-index: 300;
  display: none;
}
#search-drop.open { display: block; }

.sr-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--g6);
  transition: background 0.08s;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--g5); }
.sr-book {
  font-family: var(--fh);
  font-size: 10px;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}
.sr-title { font-size: 14px; color: var(--g22); }

.tb-star { display: none; }

/* ── LAYOUT (structure unchanged) ───────────────────────────── */
#shell {
  display: flex;
  height: 100vh;
  gap: 4px;
  padding: calc(var(--topbar-h) + 4px) 4px 4px;
  background: var(--g3);
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--g5);
  border: 1px solid var(--g7);
  border-radius: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
}

.nb-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  background: var(--g4);
  border-bottom: 1px solid var(--g7);
  transition: background 0.08s;
}
.nb-hd:hover { background: var(--g6); }
.nb-icon { color: var(--yellow); font-size: 14px; flex-shrink: 0; line-height: 1; }
.nb-label {
  font-family: var(--fh);
  font-size: 12px;
  font-weight: 700;
  color: var(--g26);
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.nb-arr {
  color: var(--g14);
  font-size: 8px;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.nb.open .nb-arr { transform: rotate(90deg); }
.nb-children { display: none; }
.nb.open .nb-children { display: block; }

.ns-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--g5);
  border-bottom: 1px solid var(--g6);
  transition: background 0.08s, color 0.08s;
}
.ns-hd:hover { background: var(--g6); }
.ns-hd::before {
  content: '';
  display: block;
  width: 3px;
  height: 14px;
  background: var(--g10);
  border-radius: 2px;
  flex-shrink: 0;
  transition: background 0.12s;
}
.ns-hd:hover::before,
.ns.open .ns-hd::before { background: var(--yellow); }
.ns-gem { display: none; }
.ns-label {
  font-family: var(--fh);
  font-size: 11px;
  font-weight: 600;
  color: var(--g18);
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.12s;
}
.ns-hd:hover .ns-label,
.ns.open .ns-label { color: var(--g24); }
.ns-arr {
  color: var(--g12);
  font-size: 8px;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.ns.open .ns-arr { transform: rotate(90deg); }
.ns-children { display: none; background: var(--g4); }
.ns.open .ns-children { display: block; }

.np {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 22px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--g6);
  color: var(--g16);
  font-size: 13px;
  transition: background 0.08s, color 0.08s;
}
.np:hover { background: var(--g5); color: var(--g22); }
.np.active {
  background: rgba(255,216,0,.08);
  color: var(--yellow);
  border-left: 3px solid var(--yellow);
  padding-left: 19px;
}
.np-dot {
  font-size: 8px;
  color: var(--g11);
  flex-shrink: 0;
  transition: color 0.1s;
}
.np:hover .np-dot,
.np.active .np-dot { color: var(--yellow); }

/* ── CONTENT PANEL ──────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  height: 100%;
  background: var(--g5);
  border: 1px solid var(--g7);
  border-radius: 6px;
}
#content-inner { max-width: 900px; margin: 0 auto; padding: 28px 36px 80px; }

#breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--g14);
  margin-bottom: 16px;
}
#breadcrumb:empty { display: none; }
.bc-book,
.bc-sec,
.bc-page { color: var(--g14); }
.bc-page { color: var(--g18); }
.bc-sep { color: var(--g11); font-size: 10px; }

/* ── DOC TYPOGRAPHY ─────────────────────────────────────────── */
.doc h1 {
  font-family: var(--fh);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--g28);
  text-transform: uppercase;
  padding-bottom: 14px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--g7);
  line-height: 1.1;
}
.doc h2 {
  font-family: var(--fh);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--g28);
  margin-top: 36px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--g7);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.2;
}
.doc h2::before {
  content: '';
  display: block;
  width: 3px;
  height: 20px;
  background: var(--yellow);
  border-radius: 2px;
  flex-shrink: 0;
}
.doc h3 {
  font-family: var(--fh);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--g24);
  margin-top: 24px;
  margin-bottom: 8px;
}
.doc p { margin-bottom: 14px; color: var(--g22); }
.doc strong { color: var(--g26); font-weight: 600; }
.doc em { color: var(--g16); font-style: italic; }
.doc ul, .doc ol { margin: 6px 0 16px 20px; }
.doc li { margin-bottom: 6px; color: var(--g22); }
.doc ul li::marker { color: var(--yellow); }
.doc ol li::marker { color: var(--g14); font-weight: 600; }

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
  background: var(--g4);
  border: 1px solid var(--g7);
  border-radius: 4px;
  overflow: hidden;
}
.doc th,
.doc td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--g6);
  vertical-align: top;
}
.doc th {
  font-family: var(--fh);
  font-size: 11px;
  font-weight: 700;
  color: var(--g24);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--g6);
}
.doc tr:last-child td { border-bottom: none; }
.doc td code { font-size: 12px; }

.doc pre {
  background: rgba(0,0,0,.22);
  border: 1px solid var(--g7);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 14px 0;
  font-family: var(--fm);
  font-size: 12px;
  color: var(--g20);
  line-height: 1.55;
  border-radius: 4px;
}
.doc code {
  font-family: var(--fm);
  font-size: 12px;
  background: var(--g6);
  color: var(--yellow);
  padding: 1px 5px;
  border-radius: 2px;
}
.doc pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  border-radius: 0;
}

.doc a {
  color: var(--g18);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.1s, border-color 0.1s;
}
.doc a:hover { color: var(--yellow); border-bottom-color: rgba(255,216,0,.35); }

.doc .note,
.doc .warn {
  border: 1px solid var(--g7);
  border-radius: 4px;
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 14px;
  color: var(--g20);
  background: rgba(0,0,0,.18);
}
.doc .note { border-left: 3px solid var(--yellow); }
.doc .warn { border-left: 3px solid var(--red); }
.doc .note::before,
.doc .warn::before {
  display: block;
  font-family: var(--fh);
  font-size: 10px;
  letter-spacing: 0.1em;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.doc .note::before { content: 'Note'; color: var(--yellow); }
.doc .warn::before { content: 'Warning'; color: var(--red); }

@keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.doc { animation: fadeUp 0.15s ease-out; }

/* ── WELCOME PAGE ───────────────────────────────────────────── */
#welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 8px 0 20px;
  max-width: 640px;
}
.w-kicker {
  font-family: var(--fh);
  font-size: 11px;
  font-weight: 600;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 12px;
}
.w-kicker::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--red);
  margin-right: 8px;
  vertical-align: -2px;
  border-radius: 1px;
}
.w-stars { display: none; }
.w-title {
  height: 48px;
  width: auto;
  margin-bottom: 10px;
}
.w-sub {
  font-family: var(--fh);
  font-size: 28px;
  font-weight: 700;
  color: var(--g28);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
  margin-bottom: 12px;
}
.w-lead {
  font-size: 15px;
  color: var(--g16);
  max-width: 36em;
  margin-bottom: 28px;
  line-height: 1.6;
}
.w-rule { display: none; }
.w-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  text-align: left;
}

.w-card {
  background: var(--g4);
  border: 1px solid var(--g7);
  border-radius: 6px;
  padding: 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
  transition: border-color 0.12s, background 0.12s;
}
.w-card:hover { border-color: var(--g10); background: var(--g6); }
.w-card-icon { font-size: 20px; color: var(--yellow); line-height: 1; }
.w-card-title {
  font-family: var(--fh);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--g26);
  margin: 0;
}
.w-card-desc {
  font-size: 13px;
  color: var(--g14);
  line-height: 1.5;
  flex: 1;
}

.placeholder {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  background: var(--g4);
  border: 1px solid var(--g7);
  border-left: 3px solid var(--yellow);
  border-radius: 6px;
  margin-top: 20px;
}
.placeholder-icon { font-size: 20px; color: var(--g12); }
.placeholder p { color: var(--g16); font-size: 14px; margin: 0; }

.page-loading {
  padding: 32px 0;
  color: var(--g14);
  font-family: var(--fh);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  #content-inner { padding: 20px 18px 60px; }
  .w-grid { grid-template-columns: 1fr; }
  #search-input { width: 200px; min-width: 140px; }
}
