/* ===== Темы ================================================================ */
:root {
  --font: Manrope, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --radius: 20px;
  --top: max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px));
  --bottom: max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px));
  --ease: cubic-bezier(.2, .9, .3, 1.2);
}
:root, [data-theme="light"] {
  --bg: #F4F5FA;
  --bg-2: #ECEEF6;
  --card: #FFFFFF;
  --card-2: #F7F8FC;
  --line: #E3E6EF;
  --text: #15171F;
  --muted: #6A7183;
  --primary: #5A4BFF;
  --primary-2: #7B6DFF;
  --primary-soft: #EEECFF;
  --on-primary: #FFFFFF;
  --green: #16A34A;
  --green-soft: #E7F8EE;
  --orange: #EA7A16;
  --orange-soft: #FFF2E5;
  --red: #E5484D;
  --red-soft: #FFECEE;
  --portal: #4ADE80;
  --you: #5A4BFF;
  --on-you: #FFFFFF;
  --shadow: 0 6px 24px rgba(30, 35, 60, .08);
  --code-bg: #F2F3F8;
  --code-text: #2B2F3D;
  --mock-bg: #FFFFFF;
  --mock-bar: #F1F2F6;
}
[data-theme="dark"] {
  --bg: #0F1116;
  --bg-2: #151821;
  --card: #181B23;
  --card-2: #1E222C;
  --line: #2A2F3B;
  --text: #F1F3F8;
  --muted: #98A0B3;
  --primary: #8577FF;
  --primary-2: #A196FF;
  --primary-soft: #232043;
  --on-primary: #0F1116;
  --green: #4ADE80;
  --green-soft: #12291C;
  --orange: #FF9F4A;
  --orange-soft: #2E1E10;
  --red: #FF6B70;
  --red-soft: #321519;
  --portal: #4ADE80;
  --you: #6E60FF;
  --on-you: #FFFFFF;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --code-bg: #12141A;
  --code-text: #E6E9F2;
  --mock-bg: #1C1F27;
  --mock-bar: #242833;
}

/* ===== База ================================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden; transition: background .3s, color .3s; }
main { max-width: 640px; margin: 0 auto; padding: calc(var(--top) + 8px) 16px calc(var(--bottom) + 150px); }
img { display: block; max-width: 100%; }
a { color: var(--primary); font-weight: 700; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.muted { color: var(--muted); }
b, strong { font-weight: 800; }
code { font-family: var(--mono); font-size: .9em; background: var(--primary-soft); color: var(--primary); padding: 1px 6px; border-radius: 7px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.screen-center { min-height: 75vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 20px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Кнопки ============================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 0 22px; border-radius: 16px; font-weight: 800; font-size: 16.5px; transition: transform .15s var(--ease), opacity .2s, background .2s; user-select: none; }
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-ghost { background: var(--card); border: 1.5px solid var(--line); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; box-shadow: none; }

/* ===== Верхняя панель ===================================================== */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(var(--top) + 8px) 0 10px; margin: calc(-1 * (var(--top) + 8px)) 0 6px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.topbar .grow { flex: 1; min-width: 0; }
.brand { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--portal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--portal) 25%, transparent); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; transition: transform .15s var(--ease); }
.icon-btn:active { transform: scale(.9); }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 10px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--muted); transition: all .2s; }
.seg button.on { background: var(--primary); color: #fff; }
.lesson-bar { flex: 1; min-width: 0; }
.lesson-bar .t { font-weight: 800; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbar { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; margin-top: 6px; }
.pbar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--portal)); transition: width .45s var(--ease); }

