/* Tabcade Studio. Tabcade colours, square-ish corners (4px max), no glows or blur. */
:root {
  --blue: #14287f; --dark: #0c0f17; --orange: #ff6b1f; --ink: #121726;
  --panel: #171d2e; --panel2: #1e2539; --line: #2b3450; --text: #eef1f8; --sub: #9aa3bd;
  --bad: #e53935; --good: #3fae49;
  --display: 'Big Shoulders Display', Impact, sans-serif;
  --body: Figtree, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--dark); color: var(--text); font: 600 14px/1.35 var(--body); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 1px; }

/* ---- top bar ---- */
.top { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px; background: var(--blue); border-bottom: 3px solid var(--ink); }
.brand { display: flex; align-items: baseline; gap: 6px; color: #fff; text-decoration: none; font-family: var(--display); font-weight: 900; font-size: 26px; letter-spacing: .02em; }
.brand span { color: var(--orange); font-size: 20px; }
.proj { display: flex; align-items: center; gap: 8px; max-width: 220px; height: 36px; padding: 0 12px; background: var(--ink); border: 2px solid #0a1030; border-radius: 4px; font-weight: 800; }
.proj span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj i { font-style: normal; color: var(--orange); }
.save { color: #b9c3ec; font-weight: 600; min-width: 62px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tabs button { height: 40px; padding: 0 16px; border: 0; border-radius: 4px 4px 0 0; margin-top: 16px; background: #1c348f; color: #d7ddf7; font: 800 17px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.tabs button:hover { background: #24409f; }
.tabs button.on { background: var(--dark); color: var(--orange); }
.spacer { flex: 1; }
.hbtn { height: 38px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 4px; background: #fff; color: var(--ink); font-weight: 800; }
.hbtn:hover:not(:disabled) { background: #e8ebf5; }
.hbtn.play { min-width: 96px; background: var(--orange); }
.hbtn.play:hover { background: #ff8340; }
body.playing .hbtn.play { background: var(--bad); color: #fff; }

/* ---- layout ---- */
main { position: relative; height: calc(100% - 56px); }
.tab { position: absolute; inset: 0; display: grid; grid-template-columns: 220px 1fr 290px; gap: 0; }
.left, .right { display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 8px; overflow: auto; background: var(--ink); }
.left { border-right: 2px solid #000; }
.right { border-left: 2px solid #000; }
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel { padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.panel.grow { flex: 1; min-height: 120px; overflow: auto; }
.panel h3 { margin: 0 0 8px; font: 900 15px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--orange); }
.note { margin: 4px 0 8px; color: var(--sub); font-weight: 600; font-size: 13px; }
.tag { margin: 2px 0 8px; color: #c8d0ea; font-size: 13px; }
.row { display: flex; gap: 6px; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
body.playing .left, body.playing .right, body.playing .tabs { pointer-events: none; opacity: .5; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 12px; border: 2px solid #000; border-radius: 4px; background: var(--panel2); color: var(--text); font-weight: 800; text-decoration: none; }
.btn:hover:not(:disabled) { background: #283153; }
.btn.orange { background: var(--orange); color: var(--ink); }
.btn.orange:hover:not(:disabled) { background: #ff8340; }
.btn.bad { background: #5a1a1f; }
.btn.bad:hover:not(:disabled) { background: var(--bad); }
.mini { height: 28px; padding: 0 9px; border: 1px solid #000; border-radius: 4px; background: var(--panel2); font-size: 12px; font-weight: 800; }
.mini:hover { background: #283153; }
.mini.bad:hover { background: var(--bad); }

/* tools + insert */
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tool { height: 36px; border: 2px solid #000; border-radius: 4px; background: var(--panel2); font-weight: 800; }
.tool.on { background: var(--orange); color: var(--ink); }
.snaps { display: flex; gap: 6px; margin-top: 8px; }
.snaps label { display: flex; flex-direction: column; gap: 2px; flex: 1; font-size: 12px; color: var(--sub); }
select, input[type=text], input[type=number], input[type=search] { width: 100%; height: 30px; padding: 0 6px; background: var(--dark); border: 1px solid var(--line); border-radius: 4px; font-weight: 600; }
.insert { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ins { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 8px; border: 2px solid #000; border-radius: 4px; background: var(--panel2); font-weight: 800; text-align: left; }
.ins:hover { background: #283153; }
.shape { display: inline-block; width: 18px; height: 18px; background: #c7ccd4; border-radius: 2px; flex: none; }
.shape.sphere { border-radius: 50%; }
.shape.cylinder { width: 12px; border-radius: 3px / 6px; }
.shape.wedge { clip-path: polygon(0 100%, 100% 100%, 0 0); border-radius: 0; }
.shape.spawn { background: var(--orange); height: 8px; }
.toolbox { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tb { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2); font-size: 12px; font-weight: 700; }
.tb:hover { border-color: var(--orange); }
.tb img { width: 100%; aspect-ratio: 4 / 3; background: #2a3352; border-radius: 2px; }

/* viewport */
.view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #1a2238; outline: none; }
.view .gl { display: block; position: absolute; inset: 0; touch-action: none; }
.viewhint { position: absolute; left: 8px; bottom: 8px; padding: 4px 8px; background: rgba(12, 15, 23, .75); border-radius: 4px; color: #c8d0ea; font-size: 12px; pointer-events: none; }
.playhost { position: absolute; inset: 0; z-index: 5; background: var(--dark); }
.playframe { display: block; width: 100%; height: 100%; border: 0; }
.output { height: 132px; display: flex; flex-direction: column; background: var(--ink); border-top: 2px solid #000; }
.outhead { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 0; }
.outhead h3 { margin: 0; font: 900 14px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--orange); }
.outlist { flex: 1; overflow: auto; padding: 4px 10px 8px; font: 500 13px/1.45 var(--mono); }
.outlist .line { display: block; width: 100%; padding: 1px 0; border: 0; background: none; text-align: left; font: inherit; white-space: pre-wrap; }
.line.err { color: #ff8a80; }
button.line.err:hover { text-decoration: underline; }
.line.info { color: var(--sub); }
.line.log { color: #e4e9f7; }

/* explorer + properties */
.tree { display: flex; flex-direction: column; gap: 1px; max-height: 34vh; overflow: auto; }
.panel.grow .tree { max-height: none; }
.node { display: flex; align-items: center; gap: 6px; width: 100%; height: 28px; padding: 0 8px; border: 0; border-radius: 3px; background: none; text-align: left; font-weight: 700; }
.node:hover { background: var(--panel2); }
.node.on { background: var(--orange); color: var(--ink); }
.node.off span { text-decoration: line-through; opacity: .6; }
.node i { width: 16px; font-style: normal; text-align: center; }
.node span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node em { font-style: normal; font-size: 11px; padding: 1px 5px; border-radius: 3px; background: var(--blue); color: #dfe5ff; }
.node.on em { background: var(--ink); }
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.field > span { color: var(--sub); font-size: 12px; font-weight: 700; }
.xyz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.xyz label { display: flex; align-items: center; gap: 3px; }
.xyz b { width: 12px; font-size: 11px; color: var(--sub); }
.xyz label:nth-child(1) b { color: #ff7a70; } .xyz label:nth-child(2) b { color: #6fd179; } .xyz label:nth-child(3) b { color: #7ea6ff; }
.xyz input { padding: 0 3px; }
.colors { display: flex; gap: 6px; align-items: flex-start; }
.colors input[type=color] { width: 40px; height: 40px; padding: 0; border: 2px solid #000; border-radius: 4px; background: none; flex: none; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; flex: 1; }
.sw { height: 18px; border: 1px solid #000; border-radius: 2px; padding: 0; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: 700; }
.check input { width: 18px; height: 18px; accent-color: var(--orange); }
input[type=range] { width: 100%; accent-color: var(--orange); }

/* assets */
.tab.assets, .tab.scripts, .tab.anim { }
.tab.assets { display: block; padding: 18px 22px; overflow: auto; }
.ashead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ashead h2, .empty h2 { margin: 0; font: 900 34px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; }
.ashead input { max-width: 260px; height: 36px; }
.chips { display: flex; gap: 6px; }
.chip { height: 34px; padding: 0 14px; border: 2px solid #000; border-radius: 4px; background: var(--panel2); font-weight: 800; }
.chip.on { background: var(--orange); color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 10px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.card img { width: 100%; aspect-ratio: 4 / 3; background: #2a3352; border-radius: 3px; }
.card b { font-size: 16px; font-weight: 800; }
.card small { color: var(--sub); }
.card .row { margin-top: auto; padding-top: 6px; }

/* scripts */
.tab.scripts .center { padding: 10px; gap: 8px; }
.sceditor { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.schead { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 10px; align-items: end; }
.schead .field, .schead .check { margin: 0; }
.schead .check { height: 34px; }
.code { display: flex; flex: 1; min-height: 0; border: 2px solid #000; border-radius: 4px; background: #0a0d14; overflow: hidden; }
.gutter { width: 44px; padding: 10px 6px 10px 0; overflow: hidden; background: #111624; color: #5d6789; text-align: right; font: 500 14px/20px var(--mono); user-select: none; }
.gutter .bad { background: var(--bad); color: #fff; }
.code textarea { flex: 1; padding: 10px; border: 0; outline: none; resize: none; background: none; color: #e8ecf8; font: 500 14px/20px var(--mono); tab-size: 2; white-space: pre; }
.empty { margin: auto; max-width: 420px; text-align: center; color: var(--sub); }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.docs .docgroup { margin-bottom: 12px; }
.docs h4 { margin: 4px 0 6px; font-size: 13px; color: #c8d0ea; }
.doc { display: block; width: 100%; padding: 6px 8px; margin-bottom: 3px; border: 1px solid transparent; border-radius: 4px; background: var(--panel2); text-align: left; }
.doc:hover { border-color: var(--orange); }
.doc code { display: block; color: var(--orange); font: 700 12.5px/1.4 var(--mono); white-space: pre-wrap; }
.doc span { display: block; margin-top: 2px; color: var(--sub); font-size: 12px; font-weight: 600; }
#scExample { margin: 8px 0; }

/* animations */
.timeline { height: 240px; display: flex; flex-direction: column; background: var(--ink); border-top: 2px solid #000; }
.tlbar { display: flex; align-items: end; gap: 12px; padding: 8px 10px; }
.tlbar .field, .tlbar .check { margin: 0; }
.tlbar .field { width: 120px; }
.tlbar .field:last-child { width: 160px; }
.time { min-width: 110px; padding-bottom: 8px; font: 700 14px var(--mono); color: #c8d0ea; }
.tracks { position: relative; flex: 1; overflow: hidden; padding: 0 10px 8px; cursor: pointer; user-select: none; }
.track { display: flex; align-items: center; height: 24px; }
.track > span { width: 84px; flex: none; font-size: 12px; color: var(--sub); }
.track.on > span { color: var(--orange); }
.track .lane { position: relative; flex: 1; height: 20px; background: var(--panel); border-radius: 3px; }
.track.on .lane { background: #262f4b; }
.track.ticks .lane { background: none; height: 16px; }
.ticks b { position: absolute; top: 0; transform: translateX(-50%); font-size: 10px; color: var(--sub); }
.key { position: absolute; top: 4px; width: 12px; height: 12px; margin-left: -6px; background: var(--orange); border: 2px solid #000; transform: rotate(45deg); }
.playhead { position: absolute; top: 0; bottom: 8px; width: 2px; background: #fff; pointer-events: none; }
.joints { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.slider { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 2px 8px; margin-bottom: 8px; }
.slider b { grid-column: 1 / -1; font-size: 12px; color: var(--sub); }
.slider output { text-align: right; font: 700 13px var(--mono); }

/* modal + toast */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(5, 7, 12, .7); }
.sheet { width: min(640px, 92vw); max-height: 86vh; overflow: auto; padding: 20px 22px; background: var(--panel); border: 3px solid #000; border-radius: 4px; }
.sheet h2 { margin: 0 0 8px; font: 900 30px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; }
.sheet p { color: #c8d0ea; }
.plist { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.prow { display: grid; grid-template-columns: 1fr auto auto auto; grid-template-rows: auto auto; gap: 4px 6px; align-items: center; padding: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; }
.prow.on { border-color: var(--orange); }
.prow small { grid-column: 1; grid-row: 2; color: var(--sub); }
.prow .btn { grid-row: 1 / 3; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 60; transform: translateX(-50%); max-width: 80vw; padding: 10px 16px; background: var(--orange); color: var(--ink); border: 2px solid #000; border-radius: 4px; font-weight: 800; }
.nojs { padding: 40px; text-align: center; }

/* small screens (Chromebooks at 1366 and below) */
@media (max-width: 1200px) {
  .tab { grid-template-columns: 190px 1fr 250px; }
  .tabs button { padding: 0 10px; font-size: 15px; }
  .save { display: none; }
}
/* right-click menu */
.ctx { position: fixed; z-index: 70; min-width: 210px; padding: 4px; background: var(--panel2); border: 1px solid #000; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.ctx button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 18px; height: 30px; padding: 0 10px; border: 0; border-radius: 4px; background: none; color: inherit; font: 700 13px/1 inherit; font-family: inherit; text-align: left; cursor: pointer; }
.ctx button:hover:not(:disabled), .ctx button:focus-visible { background: var(--orange); color: var(--ink); outline: none; }
.ctx button:disabled { opacity: .4; cursor: default; }
.ctx kbd { font: 600 11px/1 inherit; font-family: inherit; opacity: .7; }
.ctx hr { margin: 4px 2px; border: 0; border-top: 1px solid rgba(255,255,255,.12); }
a.hbtn { display: inline-flex; align-items: center; text-decoration: none; }
