:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2a7bde);
  --btn: var(--tg-theme-button-color, #2a7bde);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --ok: #2fa84f;
  --warn: #e0a100;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
textarea, input { -webkit-user-select: text; user-select: text; }

main { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 22px; margin: 4px 0 4px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.muted { color: var(--hint); font-size: 13px; }
p { margin: 6px 0; }

.loader { width: 28px; height: 28px; margin: 40vh auto 0; border: 3px solid var(--bg2); border-top-color: var(--btn);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Banner */
.banner { background: var(--bg2); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; font-size: 14px; }
.banner b { display: block; margin-bottom: 2px; }

/* Ekspert kartochkasi */
.card { display: flex; gap: 12px; align-items: center; background: var(--bg2); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px; cursor: pointer; transition: transform .12s ease-out; }
.card:active { transform: scale(.98); }
.avatar { width: 52px; height: 52px; border-radius: 50%; flex: none; background: var(--btn); color: var(--btn-text);
  display: grid; place-items: center; font-weight: 600; font-size: 20px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.card .body { flex: 1; min-width: 0; }
.card .name { font-weight: 600; }
.card .sub { color: var(--hint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 5px; background: color-mix(in srgb, var(--hint) 25%, transparent); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }

/* Dars ro'yxati */
.lesson { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius);
  background: var(--bg2); margin-bottom: 8px; cursor: pointer; }
.lesson .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 600; background: var(--btn); color: var(--btn-text); }
.lesson.done .num { background: var(--ok); }
.lesson.locked { opacity: .55; }
.lesson.locked .num { background: var(--hint); }
.lesson .body { flex: 1; min-width: 0; }
.lesson .title { font-weight: 500; }
.lesson .state { font-size: 12px; color: var(--hint); }

/* Video */
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; }
.player video { width: 100%; height: 100%; display: block; }
.watermark { position: absolute; pointer-events: none; color: rgba(255,255,255,.35); font-size: 12px;
  font-weight: 600; text-shadow: 0 0 2px rgba(0,0,0,.6); transition: top 1.2s ease, left 1.2s ease; white-space: nowrap; }
.novideo { aspect-ratio: 16/9; border-radius: var(--radius); background: var(--bg2); display: grid; place-items: center;
  color: var(--hint); text-align: center; padding: 16px; }
.watch-info { margin-top: 8px; font-size: 13px; color: var(--hint); }

/* Vazifa */
.task { border: 2px solid var(--btn); border-radius: var(--radius); padding: 14px; margin-top: 18px; }
.task.locked { border-color: color-mix(in srgb, var(--hint) 40%, transparent); }
.task h3 { margin: 0 0 8px; font-size: 16px; }
.task .text { white-space: pre-wrap; }
textarea { width: 100%; min-height: 120px; margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--hint) 40%, transparent); background: var(--bg); color: var(--text);
  font: inherit; resize: vertical; }
.counter { text-align: right; font-size: 12px; color: var(--hint); margin-top: 4px; }
.file-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.file-row label { color: var(--link); cursor: pointer; font-size: 14px; }
.file-row .fname { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.btn { display: block; width: 100%; padding: 13px; border: 0; border-radius: 12px; background: var(--btn); color: var(--btn-text);
  font: inherit; font-weight: 600; line-height: 1; margin-top: 12px; cursor: pointer; transition: transform .12s ease-out, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--bg2); color: var(--link); }

.done-box { background: color-mix(in srgb, var(--ok) 14%, transparent); border-radius: var(--radius); padding: 14px; margin-top: 18px; }
.done-box .answer { white-space: pre-wrap; font-size: 14px; margin-top: 6px; }
.reply { margin-top: 10px; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: 14px; white-space: pre-wrap; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); background: #222; color: #fff;
  padding: 12px 14px; border-radius: 12px; font-size: 14px; z-index: 10; }
