:root{
  --bg:#fbfaf8; --fg:#1c1b19; --muted:#6b6862; --line:#e3e0da;
  --accent:#8a4b2a; --accent-soft:#f2ece6; --code:#f3f1ed;
  --sidebar:300px;
}
@media (prefers-color-scheme: dark){
  :root{ --bg:#161513; --fg:#e8e5df; --muted:#9c978e; --line:#2e2c28;
         --accent:#d99a6c; --accent-soft:#26231f; --code:#211f1c; }
}
*{box-sizing:border-box}
html{
  scroll-behavior:smooth;
  overflow-x:hidden;
  max-width:100%;
}
body{
  margin:0; background:var(--bg); color:var(--fg);
  font:16px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  overflow-x:hidden;
  max-width:100%;
}
a{color:var(--accent); text-decoration:none}
a:hover{text-decoration:underline}

/* sidebar */
#sidebar{
  position:fixed; top:0; left:0; bottom:0; width:var(--sidebar);
  overflow-y:auto; padding:26px 20px 40px;
  border-right:1px solid var(--line); background:var(--bg);
}
.brand{display:block; font-weight:700; font-size:19px; color:var(--fg); margin-bottom:22px; line-height:1.25}
.brand span{display:block; font-weight:400; font-size:12px; color:var(--muted); letter-spacing:.04em; text-transform:uppercase; margin-top:3px}
.brand:hover{text-decoration:none}
ul.nav{list-style:none; margin:0 0 24px; padding:0}
ul.nav li{margin-bottom:2px; border-radius:7px}
ul.nav li a{display:block; padding:7px 10px 2px; font-weight:600; font-size:14.5px; color:var(--fg)}
ul.nav li span{display:block; padding:0 10px 7px; font-size:12px; color:var(--muted); line-height:1.4}
ul.nav li:hover{background:var(--accent-soft)}
ul.nav li.active{background:var(--accent-soft)}
ul.nav li.active a{color:var(--accent)}
.toc{border-top:1px solid var(--line); padding-top:16px}
.toc h4{margin:0 0 10px; padding-left:10px; font-size:11px; letter-spacing:.09em; text-transform:uppercase; color:var(--muted); font-weight:600}
.toc ul{list-style:none; margin:0; padding:0}
.toc li{margin:0 0 5px; padding-left:10px}
.toc a{font-size:13px; color:var(--muted); line-height:1.4; display:block}
.toc a:hover{color:var(--accent); text-decoration:none}
.toc ul.sub{margin:4px 0 10px 20px; padding-left:11px; border-left:1px solid var(--line)}
.toc ul.sub li{padding-left:0}
.toc ul.sub a{font-size:12.5px}
.foot{margin-top:26px; padding-top:14px; border-top:1px solid var(--line); font-size:12px; color:var(--muted)}

/* main: column after the sidebar; overflow clipped so wide math/figures cannot widen the page */
main{
  margin-left:var(--sidebar);
  padding:40px 40px 110px;
  max-width:1400px;
  min-width:0;
  overflow-x:hidden;
}
@media (min-width:1600px){ main{padding:44px 48px 120px} }
@media (max-width:820px){ main{padding:28px 20px 80px} }
.tools{display:flex; align-items:center; gap:12px; margin-bottom:26px}
#filter{
  flex:1; padding:9px 13px; font-size:14px; color:var(--fg);
  background:var(--bg); border:1px solid var(--line); border-radius:8px;
}
#filter:focus{outline:none; border-color:var(--accent)}
#count{font-size:12.5px; color:var(--muted); white-space:nowrap}

article h1{font-size:30px; line-height:1.25; margin:0 0 18px; letter-spacing:-.01em}
article h1+p{color:var(--muted)}
article h2{
  font-size:23px; margin:46px 0 14px; padding-top:22px;
  border-top:1px solid var(--line); letter-spacing:-.01em;
}
article h3{font-size:17.5px; margin:32px 0 10px; line-height:1.35}
article h4{font-size:15px; margin:22px 0 8px; color:var(--muted)}
article p{margin:0 0 14px; text-align:justify; text-justify:inter-word;
  hyphens:auto; -webkit-hyphens:auto; hyphenate-limit-chars:6 3 3}
