/* ══ CSS VARIABLES ═══════════════════════════════════════════════════════════ */
:root {
  /* Brand accent colors */
  --primary:   #1CB0F6;
  --primary-d: #1490c4;
  --green:     #58CC02;
  --green-d:   #46a302;
  --red:       #FF4B4B;
  --gold:      #FFB020;
  --purple:    #CE82FF;
  --indigo:    #6366f1;
  --cyan:      #22d3ee;

  /* Backgrounds — deep navy */
  --bg:     #0c1019;
  --bg2:    #11162a;
  --bg3:    #1a2040;
  --card:   #131830;

  /* Borders — transparent glass style */
  --border:  rgba(255,255,255,.07);
  --border2: rgba(255,255,255,.12);

  /* Text */
  --text:  #e8eaf6;
  --text2: #9ba3c7;
  --text3: #6c7494;

  /* Bottom chrome row (Run / AI / sidebar user) — одна висота */
  --editor-bottom-bar-h: 60px;
  /* Трохи підняти нижні панелі від краю екрана */
  --bottom-chrome-lift: 10px;

  /* Misc */
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
  --trans:     .18s ease;
  --editor-bg: #0c1019;
  --nav-h:     64px;
}

html[data-theme="light"] {
  --bg:      #f5f7ff;
  --bg2:     #ffffff;
  --bg3:     #eef1ff;
  --card:    #ffffff;
  --border:  #e1e6f5;
  --border2: #cbd3ed;
  --text:    #1a1d35;
  --text2:   #6b74a8;
  --text3:   #969cbb;
  --shadow:  0 4px 24px rgba(80,90,180,.1);
  --editor-bg: #f8fafc;
}

html[data-theme="aurora"] {
  --primary:   #00d4aa;
  --primary-d: #00b890;
  --green:     #00d4aa;
  --green-d:   #00b890;
  --purple:    #b47aff;
  --gold:      #ffd166;
  --bg:        #060b14;
  --bg2:       #0b1525;
  --bg3:       #111e35;
  --card:      #0e1a2e;
  --border:    rgba(26,58,88,.5);
  --border2:   rgba(26,58,88,.9);
  --text:      #e2f0ff;
  --text2:     #7aadcc;
  --text3:     #4a7a99;
  --shadow:    0 4px 24px rgba(0,140,255,.2);
  --editor-bg: #060b14;
}
html[data-theme="aurora"] .btn-primary {
  background: linear-gradient(135deg, #00d4aa, #38c5ff);
  box-shadow: 0 4px 0 #007a66, 0 0 20px rgba(0,212,170,.25);
  color: #060b14;
}
html[data-theme="aurora"] .btn-primary:hover {
  background: linear-gradient(135deg, #00eabb, #55d4ff);
}

/* ══ BASE ════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.noto-emoji body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Color Emoji", sans-serif;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input  { font: inherit; color: inherit; background: none; border: none; outline: none; }

/* ══ SCREENS ════════════════════════════════════════════════════════════════ */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}
.screen.active { display: flex; }

/* Challenge/Sandbox screens take full viewport */
#screen-challenge.active,
#screen-sandbox.active {
  height: 100vh;
  min-height: unset;
  overflow: hidden;
  padding-bottom: calc(var(--bottom-chrome-lift) + env(safe-area-inset-bottom, 0px));
}

/* ══ HEADER ════════════════════════════════════════════════════════════════ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 5px;
}
.logo-icon-mini { display: inline-flex; align-items: center; vertical-align: middle; margin-right: 4px; }
.logo-text .sp-s1, .logo-text .sp-s2, .logo-text .sp-s3, .logo-text .sp-s4 { font-size: inherit; }

.screen-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 10px; }

/* ══ BODY ═══════════════════════════════════════════════════════════════════ */
.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}

/* ══ BUTTONS ════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform var(--trans), box-shadow var(--trans), background var(--trans);
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 0 var(--primary-d);
}
.btn-primary:hover { background: #2ec0ff; transform: translateY(-1px); }
.btn-primary:active { box-shadow: none; transform: translateY(4px); }
.btn-primary:disabled { background: var(--bg3); box-shadow: 0 4px 0 var(--border2); color: var(--text2); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 2px solid var(--border2);
}
.btn-secondary:hover { background: rgba(255,255,255,.05); }

.btn-danger {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 0 #c93b3b;
}
.btn-danger:active { box-shadow: none; transform: translateY(4px); }

.btn-run {
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 0 var(--green-d);
  padding: 9px 14px;
  font-size: .875rem;
}
.btn-run:hover { background: #62e002; }
.btn-run:active { box-shadow: none; transform: translateY(3px); }

.btn-check {
  background: var(--gold);
  color: #0c1019;
  box-shadow: 0 3px 0 #c88a00;
  padding: 9px 14px;
  font-size: .875rem;
}
.btn-check:hover { filter: brightness(1.05); }

.btn-hint {
  background: var(--bg3);
  color: var(--text);
  border: 1.5px solid var(--border2);
  padding: 9px 14px;
  font-size: .875rem;
}
.btn-hint:hover { border-color: var(--primary); color: var(--primary); }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .95rem;
  color: var(--text2);
  padding: 8px 0;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--trans);
}
.btn-back:hover { color: var(--text); }

.btn-icon-sm {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  color: var(--text2);
  padding: 8px 12px;
  font-size: .875rem;
  border-radius: var(--radius);
}
.btn-icon-sm:hover { border-color: var(--primary); color: var(--primary); }

.btn-star {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
  transition: all var(--trans);
  color: var(--text2);
}
.btn-star:hover { background: var(--bg3); color: #f59e0b; }
.btn-star.starred { color: #f59e0b; }

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: .875rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background var(--trans);
}
.btn-text:hover { background: rgba(28,176,246,.12); }

/* ══ BOTTOM NAV ═════════════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 0 4px;
  flex-shrink: 0;
}

/* Hide bottom nav on challenge/sandbox screens */
#screen-challenge.active ~ .bottom-nav,
#screen-sandbox.active ~ .bottom-nav { display: none; }

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  transition: all var(--trans);
  color: var(--text2);
}
.nav-btn.active { color: var(--primary); }
.nav-btn:hover { background: var(--bg3); }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 500; }

