/* ============ UpSkill — «ночная IDE» ============ */

:root {
  --bg: #0a0e14;
  --surface: #10161f;
  --surface-2: #161e2a;
  --surface-3: #1d2736;
  --border: #1f2a3a;
  --border-hi: #2c3b52;
  --text: #e8edf2;
  --muted: #8b98a8;
  --dim: #5c6b7d;
  --accent: #ffb454;
  --accent-dim: rgba(255, 180, 84, .12);
  --green: #c2d94c;
  --cyan: #39bae6;
  --red: #f07178;
  --mint: #95e6cb;
  --font-display: 'Unbounded', sans-serif;
  --font-body: 'Golos Text', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 14px;
  --sidebar-w: 300px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
}

/* фоновая сетка как в блюпринте */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(57, 186, 230, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 186, 230, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 75%);
}

.app { display: flex; position: relative; z-index: 1; }

/* ============ Sidebar ============ */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  position: sticky; top: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16,22,31,.92), rgba(10,14,20,.96));
  backdrop-filter: blur(8px);
  padding: 26px 18px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}

.logo {
  display: block; text-decoration: none; color: var(--text);
  font-family: var(--font-display); font-weight: 900; font-size: 22px;
  letter-spacing: -.5px; margin: 0 8px 4px;
}
.logo em { font-style: normal; color: var(--accent); }
.logo-sub {
  margin: 0 8px 22px; font-size: 12px; color: var(--dim);
  font-family: var(--font-mono);
}

.side-progress { margin: 0 8px 24px; }
.side-progress-bar {
  height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden;
}
.side-progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width .6s cubic-bezier(.22,1,.36,1);
}
.side-progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 7px;
  font-family: var(--font-mono);
}

.nav-title {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 2px; color: var(--dim); margin: 18px 8px 10px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px; border-radius: 10px;
  text-decoration: none; color: var(--muted);
  transition: background .15s, color .15s;
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--surface-2); color: var(--text);
  border-color: var(--border-hi);
}
.nav-item .dot {
  width: 10px; height: 10px; min-width: 10px; border-radius: 3px;
  background: var(--mod, var(--accent));
  box-shadow: 0 0 10px color-mix(in srgb, var(--mod, var(--accent)) 50%, transparent);
}
.nav-item .nav-name { flex: 1; font-size: 14px; font-weight: 500; }
.nav-item .nav-pct {
  font-family: var(--font-mono); font-size: 11px; color: var(--dim);
}
.nav-item.done .nav-pct { color: var(--green); }

/* ============ Main ============ */

.main {
  flex: 1; min-width: 0;
  padding: 44px clamp(20px, 4vw, 56px) 90px;
  max-width: 1120px;
  margin-inline: auto;   /* дашборд и справочник центрируются на широких экранах */
  animation: viewIn .45s cubic-bezier(.22,1,.36,1);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.reveal { opacity: 0; animation: viewIn .5s cubic-bezier(.22,1,.36,1) forwards; }

/* ============ Dashboard ============ */

.hero { margin-bottom: 40px; position: relative; }
.hero-kicker {
  font-family: var(--font-mono); font-size: 13px; color: var(--accent);
  margin-bottom: 14px; letter-spacing: 1px;
}
.hero h1 {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(30px, 4.6vw, 52px); line-height: 1.12;
  letter-spacing: -1px; margin-bottom: 18px;
}
.hero h1 .hl {
  background: linear-gradient(90deg, var(--accent), var(--green));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); max-width: 640px; font-size: 17px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 34px 0 44px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat b {
  display: block; font-family: var(--font-display); font-size: 30px;
  font-weight: 700; color: var(--text); line-height: 1.2;
}
.stat b .of { font-size: 15px; color: var(--dim); font-weight: 500; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.a b { color: var(--accent); }
.stat.g b { color: var(--green); }
.stat.c b { color: var(--cyan); }

.section-title {
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  margin: 40px 0 18px; letter-spacing: -.4px;
}

.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }

.mod-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  text-decoration: none; color: var(--text);
  transition: transform .2s cubic-bezier(.22,1,.36,1), border-color .2s, box-shadow .2s;
  display: flex; flex-direction: column; gap: 10px;
}
.mod-card::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--mod, var(--accent)); opacity: .85;
}
.mod-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--mod, var(--accent)) 45%, var(--border));
  box-shadow: 0 14px 40px -18px color-mix(in srgb, var(--mod, var(--accent)) 35%, transparent);
}
.mod-num {
  font-family: var(--font-mono); font-size: 11px; color: var(--dim);
  letter-spacing: 1px;
}
.mod-card h3 {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  letter-spacing: -.3px; line-height: 1.3;
}
.mod-card p { font-size: 13.5px; color: var(--muted); flex: 1; }
.mod-meta {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--dim);
}
.mod-meta .bar {
  flex: 1; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden;
}
.mod-meta .bar i {
  display: block; height: 100%;
  background: var(--mod, var(--accent));
  transition: width .5s ease;
}
.mod-card .badge-done {
  position: absolute; top: 16px; right: 16px;
  color: var(--green); font-family: var(--font-mono); font-size: 11px;
}