/* ===== Главная ============================================================= */
.hero { position: relative; display: flex; align-items: flex-end; gap: 4px; padding: 18px 16px 0; border-radius: 26px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.hero::before { content: ""; position: absolute; width: 220px; height: 220px; left: -40px; bottom: -70px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--portal) 45%, transparent) 0%, transparent 65%); animation: portal 6s ease-in-out infinite; }
.hero::after { content: ""; position: absolute; width: 170px; height: 170px; left: -15px; bottom: -45px; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--portal) 55%, transparent); animation: spin 18s linear infinite; }
@keyframes portal { 50% { transform: scale(1.12); opacity: .75; } }
.hero-img { position: relative; z-index: 1; height: 196px; width: auto; margin-bottom: -6px; flex: none; animation: bob 3.2s ease-in-out infinite; transform-origin: bottom center; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-1.5deg); } }
.hero-say { position: relative; z-index: 1; flex: 1; align-self: center; margin-bottom: 18px; background: var(--card-2); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px; padding: 12px 14px; font-weight: 600; font-size: 15px; }
.hero-say b { color: var(--primary); }

.stats { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.stat .pbar { margin-top: 8px; }

.continue { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; border-radius: 22px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 10px 26px color-mix(in srgb, var(--primary) 35%, transparent); margin-bottom: 22px; transition: transform .15s var(--ease); position: relative; overflow: hidden; }
.continue:active { transform: scale(.98); }
.continue::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.25) 50%, transparent 70%); transform: translateX(-100%); animation: shine 3s ease-in-out infinite 1s; }
@keyframes shine { 60%, 100% { transform: translateX(100%); } }
.continue .em { width: 52px; height: 52px; border-radius: 16px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 28px; flex: none; }
.continue .l { font-size: 12.5px; font-weight: 800; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.continue .t { font-size: 18px; font-weight: 800; line-height: 1.2; }
.continue .go { margin-left: auto; font-size: 24px; font-weight: 800; }

.sec-title { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 10px; }

.path { position: relative; display: flex; flex-direction: column; gap: 10px; }
.path::before { content: ""; position: absolute; left: 35px; top: 30px; bottom: 30px; width: 3px; border-radius: 3px; background: repeating-linear-gradient(var(--line) 0 8px, transparent 8px 14px); }
.node { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 10px 12px 10px 10px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); transition: transform .15s var(--ease); animation: rise .4s var(--ease) both; }
.node:active { transform: scale(.98); }
.node .em { position: relative; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: var(--card-2); border: 2px solid var(--line); flex: none; }
.node.done .em { background: var(--green-soft); border-color: var(--green); }
.node.current { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.node.current .em { border-color: var(--primary); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px var(--primary-soft); } }
.node .body { flex: 1; min-width: 0; }
.node .n { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.node .t { font-weight: 800; font-size: 16px; line-height: 1.25; }
.node .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.node .st { flex: none; font-size: 13px; font-weight: 800; color: var(--muted); }
.node.done .st { color: var(--green); }
.node .badge-done { position: absolute; right: -6px; bottom: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; font-size: 13px; font-weight: 900; display: grid; place-items: center; border: 2px solid var(--card); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.achs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ach { text-align: center; padding: 10px 4px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font-size: 11.5px; font-weight: 700; line-height: 1.2; color: var(--muted); }
.ach .i { font-size: 26px; margin-bottom: 4px; filter: grayscale(1); opacity: .35; }
.ach.on { color: var(--text); border-color: color-mix(in srgb, var(--orange) 50%, var(--line)); background: var(--orange-soft); }
.ach.on .i { filter: none; opacity: 1; }

/* ===== Онбординг (выбор системы) ========================================== */
.onb { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: center; }
.onb img { height: 230px; width: auto; margin: 0 auto; animation: bob 3s ease-in-out infinite; }
.onb h1 { font-size: 26px; line-height: 1.15; margin: 4px 0 0; }
.onb .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.onb .choice { padding: 18px 10px; border-radius: 20px; background: var(--card); border: 2px solid var(--line); font-weight: 800; font-size: 17px; transition: transform .15s var(--ease), border-color .2s; }
.onb .choice .i { font-size: 34px; display: block; margin-bottom: 6px; }
.onb .choice:active { transform: scale(.95); border-color: var(--primary); }

/* ===== Лента урока ========================================================= */
.feed { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.msg { display: flex; align-items: flex-end; gap: 8px; animation: pop .35s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
.msg .ava { width: 38px; height: 38px; border-radius: 12px; flex: none; overflow: hidden; background: #464D5B; }
.msg .ava img { width: 100%; height: 100%; object-fit: cover; }
.msg .ava.hide { visibility: hidden; }
.bubble { max-width: 84%; padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--card); border: 1px solid var(--line); font-size: 16px; font-weight: 500; box-shadow: 0 2px 8px rgba(0,0,0,.03); }
.msg.you { justify-content: flex-end; }
.msg.you .bubble { background: var(--you); color: var(--on-you); border: 0; border-radius: 18px 18px 6px 18px; }
.msg.you .bubble .term { color: inherit; border-color: rgba(255,255,255,.6); }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { transform: translateY(-5px); opacity: 1; } 0%, 60%, 100% { opacity: .4; } }
.term { color: var(--primary); font-weight: 700; border-bottom: 2px dashed color-mix(in srgb, var(--primary) 55%, transparent); cursor: pointer; }

.block { animation: pop .4s var(--ease) both; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); padding: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.03); }
.block-title { font-weight: 800; font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

.note { display: flex; gap: 10px; align-items: flex-start; border-radius: 18px; padding: 12px 14px; font-weight: 600; font-size: 15px; animation: pop .4s var(--ease) both; }
.note .i { font-size: 20px; line-height: 1.3; }
.note.tip { background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); }
.note.warn { background: var(--orange-soft); border: 1px solid color-mix(in srgb, var(--orange) 35%, transparent); }

.flow { display: flex; flex-direction: column; gap: 0; }
.flow .st { display: flex; align-items: center; gap: 12px; padding: 8px 0; opacity: 0; animation: slideIn .45s var(--ease) forwards; }
.flow .st .i { width: 42px; height: 42px; flex: none; border-radius: 14px; background: var(--primary-soft); display: grid; place-items: center; font-size: 21px; }
.flow .st .x { font-weight: 700; font-size: 15px; }
.flow .arrow { margin-left: 20px; width: 2px; height: 12px; background: var(--line); opacity: 0; animation: slideIn .3s forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

.cards { display: grid; gap: 10px; }
.cardx { display: flex; gap: 12px; padding: 12px 14px; border-radius: 18px; background: var(--card); border: 1.5px solid var(--line); opacity: 0; animation: pop .45s var(--ease) forwards; }
.cardx.hl { border-color: var(--primary); background: var(--primary-soft); }
.cardx .i { font-size: 26px; line-height: 1.2; }
.cardx .t { font-weight: 800; }
.cardx .x { font-size: 14.5px; color: var(--muted); font-weight: 500; }

.osbox { border-radius: 18px; background: var(--card); border: 1px solid var(--line); padding: 12px 14px; animation: pop .4s var(--ease) both; }
.osbox .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.osbox .txt { font-weight: 600; }

.copy { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--code-bg); animation: pop .4s var(--ease) both; }
.copy .head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); background: var(--card); }
.copy .lbl { font-size: 12.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--primary); }
.copy .cbtn { font-weight: 800; font-size: 14px; padding: 8px 14px; border-radius: 11px; background: var(--primary); color: #fff; transition: transform .15s var(--ease); }
.copy .cbtn:active { transform: scale(.93); }
.copy .cbtn.ok { background: var(--green); }
.copy pre { margin: 0; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 15px; font-weight: 600; color: var(--code-text); }
.copy.cmd pre { font-family: var(--mono); font-size: 13.5px; white-space: pre; overflow-x: auto; word-break: normal; }

.quiz .q { font-weight: 800; font-size: 16.5px; margin-bottom: 10px; }
.quiz .opts { display: flex; flex-direction: column; gap: 8px; }
.quiz .opt { text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--card-2); border: 2px solid var(--line); font-weight: 700; font-size: 15px; transition: transform .15s var(--ease), border-color .2s, background .2s; }
.quiz .opt:active { transform: scale(.98); }
.quiz .opt.right { border-color: var(--green); background: var(--green-soft); }
.quiz .opt.wrong { border-color: var(--red); background: var(--red-soft); animation: shake .4s; }
.quiz.solved .opt:not(.right) { opacity: .5; }
.quiz .why { margin-top: 10px; display: flex; gap: 10px; align-items: flex-start; font-weight: 600; font-size: 15px; animation: pop .35s var(--ease) both; }
.quiz .why img { width: 34px; height: 34px; border-radius: 10px; flex: none; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.check { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check label { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 14px; background: var(--card-2); border: 1.5px solid var(--line); font-weight: 700; font-size: 15px; cursor: pointer; transition: all .2s; }
.check input { appearance: none; -webkit-appearance: none; width: 26px; height: 26px; flex: none; margin: 0; border-radius: 9px; border: 2px solid var(--line); display: grid; place-items: center; transition: all .2s var(--ease); background: var(--card); }
.check input:checked { background: var(--green); border-color: var(--green); transform: scale(1.08); }
.check input:checked::after { content: "✓"; color: #fff; font-weight: 900; font-size: 15px; }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }

/* ===== Тренажёр ============================================================ */
.sim .task { display: flex; gap: 8px; align-items: center; font-weight: 800; font-size: 15.5px; margin-bottom: 10px; }
.sim .task .i { width: 30px; height: 30px; flex: none; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 16px; }
.sim .lead { margin: -4px 0 10px 38px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.sim .stage { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); user-select: none; }
.sim .result { margin-top: 10px; font-weight: 700; display: flex; gap: 8px; align-items: center; animation: pop .35s var(--ease) both; }
.sim .result.ok { color: var(--green); }
.sim .result.hint { color: var(--orange); }
.sim.done .stage { pointer-events: none; }
.hit-hint { animation: hintRing 1.2s ease-in-out infinite !important; position: relative; z-index: 2; }
@keyframes hintRing { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--orange) 70%, transparent); } 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--orange) 0%, transparent), 0 0 0 3px var(--orange); } }
.hit-ok { animation: okPop .5s var(--ease) both; box-shadow: 0 0 0 3px var(--green) !important; }
@keyframes okPop { 40% { transform: scale(1.1); } }
.miss-flash { animation: shake .35s; }
.tap-dot { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 35%, transparent); pointer-events: none; animation: tap .5s ease-out forwards; z-index: 5; }
@keyframes tap { to { transform: scale(2.4); opacity: 0; } }