/* ══ HOME SCREEN ════════════════════════════════════════════════════════════ */
.home-greeting {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,75,75,.12);
  border: 1px solid rgba(255,75,75,.25);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: .875rem;
  font-weight: 700;
  color: #ff7070;
}

.xp-display {
  font-size: .875rem;
  font-weight: 700;
  background: rgba(255,176,32,.12);
  border: 1px solid rgba(255,176,32,.25);
  color: var(--gold);
  padding: 5px 12px;
  border-radius: 20px;
}

/* XP Card */
.xp-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.xp-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.level-badge {
  background: rgba(28,176,246,.15);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(28,176,246,.3);
}
.xp-number { font-size: .75rem; color: var(--text2); font-weight: 600; }
.xp-bar-wrap {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}
.xp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--indigo));
  border-radius: 4px;
  transition: width .6s ease;
}

/* Daily Card */
.daily-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  border-left: 3px solid var(--gold);
}
.daily-icon { font-size: 28px; flex-shrink: 0; }
.daily-info { flex: 1; min-width: 0; }
.daily-title { font-size: .9rem; font-weight: 600; color: var(--text); }
.daily-meta { font-size: .75rem; color: var(--text2); margin-top: 3px; }

/* ── Featured Course (Home) ──────────────────────────────────────────────── */
#home-featured-wrap { margin-bottom: 4px; }

.featured-pick-prompt {
  background: var(--card);
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--trans);
}
.featured-pick-prompt:hover { border-color: var(--primary); }
.fpp-icon { font-size: 32px; margin-bottom: 8px; }
.fpp-title { font-size: .95rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.fpp-sub   { font-size: .78rem; color: var(--text2); }

.featured-course-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--trans);
}
.featured-course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.fcc-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
}
.fcc-logo { width: 44px; height: 44px; flex-shrink: 0; }
.fcc-info { flex: 1; min-width: 0; }
.fcc-name { font-size: 1rem; font-weight: 800; color: var(--text); }
.fcc-desc { font-size: .78rem; color: var(--text2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcc-badge { font-size: .65rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-top: 5px; display: inline-block; }
.fcc-progress { padding: 0 14px 4px; }
.fcc-bar-wrap { height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.fcc-bar { height: 100%; border-radius: 3px; transition: width .5s ease; }
.fcc-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 12px;
  gap: 8px;
}
.fcc-stats { display: flex; gap: 14px; }
.fcc-stat { font-size: .72rem; color: var(--text2); }
.fcc-stat strong { color: var(--text); font-weight: 700; }
.fcc-continue-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--trans);
}
.fcc-continue-btn:hover { opacity: .85; }

/* ── Course Cards Grid (Courses screen) ──────────────────────────────────── */
.course-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 480px) { .course-cards-grid { grid-template-columns: repeat(3, 1fr); } }

.cc-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px 12px;
  cursor: pointer;
  transition: all var(--trans);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  position: relative;
}
.cc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.cc-card:active { transform: scale(.97); }
.cc-card-top-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: var(--radius) var(--radius) 0 0; }
.cc-icon { font-size: 32px; line-height: 1; margin-top: 4px; }
.cc-name { font-size: .82rem; font-weight: 700; color: var(--text); text-align: center; }
.cc-stat { font-size: .72rem; color: var(--text2); }
.cc-bar-wrap { width: 100%; height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.cc-bar { height: 100%; border-radius: 2px; transition: width .4s ease; }

/* Continue Course Cards */
#home-continue-list { display: flex; flex-direction: column; gap: 10px; }

.continue-course-card {
  background: var(--card);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: all var(--trans);
}
.continue-course-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 2px rgba(28,176,246,.3); }
.ccc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ccc-icon { font-size: 26px; flex-shrink: 0; }
.ccc-info { flex: 1; min-width: 0; }
.ccc-name { font-size: .9rem; font-weight: 700; color: var(--text); }
.ccc-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.ccc-tasks { font-size: .75rem; color: var(--text2); }
.ccc-arrow { font-size: 18px; color: var(--primary); flex-shrink: 0; }
.ccc-bar-wrap { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.ccc-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--indigo)); border-radius: 3px; transition: width .5s ease; }
.ccc-xp-row { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text2); margin-top: 5px; }

.level-badge-sm {
  background: rgba(28,176,246,.15);
  color: var(--primary);
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(28,176,246,.3);
  white-space: nowrap;
}

/* Course XP Strip (lesson screen) */
.course-xp-strip {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.cxs-course { font-size: .82rem; font-weight: 600; color: var(--text); flex-shrink: 0; }
.cxs-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.cxs-xp { font-size: .72rem; color: var(--text2); }
.course-xp-strip .cxs-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  flex-basis: 100%;
  margin-top: 2px;
}
.cxs-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--indigo)); border-radius: 2px; transition: width .5s ease; }

/* ── Course page header + hero ───────────────────────────────────────────── */
#screen-course-page .course-page-app-header {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding-bottom: 14px;
}
.course-page-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin-bottom: 12px;
}
.course-page-header-info {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  padding: 0 4px;
}
.cph-head-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
}
.cph-head-logo { flex-shrink: 0; border-radius: 8px; }
.cph-head-emoji { font-size: 28px; line-height: 1; flex-shrink: 0; }
.cph-head-text { min-width: 0; text-align: left; }
.cph-head-name {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

#screen-course-page .course-page-screen-body {
  padding-top: 12px;
  gap: 18px;
}

.course-page-hero {
  background: linear-gradient(165deg, var(--card) 0%, rgba(28, 176, 246, 0.04) 100%);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 22px 20px 20px;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
  text-align: center;
}
.cph-hero-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.cph-hero-logo-wrap {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.cph-hero-logo-wrap--emoji { border-radius: 20px; }
.cph-hero-logo { width: 44px; height: 44px; object-fit: contain; }
.cph-hero-emoji { font-size: 40px; line-height: 1; }
.cph-hero-title {
  margin: 4px 0 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 32rem;
}
.cph-hero-desc {
  margin: 0;
  font-size: 0.95rem;
  color: color-mix(in srgb, var(--text) 82%, var(--text2));
  line-height: 1.55;
  max-width: 36rem;
  text-wrap: balance;
}
.cph-hero-meta {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.cph-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 22px;
}
.cph-stat-item { display: flex; flex-direction: column; gap: 3px; align-items: center; min-width: 56px; }
.cph-stat-num { font-size: 1.05rem; font-weight: 800; color: var(--primary); }
.cph-stat-lbl { font-size: .62rem; color: var(--text2); text-transform: uppercase; letter-spacing: .55px; font-weight: 600; }
.cph-progress-block { margin-top: 14px; max-width: 420px; margin-left: auto; margin-right: auto; }
.cph-bar-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 6px;
  overflow: hidden;
}
.cph-bar-fill { height: 100%; border-radius: 6px; transition: width 0.45s ease; }
.cph-progress-caption { font-size: 12px; color: var(--text2); margin-top: 6px; font-weight: 500; }

