/*
 * B1 Cittadinanza — стили «Quaderno d'esame». Без фреймворков и веб-шрифтов.
 * Нарочно не похож на bilim.click и toutquiz.click: бумажный фон, serif-заголовки,
 * шапка в одну строку с двойной линией, оглавления вместо карточек, рамки без теней, углы 4px.
 * Цвета: зелёные «чернила» — основной, терракота — действие, охра — пометки;
 * зелёный и красный «ok/bad» — только для верного и неверного ответа.
 */
:root {
    --paper: #faf7f0;
    --sheet: #fffdf8;
    --ink: #1f2a24;
    --muted: #6b6a5e;
    --green: #1f5c46;
    --green-soft: #e6efe9;
    --terra: #c4502e;
    --terra-dark: #a03d20;
    --ochre: #d9a441;
    --ochre-soft: #fbf1db;
    --rule: #ddd5c3;
    --margin: #e8a596;
    --line-blue: #e4e9ef;
    --ok: #2e7d4f;
    --ok-soft: #e3f1e7;
    --bad: #b8372b;
    --bad-soft: #f8e4e1;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --r: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.65 var(--sans); display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--green); text-decoration-color: rgba(31, 92, 70, .35); text-underline-offset: 3px; }
a:hover { color: var(--terra); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -.005em; }
button, select, input, textarea { font: inherit; }
[hidden] { display: none !important; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.main { flex: 1; padding-bottom: 32px; }
.empty { color: var(--muted); font-style: italic; }
.more { display: inline-block; margin-top: 10px; font-size: 14px; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: var(--r); border: 1px solid var(--terra); background: var(--terra); color: #fff; text-decoration: none; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--terra-dark); border-color: var(--terra-dark); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--paper); }
.icon-btn { width: 38px; height: 38px; flex-shrink: 0; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sheet); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--green); color: var(--green); }

/* ---------- шапка: одна строка + двойная линия ---------- */
.header { position: relative; z-index: 10; }
.header-in { display: flex; align-items: center; gap: 28px; min-height: 68px; }
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.brand:hover { color: var(--ink); }
.brand b { font: 600 25px/1 var(--serif); }
.brand b i { font-style: normal; color: var(--terra); }
.brand small { font: italic 14px var(--serif); color: var(--muted); }
.menu { display: flex; gap: 22px; margin-left: auto; }
.menu a { color: var(--ink); text-decoration: none; font-size: 15px; padding: 4px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.menu a:hover, .menu a.on { color: var(--green); border-bottom-color: var(--terra); }
.burger { display: none; }
.rule2 { border-top: 3px double var(--ink); opacity: .85; }
.search-bar { display: flex; gap: 8px; padding-bottom: 14px; }
.search-bar input, .search-inline input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--ink); border-radius: var(--r); background: var(--sheet); outline: none; }
.search-bar input:focus, .search-inline input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search-inline { display: flex; gap: 8px; max-width: 560px; margin-top: 14px; }

