/* ===== Mavzular: sarg'ish (standart), yorug', tungi ===== */
:root, [data-theme="sepia"] {
  --bg: #f8f8f6; --surface: #ffffff; --fg: #1b1d21; --muted: #5a606a; --line: #e2e3df;
  --accent: #0b57a4; --on-accent: #ffffff; --accent-soft: #e7eff9; --code-bg: #f2f3f0;
  --kw: #7a2fc9; --type: #08686a; --str: #9a4300; --com: #5c6370; --num: #b02a62;
  --badge-bg: #e5f3ea; --badge-fg: #1c6b3a; --chip: #f2f3f0; --chip-fg: #3d424a;
  --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  --st-ok: #dafbe1; --st-ok-b: #4ac26b; --st-warn: #fff8c5; --st-warn-b: #d4a72c;
  --st-bad: #ffebe9; --st-bad-b: #ff8182; --st-info: #ddf4ff; --st-info-b: #54aeff;
  color-scheme: light;
}
[data-theme="light"] {
  --bg: #ffffff; --surface: #f6f7f9; --fg: #15171c; --muted: #535a66; --line: #e3e6eb;
  --accent: #1257c2; --on-accent: #ffffff; --accent-soft: #eaf1fd; --code-bg: #f4f6f9;
  --kw: #7a2fc9; --type: #07676a; --str: #9a4300; --com: #596170; --num: #b02a62;
  --badge-bg: #e3f4e9; --badge-fg: #1a6837; --chip: #eef0f3; --chip-fg: #363b44;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #111317; --surface: #181b20; --fg: #e7e8eb; --muted: #9ca3ae; --line: #2b3038;
  --accent: #7ab8ff; --on-accent: #0b1626; --accent-soft: #1a2838; --code-bg: #0c0e11;
  --kw: #c6a4ff; --type: #62d3c4; --str: #f1b57c; --com: #8d95a2; --num: #ff92c2;
  --badge-bg: #183324; --badge-fg: #8fdcaa; --chip: #22262d; --chip-fg: #c3c8d0;
  --ok: #3fb950; --warn: #d29922; --bad: #f85149;
  --st-ok: #12301c; --st-ok-b: #2ea043; --st-warn: #2e2410; --st-warn-b: #9e6a03;
  --st-bad: #3a1416; --st-bad-b: #da3633; --st-info: #0f2639; --st-info-b: #1f6feb;
  color-scheme: dark;
}
/* Tanlov bo'lmasa, tizim sozlamasi tungi bo'lsa — tungi mavzu */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #111317; --surface: #181b20; --fg: #e7e8eb; --muted: #9ca3ae; --line: #2b3038;
    --accent: #7ab8ff; --on-accent: #0b1626; --accent-soft: #1a2838; --code-bg: #0c0e11;
    --kw: #c6a4ff; --type: #62d3c4; --str: #f1b57c; --com: #8d95a2; --num: #ff92c2;
    --badge-bg: #183324; --badge-fg: #8fdcaa; --chip: #22262d; --chip-fg: #c3c8d0;
    --ok: #3fb950; --warn: #d29922; --bad: #f85149;
    --st-ok: #12301c; --st-ok-b: #2ea043; --st-warn: #2e2410; --st-warn-b: #9e6a03;
    --st-bad: #3a1416; --st-bad-b: #da3633; --st-info: #0f2639; --st-info-b: #1f6feb;
    color-scheme: dark;
  }
}
:root {
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

/* ===== Asos ===== */
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; font: 15px/1.6 var(--sans); color: var(--fg); background: var(--bg); }
body > .page { flex: 1 0 auto; width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, tt, pre, kbd { font-family: var(--mono); font-size: 13.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); font-size: 13px; }
.nowrap { white-space: nowrap; }
.wrap { max-width: 1360px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.page { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.eyebrow a { color: inherit; }
.flash { padding: 8px 12px; background: var(--st-info); border: 1px solid var(--st-info-b); border-radius: 8px; margin: 8px 0 16px; }

/* ===== Header ===== */
header.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font: 500 14px var(--mono); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; }
.brand-text small { font-size: 12px; color: var(--muted); }
.mainnav { display: flex; flex-wrap: wrap; gap: 4px; }
.mainnav a { padding: 8px 12px; border-radius: 6px; color: var(--muted); }
.mainnav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.top-tools { flex: 1 1 300px; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 12px; }
.search { flex: 0 1 300px; }
.search input, .hero-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit;
}
.search input { height: 40px; padding: 0 12px; font-size: 14px; }
.search input:focus, .hero-search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.theme-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.theme-switch button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 999px; border: 1px solid var(--line); }
.dot-light { background: #ffffff; } .dot-sepia { background: #f3ecd9; } .dot-dark { background: #111317; }

/* ===== Footer ===== */
footer.bottom { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; }
.bottom-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 20px; padding-bottom: 20px; }

