:root {
  --bg: #fff;
  --bg-soft: #f6f5f2;
  --border: #e6e4de;
  --text: #1c1c1a;
  --text-soft: #6e6c66;
  --accent: #9e3d28;
  --accent-soft: #f8efe9;
  --chapter-link-line: #223322;
  --index-link-line: #222222;
  --max: 56rem;
  --sans: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #16160f;
  --bg-soft: #1f1f18;
  --border: #33312b;
  --text: #ecebe6;
  --text-soft: #a3a099;
  --accent: #e8836a;
  --accent-soft: #2a1a15;
  --chapter-link-line: #c5d4c4;
  --index-link-line: #d0d0d0;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 40;
  background: var(--bg);
  padding: .4rem .7rem;
  border: 1px solid var(--border);
}

/* ----- иноагент ----- */

.disclaimer {
  background: #141412;
  color: #e7e4db;
  padding: .85rem 1.25rem 1rem;
  border-top: 2px solid #f4e000;
  font-size: .72rem;
  line-height: 1.5;
}

.disclaimer p {
  margin: 0;
}

.disclaimer .note {
  color: #9c998f;
  margin-bottom: .35rem;
}

.disclaimer .legal {
  font-size: 2em;
  font-weight: 600;
  letter-spacing: .01em;
  text-transform: uppercase;
  line-height: 1.25;
}

.disclaimer .comment {
  margin-top: .45rem;
  color: #b9b6ac;
}

/* ----- header ----- */

body > header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  background: #ffff00;
  color: #111;
  border-bottom: 0;
}

.icon {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid #F1F100;
  border-radius: 3px;
  position: relative;
  top: -1px;
}

.brand {
  font-weight: 600;
  color: #111;
  text-decoration: none;
  letter-spacing: -.01em;
  min-width: 0;
  margin-right: auto;
}

.tools { display: flex; align-items: center; gap: .4rem; }

.lang-link {
  color: #111;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-decoration: none;
  padding: .15rem .2rem;
}
.lang-link:hover,
.lang-link:focus-visible { text-decoration: underline; }

.nav-toggle,
.theme-toggle {
  font: inherit;
  cursor: pointer;
}

.nav-toggle {
  display: none;
  font-size: .82rem;
  padding: .28rem .65rem;
  background: transparent;
  color: #111;
  border: 1px solid #111;
  border-radius: 3px;
}
.nav-toggle:hover { color: #111; border-color: #111; }

.theme-toggle {
  font-size: .95rem;
  line-height: 1;
  padding: .2rem .35rem;
  margin: 0;
  background: none;
  border: 0;
  color: #111;
  opacity: .38;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
  opacity: .75;
  color: #111;
}
.theme-toggle:focus-visible {
  outline: 1px solid #111;
  outline-offset: 2px;
}

/* ----- layout ----- */

.wrap {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  gap: 1.5rem 1.75rem;
  max-width: 80rem;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 4rem;
}

#nav {
  position: sticky;
  top: 4.2rem;
  align-self: start;
  z-index: 15;
  font-size: .88rem;
}

#nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

#nav a {
  display: flex;
  align-items: baseline;
  position: relative;
  gap: .45rem;
  padding: .38rem 0 .38rem .55rem;
  color: var(--text-soft);
  text-decoration: none;
  border-left: 1px solid transparent;
  margin-left: -1px;
  white-space: nowrap;
}
#nav a:hover,
#nav a:focus-visible { color: var(--text); }
#nav a[aria-current="page"] {
  color: var(--text);
  border-left-color: var(--text);
}
#nav .n {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: .82rem;
}

#nav .label {
  position: absolute;
  left: calc(100% + .4rem);
  top: 50%;
  transform: translate(-.3rem, -50%);
  padding: .2rem .65rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  opacity: 0;
  pointer-events: none;
  z-index: 16;
  transition: opacity .12s ease, transform .12s ease;
}

#nav a:hover .label,
#nav a:focus-visible .label,
#nav a:active .label {
  opacity: 1;
  transform: translate(0, -50%);
}

main { min-width: 0; max-width: var(--max); }

/* ----- index ----- */

main > h1 {
  font-family: var(--serif);
  font-size: clamp(1.85rem, 4.5vw, 2.6rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 1rem;
}

.intro { color: var(--text-soft); }
.intro p { margin: 0 0 .8rem; }

.index {
  list-style: none;
  margin: 2.25rem 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.index > li {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border);
}

.index > li > a {
  display: flex;
  gap: .85rem;
  align-items: baseline;
  color: inherit;
  text-decoration: none;
}

.index span {
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
}

.index strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.35rem;
}

.index > li > a:hover strong { color: var(--accent); }

.index ul {
  list-style: none;
  margin: .45rem 0 0 2.15rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem .9rem;
  font-size: .86rem;
}

.index ul li {
  display: inline-flex;
  align-items: center;
}

.index ul li::before {
  content: "·";
  margin-right: .35rem;
  color: var(--text-soft);
  font-size: .72em;
  line-height: 1;
}

.index ul a {
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}

.index ul a:hover,
.index ul a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--index-link-line);
}

/* ----- chapter ----- */

.kicker {
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 .4rem;
}

article > h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 1.4rem;
}

.toc {
  margin: 0 0 2.25rem;
  padding: 0 0 1.15rem;
  border-bottom: 1px solid var(--border);
}

