:root {
  --bg: #0f1720;
  --bg-2: #16212d;
  --panel: rgba(20, 30, 41, 0.94);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8eef4;
  --muted: #9fb0c0;
  --accent: #f2b544;
  --accent-ink: #1b1406;
  --ok: #4cc38a;
  --bad: #ef6461;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 35%, #1d2b3a 0%, var(--bg) 70%);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  /* Model aylantirilganda yoki tez bosilganda sahifadagi yozuvlar belgilanib (koʻk) qolmasin */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* Taʼrif va nomlarni nusxalash mumkin boʻlsin */
.sheet h2, .sheet p, input, textarea { -webkit-user-select: text; user-select: text; }

button {
  font: inherit;
  color: inherit;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}
button:hover { border-color: rgba(255, 255, 255, 0.3); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 40px;
}
a.btn:hover { border-color: rgba(255, 255, 255, 0.3); }
button.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
a { color: var(--accent); }

/* Yuqori panel */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(var(--bg) 40%, transparent);
}
.brand { font-size: 17px; margin: 0 auto 0 0; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; }
.brand span { color: var(--accent); font-weight: 500; font-size: 0.8em; margin-left: 2px; }
.mode { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.mode button { border: 0; background: transparent; min-height: 34px; padding: 6px 12px; color: var(--muted); }
.mode button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.offline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#credits h2 + p { margin-top: 0; }
.icon-btn { width: 40px; padding: 0; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Sahna */
#stage { position: fixed; inset: 0; }
#view { width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.hint {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%);
  margin: 0; padding: 6px 12px; max-width: calc(100% - 32px);
  font-size: 13px; color: var(--muted); text-align: center;
  background: rgba(15, 23, 32, 0.7); border-radius: 999px;
  transition: opacity 0.6s;
}
.boot { position: absolute; inset: 45% 16px auto; text-align: center; color: var(--muted); z-index: 2; }
.boot .err { display: none; color: var(--text); line-height: 1.6; }
.boot .err button { display: block; margin: 12px auto 0; }
.boot.failed .ok { display: none; }
.boot.failed .err { display: block; }
.hint.gone { opacity: 0; pointer-events: none; }
.loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: grid; gap: 8px; justify-items: center; color: var(--muted); font-size: 14px;
}
.loading .bar { width: 180px; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.loading .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* Qatlamlar */
.layers {
  position: fixed; left: 16px; top: 64px; z-index: 4;
  display: grid; gap: 8px; max-width: 220px;
}
.layer-list { display: grid; gap: 6px; }
.layer {
  display: flex; align-items: center; gap: 8px; justify-content: flex-start;
  text-align: left; border-radius: 10px; padding: 6px 10px; min-height: 38px;
  background: var(--panel);
}
.layer .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; opacity: 0.35; }
.layer[aria-pressed="true"] .dot { opacity: 1; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }
.layer[aria-pressed="false"] { color: var(--muted); }
body[data-mode="school"] .layer.student-only { display: none; }
.layer .pct { margin-left: auto; font-size: 12px; color: var(--muted); }
.opacity { display: grid; gap: 4px; font-size: 12px; color: var(--muted); background: var(--panel); padding: 8px 10px; border-radius: 10px; }
.opacity input { width: 100%; accent-color: var(--accent); }

/* Pastki asboblar */
.toolbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 10px 16px calc(12px + var(--safe-b));
  background: linear-gradient(transparent, var(--bg) 55%);
  pointer-events: none;
}
.toolbar > * { pointer-events: auto; }
.toolbar .short { display: none; }