@supports not (color: color-mix(in srgb, red, blue)) {
  .cph-hero-desc { color: var(--text); opacity: 0.88; }
}

#screen-course-page .module-list {
  padding-left: 0;
  padding-right: 0;
}

/* Lesson screen: clearer rhythm between title, theory, tasks */
#screen-lesson .app-header {
  gap: 12px;
  padding-top: 14px;
  padding-bottom: 12px;
}
#screen-lesson .screen-title {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
  text-align: right;
}
.lesson-body {
  gap: 22px;
  padding-top: 6px;
}
.lesson-body .section-title {
  margin-top: 4px;
  margin-bottom: 2px;
}
.lesson-challenges {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lesson-theory {
  margin-bottom: 2px;
}

/* ══ COURSES SCREEN ══════════════════════════════════════════════════════════ */
.course-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.course-item {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--trans);
}
.course-item:hover { border-color: var(--primary); transform: translateX(2px); }
.course-item-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}
.course-item-icon { font-size: 36px; display: flex; align-items: center; justify-content: center; }
.lang-logo { display: block; object-fit: contain; }
.course-item-info { flex: 1; }
.course-item-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.course-item-desc { font-size: .82rem; color: var(--text2); margin-top: 3px; }
.course-item-meta { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.course-item-stat { font-size: .78rem; color: var(--text2); }
.course-item-arrow { font-size: 20px; color: var(--text3); }

/* Modules */
.module-list { padding: 0 20px 16px; display: none; flex-direction: column; gap: 8px; }
.module-list.open { display: flex; }

.module-item {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.module-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
  transition: background var(--trans);
}
.module-header:hover { background: rgba(28,176,246,.08); }
.module-lessons { padding: 0 14px 12px; display: none; flex-direction: column; gap: 6px; }
.module-lessons.open { display: flex; }

.lesson-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg2);
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--trans);
  border: 1.5px solid transparent;
}
.lesson-item:hover { border-color: var(--primary); background: rgba(28,176,246,.06); }
.lesson-item.completed { opacity: .7; }
.lesson-status { font-size: 16px; flex-shrink: 0; }
.lesson-name { font-size: .875rem; font-weight: 500; flex: 1; }
.lesson-xp { font-size: .72rem; color: var(--gold); font-weight: 600; }

/* ══ CONTINUE POPUP ══════════════════════════════════════════════════════════ */
.continue-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .2s ease;
}
.continue-popup-sheet {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border2);
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 500px;
  text-align: center;
  animation: slideUp .25s ease;
}
.continue-popup-icon  { font-size: 36px; margin-bottom: 10px; }
.continue-popup-title { font-size: 1.05rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.continue-popup-lesson { font-size: .82rem; color: var(--text2); margin-bottom: 20px; line-height: 1.4; }
.continue-popup-actions { display: flex; flex-direction: column; gap: 10px; }
.continue-popup-actions .btn { width: 100%; justify-content: center; }

/* ══ LESSON SCREEN ═══════════════════════════════════════════════════════════ */
.lesson-body { gap: 20px; }

.lesson-theory {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  line-height: 1.7;
}
.lesson-theory h2 { font-size: 1.1rem; color: var(--text); margin-bottom: 12px; }
.lesson-theory h3 { font-size: .95rem; color: var(--primary); margin: 14px 0 8px; }
.lesson-theory p { font-size: .9rem; color: var(--text); margin-bottom: 10px; }
.lesson-theory code {
  background: var(--bg3);
  color: var(--cyan);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: "Fira Code", "Consolas", monospace;
  font-size: .82rem;
}
.lesson-theory pre {
  background: var(--editor-bg);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.lesson-theory pre code {
  background: none;
  padding: 0;
  font-size: .82rem;
  color: var(--text);
}
.lesson-theory ul, .lesson-theory ol {
  padding-left: 20px;
  margin-bottom: 10px;
}
.lesson-theory li { font-size: .9rem; color: var(--text); margin-bottom: 4px; }
.lesson-theory strong { color: var(--primary); }

/* Challenge list */
.challenge-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--trans);
  margin-bottom: 8px;
}
.challenge-list-item:hover { border-color: var(--primary); transform: translateX(3px); }
.challenge-list-item.done { border-color: var(--green); }
.cli-icon { font-size: 20px; }
.cli-info { flex: 1; }
.cli-name { font-size: .9rem; font-weight: 600; color: var(--text); }
.cli-meta { font-size: .75rem; color: var(--text2); margin-top: 2px; }
.cli-xp { font-size: .75rem; font-weight: 700; color: var(--gold); }

/* Screenshot verify section */
#screenshot-verify-section {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ══ CHALLENGE / SANDBOX LAYOUT ══════════════════════════════════════════════ */
.challenge-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  min-height: 52px;
  box-sizing: border-box;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.challenge-meta { flex: 1; display: flex; align-items: center; gap: 8px; }
