/* poker.altbar.ru — тёмная тема, один файл, без сборщика. */

:root {
  color-scheme: dark;
  --bg: #0d1014;
  --bg-soft: #12161c;
  --panel: #161b22;
  --panel-2: #1b212a;
  --line: #262d38;
  --line-soft: #1e242d;
  --text: #e7ebf0;
  --muted: #8d97a5;
  --pos: #3fb950;
  --neg: #f4564a;
  --accent: #58a6ff;
  --felt: #1f7a4d;
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --measure: min(72em, 72ch);
  --header-h: 56px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  font-feature-settings: "tnum" 1;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.01em; margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
code, .mono, .n, pre { font-family: var(--mono); }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.neutral { color: var(--muted); }
.pip { color: var(--felt); }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  height: var(--header-h);
  padding: 0 clamp(.75rem, 3vw, 1.5rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 650; letter-spacing: -.02em; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--muted); padding: .35rem .6rem; border-radius: 8px;
  white-space: nowrap; font-size: .93rem;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--panel-2); color: var(--text); }
.find { flex: 0 1 220px; }
.find input, .bigfind input {
  width: 100%; padding: .4rem .7rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font: inherit; font-size: .9rem;
}
.find input:focus, .bigfind input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.out button, .bigfind button {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: .35rem .65rem; border-radius: 8px; font: inherit; font-size: .88rem; cursor: pointer;
}
.out button:hover, .bigfind button:hover { color: var(--text); border-color: var(--muted); }

/* ---------- каркас ---------- */
.wrap {
  max-width: 1180px; margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(.75rem, 3vw, 1.5rem) 4rem;
}
.wrap.center { min-height: 100dvh; display: grid; place-items: center; padding-top: 0; }
.foot {
  max-width: 1180px; margin: 0 auto; padding: 1rem clamp(.75rem, 3vw, 1.5rem) 2rem;
  display: flex; gap: .75rem; justify-content: space-between; flex-wrap: wrap;
  color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line-soft);
}
.page-head { margin-bottom: 1.5rem; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(.9rem, 2.5vw, 1.25rem);
  margin-bottom: 1.25rem; scroll-margin-top: calc(var(--header-h) + 12px);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem;
}
.card.empty { text-align: center; color: var(--muted); }
.card.empty h1 { font-size: 3rem; color: var(--line); }

.banner {
  display: flex; gap: .5rem; flex-wrap: wrap;
  background: #2a2113; border: 1px solid #5a4520; color: #e8cf9a;
  border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.25rem;
}
.alert {
  background: #2a1414; border: 1px solid #5c2626; color: #f2b8b3;
  border-radius: 8px; padding: .55rem .75rem; font-size: .9rem;
}

/* ---------- логин ---------- */
.login { width: min(380px, 92vw); display: grid; gap: .75rem; }
.login h1 { font-size: 1.3rem; margin: 0; }
.login label { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); }
.login input {
  padding: .55rem .7rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font: inherit;
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login button {
  margin-top: .25rem; padding: .6rem; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--felt); color: #fff; font: inherit; font-weight: 600;
}
.login button:hover { filter: brightness(1.12); }

/* ---------- цифры ---------- */
.totals {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem;
}
.tot { background: var(--panel); padding: .7rem .8rem; display: grid; gap: .1rem; }
.tot span { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.tot b { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; }

.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .75rem; margin-bottom: 1.25rem; align-items: start;
}
.card.hl { padding: .85rem 1rem; }
.card.hl h3 { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.card.hl .val { font-family: var(--mono); font-size: 1.2rem; font-weight: 650; margin: .15rem 0 .35rem; overflow-wrap: anywhere; }
/* заметки бывают длинные — карточка не должна вырастать на пол-экрана */
.card.hl p.muted { font-size: .82rem; line-height: 1.5; margin: 0; max-height: 8.4em; overflow-y: auto; scrollbar-width: thin; }
.card.hl p.muted::-webkit-scrollbar { width: 4px; }
.card.hl p.muted::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.ranked { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.ranked li {
  display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem;
  padding: .45rem .6rem; background: var(--panel-2); border-radius: 8px;
}
.ranked .name { min-width: 0; overflow-wrap: anywhere; }
.ranked .mono { font-size: .85rem; text-align: right; }
.ranked .mono.muted { grid-column: 2; font-size: .78rem; }

/* ---------- таблицы ---------- */
.tablewrap { max-height: 32rem; overflow: auto; border: 1px solid var(--line-soft); border-radius: 10px; margin-top: .9rem; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; }
table.grid th, table.grid td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--panel-2);
  color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  cursor: pointer; user-select: none;
}
table.grid thead th:hover { color: var(--text); }
table.grid thead th[aria-sort]::after { content: " ▾"; opacity: .8; }
table.grid thead th[aria-sort="ascending"]::after { content: " ▴"; }
table.grid tbody th { font-weight: 500; white-space: normal; min-width: 9rem; }
table.grid tbody tr:hover td, table.grid tbody tr:hover th { background: var(--panel-2); }
table.grid td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.ci { color: var(--muted); font-size: .82rem; }

