/* Ibroximov Baxromsher — Telegram mavzusiga moslashadigan, mobil-birinchi dizayn.
   Telegram ichida --tg-theme-* o'zgaruvchilarini telegram-web-app.js o'zi beradi. */

:root {
  /* Zaxira ranglar (Telegram mavzu bermasa yoki oddiy brauzerda) */
  --z-fon: #f4f7f5;
  --z-karta: #ffffff;
  --z-matn: #16211b;
  --z-ikkinchi: #66756c;
  --z-asosiy: #1f8a52;
  --z-havola: #1f8a52;

  /* Telegram'da sahifa foni — secondary_bg, kartalar — section_bg (Telegram sozlamalari uslubi) */
  --fon: var(--tg-theme-secondary-bg-color, var(--z-fon));
  --karta: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--z-karta)));
  --matn: var(--tg-theme-text-color, var(--z-matn));
  --ikkinchi-matn: var(--tg-theme-hint-color, var(--z-ikkinchi));
  --asosiy: var(--tg-theme-button-color, var(--z-asosiy));
  --asosiy-matn: var(--tg-theme-button-text-color, #ffffff);
  --havola: var(--tg-theme-link-color, var(--z-havola));
  --chiziq: rgba(127, 127, 127, 0.18);
  --yashil: #1f9d55;
  --sariq: #d08a00;
  --qizil: #d64545;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not(.tg) { --z-fon: #101613; --z-karta: #19221d; --z-matn: #e7efe9; --z-ikkinchi: #93a399; --z-asosiy: #2fb06a; --z-havola: #4fd18a; }
}
:root[data-sxema="dark"] { --z-fon: #101613; --z-karta: #19221d; --z-matn: #e7efe9; --z-ikkinchi: #93a399; --z-asosiy: #2fb06a; --z-havola: #4fd18a; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fon);
  color: var(--matn);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main { max-width: 760px; margin: 0 auto; padding: 16px 14px 24px; min-height: 80vh; }
h1 { font-size: 1.45rem; margin: 6px 0 12px; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }
a { color: var(--havola); }
img { max-width: 100%; }

.yuklanmoqda { padding: 40px 0; text-align: center; color: var(--ikkinchi-matn); }
.kichik-matn, small { color: var(--ikkinchi-matn); font-size: 0.88rem; }
.xato-matn { color: var(--qizil); }
.ogoh { color: var(--sariq); font-size: 0.85rem; }
.orqaga { display: inline-block; margin-bottom: 4px; text-decoration: none; font-size: 0.95rem; }
.pastki { text-align: center; color: var(--ikkinchi-matn); font-size: 0.8rem; padding: 0 0 24px; }

/* ---------- bosh sahifa */
.bosh-sarlavha {
  background: linear-gradient(135deg, #1f8a52, #2c6fb0);
  color: #fff; border-radius: var(--radius); padding: 18px 16px; margin-bottom: 16px;
}
.bosh-sarlavha p { margin: 6px 0 14px; opacity: 0.95; }
.logo { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.5px; }
.statlar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.statlar div { background: rgba(255, 255, 255, 0.16); border-radius: 10px; padding: 8px; text-align: center; }
.statlar b { display: block; font-size: 1.15rem; }
.statlar span { font-size: 0.75rem; opacity: 0.9; }

.bolimlar, .setka { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .bolimlar, .setka { grid-template-columns: repeat(3, 1fr); } }

.bolim {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--karta); color: var(--matn); text-decoration: none;
  border-radius: var(--radius); padding: 14px; border: 1px solid var(--chiziq);
  transition: transform 0.12s;
}
.bolim:active { transform: scale(0.97); }
.bolim.gorizontal { margin-bottom: 10px; }
.bolim.diqqat { border-color: var(--sariq); }
.ikon { font-size: 1.7rem; line-height: 1.2; }
.ikon.katta {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--asosiy); color: var(--asosiy-matn); font-weight: 800; font-size: 1.3rem; margin-bottom: 4px;
}