article li{text-align:justify; hyphens:auto; -webkit-hyphens:auto}
/* выключки не нужны там, где строка короткая или центрированная */
article figure p, article figure .figlink,
article p.origin, article .attrib p, article table p,
article p:has(> img), article blockquote p{text-align:left; hyphens:manual}
article figcaption{text-align:justify; hyphens:auto; -webkit-hyphens:auto}
article .algo li{text-align:left; hyphens:manual}
article ul,article ol{margin:0 0 16px; padding-left:22px}
article li{margin-bottom:7px}
article li>p{margin-bottom:6px}
article hr{border:none; border-top:1px solid var(--line); margin:34px 0}
article blockquote{
  margin:0 0 16px; padding:10px 16px; border-left:3px solid var(--accent);
  background:var(--accent-soft); border-radius:0 7px 7px 0;
}
article blockquote p:last-child{margin-bottom:0}
code{background:var(--code); padding:1.5px 5px; border-radius:4px; font-size:.9em;
     font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
pre{background:var(--code); padding:14px 16px; border-radius:9px; overflow-x:auto; margin:0 0 16px}
pre code{background:none; padding:0; font-size:13px; line-height:1.55}
strong{font-weight:650}
article table{border-collapse:collapse; width:100%; max-width:100%; margin:0 0 18px; font-size:14px}
article th,article td{border:1px solid var(--line); padding:7px 10px; text-align:left}
article th{background:var(--accent-soft); font-weight:600}

.hidden{display:none !important}
mark{background:#ffe9a8; color:#1c1b19; border-radius:3px; padding:0 2px}
@media (prefers-color-scheme: dark){ mark{background:#6b5620; color:#f4efe4} }

/* index cards */
.cards{display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:14px; margin:22px 0 30px}
.card{
  display:block; padding:16px 18px; border:1px solid var(--line);
  border-radius:11px; background:var(--bg); color:var(--fg);
}
.card:hover{border-color:var(--accent); text-decoration:none}
.card b{display:block; font-size:15.5px; margin-bottom:5px}
.card span{font-size:13px; color:var(--muted); line-height:1.45}
.legend{font-size:14px; color:var(--muted)}

#menu-btn{
  display:none; position:fixed; top:12px; left:12px; z-index:20;
  width:40px; height:40px; font-size:18px; cursor:pointer;
  background:var(--bg); color:var(--fg); border:1px solid var(--line); border-radius:9px;
}
@media (max-width:1000px){
  #menu-btn{display:block}
  #sidebar{transform:translateX(-100%); transition:transform .2s ease; z-index:15; width:290px; box-shadow:0 0 40px rgba(0,0,0,.14)}
  #sidebar.open{transform:none}
  main{margin-left:0; padding:64px 20px 80px}
}

/* быстрый доступ к позициям с кодом */
.practice{
  margin:0 0 26px; padding:15px 18px 12px;
  border:1px solid var(--line); border-left:3px solid var(--accent);
  border-radius:0 10px 10px 0; background:var(--accent-soft);
}
.practice h4{
  margin:0 0 9px; font-size:11px; letter-spacing:.09em; text-transform:uppercase;
  color:var(--accent); font-weight:700;
}
.practice ul{margin:0; padding-left:18px; columns:2; column-gap:26px}
.practice li{margin-bottom:5px; font-size:13.5px; break-inside:avoid}
@media (max-width:700px){ .practice ul{columns:1} }

/* страница полного перевода */
.attrib{
  margin:0 0 24px; padding:14px 18px; border:1px solid var(--line);
  border-radius:10px; background:var(--accent-soft); font-size:13.5px; color:var(--muted);
}
.attrib p{margin:0 0 7px} .attrib p:last-child{margin:0}
.attrib b{color:var(--fg)}

article figure{margin:26px 0; text-align:center; max-width:100%}
article figure img{max-width:100%; height:auto; border:1px solid var(--line); border-radius:9px; background:#fff}
article figure .figlink{display:none; font-size:13px; color:var(--muted); padding:26px 14px;
  border:1px dashed var(--line); border-radius:9px; margin:0}
article figure.nofig img{display:none}
article figure.nofig .figlink{display:block}
article figcaption{margin-top:10px; font-size:13.5px; color:var(--muted); line-height:1.5; text-align:left}

a.fn{font-size:.72em; vertical-align:super; padding:0 1px; text-decoration:none}
ol.footnotes{font-size:13.5px; color:var(--muted); padding-left:20px}
ol.footnotes li{margin-bottom:7px}
ul.refs{list-style:none; padding-left:0; font-size:13.5px}
ul.refs li{margin-bottom:8px; padding-left:20px; text-indent:-20px; line-height:1.5}

/* Display math must not widen the page: cap to the column and scroll locally if needed.
   Assistive MathML is a known MathJax 3 source of viewport overflow. */
mjx-container{
  max-width:100%;
  box-sizing:border-box;
}
mjx-container[display="true"]{
  display:block;
  margin:18px 0 !important;
  max-width:100%;
  overflow-x:auto;
  overflow-y:hidden;
}
mjx-assistive-mml{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  overflow:hidden !important;
  clip:rect(1px,1px,1px,1px);
  clip-path:inset(50%);
}

p.origin{
  margin:34px 0 0; padding-top:16px; border-top:1px solid var(--line);
  font-size:13.5px; color:var(--muted);
}

/* --- список полных переводов на обзорной странице --- */
.cards-tr{display:flex; flex-direction:column; gap:0; margin:0 0 26px;
  border-top:1px solid var(--line)}
a.tr{display:grid; grid-template-columns:150px 1fr; gap:16px; align-items:stretch;
  padding:16px 8px; border:none; border-bottom:1px solid var(--line);
  text-decoration:none; color:inherit; background:transparent;
  transition:background .15s}
a.tr:hover{background:var(--accent-soft)}
.tr-thumb{display:block; width:150px; min-height:112px; overflow:hidden;
  border:none; border-radius:6px; background:transparent}
.tr-thumb img{width:100%; height:100%; object-fit:cover; display:block}
.tr-thumb .noimg{display:block; width:100%; height:100%;
  background:repeating-linear-gradient(135deg,transparent,transparent 7px,
    var(--accent-soft) 7px,var(--accent-soft) 14px)}
.tr-body{display:block; min-width:0}
.tr-t{display:block; font-weight:600; line-height:1.3; margin-bottom:5px}
a.tr:hover .tr-t{text-decoration:underline}
.tr-d{display:block; font-size:14px; line-height:1.5; color:var(--muted);
  text-align:justify; hyphens:auto; -webkit-hyphens:auto}
.tr-date{display:block; margin-top:6px; font-size:12.5px; color:var(--muted); opacity:.8}
.tr-ext{color:var(--accent); cursor:pointer; text-decoration:underline;
  text-decoration-style:dotted; text-underline-offset:2px}
.tr-ext:hover{text-decoration-style:solid}
.tr-ext:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:3px}
@media (max-width:640px){
  a.tr{grid-template-columns:104px 1fr; gap:11px}
  .tr-thumb{width:104px}
}

/* ссылка на репозиторий внутри карточки перевода */
.repo{color:var(--accent); cursor:pointer; text-decoration:underline;
  text-decoration-style:dotted; text-underline-offset:2px}
.repo:hover{text-decoration-style:solid}
.repo:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:3px}
.xref{color:var(--accent); cursor:pointer; text-decoration:underline; text-underline-offset:2px}
.xref:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:3px}

/* теги (ключевые слова) в карточках переводов */
.tr-tags{display:flex; flex-wrap:wrap; gap:5px; margin-top:8px}
.tag{display:inline-block; padding:2px 8px; font-size:11.5px; line-height:1.55;
  color:var(--muted); background:var(--accent-soft); border-radius:20px;
  white-space:nowrap; max-width:100%; overflow:hidden; text-overflow:ellipsis;
  cursor:pointer; transition:background .13s, color .13s, box-shadow .13s}
.tag:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
/* карточка под курсором: чипы чуть светлее фона строки */
a.tr:hover .tag{background:var(--bg); color:var(--muted)}
/* сам тег под курсором — контрастная обводка и цвет акцента, без заливки */
.tag:hover, a.tr:hover .tag:hover{
  background:var(--accent-soft); color:var(--accent);
  box-shadow:inset 0 0 0 1px var(--accent)}

/* перекрёстные ссылки на литературу */
a.cite{color:var(--accent); text-decoration:none; font-variant-numeric:tabular-nums}
a.cite:hover{text-decoration:underline}
a.backref{color:var(--muted); text-decoration:none; font-size:13px; margin-left:4px}
a.backref:hover{color:var(--accent)}
article ul li:target, article li:target{background:var(--accent-soft); border-radius:6px;
  box-shadow:0 0 0 6px var(--accent-soft)}
:target{scroll-margin-top:24px}







/* рейтинг: 5 звёзд (SVG), закраска = ширина вложенного svg */
.rating{
  display:inline-flex; align-items:center; gap:6px;
  font-size:12.5px; color:var(--muted); line-height:1; vertical-align:middle;
}
.rating-stars{
  display:inline-block;
  width:72px; height:14px;
  vertical-align:-2px;
}
.rating-stars svg{ display:block; width:100%; height:100%; }
.rating-stars .rs-empty{ fill:#c8c3bb; }
.rating-stars .rs-full{ fill:var(--accent); }
@media (prefers-color-scheme: dark){
  .rating-stars .rs-empty{ fill:#4a4640; }
}
.rating-score{ font-variant-numeric:tabular-nums; color:var(--muted); }
.tr-date .rating{ margin:0; }
.tr-date .rating-stars{ width:66px; height:13px; }
article > .rating{
  display:flex; margin:0 0 14px; font-size:13.5px;
}
article > .rating .rating-stars{ width:96px; height:18px; }

/* рейтинг вместо ⭐ в оглавлении разделов (execution и т.п.) */
.rating--h3, .rating--toc{
  display:inline-flex; align-items:center; gap:5px;
  vertical-align: -2px; margin-right: 4px;
  font-weight: 500;
}
.rating--h3 .rating-stars{ width:96px; height:18px; }
.rating--toc .rating-stars{ width:64px; height:12px; }
.rating--h3 .rating-score, .rating--toc .rating-score{
  font-size: 13.5px; color: var(--muted); font-weight: 600;
}
h3 .rating--h3{ margin-right: 8px; }
.toc .rating--toc{ margin-right: 2px; }
.toc a:has(.rating--toc){ display:flex; align-items:flex-start; gap:6px; }
.toc .rating--toc{ flex:0 0 auto; margin-top:2px; }

/* ссылка-заголовок перевода в списках разделов */
a.h3-title{
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
}
a.h3-title:hover{
  color: var(--accent);
  text-decoration: underline;
}
h3:has(.rating--h3){
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
}
h3 .rating--h3{ flex: 0 0 auto; }
h3 a.h3-title{ flex: 1 1 12em; min-width: 0; }