/* ===== Bosh sahifa ===== */
.hero { padding: 40px 0 32px; }
.hero h1 { margin: 0; max-width: 760px; font-size: 44px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }
.hero p { margin: 16px 0 28px; max-width: 640px; font-size: 18px; color: var(--muted); }
.hero-search { max-width: 640px; }
.hero-search input { height: 56px; padding: 0 18px; border-radius: 12px; font-size: 16px; background: var(--surface); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 40px; }
.card { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 { margin: 0; font-size: 17px; font-weight: 600; }
.card h3 a { color: var(--fg); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; font: 13px var(--mono); background: var(--accent-soft); color: var(--accent); }
.chip.untr, .chip.more { background: var(--chip); color: var(--chip-fg); }
.linklist { list-style: none; margin: 0 0 24px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.linklist li + li { border-top: 1px solid var(--line); }
.linklist a { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 14px 20px; color: var(--fg); }
.linklist a:hover { background: var(--accent-soft); text-decoration: none; }
.ll-title { font-weight: 600; }
.linklist code { color: var(--muted); font-size: 13px; }

/* ===== Maqola sahifasi: menyu | matn | mundarija ===== */
.doc { display: grid; grid-template-columns: 220px minmax(0, 1fr) 200px; grid-template-areas: "side main toc"; gap: 40px; align-items: start; }
.doc.no-toc { grid-template-columns: 220px minmax(0, 1fr); grid-template-areas: "side main"; }
.side { grid-area: side; font-size: 14px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.side ul { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side li a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--fg); }
.side li a:hover { background: var(--accent-soft); text-decoration: none; }
.side li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-note { margin: 0; padding: 12px; border: 1px dashed var(--line); border-radius: 8px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.article { grid-area: main; min-width: 0; max-width: 860px; }
.toc-side { grid-area: toc; font-size: 13px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.toc-side ul { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.toc-side a { color: var(--muted); }
.toc-side a:hover { color: var(--accent); }
.toc-side .lv4 { padding-left: 12px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs [aria-current] { color: var(--fg); }
.title-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 12px 0 20px; }
.page-title { margin: 0; font: 500 34px/1.2 var(--mono); letter-spacing: -.02em; overflow-wrap: anywhere; }
.lang-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.lang-switch a { padding: 6px 12px; border-radius: 6px; color: var(--muted); }
.lang-switch a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.source-note { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .doc, .doc.no-toc { grid-template-columns: 200px minmax(0, 1fr); grid-template-areas: "side toc" "side main"; gap: 24px 32px; }
  .toc-side { position: static; max-height: none; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
}
@media (max-width: 760px) {
  .doc, .doc.no-toc { grid-template-columns: minmax(0, 1fr); grid-template-areas: "toc" "main" "side"; }
  .side { position: static; max-height: none; }
  .content table { display: block; overflow-x: auto; }
  .top-tools { justify-content: flex-start; }
  .search { flex: 1 1 100%; }
  .hero h1 { font-size: 32px; }
  .page-title { font-size: 26px; }
}

/* ===== cppreference kontenti ===== */
.content { font-size: 16px; line-height: 1.7; overflow-wrap: break-word; }
.content h2, .content h3, .content h4 { margin: 36px 0 12px; line-height: 1.3; letter-spacing: -.01em; scroll-margin-top: 16px; }
.content h2 { font-size: 24px; }
.content h3 { font-size: 21px; }
.content h4 { font-size: 17px; }
.content p { margin: 0 0 14px; }
.content table { border-collapse: collapse; margin: 12px 0; max-width: 100%; }
.content td, .content th { padding: 6px 10px; vertical-align: top; }
.content table.wikitable { display: block; overflow-x: auto; }
.content code, .content tt { font-size: .875em; padding: 1px 5px; border-radius: 4px; background: var(--code-bg); }
.content pre code, .content td code, .content .t-dcl code, .content .t-sdsc code { padding: 0; background: none; }
.content pre, .content .mw-geshi pre, .content div.mw-highlight pre {
  margin: 12px 0; padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.65;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px;
}
.content #toc { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 16px; font-size: 14px; }
.content #toc h2 { margin: 4px 0; font-size: 15px; }
.content #toc ul { list-style: none; padding-left: 12px; margin: 4px 0; }
.content .tocnumber { color: var(--muted); margin-right: 4px; }

/* E'lonlar, a'zolar, parametrlar jadvallari */
.content .t-dcl-begin, .content .t-dsc-begin, .content .t-par-begin, .content .t-sdsc-begin, .content .t-rev-begin {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.content .t-dcl-begin { background: var(--code-bg); }
.content .t-dcl-begin td, .content .t-dsc-begin td, .content .t-par-begin td, .content .t-rev-begin td { border-bottom: 1px solid var(--line); }
.content .t-dsc-header td, .content .t-dcl-header td { color: var(--muted); font-size: 13px; }
.content .t-dsc-member-div div { display: inline-block; }
.content .t-dsc > td:first-child, .content .t-par > td:first-child { font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.content .t-dsc > td:first-child a, .content .t-dsc > td:first-child code { color: var(--accent); }
.content .t-par > td:first-child { color: var(--type); }
.content .t-lines > span { display: block; }
.content .t-spar { font-style: italic; color: var(--type); font-family: var(--mono); font-size: .92em; }
.content .t-li1, .content .t-li2, .content .t-li3 { margin: 6px 0; }
.content .t-li2 { margin-left: 1.5em; } .content .t-li3 { margin-left: 3em; }
.content .t-li { font-weight: 600; margin-right: 4px; }
.content .t-sdsc-sep, .content .t-dcl-sep { padding: 2px; border: 0 !important; }
.content .t-dcl td:last-child, .content .t-dcl-rev-num td:last-child { color: var(--muted); font-size: 12px; white-space: nowrap; }
.content .t-mark { font-size: 12px; color: var(--muted); white-space: nowrap; }
.content .t-mark-rev {
  display: inline-block; padding: 0 8px; border-radius: 999px; font: 600 12px/1.7 var(--sans);
  background: var(--badge-bg); color: var(--badge-fg); white-space: nowrap;
}
.content [class*="t-until-"], .content [class*="t-deprecated-"] { background: var(--st-warn); color: var(--fg); }
.content .t-example-live-link, .content .coliru-btn { display: none; }
/* cppreference'dagi qattiq kodlangan fon/chegara ranglari mavzuga moslanadi */
.content [style*="background"]:not([style*="transparent"]) { background: var(--surface) !important; color: inherit !important; }
.content [style*="silver"] { border-color: var(--line) !important; }
.content .wikitable { border: 1px solid var(--line); }
.content .wikitable th, .content .wikitable td { border: 1px solid var(--line); }
.content .wikitable th { background: var(--surface); }
.content .table-yes { background: var(--st-ok) !important; }
.content .table-no { background: var(--st-bad) !important; }
.content .table-maybe { background: var(--st-warn) !important; }
.content .table-na { background: var(--chip) !important; color: var(--muted) !important; }
.content .ambox { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.content .references { font-size: 14px; color: var(--muted); }
.content .mainpagediv { margin-bottom: 8px; }

/* Tarjima qilinmagan sahifaga havola */
.content a.untr::after {
  content: "EN"; margin-left: 3px; padding: 0 3px; border-radius: 3px; vertical-align: 1px;
  font: 600 9px/1.4 var(--sans); color: var(--muted); border: 1px solid var(--line);
}
.content .t-dsc > td:first-child a.untr::after { content: none; }

/* Kodni ranglash: Pygments (mw-highlight) va GeSHi (mw-geshi) */
.content .k, .content .kd, .content .kr, .content .kn, .content .kp, .content .kc, .content .cp,
.content .kw1, .content .kw2, .content .kw3, .content .kw4 { color: var(--kw); }
.content .kt, .content .nc, .content .nb, .content .nn { color: var(--type); }
.content .s, .content .s1, .content .s2, .content .sc, .content .sa, .content .cpf,
.content .st0, .content .st_h { color: var(--str); }
.content .se, .content .es0 { color: var(--str); font-weight: 600; }
.content .c, .content .c1, .content .cm, .content .cs, .content .co1, .content .co2, .content .coMULTI { color: var(--com); font-style: italic; }
.content .mi, .content .mf, .content .mh, .content .mo, .content .il,
.content [class^="nu"], .content [class*=" nu"] { color: var(--num); }

/* ===== Admin ===== */
body.admin .wrap.page { max-width: 1500px; }
form.add textarea, form.edit textarea, form.edit input {
  width: 100%; font-family: var(--mono); font-size: 13px; padding: 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg);
}
form.add label, form.edit label { display: block; margin-bottom: 8px; }
button { padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); cursor: pointer; font: inherit; }
button:hover { background: var(--accent-soft); }
.btn-approve { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-approve:hover { background: #116329; }
.btn-retranslate { color: var(--bad); }
form.inline { display: inline; margin-right: 8px; }
.actions { margin: 12px 0 20px; }
.tabs { margin: 20px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tabs a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; }
.tabs a.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.st { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; background: var(--surface); border: 1px solid var(--line); }
.st-published { background: var(--st-ok); border-color: var(--st-ok-b); }
.st-draft { background: var(--st-warn); border-color: var(--st-warn-b); }
.st-failed { background: var(--st-bad); border-color: var(--st-bad-b); }
.st-translating, .st-queued { background: var(--st-info); border-color: var(--st-info-b); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.compare section { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; max-height: 80vh; overflow: auto; background: var(--bg); }
.compare h2 { position: sticky; top: 0; z-index: 1; background: var(--surface); margin: 0 -14px; padding: 8px 14px; font-size: 14px; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .compare { grid-template-columns: 1fr; } }
