/* CT·GenAI app — light-first, premium, RTL/LTR aware. Shares tokens with the slide deck. */
:root {
  --bg: #F7F7F4; --bg-2: #EFEEE8; --surface: #FFFFFF; --surface-2: #FBFBF9;
  --ink: #0F1318; --ink-2: #485060; --ink-3: #8790A0;
  --line: rgba(15, 19, 24, .09); --line-2: rgba(15, 19, 24, .16);
  --accent: #4338CA; --accent-2: #0E9F9A; --accent-soft: rgba(67, 56, 202, .08); --accent-2-soft: rgba(14, 159, 154, .10);
  --good: #0B8F63; --good-soft: rgba(11, 143, 99, .10); --bad: #D2405A; --bad-soft: rgba(210, 64, 90, .09); --warn: #A8680E; --warn-soft: rgba(168, 104, 14, .12);
  --shadow-sm: 0 1px 2px rgba(15, 19, 24, .05);
  --shadow: 0 1px 2px rgba(15, 19, 24, .04), 0 18px 40px -18px rgba(15, 19, 24, .16);
  --radius: 22px; --radius-sm: 14px; --ease: cubic-bezier(.22, .8, .24, 1);
  --header-h: 64px;
  --app-w: clamp(min(100%, 1100px), 72%, 1800px); /* app width on wide screens: 72% of the window, capped */
  --app-gutter: max(clamp(14px, 3vw, 32px), calc((100% - var(--app-w)) / 2));
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0B0E14; --bg-2: #10141C; --surface: #131925; --surface-2: #171E2C;
  --ink: #EEF1F6; --ink-2: #A9B2C3; --ink-3: #6E7890;
  --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .16);
  --accent: #8B84FF; --accent-2: #3CD2C8; --accent-soft: rgba(139, 132, 255, .12); --accent-2-soft: rgba(60, 210, 200, .12);
  --good: #3DD6A0; --good-soft: rgba(61, 214, 160, .12); --bad: #FF7A92; --bad-soft: rgba(255, 122, 146, .12); --warn: #F0B35A; --warn-soft: rgba(240, 179, 90, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -18px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font-family: 'Inter', 'Heebo', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; line-height: 1.5; }
html[lang="he"] body { font-family: 'Heebo', 'Inter', system-ui, sans-serif; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; background: radial-gradient(900px 520px at 85% -10%, var(--accent-soft), transparent 70%), radial-gradient(700px 480px at -5% 105%, var(--accent-2-soft), transparent 70%); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
em.grad, .grad { font-style: normal; background: linear-gradient(100deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
[dir="rtl"] .flip { transform: scaleX(-1); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── header ─────────────────────────────────────────── */
.header { position: sticky; top: 0; z-index: 50; height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 var(--app-gutter); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .mark { width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; letter-spacing: -.03em; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; line-height: 1.15; }
.brand small { display: block; font-size: 12px; color: var(--ink-3); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg-2); }
.nav a { padding: 8px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2); transition: all .2s var(--ease); white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.tools { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); transition: all .2s var(--ease); font-size: 12px; font-weight: 700; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); transform: translateY(-1px); }
.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--bg-2); }
.seg a { padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--ink-3); }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); padding: 0 6px; }
.user-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
@media (max-width: 860px) { .brand small, .user-chip { display: none; } .nav a { padding: 8px 12px; } }
@media (max-width: 560px) { .brand b { display: none; } }

main { position: relative; z-index: 1; flex: 1; }
.container { max-width: var(--app-w); margin: 0 auto; padding: clamp(24px, 4vw, 56px) clamp(16px, 4vw, 40px); }