/* ---------- ro'yxatlar va kartalar */
.karta {
  background: var(--karta); border-radius: var(--radius); padding: 14px;
  margin-bottom: 12px; border: 1px solid var(--chiziq);
}
.karta > summary { cursor: pointer; }
.royxat { list-style: none; padding: 0; margin: 0; counter-reset: n; }
ol.royxat li { counter-increment: n; }
ol.royxat li > a > span:first-child::before, ol.royxat li.tez-orada > span:first-child::before { content: counter(n) ". "; color: var(--ikkinchi-matn); }
.royxat li > a, .royxat li.tez-orada {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 12px; margin-bottom: 8px; border-radius: 12px; text-decoration: none;
  background: var(--karta); color: var(--matn); border: 1px solid var(--chiziq);
}
.karta .royxat li > a { background: transparent; }
.royxat li.tez-orada { opacity: 0.55; }
.royxat li small { white-space: nowrap; }
.strelka { color: var(--ikkinchi-matn); font-size: 1.3rem; line-height: 1; }

.badge { font-size: 0.8rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: #fff; white-space: nowrap; }
.badge.yashil, .natija-foiz.yashil { background: var(--yashil); }
.badge.sariq, .natija-foiz.sariq { background: var(--sariq); }
.badge.qizil, .natija-foiz.qizil { background: var(--qizil); }

.chiplar { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chiziq); border-radius: 99px; padding: 4px 10px; font-size: 0.88rem; }

/* ---------- tugmalar */
.tugma {
  display: inline-block; border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--asosiy); color: var(--asosiy-matn); font: inherit; font-weight: 600;
  text-decoration: none; text-align: center; cursor: pointer;
}
.tugma.ikkinchi { background: var(--chiziq); color: var(--matn); }
.tugmalar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tugmalar .tugma { flex: 1; }
.tugmalar.ustun { flex-direction: column; }

/* ---------- video */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video.bosh {
  display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%;
  background: linear-gradient(135deg, rgba(31, 138, 82, 0.15), rgba(44, 111, 176, 0.15));
  color: var(--matn); border: 1px dashed var(--chiziq); font: inherit; cursor: pointer;
}
.video.bosh span { font-size: 2.4rem; }
.video.bosh p { margin: 4px 0 0; color: var(--ikkinchi-matn); }
.konspekt p { margin: 0 0 10px; }

