:root {
  --ink: #e8e2d4;
  --dim: #9b9484;
  --panel: #23262b;
  --panel2: #1a1c20;
  --line: #3a3f47;
  --accent: #d9761f;
  --accent2: #f0a34a;
  --ok: #7bb661;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #101215 radial-gradient(1200px 600px at 20% 0%, #1d2a3a 0%, #101215 70%);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", "PT Sans", system-ui, sans-serif;
}
a { color: var(--accent2); }
.loading { padding: 40px; color: var(--dim); }

.layout { display: grid; grid-template-columns: 340px 1fr; height: 100vh; }

/* левая колонка */
.side {
  background: linear-gradient(180deg, #1c1f24, #14161a);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.brand {
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.brand small { display: block; font-weight: 400; letter-spacing: 0; text-transform: none;
  color: var(--dim); font-size: 12px; margin-top: 3px; }
.list { overflow: auto; padding: 8px; }
details.chapter { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px;
  background: var(--panel); }
details.chapter > summary {
  cursor: pointer; padding: 9px 12px; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; gap: 8px;
}
details.chapter > summary::-webkit-details-marker { display: none; }
details.chapter > summary .n { color: var(--dim); font-weight: 400; font-size: 12px; }
details.chapter[open] > summary { border-bottom: 1px solid var(--line); color: var(--accent2); }
ul.ex { list-style: none; margin: 0; padding: 6px; }
ul.ex li { margin: 2px 0; }
ul.ex button {
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  color: var(--ink); padding: 7px 9px; border-radius: 5px; cursor: pointer;
  font: inherit; display: flex; gap: 8px; align-items: baseline;
}
ul.ex button:hover { background: #2a2f36; border-color: var(--line); }
ul.ex button.active { background: #33261a; border-color: var(--accent); }
ul.ex button .num { color: var(--dim); font-size: 12px; min-width: 18px; }
ul.ex button.done .num::after { content: " ✓"; color: var(--ok); }

/* правая часть */
.main { overflow: auto; padding: 0; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; background: rgba(16,18,21,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 650; }
.topbar .crumb { color: var(--dim); font-size: 12px; }
.topbar .spacer { flex: 1; }
.btn {
  background: var(--accent); color: #1a1206; border: 0; border-radius: 5px;
  padding: 8px 14px; font: inherit; font-weight: 700; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn:disabled { opacity: .45; cursor: default; }

.doc { max-width: 860px; padding: 22px 26px 60px; }
.doc .lead { font-size: 17px; color: #d9d3c4; margin: 0 0 6px; }
.doc .meta { color: var(--dim); font-size: 12px; margin-bottom: 18px; }
.doc h2 {
  font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent2);
  margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.doc h3 { font-size: 15px; margin: 18px 0 8px; }
.doc p { margin: 0 0 12px; }
.doc i { color: #cfc6b3; }
.doc img {
  display: block; max-width: 100%; height: auto; margin: 12px 0 16px;
  border: 1px solid var(--line); border-radius: 4px; background: #000;
}
.doc code, .doc pre { font-family: "Cascadia Mono", "JetBrains Mono", ui-monospace, monospace; }
.doc pre {
  background: #0d0f12; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 10px 12px; overflow: auto; margin: 10px 0 16px; font-size: 13.5px;
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; }
.gallery figcaption { color: var(--dim); font-size: 12px; margin-top: 4px; }
.goalbox {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px 14px; margin: 0 0 18px;
}
.goalbox ul { margin: 6px 0 0; padding-left: 18px; }
.goalbox li { color: #d5cdbd; }
.empty { color: var(--dim); padding: 60px 26px; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { max-height: 40vh; }
}
