:root {
  --bg: #1a1b26; --bg2: #16161e; --panel: #24283b; --panel2: #1f2335; --line: #2f3549; --line2: #3b4261;
  --fg: #c0caf5; --fg2: #a9b1d6; --mute: #565f89; --blue: #7aa2f7; --cyan: #7dcfff; --magenta: #bb9af7;
  --green: #9ece6a; --orange: #ff9e64; --red: #f7768e; --yellow: #e0af68; --teal: #73daca;
  --glass: rgba(31, 35, 53, .78); --r: 14px;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font: 13px/1.4 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#c.pointer { cursor: pointer; }
#labels { position: absolute; inset: 0; pointer-events: none; }
.hidden { display: none !important; }
kbd { font: 600 10px var(--mono); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line2); background: var(--bg2); color: var(--fg2); }

/* ---------- glass panels ---------- */
#topbar, #side .card, #drawer, #hint, .mbox {
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(122, 162, 247, .14); box-shadow: 0 10px 40px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .03);
}
#topbar { position: absolute; top: 12px; left: 12px; right: 12px; height: 56px; border-radius: var(--r);
  display: flex; align-items: center; gap: 18px; padding: 0 12px 0 14px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.brand .logo { width: 30px; height: 30px; color: var(--blue); filter: drop-shadow(0 0 6px rgba(122, 162, 247, .55)); }
.brand b { font-size: 16px; letter-spacing: .3px; display: block; line-height: 1.1; }
.brand b span { color: var(--magenta); }
.brand small { color: var(--mute); font-size: 11px; }
.controls { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; }
.right { display: flex; align-items: center; gap: 8px; }

.btn { border: 1px solid var(--line2); background: var(--panel); border-radius: 10px; padding: 7px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(122, 162, 247, .12); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; border-color: var(--line2); }
.btn.primary { background: linear-gradient(180deg, #7aa2f7, #5f86e0); color: #11121a; border-color: #8fb1ff; font-weight: 650;
  box-shadow: 0 0 18px rgba(122, 162, 247, .35); }
.btn.primary kbd { background: rgba(0, 0, 0, .18); border-color: rgba(0, 0, 0, .2); color: #11121a; }
.btn.primary:hover { box-shadow: 0 0 26px rgba(122, 162, 247, .55); }
.btn.primary:disabled { background: var(--panel); color: var(--mute); border-color: var(--line2); box-shadow: none; }
.btn.primary:disabled kbd { color: var(--mute); }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--red); color: var(--red); box-shadow: 0 0 0 3px rgba(247, 118, 142, .12); }
.btn.solid.danger { background: var(--red); color: #1a1b26; border-color: var(--red); font-weight: 650; }
.btn.pulse { animation: pulse .35s ease-out; }
@keyframes pulse { 0% { transform: scale(.96); } 100% { transform: scale(1); } }

.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--fg2); transition: .15s; }
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--panel); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line2); }
#mode button[data-mode=auto].on { background: rgba(158, 206, 106, .15); color: var(--green); box-shadow: inset 0 0 0 1px rgba(158, 206, 106, .5), 0 0 14px rgba(158, 206, 106, .25); }
#mode button[data-mode=manual].on { color: var(--blue); }
.seg.small button { padding: 6px 9px; font: 600 11px var(--mono); }
.seg.small button.on { color: var(--cyan); }

.conn { display: inline-flex; align-items: center; gap: 6px; color: var(--mute); font-size: 11px; padding: 0 6px; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--mute); }
.conn.ok i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn.ok em { color: var(--fg2); }
.conn.bad i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.conn em { font-style: normal; }