.challenge-title { font-size: .9rem; font-weight: 600; color: var(--text); }
.challenge-xp {
  font-size: .78rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255,176,32,.15);
  padding: 2px 8px;
  border-radius: 10px;
}
.challenge-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Language pill selector */
.lang-pill-group {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.lang-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  color: var(--text2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
}
.lang-pill:hover { border-color: var(--primary); color: var(--text); }
.lang-pill.active {
  background: rgba(28,176,246,.15);
  border-color: var(--primary);
  color: var(--primary);
}
.lang-pill img { display: block; flex-shrink: 0; }

/* Two-column layout */
.challenge-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.challenge-left {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.challenge-right {
  width: 380px;
  min-width: 260px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg2);
}

@media (max-width: 700px) {
  .challenge-layout { flex-direction: column; }
  .challenge-right { width: 100%; min-width: unset; max-height: 280px; border-right: none; border-top: 1px solid var(--border); }
}

/* Task description */
.task-description {
  padding: 12px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  color: var(--text);
  line-height: 1.6;
  flex-shrink: 0;
  max-height: 120px;
  overflow-y: auto;
}
.task-description strong { color: var(--primary); }

/* Sandbox: імпортована задача з AI */
.sandbox-task-banner {
  flex-shrink: 0;
  max-height: 140px;
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  line-height: 1.45;
  color: var(--text);
}
.sandbox-task-banner strong { color: var(--primary); display: block; margin-bottom: 4px; }
.sandbox-task-banner .sandbox-task-desc { color: var(--text2); font-size: .78rem; }
.ai-task-offer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--bg3);
}
.ai-task-offer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Monaco Editor container */
.editor-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Output panel */
.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text2);
  flex-shrink: 0;
}
.runtime-badge { font-size: .72rem; color: var(--text2); }

.output-panel {
  flex: 1;
  padding: 12px;
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
  font-size: .82rem;
  color: var(--text);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--editor-bg);
  min-height: 80px;
  max-height: 320px;
}
.output-panel:has(.jdk-guide) {
  max-height: min(70vh, 520px);
}
.output-placeholder { color: var(--text2); font-style: italic; }
.output-error { color: var(--red); display: block; margin-top: 8px; }
.output-error-block {
  margin: 0;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--red) 12%, var(--bg3));
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--border));
  border-radius: 10px;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(55vh, 420px);
  overflow-y: auto;
  color: #fecaca;
}
.output-pre {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}
.output-hint-warn {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.1);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
}

.jdk-guide { line-height: 1.45; }
.jdk-guide-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.jdk-guide-sub { font-size: 0.82rem; color: var(--text2); margin-top: 8px; }
.jdk-guide-manual { margin-top: 12px !important; font-weight: 600; color: var(--text); }
.jdk-guide-after { margin-top: 12px !important; }
.jdk-guide-top {
  margin: 12px 0;
  padding: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.jdk-guide-top-lbl {
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 8px;
  color: var(--text);
}
.jdk-guide-snippet {
  margin: 0 0 10px;
  padding: 10px;
  background: var(--editor-bg);
  border-radius: 8px;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border2);
}
.jdk-install-auto-btn { margin: 10px 0; font-size: 0.85rem; padding: 9px 18px; width: 100%; max-width: 360px; }
.jdk-copy-all-btn { font-size: 0.8rem; padding: 6px 12px; }
.jdk-guide-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.jdk-guide-os { font-size: 0.72rem; font-weight: 700; color: var(--primary); min-width: 72px; }
.jdk-guide-cmd { flex: 1; min-width: 160px; font-size: 0.75rem; color: var(--text); }
.jdk-copy-btn {
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
}
.jdk-copy-btn:hover { border-color: var(--primary); color: var(--primary); }

.jdk-install-log-wrap {
  margin-top: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--red) 8%, var(--bg3));
  border: 1px solid color-mix(in srgb, var(--red) 35%, var(--border));
  border-radius: 10px;
}
.jdk-install-log-title {
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 8px;
  color: var(--text);
}
.jdk-install-log-pre {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(50vh, 360px);
  overflow-y: auto;
  color: #fecaca;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
}

.daily-preparing-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
}
body.daily-preparing-lock {
  overflow: hidden;
}
.daily-preparing-inner {
  text-align: center;
  padding: 28px 32px;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}
.daily-preparing-spin {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid var(--border2);
  border-top-color: var(--primary);
  animation: dailyPrepSpin 0.85s linear infinite;
}
@keyframes dailyPrepSpin {
  to { transform: rotate(360deg); }
}
.daily-preparing-text {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 8px;
  color: var(--text);
}
.daily-preparing-sub {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text2);
}

.settings-model-custom-wrap .settings-label { margin-bottom: 8px; }
.settings-model-custom-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}
.settings-model-custom-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 0.88rem;
  font-family: ui-monospace, monospace;
}
.settings-model-custom-pull { flex-shrink: 0; padding: 10px 18px; }

/* Test results */
.test-results {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  flex-shrink: 0;
}
.test-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .78rem;
}
.test-result-item.pass {
  background: rgba(88,204,2,.12);
  color: var(--green);
  border: 1px solid rgba(88,204,2,.25);
}
.test-result-item.fail {
  background: rgba(255,75,75,.12);
  color: var(--red);
  border: 1px solid rgba(255,75,75,.25);
}
.test-icon { flex-shrink: 0; font-size: .82rem; }
.test-desc { flex: 1; }
.test-got { opacity: .7; font-family: monospace; }

/* AI Hint */
.ai-hint-area {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
}
.ai-hint-header {
  padding: 8px 12px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--purple);
  background: rgba(206,130,255,.1);
  border-bottom: 1px solid var(--border);
}
.ai-hint-bubble {
  padding: 10px 12px;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.6;
}

/* ══ AI CHAT SCREEN ══════════════════════════════════════════════════════════ */
.ai-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 24px 16px;
  max-width: 480px;
  margin: 0 auto;
}
.ai-setup-icon { font-size: 64px; }
.ai-setup h2 { font-size: 1.35rem; font-weight: 700; }
.ai-setup p { font-size: .9rem; color: var(--text2); line-height: 1.6; }

.ai-system-info {
  background: var(--bg3);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .82rem;
  color: var(--text2);
  text-align: left;
  width: 100%;
}

.model-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: .875rem;
  cursor: pointer;
  transition: all var(--trans);
}
.model-item:hover, .model-item.selected { border-color: var(--primary); color: var(--primary); }

.install-progress { width: 100%; }
.progress-text { font-size: .82rem; color: var(--text2); margin-bottom: 8px; }
.progress-bar-wrap { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width .3s ease;
  animation: progressPulse 1.5s ease-in-out infinite;
}
@keyframes progressPulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

/* AI Chat */
.ai-chat-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.ai {
  background: var(--bg3);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border2);
}
.chat-msg.ai.loading { opacity: .6; font-style: italic; }

