:root {
  --bg: #12151b; --panel: #1a1f28; --panel2: #222834; --line: #2e3542; --text: #e7e9ee; --dim: #8d97a8;
  --accent: #ff9d3c; --accent-ink: #1d1203; --good: #4fd08a; --bad: #ff6b6b; --blue: #6ab0ff; --violet: #b79cff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; display: flex; flex-direction: column; overflow: hidden; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h2 { font-size: 18px; } h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); }
p { margin: 0 0 .7em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: #0003; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); }
.dim { color: var(--dim); } .good { color: var(--good); } .bad { color: var(--bad); } .spacer { flex: 1; }
button { font: inherit; color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 7px; padding: 7px 13px; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); } button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { background: var(--panel2); }
button.danger { background: var(--bad); } button.ok { background: var(--good); }
button.small { padding: 3px 9px; font-size: 12px; }
select, input[type=text], input[type=number] { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; max-width: 100%; }
label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 10px; }
label > select, label > input[type=text], label > input[type=number] { display: block; width: 100%; margin-top: 3px; }
label.check { display: flex; gap: 7px; align-items: center; color: var(--text); font-size: 13px; margin-bottom: 5px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 500; font-size: 12px; }

#topbar { display: flex; align-items: center; gap: 14px; padding: 7px 14px; background: #0c0e12; border-bottom: 1px solid var(--line); flex: none; }
.brand { font-weight: 700; } .logo { margin-right: 4px; }
.meter { font-family: var(--mono); font-size: 12px; }
#shell { flex: 1; display: flex; min-height: 0; }
#dock { width: 84px; flex: none; background: #0f1217; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; padding: 8px 6px; overflow: auto; }
#dock button { background: transparent; color: var(--dim); font-weight: 500; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; position: relative; }
#dock button .ico { font-size: 21px; } #dock button.active { background: var(--panel2); color: var(--text); }
#dock button .badge { position: absolute; top: 4px; right: 10px; background: var(--accent); color: var(--accent-ink); border-radius: 9px; font-size: 10px; padding: 0 5px; font-weight: 700; }
#window { flex: 1; min-width: 0; display: flex; flex-direction: column; margin: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.titlebar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: var(--panel2); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--dim); flex: none; }
.lights i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #3b4352; margin-right: 5px; }
#app { flex: 1; min-height: 0; overflow: auto; }
#chat { width: 300px; flex: none; border-left: 1px solid var(--line); background: #0f1217; display: flex; flex-direction: column; }
.chat-head { padding: 9px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.chat-log { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; } .msg .av { width: 28px; height: 28px; border-radius: 7px; background: var(--panel2); display: grid; place-items: center; flex: none; }
.msg .who { font-weight: 600; font-size: 12.5px; } .msg .when { color: var(--dim); font-size: 11px; margin-left: 5px; font-weight: 400; }
.msg .body { font-size: 13px; }

.pad { padding: 16px 18px; } .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; } .col { display: flex; flex-direction: column; gap: 10px; }
.split { display: flex; height: 100%; min-height: 0; } .split > .side { width: 280px; flex: none; border-right: 1px solid var(--line); overflow: auto; padding: 12px; }
.split > .side.right { border-right: 0; border-left: 1px solid var(--line); } .split > .mainc { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; }
.chip { display: inline-block; font-family: var(--mono); font-size: 11.5px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line); background: var(--bg); margin: 0 4px 4px 0; }
.chip.good { border-color: #2c6b4a; } .chip.bad { border-color: #7a3535; } .chip.warn { color: var(--accent); border-color: #7a5320; }
.lang { font-family: var(--mono); background: #0003; border-left: 3px solid var(--accent); padding: 5px 10px; border-radius: 4px; display: inline-block; }
.view3d { position: relative; background: #1b2028; min-height: 300px; flex: 1; } .view3d canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; touch-action: none; }
.hud { position: absolute; left: 10px; top: 10px; z-index: 2; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.hud .chip { background: #000a; }
.banner { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; background: #000c; border: 1px solid var(--line); padding: 7px 14px; border-radius: 8px; text-align: center; }
.rec { color: var(--bad); font-weight: 700; } .rec::before { content: "● "; animation: blink 1s infinite; } @keyframes blink { 50% { opacity: .2; } }
.keys { display: grid; grid-template-columns: repeat(3, 38px); gap: 4px; } .keys button { padding: 8px 0; background: var(--panel2); color: var(--text); border: 1px solid var(--line); touch-action: none; user-select: none; }
kbd { font-family: var(--mono); font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; flex: none; }

.ticket { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); margin-bottom: 8px; }
.ticket.done { opacity: .6; } .ticket.active { border-color: var(--accent); }
.ticket .id { font-family: var(--mono); color: var(--dim); font-size: 12px; width: 52px; flex: none; padding-top: 2px; }
.ticket .st { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.ticket.done .st { color: var(--good); } .ticket.active .st { color: var(--accent); }
.eplist button { display: flex; width: 100%; justify-content: space-between; gap: 6px; background: transparent; color: var(--text); font-weight: 400; border: 1px solid transparent; padding: 5px 8px; font-size: 12.5px; text-align: left; }
.eplist button.sel { background: var(--panel2); border-color: var(--line); } .eplist .k { color: var(--good); } .eplist .x { color: var(--bad); }
.term { background: #0a0c10; font-family: var(--mono); font-size: 12px; padding: 10px 12px; white-space: pre-wrap; overflow: auto; color: #b9c3d3; border-radius: 7px; border: 1px solid var(--line); min-height: 60px; max-height: 220px; }
.chart { width: 100%; height: 150px; display: block; background: #0a0c10; border-radius: 7px; border: 1px solid var(--line); }
.spark { width: 100%; height: 46px; display: block; background: #0a0c10; border-radius: 6px; }
.code-editor { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; flex: none; } .code-editor .cm-editor { min-height: 220px; max-height: 520px; font-size: 13px; } .code-editor .cm-scroller { font-family: var(--mono); line-height: 1.5; overflow: auto; } .code-editor .cm-editor.cm-focused { outline: none; }
textarea.code { width: 100%; min-height: 220px; flex: 1; background: #0a0c10; color: #e3e8f1; border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; tab-size: 4; white-space: pre; }
.lesson-nav button { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); font-weight: 400; padding: 5px 8px; font-size: 13px; } .lesson-nav button.sel { background: var(--panel2); }
.lesson-nav .unit { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin: 10px 8px 3px; }
.test { font-size: 13px; padding: 2px 0; } .test.pass::before { content: "✓ "; color: var(--good); } .test.fail::before { content: "✗ "; color: var(--bad); }
.req { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; } .req .mark { width: 18px; }

#toasts { position: fixed; right: 16px; top: 52px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel2); border: 1px solid var(--accent); padding: 9px 13px; border-radius: 8px; max-width: 320px; box-shadow: 0 8px 24px #0008; }
#guide { position: fixed; z-index: 50; width: 300px; max-width: calc(100vw - 20px); background: #fff7e8; color: #2a2114; border-radius: 10px; box-shadow: 0 12px 40px #000a; border: 2px solid var(--accent); }
#guide .gh { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 12.5px; border-radius: 7px 7px 0 0; }
#guide .gb { padding: 10px 12px; font-size: 13.5px; } #guide .gf { display: flex; gap: 6px; padding: 0 12px 10px; align-items: center; }
#guide button.ghost { color: #2a2114; border-color: #d9c7a3; } #guide .gh button { background: transparent; padding: 0 4px; }
#guide code { background: #0001; border-color: #0002; }
.guide-ring { outline: 3px solid var(--accent) !important; outline-offset: 3px; border-radius: 6px; animation: ring 1.2s infinite; } @keyframes ring { 50% { outline-color: #ff9d3c55; } }
#modal { position: fixed; inset: 0; z-index: 70; background: #000a; display: grid; place-items: center; padding: 16px; }
#modal[hidden], #guide[hidden] { display: none; }
#modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; max-width: 520px; width: 100%; padding: 22px 24px; max-height: 90vh; overflow: auto; }

@media (max-width: 1150px) { #chat { display: none; } #chat.as-app { display: flex; width: auto; border: 0; height: 100%; } }
@media (max-width: 760px) {
  #shell { flex-direction: column-reverse; } #dock { width: auto; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 4px; }
  #dock button { flex: 1; min-width: 54px; font-size: 10px; padding: 5px 2px; } #window { margin: 0; border-radius: 0; border: 0; }
  .split { flex-direction: column; height: auto; } .split > .side { width: auto !important; border: 0; border-bottom: 1px solid var(--line); max-height: 34vh; } .split > .side.right { max-height: none; border-top: 1px solid var(--line); }
  .brand { font-size: 0; } .brand .logo { font-size: 20px; } #topbar button { padding: 4px 8px; font-size: 12px; } #toasts { left: 10px; right: 10px; }
  .view3d { min-height: 52vw; flex: none; } #topbar .brand .dim, #clock { display: none; } #topbar { gap: 8px; }
}
[hidden] { display: none !important; }

.lesson-text a, .explain a, .card a { color: #6db3ff; text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.lesson-text a:hover, .card a:hover { color: #9fd0ff; }
.term { resize: vertical; }

a { color: #6db3ff; text-underline-offset: 2px; } a:hover { color: #9fd0ff; }
