:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #1f2340;
  --muted: #6b7090;
  --border: #e3e6f0;
  --primary: #7a2fd0;
  --primary-soft: #f3eaff;
  --accent: #ffa21f;
  --accent-soft: #fff3de;
  --brand-grad: linear-gradient(135deg, #6a24c4 0%, #9b3fd6 48%, #ff9f1c 100%);
  --python: #3776ab;
  --python-soft: #e6f0fa;
  --scratch: #f28c1b;
  --scratch-soft: #fff1e0;
  --web: #e34c26;
  --network: #0b7a85;
  --network-soft: #e1f4f5;
  --web-soft: #fdebe6;
  --ok: #1f9d55;
  --ok-soft: #e3f6eb;
  --bad: #d64545;
  --bad-soft: #fde8e8;
  --warn: #c98a00;
  --warn-soft: #fff6d9;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 35, 64, .06);
  --sidebar: 240px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
code, pre, .mono { font-family: "JetBrains Mono", Consolas, monospace; font-size: .92em; }
pre { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow-x: auto; margin: 0; white-space: pre-wrap; }
:not(pre) > code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; padding: 4px 10px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 600;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav .ico { width: 22px; text-align: center; }
.nav-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 12px 4px; font-weight: 700; }
.badge { margin-left: auto; background: var(--bad); color: #fff; font-size: .72rem; border-radius: 999px; padding: 1px 8px; font-weight: 700; }
.sidebar-credit { padding: 4px 10px 0; font-size: .72rem; color: var(--muted); }
.sidebar-credit a { color: var(--muted); font-weight: 700; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--border); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: 1rem; }
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1200px; }
.topbar { display: none; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; background: var(--primary); color: #fff; text-decoration: none; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.accent { background: var(--accent); color: #3a1a00; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.python { background: var(--python); }
.btn.scratch { background: var(--scratch); }
.btn.sm { padding: 6px 12px; font-size: .875rem; }

input[type=text], input[type=password], input[type=url], input[type=number], input[type=email], input[type=tel], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.errorlist { color: var(--bad); margin: 4px 0; padding-left: 18px; font-size: .875rem; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.pill.python { background: var(--python-soft); color: var(--python); }
.pill.scratch { background: var(--scratch-soft); color: var(--scratch); }
.pill.ok, .pill.accepted { background: var(--ok-soft); color: var(--ok); }
.pill.bad, .pill.wrong, .pill.rejected { background: var(--bad-soft); color: var(--bad); }
.pill.pending { background: var(--warn-soft); color: var(--warn); }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { background: var(--ok-soft); color: var(--ok); padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.messages li.error { background: var(--bad-soft); color: var(--bad); }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.python > span { background: var(--python); }
.progress.scratch > span { background: var(--scratch); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* Home */
.dash-hero { background: var(--brand-grad); color: #fff; border: 0; padding: 28px 32px; }
.dash-hero h1 { margin: 0 0 8px; }
.dash-hero h1 { color: #fff; }
.dash-hero .muted { color: rgba(255,255,255,.85); }
.stat { text-align: left; }
.stat .num { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .875rem; font-weight: 600; }
.track-card { border-top: 4px solid var(--python); }
.track-card.scratch { border-top-color: var(--scratch); }
.level-row { display: grid; grid-template-columns: 26px 1fr 60px; gap: 10px; align-items: center; font-size: .875rem; padding: 3px 0; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }

/* Problem list */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 8px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 700; }
.tab:hover { text-decoration: none; border-color: var(--primary); }
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.tab.python.active { background: var(--python); border-color: var(--python); }
.tab.scratch.active { background: var(--scratch); border-color: var(--scratch); }
.levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.level-card { background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: 10px 12px; color: var(--text); }
.level-card:hover { text-decoration: none; border-color: var(--primary); }
.level-card.active { border-color: var(--primary); background: var(--primary-soft); }
.level-card .t { font-weight: 800; font-size: .9rem; }
.level-card .n { font-size: .78rem; color: var(--muted); margin-bottom: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; color: var(--text); display: flex; flex-direction: column; gap: 2px;
  min-height: 78px; position: relative;
}
.tile:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow); }
.tile .no { font-weight: 800; font-size: .85rem; color: var(--muted); }
.tile .tt { font-size: .85rem; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .st { position: absolute; top: 8px; right: 10px; font-size: .9rem; }
.tile.solved { background: var(--ok-soft); border-color: #b7e4c7; }
.tile.tried { background: var(--bad-soft); border-color: #f5c2c2; }
.tile.pending { background: var(--warn-soft); border-color: #f1dd9d; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }

/* Problem detail */
.problem-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.md h3 { margin-top: 1.1em; font-size: 1rem; }
.md p { margin: .5em 0; }
.md img { max-width: 100%; }
.samples { display: grid; gap: 10px; }
.sample { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sample .lbl { font-size: .75rem; font-weight: 800; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.editor-wrap .CodeMirror { height: 360px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; }
#code { min-height: 360px; font-family: Consolas, monospace; }
.lang-tabs { margin: 0; }
.lang-tabs .tab { font: inherit; font-weight: 700; cursor: pointer; padding: 6px 14px; }
.lang-tabs .tab[data-lang="python"].active { background: var(--python); border-color: var(--python); }
.lang-tabs .tab[data-lang="javascript"].active { background: #c9a400; border-color: #c9a400; }
.lang-tabs .tab[data-lang="blocks"].active { background: var(--scratch); border-color: var(--scratch); }
.code-tabs .tab { font: inherit; font-weight: 700; cursor: pointer; padding: 6px 14px; }
#blockly { height: 460px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.code-view { background: #1e2033; color: #e8e9f3; border-radius: 10px; padding: 12px 14px; margin: 10px 0 0; max-height: 360px; overflow: auto; font-family: Consolas, monospace; font-size: .85rem; white-space: pre; }
.select-sm { width: auto; padding: 6px 10px; font-size: .875rem; }
.translate-panel { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.console { background: #1e2033; color: #e8e9f3; border-radius: 10px; padding: 12px 14px; min-height: 60px; white-space: pre-wrap; font-family: Consolas, monospace; font-size: .9rem; }
.console.err { color: #ffb3b3; }
.results { display: grid; gap: 8px; }
.result { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.result.ok { border-color: #b7e4c7; background: var(--ok-soft); }
.result.bad { border-color: #f5c2c2; background: var(--bad-soft); }
.banner { padding: 14px 16px; border-radius: 12px; font-weight: 800; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.pending { background: var(--warn-soft); color: var(--warn); }
.blocks-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; overflow-x: auto; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choice { padding: 10px 18px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); font: inherit; font-weight: 700; cursor: pointer; color: var(--text); }
.choice:hover { border-color: var(--scratch); }
.choice.selected { border-color: var(--scratch); background: var(--scratch-soft); }
.solution { margin-top: 10px; }
.solution summary { cursor: pointer; font-weight: 700; color: var(--muted); }

/* Chat */
.chat { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 120px); min-height: 480px; padding: 0; overflow: hidden; }
.chat-rooms { border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.chat-rooms .head { padding: 14px 16px; font-weight: 800; border-bottom: 1px solid var(--border); }
.room-link { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--text); border-bottom: 1px solid var(--border); }
.room-link:hover { background: var(--surface-2); text-decoration: none; }
.room-link.active { background: var(--primary-soft); }
.room-link .name { font-weight: 700; font-size: .95rem; }
.room-link .sub { font-size: .78rem; color: var(--muted); }
.new-chat { padding: 12px 16px; margin-top: auto; border-top: 1px solid var(--border); }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 800; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--surface); border: 1px solid var(--border); padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.mine .bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.msg .meta { font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.msg.mine .meta { text-align: right; }
.msg .teacher-tag { color: var(--primary); font-weight: 800; }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form textarea { resize: none; height: 46px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Lessons */
.course { border-left: 4px solid var(--python); }
.course.scratch { border-left-color: var(--scratch); }
.lesson-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.lesson-link:hover { background: var(--surface-2); text-decoration: none; }
.lesson-link .chk { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: .8rem; flex-shrink: 0; }
.lesson-link.done .chk { background: var(--ok); border-color: var(--ok); color: #fff; }
.lesson-body { font-size: 1.05rem; }
.lesson-body .md h2 { margin-top: 1.4em; }
.lesson-body pre { margin: 10px 0; }
.video { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; margin-bottom: 16px; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Avatars picker */
.avatar-pick ul, .avatar-pick > div { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.avatar-pick label { font-size: 1.6rem; border: 2px solid var(--border); border-radius: 12px; padding: 4px 10px; cursor: pointer; font-weight: 400; }
.avatar-pick input { display: none; }
.avatar-pick label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--brand-grad); }
.login-page { grid-template-rows: 1fr auto; }
.login-card { width: 100%; max-width: 400px; align-self: center; }
.login-credit { margin: 16px 0 0; font-size: .8rem; color: rgba(255, 255, 255, .85); text-align: center; }
.login-credit a { color: #fff; font-weight: 700; }
.login-card .brand { justify-content: center; padding-bottom: 6px; }

@media (max-width: 1000px) {
  .problem-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; }
  .sidebar.open { display: flex; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
  .main { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-rooms { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--border); }
  .chat-log { min-height: 50vh; }
  .sample { grid-template-columns: 1fr; }
  .msg { max-width: 92%; }
}

/* ---------------------------------------------------------------- Collapsible sidebar */
.sidebar-head { display: flex; align-items: center; gap: 4px; }
.sidebar-head .brand { flex: 1; min-width: 0; }
.nav-collapse { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; width: 28px; height: 28px; cursor: pointer; color: var(--muted); font-weight: 800; flex-shrink: 0; margin-bottom: 14px; }
.nav-collapse:hover { color: var(--primary); border-color: var(--primary); }
.nav a { position: relative; }
@media (min-width: 761px) {
  .sidebar { transition: width .15s ease; }
  .nav-collapsed .sidebar { width: 72px; padding: 20px 10px; overflow: hidden; }
  .nav-collapsed .sidebar-head { flex-direction: column; }
  .nav-collapsed .brand { padding: 4px 0 8px; justify-content: center; }
  .nav-collapsed .nav-collapse { transform: rotate(180deg); }
  .nav-collapsed .brand-name, .nav-collapsed .lbl, .nav-collapsed .nav-label, .nav-collapsed .sidebar-credit, .nav-collapsed .sidebar-user .who { display: none; }
  .nav-collapsed .nav a { justify-content: center; padding: 10px 0; }
  .nav-collapsed .nav .ico { font-size: 1.15rem; }
  .nav-collapsed .nav .badge { position: absolute; top: 2px; right: 2px; padding: 0 5px; }
  .nav-collapsed .sidebar-user { justify-content: center; padding: 10px 0; }
  .nav-collapsed .main { max-width: 1400px; }
}

/* ---------------------------------------------------------------- Editor: blocks get the full width */
.blocks-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.blocks-side .code-view { max-height: calc(70vh - 50px); }
#blockly { height: max(460px, 70vh); }
.problem-layout.blocks-mode { grid-template-columns: minmax(0, 1fr); }
.problem-layout.blocks-mode .samples { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
@media (max-width: 1100px) {
  .blocks-editor { grid-template-columns: minmax(0, 1fr); }
  .blocks-side .code-view { max-height: 240px; }
}

/* ---------------------------------------------------------------- Public site */
.main-public { max-width: 1200px; margin: 0 auto; width: 100%; }
.pub-inner { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.pub-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.pub-header .pub-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.pub-header .brand { padding: 0; }
.pub-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.pub-nav > a { color: var(--text); font-weight: 700; padding: 8px 10px; border-radius: 8px; }
.pub-nav > a:hover { background: var(--surface-2); text-decoration: none; }
.pub-actions { display: flex; gap: 8px; margin-left: 8px; }
.pub-toggle { display: none; margin-left: auto; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn.ghost { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .6); }

.hero { background: var(--brand-grad); color: #fff; padding: 56px 0 64px; }
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); margin: 14px 0; }
.hero-text { font-size: 1.15rem; opacity: .95; max-width: 34em; }
.hero-tag { display: inline-block; background: rgba(255, 255, 255, .18); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .9rem; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.hero-art { display: grid; gap: 14px; }
.hero-card { background: #fff; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); }
.hb { color: #fff; font-weight: 800; font-size: .95rem; padding: 8px 14px; border-radius: 10px; }
.hb-1 { background: #ffbf00; border-radius: 16px 16px 10px 10px; }
.hb-2 { background: #ffab19; }
.hb-3 { background: #4c97ff; margin-left: 18px; }
.hb-4 { background: #9966ff; margin-left: 18px; }
.hero-code { background: #1e2033; color: #e8e9f3; border-radius: 18px; padding: 18px 20px; font-size: .95rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); }
.hero-code .k { color: #ff9ac1; }
.hero-code .s { color: #9be89b; }

.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: -28px; position: relative; }
.stats-strip > div { background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); text-align: center; }
.stats-strip strong { display: block; font-size: 1.6rem; color: var(--primary); }
.stats-strip span { color: var(--muted); font-size: .9rem; font-weight: 600; }

.section { padding-top: 48px; padding-bottom: 48px; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: 18px; }
.about-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: start; }
.about-grid .md { font-size: 1.05rem; }
.features { display: grid; gap: 12px; }
.feature { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.feature > span { font-size: 1.8rem; line-height: 1; }
.feature p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }

.offer-grid, .news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.offer { display: flex; flex-direction: column; gap: 8px; }
.offer + .offer { margin-top: 0; }
.offer-head { display: flex; gap: 12px; align-items: center; }
.offer-head h3 { margin: 0 0 4px; }
.offer-emoji { font-size: 2rem; width: 52px; height: 52px; display: grid; place-items: center; background: var(--primary-soft); border-radius: 14px; flex-shrink: 0; }
.offer p { margin: 0; color: var(--muted); }
.offer-facts { list-style: none; padding: 0; margin: 0 0 6px; font-size: .92rem; display: grid; gap: 3px; }
.offer .btn { margin-top: auto; }

.schedule { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.day + .day { margin-top: 0; }
.day h3 { margin: 0 0 10px; color: var(--primary); }
.slot { display: flex; gap: 12px; padding: 8px 0; border-top: 1px dashed var(--border); }
.slot-time { font-weight: 800; white-space: nowrap; min-width: 92px; }

.news-card { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.news-card + .news-card { margin-top: 0; }
.news-card:hover { text-decoration: none; border-color: var(--primary); }
.news-emoji { font-size: 1.8rem; }
.news-list { display: grid; gap: 12px; }
.news-row { display: flex; gap: 14px; color: var(--text); }
.news-row + .news-row { margin-top: 0; }
.news-row:hover { text-decoration: none; border-color: var(--primary); }
.article { max-width: 760px; }
.article .lead { font-size: 1.15rem; color: var(--muted); }

.try-box { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: linear-gradient(135deg, var(--python-soft), var(--scratch-soft)); border-radius: 20px; padding: 28px; }
.try-box h2 { margin: 0 0 6px; }
.try-box p { margin: 0; max-width: 36em; }
.try-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.enroll-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 32px; align-items: start; }
.enroll-points { list-style: none; padding: 0; display: grid; gap: 8px; }
.enroll-form .banner { margin-bottom: 12px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 700; margin-bottom: 4px; font-size: .92rem; }
.field .req { color: var(--bad); }
.field-error { color: var(--bad); font-size: .85rem; margin-top: 3px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.field input, .field select, .field textarea { width: 100%; }

.pub-footer { background: #1e2033; color: #c9cbe0; padding: 36px 0 20px; }
.pub-footer a { color: #fff; }
.pub-footer strong { color: #fff; display: block; margin-bottom: 6px; }
.pub-footer .brand { color: #fff; }
.pub-footer .muted { color: #9a9cb8; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; }
.footer-grid > div > div { margin: 3px 0; }
.footer-credit { margin-top: 24px; padding-top: 16px; border-top: 1px solid #34375a; font-size: .82rem; color: #9a9cb8; }
.main-public + .pub-footer, .article + .pub-footer, .section + .pub-footer { margin-top: 40px; }

.request-list { display: grid; gap: 12px; }
.request + .request { margin-top: 0; }
.request-info { display: grid; gap: 3px; margin: 8px 0; }
.request textarea { width: 100%; }
.tile.locked { opacity: .55; }
.lock-note { background: var(--warn-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }

@media (max-width: 900px) {
  .pub-toggle { display: inline-flex; }
  .pub-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; box-shadow: var(--shadow); }
  .pub-nav.open { display: flex; }
  .pub-nav > a { padding: 12px 10px; font-size: 1.05rem; }
  .pub-actions { margin: 8px 0 0; }
  .pub-actions .btn { flex: 1; justify-content: center; }
  .hero { padding: 36px 0 52px; }
  .hero-grid, .about-grid, .enroll-grid, .footer-grid { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .pub-inner { padding: 0 16px; }
  .section { padding-top: 32px; padding-bottom: 32px; }
  .hero-cta .btn, .try-actions .btn { flex: 1; text-align: center; justify-content: center; }
  .form-2 { grid-template-columns: 1fr; }
  .editor-wrap .CodeMirror { height: 280px; }
  #blockly { height: 62vh; min-height: 380px; }
  .kbd-hint { display: none; }
  .btn { min-height: 42px; }
  .lang-tabs .tab { padding: 6px 10px; font-size: .92rem; }
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming into fields */
}

/* ---------------------------------------------------------------- Celebration */
.celebrate { position: fixed; inset: 0; z-index: 900; background: rgba(31, 35, 64, .45); display: grid; place-items: center; padding: 16px; animation: cl-fade .2s ease; }
.celebrate-card { position: relative; background: var(--surface); border-radius: 22px; padding: 28px 24px 22px; width: min(420px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: cl-pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.celebrate-card h2 { font-size: 1.7rem; margin: 6px 0 8px; }
.celebrate-card p { margin: 6px 0; }
.celebrate-emoji { font-size: 4rem; line-height: 1; animation: cl-bounce 1s ease .3s 2; }
.celebrate-points { display: inline-block; background: var(--warn-soft); color: var(--warn); font-weight: 800; font-size: 1.3rem; border-radius: 999px; padding: 6px 18px; margin: 4px 0 6px; }
.celebrate-milestone { font-weight: 800; color: var(--primary); }
.celebrate-guest { background: var(--primary-soft); border-radius: 12px; padding: 10px 12px; }
.celebrate-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.celebrate-sound { position: absolute; top: 10px; right: 12px; background: none; border: 0; font: inherit; font-size: .8rem; color: var(--muted); cursor: pointer; }
@keyframes cl-fade { from { opacity: 0; } }
@keyframes cl-pop { from { transform: scale(.7); opacity: 0; } }
@keyframes cl-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px) rotate(-6deg); } 70% { transform: translateY(0) rotate(4deg); } }
@media (prefers-reduced-motion: reduce) {
  .celebrate, .celebrate-card, .celebrate-emoji { animation: none; }
}

/* ---------------------------------------------------------------- Erdenet / online / phone */
.pub-phone { font-weight: 800; color: var(--text); background: var(--ok-soft); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.pub-phone:hover { text-decoration: none; background: #cdeedb; }
.online { background: linear-gradient(135deg, #fff8ec 0%, #eef0ff 100%); }
.online-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: center; }
.online-lead { font-size: 1.12rem; }
.free-badge { display: inline-block; background: var(--ok); color: #fff; font-weight: 800; letter-spacing: .06em; border-radius: 10px; padding: 6px 14px; margin-bottom: 12px; transform: rotate(-2deg); box-shadow: 0 6px 16px rgba(31, 157, 85, .3); }
.online-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.online-list li { display: flex; gap: 14px; background: var(--surface); border-radius: 14px; padding: 14px; border: 1px solid var(--border); }
.online-list li > span { font-size: 1.7rem; line-height: 1; }
.online-list p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.call-card { display: inline-flex; align-items: center; gap: 14px; background: var(--ok); color: #fff; border-radius: 16px; padding: 14px 22px; margin: 4px 0 14px; box-shadow: 0 8px 20px rgba(31, 157, 85, .25); }
.call-card:hover { text-decoration: none; filter: brightness(1.05); }
.call-card > span:first-child { font-size: 1.8rem; }
.call-card small { display: block; opacity: .9; font-weight: 700; }
.call-card strong { font-size: 1.6rem; letter-spacing: .03em; }
.btn.secondary.btn-lg { color: var(--text); }

/* ---------------------------------------------------------------- Logic games */
.games-hero { background: linear-gradient(135deg, #4c97ff, #9966ff); color: #fff; border-radius: 20px; padding: 24px; margin-bottom: 18px; }
.games-hero h1 { margin: 0 0 6px; }
.games-hero p { margin: 0; opacity: .95; }
.game-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.game-card { color: var(--text); display: flex; flex-direction: column; gap: 6px; }
.game-card + .game-card { margin-top: 0; }
.game-card:hover { text-decoration: none; border-color: var(--primary); }
.game-card h2 { margin: 0; }
.game-card p { margin: 0 0 8px; color: var(--muted); }
.game-emoji { font-size: 3rem; line-height: 1; }
.game-top { margin-bottom: 12px; }
.level-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.level-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface); border: 2px solid var(--border); color: var(--text); }
.level-dot:hover { text-decoration: none; border-color: var(--primary); }
.level-dot.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.level-dot.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.level-dot.locked { opacity: .4; cursor: not-allowed; }
.game-layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
.game-left + .game-right { margin-top: 0; }
.game-left h2 { margin-bottom: 6px; }
.level-hint { background: var(--warn-soft); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.stage { border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.robot-svg, .turtle-canvas { display: block; width: 100%; height: auto; }
.cell-ground { fill: #eaf6d6; stroke: #dbeec2; }
.cell-rock { fill: #c9b8a6; stroke: #bba792; }
.cell-emoji { font-size: 24px; text-anchor: middle; dominant-baseline: central; }
.cell-emoji.rock { font-size: 20px; }
.cell-emoji.taken { opacity: 0; transition: opacity .3s; }
.bot { transition: transform .2s ease; }
.bot-body { font-size: 26px; }
.bot-arrow { fill: var(--primary); transition: transform .15s; }
.bot.crash .bot-body { animation: cl-shake .3s 2; }
@keyframes cl-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.game-controls { margin-top: 12px; }
.game-msg { margin-top: 10px; font-weight: 700; min-height: 1.5em; }
.game-msg.ok { color: var(--ok); }
.game-msg.bad { color: var(--bad); }
.game-msg.pending { color: var(--muted); }
#game-blockly { height: max(480px, calc(100vh - 220px)); margin-top: 10px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
#block-count.full { background: var(--warn-soft); color: var(--warn); }
.celebrate-message { font-weight: 700; }
@media (max-width: 900px) {
  .online-grid, .game-layout { grid-template-columns: 1fr; }
  #game-blockly { height: 60vh; min-height: 380px; }
}
@media (max-width: 760px) {
  .pub-phone { margin-left: auto; padding: 6px 10px; font-size: .9rem; }
  .pub-toggle { margin-left: 6px; }
  .call-card { width: 100%; justify-content: center; }
}
@media (max-width: 420px) {
  .pub-header .brand-name { display: none; }
}

/* Public header: keep it on one line, switch to the menu button earlier */
.pub-header .pub-inner { max-width: 1340px; }
.pub-header .brand { white-space: nowrap; }
.pub-nav { flex-wrap: nowrap; }
.pub-nav > a { padding: 8px 9px; white-space: nowrap; }
@media (max-width: 1280px) {
  .pub-toggle { display: inline-flex; }
  .pub-phone { margin-left: auto; }
  .pub-toggle { margin-left: 8px; }
  .pub-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; box-shadow: var(--shadow); }
  .pub-nav.open { display: flex; }
  .pub-nav > a { padding: 12px 10px; font-size: 1.05rem; }
  .pub-actions { margin: 8px 0 0; }
  .pub-actions .btn { flex: 1; justify-content: center; }
}

.hero-note { display: inline-block; background: rgba(255, 255, 255, .16); border-radius: 12px; padding: 8px 14px; margin: 4px 0 0; font-weight: 700; }
.schedule-facts { display: flex; flex-wrap: wrap; gap: 10px; margin: -4px 0 18px; }
.schedule-facts > span { background: var(--primary-soft); color: var(--text); border-radius: 999px; padding: 8px 16px; }

/* ---------------------------------------------------------------- HTML/CSS track */
.pill.web { background: var(--web-soft); color: var(--web); }
.btn.web { background: var(--web); }
.tab.web.active { background: var(--web); border-color: var(--web); }
.progress.web span { background: var(--web); }
.track-card.web { border-top: 4px solid var(--web); }
.web-levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.web-preview { width: 100%; height: 320px; border: 1px solid var(--border); border-radius: 10px; background: #fff; display: block; }
.checklist { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: .92rem; }
.checklist li.ok { background: var(--ok-soft); }
.checklist li.bad { background: var(--bad-soft); }
.checklist .mark { flex-shrink: 0; width: 1.4em; text-align: center; }
@media (max-width: 760px) {
  .web-levels { grid-template-columns: 1fr; }
  .web-preview { height: 260px; }
}

/* ---------------------------------------------------------------- Networking track */
.pill.network { background: var(--network-soft); color: var(--network); }
.btn.network { background: var(--network); }
.tab.network.active { background: var(--network); border-color: var(--network); }
.progress.network span { background: var(--network); }
.track-card.network { border-top: 4px solid var(--network); }
.stats-auto { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ---------------------------------------------------------------- Cable crimping game */
.crimp-guide { margin: 0 0 12px; }
.guide-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.guide-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 800; font-size: .8rem; }
.crimp-ends { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.crimp-end { border: 2px solid var(--border); border-radius: 16px; padding: 12px; cursor: pointer; }
.crimp-end.active { border-color: var(--network); }
.plug { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; background: linear-gradient(#eef6f7, #d9ecee); border: 2px solid #a9cdd1;
  border-radius: 10px 10px 18px 18px; padding: 8px 6px 14px; margin: 8px 0 12px; }
.pin { min-height: 104px; border-radius: 6px; background: rgba(255, 255, 255, .7); border: 1px dashed #9bbfc3; display: flex; flex-direction: column;
  align-items: center; gap: 4px; padding-top: 2px; }
.pin.good { background: var(--ok-soft); border: 2px solid var(--ok); }
.pin.bad { background: var(--bad-soft); border: 2px solid var(--bad); }
.pin-no { font-weight: 800; font-size: .78rem; color: var(--muted); }
.pool { display: flex; flex-wrap: wrap; gap: 3.2em 32px; justify-content: center; }
.wire { --c: #888; width: 32px; height: 84px; border-radius: 8px; border: 2px solid rgba(0, 0, 0, .15); background: var(--c); cursor: pointer;
  position: relative; padding: 0; box-shadow: inset -4px 0 0 rgba(0, 0, 0, .12); }
.wire.striped { background: repeating-linear-gradient(160deg, #fbfbfb 0 7px, var(--c) 7px 13px); }
.wire:hover { transform: translateY(-3px); }
.wire.in-plug { width: 100%; height: 76px; border-radius: 4px; }
.wire.mini { width: 22px; height: 46px; cursor: default; }
.wire.mini:hover { transform: none; }
.wire-name { position: absolute; left: 50%; top: calc(100% + 4px); transform: translateX(-50%); width: 58px; font-size: .62rem; line-height: 1.15;
  text-align: center; white-space: normal; overflow-wrap: anywhere; color: var(--muted); display: none; }
.pool .wire-name { display: block; }
.pool { padding-bottom: 3em; }

/* ---------------------------------------------------------------- Network lab */
.net-layout { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.net-side + .net-main { margin-top: 0; }
.net-tools { margin-bottom: 10px; }
.net-tools .tab { font: inherit; font-weight: 700; cursor: pointer; padding: 6px 12px; }
.net-layout > * { min-width: 0; }  /* let the stage scroll inside its card instead of widening the page */
.net-stage-wrap { overflow-x: auto; border-radius: 14px; max-width: 100%; }
.net-stage { width: 100%; height: auto; display: block; background: #f7fafc; border: 1px solid var(--border); border-radius: 14px;
  background-image: radial-gradient(#dfe6ef 1px, transparent 1px); background-size: 20px 20px; }
.net-stage[data-mode="cable"] { cursor: crosshair; }
.net-stage[data-mode="delete"] { cursor: not-allowed; }
.cable { stroke: #3a7bd5; stroke-width: 4; stroke-linecap: round; }
.cable-hit { stroke: transparent; stroke-width: 18; cursor: pointer; }
.net-stage[data-mode="delete"] .net-link:hover .cable { stroke: var(--bad); }
.iface-label { font-size: 12px; font-weight: 800; fill: var(--network); text-anchor: middle; }
.net-dev { cursor: grab; touch-action: none; }  /* drag devices; swiping elsewhere scrolls the stage */
.net-dev .dev-body { fill: #fff; stroke: #c6d0dd; stroke-width: 2; }
.net-dev.switch .dev-body { fill: #e1f4f5; stroke: var(--network); }
.net-dev.router .dev-body { fill: #fff1e0; stroke: var(--scratch); }
.net-dev.server .dev-body { fill: #ecebff; stroke: var(--primary); }
.net-dev.selected .dev-body { stroke: var(--primary); stroke-width: 4; }
.net-dev.cabling .dev-body { stroke: var(--ok); stroke-width: 4; stroke-dasharray: 6 4; }
.dev-icon { font-size: 26px; text-anchor: middle; dominant-baseline: central; }
.dev-name { font-size: 13px; font-weight: 800; text-anchor: middle; fill: var(--text); }
.dev-ip { font-size: 11px; text-anchor: middle; fill: var(--muted); }
.packet { stroke: #fff; stroke-width: 2; }
.packet.go { fill: var(--ok); }
.packet.back { fill: var(--primary); }
.net-ping { margin-top: 10px; gap: 8px; }
.net-props h3 { margin: 0 0 8px; }
.net-field { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .9rem; }
.net-field input, .net-field select { width: 100%; }
.net-field input.invalid { border-color: var(--bad); background: var(--bad-soft); }
.net-port { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
@media (max-width: 900px) {
  .net-layout { grid-template-columns: minmax(0, 1fr); }
  .net-main { order: -1; }
}
@media (max-width: 760px) {
  .net-stage { min-width: 640px; }
  .pin { min-height: 84px; }
  .wire { width: 28px; height: 70px; }
  .wire.in-plug { height: 60px; }
}
#crimp-time:empty { display: none; }
.crimp-ends { grid-template-columns: repeat(auto-fit, minmax(300px, 520px)); }
.mobile-only { display: none; }
@media (max-width: 760px) { .mobile-only { display: block; } }