/* ---------- test */
.test-bosh { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.taymer { font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--chiziq); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress div { height: 100%; background: var(--asosiy); transition: width 0.25s; }
.savol-matn { font-weight: 600; margin: 0 0 10px; }
.savol-rasm { display: block; margin: 8px auto 12px; max-height: 260px; border-radius: 10px; background: #fff; }
.savol-rasm.kichik { max-height: 140px; }
.variantlar { display: flex; flex-direction: column; gap: 8px; }
.variant {
  display: flex; gap: 8px; align-items: flex-start; text-align: left;
  border: 1.5px solid var(--chiziq); background: transparent; color: var(--matn);
  border-radius: 12px; padding: 11px 12px; font: inherit; cursor: pointer;
}
.variant:disabled { cursor: default; }
.variant.tanlangan { border-color: var(--asosiy); background: rgba(31, 138, 82, 0.1); }
.variant.togri { border-color: var(--yashil); background: rgba(31, 157, 85, 0.14); }
.variant.notogri { border-color: var(--qizil); background: rgba(214, 69, 69, 0.12); }
.izoh { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(44, 111, 176, 0.1); font-size: 0.95rem; }
.nuqtalar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.nuqta {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--chiziq);
  background: transparent; color: var(--matn); font: inherit; font-size: 0.8rem; cursor: pointer;
}
.nuqta.bor { background: rgba(31, 138, 82, 0.18); }
.nuqta.joriy { border: 2px solid var(--asosiy); font-weight: 700; }

.natija { text-align: center; }
.natija-foiz {
  width: 110px; height: 110px; border-radius: 50%; margin: 6px auto 10px;
  display: grid; place-items: center; color: #fff; font-size: 2rem; font-weight: 800;
}
.daraja { font-size: 1.05rem; }
.korib.ok { border-left: 4px solid var(--yashil); }
.korib.xato { border-left: 4px solid var(--qizil); }
.korib p { margin: 4px 0; }

/* ---------- masalalar */
.masala details { margin-top: 12px; }
.masala summary { cursor: pointer; color: var(--havola); font-weight: 600; }
.yechim { padding-left: 20px; margin: 8px 0 0; }
.yechim li { margin-bottom: 6px; }

/* ---------- jadvallar, laboratoriya */
.jadval { border-collapse: collapse; margin: 8px auto; font-size: 0.92rem; }
.jadval th, .jadval td { border: 1px solid var(--chiziq); padding: 6px 8px; text-align: center; }
.jadval th { background: rgba(127, 127, 127, 0.08); }
.jadval.chap { width: 100%; }
.jadval.chap th { text-align: left; width: 42%; }
.jadval.chap td { text-align: left; }
.jadval-orama { overflow-x: auto; }
.punnett td { font-family: ui-monospace, Menlo, monospace; }
.ketma { font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.qator { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.qator input { flex: 1; min-width: 0; }
input, textarea {
  font: inherit; color: var(--matn); background: var(--fon);
  border: 1.5px solid var(--chiziq); border-radius: 10px; padding: 10px;
}
textarea { width: 100%; margin-bottom: 10px; font-family: ui-monospace, Menlo, monospace; }
.nisbat { margin: 0; padding-left: 18px; }
.hisob { text-align: center; }
.katta-son { font-size: 3rem; font-weight: 800; color: var(--asosiy); line-height: 1.1; }
.qogozlar { padding-left: 18px; margin: 10px 0 0; }
.qogozlar li { margin-bottom: 8px; }

/* ---------- toast, oyna */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 99px; transition: 0.25s; z-index: 10;
}
.toast.korin { opacity: 1; transform: translate(-50%, 0); }
.oyna { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: grid; place-items: center; z-index: 20; padding: 16px; }
.oyna-ichi { background: var(--karta); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 560px; }
.oyna-ichi textarea { height: 50vh; font-size: 0.85rem; }

/* ---------- Biology English */
.bolim.keng { margin-bottom: 10px; border-color: var(--asosiy); background: linear-gradient(135deg, rgba(31, 138, 82, 0.12), rgba(44, 111, 176, 0.12)), var(--karta); }
.statlar.kulrang div { background: var(--chiziq); }
.statlar.kulrang span { opacity: 1; color: var(--ikkinchi-matn); }
.hisob .tugma { margin-top: 12px; }
.ovoz { border: 0; background: transparent; font-size: 1.05rem; cursor: pointer; padding: 0 2px; vertical-align: middle; }
.tarjima { color: var(--ikkinchi-matn); font-weight: 400; font-size: 0.92rem; display: block; margin-top: 4px; }
.tarjima-tugma { border: 1px solid var(--chiziq); background: transparent; color: var(--matn); border-radius: 99px; padding: 2px 10px; font: inherit; font-size: 0.85rem; cursor: pointer; }
.tarjima-tugma.yoniq { background: var(--asosiy); color: var(--asosiy-matn); border-color: var(--asosiy); }
.test-bosh { align-items: center; gap: 8px; }
.kartochka { text-align: center; padding: 22px 14px; }
.soz-en { font-size: 1.8rem; font-weight: 800; }
.soz-uz { font-size: 1.4rem; font-weight: 700; color: var(--asosiy); margin: 10px 0 6px; }
.misol { font-style: italic; }
.tugma.qizil-tugma { background: var(--qizil); color: #fff; }
.sozlar, .misollar { list-style: none; padding: 0; margin: 0; }
.sozlar li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--chiziq); }
.sozlar .uz { text-align: right; color: var(--ikkinchi-matn); }
.misollar li { padding: 8px 0; border-bottom: 1px solid var(--chiziq); }
.shablon { font-family: ui-monospace, Menlo, monospace; background: var(--chiziq); padding: 8px 10px; border-radius: 8px; }

/* =====================================================================
   Qurilmalarga moslashuv: telefon → iPad → kompyuter
   ===================================================================== */

/* iPhone "chiqiq" (notch) va yumaloq burchaklar uchun xavfsiz chegaralar */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
main { padding-top: max(16px, env(safe-area-inset-top)); }

/* ---------- pastki menyu (telefon va iPad tik holatda) */
.yon-panel { display: none; }
body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
.tab-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--karta); border-top: 1px solid var(--chiziq);
  padding: 6px max(4px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
}
.tab-panel a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 0;
  text-decoration: none; color: var(--ikkinchi-matn); font-size: 1.3rem; line-height: 1.2; border-radius: 10px;
}
.tab-panel a small { font-size: 0.68rem; color: inherit; }
.tab-panel a.faol { color: var(--asosiy); }
.tab-panel a.faol small { font-weight: 700; }

