:root {
  --bg: #0a0e16;
  --bg2: #0f1521;
  --panel: #131a28;
  --panel2: #182134;
  --line: #243049;
  --line2: #2f3d5c;
  --text: #dbe3f0;
  --muted: #8d9ab3;
  --dim: #5d6a84;
  --amber: #ffb547;
  --amber2: #ffcf85;
  --cyan: #5cc8ff;
  --green: #6ee7a8;
  --red: #ff6b6b;
  --pink: #ff8fc7;
  --purple: #b99bff;
  --orange: #ff9a5c;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --lh: 20px;
  --side: 270px;
  --ide-w: 46%;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); overflow: hidden; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code, kbd, pre { font-family: var(--mono); }

/* ---------- top bar ---------- */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: linear-gradient(180deg, #111829, #0d1320); border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; display: none; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none !important; }
.chip-logo { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 54px; height: 30px;
  background: #1b2232; border: 1px solid #39465f; border-radius: 4px; box-shadow: inset 0 0 0 2px #0e131e; }
.chip-logo b { font: 700 12px var(--mono); color: var(--amber); letter-spacing: 1px; }
.chip-logo i { position: absolute; width: 4px; height: 5px; background: #8f9bb3; }
.chip-logo i:nth-child(1) { top: -5px; left: 8px; } .chip-logo i:nth-child(2) { top: -5px; left: 24px; } .chip-logo i:nth-child(3) { top: -5px; left: 40px; }
.chip-logo i:nth-child(5) { bottom: -5px; left: 8px; } .chip-logo i:nth-child(6) { bottom: -5px; left: 24px; } .chip-logo i:nth-child(7) { bottom: -5px; left: 40px; }
.brand-text { font-weight: 800; font-size: 16px; line-height: 1.15; display: flex; flex-direction: column; }
.brand-text small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.progress-wrap { display: flex; align-items: center; gap: 8px; margin-left: 8px; }
.progress { width: 140px; height: 6px; background: #1d2638; border-radius: 4px; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: linear-gradient(90deg, var(--amber), var(--green)); transition: width .4s; }
#progressText { font: 600 12px var(--mono); color: var(--muted); }
.top-links { margin-left: auto; display: flex; gap: 4px; }
.top-links a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 500; font-size: 14px; }
.top-links a:hover, .top-links a.active { background: var(--panel2); color: var(--text); text-decoration: none; }
.mobile-tabs { display: none; }

/* ---------- layout ---------- */
.layout { display: flex; height: calc(100% - 56px); }
#sidebar { width: var(--side); flex: none; overflow-y: auto; background: var(--bg2); border-right: 1px solid var(--line); padding: 12px 10px 40px; }
#lesson { flex: 1 1 auto; min-width: 320px; overflow-y: auto; scroll-behavior: smooth; }
#splitter { width: 6px; cursor: col-resize; background: var(--bg2); border-left: 1px solid var(--line); border-right: 1px solid var(--line); flex: none; }
#splitter:hover, #splitter.drag { background: var(--line2); }
#ide { width: var(--ide-w); min-width: 380px; flex: none; display: flex; flex-direction: column; background: var(--bg2); min-height: 0; }
body.no-ide #ide, body.no-ide #splitter { display: none; }

/* ---------- sidebar ---------- */
.nav-home { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 600; margin-bottom: 6px; }
.nav-day { margin-bottom: 4px; border-radius: 10px; }
.nav-day > button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 10px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.nav-day > button:hover { background: var(--panel); }
.day-num { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font: 700 13px var(--mono); background: var(--panel2); color: var(--amber); border: 1px solid var(--line); position: relative; }
.day-num.done { background: #17352a; color: var(--green); border-color: #2a5a45; }
.day-title { font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.day-title small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; margin-top: 2px; }
.nav-items { display: none; padding: 2px 0 8px 22px; margin-left: 15px; border-left: 1px dashed var(--line2); }
.nav-day.open .nav-items { display: block; }
.nav-items a { display: flex; gap: 8px; align-items: baseline; padding: 4px 8px; border-radius: 6px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.nav-items a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav-items a.active, .nav-home.active { background: var(--panel2); color: var(--text); }
.nav-items a .st { flex: none; width: 14px; font-size: 11px; color: var(--dim); }
.nav-items a .st.ok { color: var(--green); }
.side-extra { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-extra a { display: block; padding: 6px 10px; color: var(--muted); font-size: 13.5px; border-radius: 6px; }
.side-extra a:hover { background: var(--panel); color: var(--text); text-decoration: none; }

/* ---------- article ---------- */
#content { max-width: 860px; margin: 0 auto; padding: 28px 36px 120px; }
#content h1 { font-size: 30px; line-height: 1.2; margin: 6px 0 8px; letter-spacing: -0.5px; }
#content h2 { font-size: 21px; margin: 34px 0 10px; padding-top: 6px; letter-spacing: -0.2px; }
#content h3 { font-size: 17px; margin: 24px 0 8px; color: var(--amber2); }
#content p, #content li { color: #cdd6e5; }
#content ul, #content ol { padding-left: 22px; }
#content li { margin: 4px 0; }
#content strong { color: #fff; }
.crumbs { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.lead { font-size: 17px; color: var(--muted) !important; }
#content code { background: #1a2335; border: 1px solid #253048; padding: 1px 5px; border-radius: 5px; font-size: 13px; color: var(--amber2); white-space: nowrap; }
#content table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 14px; }
#content th, #content td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
#content th { background: var(--panel); color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
#content td code { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
dfn { font-style: normal; border-bottom: 1px dotted var(--cyan); cursor: help; color: #e8f4ff; }

.callout { border: 1px solid var(--line); border-left: 4px solid var(--cyan); background: var(--panel); border-radius: 10px; padding: 12px 16px; margin: 16px 0; }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }
.callout::before { display: block; font-weight: 700; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.tip { border-left-color: var(--green); } .tip::before { content: '💡 Подсказка'; color: var(--green); }
.warn { border-left-color: var(--red); } .warn::before { content: '⚠ Ловушка'; color: var(--red); }
.note { border-left-color: var(--cyan); } .note::before { content: 'ℹ Нюанс'; color: var(--cyan); }
.hist { border-left-color: var(--purple); } .hist::before { content: '📜 История'; color: var(--purple); }
.arch { border-left-color: var(--amber); } .arch::before { content: '🧠 Архитектура'; color: var(--amber); }
.try { border-left-color: var(--pink); } .try::before { content: '🧪 Попробуй сам'; color: var(--pink); }

/* code blocks in lessons */
.codeblock { margin: 16px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0c121d; }
.codeblock .cb-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.codeblock .cb-head .spacer { flex: 1; }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.55; }
pre.plain { background: #0c121d; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.5; }

/* syntax colors */
.k-op { color: var(--cyan); font-weight: 600; }
.k-dir { color: var(--purple); font-weight: 600; }
.k-reg { color: var(--pink); }
.k-num { color: var(--orange); }
.k-str { color: var(--green); }
.k-lbl { color: var(--amber); }
.k-com { color: #5f7090; font-style: italic; }
.k-err { text-decoration: wavy underline var(--red); }

/* buttons */
.btn { background: var(--panel2); border: 1px solid var(--line2); color: var(--text); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #4a5b80; background: #1f2a40; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: #2d2310; border-color: #6a5121; color: var(--amber); }
.btn.primary:hover:not(:disabled) { background: #3a2c12; border-color: var(--amber); }
.btn.ok { background: #12301f; border-color: #2a6a47; color: var(--green); }
.btn.ok:hover:not(:disabled) { background: #173d28; border-color: var(--green); }
.btn.ghost { background: none; border-color: transparent; }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.spacer { flex: 1; }

/* ---------- task cards ---------- */
.task { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 16px 18px; margin: 18px 0; }
.task.active { border-color: #6a5121; box-shadow: 0 0 0 1px #6a5121 inset; }
.task.solved { border-color: #2a6a47; }
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-head h3 { margin: 0 !important; color: var(--text) !important; font-size: 17px; }
.stars { color: var(--amber); font-size: 13px; letter-spacing: 1px; }
.badge { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: #12301f; color: var(--green); border-color: #2a6a47; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.task-result { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 14px; display: none; white-space: pre-wrap; }
.task-result.show { display: block; }
.task-result.ok { background: #12301f; color: var(--green); }
.task-result.bad { background: #351717; color: #ffb3b3; }
details.hint { margin-top: 8px; border: 1px dashed var(--line2); border-radius: 8px; padding: 6px 12px; }
details.hint summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px; }
details.hint[open] summary { color: var(--amber2); margin-bottom: 6px; }
details.sol summary { color: var(--red); }

/* ---------- quiz ---------- */
.quiz-q { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 14px 0; background: var(--panel); }
.quiz-q .qn { font-weight: 700; margin-bottom: 8px; }
.quiz-q label { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.quiz-q label:hover { background: var(--panel2); }
.quiz-q label.right { background: #12301f; }
.quiz-q label.wrong { background: #351717; }
.quiz-q .expl { display: none; margin-top: 8px; color: var(--muted); font-size: 14px; }
.quiz-q.checked .expl { display: block; }
.score { font-size: 18px; font-weight: 700; margin: 10px 0; }

/* ---------- home ---------- */
.hero { padding: 26px 26px; border-radius: 18px; background: radial-gradient(120% 140% at 100% 0%, #2a1f0c 0%, transparent 55%), linear-gradient(160deg, #141d2e, #0f1522); border: 1px solid var(--line); margin-bottom: 26px; }
.hero h1 { font-size: 36px !important; margin: 0 0 10px !important; }
.hero p { font-size: 16.5px; margin: 0 0 10px; }
.hero canvas { width: 100%; max-width: 520px; display: block; margin: 16px 0 6px; border-radius: 10px; background: #120807; border: 1px solid #3a2016; image-rendering: pixelated; }
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 16px 0; }
.week a { display: block; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 14px; color: var(--text); text-decoration: none !important; transition: border-color .15s, transform .15s; }
.week a:hover { border-color: var(--amber); transform: translateY(-2px); }
.week .wd { font: 700 12px var(--mono); color: var(--amber); letter-spacing: 1px; }
.week .wt { font-weight: 700; margin: 4px 0; line-height: 1.3; }
.week .ws { font-size: 13px; color: var(--muted); line-height: 1.45; }
.week .wp { margin-top: 10px; height: 4px; background: #1d2638; border-radius: 3px; overflow: hidden; }
.week .wp i { display: block; height: 100%; background: var(--green); }
.next-btn { display: flex; justify-content: space-between; gap: 10px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.next-btn a { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--panel); max-width: 48%; }
.next-btn a small { display: block; color: var(--muted); font-size: 12px; }
.read-mark { margin-top: 30px; }

/* ---------- reference / glossary ---------- */
.search { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); color: var(--text); font-size: 15px; margin: 10px 0 14px; outline: none; }
.search:focus { border-color: var(--amber); }
.ref-table td:first-child { font-family: var(--mono); color: var(--cyan); font-weight: 600; white-space: nowrap; }
.ref-table td.mono { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.gl-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.gl-item b { color: var(--amber2); font-size: 15.5px; }
.gl-item .en { color: var(--dim); font-size: 13px; margin-left: 6px; }
.gl-item p { margin: 4px 0 0; }
.letter { font: 800 22px var(--mono); color: var(--amber); margin: 22px 0 4px; }

/* ---------- IDE ---------- */
.ide-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); position: relative; flex-wrap: wrap; }
.ide-toolbar select { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.menu { position: absolute; right: 10px; top: 46px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 6px; z-index: 20; display: flex; flex-direction: column; min-width: 240px; box-shadow: 0 10px 30px #0008; }
.menu button { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.menu button:hover { background: var(--line); }
#programs { width: min(420px, 92vw); color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 12px; padding: 20px; }
#programs::backdrop { background: #0009; }
#programs h2 { margin-top: 0; }
#programs label { display: block; margin: 14px 0 8px; }
#programs input, #programs select { display: block; width: 100%; margin-top: 5px; padding: 7px; color: var(--text); background: var(--bg); border: 1px solid var(--line2); }
.task-banner { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: #1f1a0e; border-bottom: 1px solid #4a3a18; font-size: 13.5px; }
.tb-label { font: 700 11px var(--mono); color: var(--amber); text-transform: uppercase; letter-spacing: 1px; }
.tb-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.editor { flex: 1 1 50%; min-height: 160px; display: flex; overflow: hidden; background: #0b1019; position: relative; }
.gutter { flex: none; width: 48px; padding: 10px 0; background: #0d131e; border-right: 1px solid var(--line); overflow: hidden; font: 12px/var(--lh) var(--mono); color: var(--dim); text-align: right; user-select: none; }
.gutter div { height: var(--lh); padding-right: 8px; cursor: pointer; position: relative; }
.gutter div:hover { color: var(--text); }
.gutter div.bp::before { content: ''; position: absolute; left: 6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 6px var(--red); }
.gutter div.err { color: var(--red); font-weight: 700; }
.code-area { position: relative; flex: 1; overflow: hidden; }
.code-area pre.hl, .code-area textarea {
  position: absolute; inset: 0; margin: 0; padding: 10px 12px; border: 0;
  font: 13.5px/var(--lh) var(--mono); white-space: pre; tab-size: 8; letter-spacing: 0;
  overflow: auto;
}
.code-area pre.hl { color: var(--text); pointer-events: none; overflow: hidden; }
.code-area textarea { background: transparent; color: transparent; caret-color: var(--amber); resize: none; outline: none; }
.code-area textarea::selection { background: #3a4a6e; color: transparent; }
.line-marks { position: absolute; left: 0; right: 0; top: 0; height: 0; pointer-events: none; }
.line-marks .mk { position: absolute; left: 0; right: 0; height: var(--lh); }
.line-marks .mk.cur { background: #3a2c1255; box-shadow: inset 3px 0 0 var(--amber); }
.line-marks .mk.err { background: #ff6b6b1c; box-shadow: inset 3px 0 0 var(--red); }

.messages { max-height: 92px; overflow-y: auto; font-size: 12.5px; border-top: 1px solid var(--line); background: #0d131e; flex: none; }
.messages:empty { display: none; }
.messages div { padding: 4px 12px; border-bottom: 1px solid #172033; cursor: default; }
.messages .e { color: #ffb3b3; cursor: pointer; } .messages .e b { color: var(--red); }
.messages .w { color: var(--amber2); }
.messages .i { color: var(--muted); }
.messages .s { color: var(--green); }

.ide-bottom { flex: 1 1 45%; min-height: 200px; display: grid; grid-template-columns: 236px 1fr; border-top: 1px solid var(--line); overflow: hidden; }
.cpu { border-right: 1px solid var(--line); padding: 8px 10px; overflow-y: auto; font: 12.5px/1.5 var(--mono); }
.cpu .title { font: 700 10.5px var(--sans); text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); margin: 6px 0 4px; display: flex; justify-content: space-between; align-items: center; }
.cpu .title button { background: none; border: 1px solid var(--line); border-radius: 5px; font: 600 10px var(--mono); color: var(--muted); padding: 0 5px; cursor: pointer; }
.regs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; }
.reg { display: flex; justify-content: space-between; background: #0d131e; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.reg span { color: var(--muted); }
.reg b { color: var(--text); font-weight: 600; }
.reg.wide { grid-column: span 2; }
.reg.changed b { color: var(--amber); }
.flags { display: flex; gap: 3px; }
.flag { flex: 1; text-align: center; border: 1px solid var(--line); border-radius: 5px; padding: 1px 0; color: var(--dim); font-size: 11.5px; }
.flag.on { background: #12301f; border-color: #2a6a47; color: var(--green); font-weight: 700; }
.cpu .instr { color: var(--cyan); background: #0d131e; border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.cpu .stat { color: var(--muted); font-size: 11.5px; }
.cpu .state { font-weight: 700; }
.state.run { color: var(--green); } .state.halt { color: var(--amber); } .state.stop { color: var(--muted); } .state.brk { color: var(--red); }

.devices { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.dev-tabs { display: flex; gap: 2px; padding: 4px 6px 0; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: none; }
.dev-tabs button { background: none; border: 0; padding: 6px 10px; font-size: 12.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.dev-tabs button.active { color: var(--text); border-bottom-color: var(--amber); }
.dev-tabs button.ping::after { content: '•'; color: var(--amber); margin-left: 4px; }
.dev-body { flex: 1; overflow: auto; position: relative; }
.dev { padding: 8px; height: 100%; display: flex; flex-direction: column; gap: 6px; }
.dev[hidden] { display: none; }
#term { flex: 1; margin: 0; background: #07100b; color: #8dffb9; border: 1px solid #16301f; border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.35; overflow: auto; white-space: pre-wrap; word-break: break-all; min-height: 60px; text-shadow: 0 0 6px #3dff8a55; }
#kbd { background: var(--panel); border: 1px solid var(--line2); color: var(--text); border-radius: 8px; padding: 6px 10px; font: 12.5px var(--mono); outline: none; }
#kbd:focus { border-color: var(--green); }
#screen, #matrix { max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 0 auto; image-rendering: auto; }
#screen { background: #06120c; border: 1px solid #16301f; }
#matrix { background: #120807; border: 1px solid #3a2016; }
.dev-cap { font-size: 11.5px; color: var(--dim); text-align: center; font-family: var(--mono); }
.panel-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.pl { font-size: 11.5px; color: var(--muted); width: 160px; font-family: var(--mono); }
.leds, .switches { display: flex; gap: 8px; }
.led { width: 18px; height: 18px; border-radius: 50%; background: #3a1414; border: 2px solid #2a1010; }
.led.on { background: #ff4040; box-shadow: 0 0 10px #ff4040, 0 0 3px #fff inset; border-color: #ff8080; }
.sw { width: 18px; height: 32px; border-radius: 4px; background: #0d131e; border: 1px solid var(--line2); position: relative; cursor: pointer; padding: 0; }
.sw::after { content: ''; position: absolute; left: 2px; right: 2px; height: 13px; bottom: 2px; background: #5d6a84; border-radius: 2px; transition: .15s; }
.sw.on::after { bottom: 15px; background: var(--amber); }
.seg7 { display: flex; gap: 6px; background: #0a0505; padding: 6px 8px; border-radius: 6px; border: 1px solid #2a1414; }
.seg7 svg { width: 34px; height: 56px; }
.seg7 .s { fill: #2a1010; } .seg7 .s.on { fill: #ff3b30; filter: drop-shadow(0 0 3px #ff3b30); }
.mono { font-family: var(--mono); }
.mem-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.mem-bar input { width: 64px; background: var(--panel); border: 1px solid var(--line2); color: var(--text); border-radius: 6px; padding: 2px 6px; font: 12.5px var(--mono); }
#memDump, #listing { margin: 0; font-size: 12px; line-height: 1.45; color: var(--text); white-space: pre; overflow: auto; }
#memDump .pc { background: var(--amber); color: #000; border-radius: 2px; }
#memDump .sp { background: var(--purple); color: #000; border-radius: 2px; }
#memDump .hlm { outline: 1px solid var(--pink); }
#memDump .ad { color: var(--dim); }
#memDump .as { color: var(--green); }
#memDump .z { color: #3d4a63; }
#listing .la { color: var(--dim); }
#listing .lb { color: var(--orange); }
#listing .cur { background: #3a2c12; }

.tooltip { position: fixed; z-index: 100; max-width: 340px; background: #1c2539; border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; box-shadow: 0 10px 30px #000a; pointer-events: none; }
.tooltip b { color: var(--amber2); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2539; border: 1px solid var(--line2); padding: 10px 18px; border-radius: 10px; z-index: 100; font-weight: 600; box-shadow: 0 10px 30px #000a; }
.toast.ok { border-color: var(--green); color: var(--green); }

/* diagrams */
.diagram { margin: 18px 0; background: #0c121d; border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow-x: auto; }
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram .cap { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.bits { display: inline-flex; gap: 2px; font-family: var(--mono); vertical-align: middle; }
.bits span { width: 22px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line2); border-radius: 4px; background: #0d131e; font-size: 13px; }
.bits span.one { background: #2d2310; color: var(--amber); border-color: #6a5121; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #243049; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- responsive ---------- */
@media (max-width: 1250px) {
  #sidebar { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 10px 0 30px #0008; }
  body.side-open #sidebar { transform: none; }
  .icon-btn { display: inline-block; }
  .progress-wrap { display: none; }
}
@media (max-width: 900px) {
  .top-links { display: none; }
  .mobile-tabs { display: flex; margin-left: auto; gap: 4px; }
  .mobile-tabs button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13.5px; }
  .mobile-tabs button.active { border-color: var(--amber); color: var(--amber); }
  .brand-text small { display: none; }
  #splitter { display: none; }
  #lesson, #ide { width: 100% !important; min-width: 0; }
  body:not(.pane-ide) #ide { display: none; }
  body.pane-ide #lesson { display: none; }
  #content { padding: 18px 16px 80px; }
  #ide { overflow-y: auto; }
  .editor { flex: none; height: 46vh; }
  .ide-bottom { flex: none; overflow: visible; grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .devices { min-height: 360px; }
  .ide-toolbar select { max-width: 150px; }
  .cpu { border-right: 0; border-bottom: 1px solid var(--line); max-height: 170px; }
  .regs { grid-template-columns: repeat(4, 1fr); }
  .reg.wide { grid-column: span 2; }
}