/* ── primitives ─────────────────────────────────────── */
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
[dir="rtl"] .kicker { letter-spacing: .04em; }
h1, h2, h3 { letter-spacing: -.02em; margin: 0; }
.page-title { font-size: clamp(32px, 5vw, 56px); font-weight: 750; line-height: 1.06; letter-spacing: -.03em; }
[dir="rtl"] .page-title { line-height: 1.15; letter-spacing: -.01em; }
.lead { font-size: clamp(16px, 1.6vw, 19px); color: var(--ink-2); max-width: 680px; margin: 16px 0 0; line-height: 1.6; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
[dir="rtl"] .tag { letter-spacing: .02em; }
.tag.teal { background: var(--accent-2-soft); color: var(--accent-2); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ghost { background: var(--bg-2); color: var(--ink-3); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 650; font-size: 14px; background: var(--ink); color: var(--bg); transition: transform .2s var(--ease), opacity .2s, box-shadow .2s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn.accent { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent-2))); color: #fff; box-shadow: 0 8px 20px -8px var(--accent); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-2); }
.btn.good { background: var(--good); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.progress-bar { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.progress-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s var(--ease); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); margin-bottom: 22px; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .5; }
.crumbs b { color: var(--ink-2); font-weight: 600; }

/* ── home ───────────────────────────────────────────── */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: end; margin-bottom: clamp(32px, 5vw, 56px); }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; gap: 24px; } }
.stat { min-width: 240px; padding: 22px 24px; }
.stat .big { font-size: 44px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.stat .sub { font-size: 13px; color: var(--ink-3); margin: 6px 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.chapter-card { position: relative; padding: 26px; display: flex; flex-direction: column; gap: 10px; min-height: 250px; transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s; }
.chapter-card:hover:not(.soon) { transform: translateY(-3px); border-color: var(--line-2); }
.chapter-card .num { font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.chapter-card h3 { font-size: 20px; line-height: 1.25; }
.chapter-card p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; flex: 1; }
.chapter-card .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.chapter-card .top { display: flex; justify-content: space-between; align-items: center; }
.chapter-card.soon { opacity: .62; box-shadow: none; background: transparent; border-style: dashed; }
.chapter-card .stretch { position: absolute; inset: 0; border-radius: inherit; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 0 0 18px; }
.section-head h2 { font-size: 20px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.filters button { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.filters button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ex-card .glyph { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.ex-card.quiz .glyph { background: var(--accent-2-soft); color: var(--accent-2); }

/* ── learning shell ─────────────────────────────────── */
.shell { width: var(--app-w); margin: 0 auto; display: grid; grid-template-columns: var(--side-w, 320px) 1fr; min-height: calc(100vh - var(--header-h)); }
.sidebar { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; border-inline-end: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent); padding: 22px 14px 40px; position: sticky; z-index: 5; }
.sidebar h2 { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 8px 10px; }
[dir="rtl"] .sidebar h2 { letter-spacing: .02em; }
.side-progress { margin: 0 8px 20px; }
.side-progress .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-3); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.side-ch { margin-bottom: 4px; border-radius: 14px; }
.side-ch summary { list-style: none; display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; cursor: pointer; }
.side-ch summary::-webkit-details-marker { display: none; }
.side-ch summary:hover { background: var(--bg-2); }
.side-ch .n { width: 30px; height: 30px; border-radius: 10px; background: var(--bg-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.side-ch[open] > summary .n, .side-ch.cur > summary .n { background: var(--accent-soft); color: var(--accent); }
.side-ch .t { font-size: 14px; font-weight: 600; line-height: 1.3; }
.side-ch .c { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.side-ch.soon { opacity: .55; }
.row-soon { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 10px; }
.row-soon .n { width: 30px; height: 30px; border-radius: 10px; background: var(--bg-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.row-soon .t { font-size: 14px; font-weight: 600; line-height: 1.3; }
.row-soon .c { font-size: 12px; color: var(--ink-3); }
.side-list { margin: 2px 0 8px; padding-inline-start: 30px; border-inline-start: 1px solid var(--line); margin-inline-start: 24px; display: grid; gap: 2px; }
.side-link { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
.side-link:hover { background: var(--bg-2); color: var(--ink); }
.side-link.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-link small { font-size: 12px; color: var(--ink-3); }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; }
.dot.prog { border-color: var(--warn); }
.dot.prog::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.dot.done { border-color: var(--good); background: var(--good); }
.dot.done::after { content: ''; width: 5px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.quiz-link { border: 1px dashed var(--line-2); margin-top: 6px; }
.side-toggle { display: none; }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; width: 100%; }
  .sidebar { position: fixed; inset-block: var(--header-h) 0; inset-inline-start: 0; width: min(340px, 90vw); transform: translateX(-105%); transition: transform .3s var(--ease); background: var(--surface); box-shadow: var(--shadow); height: auto; }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .sidebar.open { transform: none; }
  .side-toggle { display: inline-flex; margin-bottom: 18px; }
}

.lesson { width: 100%; min-width: 0; margin: 0 auto; padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 40px) 80px; }
.lesson h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.08; font-weight: 750; letter-spacing: -.03em; }
[dir="rtl"] .lesson h1 { line-height: 1.2; letter-spacing: -.01em; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 30px; }
.deck-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface); }
.deck-frame .ratio { width: 100%; aspect-ratio: 16 / 10; min-height: 480px; max-height: calc(100vh - 150px); }
@media (max-width: 640px) { .deck-frame .ratio { aspect-ratio: 3 / 4; min-height: 0; max-height: none; } }
.deck-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.video-frame { margin-bottom: 8px; }
.video-frame .ratio { aspect-ratio: 16 / 9; min-height: 0; }
@media (max-width: 640px) { .video-frame .ratio { aspect-ratio: 16 / 9; } }
.video-frame video { width: 100%; height: 100%; display: block; background: #000; }
.video-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; color: var(--ink-3); background: repeating-linear-gradient(135deg, transparent 0 14px, rgba(127,127,127,.06) 14px 28px); }
.video-placeholder svg { width: 56px; height: 56px; fill: none; stroke: currentColor; stroke-width: 1.5; opacity: .6; }
.video-placeholder b { font-size: 1.05rem; color: var(--ink-2); }
.deck-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.deck-bar a { color: var(--accent); font-weight: 600; }
.block-title { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 36px 0 14px; }
[dir="rtl"] .block-title { letter-spacing: .02em; }
.lesson-nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
.lesson-nav .side { max-width: 250px; font-size: 13px; color: var(--ink-3); }
.lesson-nav .side b { display: block; color: var(--ink); font-size: 14px; font-weight: 600; margin-top: 2px; }
.lesson-nav .side:hover b { color: var(--accent); }
.lesson-nav .next { text-align: end; }

/* prose */
.prose { font-size: 16.5px; line-height: 1.7; color: var(--ink-2); }
.prose h2 { font-size: 24px; color: var(--ink); margin: 34px 0 12px; }
.prose h3 { font-size: 18px; color: var(--ink); margin: 28px 0 10px; }
.prose h4 { font-size: 16px; color: var(--ink); margin: 20px 0 8px; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 14px; }
.prose strong { color: var(--ink); font-weight: 650; }
.prose ul, .prose ol { margin: 0 0 16px; padding-inline-start: 22px; }
.prose li { margin-bottom: 8px; padding-inline-start: 4px; }
.prose li::marker { color: var(--accent); font-weight: 700; }
.prose code { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--bg-2); padding: .15em .45em; border-radius: 6px; color: var(--ink); }
.prose pre { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; overflow-x: auto; direction: ltr; text-align: left; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: 16px 0; padding: 14px 18px; border-inline-start: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink); }
[dir="rtl"] .prose blockquote { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.prose th { text-align: start; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); }
[dir="rtl"] .prose th { letter-spacing: .02em; }
.prose th, .prose td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }

/* ── quiz ───────────────────────────────────────────── */
.quiz-wrap { max-width: 780px; margin: 0 auto; padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 40px) 80px; }
.q-card { padding: 28px; margin-bottom: 18px; transition: opacity .3s, transform .3s var(--ease); }
.q-card.locked { opacity: .4; pointer-events: none; transform: scale(.992); }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.q-text { font-size: 19px; font-weight: 650; line-height: 1.4; margin: 0 0 20px; letter-spacing: -.01em; }
.opts { display: grid; gap: 10px; }
.opt { display: grid; grid-template-columns: 28px 1fr; gap: 14px; align-items: start; text-align: start; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 15.5px; line-height: 1.45; transition: all .2s var(--ease); }
.opt:hover { border-color: var(--accent); }
.opt .l { width: 26px; height: 26px; border-radius: 8px; background: var(--bg-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .l { background: var(--accent); color: #fff; }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .l { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .l { background: var(--bad); color: #fff; }
.opt.done { cursor: default; }
.why { margin-top: 16px; padding: 14px 18px; border-radius: var(--radius-sm); font-size: 14.5px; line-height: 1.55; }
.why.ok { background: var(--good-soft); color: var(--ink); }
.why.no { background: var(--bad-soft); color: var(--ink); }
.why b { display: block; margin-bottom: 2px; }
.why.ok b { color: var(--good); } .why.no b { color: var(--bad); }
.q-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.result { text-align: center; padding: 48px 28px; }
.result .score { font-size: 72px; font-weight: 750; letter-spacing: -.04em; line-height: 1; margin: 16px 0 8px; }
.result .score.pass { color: var(--good); } .result .score.fail { color: var(--warn); }
.result h2 { font-size: 26px; }
.result p { color: var(--ink-2); margin: 8px 0; }
.result .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }

/* ── dialog / modal ─────────────────────────────────── */
dialog { border: 0; padding: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); width: min(480px, 92vw); }
dialog::backdrop { background: rgba(15, 19, 24, .45); backdrop-filter: blur(4px); }
.dlg { padding: 28px; }
.dlg h3 { font-size: 20px; margin-bottom: 4px; }
.dlg .muted { color: var(--ink-3); font-size: 14px; margin: 0 0 20px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); outline: none; direction: ltr; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dlg .row { display: flex; gap: 10px; margin-top: 8px; }
.dlg .row .btn { flex: 1; }
.provider { padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); margin-bottom: 14px; }
.provider h4 { margin: 0 0 12px; font-size: 14px; }
.toast { position: fixed; inset-block-end: 24px; inset-inline-start: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .3s var(--ease); z-index: 200; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── chat (live AI lab) ─────────────────────────────── */
.lab { width: var(--app-w); margin: 0 auto; display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - var(--header-h)); }
@media (max-width: 900px) { .lab { grid-template-columns: 1fr; } .lab-side { display: none; } .lab-side.open { display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 40; } }
.lab-side { overflow-y: auto; padding: 24px 22px; border-inline-end: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 75%, transparent); }
.lab-side h3 { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 14px; }
[dir="rtl"] .lab-side h3 { letter-spacing: .02em; }
.lab-side textarea { min-height: 150px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.55; resize: vertical; }
.lab-side .hint { font-size: 12.5px; color: var(--ink-3); margin: 6px 0 0; }
.lab-main { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.lab-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.lab-head h1 { font-size: 18px; letter-spacing: -.01em; }
.lab-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); max-width: 60ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgs { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: min(760px, 88%); padding: 14px 18px; border-radius: 18px; font-size: 15px; line-height: 1.6; }
.msg.user .bubble { background: var(--ink); color: var(--bg); border-end-end-radius: 6px; white-space: pre-wrap; }
.msg.ai .bubble { background: var(--surface); border: 1px solid var(--line); border-end-start-radius: 6px; box-shadow: var(--shadow-sm); overflow-x: auto; }
.msg.ai .bubble p { margin: 0 0 10px; } .msg.ai .bubble p:last-child { margin: 0; }
.msg.ai .bubble table { border-collapse: collapse; font-size: 13.5px; } .msg.ai .bubble th, .msg.ai .bubble td { border: 1px solid var(--line); padding: 6px 10px; }
.welcome { max-width: 680px; margin: 24px auto; padding: 32px; }
.welcome h2 { font-size: 22px; margin-bottom: 14px; }
.composer { padding: 14px 24px 18px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); }
.composer form { max-width: 880px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px; padding: 8px 8px 8px 16px; border: 1px solid var(--line-2); border-radius: 18px; background: var(--surface); }
[dir="rtl"] .composer form { padding: 8px 16px 8px 8px; }
.composer textarea { flex: 1; border: 0; outline: none; resize: none; background: transparent; padding: 8px 0; max-height: 160px; line-height: 1.5; }
.composer .foot { max-width: 880px; margin: 8px auto 0; text-align: center; font-size: 12px; color: var(--ink-3); }
.status-line { height: 20px; font-size: 12.5px; color: var(--ink-3); max-width: 880px; margin: 0 auto 6px; }
.cursor { display: inline-block; width: 7px; height: 16px; background: var(--accent); vertical-align: middle; animation: blink 1s infinite; margin-inline-start: 2px; }
@keyframes blink { 50% { opacity: 0; } }

