/* ===== Tokens ===== */
:root {
  --ink: #0d2b33;
  --ink-soft: #3d5a63;
  --night: #08323d;
  --teal: #0b7f9a;
  --teal-d: #075a6e;
  --teal-l: #e3f2f5;
  --gold: #f2b632;
  --gold-soft: #fdf3d6;
  --red: #cc3b2b;
  --bg: #f4f9fa;
  --card: #ffffff;
  --line: #d5e5e9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(8, 50, 61, .06), 0 6px 20px rgba(8, 50, 61, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.65; color: var(--ink); background: var(--bg); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--teal-d); text-underline-offset: 3px; }
a:hover { color: var(--night); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; color: var(--night); letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.wrap { width: min(1160px, 100% - 40px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--night); padding: 10px 16px; border-radius: 8px; z-index: 100; font-weight: 700; }
.skip:focus { left: 8px; }
.eyebrow { display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--teal-d); margin-bottom: .6em; }
.muted { color: var(--ink-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Header ===== */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--night); border-bottom: 3px solid var(--gold); }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand b { display: block; font-size: 1.15rem; line-height: 1.1; }
.brand small { display: block; font-size: .72rem; color: #a9cdd6; line-height: 1.2; margin-top: 2px; }
.nav { display: flex; gap: 2px; }
.nav a { color: #d6ebf0; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: .95rem; font-weight: 600; }
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a[aria-current="page"] { background: var(--gold); color: var(--night); }
.menu-btn { display: none; background: transparent; color: #fff; border: 2px solid rgba(255, 255, 255, .4); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 700; cursor: pointer; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 22px; border-radius: 12px; font-weight: 700; text-decoration: none; border: 2px solid transparent; cursor: pointer; font-size: 1rem; font-family: inherit; line-height: 1.2; }
.btn-gold { background: var(--gold); color: var(--night); }
.btn-gold:hover { background: #ffc94d; color: var(--night); }
.btn-line { border-color: rgba(255, 255, 255, .55); color: #fff; }
.btn-line:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.btn-teal { background: var(--teal-d); color: #fff; }
.btn-teal:hover { background: var(--night); color: #fff; }

/* ===== Hero ===== */
.hero { position: relative; background: var(--night) url("../assets/tamga-pattern.svg") repeat; background-size: 240px; color: #fff; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(8, 50, 61, .97) 38%, rgba(8, 50, 61, .78)); }
.hero .wrap { position: relative; display: grid; grid-template-columns: 1.25fr .9fr; gap: 48px; align-items: center; padding-block: 72px 80px; }
.hero h1 { color: #fff; margin-bottom: .3em; }
.hero .eyebrow { color: var(--gold); }
.hero .lead { font-size: 1.2rem; color: #d6ebf0; max-width: 40em; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.chain-card { background: #fff; color: var(--ink); border-radius: 20px; padding: 26px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.chain-card h2 { font-size: 1.05rem; margin-bottom: 4px; }
.chain-card .sub { font-size: .9rem; color: var(--ink-soft); margin-bottom: 18px; }
.chain { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 3px solid var(--red); }
.chain li { position: relative; padding: 5px 0 12px 16px; font-weight: 600; line-height: 1.3; }
.chain li::before { content: ""; position: absolute; left: -31px; top: 9px; width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 3px solid var(--red); }
.chain li small { display: block; font-weight: 400; font-size: .82rem; color: var(--ink-soft); }
.chain li:last-child { padding-bottom: 0; }
.chain li.end::before { background: var(--red); }
.chain li.end { color: var(--red); font-size: 1.15rem; }

/* ===== Sections ===== */
.section { padding-block: 64px; }
.section.alt { background: #fff; border-block: 1px solid var(--line); }
.section-head { max-width: 46em; margin-bottom: 32px; }
.section-head p { color: var(--ink-soft); font-size: 1.08rem; }
.page-head { background: var(--night) url("../assets/tamga-pattern.svg") repeat; background-size: 240px; color: #fff; position: relative; }
.page-head::before { content: ""; position: absolute; inset: 0; background: rgba(8, 50, 61, .94); }
.page-head .wrap { position: relative; padding-block: 48px 52px; }
.page-head h1 { color: #fff; font-size: clamp(1.8rem, 4vw, 2.7rem); margin-bottom: .3em; }
.page-head p { color: #d6ebf0; max-width: 46em; font-size: 1.1rem; margin: 0; }
.page-head .eyebrow { color: var(--gold); }

/* ===== Stats ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: -36px; position: relative; z-index: 2; }
.stat { background: #fff; border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); border-top: 4px solid var(--gold); }
.stat b { display: block; font-size: 2.2rem; line-height: 1; color: var(--teal-d); }
.stat span { display: block; margin-top: 8px; font-size: .95rem; color: var(--ink-soft); line-height: 1.35; }

/* ===== Cards ===== */
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h3 { margin-bottom: .4em; }
.card p:last-child { margin-bottom: 0; }
.card.link { text-decoration: none; color: inherit; display: block; transition: transform .15s, border-color .15s; }
.card.link:hover { transform: translateY(-3px); border-color: var(--teal); }
.card .num { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--teal-l); color: var(--teal-d); font-weight: 800; margin-bottom: 14px; }
.card .more { display: inline-block; margin-top: 8px; font-weight: 700; color: var(--teal-d); }
.note-card { border-left: 5px solid var(--gold); background: var(--gold-soft); border-radius: var(--radius); padding: 18px 22px; }
.note-card h3 { font-size: 1.02rem; margin-bottom: .3em; }
.note-card p { margin: 0; font-size: .96rem; }

/* ===== Compare table (home) ===== */
.verdicts { display: grid; gap: 12px; }
.verdict { display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.verdict b { display: block; }
.verdict span.t { font-size: .94rem; color: var(--ink-soft); }
.tag { display: inline-block; padding: 5px 12px; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.tag.yes { background: #dff3e6; color: #14532d; }
.tag.no { background: #fbe1dd; color: #8a2417; }
.tag.partial { background: #fdf0c9; color: #6b4a00; }

/* ===== Author teaser ===== */
.author-teaser { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: center; }
.author-teaser img, .author-photo { width: 100%; aspect-ratio: 4/5; object-fit: cover; object-position: 50% 12%; border-radius: 18px; box-shadow: var(--shadow); background: #e3f2f5; }

/* ===== Chronicle ===== */
.tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 24px; }
.search { flex: 1 1 280px; max-width: 460px; }
.search input { width: 100%; padding: 13px 16px; border: 2px solid var(--line); border-radius: 12px; font: inherit; background: #fff; color: var(--ink); }
.search input:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px rgba(11, 127, 154, .2); }
.chron { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 28px; align-items: start; }
.panel { position: sticky; top: 90px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.panel h2 { font-size: 1.9rem; margin-bottom: 2px; }
.panel .meta { color: var(--ink-soft); margin-bottom: 16px; font-size: .96rem; }
.panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--teal-d); margin: 20px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }
.chips li { background: var(--teal-l); color: var(--night); border-radius: 8px; padding: 4px 10px; font-size: .9rem; }
.panel blockquote { margin: 0; padding: 10px 14px; border-left: 4px solid var(--gold); background: var(--gold-soft); border-radius: 0 10px 10px 0; font-size: .95rem; }
.panel .empty { color: var(--ink-soft); font-size: .95rem; }
.panel .empty button { font: inherit; color: var(--teal-d); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; font-weight: 700; }
.gbar { display: flex; align-items: baseline; justify-content: space-between; font-weight: 700; margin-bottom: 4px; }
.track { height: 12px; border-radius: 999px; background: #e3edf0; overflow: hidden; }
.fill { height: 100%; border-radius: 999px; background: var(--teal); }
.eras { display: grid; gap: 12px; margin-bottom: 28px; }
.era { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.era header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-bottom: 10px; }
.era h3 { margin: 0; font-size: 1rem; }
.era header span { font-size: .85rem; color: var(--ink-soft); }
.era ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.era li { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: .88rem; line-height: 1.25; transition: background .2s, border-color .2s; }
.era li small { display: block; color: var(--ink-soft); font-size: .76rem; }
.era li.on { background: #fde5e1; border-color: var(--red); color: #7a1f14; font-weight: 700; }
.era li.on small { color: #8a2417; }
.zhuzes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.zhuz { border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); background: var(--teal-l); }
.zhuz.orta { background: #eef0fb; }
.zhuz.kishi { background: #e7f5ec; }
.zhuz.out { background: var(--gold-soft); }
.zhuz h3 { font-size: 1rem; margin-bottom: 10px; }
.zhuz ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.tribe { width: 100%; text-align: left; font: inherit; background: #fff; border: 2px solid transparent; border-radius: 10px; padding: 9px 12px; cursor: pointer; color: var(--ink); box-shadow: 0 1px 2px rgba(8, 50, 61, .1); line-height: 1.25; }
.tribe small { display: block; color: var(--ink-soft); font-size: .78rem; margin-top: 2px; }
.tribe:hover { border-color: var(--teal); }
.tribe[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.tribe[aria-pressed="true"] small { color: #ffe3de; }
.tribe.dim { opacity: .35; }
.tribe.hit { border-color: var(--gold); }
.zhuz-note { font-size: .88rem; color: var(--ink-soft); margin-top: 14px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.figure button { display: block; width: 100%; padding: 0; border: 0; background: #fff; cursor: zoom-in; }
.figure img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #fff; }
.figure figcaption { padding: 14px 18px 18px; font-size: .94rem; color: var(--ink-soft); border-top: 1px solid var(--line); }
.figure figcaption b { display: block; color: var(--ink); margin-bottom: 2px; }

/* ===== Genetics table ===== */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filters button { font: inherit; font-weight: 700; padding: 9px 16px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--night); border-color: var(--night); color: #fff; }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.gen { width: 100%; border-collapse: collapse; font-size: .96rem; }
.gen th { text-align: left; background: var(--night); color: #fff; padding: 12px 14px; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.gen td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.gen td:first-child { font-weight: 700; }
.gen .hg { white-space: nowrap; font-weight: 700; font-size: .9rem; }
.gen .share { width: 170px; }
.gen .share b { display: block; font-size: .9rem; margin-bottom: 4px; }
.gen td.nodata { color: var(--ink-soft); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.zh-tag { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }

/* ===== Accordion ===== */
.acc { display: grid; gap: 12px; }
.acc details { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.acc summary { cursor: pointer; padding: 18px 22px; font-weight: 700; font-size: 1.08rem; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--night); }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "+"; font-size: 1.6rem; line-height: 1; color: var(--teal-d); flex: none; }
.acc details[open] summary::after { content: "–"; }
.acc .body { padding: 0 22px 22px; }
.acc .body > p { color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.two > div { border-radius: 12px; padding: 14px 16px; font-size: .96rem; }
.two .h { background: var(--teal-l); }
.two .d { background: #f1ecfb; }
.two b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; color: var(--ink-soft); }
.conclusion { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; font-weight: 600; }

/* ===== Timeline / lists ===== */
.tl { list-style: none; margin: 0; padding: 0 0 0 20px; border-left: 3px solid var(--teal); display: grid; gap: 14px; }
.tl li { position: relative; padding-left: 18px; }
.tl li::before { content: ""; position: absolute; left: -30px; top: 8px; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 3px solid var(--night); }
.tl b { color: var(--night); }
.usage { counter-reset: u; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.usage li { counter-increment: u; display: flex; gap: 14px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.usage li::before { content: counter(u); flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--night); color: var(--gold); display: grid; place-items: center; font-weight: 800; }
.seal-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .96rem; }
.seal-table th { background: var(--night); color: #fff; text-align: left; padding: 12px 14px; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.seal-table td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.seal-table td:first-child { font-weight: 700; white-space: nowrap; }
.seal-table q { font-style: italic; }
.quote { border-left: 5px solid var(--gold); background: var(--gold-soft); padding: 16px 22px; border-radius: 0 var(--radius) var(--radius) 0; margin: 0 0 20px; }
.quote cite { display: block; margin-top: 6px; font-size: .9rem; color: var(--ink-soft); font-style: normal; }
.kv { display: grid; gap: 10px; }

/* ===== Sources ===== */
.src-group { margin-bottom: 36px; }
.src-group h2 { font-size: 1.4rem; display: flex; align-items: baseline; gap: 10px; }
.src-group h2 small { font-size: .9rem; color: var(--ink-soft); font-weight: 400; }
.src-list { margin: 0; padding: 0; list-style: none; counter-reset: s; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.src-list li { counter-increment: s; position: relative; padding: 12px 16px 12px 56px; border-top: 1px solid var(--line); font-size: .95rem; line-height: 1.5; }
.src-list li:first-child { border-top: 0; }
.src-list li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 30px; text-align: right; color: var(--teal-d); font-weight: 800; font-size: .9rem; }
.src-list li[hidden] { display: none; }
.count { color: var(--ink-soft); font-size: .95rem; margin-left: 4px; }

/* ===== Author ===== */
.author { display: grid; grid-template-columns: 300px 1fr; gap: 40px; align-items: start; }
.pubs { display: grid; gap: 24px; }
.pub { display: grid; grid-template-columns: 200px 1fr; gap: 26px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.pub .cover { width: 100%; aspect-ratio: var(--ar); background-repeat: no-repeat; background-size: var(--bs); background-position: var(--bp); border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; padding: 0; }
.pub h3 { font-size: 1.35rem; }
.pub .where { color: var(--teal-d); font-weight: 700; font-size: .95rem; margin-bottom: 10px; }
.pub .kw { font-size: .94rem; color: var(--ink-soft); }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.thumbs button { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 700; font-size: .9rem; color: var(--teal-d); cursor: zoom-in; }
.thumbs button:hover { border-color: var(--teal); }

/* ===== Lightbox ===== */
.lb { position: fixed; inset: 0; z-index: 200; background: rgba(4, 22, 28, .92); display: none; align-items: center; justify-content: center; padding: 24px; }
.lb.open { display: flex; }
.lb img { max-height: 88vh; max-width: 96vw; width: auto; border-radius: 8px; background: #fff; }
.lb button { position: absolute; top: 14px; right: 14px; font: inherit; font-weight: 700; background: var(--gold); color: var(--night); border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; }
.lb p { position: absolute; bottom: 14px; left: 0; right: 0; margin: 0; text-align: center; color: #d6ebf0; font-size: .95rem; padding: 0 20px; }

/* ===== Footer ===== */
.site-footer { background: var(--night); color: #b9d6dd; padding-block: 40px; margin-top: 40px; font-size: .94rem; }
.site-footer .cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; }
.site-footer b { color: #fff; }
.site-footer a { color: var(--gold); }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer .fine { margin-top: 24px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .15); font-size: .85rem; color: #8fb5be; }

/* ===== Responsive ===== */
@media (max-width: 1020px) {
  .chron { grid-template-columns: 1fr; }
  .panel { position: static; order: -1; }
  .hero .wrap { grid-template-columns: 1fr; padding-block: 52px 64px; }
  .grid-3, .gallery { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; top: 69px; left: 0; right: 0; background: var(--night); flex-direction: column; padding: 8px 20px 18px; border-bottom: 3px solid var(--gold); }
  .nav.open { display: flex; }
  .nav a { padding: 13px 12px; }
  .author, .pub { grid-template-columns: 1fr; }
  .author-photo { max-width: 260px; }
  .pub .cover { max-width: 220px; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .section { padding-block: 44px; }
  .grid-3, .grid-2, .gallery, .zhuzes, .two, .site-footer .cols { grid-template-columns: 1fr; }
  .author-teaser { grid-template-columns: 1fr; }
  .author-teaser img { max-width: 180px; }
  .verdict { grid-template-columns: 1fr; }
  .stats { gap: 10px; }
  .stat { padding: 16px; }
  .stat b { font-size: 1.8rem; }
  .gen thead { display: none; }
  .gen, .gen tbody, .gen tr, .gen td { display: block; width: 100%; }
  .gen tr { padding: 14px 16px; border-top: 1px solid var(--line); }
  .gen tr:first-child { border-top: 0; }
  .gen td { border: 0; padding: 3px 0; }
  .gen .share { width: auto; }
  .seal-table thead { display: none; }
  .seal-table, .seal-table tbody, .seal-table tr, .seal-table td { display: block; }
  .seal-table tr { padding: 12px 14px; border-top: 1px solid var(--line); }
  .seal-table td { border: 0; padding: 2px 0; white-space: normal !important; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
