/*
 * Bilim — стили сайта. Без фреймворков и веб-шрифтов: страница должна быстро
 * открываться на школьном телефоне с медленным интернетом.
 * Цвета: синий (небо флага) — основной, золото — акценты.
 */
:root {
    --blue: #0b5c8f;
    --blue-dark: #08456c;
    --blue-soft: #e8f2f9;
    --sky: #19a7ce;
    --gold: #f5b82e;
    --gold-soft: #fff6df;
    --ink: #1c2733;
    --muted: #5d6b7a;
    --line: #e2e8ef;
    --bg: #f7f8fa;
    --card: #fff;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 40, 64, .06), 0 4px 16px rgba(16, 40, 64, .06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.6 var(--font); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--sky); }
img, svg { vertical-align: middle; }
button, input { font: inherit; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.main { flex: 1; padding-bottom: 48px; }

/* ---------- шапка ---------- */
.header { background: #fff; box-shadow: 0 1px 0 var(--line); position: relative; z-index: 10; }
.header::after { /* орнаментная полоса */
    content: ""; display: block; height: 4px;
    background: repeating-linear-gradient(135deg, var(--gold) 0 8px, #ffd56b 8px 16px);
}
.header-in { display: flex; align-items: center; gap: 24px; min-height: 72px; }
.logo { display: flex; align-items: center; gap: 12px; color: var(--ink); flex-shrink: 0; }
.logo:hover { color: var(--ink); }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-text b { font-size: 22px; letter-spacing: -.01em; color: var(--blue); }
.logo-text small { font-size: 12px; color: var(--muted); max-width: 240px; }
.header-search { flex: 1; max-width: 460px; margin-left: auto; display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.header-search:focus-within { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(25, 167, 206, .15); background: #fff; }
.header-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 9px 16px; outline: none; }
.header-search button { border: 0; background: transparent; color: var(--muted); padding: 0 14px; cursor: pointer; }
.header-search button:hover { color: var(--blue); }
.nav { background: var(--blue); }
.nav-in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav-in::-webkit-scrollbar { display: none; }
.nav a { color: #dcebf6; padding: 11px 14px; white-space: nowrap; font-weight: 500; font-size: 15px; border-bottom: 3px solid transparent; }
.nav a:hover, .nav a.active { color: #fff; border-bottom-color: var(--gold); }
.nav-toggle { display: none; margin-left: auto; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; flex-direction: column; justify-content: center; align-items: center; gap: 4px; }
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; }

/* ---------- главная ---------- */
.hero { background: radial-gradient(circle at 85% 20%, rgba(245, 184, 46, .25), transparent 40%), linear-gradient(135deg, var(--blue-dark), var(--blue) 55%, var(--sky)); color: #fff; padding: 56px 0 64px; margin-bottom: 36px; position: relative; overflow: hidden; }
.hero::after { /* шаңырақ на фоне */
    content: ""; position: absolute; right: -60px; top: -40px; width: 340px; height: 340px; opacity: .12;
    background: url("ornament.svg") center / contain no-repeat;
}
.hero-in { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.15; margin: 0 0 14px; max-width: 760px; letter-spacing: -.02em; }
.hero p { font-size: 18px; color: #d7e9f5; max-width: 680px; margin: 0 0 28px; }
.hero-search { display: flex; max-width: 600px; background: #fff; border-radius: 14px; padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); }
.hero-search input { flex: 1; min-width: 0; border: 0; outline: none; padding: 10px 14px; font-size: 17px; color: var(--ink); background: transparent; }
.hero-search button { border: 0; border-radius: 10px; background: var(--gold); color: #3a2a00; font-weight: 700; padding: 10px 24px; cursor: pointer; transition: filter .15s; }
.hero-search button:hover { filter: brightness(1.05); }
.hero-search-inline { box-shadow: none; border: 1px solid var(--line); margin-top: 16px; }
.hero-stat { margin-top: 22px; color: #d7e9f5; }
.hero-stat b { color: var(--gold); font-size: 20px; }

.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.cat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; border-top: 4px solid var(--blue); }
.cat:nth-child(3n+2) { border-top-color: var(--gold); }
.cat:nth-child(3n+3) { border-top-color: var(--sky); }
.cat-head { display: flex; gap: 14px; align-items: center; color: var(--ink); margin-bottom: 14px; }
.cat-head:hover b { color: var(--blue); }
.cat-head b { display: block; font-size: 19px; line-height: 1.25; }
.cat-head small { color: var(--muted); font-size: 13px; }
.cat-icon { flex-shrink: 0; width: 48px; height: 48px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 14px; padding: 5px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); transition: all .15s; }
.chip:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.chip-more { color: var(--blue); font-weight: 600; }

/* ---------- блоки и списки ---------- */
.block { margin-top: 40px; }
.block-title { font-size: 22px; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
.block-title::before { content: ""; width: 6px; height: 22px; border-radius: 3px; background: var(--gold); }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li { padding: 12px 18px; border-bottom: 1px solid var(--line); break-inside: avoid; }
.list li:last-child { border-bottom: 0; }
.list li a { font-weight: 500; }
.list li small { display: block; color: var(--muted); font-size: 13px; }
.list-cols { columns: 2; column-gap: 0; }
.list-cols li { border-right: 1px solid var(--line); }
.list-numbered { counter-reset: n calc(var(--start, 1) - 1); }
ol.list { list-style: decimal inside; }
ol.list li::marker { color: var(--muted); font-size: 14px; }
.more { display: inline-block; margin-top: 14px; font-weight: 600; }
.empty { color: var(--muted); padding: 24px 0; }

/* ---------- раздел ---------- */
.crumbs { font-size: 14px; color: var(--muted); padding: 18px 0 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--blue); }
.crumbs-sep { color: #b4beca; }
.page-head { margin: 8px 0 24px; }
.page-head h1 { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.2; margin: 0 0 10px; letter-spacing: -.015em; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 10px; max-width: 820px; }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 28px; }
.tile { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px; color: var(--ink); border-left: 4px solid var(--blue); transition: transform .15s, box-shadow .15s; }
.tile:hover { transform: translateY(-2px); color: var(--ink); box-shadow: 0 6px 22px rgba(16, 40, 64, .12); }
.tile b { display: block; font-size: 16px; line-height: 1.3; }
.tile small { color: var(--muted); }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 24px; }
.pager a, .pager span { min-width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; padding: 0 10px; }
.pager a { background: var(--card); box-shadow: var(--shadow); }
.pager .current { background: var(--blue); color: #fff; font-weight: 700; }
.pager .gap { color: var(--muted); }

/* ---------- материал ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.article { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 40px 36px; }
.article .page-head { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-top: 0; }
.tools { display: flex; gap: 8px; margin-left: auto; }
.tool { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 6px 12px; font-size: 14px; cursor: pointer; transition: all .15s; }
.tool:hover { border-color: var(--blue); color: var(--blue); }
.tool.done { border-color: #2e9d5b; color: #2e9d5b; }

.content { font-size: 17px; line-height: 1.75; overflow-wrap: break-word; }
.content > :first-child { margin-top: 0; }
.content p { margin: 0 0 1em; }
.content h2 { font-size: 23px; line-height: 1.3; margin: 1.8em 0 .7em; padding-left: 14px; border-left: 4px solid var(--gold); }
.content h3 { font-size: 19px; margin: 1.5em 0 .6em; color: var(--blue-dark); }
.content h4 { font-size: 17px; margin: 1.3em 0 .5em; }
.content ul, .content ol { padding-left: 1.4em; margin: 0 0 1em; }
.content li { margin: .3em 0; }
.content li::marker { color: var(--blue); }
.content blockquote { margin: 1.2em 0; padding: 14px 20px; background: var(--gold-soft); border-left: 4px solid var(--gold); border-radius: 0 10px 10px 0; font-style: italic; }
.content blockquote p:last-child { margin: 0; }
.content hr { border: 0; height: 1px; background: var(--line); margin: 2em 0; }
.content strong { color: #0f1b26; }
.table-wrap { overflow-x: auto; margin: 1.2em 0 1.6em; border: 1px solid var(--line); border-radius: 10px; -webkit-overflow-scrolling: touch; }
.content table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.55; min-width: 560px; }
.content th, .content td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
.content th:last-child, .content td:last-child { border-right: 0; }
.content tr:last-child td { border-bottom: 0; }
.content th { background: var(--blue-soft); color: var(--blue-dark); font-weight: 700; }
.content tbody tr:nth-child(even) td { background: #fafbfd; }
.related .list { box-shadow: none; border: 1px solid var(--line); }

.aside { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 20px; }
.aside-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.aside-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; font-weight: 700; }
.aside-link { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.aside-link:last-child { border-bottom: 0; }
.aside-link small { color: var(--muted); font-weight: 400; }

.ad { margin: 24px 0; text-align: center; overflow: hidden; }
.ad:empty { display: none; }
.ad-aside { margin: 0; }

.notfound { text-align: center; padding: 64px 0; max-width: 560px; margin: 0 auto; }
.notfound-code { font-size: 96px; font-weight: 800; line-height: 1; color: var(--gold); }
.notfound .hero-search { margin: 20px auto; }

/* ---------- подвал ---------- */
.footer { background: #0e2233; color: #a9bccd; font-size: 14px; }
.footer a { color: #d5e3ef; }
.footer a:hover { color: var(--gold); }
.footer-in { display: grid; grid-template-columns: 1fr 2fr; gap: 40px; padding-top: 36px; padding-bottom: 24px; }
.logo-footer { color: #fff; margin-bottom: 10px; }
.logo-footer b { font-size: 20px; color: #fff; }
.footer-about p { margin: 0; max-width: 360px; }
.footer-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 24px; align-content: start; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 16px; padding-bottom: 20px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; }
.footer-feedback { display: inline-flex; align-items: center; gap: 8px; font: inherit; color: #d5e3ef; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px; padding: 6px 14px; cursor: pointer; transition: all .15s; }
.footer-feedback:hover { color: var(--gold); border-color: var(--gold); }

/* ---------- кері байланыс ---------- */
.feedback { width: min(480px, calc(100% - 28px)); border: 0; border-radius: var(--radius); padding: 26px 24px 22px; box-shadow: 0 20px 60px rgba(8, 30, 50, .3); color: var(--ink); }
.feedback::backdrop { background: rgba(14, 34, 51, .55); }
.feedback h2 { margin: 0 0 6px; font-size: 22px; color: var(--blue); }
.feedback-hint { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.feedback-close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.feedback-close:hover { background: var(--bg); color: var(--ink); }
.feedback label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.feedback input, .feedback textarea { display: block; width: 100%; margin-top: 4px; font: 16px/1.4 var(--font); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--bg); resize: vertical; }
.feedback input:focus, .feedback textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(25, 167, 206, .15); background: #fff; }
.feedback .feedback-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.feedback-submit { border: 0; border-radius: 10px; background: var(--gold); color: #3a2a00; font: 700 16px var(--font); padding: 11px 26px; cursor: pointer; }
.feedback-submit:hover { filter: brightness(1.05); }
.feedback-submit:disabled { opacity: .6; cursor: default; }
.feedback-error { color: #b42318; font-size: 14px; margin: 10px 0 0; }
.feedback-done { margin: 8px 0 4px; font-size: 17px; color: var(--ink); }

/* ---------- адаптив ---------- */
@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .aside { position: static; }
    .article { padding: 24px 22px 28px; }
}
@media (max-width: 760px) {
    .wrap { padding: 0 14px; }
    .header-in { flex-wrap: wrap; gap: 10px 14px; min-height: 0; padding-top: 12px; padding-bottom: 12px; }
    .logo-text small { display: none; }
    .nav-toggle { display: flex; }
    .header-search { order: 3; flex-basis: 100%; max-width: none; }
    .nav { display: none; }
    .nav.open { display: block; }
    .nav-in { flex-direction: column; gap: 0; padding: 6px 14px; }
    .nav a { border-bottom: 1px solid rgba(255, 255, 255, .1); }
    .hero { padding: 36px 0 40px; margin-bottom: 24px; }
    .hero p { font-size: 16px; }
    .hero-search button { padding: 10px 16px; }
    .cats { grid-template-columns: 1fr; }
    .list-cols { columns: 1; }
    .list-cols li { border-right: 0; }
    .article { padding: 20px 16px 24px; margin: 0 -14px; border-radius: 0; }
    .content { font-size: 16px; }
    .tools { margin-left: 0; }
    .footer-in { grid-template-columns: 1fr; gap: 24px; }
}

/* ---------- печать: ҚМЖ и сочинения печатают ---------- */
@media print {
    .header, .nav, .footer, .feedback, .aside, .ad, .crumbs, .tools, .related, .pager { display: none !important; }
    body { background: #fff; font-size: 12pt; }
    .wrap { max-width: none; padding: 0; }
    .layout { display: block; }
    .article { box-shadow: none; padding: 0; }
    .page-head { border: 0 !important; }
    .page-meta a { color: #000; }
    .content { font-size: 12pt; line-height: 1.5; }
    .table-wrap { overflow: visible; border: 0; }
    .content table { min-width: 0; font-size: 10pt; }
    .content th, .content td { border: 1px solid #555 !important; }
    .content tr { break-inside: avoid; }
    a { color: #000; }
}

/* ---------- тест (ҚАЗТЕСТ; движок из quiz-fr) ---------- */
[hidden] { display: none !important; }
.badge { display: inline-block; background: var(--gold-soft); color: #7a5600; border-radius: 999px; padding: 2px 10px; font-weight: 600; font-size: 13px; }
.badge-soft { background: var(--blue-soft); color: var(--blue-dark); }
.passage { margin: 0 0 28px; padding: 22px 26px; border-radius: var(--radius); background: #fbfcfe; border: 1px solid var(--line); border-left: 4px solid var(--blue); }
.passage-title { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 12px; }
.quiz { margin-top: 8px; --ok: #1f9d63; --ok-soft: #e5f6ed; --bad: #d64545; --bad-soft: #fcebeb; }
.quiz-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px); padding: 12px 0 10px; margin-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.quiz-bar b { color: var(--ink); }
.quiz-progress { flex: 1 1 160px; height: 8px; border-radius: 999px; background: var(--blue-soft); overflow: hidden; }
.quiz-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--sky)); border-radius: 999px; transition: width .3s; }
.questions { list-style: none; margin: 0; padding: 0; }
.question { padding: 22px 0 20px; border-bottom: 1px solid var(--line); scroll-margin-top: 70px; }
.question:last-child { border-bottom: 0; }
.q-text { display: flex; gap: 12px; font-size: 18px; font-weight: 650; line-height: 1.45; margin: 0 0 14px; }
.q-num { flex-shrink: 0; width: 32px; height: 32px; border-radius: 10px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700; margin-top: -2px; }
.choices { list-style: none; margin: 0 0 0 44px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { width: 100%; height: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; line-height: 1.35; transition: border-color .12s, background .12s, transform .12s; }
.choice:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-soft); }
.choice:active:not(:disabled) { transform: scale(.98); }
.choice:disabled { cursor: default; }
.choice-letter { flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--muted); }
.choice.is-right { border-color: var(--ok); background: var(--ok-soft); }
.choice.is-right .choice-letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.is-wrong .choice-letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.question.answered .choice:not(.is-right):not(.is-wrong) { opacity: .55; }
.q-answer { margin: 14px 0 0 44px; }
.q-answer summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: 14px; }
.q-expl { margin: 10px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--gold-soft); border-left: 4px solid var(--gold); font-size: 16px; line-height: 1.6; }
.q-expl p { margin: 0; }
.q-expl .q-ru { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(0, 0, 0, .12); color: var(--muted); font-size: 15px; }
.js .q-answer:not([open]) { display: none; }
.js .q-answer summary { display: none; }
.question.got-it .q-expl { background: var(--ok-soft); border-left-color: var(--ok); }
.question.missed .q-expl { background: var(--bad-soft); border-left-color: var(--bad); }
.questions .ad-middle { padding: 20px 0; border-bottom: 1px solid var(--line); list-style: none; }
.quiz-result { margin-top: 24px; padding: 28px; border-radius: var(--radius); text-align: center; background: linear-gradient(135deg, var(--blue-dark), var(--blue) 60%, var(--sky)); color: #fff; }
.result-score { font-size: 22px; color: #d7e9f5; }
.result-score b { font-size: 64px; line-height: 1; color: var(--gold); }
.result-verdict { font-size: 19px; margin: 10px 0 8px; }
.result-pass { display: inline-block; margin: 0 0 20px; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .14); font-weight: 600; }
.result-pass.is-pass { background: rgba(31, 157, 99, .9); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
.btn { display: inline-flex; align-items: center; border: 0; border-radius: 12px; padding: 12px 22px; background: var(--gold); color: #3a2a00; font-weight: 700; cursor: pointer; transition: filter .15s; }
.btn:hover { filter: brightness(1.05); color: #3a2a00; }
.btn-ghost { background: rgba(255, 255, 255, .16); color: #fff; }
.btn-ghost:hover { color: #fff; }

@media (max-width: 760px) {
    .passage { padding: 16px; }
    .q-text { font-size: 17px; }
    .choices { grid-template-columns: 1fr; margin-left: 0; }
    .q-answer { margin-left: 0; }
}

@media print {
    .quiz-bar, .quiz-result { display: none !important; }
    .passage { border: 0; padding: 0; background: none; }
    .question { break-inside: avoid; padding: 10px 0; }
    .choice { border: 1px solid #999; padding: 4px 8px; }
    .js .q-answer, .q-answer { display: none !important; }
}