/* ---------- side panel ---------- */
#side { position: absolute; top: 80px; right: 12px; bottom: 12px; width: 330px; display: flex; flex-direction: column; gap: 10px; z-index: 4; pointer-events: none; }
#side .card { border-radius: var(--r); padding: 12px 14px; pointer-events: auto; }
#side .card.grow { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
.card h3 { margin: 0 0 10px; font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--fg2); display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 22px; }
.seqchip { font: 600 10px var(--mono); color: var(--mute); letter-spacing: 0; text-transform: none; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kpi b { display: block; font: 700 20px var(--mono); }
.kpi span { color: var(--mute); font-size: 11px; }
.kpi.blue b { color: var(--blue); } .kpi.orange b { color: var(--orange); } .kpi.green b { color: var(--green); }
.progress { height: 5px; border-radius: 4px; background: var(--bg2); margin: 10px 0 8px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--green)); box-shadow: 0 0 10px rgba(158, 206, 106, .6); transition: width .4s; }
.dbline { display: flex; justify-content: space-between; color: var(--mute); font-size: 11px; }
.dbline b { color: var(--fg2); font-family: var(--mono); font-weight: 600; }

#find { display: flex; gap: 4px; text-transform: none; letter-spacing: 0; }
#find input { width: 92px; background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 3px 7px; font: 11px var(--mono); outline: none; text-transform: uppercase; }
#find input:focus { border-color: var(--magenta); }
#find button { background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; padding: 0 7px; color: var(--mute); }
.empty { color: var(--mute); font-size: 12px; padding: 4px 0 2px; }
.cube-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cube-id { font: 700 20px var(--mono); color: var(--magenta); text-shadow: 0 0 12px rgba(187, 154, 247, .5); }
.pill { font: 600 10px var(--mono); padding: 2px 7px; border-radius: 20px; border: 1px solid currentColor; text-transform: uppercase; letter-spacing: .5px; }
.pill.raw { color: var(--blue); } .pill.in_process { color: var(--orange); } .pill.done { color: var(--green); }
.cube-head .locate { margin-left: auto; padding: 3px 9px; font-size: 11px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12px; margin-bottom: 8px; }
.facts dt { color: var(--mute); } .facts dd { margin: 0; font-family: var(--mono); font-size: 11.5px; }
.facts .yes { color: var(--green); } .facts .no { color: var(--mute); }
.hist { list-style: none; margin: 0; padding: 0 0 0 2px; max-height: 170px; overflow: auto; border-left: 1px solid var(--line2); }
.hist li { position: relative; padding: 2px 0 4px 12px; font-size: 11.5px; color: var(--fg2); }
.hist li::before { content: ""; position: absolute; left: -4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--k, var(--mute)); box-shadow: 0 0 6px var(--k, transparent); }
.hist time { font: 10px var(--mono); color: var(--mute); margin-right: 6px; }

#feed { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; font-size: 11.5px; mask-image: linear-gradient(180deg, #000 85%, transparent); }
#feed li { display: grid; grid-template-columns: 54px 1fr; gap: 6px; padding: 4px 4px; border-radius: 6px; color: var(--fg2); cursor: default; }
#feed li.new { animation: flash 1.2s ease-out; }
#feed li[data-cube] { cursor: pointer; }
#feed li[data-cube]:hover { background: rgba(122, 162, 247, .08); }
#feed time { font: 10px var(--mono); color: var(--mute); padding-top: 1px; }
#feed .k { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--k, var(--mute)); margin-right: 6px; box-shadow: 0 0 6px var(--k, transparent); vertical-align: 1px; }
@keyframes flash { 0% { background: rgba(125, 207, 255, .14); } 100% { background: transparent; } }
.live { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--green); letter-spacing: 1px; }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2s infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- station drawer ---------- */
#drawer { position: absolute; top: 80px; left: 12px; bottom: 12px; width: 390px; border-radius: var(--r); z-index: 6;
  display: flex; flex-direction: column; transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .3s; }
