/* «Сөз әлемі» — ортақ стиль */
:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-2: #eef3fa;
  --text: #16212f;
  --muted: #5a6a7e;
  --line: #e1e8f0;
  --primary: #1b74e4;
  --primary-2: #155fc0;
  --primary-soft: #e6f0fd;
  --on-primary: #ffffff;
  --gold: #e9a21c;
  --gold-soft: #fdf3dc;
  --ok: #17915a;
  --ok-soft: #e3f5ec;
  --err: #d23f3f;
  --err-soft: #fde9e9;
  --warn: #b7791f;
  --warn-soft: #fdf2df;
  --shadow: 0 1px 2px rgba(16, 33, 56, 0.06), 0 6px 20px rgba(16, 33, 56, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1620;
    --surface: #17212d;
    --surface-2: #1e2a38;
    --text: #e8eef6;
    --muted: #9aabbf;
    --line: #2a3747;
    --primary: #4c96f0;
    --primary-2: #6aa9f4;
    --primary-soft: #1a2c44;
    --gold: #f0b43c;
    --gold-soft: #3a2f18;
    --ok: #3cc187;
    --ok-soft: #173326;
    --err: #ef6b6b;
    --err-soft: #3a1f22;
    --warn: #e8b45a;
    --warn-soft: #3a2e17;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1620;
  --surface: #17212d;
  --surface-2: #1e2a38;
  --text: #e8eef6;
  --muted: #9aabbf;
  --line: #2a3747;
  --primary: #4c96f0;
  --primary-2: #6aa9f4;
  --primary-soft: #1a2c44;
  --gold: #f0b43c;
  --gold-soft: #3a2f18;
  --ok: #3cc187;
  --ok-soft: #173326;
  --err: #ef6b6b;
  --err-soft: #3a1f22;
  --warn: #e8b45a;
  --warn-soft: #3a2e17;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 2.4vw, 1.6rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.section { padding: 32px 0; }
.container.section { padding: 32px 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.hidden { display: none !important; }

/* ---------- шапка ---------- */
.header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-in { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 34px; height: 34px; flex: none; }
.nav { display: flex; gap: 2px; margin-left: 8px; flex: 1; }
.nav a {
  color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 0.93rem; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--primary); font-weight: 600; }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.lang-select {
  min-width: 68px;
  min-height: 40px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 0 8px; font: inherit; font-size: 0.9rem;
}
.header .burger { display: none; }
@media (max-width: 1240px) {
  .nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; margin: 0; box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
  .header .burger { display: inline-flex; }
}
@media (max-width: 560px) {
  .header-in { gap: 8px; }
  .header-tools { gap: 6px; }
  .brand { font-size: 1.05rem; }
  .brand svg { width: 30px; height: 30px; }
  .lang-select { min-width: 0; width: 64px; padding: 0 4px; }
  .header #theme { display: none; }
  .header .user-btn span { display: none; }
  .header .user-btn { width: 44px; padding: 0; }
}
.nav .theme-mobile { display: none; }
@media (max-width: 560px) { .nav .theme-mobile { display: block; } }
html, body { overflow-x: clip; }
.example { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }

/* ---------- батырмалар ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 0.97rem; cursor: pointer; text-decoration: none !important;
  background: var(--primary); color: var(--on-primary); transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--primary-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--err); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 0.88rem; }
.btn.icon { width: 44px; padding: 0; }
.btn svg { width: 18px; height: 18px; }

/* ---------- карточкалар ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: 6px; }
.card-link { display: block; color: inherit; transition: transform 0.15s, box-shadow 0.15s; }
.card-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16, 33, 56, 0.12); }
.icon-tile {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); margin-bottom: 12px;
}
.icon-tile svg { width: 26px; height: 26px; }
.icon-tile.gold { background: var(--gold-soft); color: var(--gold); }
.icon-tile.ok { background: var(--ok-soft); color: var(--ok); }
.icon-tile.err { background: var(--err-soft); color: var(--err); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.gold { background: var(--gold-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.err { background: var(--err-soft); color: var(--err); }

/* ---------- формалар ---------- */
label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.error-text { color: var(--err); font-size: 0.9rem; margin-top: 6px; }

/* ---------- қазақ әріптері пернетақтасы ---------- */
.kk-keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.kk-keys button {
  min-width: 44px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.05rem; cursor: pointer;
}
.kk-keys button:hover { background: var(--primary-soft); color: var(--primary); }

/* ---------- хабарламалар ---------- */
.alert { border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid; margin: 12px 0; }
.alert.info { background: var(--primary-soft); border-color: transparent; color: var(--text); }
.alert.ok { background: var(--ok-soft); border-color: transparent; }
.alert.err { background: var(--err-soft); border-color: transparent; color: var(--text); }
.alert.warn { background: var(--warn-soft); border-color: transparent; }
.ai-note { font-size: 0.82rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.ai-note svg { width: 14px; height: 14px; flex: none; }
.toast-wrap { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 0.95rem; }

/* ---------- жүктелу / бос күй ---------- */
.spinner { width: 22px; height: 22px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 12px; align-items: center; color: var(--muted); padding: 24px 0; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; opacity: 0.5; margin-bottom: 8px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; min-height: 16px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- басты бет ---------- */
.hero { padding: 56px 0 32px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; right: -120px; top: -80px; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, var(--primary-soft), transparent 70%); z-index: -1;
}
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1 span { color: var(--primary); }
.hero .lead { font-size: 1.12rem; color: var(--muted); max-width: 560px; }
.hero-art { aspect-ratio: 1; max-width: 420px; justify-self: center; width: 100%; }
.steps { counter-reset: s; }
.step { position: relative; padding-left: 56px; }
.step::before {
  counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 40px; height: 40px;
  border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700;
}

/* ---------- сабақ карточкалары (tilqural үлгісі) ---------- */
.lesson-card { display: flex; gap: 14px; align-items: center; }
.lesson-art { width: 76px; height: 76px; border-radius: 14px; flex: none; display: grid; place-items: center; color: #fff; }
.lesson-art svg { width: 38px; height: 38px; }
.lesson-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.lesson-meta span { display: inline-flex; align-items: center; gap: 4px; }
.lesson-meta svg { width: 15px; height: 15px; }
.progress-line { height: 4px; background: var(--surface-2); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.progress-line > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; color: var(--muted);
  cursor: pointer; white-space: nowrap; min-height: 44px;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- сөз тізімі ---------- */
.word-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.word-row:last-child { border-bottom: 0; }
.word-kk { font-weight: 700; font-size: 1.05rem; }
.speak-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--primary); cursor: pointer; display: grid; place-items: center; }
.speak-btn svg { width: 18px; height: 18px; }

/* ---------- диагностика / жаттығу ---------- */
.quiz { max-width: 720px; margin: 0 auto; }
.bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); transition: width 0.3s; }
.question-text { font-size: 1.2rem; font-weight: 600; white-space: pre-line; margin: 16px 0; }
.options { display: grid; gap: 10px; }
.option {
  text-align: left; min-height: 52px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; cursor: pointer;
}
.option:hover { border-color: var(--primary); }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--err); background: var(--err-soft); }
.feedback { border-radius: 12px; padding: 14px 16px; margin-top: 14px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.err { background: var(--err-soft); }
.ex-item { border-top: 1px solid var(--line); padding: 18px 0; }
.ex-item:first-child { border-top: 0; }

/* ---------- репетитор чаты ---------- */
.chat-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
@media (max-width: 860px) { .chat-layout { grid-template-columns: 1fr; } .chat-side { display: none; } .chat-side.open { display: block; } }
.chat-box { display: flex; flex-direction: column; height: calc(100vh - 180px); min-height: 520px; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px 4px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 86%; padding: 12px 16px; border-radius: 16px; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .rule { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 0.93rem; }
.msg ul { padding-left: 20px; margin: 6px 0; }
.msg .tr { color: var(--muted); font-size: 0.9rem; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.chat-input textarea { min-height: 52px; max-height: 160px; }
.chat-list button { width: 100%; text-align: left; background: none; border: 0; padding: 10px; border-radius: 8px; color: var(--text); font: inherit; cursor: pointer; }
.chat-list button:hover, .chat-list button.active { background: var(--surface-2); }

/* ---------- мәтін талдау ---------- */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } }
.text-view { white-space: pre-wrap; line-height: 1.8; }
mark.err { background: var(--err-soft); color: var(--err); border-bottom: 2px solid var(--err); padding: 0 2px; border-radius: 3px; }
mark.sugg { background: var(--warn-soft); color: var(--warn); border-bottom: 2px dashed var(--warn); padding: 0 2px; border-radius: 3px; }
mark.fix { background: var(--ok-soft); color: var(--ok); padding: 0 2px; border-radius: 3px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

/* ---------- прогресс ---------- */
.stat { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.88rem; }
.hbar { display: grid; grid-template-columns: 150px 1fr 48px; gap: 10px; align-items: center; margin: 8px 0; font-size: 0.92rem; }
@media (max-width: 520px) { .hbar { grid-template-columns: 110px 1fr 40px; } }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 6px; background: var(--primary); }
.calendar { display: grid; grid-template-columns: repeat(12, 1fr); grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; }
.calendar i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.calendar i.l1 { background: color-mix(in srgb, var(--primary) 30%, var(--surface-2)); }
.calendar i.l2 { background: color-mix(in srgb, var(--primary) 60%, var(--surface-2)); }
.calendar i.l3 { background: var(--primary); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge-card { text-align: center; padding: 14px 8px; border-radius: 12px; border: 1px solid var(--line); font-size: 0.85rem; }
.badge-card svg { width: 34px; height: 34px; color: var(--gold); }
.badge-card.off { opacity: 0.4; filter: grayscale(1); }
.level-chart { display: flex; gap: 10px; align-items: flex-end; height: 160px; padding-top: 10px; }
.level-chart div { flex: 1; background: var(--primary); border-radius: 6px 6px 0 0; position: relative; min-width: 18px; max-width: 60px; }
.level-chart div span { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 0.8rem; font-weight: 700; }

/* ---------- футер ---------- */
.footer { border-top: 1px solid var(--line); padding: 28px 0; margin-top: 40px; color: var(--muted); font-size: 0.9rem; background: var(--surface); }
.footer a { color: var(--muted); }

/* ---------- басып шығару (PDF есеп) ---------- */
@media print {
  .header, .footer, .no-print, .toast-wrap { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