.continue-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--accent); color: #17110a;
  font-weight: 700; font-size: 15px; font-family: var(--font-body);
  padding: 13px 24px; border-radius: 12px; text-decoration: none;
  margin-top: 26px; border: none; cursor: pointer;
  transition: transform .15s, box-shadow .2s;
  box-shadow: 0 8px 30px -10px rgba(255, 180, 84, .5);
}
.continue-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 36px -10px rgba(255,180,84,.6); }

/* ============ Module page ============ */

.crumbs {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--dim);
  margin-bottom: 22px; display: flex; gap: 8px; flex-wrap: wrap;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.mod-hero { margin-bottom: 34px; }
.mod-hero .tag {
  display: inline-block; font-family: var(--font-mono); font-size: 12px;
  color: var(--mod, var(--accent));
  border: 1px solid color-mix(in srgb, var(--mod, var(--accent)) 40%, transparent);
  background: color-mix(in srgb, var(--mod, var(--accent)) 10%, transparent);
  padding: 4px 12px; border-radius: 100px; margin-bottom: 16px;
}
.mod-hero h1 {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(26px, 3.6vw, 40px); letter-spacing: -.8px; margin-bottom: 12px;
}
.mod-hero p { color: var(--muted); max-width: 680px; }

.lesson-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 36px; }
.lesson-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 15px 20px;
  text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.lesson-row:hover { border-color: var(--border-hi); transform: translateX(4px); }
.lesson-row .idx {
  font-family: var(--font-mono); font-size: 13px; color: var(--dim);
  width: 26px; min-width: 26px; text-align: center;
}
.lesson-row .name { flex: 1; font-weight: 500; font-size: 15px; }
.lesson-row .check {
  font-family: var(--font-mono); font-size: 12px; color: var(--dim);
}
.lesson-row.done .check { color: var(--green); }
.lesson-row.done .idx { color: var(--green); }

.lesson-row.quiz-row { border-style: dashed; border-color: color-mix(in srgb, var(--mod, var(--accent)) 45%, var(--border)); }
.lesson-row.quiz-row .idx { color: var(--mod, var(--accent)); }

/* видео */
.video-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.video-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; text-decoration: none; color: var(--text);
  transition: border-color .15s;
}
.video-card:hover { border-color: var(--red); }
.video-card .yt {
  color: var(--red); font-size: 18px; line-height: 1.3;
}
.video-card .vt { font-size: 13.5px; font-weight: 500; line-height: 1.45; }
.video-card .vc { font-size: 11.5px; color: var(--dim); font-family: var(--font-mono); margin-top: 3px; }

/* ============ Lesson ============ */