/* ---------- графики ---------- */
.chart-box { margin: 0; }
.chart { width: 100%; }
.metric-switch { display: flex; gap: .25rem; flex-wrap: wrap; }
.metric-switch button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  padding: .25rem .55rem; border-radius: 7px; font: inherit; font-size: .8rem; cursor: pointer;
}
.metric-switch button.on { background: var(--felt); border-color: var(--felt); color: #fff; }
.toc-inline { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1.25rem; }
.toc-inline a { background: var(--panel); border: 1px solid var(--line); color: var(--muted); padding: .25rem .6rem; border-radius: 999px; font-size: .82rem; }
.toc-inline a:hover { color: var(--text); text-decoration: none; }

/* ---------- библиотека ---------- */
.doclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line-soft); border-radius: 8px; overflow: hidden; }
.doclist li { background: var(--panel); padding: .5rem .7rem; display: grid; grid-template-columns: 1fr auto; gap: 0 .75rem; align-items: baseline; }
.doclist li:hover { background: var(--panel-2); }
.doclist .path { grid-column: 1 / -1; font-size: .74rem; }
.doclist .mono { font-size: .8rem; }
.count { font-size: .8rem; font-weight: 400; }

.hit { border-bottom: 1px solid var(--line-soft); padding: .9rem 0; }
.hit h2 { font-size: 1.05rem; }
.hit .mono { font-size: .76rem; }
.snippet { font-size: .88rem; color: #c3cbd6; margin: .25rem 0; overflow-wrap: anywhere; }
mark { background: #4a3c12; color: #ffd98a; border-radius: 3px; padding: 0 .12em; }
.bigfind { display: flex; gap: .5rem; margin: .75rem 0; max-width: 520px; }

/* ---------- документ ---------- */
.wrap.reading { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: clamp(1rem, 3vw, 2.5rem); align-items: start; }
.wrap.reading.toc-left { grid-template-columns: 220px minmax(0, 1fr); }
.wrap.reading.toc-left .doc { order: 2; }
.wrap.reading.toc-left .toc { order: 1; }
.doc { min-width: 0; }
.doc-head { border-bottom: 1px solid var(--line); padding-bottom: .9rem; margin-bottom: 1.25rem; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.meta { font-size: .8rem; }
.toc { position: sticky; top: calc(var(--header-h) + 1rem); max-height: calc(100dvh - var(--header-h) - 3rem); overflow: auto; font-size: .84rem; }
.toc-title { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.toc nav { display: grid; gap: .15rem; border-left: 1px solid var(--line); }
.toc a { color: var(--muted); padding: .12rem .6rem; overflow-wrap: anywhere; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.lvl3 { padding-left: 1.3rem; font-size: .8rem; }
.toc a.active { color: var(--text); box-shadow: inset 2px 0 0 var(--felt); }

.md { max-width: var(--measure); overflow-wrap: break-word; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.8rem 0 .6rem; scroll-margin-top: calc(var(--header-h) + 12px); }
.md h2 { border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.md ul, .md ol { padding-left: 1.3rem; }
.md li { margin: .2rem 0; }
.md blockquote { margin: 1rem 0; padding: .1rem 1rem; border-left: 3px solid var(--felt); color: #c3cbd6; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.md img { max-width: 100%; height: auto; }
.md table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.md .tablewrap { max-height: none; }
.md th, .md td { border: 1px solid var(--line); padding: .35rem .55rem; text-align: left; }
.md thead th { background: var(--panel-2); }
.md code { background: var(--panel-2); padding: .1em .35em; border-radius: 5px; font-size: .88em; }
.md pre { background: #0a0d11; border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md .header-anchor { color: var(--line); margin-left: .35rem; text-decoration: none; font-weight: 400; }
.md h2:hover .header-anchor, .md h3:hover .header-anchor { color: var(--muted); }

/* ---------- мобильное ---------- */
@media (max-width: 900px) {
  .wrap.reading, .wrap.reading.toc-left { grid-template-columns: minmax(0, 1fr); }
  .toc, .wrap.reading.toc-left .toc {
    order: 0; position: static; max-height: 11rem; margin-bottom: 1rem;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem;
  }
  .wrap.reading .doc, .wrap.reading.toc-left .doc { order: 1; }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .find { display: none; }
  .brand span.pip + * { display: none; }
  .nav { gap: 0; }
  .doclist li { grid-template-columns: 1fr; }
  .doclist li .mono:not(.path) { display: none; }
  table.grid { font-size: .82rem; }
  .tablewrap { max-height: 24rem; }
}

/* блоки раздач */
h3.sub, h4.sub { margin: 1.2rem 0 .4rem; color: var(--muted); font-size: .84rem; text-transform: uppercase; letter-spacing: .05em; }
table.grid.kv tbody th { color: var(--muted); font-weight: 400; }
table.grid.kv { font-size: .85rem; }