/* Maʼlumot paneli */
.sheet, .game {
  position: fixed; z-index: 6;
  right: 16px; top: 64px; width: 340px; max-width: calc(100% - 32px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.sheet h2 { margin: 4px 32px 4px 0; font-size: 22px; line-height: 1.2; }
.sheet .system { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); }
.sheet .secondary { margin: 0 0 4px; font-style: italic; font-size: 16px; color: var(--text); }
.sheet .tertiary { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
.sheet .group { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.sheet { max-height: calc(100% - 80px); overflow-y: auto; }
.sheet .definition { margin: 10px 0 0; font-size: 15px; line-height: 1.5; }
.sheet .definition-en { margin-top: 10px; font-size: 14px; color: var(--muted); }
.sheet .definition-en summary { cursor: pointer; color: var(--text); padding: 4px 0; }
.sheet .definition-en p { margin: 6px 0 0; line-height: 1.5; }
.sheet .definition-en .source { font-size: 12px; }
.sheet .badge { margin: 10px 0 0; font-size: 12px; color: #f6d38f; background: rgba(242, 181, 68, 0.12); padding: 6px 8px; border-radius: 8px; }
.close { position: absolute; right: 10px; top: 10px; width: 36px; min-height: 36px; padding: 0; font-size: 20px; line-height: 1; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.actions button, .actions a.btn { flex: 1 1 auto; font-size: 14px; }
body[data-mode="school"] .tertiary { display: none; }

/* Oʻyin */
.game { left: 50%; right: auto; transform: translateX(-50%); top: 64px; text-align: center; }
.game-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.game-ask { margin: 10px 0 2px; font-size: 18px; }
.game-ask strong { color: var(--accent); }
.game-sub { margin: 0; font-size: 14px; color: var(--muted); font-style: italic; min-height: 1em; }
.game-feedback { margin: 8px 0 0; min-height: 1.3em; font-weight: 600; }
.game-feedback.ok { color: var(--ok); }
.game-feedback.bad { color: var(--bad); }
body.playing .layers, body.playing .toolbar #show-all { opacity: 0.6; }

/* Qismlar (yorliqlar) */
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lm {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  display: flex; align-items: flex-start; gap: 6px;
  min-height: 0; padding: 0; border: 0; background: none; border-radius: 0;
  font-size: 12px; line-height: 1.25; text-align: left; white-space: nowrap;
}
.lm i {
  flex: none; width: 9px; height: 9px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px rgba(15, 23, 32, 0.85);
}
.lm span, .lm small {
  margin-top: -9px; padding: 2px 6px; border-radius: 6px;
  background: rgba(15, 23, 32, 0.82); color: var(--text);
}
.lm.collide span { display: none; }
.lm small { display: none; font-size: 11px; color: var(--muted); margin-top: 4px; }
.lm.open { flex-direction: row; flex-wrap: wrap; max-width: 240px; white-space: normal; }
.lm.open small { display: block; flex-basis: 100%; margin-left: 15px; }
.lm:hover span, .lm.open span { background: var(--accent); color: var(--accent-ink); }
#act-parts[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* Nomlar */
.nm {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  margin: -11px 0 0 0; padding: 3px 8px; min-height: 0; border-radius: 999px;
  translate: -50% 0; white-space: nowrap; font-size: 12px; line-height: 1.3;
  background: rgba(15, 23, 32, 0.78); border: 1px solid rgba(255, 255, 255, 0.18); color: var(--text);
}
.nm:hover { background: var(--accent); color: var(--accent-ink); }
#names-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* Kesim */
.section-panel { display: grid; gap: 10px; top: 64px; bottom: auto; left: auto; right: 16px; transform: none; width: 360px; text-align: left; }
.section-panel input[type="range"] { width: 100%; accent-color: var(--accent); }
.section-panel .actions { margin-top: 0; }
.panel-title { margin: 0; font-size: 14px; color: var(--muted); }
.region-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.region-grid button { font-size: 14px; }
.region-grid button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
#region-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.detail-badge { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; margin: 0; z-index: 2;
  font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; pointer-events: none; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; min-height: 34px; padding: 6px 8px; font-size: 14px; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
#section-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* Dialoglar */
dialog {
  width: min(640px, calc(100% - 32px)); max-height: calc(100% - 64px);
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
#credits h2 { margin-top: 0; }
#credits li { margin-bottom: 8px; line-height: 1.45; }
#credits p { line-height: 1.5; }
.small { font-size: 13px; color: var(--muted); }
#search { padding: 12px; }
/* „Fikr bildirish“ uslublari css/feedback.css da — boshqa sahifalar ham ishlatadi. */
.search-box { display: flex; gap: 8px; }
.search-box input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.search-box button { width: 44px; padding: 0; font-size: 20px; }
.results { list-style: none; margin: 10px 0 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.results li button {
  width: 100%; text-align: left; border-radius: 8px; border: 0; background: transparent;
  display: grid; gap: 2px; padding: 8px 10px;
}
.results li button:hover, .results li button:focus-visible { background: var(--bg); }
.results small { color: var(--muted); font-style: italic; }
.results .empty { color: var(--muted); padding: 8px 10px; }
.noscript { position: fixed; inset: 40% 16px auto; text-align: center; }

/* Telefon */
@media (max-width: 640px) {
  .brand { font-size: 16px; }
  .brand span { display: none; }
  .topbar { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .icon-btn { width: 36px; }
  .mode button { padding: 6px 10px; font-size: 14px; }
  .layers { top: auto; bottom: calc(66px + var(--safe-b)); left: 0; right: 0; max-width: none; padding: 0 16px; }
  .layer-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .layer-list::-webkit-scrollbar { display: none; }
  .layer { flex: none; min-height: 36px; font-size: 14px; }
  .toolbar { gap: 5px; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar button { flex: none; font-size: 14px; padding: 8px 10px; }
  .toolbar .accent { margin-left: auto; }
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: calc(16px + var(--safe-b));
  }
  .sheet h2 { font-size: 20px; }
  .sheet { max-height: 60vh; }
  .game { top: 56px; width: calc(100% - 32px); }
  .section-panel { top: 56px; bottom: auto; left: 50%; right: auto; transform: translateX(-50%); padding: 12px; gap: 8px; }
  .toolbar .long { display: none; }
  .toolbar .short { display: inline; }
  .hint { top: 60px; font-size: 12px; border-radius: 12px; }
  .opacity { grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 6px 10px; }
}

/* Bosh sahifa va mavzular */
.home {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(ellipse at 50% 0%, #1d2b3a 0%, var(--bg) 60%);
  -webkit-overflow-scrolling: touch;
}
.deep .home { display: none; }
.home-in { max-width: 1080px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px calc(28px + var(--safe-b)); }
.home-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.home-brand { display: grid; line-height: 1.15; }
.home-brand b { font-size: 26px; letter-spacing: 0.3px; }
.home-brand span { color: var(--accent); font-size: 14px; }
.home-lead { color: var(--muted); line-height: 1.55; margin: 12px 0 18px; max-width: 720px; }
.home-lead b { color: var(--text); font-weight: 600; }
.home-tiles { display: grid; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: repeat(2, minmax(150px, auto)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  min-height: 150px; padding: 14px; border-radius: 16px; overflow: hidden; text-align: left; text-decoration: none;
  color: var(--text); background: linear-gradient(160deg, #1f2e3d, #142030); border: 1px solid var(--line);
}
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; opacity: 0.95; }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(10, 16, 23, 0.92)); }
.tile .t, .tile .s { position: relative; z-index: 1; }
.tile .t { font-size: 19px; font-weight: 700; }
.tile .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile:hover { border-color: rgba(255, 255, 255, 0.3); }
.tile-big { grid-row: span 2; }
.tile-big .t { font-size: 26px; color: var(--accent); }
.home-index {
  position: sticky; top: 0; z-index: 2; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 22px -16px 4px; padding: 10px 16px; background: rgba(15, 23, 32, 0.92); backdrop-filter: blur(6px);
}
.home-index::-webkit-scrollbar { display: none; }
.home-index a {
  flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-2);
  color: var(--text); text-decoration: none; font-size: 14px;
}
.topic-sec { scroll-margin-top: 60px; }
.topic-sec h2 { margin: 22px 0 2px; font-size: 21px; }
.topic-sec .sub { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: 2px;
  padding: 0 0 12px; border-radius: 14px; overflow: hidden; min-height: 0; background: var(--bg-2);
}
.card .pic {
  display: block; aspect-ratio: 1 / 1; margin-bottom: 8px;
  background: radial-gradient(circle at 50% 40%, #243548, #121c27 75%);
}
.card .pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .t { padding: 0 12px; font-weight: 600; font-size: 15px; line-height: 1.25; }
.card .s { padding: 0 12px; font-size: 12.5px; color: var(--muted); }
.card .s:empty { display: none; }
body[data-mode="school"] .card.student-only { display: none; }
.home-foot { margin-top: 28px; color: var(--muted); font-size: 13px; line-height: 1.5; border-top: 1px solid var(--line); padding-top: 14px; }
body.at-home { overflow: hidden; }

.topic-bar {
  position: absolute; left: 50%; top: 62px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 2px; max-width: calc(100% - 32px);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 999px; padding: 2px;
}
.topic-bar button { border: 0; background: transparent; min-height: 34px; }
.topic-name { padding: 4px 10px 4px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-name span { color: var(--accent); font-size: 18px; }
.topic-x { width: 34px; padding: 0; font-size: 20px; color: var(--muted); }
body.playing .topic-bar { display: none; }

@media (max-width: 640px) {
  .home-brand b { font-size: 22px; }
  .home-tiles { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
  .tile { min-height: 120px; }
  .tile-big { grid-column: span 2; grid-row: auto; min-height: 210px; }
  .tile .t { font-size: 17px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .topic-bar { top: 56px; }
}

/* Viktorina */
.quiz {
  position: fixed; z-index: 6; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%);
  width: 420px; max-width: calc(100% - 24px); text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); backdrop-filter: blur(6px);
}
.quiz .close { position: absolute; right: 6px; top: 6px; width: 34px; min-height: 34px; padding: 0; border: 0; background: transparent; font-size: 20px; color: var(--muted); }
.quiz .game-head { padding-right: 30px; }
.quiz-ask { margin: 8px 0 10px; font-size: 17px; font-weight: 600; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-options button { border-radius: 12px; min-height: 48px; font-size: 15px; line-height: 1.2; padding: 8px 10px; }
.quiz-options button.ok { background: var(--ok); border-color: var(--ok); color: #06210f; font-weight: 600; }
.quiz-options button.bad { background: var(--bad); border-color: var(--bad); color: #2a0606; }
.quiz-options button:disabled { cursor: default; opacity: 1; }
.quiz-final { margin: 0; font-size: 40px; font-weight: 700; color: var(--accent); }
.quiz-verdict { margin: 4px 0 8px; }
.quiz #quiz-result .actions { justify-content: center; }
body.quizzing .layers, body.quizzing .toolbar, body.quizzing .topic-bar, body.quizzing #info { display: none !important; }
.quiz-pin { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; }
.quiz-pin i {
  position: absolute; left: -14px; top: -38px; width: 28px; height: 28px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: var(--accent); box-shadow: 0 0 0 3px rgba(15, 23, 32, 0.85), 0 4px 10px rgba(0, 0, 0, 0.5);
  animation: pin-drop 0.35s ease-out;
}
.quiz-pin i::after { content: ""; position: absolute; left: 9px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent-ink); }
@keyframes pin-drop { from { translate: 0 -14px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
#quiz-pick h2 { margin-top: 0; }
.quiz-type { margin: 4px 0 6px; }
.quiz-pick-sub { margin: 14px 0 4px; font-weight: 600; }
.quiz-sec { margin: 12px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 14px; padding: 6px 12px; min-height: 36px; }
.accent-chip { border-color: var(--accent); color: var(--accent); }
body[data-mode="school"] .chip.student-only { display: none; }
#quiz-pick .close { float: right; width: 36px; min-height: 36px; padding: 0; font-size: 20px; }

@media (max-width: 640px) {
  .quiz { bottom: calc(8px + var(--safe-b)); padding: 12px; }
  .quiz-options button { font-size: 14px; min-height: 46px; }
}
.sec-presets { gap: 5px; }
.sec-presets .chip { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.sec-presets .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
@media (max-width: 640px) {
  .section-panel { gap: 6px; padding: 8px 10px; }
  .sec-presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px; }
  .sec-presets::-webkit-scrollbar { display: none; }
  .sec-presets .chip { flex: none; }
  .section-panel .seg button { min-height: 30px; padding: 4px 6px; font-size: 13px; }
  .section-panel .actions { flex-wrap: nowrap; gap: 6px; }
  .section-panel .actions button { flex: 1; min-height: 34px; padding: 4px 8px; font-size: 13px; }
}

/* Tekisliklar darsi */
.plane-labels .pl {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12.5px; font-weight: 600; pointer-events: none;
  padding: 3px 8px; border-radius: 999px; background: rgba(15, 23, 32, 0.82); border: 1px solid var(--line);
}
.plane-labels .pl small { font-weight: 400; color: var(--muted); }
.pl.red, b.red { color: #ff7b7f; }
.pl.blue, b.blue { color: #7db4ff; }
.pl.green, b.green { color: #7fd38a; }
.lesson { top: auto; bottom: 72px; left: 16px; right: auto; max-height: calc(100% - 430px); }
.lesson summary { cursor: pointer; font-weight: 700; font-size: 16px; }
.lesson p { line-height: 1.5; font-size: 14px; margin: 8px 0 0; }
body.at-home .lesson, body.quizzing .lesson, body.quizzing .plane-labels { display: none !important; }
@media (max-width: 640px) {
  .lesson { top: 100px; bottom: auto; max-height: 50vh; border-radius: var(--radius); left: 12px; right: 12px; width: auto; }
  .plane-labels .pl { font-size: 11px; padding: 2px 6px; }
  .plane-labels .pl small { display: none; }
}

/* Qaysi tomondan qarash */
.viewdir { position: absolute; right: 16px; bottom: 76px; z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.viewdir-btn { background: var(--panel); }
.viewdir-menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.viewdir-menu button { min-height: 34px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
body.quizzing .viewdir, body.playing .viewdir { display: none; }
@media (max-width: 640px) {
  /* telefonda pastki panel balandligi oʻzgaradi — tugma yuqorida, menyu pastga ochiladi */
  .viewdir { right: 12px; top: auto; bottom: calc(196px + var(--safe-b)); }
  .check-row { padding: 4px 10px; }
}

/* Oʻqituvchi testi */
.teacher-banner {
  display: grid; gap: 2px; margin-top: 14px; padding: 12px 16px; border-radius: 14px; text-decoration: none; color: var(--text);
  background: linear-gradient(120deg, rgba(242, 181, 68, 0.16), rgba(242, 181, 68, 0.04)); border: 1px solid rgba(242, 181, 68, 0.45);
}
.teacher-banner .t { font-weight: 700; color: var(--accent); }
.teacher-banner .s { font-size: 13.5px; color: var(--muted); }
.book-banner { background: linear-gradient(120deg, rgba(76, 195, 138, 0.18), rgba(76, 195, 138, 0.04)); border-color: rgba(76, 195, 138, 0.5); }
.book-banner .t { color: #6fdca5; font-size: 17px; }
#test-start .kicker { margin: 0; color: var(--accent); font-size: 13px; }
#test-start h2 { margin: 0; }
.test-done { text-align: center; }
.test-done .actions { justify-content: center; }
.check-row { display: flex !important; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 13px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* Ajratish */
.explode-panel input[type="range"] { width: 100%; accent-color: var(--accent); }
.explode-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -6px; }
#explode-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
body.exploded #names, body.exploded #labels { display: none; }
.hover-tip {
  position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; white-space: nowrap;
  padding: 4px 9px; border-radius: 8px; font-size: 13px; background: rgba(15, 23, 32, 0.9);
  border: 1px solid var(--line); color: var(--text); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
@media (min-width: 641px) {
  .explode-panel { top: auto; bottom: 64px; right: auto; left: 50%; transform: translateX(-50%); width: 440px; }
}

/* Jarayonlar */
.proc .proc-phase { margin: 0 0 8px; font-weight: 700; color: var(--accent); min-height: 2.6em; font-size: 15px; line-height: 1.3; }
.proc-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.proc-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.proc-legend i.red, .proc span.red { background: none; }
.proc-legend i.red { background: #e2463a; }
.proc-legend i.blue { background: #3d64d8; }
.proc span.red { color: #ff7b6f; font-weight: 600; }
.proc span.blue { color: #7da2ff; font-weight: 600; }
.proc-legend i.cyan { background: #4ec8ff; }
.proc-legend i.amber { background: #ffb85c; }
.proc-legend i.green { background: #6fdc5a; }
.proc span.cyan { color: #6fd2ff; font-weight: 600; }
.proc span.amber { color: #ffc277; font-weight: 600; }
.proc-ctrl { display: flex; align-items: center; gap: 10px; }
.proc-ctrl #proc-play { width: 44px; padding: 0; font-size: 18px; flex: none; }
.proc-bpm { flex: 1; display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.proc-bpm input { width: 100%; accent-color: var(--accent); }
.proc details { margin-top: 10px; }
body.at-home .proc, body.quizzing .proc { display: none !important; }
@media (max-width: 640px) {
  .proc { top: 98px; padding: 10px 12px; }
  .proc .proc-phase { min-height: 0; font-size: 13.5px; margin-bottom: 4px; }
  .proc-legend { margin-bottom: 4px; }
}
.proc { max-height: calc(100% - 360px); }
@media (max-width: 640px) { .proc { max-height: 45vh; } }
#proc-play svg { width: 20px; height: 20px; fill: currentColor; display: block; margin: auto; }
#proc-play[data-playing="1"] .i-play, #proc-play[data-playing="0"] .i-pause { display: none; }
.pan-btns { display: flex; flex-direction: column; gap: 6px; }
.pan-btns .icon-btn, .viewdir-btn { background: var(--panel); }
.hint .mouse-hint { display: none; }
@media (pointer: fine) { .hint .mouse-hint { display: inline; } .hint .touch-hint { display: none; } }

/* Darslik mavzusi (§) paneli: shu darsning 3D mavzulari, viktorina, test, oldingi/keyingi § */
.par-bar {
  position: absolute; left: 50%; top: 62px; transform: translateX(-50%); z-index: 4; width: min(640px, calc(100% - 24px));
  background: var(--panel); border: 1px solid rgba(76, 195, 138, 0.6); border-radius: 16px; padding: 4px 4px 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
body.in-par .topic-bar { display: none; }
body.at-home .par-bar, body.quizzing .par-bar, body.playing .par-bar { display: none !important; }
.par-head { display: flex; align-items: center; gap: 2px; }
.par-head button, .par-x { border: 0; background: transparent; min-height: 36px; color: var(--text); }
.par-nav { width: 36px; padding: 0; font-size: 22px; color: #6fdca5 !important; }
.par-nav:disabled { opacity: 0.3; }
.par-title { flex: 1; min-width: 0; text-align: left; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.par-title b { color: #6fdca5; }
.par-title i { font-style: normal; color: var(--muted); font-size: 12px; }
.par-x { width: 36px; display: grid; place-items: center; font-size: 20px; color: var(--muted); text-decoration: none; }
.par-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 4px 0; scrollbar-width: none; }
.par-chips::-webkit-scrollbar { display: none; }
.par-chips button, .par-chips a {
  flex: none; font-size: 13px; padding: 6px 12px; min-height: 32px; border-radius: 999px; white-space: nowrap; text-decoration: none;
  background: var(--bg-2, #16212d); border: 1px solid var(--line, rgba(255,255,255,0.12)); color: var(--text);
}
.par-chips .on { background: rgba(76, 195, 138, 0.2); border-color: #4cc38a; color: #b9f0d2; font-weight: 600; }
.par-chips .act { border-color: rgba(242, 181, 68, 0.6); color: var(--accent); }
.par-more { padding: 8px 8px 2px; max-height: 32vh; overflow-y: auto; }
.par-more p { margin: 0 0 8px; font-size: 14px; line-height: 1.5; color: #cfdae4; }
.par-more a { font-size: 13px; color: #6fdca5; }
@media (max-width: 640px) {
  .par-bar { top: 56px; }
  body.in-par .proc, body.in-par .lesson { top: calc(var(--par-b, 100px) + 8px); }
}

/* Mikro-modellar: hujayra, qon, neyron, teri kesimi */
#micro-view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#micro-view[hidden] { display: none; }
.mlabels { pointer-events: none; }
body:not(.in-micro) .mlabels { display: none; }
.mlab {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12.5px; padding: 3px 8px 3px 4px; border-radius: 999px;
  background: rgba(12, 18, 25, 0.82); border: 1px solid rgba(255, 255, 255, 0.16); color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.mlab i {
  font-style: normal; font-size: 11px; font-weight: 700; width: 18px; height: 18px; flex: none;
  display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-ink, #1b1406);
}
body.in-micro #view { display: none; }
body.in-micro .layers, body.in-micro .toolbar, body.in-micro .viewdir, body.in-micro #info { display: none !important; }
@media (max-width: 860px) {
  .mlab { padding: 2px; gap: 0; }
  .mlab b { display: none; }     /* tor ekranda faqat raqam — model toʻsilib qolmaydi */
  .mlab i { width: 22px; height: 22px; font-size: 12px; }
}

/* Interaktiv sxemalar (qon guruhlari, vitaminlar, energiya…) */
.sxema {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--par-b, 108px) + 10px); bottom: 12px;
  width: min(680px, calc(100% - 24px)); overflow-y: auto; z-index: 2;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
}
.sxema[hidden] { display: none; }
body.in-sxema .layers, body.in-sxema .toolbar, body.in-sxema .viewdir, body.in-sxema #info { display: none !important; }
body.in-sxema #view { display: none; }
.sx-lead { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: #cfdae4; }
.sx-sub { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.sx-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sx-chip {
  font-size: 13.5px; padding: 7px 12px; min-height: 36px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2, #16212d); border: 1px solid var(--line); color: var(--text);
}
.sx-chip small { color: var(--muted); margin-left: 4px; }
.sx-chip.on { background: rgba(76, 195, 138, 0.22); border-color: #4cc38a; color: #b9f0d2; font-weight: 600; }
.sx-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.sx-cell { padding: 10px 6px; border-radius: 12px; text-align: center; border: 1px solid var(--line); background: var(--bg-2, #16212d); }
.sx-cell b { display: block; font-size: 14px; }
.sx-cell span { font-size: 11.5px; color: var(--muted); }
.sx-cell.ok { border-color: #4cc38a; background: rgba(76, 195, 138, 0.14); }
.sx-cell.ok span { color: #8fe0b4; }
.sx-cell.bad { border-color: rgba(239, 100, 97, 0.5); background: rgba(239, 100, 97, 0.08); }
.sx-cell.bad span { color: #f09a98; }
.sx-info { margin: 12px 0 0; font-size: 14px; line-height: 1.55; color: #cfdae4; }
.sx-note { margin: 14px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.sx-card { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg-2, #16212d); border: 1px solid var(--line); }
.sx-card h3 { margin: 0 0 8px; font-size: 16px; }
.sx-card h3 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.sx-card p { margin: 0 0 6px; font-size: 14px; line-height: 1.5; color: #cfdae4; }
.sx-card ol { margin: 0; padding-left: 20px; line-height: 1.65; font-size: 14px; color: #cfdae4; }
.sx-card .warn, .sx-bal .warn { color: #f6b26b; }
.sx-bal .good { color: #6fdca5; }
.sx-stage svg { width: 100%; height: auto; background: var(--bg-2, #16212d); border-radius: 12px; margin-bottom: 10px; }
.sx-steps { display: grid; gap: 8px; }
.sx-step { padding: 10px 12px; border-radius: 12px; background: var(--bg-2, #16212d); border: 1px solid var(--line); }
.sx-step b { color: var(--accent); }
.sx-step p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; color: #cfdae4; }
.sx-bal { margin-top: 12px; }
.sx-bal-in { height: 12px; border-radius: 999px; background: var(--bg-2, #16212d); border: 1px solid var(--line); overflow: hidden; }
.sx-bal-in i { display: block; height: 100%; background: linear-gradient(90deg, #f2b544, #e0705a); }
.sx-bal-t { margin: 8px 0 0; font-size: 14px; line-height: 1.6; color: #cfdae4; }
.sx-bal-q { display: block; height: 4px; margin-top: 6px; border-radius: 999px; background: #4f9fd8; }
.sx-bars { display: grid; gap: 8px; }
.sx-barrow { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.sx-barrow i { display: block; height: 14px; border-radius: 999px; background: linear-gradient(90deg, #4f9fd8, #8f87f0); }
.sx-barrow b { color: var(--text); font-size: 13px; }
@media (max-width: 640px) {
  .sxema { padding: 12px; }
  .sx-grid { grid-template-columns: repeat(2, 1fr); }
  .sx-barrow { grid-template-columns: 72px 1fr auto; font-size: 12px; }
}

/* Dars atamalari */
.par-terms { max-height: 34vh; overflow-y: auto; padding: 6px 4px 2px; display: grid; gap: 6px; }
.par-term {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2, #16212d); padding: 8px 10px; cursor: pointer;
}
.par-term > b { font-size: 14px; }
.par-term p { margin: 6px 0 0; font-size: 13.5px; line-height: 1.5; color: #cfdae4; }
.par-term .show3d {
  margin-top: 8px; font-size: 13px; padding: 5px 12px; min-height: 32px; border-radius: 999px;
  background: rgba(76, 195, 138, 0.18); border: 1px solid #4cc38a; color: #b9f0d2; cursor: pointer;
}
.par-term.on { border-color: #4cc38a; }

/* Karta yorliqlarni toʻsib qoʻymasin: bosish undan oʻtib yorliqqa yetadi,
   faqat yopish tugmasi bosiladi. */
.micro-info { z-index: 3; pointer-events: none; }
.micro-info #micro-info-close, .micro-info .mi-clear { pointer-events: auto; }
.mi-clear { margin-top: 12px; font-size: 13px; padding: 6px 13px; min-height: 34px; }
.micro-info h2 { margin: 2px 32px 6px 0; font-size: 19px; }
.mlab.tap { cursor: pointer; pointer-events: auto; }
.mlab.tap:hover { border-color: rgba(255, 255, 255, 0.4); }
.mlab.on { background: rgba(76, 195, 138, 0.9); color: #09150f; border-color: #4cc38a; font-weight: 600; }