#drawer.closed { transform: translateX(-110%); opacity: 0; pointer-events: none; }
.dhead { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dtitle { display: flex; align-items: center; gap: 10px; }
.dtitle i { width: 12px; height: 12px; border-radius: 4px; background: var(--sc, var(--blue)); box-shadow: 0 0 12px var(--sc, var(--blue)); }
.dtitle b { font-size: 16px; display: block; }
.dtitle small { color: var(--mute); font-size: 11px; }
.dscroll { flex: 1; overflow: auto; padding: 12px 14px 16px; }
.dstatus { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
.dstatus .now { flex: 1; }
.dstatus .now small { color: var(--mute); display: block; font-size: 11px; }
.dstatus .now b { font: 700 15px var(--mono); color: var(--sc, var(--fg)); }
.dstatus .now b.idle { color: var(--mute); font-weight: 500; font-family: var(--sans); font-size: 13px; }
#d-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
#d-form h4, .dreports h4 { grid-column: 1 / -1; margin: 2px 0 0; font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--fg2); display: flex; justify-content: space-between; }
.dreports h4 small { color: var(--mute); letter-spacing: 0; text-transform: none; font-weight: 400; }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld.wide { grid-column: 1 / -1; }
.fld label { font-size: 11px; color: var(--mute); }
.fld input, .fld select, .fld textarea { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; outline: none; transition: .15s; width: 100%; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--sc, var(--blue)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc, var(--blue)) 18%, transparent); }
.fld textarea { min-height: 58px; resize: vertical; }
.fld input.mono { font-family: var(--mono); }
.radios { display: flex; gap: 6px; }
.radios label { flex: 1; text-align: center; border: 1px solid var(--line); border-radius: 9px; padding: 6px 0; cursor: pointer; color: var(--fg2); font-size: 12px; background: var(--bg2); }
.radios input { display: none; }
.radios input:checked + span { color: var(--fg); }
.radios label:has(input:checked) { border-color: var(--rc, var(--blue)); background: color-mix(in srgb, var(--rc, var(--blue)) 14%, var(--bg2)); color: var(--fg); }
.factions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; }
.factions .btn.primary { background: var(--sc, var(--blue)); border-color: var(--sc, var(--blue)); box-shadow: 0 0 16px color-mix(in srgb, var(--sc, var(--blue)) 40%, transparent); }
.dreports { margin-top: 18px; }
#d-reports { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#d-reports li { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 11.5px; }
#d-reports li.manual { border-color: color-mix(in srgb, var(--sc, var(--blue)) 45%, var(--line)); }
#d-reports .rh { display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
#d-reports .rh b { font-family: var(--mono); }
#d-reports .rh .src { margin-left: auto; font: 600 9.5px var(--mono); color: var(--mute); text-transform: uppercase; }
#d-reports li.manual .src { color: var(--sc, var(--blue)); }
#d-reports .rd { color: var(--mute); font-family: var(--mono); font-size: 10.5px; word-break: break-word; }
#d-reports .rh a { color: var(--magenta); cursor: pointer; text-decoration: none; }

/* ---------- 3D labels ---------- */
.tag { pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 7px; padding: 5px 10px 5px 8px; border-radius: 10px;
  background: rgba(22, 22, 30, .82); border: 1px solid color-mix(in srgb, var(--sc) 45%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--sc) 22%, transparent); font-size: 11px; white-space: nowrap; transition: transform .15s, box-shadow .15s, opacity .3s; user-select: none; }
.tag:hover, .tag.hot { transform: translateY(-2px) scale(1.05); box-shadow: 0 0 22px color-mix(in srgb, var(--sc) 50%, transparent); }
.tag i { width: 8px; height: 8px; border-radius: 3px; background: var(--sc); box-shadow: 0 0 8px var(--sc); opacity: .45; transition: .2s; }
.tag.busy i { opacity: 1; }
.tag b { letter-spacing: 1.2px; font-size: 10.5px; color: var(--fg); }
.tag span { font: 10.5px var(--mono); color: var(--sc); min-width: 0; }
.tag span:empty { display: none; }
.tag kbd { font-size: 9px; padding: 0 4px; opacity: .7; }
body.focused .tag { opacity: .25; }
body.focused .tag.cur { opacity: 0; }