/* ---------- общие заголовки, оглавления ---------- */
.kicker { font: 600 12px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--terra); margin: 0 0 10px; }
.kicker a { color: inherit; text-decoration: none; }
.lead { font-size: 18px; color: #3c463f; max-width: 38em; margin: 0 0 20px; }
.crumbs { font-size: 14px; color: var(--muted); padding: 18px 0 0; }
.crumbs a { color: var(--muted); }
.crumbs-sep { margin: 0 6px; }
.test-head { padding: 14px 0 22px; border-bottom: 1px solid var(--rule); margin-bottom: 28px; }
.test-head h1 { font-size: 36px; margin: 0 0 12px; }
.test-head .lead { margin-bottom: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 12px; }
.chips span { padding: 2px 10px; border: 1px solid var(--rule); border-radius: 2px; background: var(--sheet); }
.chips .exam { border-color: var(--terra); color: var(--terra); }

.section-title { display: flex; align-items: baseline; gap: 14px; margin: 44px 0 14px; }
.section-title h2 { font-size: 28px; margin: 0; }
.section-title h2 a { color: var(--ink); text-decoration: none; }
.section-title h2 a:hover { color: var(--green); }
.section-title span { color: var(--muted); font-size: 15px; }
.section-title::after { content: ""; flex: 1; border-bottom: 1px solid var(--rule); transform: translateY(-6px); }

.toc { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.toc a::before { content: counter(toc, decimal-leading-zero); font: italic 15px var(--serif); color: var(--terra); min-width: 24px; }
.toc a .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc a .dots { flex: 1; border-bottom: 1px dotted #b9b19d; transform: translateY(-4px); min-width: 20px; }
.toc a .m { color: var(--muted); font-size: 13px; white-space: nowrap; }
.toc a:hover .t { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.toc-sections { margin-bottom: 28px; }
.toc-sections a .t { font: 600 18px var(--serif); }
.toc-small a { padding: 7px 0; font-size: 14px; }
.toc-small a .t { white-space: normal; }

/* ---------- главная ---------- */
.intro { display: grid; grid-template-columns: 1.5fr 1fr; gap: 40px; padding: 44px 0 20px; align-items: start; }
.intro h1 { font-size: 46px; margin: 0 0 16px; }
.intro h1 em { font-style: italic; color: var(--green); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

.session { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 22px 24px; position: relative; }
.session::before { content: ""; position: absolute; inset: 6px; border: 1px dashed var(--rule); border-radius: 2px; pointer-events: none; }
.session h2 { font: 600 13px/1.3 var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 0 0 12px; }
.session .date { font: 600 30px/1.1 var(--serif); margin: 0; }
.session .left { display: inline-block; margin: 10px 0 14px; padding: 3px 10px; background: var(--ochre-soft); border: 1px solid var(--ochre); border-radius: 2px; font-weight: 600; font-size: 14px; }
.session dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.session dt { color: var(--muted); }
.session dd { margin: 0; }

.scheda { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--ink); border-radius: var(--r); background: var(--sheet); }
.part { padding: 20px 20px 18px; border-right: 1px solid var(--rule); text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 6px; }
.part:last-child { border-right: 0; }
a.part:hover { background: var(--green-soft); color: var(--ink); }
.part .n { font: italic 600 40px/1 var(--serif); color: var(--terra); }
.part h3 { font-size: 21px; margin: 4px 0 0; }
.part p { margin: 0; color: #4a524c; font-size: 14px; }
.part .meta { margin-top: auto; padding-top: 10px; border-top: 1px dotted var(--rule); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.part.soon { opacity: .6; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 1px 6px; border: 1px solid currentColor; border-radius: 2px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.cols > section { min-width: 0; }

.ticket { margin-top: 44px; display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 26px 30px; background: var(--green); color: #eaf2ec; border-radius: var(--r); position: relative; overflow: hidden; }
.ticket::after { content: "40:00"; position: absolute; right: 26%; top: -18px; font: italic 600 120px/1 var(--serif); color: rgba(255, 255, 255, .06); pointer-events: none; }
.ticket h2 { color: #fff; font-size: 26px; margin: 0 0 6px; }
.ticket p { margin: 0; max-width: 40em; }
.ticket .btn { background: var(--ochre); border-color: var(--ochre); color: var(--ink); position: relative; z-index: 1; }
.ticket .btn:hover { background: #fff; border-color: #fff; }

/* ---------- статья ---------- */
.article-layout { display: grid; grid-template-columns: 1fr 280px; gap: 40px; align-items: start; }
.article { min-width: 0; }
.content { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 28px 36px; font: 18px/1.7 var(--serif); }
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content h2 { font-size: 26px; margin: 1.6em 0 .5em; }
.content h3 { font-size: 21px; margin: 1.4em 0 .4em; }
.content blockquote { margin: 1em 0; padding: 4px 18px; border-left: 3px solid var(--ochre); background: var(--ochre-soft); }
.content code { font-size: .9em; background: var(--green-soft); padding: 1px 4px; border-radius: 2px; }
.content hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
.content table { border-collapse: collapse; width: 100%; font: 15px/1.5 var(--sans); }
.content th, .content td { border: 1px solid var(--rule); padding: 7px 10px; text-align: left; vertical-align: top; }
.content th { background: var(--green-soft); }
.aside-title { font-size: 18px; margin: 0 0 6px; }
.intro-text { margin-bottom: 28px; }

/* ---------- тест ---------- */
.test { display: grid; grid-template-columns: 1fr 280px; gap: 32px; align-items: start; }
.test-main { min-width: 0; }
.prova { margin-bottom: 40px; }
.prova-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.prova-head h2 { margin: 0; font-size: 24px; }
.prova-head .pts { margin-left: auto; font-size: 14px; color: var(--muted); white-space: nowrap; }
.consegna { font: italic 17px var(--serif); color: #3c463f; margin: 0 0 16px; }

/* лист в линейку с красным полем */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 26px 30px 26px 64px; position: relative; font: 17px/30px var(--serif);
    background-image: linear-gradient(var(--line-blue) 1px, transparent 1px); background-size: 100% 30px; background-position: 0 25px; }
.sheet::before { content: ""; position: absolute; top: 0; bottom: 0; left: 44px; border-left: 2px solid var(--margin); opacity: .7; }
.sheet h2, .sheet h3 { font-size: 21px; margin: 0; line-height: 30px; }
.sheet p { margin: 0; text-indent: 1.4em; }
.sheet ul, .sheet ol { margin: 0; padding-left: 1.4em; }

.items { list-style: none; margin: 18px 0 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sheet); }
.item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--rule); scroll-margin-top: 16px; }
.item:last-child { border-bottom: 0; }
.item .no { font: italic 600 18px var(--serif); color: var(--terra); }
.vf { display: flex; gap: 6px; }
.vf button { width: 44px; height: 38px; border: 1px solid var(--ink); background: transparent; border-radius: var(--r); font-weight: 700; cursor: pointer; color: var(--ink); }
.vf button:hover { background: var(--green-soft); }
.item-mc { grid-template-columns: 34px 1fr; }
.choices { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; }
.choices button { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--ink); background: transparent; border-radius: var(--r); cursor: pointer; text-align: left; color: var(--ink); }
.choices button b { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--rule); border-radius: 2px; font-size: 12px; }
.choices button:hover { background: var(--green-soft); }
.item button.sel { background: var(--ink); color: var(--paper); }
.item button.sel b { border-color: var(--paper); }
.why { grid-column: 2 / -1; font-size: 14px; color: #3c463f; }
.why summary { cursor: pointer; color: var(--green); }
.why p { margin: 4px 0 0; }
.js .why { display: none; }
.js .checked .why { display: block; }
.item.ok { background: var(--ok-soft); }
.item.ko { background: var(--bad-soft); }
.item button.right { outline: 2px solid var(--ok); outline-offset: 1px; }
.item.ko button.sel { background: var(--bad); border-color: var(--bad); color: #fff; }

.gap { display: inline-flex; align-items: center; gap: 4px; text-indent: 0; scroll-margin-top: 16px; }
.gap b { font: italic 13px var(--sans); color: var(--terra); }
.gap select { border: 0; border-bottom: 2px solid var(--green); background: var(--green-soft); padding: 0 4px; height: 26px; font: 16px var(--serif); color: var(--ink); cursor: pointer; border-radius: 2px 2px 0 0; }
.gap.ok select { border-color: var(--ok); background: var(--ok-soft); }
.gap.ko select { border-color: var(--bad); background: var(--bad-soft); }
.gap .fix { font: 600 13px var(--sans); color: var(--ok); display: none; }
.gap.ko .fix { display: inline; }
.solutions { margin-top: 14px; font-size: 14px; }
.solutions summary { cursor: pointer; color: var(--green); }
.solutions ol { margin: 8px 0 0; padding-left: 1.4em; }
.solutions li { margin-bottom: 4px; }
.js .solutions { display: none; }
.js .checked .solutions { display: block; }

/* бланк ответов справа */
.foglio { position: sticky; top: 16px; background: var(--sheet); border: 1px solid var(--ink); border-radius: var(--r); padding: 18px; }
.foglio h2 { font-size: 18px; margin: 0 0 2px; }
.foglio .sub { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.timer { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px dashed var(--rule); border-radius: var(--r); margin-bottom: 10px; }
.timer b { font: 600 26px/1 var(--serif); font-variant-numeric: tabular-nums; }
.timer button { border: 0; background: none; color: var(--green); cursor: pointer; font-size: 13px; text-decoration: underline; }
.timer.off b { color: var(--muted); }
.grid-label { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 10px 0 6px; }
.cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.cells a { aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 2px; font-size: 13px; color: var(--muted); text-decoration: none; background: #fff; }
.cells a.done { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cells a.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.cells a.ko { background: var(--bad); border-color: var(--bad); color: #fff; }
.foglio .btn { width: 100%; margin-top: 16px; }
.score { margin-top: 16px; padding-top: 14px; border-top: 3px double var(--ink); }
.score table { width: 100%; border-collapse: collapse; font-size: 14px; }
.score td { padding: 4px 0; border-bottom: 1px dotted var(--rule); }
.score td:last-child { text-align: right; font-weight: 700; }
.score .tot td { border: 0; font: 600 20px var(--serif); padding-top: 8px; }
.score p { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.foglio, .mbar { display: none; }
.js .foglio { display: block; }
.next { display: flex; justify-content: space-between; gap: 16px; padding-top: 20px; border-top: 1px solid var(--rule); }
.related .section-title { margin-top: 36px; }

/* ---------- раздел, поиск, 404 ---------- */
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin: 24px 0; }
.pager a, .pager span { min-width: 38px; height: 38px; display: grid; place-items: center; padding: 0 8px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sheet); text-decoration: none; }
.pager .current { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pager .ellipsis { border: 0; background: none; }
.notfound { text-align: center; padding: 48px 0; }
.notfound .search-inline { margin: 20px auto; }
.notfound-code { font: italic 600 96px/1 var(--serif); color: var(--terra); }
.ad { margin: 24px 0; text-align: center; }

/* ---------- подвал и обратная связь ---------- */
.footer { margin-top: 48px; border-top: 3px double var(--ink); padding: 28px 0 36px; font-size: 14px; color: var(--muted); }
.footer-in { display: flex; gap: 20px 32px; flex-wrap: wrap; align-items: center; }
.footer .brand b { font-size: 20px; }
.footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer nav a { color: var(--muted); }
.footer .write { margin-left: auto; padding: 8px 16px; }
.footer p { flex-basis: 100%; margin: 0; }

.feedback { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--ink); border-radius: var(--r); padding: 26px; background: var(--sheet); color: var(--ink); }
.feedback::backdrop { background: rgba(31, 42, 36, .45); }
.feedback h2 { margin: 0 0 6px; font-size: 24px; }
.feedback-hint { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.feedback label { display: block; font-size: 14px; margin-bottom: 12px; }
.feedback input, .feedback textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 12px; border: 1px solid var(--rule); border-radius: var(--r); background: #fff; }
.feedback input:focus, .feedback textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.feedback-trap { position: absolute; left: -9999px; }
.feedback-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.feedback-error { color: var(--bad); font-size: 14px; }
.feedback-done { font: 18px var(--serif); }

/* ---------- телефон ---------- */
@media (max-width: 900px) {
    .header-in { gap: 10px; }
    .brand small { display: none; }
    .menu { display: none; position: absolute; left: 0; right: 0; top: 68px; z-index: 20; flex-direction: column; gap: 0; background: var(--paper); border-bottom: 3px double var(--ink); padding: 4px 20px 12px; }
    .menu.open { display: flex; }
    .menu a { padding: 10px 0; border-bottom: 1px solid var(--rule); }
    .menu + .icon-btn { margin-left: auto; }
    .burger { display: grid; }
    .intro { grid-template-columns: 1fr; padding-top: 28px; gap: 24px; }
    .intro h1 { font-size: 34px; }
    .scheda { grid-template-columns: 1fr 1fr; }
    .part:nth-child(2) { border-right: 0; }
    .part:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
    .cols { grid-template-columns: 1fr; }
    .ticket { grid-template-columns: 1fr; }
    .article-layout, .test { grid-template-columns: 1fr; }
    .foglio { position: static; }
    .content { padding: 20px 18px; font-size: 17px; }
    .sheet { padding: 20px 16px 20px 40px; }
    .sheet::before { left: 26px; }
    .test-head h1 { font-size: 28px; }
    .js .mbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--ink); color: var(--paper); padding: 10px 16px; gap: 12px; align-items: center; font-size: 14px; }
    .mbar b { font: 600 18px var(--serif); font-variant-numeric: tabular-nums; }
    .mbar .bar { flex: 1; height: 6px; background: rgba(255, 255, 255, .2); border-radius: 3px; overflow: hidden; }
    .mbar .bar i { display: block; height: 100%; width: 0; background: var(--ochre); }
    .mbar .btn { padding: 6px 12px; }
    .js .quiz-page { padding-bottom: 56px; }
}
@media (max-width: 520px) {
    .scheda { grid-template-columns: 1fr; }
    .part { border-right: 0; border-bottom: 1px solid var(--rule); }
    .part:last-child { border-bottom: 0; }
    .item { grid-template-columns: 26px 1fr; }
    .vf { grid-column: 2; }
    .footer .write { margin-left: 0; }
}
@media print {
    .header, .footer, .foglio, .mbar, .ad { display: none !important; }
    .test, .article-layout { display: block; }
}
