:root {
  --bg: #f7f7f5; --surface: #fff; --fg: #1c1c1c; --muted: #5f646b; --line: #e3e3de;
  --accent: #f5b301; --accent-soft: #fff4d1; --accent-ink: #7a5600; --link: #1f55c9; --bad: #b42318;
  --top: 60px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111214; --surface: #191b1f; --fg: #ececec; --muted: #a0a4ab; --line: #2c2f35; --accent-soft: #3a2f0d; --accent-ink: #ffd666; --link: #8ab4ff; --bad: #ff8a80; }
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 12px); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); }

.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.03em; color: var(--fg); text-decoration: none; }
.logo span { color: var(--accent); }
.toc-btn { display: none; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); }
.search { position: relative; flex: 1; max-width: 720px; }
.search input { width: 100%; padding: 9px 14px; font: inherit; border: 2px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); outline: none; }
.search input:focus { border-color: var(--accent); }
.results { position: absolute; top: 46px; left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.15); }
.results a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.results a:hover, .results a.sel { background: var(--accent-soft); }
.results .where { font-size: 12px; color: var(--muted); }
.results .snip { font-size: 14px; }
.results mark { background: var(--accent); color: #111; border-radius: 2px; }
.results .none { padding: 12px 14px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.toc { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow: auto; padding: 16px 8px 40px 16px; border-right: 1px solid var(--line); font-size: 14px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li ul { padding-left: 12px; }
.toc a { display: block; padding: 4px 8px; border-radius: 6px; color: var(--fg); text-decoration: none; }
.toc a:hover { background: var(--accent-soft); }
.toc a.on { background: var(--accent-soft); font-weight: 600; }
.toc .lbl { display: block; font-size: 11px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.toc li ul a { font-size: 13px; color: var(--muted); }

.doc { max-width: 860px; padding: 20px 28px 120px; }
.meta { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 18px; }
.meta h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.25; }
.meta .row { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 14px; color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #e6f6ec; color: #1f7a45; }
.badge.bad { background: #fde8e8; color: var(--bad); }
.warn { margin-top: 10px; font-size: 13px; color: var(--muted); }
details.about { margin-top: 10px; font-size: 14px; }

h2.h1 { margin: 40px 0 8px; font-size: 21px; line-height: 1.3; }
h2.h1 .lbl, h3.h2 .lbl { display: block; font-size: 12px; letter-spacing: .06em; color: var(--muted); }
h3.h2 { margin: 26px 0 6px; font-size: 17px; }
.pt { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; padding: 6px 10px; margin: 0 -10px; border-radius: 8px; }
.pt.d2 { padding-left: 34px; }
.pt.d3 { padding-left: 58px; }
.pt .num { font-weight: 700; color: var(--muted); text-decoration: none; text-align: right; white-space: nowrap; }
.pt .num:hover { color: var(--accent-ink); }
.para { margin: 6px 0; padding: 0 10px 0 92px; }
.para.def { padding-left: 92px; }
.para dfn { font-style: normal; font-weight: 650; }
.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); } 100% { background: transparent; } }
.repealed { opacity: .55; }
.repealed::after { content: "Neteko galios"; display: inline-block; margin-left: 8px; font-size: 12px; color: var(--bad); }
details.chg { grid-column: 2; font-size: 12px; color: var(--muted); }
.para + details.chg, .tbl + details.chg { padding-left: 92px; }
details.chg summary { cursor: pointer; width: max-content; }
details.chg ul { margin: 4px 0; padding-left: 18px; }
a.ref { text-decoration: underline dotted; text-underline-offset: 3px; }
.obj { display: inline-block; padding: 0 3px; border: 1px dashed var(--muted); border-radius: 3px; font-size: 12px; color: var(--muted); cursor: help; }
.tbl { margin: 10px 0 14px; overflow-x: auto; border-radius: 8px; }
.tbl table { border-collapse: collapse; font-size: 13px; background: var(--surface); }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; }
.tbl th { background: var(--bg); font-weight: 600; }
.doc img { max-width: 100%; height: auto; vertical-align: middle; }
.tbl img { max-height: 120px; }

.pop { position: fixed; z-index: 30; max-width: 460px; max-height: 260px; overflow: auto; padding: 12px 14px; font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.pop .h { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 8px 14px; border-radius: 8px; background: var(--fg); color: var(--bg); font-size: 14px; z-index: 40; }
.loading { color: var(--muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .top { gap: 8px; padding: 0 10px; }
  .search { min-width: 0; }
  .toc-btn { display: inline-block; flex: none; }
  .logo { font-size: 18px; }
  .toc { position: fixed; z-index: 25; top: var(--top); left: 0; width: min(86vw, 340px); background: var(--surface); transform: translateX(-102%); transition: transform .2s; box-shadow: 8px 0 24px rgba(0,0,0,.15); }
  .toc.open { transform: none; }
  .doc { padding: 14px 14px 100px; }
  .pt { grid-template-columns: 58px minmax(0, 1fr); }
  .pt.d2 { padding-left: 14px; }
  .pt.d3 { padding-left: 26px; }
  .para, .para.def, .para + details.chg, .tbl + details.chg { padding-left: 10px; }
}