#hint { position: absolute; left: 12px; bottom: 12px; border-radius: 11px; padding: 8px 12px; color: var(--mute); font-size: 11.5px; display: flex; gap: 6px; align-items: center; z-index: 3; transition: opacity .3s; }
#hint kbd { margin-left: 8px; } #hint kbd:first-child { margin-left: 0; }
body.focused #hint { opacity: 0; }
#hover-tip { position: absolute; pointer-events: none; z-index: 9; background: rgba(22, 22, 30, .92); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 8px; font: 11px var(--mono); color: var(--fg); transform: translate(12px, 12px); white-space: nowrap; }
#hover-tip em { font-style: normal; color: var(--mute); margin-left: 6px; }

#toasts { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 20; pointer-events: none; }
.toast { background: rgba(36, 40, 59, .95); border: 1px solid var(--line2); border-left: 3px solid var(--tc, var(--blue)); border-radius: 10px; padding: 8px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: tin .25s ease-out; font-size: 12.5px; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

#modal { position: absolute; inset: 0; background: rgba(10, 10, 16, .55); display: grid; place-items: center; z-index: 30; }
.mbox { width: 380px; border-radius: 16px; padding: 18px 20px; background: rgba(36, 40, 59, .96); }
.mbox h3 { margin: 0 0 6px; } .mbox p { color: var(--fg2); margin: 0 0 12px; }
.chk { display: flex; gap: 8px; align-items: center; color: var(--fg2); margin-bottom: 16px; cursor: pointer; }
.chk input { accent-color: var(--red); }
.mrow { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 1100px) { #side { width: 290px; } .brand small { display: none; } #hint { display: none; } }
::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; } ::-webkit-scrollbar-track { background: transparent; }

#quality button.on { color: var(--magenta); }
#app::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(120% 90% at 50% 40%, transparent 60%, rgba(8, 8, 18, .35) 100%); }
#topbar, #side, #drawer, #hint, #toasts, #modal, #hover-tip { z-index: 5; }
.tag { transition: transform .15s, box-shadow .15s; }

/* ---------- v6: pause / sky / incidents ---------- */
#speed .pause { min-width: 30px; }
#speed .pause.on { color: var(--yellow); background: rgba(224, 175, 104, .14); box-shadow: inset 0 0 0 1px rgba(224, 175, 104, .5); }
body.paused #seq::after { content: " · paused"; color: var(--yellow); }
#sky button.on { color: var(--orange); }
#sky button[data-sky="night"].on { color: var(--blue); }
.btn.blocked { opacity: .55; }
canvas#c { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
body.grabbing canvas#c { cursor: grabbing; }
.dbline.inc { margin-top: 5px; }
#k-incwrap.alert, #k-incwrap.alert b { color: var(--red); }
#k-inc-open { font-style: normal; }
.pill.st-held { color: var(--yellow); } .pill.st-dropped, .pill.st-scrapped { color: var(--red); } .pill.st-rework { color: var(--cyan); }
h5.inch { margin: 10px 0 4px; font: 600 10px var(--mono); letter-spacing: .6px; text-transform: uppercase; color: var(--red); }
ol.incs { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 4px; }
ol.incs li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; font-size: 11.5px; padding: 5px 8px; border-radius: 8px;
  background: rgba(247, 118, 142, .06); border: 1px solid rgba(247, 118, 142, .22); color: var(--fg2); }
ol.incs li.open { cursor: pointer; border-color: var(--red); background: rgba(247, 118, 142, .13); }
ol.incs li.closed { background: rgba(115, 218, 202, .05); border-color: rgba(115, 218, 202, .2); }
ol.incs li b { font-family: var(--mono); color: var(--fg); } ol.incs li time { color: var(--mute); font: 10px var(--mono); }
#banner { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 12px;
  padding: 9px 14px 9px 12px; border-radius: 12px; border: 1px solid var(--red); color: var(--fg); cursor: pointer; text-align: left; font: inherit;
  background: linear-gradient(90deg, rgba(247, 118, 142, .28), rgba(36, 40, 59, .94) 40%); box-shadow: 0 8px 30px rgba(247, 118, 142, .25), 0 0 0 4px rgba(247, 118, 142, .08);
  backdrop-filter: blur(10px); max-width: min(560px, calc(100vw - 24px)); }