.chat-scenarios {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
}
.scenario-btn {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  color: var(--text2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: .78rem;
  cursor: pointer;
  transition: all var(--trans);
}
.scenario-btn:hover { border-color: var(--primary); color: var(--primary); }

.chat-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .9rem;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send { flex-shrink: 0; }

#screen-ai-chat .screen-body {
  position: relative;
}
.ai-ollama-checking {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(4px);
}
.ai-ollama-checking-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  color: var(--text2);
  font-size: .9rem;
}
.ai-ollama-checking-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border2);
  border-top-color: var(--primary);
  animation: aiCheckSpin .75s linear infinite;
}
@keyframes aiCheckSpin {
  to { transform: rotate(360deg); }
}

.ai-voice-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  flex-wrap: wrap;
}
.ai-voice-row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.ai-voice-mascot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(160deg, #7b93ff, #4a5fcf);
  position: relative;
  flex-shrink: 0;
  transition: transform 0.25s ease, box-shadow 0.3s ease, filter 0.25s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.ai-voice-mascot::before,
.ai-voice-mascot::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  top: 14px;
}
.ai-voice-mascot::before { left: 10px; }
.ai-voice-mascot::after { right: 10px; }
.ai-voice-mascot[data-state='listen'] {
  animation: aiMascotListen 1s ease-in-out infinite;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 40%, transparent);
}
.ai-voice-mascot[data-state='think'] {
  animation: aiMascotThink 0.9s ease-in-out infinite;
  filter: saturate(0.85);
}
.ai-voice-mascot[data-state='speak'] {
  animation: aiMascotSpeak 0.45s ease-in-out infinite alternate;
}
@keyframes aiMascotListen {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
@keyframes aiMascotThink {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(-3px); opacity: 0.85; }
}
@keyframes aiMascotSpeak {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}
#btn-chat-voice-interview.active {
  border-color: var(--primary);
  color: var(--primary);
}
.ai-voice-hint {
  font-size: 0.75rem;
  color: var(--text2);
  flex: 1;
  min-width: 100px;
}

.ai-status { width: 8px; height: 8px; border-radius: 50%; background: var(--text2); transition: background .3s; }
.ai-status.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ai-status.offline { background: var(--red); }

.model-select-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  font-size: .82rem;
  color: var(--text2);
  flex-shrink: 0;
}
.lang-select {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: .875rem;
  cursor: pointer;
  outline: none;
}

/* ══ NEWS SCREEN ════════════════════════════════════════════════════════════ */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.section-title-actions { display: flex; gap: 6px; align-items: center; }

.news-loading {
  color: var(--text2);
  font-size: .875rem;
  padding: 16px 0;
  text-align: center;
}

.news-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  transition: border-color var(--trans);
}
.news-card:hover { border-color: var(--primary); }
.news-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.news-source {
  font-size: .72rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.news-time { font-size: .72rem; color: var(--text2); }
.news-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
}
.news-desc {
  font-size: .82rem;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-read-link {
  display: inline-block;
  font-size: .78rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.news-read-link:hover { text-decoration: underline; }

.news-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0 8px;
}
.news-page-info {
  font-size: .82rem;
  color: var(--text2);
  min-width: 60px;
  text-align: center;
}
.news-pagination .btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

/* ══ SETTINGS SCREEN ════════════════════════════════════════════════════════ */
.settings-section {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.settings-info { font-size: .875rem; color: var(--text2); line-height: 1.5; }

#sett-ai .sett-section-hdr h2 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
#sett-ai .sett-section-hdr p {
  font-size: 0.875rem;
  color: var(--text2);
  line-height: 1.55;
  margin: 8px 0 0;
}

#sett-ai #settings-ollama-controls .settings-label {
  margin-bottom: 12px;
}
#sett-ai #settings-ollama-controls .model-popular-grid {
  margin-top: 6px;
}
#sett-ai #settings-ollama-controls .settings-model-list {
  margin-top: 6px;
  margin-bottom: 16px;
}
#sett-ai #settings-ollama-controls .settings-catalog-block {
  margin-top: 4px;
}

.model-popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 14px;
}
.model-popular-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.mpcard-name { font-weight: 700; font-size: 0.88rem; color: var(--text); line-height: 1.25; }
.mpcard-size { font-size: 0.72rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; }
.mpcard-desc { font-size: 0.78rem; color: var(--text2); line-height: 1.45; flex: 1; }
.mpcard-btn { width: 100%; justify-content: center; margin-top: 4px; font-size: 0.8rem; padding: 8px 10px; }
.mpcard-btn--installed {
  opacity: 0.95;
  cursor: default;
}

.model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.model-row:last-child { margin-bottom: 0; }
.model-row-name { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 0.8rem; word-break: break-all; color: var(--text); }
.model-row-del { flex-shrink: 0; padding: 6px 10px; font-size: 0.85rem; }

.settings-model-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.settings-models-loading {
  font-size: 0.82rem;
  color: var(--text2);
}
.settings-catalog-block { margin-top: 8px; }
.settings-catalog-foot {
  display: none;
  font-size: 0.8rem;
  color: var(--text2);
  line-height: 1.45;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg3);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.settings-verify-hint {
  font-size: 0.78rem;
  color: var(--text2);
  line-height: 1.45;
  margin-top: 6px;
  margin-bottom: 12px;
}

/* Theme grid with visual previews */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}
.theme-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--trans), transform var(--trans);
  background: var(--bg3);
}
.theme-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.theme-card.active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.theme-preview {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  margin-bottom: 7px;
  border: 1px solid rgba(255,255,255,.08);
}
.theme-name { font-size: .78rem; font-weight: 700; color: var(--text); display: block; }

.settings-footer {
  text-align: center;
  font-size: .78rem;
  color: var(--text2);
  padding-top: 8px;
  line-height: 1.8;
}

/* Lang toggle */
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lang-toggle-btn {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 8px;
  font-size: .875rem;
  cursor: pointer;
  transition: all var(--trans);
  font-weight: 500;
}
.lang-toggle-btn.active, .lang-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(28,176,246,.08);
}

