[hidden] { display: none !important; }
:root {
  --bg: #0c111b; --panel: #121826; --panel2: #171f30; --line: #243049; --text: #dfe7f5; --mut: #8a98b4; --acc: #39ff88; --acc2: #4f8cff; --warn: #ffb03b; --err: #ff5c6c;
  --font: Inter, system-ui, -apple-system, Segoe UI, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#top { height: 46px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: linear-gradient(#141b2b, #10161f); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 6px; font-size: 16px; letter-spacing: .3px; margin-right: 6px; }
.logo b { color: var(--acc); font-weight: 800; } .logo span { color: #fff; font-weight: 600; margin-left: -5px; }
.tb-group { display: flex; gap: 4px; align-items: center; padding-right: 10px; border-right: 1px solid var(--line); }
.tb-group.right { margin-left: auto; border: 0; padding: 0; }
.tb { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; height: 30px; padding: 0 10px; color: var(--text); white-space: nowrap; }
.tb:hover { border-color: #3a4a6b; background: #1c2539; }
.tb.icon { width: 32px; padding: 0; font-size: 15px; }
.tb.play { width: 38px; font-size: 14px; color: var(--acc); border-color: #275c3f; }
.tb.play.paused { color: var(--warn); border-color: #6b5023; }
.tb.active { background: #20402c; border-color: var(--acc); color: var(--acc); }
.tb.ai { background: linear-gradient(90deg, #3b2a74, #234a8a); border-color: #5b6ad0; font-weight: 600; }
select.tb { padding: 0 6px; }
#projName { max-width: 160px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
#main { position: absolute; top: 46px; bottom: 24px; left: 0; right: 0; display: flex; }
#palette { width: 236px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.pal-search { padding: 8px; border-bottom: 1px solid var(--line); }
.pal-search input { width: 100%; background: #0d1320; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; outline: none; }
.pal-search input:focus { border-color: var(--acc2); }
#palList { overflow-y: auto; flex: 1; padding-bottom: 20px; }
.pal-cat > h4 { margin: 0; padding: 8px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; display: flex; align-items: center; gap: 6px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.pal-cat > h4 i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.pal-cat > h4 .n { margin-left: auto; color: var(--mut); font-weight: 500; }
.pal-cat.collapsed .pal-items { display: none; }
.pal-items { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0 8px 8px; }
.pal-item { background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 4px 3px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; user-select: none; position: relative; }
.pal-item:hover { border-color: #3d5080; background: #1b2438; }
.pal-item.sel { border-color: var(--acc); background: #173022; }
.pal-item canvas { width: 76px; height: 40px; }
.pal-item span { font-size: 10.5px; text-align: center; color: #c8d3e8; line-height: 1.15; }
.pal-item .edit { position: absolute; top: 2px; right: 3px; font-size: 10px; opacity: .6; }
.pal-item .edit:hover { opacity: 1; }
#stage { flex: 1; position: relative; overflow: hidden; }
#cv { display: block; outline: none; touch-action: none; }
#crumbs { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; align-items: center; }
#crumbs:empty { display: none; }
#crumbs .crumb { background: rgba(20,27,43,.92); border: 1px solid var(--line); padding: 4px 10px; border-radius: 6px; cursor: pointer; }
#crumbs .crumb.cur { border-color: #c0c8d8; cursor: default; }
#challengeBar { position: absolute; top: 8px; left: 8px; right: 8px; flex-wrap: wrap; background: rgba(26,22,48,.95); border: 1px solid #6b5bd0; border-radius: 10px; padding: 8px 12px; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 30px rgba(0,0,0,.4); }
#challengeBar b { color: #c7b8ff; white-space: nowrap; } #challengeBar .d { color: var(--mut); font-size: 12px; flex: 1; min-width: 180px; }
#challengeBar button { background: #2b2460; border: 1px solid #6b5bd0; border-radius: 6px; padding: 4px 10px; }
#challengeBar button.go { background: #1f5a37; border-color: var(--acc); color: #dfffe9; font-weight: 600; }
#placingHint { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(20,27,43,.95); border: 1px solid var(--acc); color: var(--acc); padding: 5px 12px; border-radius: 20px; font-size: 12px; pointer-events: none; }
#emptyHint { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--mut); pointer-events: none; }
#emptyHint h2 { color: #fff; margin: 0 0 8px; font-size: 22px; }
#emptyHint button { pointer-events: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; margin: 4px; }
#emptyHint button:hover { border-color: var(--acc2); }
#right { width: 330px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 0 8px; color: var(--mut); font-weight: 600; }
.tabs button.active { color: #fff; border-bottom-color: var(--acc); }
.tab { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.tab.active { display: block; }
#tab-ai.active { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.insp-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.insp-title i { width: 10px; height: 10px; border-radius: 3px; }
.insp-title h3 { margin: 0; font-size: 15px; }
.insp-title .cat { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--mut); }
.desc { color: var(--mut); font-size: 12px; margin: 4px 0 10px; }
.field { margin: 8px 0; }
.field > label { display: block; font-size: 11px; color: var(--mut); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .6px; }
.field input[type=text], .field input[type=number], .field select, .field textarea { width: 100%; background: #0d1320; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; outline: none; }
.field textarea { font-family: var(--mono); font-size: 11.5px; min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--acc2); }
.field.inline { display: flex; align-items: center; gap: 8px; } .field.inline > label { margin: 0; flex: 1; }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.swatches b { width: 18px; height: 18px; border-radius: 4px; cursor: pointer; border: 2px solid transparent; display: inline-block; }
.swatches b.on { border-color: #fff; }
.swatches input[type=color] { width: 26px; height: 22px; border: 0; background: none; padding: 0; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12px; }
.btn:hover { border-color: #3d5080; } .btn.pri { background: #1b4a30; border-color: #2f8a55; color: #dfffe9; } .btn.danger { color: #ffb3bb; border-color: #5a2a33; }
.live { background: #0d1320; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-family: var(--mono); font-size: 11px; }
.live div { display: flex; justify-content: space-between; gap: 8px; } .live .on { color: var(--acc); } .live .k { color: var(--mut); }
h5 { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--mut); }
.shortcuts .kbd { justify-self: start; align-self: start; white-space: nowrap; }
.kbd { font-family: var(--mono); font-size: 11px; background: #0d1320; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.shortcuts { display: grid; grid-template-columns: minmax(0,auto) minmax(0,1fr); gap: 5px 8px; font-size: 12px; color: var(--mut); }
.stat { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #1f2a40; font-size: 12px; } .stat b { color: #fff; font-family: var(--mono); }
/* AI */
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ai-head .model { font-size: 11px; color: #a99cff; font-family: var(--mono); }
.mini { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; }
#aiLog { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { border-radius: 10px; padding: 8px 10px; font-size: 12.5px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { background: #1d2a48; align-self: flex-end; max-width: 90%; }
.msg.bot { background: #161d2c; border: 1px solid var(--line); }
.msg.err { background: #3a1820; border: 1px solid #6b2a35; color: #ffc6cd; }
.msg code { font-family: var(--mono); font-size: 11px; background: #0d1320; padding: 0 3px; border-radius: 3px; }
.think { font-size: 11px; color: #8d86b8; border-left: 2px solid #3d3670; padding-left: 8px; margin-bottom: 6px; max-height: 110px; overflow-y: auto; white-space: pre-wrap; }
.think summary { cursor: pointer; color: #a99cff; }
.ccard { margin-top: 8px; background: #101a2a; border: 1px solid #2a4a7a; border-radius: 8px; padding: 8px; white-space: normal; }
.ccard b { color: #9fd0ff; } .ccard .w { color: var(--warn); font-size: 11px; margin-top: 4px; }
.ccard .btnrow { margin: 6px 0 0; }
.typing::after { content: '▋'; animation: blink 1s infinite; color: var(--acc); }
@keyframes blink { 50% { opacity: 0; } }
#aiChips { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px; border-top: 1px solid var(--line); }
#aiChips button { background: #1a2034; border: 1px solid #2f3a5a; border-radius: 12px; padding: 3px 9px; font-size: 11px; color: #b9c6e6; }
#aiChips button:hover { border-color: #6b6ad0; color: #fff; }
.ai-opts { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 12px; font-size: 11.5px; color: var(--mut); align-items: center; }
.ai-opts select { background: #0d1320; border: 1px solid var(--line); border-radius: 5px; padding: 2px 4px; font-size: 11.5px; }
.ai-input { display: flex; gap: 6px; padding: 8px 12px 12px; }
.ai-input textarea { flex: 1; background: #0d1320; border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: none; outline: none; }
.ai-input textarea:focus { border-color: #6b6ad0; }
.ai-input button { background: linear-gradient(#5b4ad0, #3b2fa0); border: 0; border-radius: 8px; padding: 0 14px; font-weight: 600; }
.ai-input button.stop { background: #6b2a35; }
/* status */
.ai-ext { display: flex; gap: 6px; padding: 0 12px 2px; }
.ai-ext button { flex: 1; background: #182036; border: 1px solid #34406a; border-radius: 7px; padding: 5px 6px; font-size: 11.5px; color: #c9d4f0; }
.ai-ext button:hover { border-color: #6b6ad0; color: #fff; }
.memtools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.memtools select { background: #0d1320; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.memgrid { border-collapse: collapse; font-family: var(--mono); font-size: 11.5px; }
.memgrid th { color: #6f7f9f; font-weight: 500; padding: 2px 4px; text-align: center; }
.memgrid th.ad { text-align: right; padding-right: 8px; }
.memgrid td { padding: 1px; }
.memgrid input { background: #0d1320; border: 1px solid #1f2a40; border-radius: 4px; color: #dfe7f5; font: inherit; text-align: center; padding: 3px 2px; outline: none; }
.memgrid input.nz { color: #ffcf8a; }
.memgrid input:focus { border-color: var(--acc2); background: #13203a; }
.memgrid input.cur { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc) inset; }
.memgrid input.flash { background: #2a3a1a; }
.pastebox { width: 100%; height: 220px; background: #0d1320; color: #dfe7f5; border: 1px solid #243049; border-radius: 8px; padding: 8px; font-family: var(--mono); font-size: 11px; resize: vertical; }
.pjstat { font-size: 12px; margin: 6px 0; min-height: 18px; } .pjstat.ok { color: var(--acc); } .pjstat.bad { color: var(--err); } .pjstat .w { color: var(--warn); display: block; font-size: 11px; }
.set-group { border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 8px; margin-bottom: 12px; background: var(--panel2); }
.set-group h5 { margin: 10px 0 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px dashed #24304a; }
.set-row:last-child { border-bottom: 0; }
.set-row select { background: #0d1320; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.set-row input[type=range] { width: 160px; vertical-align: middle; accent-color: var(--acc); }
.set-hint { color: var(--mut); font-size: 11.5px; margin-top: 2px; }
.switch { position: relative; display: inline-block; width: 38px; height: 21px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2a3450; border-radius: 21px; cursor: pointer; transition: .15s; }
.switch span::before { content: ''; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #c9d4ea; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: #1f7a48; } .switch input:checked + span::before { transform: translateX(17px); background: #fff; }
#status { position: absolute; bottom: 0; left: 0; right: 0; height: 24px; background: #0e1420; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 10px; font-size: 11px; color: var(--mut); font-family: var(--mono); white-space: nowrap; overflow: hidden; }
#status .grow { flex: 1; } #stWarn { color: var(--warn); } #stHint { font-family: var(--font); }
/* tooltip/menu/modal/toast */
#tooltip { position: fixed; pointer-events: none; background: rgba(10,14,22,.96); border: 1px solid #34425f; border-radius: 7px; padding: 6px 9px; font-size: 11.5px; max-width: 300px; z-index: 50; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
#tooltip b { color: #fff; } #tooltip .v { font-family: var(--mono); color: var(--acc); } #tooltip .m { color: var(--mut); }
#menu { position: fixed; background: #151c2c; border: 1px solid #34425f; border-radius: 8px; padding: 4px; min-width: 190px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
#menu button { display: flex; width: 100%; background: none; border: 0; text-align: left; padding: 6px 10px; border-radius: 5px; justify-content: space-between; gap: 20px; }
#menu button:hover { background: #22304a; } #menu button span { color: var(--mut); font-size: 11px; } #menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
#modalWrap { position: fixed; inset: 0; background: rgba(4,7,12,.7); z-index: 70; display: flex; align-items: center; justify-content: center; }
#modal { background: var(--panel); border: 1px solid #34425f; border-radius: 14px; width: min(980px, 94vw); max-height: 88vh; overflow-y: auto; padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.6); position: relative; }
#modal h2 { margin: 0 0 4px; } #modal .sub { color: var(--mut); margin-bottom: 14px; }
#modal .close { position: absolute; top: 12px; right: 14px; background: none; border: 0; font-size: 20px; color: var(--mut); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; }
.card:hover { border-color: var(--acc2); transform: translateY(-1px); }
.card h4 { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; } .card p { margin: 0; color: var(--mut); font-size: 12px; }
.tag { font-size: 10px; padding: 1px 7px; border-radius: 10px; background: #26304a; color: #b8c6ea; font-weight: 600; margin-left: auto; white-space: nowrap; }
.tag.BABFT { background: #4a2a1a; color: #ffb27a; } .tag.Build.Logic, .tag.BuildLogic { background: #1a3a2a; color: #7affb0; } .tag.Turing { background: #2a2050; color: #c3b0ff; } .tag.Sound { background: #4a1a3a; color: #ff9ad9; }
.card.done { border-color: #2f8a55; } .card .chk { color: var(--acc); }
.grp { margin: 16px 0 8px; color: #c7b8ff; font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: 1px; }
.ttable { border-collapse: collapse; font-family: var(--mono); font-size: 11px; width: 100%; }
.ttable th, .ttable td { border: 1px solid #22304a; padding: 2px 5px; text-align: center; } .ttable th { background: #1a2338; color: #b8c6ea; }
.ttable td.one { color: var(--acc); } .ttable td.bad { background: #4a1a22; color: #ffb3bb; } .ttable th.o { background: #2a2338; }
.expr { font-family: var(--mono); font-size: 11.5px; background: #0d1320; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 4px 0; word-break: break-word; } .expr b { color: var(--acc); }
#toasts { position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 80; pointer-events: none; }
.toast { background: #182234; border: 1px solid #34425f; padding: 8px 14px; border-radius: 9px; box-shadow: 0 6px 24px rgba(0,0,0,.5); animation: tin .2s ease-out; max-width: 70vw; }
.toast.warn { border-color: #6b5023; color: #ffd9a0; } .toast.ok { border-color: #2f8a55; color: #c8ffdc; } .toast.err { border-color: #6b2a35; color: #ffc6cd; } .toast.msg { border-color: #ffd43b; background: #2c2810; color: #fff3b8; font-size: 14px; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.proj-row { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--panel2); }
.proj-row .nm { flex: 1; } .proj-row .dt { color: var(--mut); font-size: 11px; } .proj-row.cur { border-color: var(--acc); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; } .help-grid h3 { margin: 10px 0 6px; color: #9fd0ff; font-size: 14px; } .help-grid p, .help-grid li { color: #b9c6e0; font-size: 12.5px; }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: #26324c; border-radius: 6px; } ::-webkit-scrollbar-track { background: transparent; }
@media (max-width: 1100px) { #right { width: 280px; } #palette { width: 200px; } .pal-item canvas { width: 64px; } .tb-group.right .tb:not(.icon) { padding: 0 6px; } }

@media (max-width: 1350px) { .tb-group.right .lbl, #btnPlayMode .lbl { display: none; } #projName { max-width: 90px; } .logo span { display: none; } }
@media (max-width: 1000px) { #right { width: 250px; } #palette { width: 170px; } .pal-items { grid-template-columns: 1fr; } #top { gap: 5px; } .tb-group { padding-right: 5px; } }
#aiChips { max-height: 62px; overflow-y: auto; flex-shrink: 0; }
#aiLog { min-height: 120px; }
@media (max-height: 600px) { #aiChips { max-height: 30px; } .ai-input textarea { rows: 2; height: 52px; } }
.set-row > div:first-child { flex: 1; min-width: 0; }
.set-row > div:last-child { flex-shrink: 0; }
.set-row select { max-width: 230px; }