footer.footer { position: relative; z-index: 1; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }
footer.footer .container { padding-block: 22px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.page-title em, .page-title .grad { white-space: nowrap; }

@media (max-width: 640px) {
  :root { --header-h: 112px; }
  .header { flex-wrap: wrap; height: auto; padding-block: 10px; row-gap: 8px; }
  .brand { order: 1; } .tools { order: 2; margin-inline-start: auto; gap: 6px; } .nav { order: 3; width: 100%; }
  .nav a { flex: 1; text-align: center; }
  .icon-btn { width: 34px; height: 34px; }
  .lab-head p { display: none; }
}

@media (max-width: 960px) { .lesson { width: 100%; } }

/* XP, level and streak */
.xp-chip { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.xp-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.xp-title { font-size: 13px; color: var(--ink-2); }
.xp-line { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.xp-streak.on { color: var(--warn); font-weight: 650; }
.xp-hint { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }

/* ── welcome dialog (first visit) ───────────────────── */
.welcome { width: min(460px, 92vw); }
.welcome .dlg { padding: 32px 28px 28px; }
.welcome .mark { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -.03em; margin-bottom: 16px; }
.welcome h3 { font-size: 24px; letter-spacing: -.02em; }
.welcome .muted { margin-bottom: 22px; line-height: 1.55; }
.choices { border: 0; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices legend { grid-column: 1 / -1; padding: 0; margin-bottom: 8px; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line-2); background: var(--surface-2); font-weight: 650; font-size: 16px; transition: border-color .2s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease); }
.choice:hover span { border-color: var(--ink-3); }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice .sw { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); flex: none; }
.choice .sw.light { background: linear-gradient(135deg, #FFFFFF 50%, #EFEEE8 50%); }
.choice .sw.dark { background: linear-gradient(135deg, #131925 50%, #0B0E14 50%); }
.welcome .row { margin-top: 24px; }
.welcome .row .btn { padding: 13px 18px; font-size: 15px; }