/* ══ TOAST ══════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: .9rem;
  font-weight: 500;
  z-index: 9000;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══ MODAL ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  animation: pop .4s cubic-bezier(.34,1.56,.64,1);
}
.xp-modal { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.xp-modal-icon { font-size: 56px; animation: pop .5s .1s both; }
.xp-modal-text { font-size: 1.75rem; font-weight: 800; color: var(--gold); }
.xp-modal-sub { font-size: .95rem; color: var(--text2); }

/* ══ SPLASH ═════════════════════════════════════════════════════════════════ */
.sp-icon-wrap {
  opacity: 0;
  transform: scale(0.4);
  animation: spIconIn .7s cubic-bezier(.34,1.56,.64,1) .3s forwards;
}
.sp-icon-box {
  width: 116px; height: 116px;
  background: #0a0f1a;
  border-radius: 28px;
  border: 1.5px solid rgba(99,102,241,.2);
  display: flex; align-items: center; justify-content: center;
}
.sp-title {
  margin-top: 26px;
  opacity: 0; transform: translateY(14px);
  animation: spFadeUp .6s ease 1.1s forwards;
  font-size: 2rem; font-weight: 700; letter-spacing: -.5px;
}
.sp-sub {
  margin-top: 8px;
  opacity: 0; transform: translateY(10px);
  animation: spFadeUp .5s ease 1.4s forwards;
  font-size: .875rem; color: var(--text3); letter-spacing: .3px;
}
.sp-s1 { color: #e2e8f0; }
.sp-s2 { color: #6366f1; }
.sp-s3 { color: #e2e8f0; }
.sp-s4 { color: #22d3ee; }

/* ══ ANIMATIONS ═════════════════════════════════════════════════════════════ */
@keyframes spIconIn { to { opacity: 1; transform: scale(1); } }
@keyframes spFadeUp { to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.fade-in { animation: fadeIn .3s ease both; }
.loading-spin { display: inline-block; animation: spin 1s linear infinite; }

/* ══ SCROLLBAR ══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* Monaco editor override */
.monaco-editor .margin { background: var(--editor-bg) !important; }

/* ══ APP WRAPPER ════════════════════════════════════════════════════════════ */
#app {
  display: contents;
}

/* ══ SIDEBAR ════════════════════════════════════════════════════════════════ */
#sidebar {
  display: none;
  flex-direction: column;
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .22s cubic-bezier(.4,0,.2,1);
}
#sidebar.collapsed { width: 64px; }
#sidebar.collapsed .sb-logo { padding: 14px 0; justify-content: center; }
#sidebar.collapsed .sb-logo-text { display: none; }
#sidebar.collapsed .sb-nav { padding: 10px 8px; }
#sidebar.collapsed .sb-item { justify-content: center; padding: 10px 6px; gap: 0; }
#sidebar.collapsed .sb-item-lbl { display: none; }
#sidebar.collapsed .sb-collapse-lbl { display: none; }
#sidebar.collapsed .sb-collapse-btn { justify-content: center; padding: 10px 6px; gap: 0; }
#sidebar.collapsed .sb-collapse-icon { transform: rotate(180deg); }
#sidebar.collapsed .sb-user {
  height: var(--editor-bottom-bar-h);
  min-height: var(--editor-bottom-bar-h);
  padding: 0;
  justify-content: center;
  gap: 0;
}
#sidebar.collapsed .sb-user-info { display: none; }

.sb-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-logo-icon { flex-shrink: 0; }
.sb-logo-text {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -.5px;
  background: linear-gradient(120deg, var(--primary), var(--indigo));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sb-logo-text span { -webkit-text-fill-color: transparent; }

.sb-nav {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text2);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--trans);
  text-align: left;
  width: 100%;
}
.sb-item:hover { background: var(--bg3); color: var(--text); }
.sb-item.active {
  font-weight: 700;
  color: var(--primary);
  background: rgba(28,176,246,.12);
  border-color: rgba(28,176,246,.25);
}
.sb-item-icon { font-size: 1rem; flex-shrink: 0; }
.sb-item-lbl { white-space: nowrap; }

.sb-collapse-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text3);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--trans);
  text-align: left;
  width: 100%;
  margin-top: 8px;
}
.sb-collapse-btn:hover { background: var(--bg3); color: var(--text2); }
.sb-collapse-icon {
  font-size: 1.1rem;
  display: inline-block;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--editor-bottom-bar-h);
  min-height: var(--editor-bottom-bar-h);
  padding: 0 12px;
  background: var(--bg3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name { font-size: .82rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-sub { font-size: .68rem; color: var(--text2); margin-top: 0; line-height: 1.2; }

/* Desktop layout — sidebar + main */
@media (min-width: 680px) {
  body { overflow: hidden; height: 100dvh; display: flex; flex-direction: column; }

  #app {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    min-height: 0;
  }
  #sidebar {
    display: flex;
    padding-bottom: calc(var(--bottom-chrome-lift) + env(safe-area-inset-bottom, 0px));
  }

  #app .screen.active {
    flex: 1;
    min-width: 0;
    min-height: unset;
    height: 100%;
    overflow: hidden;
    padding-bottom: 0;
  }
  #app .screen-body {
    flex: 1;
    overflow-y: auto;
    height: 100%;
  }
  #app .bottom-nav { display: none !important; }

  /* Challenge/Sandbox: full height inside sidebar layout */
  #app #screen-challenge.active,
  #app #screen-sandbox.active {
    height: 100%;
    padding-bottom: calc(var(--bottom-chrome-lift) + env(safe-area-inset-bottom, 0px));
  }
  /* Settings: full height for tab layout */
  #app #screen-settings.active {
    overflow: hidden;
    padding-bottom: 0;
  }
  #app .sett-section { padding-bottom: 24px; }
}