.toc p {
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 .4rem;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc li {
  display: flex;
  align-items: center;
  margin: .15rem 0;
}

.toc li::before {
  content: "·";
  margin-right: .35rem;
  color: var(--text-soft);
  font-size: .72em;
  line-height: 1;
}

.toc a {
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--chapter-link-line);
}

.body { font-size: 1.05rem; }
.body h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1.25;
  margin: 2.4rem 0 .7rem;
  scroll-margin-top: 4.5rem;
}
.body h3 {
  font-size: 1.12rem;
  font-weight: 600;
  margin: 1.8rem 0 .45rem;
  scroll-margin-top: 4.5rem;
}
.body p { margin: 0 0 1.05rem; }
.body blockquote {
  margin: 1.4rem 0;
  padding: 0 0 0 1.1rem;
  border-left: 1px solid var(--border);
  color: var(--text-soft);
}
.body img { max-width: 100%; height: auto; }
.body hr { border: 0; border-top: 1px solid var(--border); margin: 2.25rem 0; }

.body .headerlink {
  opacity: 0;
  margin-left: .3rem;
  text-decoration: none;
  font-weight: 400;
}
.body h2:hover .headerlink,
.body h3:hover .headerlink,
.body h4:hover .headerlink { opacity: .45; }

.body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0;
  font-size: .95rem;
  display: block;
  overflow-x: auto;
}
.body th, .body td {
  border-bottom: 1px solid var(--border);
  padding: .45rem .65rem;
  text-align: left;
}
.body th {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-soft);
}
.body td:not(:first-child),
.body th:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.body .courts-pub {
  margin: 1.1rem 0 1.4rem;
  max-height: 400px;
  overflow: auto;
  font-size: .6em;
}
.body .courts-pub table {
  display: table;
  width: 100%;
  margin: 0;
  line-height: 1.3;
  overflow-x: visible;
}
.body .courts-pub th,
.body .courts-pub td {
  padding: .2rem .35rem;
  text-align: left;
  font-variant-numeric: normal;
  vertical-align: top;
}
.body .courts-pub th {
  white-space: nowrap;
}
.body .courts-pub tbody tr:nth-child(even) {
  background: var(--bg-soft);
}
.body .courts-pub tr {
  font-size: .7em;
}
.body .courts-pub td.n {
  width: 2rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.body .courts-pub td.cat,
.body .courts-pub td.result,
.body .courts-pub td.party {
  max-width: 14rem;
  word-break: break-word;
}

.body .callout {
  margin: 1.1rem 0 1.4rem;
  padding: .45rem .55rem .55rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  overflow-x: auto;
  font-size: .6em;
}
.body .callout table {
  display: table;
  width: 100%;
  margin: 0;
  line-height: 1.3;
  overflow-x: visible;
}
.body .callout th,
.body .callout td {
  padding: .2rem .35rem;
  text-align: left;
  font-variant-numeric: normal;
  vertical-align: top;
}
.body .callout th {
  white-space: nowrap;
}
.body .callout tbody tr:nth-child(even) {
  background: var(--bg);
}
.body .callout .data-note {
  margin: .55em 0 0;
  color: var(--text-soft);
  font-size: .95em;
  line-height: 1.35;
}
.body .callout .rev-box {
  margin-top: .55em;
  padding: .45em .55em;
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: .95em;
  line-height: 1.35;
}

.body code {
  background: var(--bg-soft);
  padding: .12em .32em;
  font-size: .9em;
}
.body pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
}
.body pre code { background: none; padding: 0; }

/* ----- embeds ----- */

.embed { margin: 1.6rem 0; }

.embed--youtube {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  overflow: hidden;
}
.embed--youtube iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed--datawrapper iframe { display: block; }

.embed--still img {
  display: block;
  width: 100%;
  height: auto;
}
.embed--still figcaption {
  margin-top: .4rem;
  font-size: .85rem;
  color: var(--text-soft);
}

.embed--plotly iframe {
  display: block;
  width: 100%;
  min-height: 450px;
  border: 0;
  background: #fff;
}

.embed--plotly-piter iframe {
  width: 100%;
  height: 950px;
}

/* ----- pager ----- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.pager a {
  text-decoration: none;
  color: var(--text);
  line-height: 1.35;
}

.pager a:hover { color: var(--accent); }

.pager span {
  display: block;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: .15rem;
}

.pager [rel="next"] { margin-left: auto; text-align: right; }

body > footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
  text-align: center;
  color: var(--text-soft);
  font-size: .82rem;
}

body > footer p { margin: 0; }
body > footer p + p {
  margin-top: .35rem;
  color: #a8a69e;
  font-size: .72rem;
}
:root[data-theme="dark"] body > footer p + p { color: #6a6862; }

/* ----- mobile ----- */

@media (max-width: 640px) {
  .wrap { grid-template-columns: 1fr; gap: 1rem; padding: 1.2rem 1rem 3rem; }
  .nav-toggle { display: block; }
  #nav {
    position: static;
    z-index: auto;
    display: none;
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--border);
  }
  #nav.open { display: block; }
  #nav a { white-space: normal; }
  #nav .label {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    transition: none;
  }
  main { max-width: none; }
  .disclaimer { padding: .75rem 1rem .9rem; }
}
