/* Colour tokens live in turingfold.css (Turingfold design system). OLD_TOKENS_REMOVED_V1 */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 13px/1.45 TuringFold, Arial, sans-serif;
  display: grid; grid-template-columns: 280px 1fr 440px; grid-template-rows: auto auto 1fr auto; height: 100vh; overflow: hidden;
}
header { grid-column: 1 / 4; grid-row: 2; display: flex; gap: 24px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { font-weight: 650; font-size: 16px; white-space: nowrap; line-height: 1.3; padding: 2px 18px 2px 0; border-right: 1px solid var(--line); }
.modelline { font: 500 11.5px var(--mono); color: var(--dim); letter-spacing: .04em; margin-top: 5px; }
.modelline span { color: var(--accent); margin-left: 4px; }
.dim { color: var(--dim); font-weight: 400; }
.prompt { display: flex; gap: 10px; align-items: center; flex: 1; flex-wrap: wrap; justify-content: flex-end; }
input, select, button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
input[type=number] { width: 62px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
#runBtn { background: var(--accent); color: var(--ink); border: none; font-weight: 600; padding: 5px 16px; }
label { color: var(--dim); display: inline-flex; gap: 5px; align-items: center; }

aside { overflow-y: auto; background: var(--panel); padding: 10px 14px; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); }
h2 { font-size: 16px; margin: 4px 0 6px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); margin: 14px 0 6px; }
h4 { font-size: 12px; margin: 10px 0 4px; }
section { margin-bottom: 6px; }
table.kv { width: 100%; border-collapse: collapse; font-size: 12px; }
table.kv td { padding: 2px 0; border-bottom: 1px solid var(--line); }
table.kv td:last-child { text-align: right; font-family: var(--mono); }
.tokens { display: flex; flex-wrap: wrap; gap: 4px; }
.tokens .t { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 2px 5px; background: var(--panel2); }
.tokens .t small { color: var(--dim); margin-left: 4px; }
.tokens .t.gen { border-color: var(--accent); }
.tokens .t.special { color: var(--dim); }
.output { font-family: var(--mono); white-space: pre-wrap; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; min-height: 48px; }
.output b { color: var(--accent); font-weight: 600; }
.legend div { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 2px 0; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

#left, main#viewport, #right { grid-row: 3; }
main#viewport { position: relative; overflow: hidden; min-height: 0; }
main canvas { display: block; }
.labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.lbl { font: 11px var(--mono); color: var(--dim); white-space: pre; text-align: center; }
.lbl.layer { font-size: 10px; }
.lbl.op { font-size: 10px; color: var(--dim); }
.lbl.op.active { background: color-mix(in srgb, var(--panel) 85%, transparent); padding: 1px 6px; border-radius: 4px; }
.lbl.op.active { color: var(--accent); font-weight: 700; font-size: 12px; }
.lbl.stage { color: var(--text); font-size: 11px; }
.lbl.stage.tile { color: var(--accent); }
.lbl.stagetitle { color: var(--text); font: 600 13px system-ui; background: color-mix(in srgb, var(--panel) 80%, transparent); padding: 2px 8px; border-radius: 5px; }
.lbl.stage.top { background: color-mix(in srgb, var(--panel) 85%, transparent); padding: 1px 5px; border-radius: 4px; }
.lbl.stage.top.picked { color: var(--ink); background: var(--accent); }
.lbl.tok { color: var(--text); background: var(--panel); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.lbl.tok.gen { border-color: var(--accent); }
.lbl.tok.active { background: var(--accent); color: var(--ink); }
.loader { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; text-align: center; background: var(--bg); z-index: 5; padding: 16px; }
.loader .bar { width: 320px; max-width: 80vw; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 0 auto; }
.loader .bar div { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.tooltip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font: 11px var(--mono); z-index: 10; box-shadow: 0 4px 16px rgba(0,0,0,.25); white-space: pre; }
.viewtools { position: absolute; right: 10px; top: 10px; max-width: calc(100% - 20px); flex-wrap: wrap; justify-content: flex-end; display: flex; gap: 8px; align-items: center; background: color-mix(in srgb, var(--panel) 80%, transparent); padding: 4px 8px; border-radius: 6px; }

.crumb { font-size: 11px; color: var(--accent); font-family: var(--mono); }
.formula { font-family: var(--mono); font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; white-space: pre-wrap; margin: 6px 0; }
.tabs { display: flex; gap: 4px; margin: 8px 0 4px; flex-wrap: wrap; }
.tabs button { font-size: 12px; padding: 2px 10px; }
.tabs button.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }
#heat { width: 100%; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 4px; cursor: crosshair; margin-top: 4px; background: var(--panel2); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 10px; font: 11px var(--mono); color: var(--dim); }
.stats b { color: var(--text); font-weight: 500; }
table.calc { width: 100%; border-collapse: collapse; font: 11px var(--mono); margin: 4px 0; }
table.calc td, table.calc th { padding: 2px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.calc td:first-child, table.calc th:first-child { text-align: left; }
table.calc th { color: var(--dim); font-weight: 500; }
table.calc tr.sum td { font-weight: 700; border-top: 1px solid var(--dim); }
table.calc tr.hl td { background: var(--hl); }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.check { font: 11px var(--mono); padding: 4px 6px; border-radius: 4px; margin: 6px 0; }
.check.ok { color: var(--ok); border: 1px solid var(--ok); }
.check.bad { color: var(--bad); border: 1px solid var(--bad); }
.vals { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; font: 10px var(--mono); }
.vals span { padding: 2px 3px; border-radius: 3px; text-align: right; cursor: pointer; }
.vals span.sel { outline: 1px solid var(--accent); }
.rowbtns { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.rowbtns button { font-size: 11px; padding: 2px 8px; }
code { font-family: var(--mono); font-size: 11px; }

footer { grid-column: 1 / 4; grid-row: 4; border-top: 1px solid var(--line); background: var(--panel); padding: 6px 14px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.controls button { min-width: 36px; }
#play { background: var(--accent); color: var(--ink); border: none; min-width: 48px; font-weight: 700; }
.timeline { flex: 1; display: flex; gap: 10px; align-items: center; min-width: 240px; }
.timeline input { flex: 1; accent-color: var(--accent); padding: 0; }
#speedVal { font-family: var(--mono); min-width: 54px; }

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 55vh auto auto auto; overflow: auto; height: auto; }
  header, footer { grid-column: 1; }
  aside { max-height: none; }
  #left { order: 4; } #right { order: 3; }
}

/* PREP_V1: before the first run only the text box shows, centred; the 3D view appears once data is ready */
body.pre #viewport > canvas, body.pre #viewport > .labels, body.pre .toolbar, body.pre .camhint, body.pre .viewtools, body.pre .navcorner { visibility: hidden; }
body.pre #ready { right: auto; left: 50%; transform: translate(-50%, -50%); }
.prep { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; text-align: center; z-index: 6; background: color-mix(in srgb, var(--bg) 82%, transparent); }
.prep .prepmsg { font: 600 15px system-ui, sans-serif; color: var(--text); }
.prep .bar { width: 320px; max-width: 80vw; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 0 auto; }
.prep .bar div { height: 100%; width: 0; background: var(--ink, var(--accent)); transition: width .15s; }
.prep .preppct { font: 12px var(--mono); color: var(--dim); }
#stop:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.status { font: 11px var(--mono); padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--dim); }
.status.running { color: var(--ok); border-color: var(--ok); }
.status.stopped { color: var(--bad); border-color: var(--bad); }
.status.done { color: var(--accent); border-color: var(--accent); }

.tooltip.mod { white-space: normal; max-width: 340px; font: 12px system-ui, sans-serif; line-height: 1.4; }
.tooltip.mod b { font-weight: 650; }
.tooltip.mod .st { font: 11px var(--mono); padding: 0 6px; border-radius: 8px; margin-left: 6px; border: 1px solid var(--line); }
.tooltip.mod .st.done { color: var(--ok); border-color: var(--ok); }
.tooltip.mod .st.active { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.tooltip.mod .st.pending { color: var(--dim); }
.tooltip.mod table { border-collapse: collapse; font: 11px var(--mono); margin-top: 4px; width: 100%; }
.tooltip.mod td { padding: 1px 0; } .tooltip.mod td:last-child { text-align: right; padding-left: 10px; }
.tooltip.mod .hint { color: var(--dim); font-size: 11px; margin-top: 4px; }

.notice { grid-column: 1 / 4; grid-row: 1; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 7px 14px;
  background: color-mix(in srgb, var(--accent) 16%, var(--panel)); border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); font-size: 12.5px; }
.notice b { color: var(--accent); }
.notice button { background: none; border: none; color: var(--dim); padding: 0 4px; font-size: 13px; }
.notice button:hover { color: var(--text); }
@media (max-width: 1100px) {
  body { grid-template-rows: none; }
  .notice, header, footer, #left, main#viewport, #right { grid-row: auto; }
  .notice { grid-column: 1; }
  main#viewport { height: 55vh; }
  .brand { border-right: none; padding-right: 0; }
}

.toolbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; align-items: center; z-index: 3;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.toolbar button { border: none; background: none; min-width: 34px; height: 30px; border-radius: 7px; font-size: 15px; padding: 0 6px; display: inline-grid; place-items: center; color: var(--text); }
.toolbar button:hover { background: var(--panel2); }
.toolbar button.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.camhint { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--dim); white-space: nowrap; pointer-events: none; z-index: 2; }
.navcorner { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; z-index: 3; }
.zoombar { position: relative; display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: visible; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.zoombar > button { border: none; background: none; border-radius: 0; min-width: 34px; height: 30px; }
.zoombar > button:hover { background: var(--panel2); }
#zoomPct { min-width: 58px; font-family: var(--mono); font-size: 12px; }
.zoommenu { position: absolute; bottom: 36px; left: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; min-width: 220px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.zoommenu button { display: flex; justify-content: space-between; width: 100%; border: none; background: none; padding: 6px 8px; border-radius: 6px; font-size: 12.5px; }
.zoommenu button:hover { background: var(--panel2); }
.zoommenu kbd { font: 11px var(--mono); color: var(--dim); }
.ready { position: absolute; top: 50%; right: 16px; transform: translateY(-50%); width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: 0 8px 28px rgba(0,0,0,.2); z-index: 4; }
.ready h3 { margin: 0 0 6px; color: var(--accent); }
.ready p { margin: 0 0 12px; }
.ready button { width: 100%; background: var(--accent); color: var(--ink); border: none; font-weight: 650; padding: 8px; }
@media (max-width: 1100px) { .camhint { display: none; } .toolbar { top: 6px; } }
.ready .field { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin-bottom: 10px; color: var(--dim); font-size: 12px; font-weight: 600; }
.ready textarea { font: 14px system-ui, sans-serif; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; resize: vertical; }
.ready textarea:focus, .ready input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.ready .row { display: flex; align-items: center; gap: 10px; }
.ready .row input { width: 70px; font-size: 14px; }
.ready .row small { color: var(--dim); font-weight: 500; }
.ready .err { color: var(--bad); font-size: 12px; margin: -4px 0 10px; }
.ready .fieldhead { display: flex; justify-content: space-between; align-items: baseline; }
.ready .tokcount { font: 500 11px var(--mono); color: var(--dim); }
.ready .tokcount.over { color: var(--bad); font-weight: 700; }
.ready .note { color: var(--dim); font-weight: 400; font-size: 11.5px; }
.toast { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 7px 14px; border-radius: 8px; font-size: 12.5px; z-index: 6; box-shadow: 0 6px 20px rgba(0,0,0,.25); pointer-events: none; }
.camhint b { color: var(--accent); font-weight: 600; }