.lesson-body { max-width: 780px; }
.lesson-body h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(24px, 3vw, 32px); letter-spacing: -.6px;
  margin-bottom: 26px; line-height: 1.25;
}
.lesson-body h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
  letter-spacing: -.3px; margin: 38px 0 14px;
  padding-top: 10px;
}
.lesson-body h3 { font-size: 17px; font-weight: 700; margin: 26px 0 10px; }
.lesson-body p { margin-bottom: 14px; color: #c7d0da; }
.lesson-body ul, .lesson-body ol { margin: 0 0 16px 22px; color: #c7d0da; }
.lesson-body li { margin-bottom: 7px; }
.lesson-body strong { color: var(--text); }
.lesson-body a { color: var(--cyan); }
.lesson-body table {
  width: 100%; border-collapse: collapse; margin: 6px 0 20px; font-size: 14px;
}
.lesson-body th, .lesson-body td {
  border: 1px solid var(--border); padding: 9px 13px; text-align: left;
}
.lesson-body th { background: var(--surface-2); font-weight: 600; }
.lesson-body td { color: #c7d0da; }

.lesson-body code:not(pre code) {
  font-family: var(--font-mono); font-size: .86em;
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 1.5px 7px; border-radius: 6px; color: var(--mint);
  white-space: nowrap;
}

pre.code {
  background: #0d1320; border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px; margin: 6px 0 20px;
  overflow-x: auto; position: relative;
  font-size: 13.5px; line-height: 1.7;
}
pre.code code { font-family: var(--font-mono); display: block; }
pre.code::after {
  content: attr(data-lang); position: absolute; top: 10px; right: 14px;
  font-family: var(--font-mono); font-size: 10px; color: var(--dim);
  text-transform: uppercase; letter-spacing: 1px;
}

/* подсветка */
.tk-kw { color: #ff8f40; }
.tk-str { color: #c2d94c; }
.tk-com { color: #5c6b7d; font-style: italic; }
.tk-num { color: #d4bfff; }
.tk-fn { color: #ffd580; }
.tk-type { color: #39bae6; }

/* коллауты */
.callout {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px 14px; margin: 20px 0;
  background: var(--surface); font-size: 14.5px;
}
.callout .co-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 8px;
}
.callout p:last-child { margin-bottom: 0; }
.callout ul { margin-bottom: 4px; }
.callout.when { border-color: rgba(194, 217, 76, .35); background: rgba(194, 217, 76, .05); }
.callout.when .co-title { color: var(--green); }
.callout.warn { border-color: rgba(240, 113, 120, .35); background: rgba(240, 113, 120, .05); }
.callout.warn .co-title { color: var(--red); }
.callout.tip { border-color: rgba(57, 186, 230, .35); background: rgba(57, 186, 230, .05); }
.callout.tip .co-title { color: var(--cyan); }
.callout.int { border-color: rgba(255, 180, 84, .4); background: rgba(255, 180, 84, .06); }
.callout.int .co-title { color: var(--accent); }

/* навигация урока */
.lesson-nav {
  display: flex; gap: 12px; margin-top: 44px; flex-wrap: wrap;
  border-top: 1px solid var(--border); padding-top: 26px;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  padding: 11px 20px; border-radius: 10px; cursor: pointer;
  text-decoration: none; border: 1px solid var(--border-hi);
  background: var(--surface-2); color: var(--text);
  transition: border-color .15s, background .15s, transform .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary {
  background: var(--accent); color: #17110a; border-color: var(--accent);
}
.btn.primary:hover { box-shadow: 0 8px 24px -8px rgba(255,180,84,.5); }
.btn.done-btn.marked { border-color: var(--green); color: var(--green); background: rgba(194,217,76,.08); }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.spacer { flex: 1; }

/* ============ Quiz ============ */

.quiz-wrap { max-width: 720px; }
.quiz-head { margin-bottom: 30px; }
.quiz-head h1 {
  font-family: var(--font-display); font-weight: 700; font-size: 28px;
  letter-spacing: -.5px; margin-bottom: 10px;
}
.quiz-progress {
  display: flex; gap: 6px; margin: 22px 0 30px;
}
.quiz-progress i {
  flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3);
  transition: background .3s;
}
.quiz-progress i.past { background: var(--mod, var(--accent)); }
.quiz-progress i.cur { background: var(--text); }

.q-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  animation: viewIn .35s cubic-bezier(.22,1,.36,1);
}
.q-num { font-family: var(--font-mono); font-size: 12px; color: var(--dim); margin-bottom: 12px; }
.q-text { font-size: 17.5px; font-weight: 600; margin-bottom: 8px; line-height: 1.5; }
.q-text code { font-family: var(--font-mono); font-size: .85em; background: var(--surface-3); padding: 1px 6px; border-radius: 5px; color: var(--mint); }
.q-card pre.code { margin-top: 14px; }

.q-options { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.q-opt {
  text-align: left; font-family: var(--font-body); font-size: 14.5px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 10px;
  padding: 13px 17px; cursor: pointer; line-height: 1.5;
  transition: border-color .15s, background .15s, transform .1s;
}
.q-opt code { font-family: var(--font-mono); font-size: .85em; }
.q-opt:hover:not(:disabled) { border-color: var(--accent); transform: translateX(3px); }
.q-opt:disabled { cursor: default; }
.q-opt.correct { border-color: var(--green); background: rgba(194, 217, 76, .12); }
.q-opt.wrong { border-color: var(--red); background: rgba(240, 113, 120, .12); }
.q-opt.faded { opacity: .45; }

.q-explain {
  margin-top: 18px; padding: 15px 18px; border-radius: 10px;
  font-size: 14px; line-height: 1.6;
  border: 1px solid var(--border); background: var(--surface-2);
  animation: viewIn .3s ease;
}
.q-explain b { display: block; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px; }
.q-explain.ok b { color: var(--green); }
.q-explain.bad b { color: var(--red); }

.q-next { margin-top: 20px; display: flex; justify-content: flex-end; }

/* результат квиза */
.quiz-result { text-align: center; padding: 30px 0 10px; }
.score-ring { position: relative; width: 168px; height: 168px; margin: 0 auto 24px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--surface-3); }
.score-ring .ring-val {
  stroke: var(--mod, var(--accent)); stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(.22,1,.36,1);
}
.score-ring .score-label {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-ring .score-label b { font-family: var(--font-display); font-size: 34px; font-weight: 900; }
.score-ring .score-label span { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.quiz-result h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 10px; }
.quiz-result p { color: var(--muted); margin-bottom: 24px; }
.quiz-result .btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============ Правая колонка урока ============ */

.lesson-rail { display: none; }

@media (min-width: 1240px) {
  /* урок занимает всю доступную ширину: ~62% контент / ~38% колонка ИИ.
     Сворачивание левого бара автоматически отдаёт место обеим колонкам */
  .main:has(.lesson-layout) { max-width: none; }
  .lesson-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(360px, 1fr);
    gap: clamp(32px, 3vw, 64px);
    align-items: start;
  }
  .lesson-layout .lesson-body,
  .lesson-layout .task-block { max-width: none; }
  .lesson-rail {
    display: block;
    position: sticky; top: 36px;
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hi) transparent;
    padding-bottom: 20px;
  }
}

.rail-title {
  font-family: var(--font-mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 2px; color: var(--dim);
  margin: 0 0 10px;
}
.rail-title:not(:first-child) { margin-top: 26px; }

/* сворачиваемые секции колонки */
.rail-sec { margin-bottom: 20px; }
.rail-sec summary.rail-title {
  margin: 0 0 10px; cursor: pointer; list-style: none;
  user-select: none; transition: color .15s;
}
.rail-sec summary.rail-title::-webkit-details-marker { display: none; }
.rail-sec summary.rail-title::before {
  content: '▸'; display: inline-block; margin-right: 7px;
  transition: transform .2s;
}
.rail-sec[open] summary.rail-title::before { transform: rotate(90deg); }
.rail-sec summary.rail-title:hover { color: var(--muted); }

.rail-toc a {
  display: block; text-decoration: none;
  font-size: 13px; line-height: 1.4; color: var(--muted);
  padding: 6px 12px; border-left: 2px solid var(--border);
  transition: color .15s, border-color .15s, background .15s;
}
.rail-toc a:hover { color: var(--text); }
.rail-toc a.active {
  color: var(--text);
  border-left-color: var(--mod, var(--accent));
  background: linear-gradient(90deg, color-mix(in srgb, var(--mod, var(--accent)) 8%, transparent), transparent);
}

.rail-terms { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.rail-terms .term { font-size: 12.5px; color: var(--muted); }
.rail-terms .term:hover { color: var(--text); }

.rail-next { display: flex; flex-direction: column; gap: 8px; }
.rail-next .btn { justify-content: center; font-size: 13px; padding: 9px 14px; }

/* чат ИИ, пристыкованный в правую колонку */
.rail-chat:not(:empty) { margin-bottom: 26px; }
.rail-chat .ai-panel { margin: 0; }
.rail-chat .ai-msgs {
  max-height: 52vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}
.rail-chat .ai-chip { font-size: 11.5px; padding: 4px 11px; }
.rail-chat .ai-form textarea { font-size: 13px; }

/* визуальная связь чата с блоком-источником */
.ai-source {
  outline: 1.5px solid color-mix(in srgb, var(--accent) 65%, transparent);
  outline-offset: 3px;
  border-radius: 12px;
  box-shadow: 0 0 28px -8px rgba(255, 180, 84, .35);
}
.ai-src {
  display: flex; align-items: center; gap: 4px; width: 100%;
  background: var(--accent-dim); border: none;
  border-bottom: 1px solid var(--border);
  color: var(--accent); cursor: pointer; text-align: left;
  font-family: var(--font-mono); font-size: 11px;
  padding: 7px 14px;
}
.ai-src span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-src:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* подсказки в коде */
.code-hint {
  border-bottom: 1px dotted rgba(139, 152, 168, .45);
  cursor: help;
  transition: border-color .15s;
}
.code-hint:hover { border-bottom-color: var(--accent); }

/* ============ Термины и справочник ============ */

.term {
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 65%, transparent);
  cursor: help;
  transition: background .15s, border-color .15s;
  border-radius: 3px 3px 0 0;
}
.term:hover {
  background: var(--accent-dim);
  border-bottom-style: solid;
}

.term-tip {
  position: fixed; z-index: 100;
  max-width: 340px;
  background: var(--surface-3);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 13.5px; line-height: 1.55; color: #d5dde6;
  box-shadow: 0 16px 48px -12px rgba(0, 0, 0, .7);
  opacity: 0; pointer-events: none;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s;
}
.term-tip.show { opacity: 1; transform: none; }
.term-tip b {
  display: block; color: var(--accent);
  font-size: 12.5px; font-family: var(--font-mono);
  margin-bottom: 5px; letter-spacing: .3px;
}
.term-tip i {
  display: block; font-style: normal; color: var(--dim);
  font-size: 11px; margin-top: 7px; font-family: var(--font-mono);
}

.gloss-search {
  width: 100%; max-width: 520px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 12px;
  padding: 13px 18px; font-size: 15px; font-family: var(--font-body);
  outline: none; transition: border-color .15s;
}
.gloss-search:focus { border-color: var(--accent); }
.gloss-search::placeholder { color: var(--dim); }

.gloss-count {
  font-family: var(--font-mono); font-size: 12px; color: var(--dim);
  margin: 10px 2px 4px;
}

.gloss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.gloss-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
}
.gloss-card:hover { border-color: var(--border-hi); }
.gloss-term {
  font-weight: 700; font-size: 15px; margin-bottom: 6px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.gloss-en {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 400;
  color: var(--dim);
}
.gloss-def { font-size: 13.5px; color: var(--muted); line-height: 1.6; }

.glossary-nav { margin-bottom: 6px; border-style: dashed; border-color: var(--border); }

/* ============ Задание для самопроверки ============ */

.task-block {
  max-width: 780px;
  margin-top: 40px;
  border: 1px solid color-mix(in srgb, var(--mod, var(--accent)) 40%, var(--border));
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--mod, var(--accent)) 6%, var(--surface)), var(--surface));
  padding: 24px;
}
.task-head {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--mod, var(--accent));
  margin-bottom: 12px;
}
.task-text { font-size: 15px; line-height: 1.65; color: #d5dde6; margin-bottom: 16px; }

.task-answer {
  width: 100%; resize: vertical; min-height: 120px;
  background: #0d1320; color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 10px;
  padding: 12px 15px; font-family: var(--font-mono); font-size: 13px;
  line-height: 1.6; outline: none; tab-size: 2;
}
.task-answer:focus { border-color: var(--mod, var(--accent)); }
.task-answer::placeholder { color: var(--dim); font-family: var(--font-body); }

.task-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.task-solution { margin-top: 18px; }
.task-solution pre.code { margin-bottom: 12px; }
.task-note { font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* ============ ИИ-помощник (LM Studio) ============ */

.ai-bar {
  display: flex; justify-content: flex-end;
  margin: -14px 0 20px;
}
.ai-bar-callout { margin: 6px -6px -4px 0; }
.ai-ask {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--dim); padding: 4px 6px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.ai-ask:hover { color: var(--accent); background: var(--accent-dim); }

.ai-panel {
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--surface); border-radius: 12px;
  margin: -8px 0 24px; overflow: hidden;
  animation: viewIn .25s ease;
}
.ai-panel.hidden { display: none; }

.ai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.ai-title { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.ai-status {
  flex: 1; font-family: var(--font-mono); font-size: 11px; color: var(--green);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-status.err { color: var(--red); }
.ai-gear, .ai-close {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: 14px; padding: 2px 6px; border-radius: 6px;
}
.ai-gear:hover, .ai-close:hover { color: var(--text); background: var(--surface-3); }

.ai-settings { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.ai-settings.hidden { display: none; }
.ai-settings label {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--dim); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 1px;
}
.ai-settings input {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 8px;
  padding: 8px 12px; font-family: var(--font-mono); font-size: 12.5px; outline: none;
}
.ai-settings input:focus { border-color: var(--accent); }

.ai-chips {
  display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 14px 4px;
}
.ai-chip {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border-hi); border-radius: 100px;
  font-family: var(--font-body); font-size: 12px;
  padding: 5px 12px; cursor: pointer; transition: color .15s, border-color .15s;
}
.ai-chip:hover { color: var(--accent); border-color: var(--accent); }

.ai-msgs { padding: 6px 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msgs:empty { padding: 0; }
.ai-msg {
  font-size: 13.5px; line-height: 1.6; border-radius: 10px; padding: 9px 13px;
  max-width: 100%; overflow-wrap: break-word; white-space: pre-wrap;
}
.ai-msg.user {
  align-self: flex-end; background: var(--accent-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text); max-width: 85%;
}
.ai-msg.assistant {
  align-self: stretch; background: var(--surface-2);
  border: 1px solid var(--border); color: #cdd6e0;
}
.ai-msg.assistant code {
  font-family: var(--font-mono); font-size: .85em;
  background: var(--surface-3); padding: 1px 6px; border-radius: 5px; color: var(--mint);
}
.ai-code {
  display: block; background: #0d1320; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 13px; margin: 8px 0;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre; color: #d5dde6;
}
.ai-typing { color: var(--dim); font-style: italic; }

.ai-offline { white-space: normal; }
.ai-offline ol { margin: 8px 0 0 20px; }
.ai-offline li { margin-bottom: 4px; }
.ai-offline code { white-space: nowrap; }

.ai-form {
  display: flex; gap: 8px; padding: 10px 14px 14px; align-items: flex-end;
}
.ai-form textarea {
  flex: 1; resize: none; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 10px;
  padding: 9px 13px; font-family: var(--font-body); font-size: 13.5px;
  line-height: 1.5; outline: none;
}
.ai-form textarea:focus { border-color: var(--accent); }
.ai-form textarea::placeholder { color: var(--dim); }
.ai-send {
  background: var(--accent); color: #17110a; border: none;
  width: 38px; height: 38px; border-radius: 10px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform .15s;
}
.ai-send:hover { transform: translateY(-1px); }

/* ============ Mobile ============ */

.burger {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 60;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 10px;
  width: 42px; height: 42px; font-size: 17px; cursor: pointer;
}
.sidebar-overlay { display: none; }

/* складной сайдбар (десктоп) */
.side-collapse {
  position: absolute; top: 22px; right: 12px;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--dim); font-size: 15px; line-height: 1;
  width: 28px; height: 28px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.side-collapse:hover { color: var(--text); border-color: var(--border-hi); }

.sidebar-expand {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 60;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 10px;
  width: 42px; height: 42px; font-size: 17px; cursor: pointer;
  transition: border-color .15s;
}
.sidebar-expand:hover { border-color: var(--accent); }

@media (min-width: 901px) {
  /* margin-left у sticky-элемента Chrome игнорирует — сворачиваем шириной */
  .sidebar {
    transition: width .22s ease, min-width .22s ease, padding .22s ease;
    overflow-x: hidden;
  }
  body.sidebar-collapsed .sidebar {
    width: 0; min-width: 0;
    padding-left: 0; padding-right: 0;
    border-right-width: 0;
  }
  body.sidebar-collapsed .sidebar-expand { display: block; }
  /* отступ под плавающую кнопку ☰, чтобы не наезжала на контент */
  body.sidebar-collapsed .main { padding-left: 84px; }
}
@media (max-width: 900px) {
  .side-collapse { display: none; }   /* на мобиле есть бургер и оверлей */
}

@media (max-width: 900px) {
  .burger { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 55;
    transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: 20px 0 60px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: none; }
  .sidebar-overlay.show {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(5, 8, 12, .6); backdrop-filter: blur(2px);
  }
  .main { padding-top: 72px; }
}