.ornatish-banner {
  display: block; margin-bottom: 10px; padding: 10px 14px; border-radius: 12px; text-decoration: none;
  background: var(--karta); border: 1px dashed var(--asosiy); color: var(--havola); font-weight: 600; font-size: 0.95rem;
}
.qadamlar { padding-left: 18px; margin: 10px 0 0; }
.qadamlar li { margin-bottom: 8px; }
.fayl-tugma { position: relative; cursor: pointer; }
details > summary { cursor: pointer; color: var(--havola); font-weight: 600; margin-top: 10px; }
.karta > details > summary { margin-top: 12px; }

/* ---------- klaviatura maslahati: faqat sichqoncha/trackpad bor qurilmalarda */
.klaviatura-maslahat { display: none; color: var(--ikkinchi-matn); font-size: 0.8rem; text-align: center; margin: 10px 0 0; }

@media (hover: hover) and (pointer: fine) {
  .klaviatura-maslahat { display: block; }
  .bolim:hover, .royxat li > a:hover { border-color: var(--asosiy); }
  .bolim:hover { transform: translateY(-2px); }
  .variant:not(:disabled):hover { border-color: var(--asosiy); background: rgba(31, 138, 82, 0.05); }
  .tugma:hover { filter: brightness(1.07); }
  .tab-panel a:hover { background: var(--chiziq); }
}

/* ---------- iPad (tik) va katta ekranlar */
@media (min-width: 700px) {
  main { max-width: 820px; padding-left: 24px; padding-right: 24px; padding-bottom: 32px; }
  h1 { font-size: 1.7rem; }
  .bolimlar, .setka { gap: 14px; }
  .bolim { padding: 18px; }
  .ikon { font-size: 2rem; }
  .test, .kartochka, #karta-joy > .test-bosh { max-width: 720px; margin-left: auto; margin-right: auto; }
  .variant { padding: 13px 16px; font-size: 1.04rem; }
  .savol-rasm { max-height: 340px; }
  .soz-en { font-size: 2.2rem; }
  .tab-panel a small { font-size: 0.75rem; }
}

/* ---------- kompyuter va iPad (yotiq): chap menyu, pastki menyu yashiriladi */
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .tab-panel { display: none; }
  .toast { bottom: 28px; }
  .qobiq { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
  .yon-panel {
    display: block; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: max(20px, env(safe-area-inset-top)) 14px 20px; background: var(--karta); border-right: 1px solid var(--chiziq);
  }
  .yon-logo {
    display: flex; align-items: center; gap: 10px; margin: 0 8px 18px;
    font-weight: 800; font-size: 1.1rem; line-height: 1.15; color: var(--matn); text-decoration: none;
  }
  .yon-logo img { width: 34px; height: 34px; border-radius: 9px; }
  .yon-panel nav a {
    display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 2px;
    border-radius: 10px; color: var(--matn); text-decoration: none;
  }
  .yon-panel nav a:hover { background: var(--chiziq); }
  .yon-panel nav a.faol { background: var(--asosiy); color: var(--asosiy-matn); font-weight: 600; }
  main { max-width: 980px; padding: 28px 40px 36px; }
  .bosh-sarlavha { padding: 26px 28px; }
  .bosh-sarlavha .logo { font-size: 2rem; }
}

/* ---------- Telegram ichida: chap menyu yo'q, pastki menyu har qanday kenglikda */
.tg .yon-panel { display: none !important; }
.tg .qobiq { display: block; }
.tg .tab-panel { display: flex !important; }
.tg body { padding-bottom: calc(66px + env(safe-area-inset-bottom)) !important; }

/* A Level yozma (structured) savollar */
.qism .savol-matn { margin-bottom: 8px; }
.ball-belgi { color: var(--ikkinchi-matn); font-weight: 600; white-space: nowrap; }
.yozma-javob { font-family: inherit; font-size: 1rem; line-height: 1.45; resize: vertical; min-height: 80px; }
.mark-scheme { border-top: 1px dashed var(--chiziq); margin-top: 6px; padding-top: 10px; }
.ms-nuqta { display: flex; gap: 10px; align-items: flex-start; padding: 7px 4px; border-radius: 8px; cursor: pointer; }
.ms-nuqta:hover { background: var(--chiziq); }
.ms-nuqta input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--asosiy); }
.qism-ball { text-align: right; font-weight: 700; margin: 6px 0 0; }
.jami-ball { font-size: 1.1rem; margin: 0 0 10px; }
.yozma-amallar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.yozma-amallar .jami-ball { flex-basis: 100%; }