/* Макеты интерфейсов (всегда «как в жизни», светлые/тёмные по теме) */
.mk { background: var(--mock-bg); color: var(--text); font-size: 13px; }
.mk-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--mock-bar); border-bottom: 1px solid var(--line); }
.mk-dots { display: flex; gap: 5px; } .mk-dots i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.mk-dots i:nth-child(1) { background: #FF5F57; } .mk-dots i:nth-child(2) { background: #FEBC2E; } .mk-dots i:nth-child(3) { background: #28C840; }
.mk-win { margin-left: auto; display: flex; gap: 12px; color: var(--muted); font-size: 12px; }
.mk-url { flex: 1; background: var(--mock-bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; color: var(--muted); font-size: 12px; text-align: center; }
.mk-body { padding: 14px; min-height: 170px; }
.mk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); font-weight: 700; font-size: 13px; transition: transform .12s; }
.mk-btn.dark { background: #1F1F1F; color: #fff; border-color: #1F1F1F; }
[data-theme="dark"] .mk-btn.dark { background: #F1F3F8; color: #111; }
.mk-btn:active { transform: scale(.95); }
.mk-h { font-size: 19px; font-weight: 800; margin: 6px 0 4px; text-align: center; }
.mk-sub { color: var(--muted); text-align: center; margin-bottom: 14px; font-size: 12.5px; }
.mk-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mk-tabs { display: inline-flex; background: var(--mock-bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.mk-tab { padding: 4px 9px; border-radius: 7px; font-weight: 800; font-size: 13px; color: var(--muted); }
.mk-tab.on { background: var(--card-2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.mk-side { width: 92px; border-right: 1px solid var(--line); padding: 10px 8px; display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.mk-main { flex: 1; padding: 14px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; }
.mk-input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--card); }
.mk-input .ph { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.mk-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.mk-chip { padding: 5px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--card-2); font-weight: 700; font-size: 12px; }
.mk-menu { position: absolute; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 5px; min-width: 150px; z-index: 3; animation: pop .25s var(--ease) both; }
.mk-item { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 7px; font-weight: 600; font-size: 13px; }
.mk-item.sep { border-top: 1px solid var(--line); border-radius: 0; margin-top: 3px; padding-top: 8px; }
.mk-desk { position: relative; height: 210px; background: linear-gradient(135deg, #7DD3FC, #A78BFA 60%, #F0ABFC); }
[data-theme="dark"] .mk-desk { background: linear-gradient(135deg, #1E3A8A, #4C1D95 60%, #701A75); }
.mk-icon { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 3px; color: #fff; font-weight: 700; font-size: 11px; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.mk-icon .f { font-size: 34px; line-height: 1; }
.mk-task { position: absolute; left: 0; right: 0; bottom: 0; height: 34px; background: rgba(20,22,30,.75); display: flex; align-items: center; justify-content: center; gap: 10px; }
.mk-start { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; font-size: 16px; color: #60A5FA; }
.mk-perm { border: 1.5px solid var(--primary); border-radius: 12px; padding: 10px; background: var(--primary-soft); }
.mk-perm .t { font-weight: 800; margin-bottom: 8px; }
.mk-kbd { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.mk-key { min-width: 38px; height: 34px; padding: 0 8px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); border-bottom-width: 3px; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.mk-key.wide { min-width: 120px; }
.mk-repo { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; font-weight: 700; }
.mk-claude-msg { align-self: stretch; background: var(--card-2); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; }
.mk-working { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--orange); }
.mk-stop { width: 30px; height: 30px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; font-size: 11px; }
.mk-spot { margin: 30px auto 0; width: 86%; background: rgba(255,255,255,.92); border-radius: 12px; padding: 10px 12px; color: #222; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.mk-spot .res { margin-top: 8px; padding: 8px; border-radius: 8px; background: #2F6FED; color: #fff; font-weight: 700; display: flex; gap: 8px; align-items: center; }

/* ===== Конструктор промпта ================================================ */
.builder .preview { border-radius: 14px; background: var(--code-bg); border: 1px solid var(--line); padding: 12px 14px; font-weight: 600; min-height: 54px; transition: all .3s; }
.builder .preview .add { color: var(--primary); animation: pop .35s var(--ease) both; display: inline; }
.builder .meter { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.builder .meter .pbar { flex: 1; height: 12px; margin: 0; }
.builder .meter img { width: 40px; height: 40px; border-radius: 12px; transition: transform .3s var(--ease); }
.builder .chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.builder .chip { padding: 11px 10px; border-radius: 14px; border: 2px dashed var(--line); font-weight: 800; font-size: 14px; background: var(--card-2); transition: all .2s var(--ease); }
.builder .chip.on { border-style: solid; border-color: var(--primary); background: var(--primary-soft); color: var(--primary); transform: scale(.97); }

/* ===== Словарь ============================================================= */
.gl-search { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card-2); color: var(--text); font: inherit; font-weight: 600; margin-bottom: 10px; }
.gl-item { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.gl-item:last-child { border-bottom: 0; }
.gl-item b { color: var(--primary); }

/* ===== Низ урока =========================================================== */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 16px calc(var(--bottom) + 12px); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.dock .inner { max-width: 640px; margin: 0 auto; }
.dock .hint { text-align: center; font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 6px; min-height: 18px; }

.finish { text-align: center; padding: 20px 16px; animation: pop .5s var(--ease) both; background: linear-gradient(160deg, var(--primary-soft), var(--green-soft)); border-color: transparent; }
.finish img.finish-pose { height: 170px; width: auto; margin: 0 auto 6px; animation: jump 1.4s ease-in-out infinite; }
@keyframes jump { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-14px); } }
.finish .replay-btn { margin-top: 14px; min-height: 44px; font-size: 15px; }
.lesson-card { position: relative; display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px 0; margin-bottom: 12px; border-radius: 24px; background: linear-gradient(140deg, var(--primary-soft), var(--green-soft)); overflow: hidden; animation: pop .4s var(--ease) both; }
.lesson-card img { height: 150px; width: auto; flex: none; margin-bottom: -4px; animation: bob 3.2s ease-in-out infinite; transform-origin: bottom center; }
.lesson-card > div { padding-bottom: 14px; align-self: center; }
.lesson-card .n { font-size: 12px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; }
.lesson-card h1 { font-size: 22px; line-height: 1.15; margin: 4px 0; }
.lesson-card p { margin: 0; color: var(--muted); font-weight: 600; font-size: 14.5px; }
.node.locked { opacity: .75; }
.node .badge-lock { position: absolute; right: -6px; bottom: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); font-size: 11px; display: grid; place-items: center; }
.buy-banner { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; margin-bottom: 12px; border-radius: 20px; background: var(--orange-soft); border: 1.5px solid color-mix(in srgb, var(--orange) 45%, transparent); }
.buy-banner .em { font-size: 26px; } .buy-banner .go { margin-left: auto; font-weight: 800; font-size: 20px; }
.pay-card { display: flex; align-items: flex-end; gap: 10px; padding: 14px 14px 0; margin-bottom: 12px; border-radius: 24px; background: linear-gradient(140deg, var(--primary-soft), var(--orange-soft)); overflow: hidden; animation: pop .4s var(--ease) both; }
.pay-card img { height: 170px; width: auto; margin-bottom: -4px; animation: bob 3s ease-in-out infinite; }
.pay-card > div { padding-bottom: 16px; align-self: center; }
.pay-card h1 { font-size: 22px; line-height: 1.15; margin: 0 0 6px; }
.pay-card p { margin: 0; color: var(--muted); font-weight: 600; font-size: 14.5px; }
.pay-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-weight: 700; }
.pay-list li { display: flex; gap: 10px; align-items: center; }
.price { text-align: center; margin: 16px 0 10px; font-size: 15px; } .price b { font-size: 30px; }
.pay-btns { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.btn-link { color: var(--primary); font-weight: 800; padding: 10px; }
.gate-pose { height: 200px; width: auto; animation: bob 3s ease-in-out infinite; }
.finish h2 { margin: 0 0 4px; font-size: 22px; }
.finish .xp { display: inline-block; margin: 8px 0 4px; padding: 6px 14px; border-radius: 99px; background: var(--primary); color: #fff; font-weight: 800; }

/* ===== Всплывашки ========================================================== */
.pop { position: fixed; z-index: 20; left: 16px; right: 16px; max-width: 420px; margin: 0 auto; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.2); animation: pop .25s var(--ease) both; }
.pop .h { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.pop .h img { width: 32px; height: 32px; border-radius: 10px; }
.pop .x { font-weight: 600; }
.toast { position: fixed; left: 50%; top: calc(var(--top) + 14px); z-index: 30; transform: translate(-50%, -20px); display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 99px; background: var(--text); color: var(--bg); font-weight: 800; font-size: 14.5px; opacity: 0; pointer-events: none; transition: all .35s var(--ease); max-width: calc(100% - 32px); }
.toast img { width: 30px; height: 30px; border-radius: 50%; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.xp-float { position: fixed; z-index: 25; font-weight: 900; color: var(--primary); font-size: 18px; pointer-events: none; animation: floatUp 1s ease-out forwards; }
@keyframes floatUp { to { transform: translateY(-50px); opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; } }