/* ══ CUSTOM THEME ════════════════════════════════════════════════════════════ */
html[data-theme="custom"] {
  --bg:      var(--cust-bg,      #0c1019);
  --bg2:     var(--cust-bg2,     #11162a);
  --bg3:     var(--cust-bg3,     #1a2040);
  --card:    var(--cust-card,    #131830);
  --border:  var(--cust-border,  rgba(255,255,255,.06));
  --border2: var(--cust-border2, rgba(255,255,255,.1));
  --text:    var(--cust-text,    #e8eaf6);
  --text2:   var(--cust-text2,   #9ba3c7);
  --primary: var(--cust-primary, #1CB0F6);
  --primary-d: var(--cust-primary-d, #1490c4);
}

/* ══ HOME USER CARD ═════════════════════════════════════════════════════════ */
.home-user-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
}
.home-user-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--indigo));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; color: #fff;
}
.home-user-name { font-size: .95rem; font-weight: 700; color: var(--text); }
.home-user-meta { font-size: .78rem; color: var(--text2); margin-top: 2px; }

/* ══ NEW SETTINGS LAYOUT ════════════════════════════════════════════════════ */
#screen-settings.active { height: 100vh; height: 100dvh; min-height: unset; overflow: hidden; padding-bottom: 0; }
.sett-wrap { display: flex; flex-direction: column; flex: 1; overflow: hidden; height: 100%; }

/* Mobile tabs */
.sett-tabs {
  display: flex; gap: 4px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg2);
  overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
}
.sett-tabs::-webkit-scrollbar { display: none; }
.sett-tab {
  padding: 7px 14px; border-radius: 20px; font-size: .8rem; font-weight: 600;
  color: var(--text2); background: transparent; border: 1px solid transparent;
  white-space: nowrap; flex-shrink: 0; cursor: pointer; transition: all var(--trans);
}
.sett-tab.active { background: rgba(28,176,246,.12); border-color: rgba(28,176,246,.25); color: var(--primary); }

/* Desktop sidenav */
.sett-sidenav { display: none; }
@media (min-width: 680px) {
  .sett-tabs { display: none; }
  .sett-wrap { flex-direction: row; }
  .sett-sidenav {
    display: flex; flex-direction: column; gap: 3px;
    width: 200px; flex-shrink: 0;
    background: var(--bg2); border-right: 1px solid var(--border);
    padding: 18px 12px;
  }
  .sett-sidenav-hdr {
    font-size: .62rem; font-weight: 800; color: var(--text3);
    text-transform: uppercase; letter-spacing: .1em;
    padding: 0 12px; margin-bottom: 8px;
  }
}
.sett-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 9px; font-size: .875rem; cursor: pointer;
  color: var(--text2); font-weight: 500; border: 1px solid transparent;
  text-align: left; width: 100%; transition: all var(--trans);
}
.sett-nav-item:hover { background: var(--bg3); color: var(--text); }
.sett-nav-item.active { background: rgba(28,176,246,.12); border-color: rgba(28,176,246,.25); color: var(--primary); font-weight: 700; }

/* Content pane */
.sett-content { flex: 1; overflow-y: auto; position: relative; }
.sett-section {
  display: none; padding: 28px 28px 80px;
  flex-direction: column; gap: 24px; max-width: 760px;
}
.sett-section.active { display: flex; animation: screenIn .2s ease; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 679px) { .sett-section { padding: 20px 16px 96px; } }
.sett-section-hdr { margin-bottom: 4px; }
.sett-section-hdr h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 3px; }
.sett-section-hdr p { font-size: .85rem; color: var(--text2); }
.sett-grp { display: flex; flex-direction: column; gap: 10px; }
.sett-grp-lbl { font-size: .72rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }

/* Theme preset buttons */
.theme-preset-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
@media (max-width: 479px) { .theme-preset-grid { grid-template-columns: repeat(2,1fr); } }
.theme-preset-btn {
  background: var(--card); border: 1.5px solid var(--border2);
  color: var(--text); border-radius: 10px; padding: 14px 8px;
  font-size: .85rem; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: all var(--trans);
}
.theme-preset-btn:hover { border-color: var(--primary); }
.theme-preset-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(28,176,246,.08); }

/* Custom theme editor */
.custom-theme-editor {
  display: none; background: var(--card); border: 1px solid rgba(28,176,246,.4);
  border-radius: 14px; padding: 20px; flex-direction: column; gap: 20px;
}
.custom-theme-editor.visible { display: flex; }
.palette-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
@media (max-width: 479px) { .palette-grid { grid-template-columns: repeat(2,1fr); } }
.palette-btn {
  border-radius: 10px; padding: 10px 10px 9px; cursor: pointer;
  border: 2px solid transparent; transition: border-color var(--trans); text-align: left;
}
.palette-btn:hover { border-color: rgba(255,255,255,.25); }
.palette-btn.active { border-color: var(--primary) !important; }
.palette-swatches { display: flex; gap: 3px; margin-bottom: 7px; }
.palette-swatch { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(255,255,255,.1); }
.palette-name { font-size: .72rem; font-weight: 700; }
.color-picker-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
@media (max-width: 479px) { .color-picker-grid { grid-template-columns: repeat(2,1fr); } }
.color-pick-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.color-pick-item input[type=color] {
  width: 28px; height: 28px; border: none; background: none;
  cursor: pointer; border-radius: 4px; padding: 0; flex-shrink: 0;
}
.color-pick-label { font-size: .78rem; color: var(--text2); flex: 1; }

/* Profile card */
.profile-card {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px;
}
.profile-avatar {
  width: 60px; height: 60px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--indigo));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700; color: #fff;
}
.profile-details { flex: 1; min-width: 0; }
.profile-name-input {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  background: transparent; border: none; border-bottom: 1.5px solid var(--border);
  outline: none; padding: 2px 0 4px; width: 100%; font-family: inherit;
  transition: border-color .2s;
}
.profile-name-input:focus { border-color: var(--primary); }
.profile-name-input::placeholder { color: var(--text3); font-weight: 400; }
.profile-meta { font-size: .78rem; color: var(--text2); margin-top: 6px; }

/* Action buttons */
.sett-action-btn {
  width: 100%; padding: 15px 20px; border-radius: 12px; font-size: .95rem;
  font-weight: 600; font-family: inherit; text-align: left; cursor: pointer;
  background: var(--bg3); border: 1.5px solid var(--border2); color: var(--text);
  transition: all var(--trans); display: flex; align-items: center; gap: 10px;
}
.sett-action-btn:hover { border-color: var(--border); background: var(--card); }
.sett-action-danger { background: rgba(255,75,75,.08); border-color: rgba(255,75,75,.3); color: var(--red); }
.sett-action-danger:hover { background: rgba(255,75,75,.14); border-color: var(--red); }