#banner.hidden { display: none; }
#banner i { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 12px var(--red); animation: andon 0.9s infinite; flex: none; }
#banner b { display: block; font-size: 13.5px; color: var(--red); letter-spacing: .2px; }
#banner span { display: block; font-size: 11.5px; color: var(--fg2); }
#banner em { font-style: normal; font: 600 11px var(--mono); color: var(--red); white-space: nowrap; border-left: 1px solid rgba(247, 118, 142, .35); padding-left: 10px; }
#banner.flash { animation: bannerFlash .6s 2; }
@keyframes andon { 50% { opacity: .25; box-shadow: none; } }
@keyframes bannerFlash { 50% { transform: translateX(-50%) scale(1.05); box-shadow: 0 0 0 8px rgba(247, 118, 142, .3); } }
body.halted #toasts { top: 136px; }
body.incident-open #drawer { border-color: rgba(247, 118, 142, .5); }
#drawer .now.inc b { color: var(--red); }
.btn.primary.danger-solid { background: var(--teal); border-color: var(--teal); color: #11121a; }
#d-reports li.inc-open { border-left-color: var(--red); }
#press-ring { position: absolute; z-index: 6; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--yellow) calc(var(--p, 0) * 1turn), transparent 0); -webkit-mask: radial-gradient(circle, transparent 21px, #000 22px); mask: radial-gradient(circle, transparent 21px, #000 22px); opacity: .9; }
#press-ring.hidden { display: none; }
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
#press-ring.go { animation: ring var(--ms, 300ms) linear forwards; }
@keyframes ring { from { --p: 0; } to { --p: 1; } }
@media (max-width: 1100px) { #sky button { padding: 6px 7px; } #banner { top: 70px; } }
@media (max-width: 1100px) { body.incident-open #banner { display: none; } }   /* the drawer already says the line is stopped; do not cover its title */

/* ================= v7: hideable side panel ================= */
#side { transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .3s; }
body.panel-collapsed:not(.mobile) #side { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
#btn-panel { padding: 6px 9px; font-size: 14px; }
#btn-panel kbd { font-size: 9px; }
body.panel-collapsed #btn-panel { color: var(--cyan); border-color: rgba(125, 207, 255, .45); }
.mobile-only { display: none !important; }
#sheet { display: none; }
.mbox .tok { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 0; font-size: 12px; color: var(--fg2); }
.mbox .tok input { background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 8px; font: 12px var(--mono); outline: none; }
.conn.sleep i { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }

/* ================= v7: phone / portrait / touch layout ================= */
body.mobile { --sheet-h: 46vh; --bar-h: 50px; --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px); }
body.mobile .mobile-only { display: revert !important; }
body.mobile .desktop-only, body.mobile #hint, body.mobile .brand div, body.mobile #speed, body.mobile #btn-step kbd, body.mobile #btn-step .lbl { display: none !important; }
body.mobile #topbar { top: calc(6px + var(--sa-t)); left: calc(6px + var(--sa-l)); right: calc(6px + var(--sa-r)); height: 48px; gap: 8px; padding: 0 6px 0 8px; border-radius: 12px; }
body.mobile .brand { min-width: 0; gap: 0; }
body.mobile .brand .logo { width: 26px; height: 26px; }
body.mobile .controls { gap: 6px; justify-content: flex-start; min-width: 0; }
body.mobile #mode button { padding: 6px 9px; font-size: 12px; }
body.mobile #btn-step { padding: 7px 11px; }
body.mobile #btn-pause-m, body.mobile #btn-more { padding: 6px 9px; min-width: 34px; justify-content: center; }
body.mobile.paused #btn-pause-m { color: var(--yellow); border-color: rgba(224, 175, 104, .6); }
body.mobile #speed-sel { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 4px; font: 600 11px var(--mono); color: var(--cyan); }
body.mobile #topright { display: none; position: absolute; top: 54px; right: 0; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid rgba(122, 162, 247, .18); border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
body.mobile #topright.open { display: flex; }
body.mobile #topright .seg { justify-content: stretch; } body.mobile #topright .seg button { flex: 1; }
body.mobile #topright .conn { justify-content: center; padding: 4px; }
body.mobile #conn-m { display: inline-block; }
body.mobile #banner { top: calc(60px + var(--sa-t)); left: 8px; right: 8px; transform: none; max-width: none; }
body.mobile #toasts { top: calc(62px + var(--sa-t)); width: calc(100% - 24px); }
body.mobile.halted #toasts { top: calc(126px + var(--sa-t)); }
body.mobile #sheet { display: flex; flex-direction: column; position: absolute; left: var(--sa-l); right: var(--sa-r); bottom: 0; height: calc(var(--sheet-h) + var(--sa-b));
  z-index: 8; padding-bottom: var(--sa-b); border-radius: 16px 16px 0 0; background: rgba(26, 27, 38, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(122, 162, 247, .18); border-bottom: 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .45); transition: height .28s cubic-bezier(.2, .8, .2, 1); }
body.mobile #sheet.dragging { transition: none; }
#sheetbar { flex: none; height: var(--bar-h); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding-top: 6px; touch-action: none; cursor: grab; }
#sheetbar .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line2); }
#sheet-tabs { width: calc(100% - 24px); max-width: 420px; }
#sheet-tabs button { flex: 1; padding: 5px 8px; font-size: 12px; }
#sheet-tabs button:disabled { opacity: .35; cursor: default; }
#sheetbody { flex: 1; min-height: 0; overflow: hidden; position: relative; }
body.mobile #side, body.mobile #drawer { position: absolute; inset: 0; width: auto; top: 0; bottom: 0; left: 0; right: 0; transform: none; opacity: 1;
  border-radius: 0; border: 0; box-shadow: none; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: auto; }
body.mobile #side { overflow-y: auto; padding: 4px 10px 10px; gap: 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
body.mobile #side .card { background: var(--panel2); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
body.mobile #side .card.grow { flex: none; min-height: 260px; max-height: 60vh; }
body.mobile #drawer .dscroll { overscroll-behavior: contain; }
body.mobile #drawer .dhead { padding: 4px 12px 8px; }
body.mobile[data-sheet=side] #drawer, body.mobile[data-sheet=drawer] #side { display: none; }
body.mobile #drawer.closed { display: none; }
body.mobile.sheet-peek #sheetbody { visibility: hidden; }
body.mobile .mbox { width: calc(100% - 24px); }
body.mobile .tag { transform: scale(.85); }

/* v7c: effective render scale next to the quality toggle */
#q-eff { align-self: center; padding: 0 6px 0 4px; font: 500 10px/1 var(--mono, ui-monospace, monospace); color: var(--muted, #737aa2); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 1599px) { body:not(.mobile) #q-eff { display: none; } }   /* the tooltip still says it */
.seg button { white-space: nowrap; }
body.mobile #quality { flex-wrap: wrap; justify-content: center; }
body.mobile #q-eff { flex-basis: 100%; text-align: center; padding: 5px 0 2px; }

/* ---------- view-only live demo (CF_VIEW_ONLY): no controls, a badge instead ---------- */
#vo-badge { display: none; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font: 600 12px var(--mono); letter-spacing: .2px;
  color: var(--green); background: rgba(158, 206, 106, .08); border: 1px solid rgba(158, 206, 106, .35); white-space: nowrap; cursor: default; }
#vo-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: andon 1.6s infinite; flex: none; }
body.view-only #vo-badge { display: inline-flex; }
body.view-only #mode, body.view-only #btn-step, body.view-only #btn-pause-m, body.view-only #speed-sel, body.view-only #speed,
body.view-only #btn-reset, body.view-only #modal, body.view-only #d-proc, body.view-only #press-ring { display: none !important; }
body.view-only #d-form .vo-note { margin: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line2); color: var(--fg2); font-size: 12.5px; line-height: 1.5; }
body.view-only #banner em { color: var(--fg2); border-left-color: var(--line2); }
body.mobile.view-only #vo-badge { padding: 5px 10px; font-size: 11px; }
@media (max-width: 380px) { body.mobile.view-only #vo-badge { font-size: 10px; padding: 4px 8px; gap: 6px; } }