/* ══ EDITOR BOTTOM BAR (language + run) ════════════════════════════════════ */
.editor-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--editor-bottom-bar-h);
  min-height: var(--editor-bottom-bar-h);
  padding: 0 12px;
  background: var(--bg3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  flex-wrap: wrap;
}
.editor-bottom-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 260px;
}
.editor-bottom-bar .btn-run,
.editor-bottom-bar .btn-check {
  padding: 10px 16px;
  font-size: .86rem;
  flex: 0 0 auto;
  width: 148px;
}
.editor-bottom-bar .btn-tables {
  width: 148px;
}
.editor-bottom-bar .btn-icon-sm {
  padding: 9px 12px;
  font-size: .86rem;
  border-radius: 10px;
}
.lang-select-drop {
  background-color: var(--bg2);
  color: var(--text);
  border: 1.5px solid var(--border2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: .86rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--trans);
}
.lang-select-drop:hover, .lang-select-drop:focus { border-color: var(--primary); }
.lang-select-drop option { background: var(--bg2); color: var(--text); }

.lang-select-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.lang-dd {
  position: relative;
  flex: 0 0 auto;
}
.lang-dd-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 168px;
  max-width: 168px;
  padding: 10px 36px 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border2);
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  position: relative;
  transition: border-color var(--trans);
}
.lang-dd-btn:hover,
.lang-dd-btn:focus { border-color: var(--primary); outline: none; }
.lang-dd-btn::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M7 10l5 5 5-5' stroke='%239ba3c7' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  opacity: .9;
}
.lang-dd-btn img { width: 16px; height: 16px; flex-shrink: 0; }
.lang-dd-btn img { display: block; }
.lang-dd-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 220px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 50;
}
.lang-dd.open .lang-dd-menu { display: block; }
.lang-dd-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.lang-dd-item:hover { background: var(--bg3); border-color: var(--border); }
.lang-dd-item img { width: 16px; height: 16px; flex-shrink: 0; }
.lang-dd-item img { display: block; }

/* ══ OUTPUT TOOLBAR (above output panel) ════════════════════════════════════ */
.output-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  justify-content: flex-end;
}
.output-toolbar .btn-icon-sm {
  padding: 6px 10px;
  font-size: .8rem;
}
.output-toolbar .runtime-badge {
  margin-right: auto;
}

/* ══ SANDBOX HEADER CENTERED LOGO ═══════════════════════════════════════════ */
.sandbox-header {
  position: relative;
  justify-content: space-between;
}
.sandbox-logo-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: .9rem;
  font-weight: 700;
  color: var(--text2);
  pointer-events: none;
}
.sandbox-header-spacer {
  width: 80px; /* balances the back button width */
}

/* ══ OUTPUT SECTION + AI CHAT PANEL ════════════════════════════════════════ */
.output-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 80px;
}
.output-section .output-panel {
  flex: 1;
  max-height: none;
}
.output-section .test-results {
  flex-shrink: 0;
}

/* Resize drag handle */
.ai-resize-handle {
  height: 7px;
  background: var(--bg3);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.ai-resize-handle::after {
  content: '';
  width: 36px;
  height: 3px;
  background: var(--border2);
  border-radius: 3px;
}
.ai-resize-handle:hover { background: rgba(28,176,246,.08); }
.ai-resize-handle:hover::after { background: var(--primary); }

/* Inline AI chat panel */
.ai-chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 120px;
  overflow: hidden;
  background: var(--bg2);
  border-top: none;
  flex-shrink: 0;
}
.ai-chat-hdr {
  padding: 6px 12px;
  font-size: .72rem;
  font-weight: 700;
  color: var(--purple);
  background: rgba(206,130,255,.07);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  letter-spacing: .03em;
}
.ai-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .8rem;
}
.ai-chat-msg {
  max-width: 92%;
  padding: 7px 11px;
  border-radius: 10px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.ai-chat-msg.user {
  background: rgba(28,176,246,.15);
  color: var(--primary);
  align-self: flex-end;
  border: 1px solid rgba(28,176,246,.25);
  border-bottom-right-radius: 3px;
}
.ai-chat-msg.ai {
  background: var(--bg3);
  color: var(--text);
  align-self: flex-start;
  border: 1px solid var(--border2);
  border-bottom-left-radius: 3px;
}
.ai-chat-msg.loading {
  opacity: .65;
  font-style: italic;
  color: var(--text2);
}
.ai-bottom-bar {
  background: var(--bg3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  height: var(--editor-bottom-bar-h);
  min-height: var(--editor-bottom-bar-h);
  padding: 0 12px;
  display: flex;
  align-items: center;
}

.ai-chat-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 0;
  padding: 0;
  border-top: none;
  background: transparent;
  flex-shrink: 0;
  width: 100%;
}
.ai-chat-input {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: .8rem;
  font-family: inherit;
  outline: none;
}
.ai-chat-input:focus { border-color: var(--primary); }
.ai-chat-input::placeholder { color: var(--text3); }
.ai-chat-send {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--trans);
}
.ai-chat-send:hover { background: var(--primary-d); }

/* ══ SQL TABLES MODAL ════════════════════════════════════════════════════════ */
.sql-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.sql-modal-sheet {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 18px;
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop .25s cubic-bezier(.34,1.56,.64,1);
}
.sql-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.sql-modal-desc {
  padding: 10px 20px;
  font-size: .8rem;
  color: var(--text2);
  line-height: 1.5;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.sql-modal-editor {
  flex: 1;
  background: var(--editor-bg);
  color: var(--text);
  border: none;
  outline: none;
  padding: 14px 20px;
  font-family: "Fira Code", "Consolas", monospace;
  font-size: .82rem;
  line-height: 1.6;
  resize: none;
  min-height: 240px;
}
.sql-modal-editor::placeholder { color: var(--text3); }

/* ══ MOBILE OVERRIDES ═══════════════════════════════════════════════════════ */
@media (max-width: 679px) {
  #sidebar { display: none !important; }
  #app { padding-left: 0 !important; margin-left: 0 !important; }
  .screen { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav { display: flex !important; }
}
@media (min-width: 680px) {
  .bottom-nav { display: none !important; }
}

/* ══ CODEMIRROR OVERRIDES ════════════════════════════════════════════════════ */
.CodeMirror {
  height: 100%;
  width: 100%;
  font-family: "Fira Code", "Consolas", monospace;
  font-size: 14px;
  line-height: 1.6;
}
.CodeMirror-scroll { height: 100%; }
#editor, #sandbox-editor { height: 100%; overflow: hidden; }
