/* RoomSim — dark tool UI. Tokens first, then base, components, views. */
:root {
  --bg: #0f1218;
  --bg-2: #131820;
  --panel: #171c25;
  --panel-2: #1d232e;
  --panel-3: #252c39;
  --line: #2b3342;
  --line-2: #364052;
  --text: #e7eaf0;
  --muted: #8d97a8;
  --faint: #5e687a;
  --accent: #4cc2ff;
  --accent-ink: #04121c;
  --accent-soft: rgba(76, 194, 255, .14);
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff6464;
  --danger-soft: rgba(255, 100, 100, .14);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
#app { height: 100%; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; } h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .mono { font-family: var(--mono); }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 8px; }
.stack > * + * { margin-top: 12px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ico.sm { width: 15px; height: 15px; } .ico.lg { width: 24px; height: 24px; } .ico.xl { width: 40px; height: 40px; stroke-width: 1.6; }

.boot { display: grid; place-items: center; height: 100%; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, opacity .12s; user-select: none; touch-action: manipulation; }
.btn:hover { background: var(--panel-3); border-color: #43506a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: rgba(255,100,100,.4); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; }
.btn.on, .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(76,194,255,.55); color: var(--accent); }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

input, select, textarea { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 0 10px; height: 36px; width: 100%; min-width: 0; outline: none; }
textarea { padding: 8px 10px; height: auto; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="color"] { padding: 3px; width: 44px; flex: none; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; flex: none; }
input[type="range"] { padding: 0; height: 24px; background: transparent; border: 0; accent-color: var(--accent); box-shadow: none; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { opacity: .4; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 12px; color: var(--muted); font-weight: 550; }
.field .hint { font-size: 12px; color: var(--faint); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.fields.two { grid-template-columns: 1fr 1fr; }
.fields.three { grid-template-columns: 1fr 1fr 1fr; }
.unit { position: relative; }
.unit input { padding-right: 26px; }
.unit::after { content: attr(data-unit); position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 12px; pointer-events: none; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.slider { display: grid; grid-template-columns: 88px 1fr 44px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.slider output { text-align: right; font-family: var(--mono); color: var(--text); font-size: 12px; }

.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 550; padding: 0 10px; height: 30px; border-radius: 5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--panel-3); color: var(--text); }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 99px; background: var(--panel-3); color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: rgba(61,220,151,.14); color: var(--ok); }
.badge.warn { background: rgba(255,181,71,.14); color: var(--warn); }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 16px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: #bfe8ff; font-size: 13px; }
.notice.warn { background: rgba(255,181,71,.12); color: #ffd99a; }
.notice .ico { margin-top: 1px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .ico { color: var(--faint); margin-bottom: 10px; }

/* ---------- toasts & modals */
#toasts { position: fixed; z-index: 1000; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 440px); }
.toast { pointer-events: auto; background: #222a37; border: 1px solid var(--line-2); color: var(--text); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 13px; display: flex; gap: 8px; align-items: center; animation: toastIn .18s ease-out; max-width: 100%; }
.toast.error { border-color: rgba(255,100,100,.5); } .toast.error .ico { color: var(--danger); }
.toast.ok .ico { color: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; z-index: 900; background: rgba(5,8,12,.66); display: grid; place-items: center; padding: 16px; animation: fade .15s; backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); width: min(100%, 460px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(100%, 980px); }
.modal.full { width: min(100%, 1200px); height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px; overflow: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.menu { position: fixed; z-index: 950; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 4px; min-width: 190px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 9px; border: 0; background: none; color: var(--text); font: inherit; padding: 8px 10px; border-radius: 5px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--panel-3); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 4px 0; }
.progress { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- login */
.login { height: 100%; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(800px 500px at 15% 0%, rgba(76,194,255,.12), transparent 60%), radial-gradient(700px 500px at 100% 100%, rgba(61,220,151,.07), transparent 60%), var(--bg); overflow: auto; }
.login-card { width: min(100%, 380px); padding: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand img { width: 30px; height: 30px; }
.login-card form { margin-top: 22px; }
.login-card input { height: 46px; font-size: 16px; letter-spacing: .08em; }

/* ---------- app shell (dashboard pages) */
.shell { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.topbar nav { display: flex; gap: 2px; margin-left: 14px; }
.topbar nav a { color: var(--muted); padding: 7px 11px; border-radius: var(--radius-sm); font-weight: 550; display: inline-flex; align-items: center; gap: 7px; }
.topbar nav a:hover { color: var(--text); background: var(--panel); }
.topbar nav a.on { color: var(--text); background: var(--panel-2); }
.page { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.page-inner { max-width: 1240px; margin: 0 auto; padding: 22px 16px calc(40px + var(--safe-b)); }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow p { margin-top: 4px; }

.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.proj { overflow: hidden; display: flex; flex-direction: column; transition: border-color .12s, transform .12s; }
.proj:hover { border-color: var(--line-2); }
.proj-thumb { aspect-ratio: 16/10; background: linear-gradient(135deg, #1a2130, #121720); display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden; }
.proj-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proj-thumb .ico { color: var(--faint); }
.proj-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.proj-body h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.proj-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.proj-actions { display: flex; gap: 6px; margin-top: 8px; }
.proj-new { border-style: dashed; display: grid; place-items: center; min-height: 240px; cursor: pointer; color: var(--muted); background: transparent; }
.proj-new:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.method { text-align: left; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; color: var(--text); font: inherit; display: flex; flex-direction: column; gap: 6px; }
.method:hover { border-color: #46546d; }
.method.on { border-color: var(--accent); background: var(--accent-soft); }
.method .ico { color: var(--accent); }
.method b { font-size: 14px; }
.method span { font-size: 12px; color: var(--muted); }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.lib-item { overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.lib-item:hover { border-color: var(--line-2); }
.lib-item .th { aspect-ratio: 1; background: #10141b; display: grid; place-items: center; }
.lib-item .th img { width: 100%; height: 100%; object-fit: contain; }
.lib-item .nm { padding: 8px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.lib-item .nm b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- workspace */
.ws { height: 100%; display: flex; flex-direction: column; }
.ws-top { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 10px 8px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; min-height: 54px; }
.ws-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; max-width: 220px; }
.ws-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.ws-title span { font-size: 11px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; }
.save-dot.dirty { background: var(--warn); } .save-dot.err { background: var(--danger); }
.stepper { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 0 6px; justify-content: center; }
.stepper::-webkit-scrollbar { display: none; }
.step { display: inline-flex; align-items: center; gap: 7px; padding: 0 11px 0 6px; height: 34px; border-radius: 99px; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; border: 1px solid transparent; flex: none; }
.step i { font-style: normal; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--panel-3); font-size: 11px; color: var(--muted); }
.step:hover { color: var(--text); background: var(--panel); }
.step.on { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
.step.on i { background: var(--accent); color: var(--accent-ink); }
.step.done i { background: rgba(61,220,151,.2); color: var(--ok); }
.ws-body { flex: 1; display: flex; min-height: 0; position: relative; }
.ws-panel { width: 350px; flex: none; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.ws-panel-head { padding: 14px 16px 10px; display: flex; align-items: center; gap: 8px; }
.ws-panel-head h2 { flex: 1; }
.ws-panel-body { flex: 1; overflow: auto; padding: 4px 16px calc(24px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.ws-panel-foot { padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 8px; }
.ws-view { flex: 1; position: relative; min-width: 0; background: #0b0e13; overflow: hidden; }
.ws-view > canvas { display: block; width: 100%; height: 100%; outline: none; }
.ws-view canvas { touch-action: none; outline: none; }
.ws-handle { display: none; }
.view-tools { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 5; pointer-events: none; }
.view-tools > * { pointer-events: auto; }
.view-tools.right { left: auto; right: 10px; justify-content: flex-end; }
.view-tools.bottom { top: auto; bottom: 10px; }
.view-tools .btn { background: rgba(23,28,37,.86); backdrop-filter: blur(6px); }
.view-tools .btn.on { background: rgba(20,60,85,.9); }
.view-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(15,18,24,.85); border: 1px solid var(--line-2); padding: 7px 12px; border-radius: 99px; font-size: 12px; color: var(--muted); pointer-events: none; white-space: nowrap; z-index: 4; max-width: 94%; overflow: hidden; text-overflow: ellipsis; }
.view-hint b { color: var(--text); }

.section { margin-top: 16px; }
.section:first-child { margin-top: 4px; }
.section > h4 { margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.section > h4 .grow + * { text-transform: none; letter-spacing: 0; }
.list { display: flex; flex-direction: column; gap: 4px; }
.li { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid transparent; cursor: pointer; min-height: 40px; }
.li:hover { border-color: var(--line-2); }
.li.on { border-color: var(--accent); background: var(--accent-soft); }
.li .sw { width: 26px; height: 26px; border-radius: 5px; flex: none; background: #888 center/cover; border: 1px solid rgba(255,255,255,.12); }
.li .t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.li .t b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .t span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 -16px 12px; padding: 0 12px; position: sticky; top: -4px; background: var(--panel); z-index: 2; }
.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: 13px; padding: 10px 10px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.tex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.tex { border-radius: var(--radius-sm); overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; position: relative; }
.tex img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #0c0f14; }
.tex span { display: block; font-size: 11px; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.tex.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tex.none { display: grid; place-items: center; aspect-ratio: auto; color: var(--muted); min-height: 92px; font-size: 12px; }
.tex .more { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 6px; background: rgba(10,13,18,.75); border: 0; color: var(--text); display: grid; place-items: center; cursor: pointer; }
.add-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.add-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px 6px; min-height: 78px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; text-align: center; }
.add-tile:hover { border-color: var(--accent); }
.add-tile.on { border-color: var(--accent); background: var(--accent-soft); }
.add-tile img { width: 54px; height: 54px; object-fit: contain; }
.add-tile .ico { color: var(--accent); }

.color-row { display: flex; gap: 6px; flex-wrap: wrap; }
.color-row button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid rgba(255,255,255,.15); cursor: pointer; padding: 0; }

/* walk HUD */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%); }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: rgba(255,255,255,.8); box-shadow: 0 0 2px #000; }
.crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; } .crosshair::after { top: 8px; left: 0; height: 2px; width: 18px; }
.walk-start { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8,10,14,.55); pointer-events: auto; z-index: 7; padding: 16px; }
.walk-start .card { max-width: 420px; padding: 22px; text-align: center; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; text-align: left; margin: 14px 0; font-size: 13px; color: var(--muted); }
.minimap { position: absolute; right: 10px; top: 10px; width: 150px; height: 150px; border-radius: 10px; background: rgba(10,13,18,.75); border: 1px solid var(--line-2); pointer-events: none; }
.joy { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); pointer-events: none; transform: translate(-50%, -50%); }
.joy > div { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(255,255,255,.35); }
.touch-btns { position: absolute; right: 14px; bottom: calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: auto; z-index: 8; }
.touch-btns button { width: 60px; height: 60px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(20,24,32,.6); color: #fff; display: grid; place-items: center; font: inherit; font-size: 11px; font-weight: 700; touch-action: none; }
.touch-btns button.on { background: rgba(76,194,255,.35); }

/* texture editor */
.te { display: grid; grid-template-columns: 1fr 300px; gap: 16px; height: 100%; min-height: 0; }
.te-stage { position: relative; background: #07090c; border-radius: var(--radius); overflow: hidden; min-height: 300px; touch-action: none; }
.te-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.te-side { overflow: auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; padding-right: 4px; }
.te-side > * { flex: none; }
.te-preview { width: 100%; aspect-ratio: 1; background: #07090c center/contain no-repeat; border-radius: var(--radius-sm); border: 1px solid var(--line); position: relative; }
.te-preview .spinner { position: absolute; right: 8px; top: 8px; }

/* scan */
.scan { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; color: #fff; }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-top { position: relative; z-index: 3; display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 12px 10px; background: linear-gradient(rgba(0,0,0,.7), transparent); }
.scan-bottom { position: relative; z-index: 3; margin-top: auto; padding: 12px 12px calc(14px + var(--safe-b)); background: linear-gradient(transparent, rgba(0,0,0,.8) 30%); display: flex; flex-direction: column; gap: 10px; }
.scan-reticle { position: absolute; left: 50%; top: 50%; width: 70px; height: 70px; transform: translate(-50%, -50%); z-index: 2; pointer-events: none; }
.scan-reticle::before, .scan-reticle::after { content: ""; position: absolute; background: #4cc2ff; box-shadow: 0 0 4px #000; }
.scan-reticle::before { left: 34px; top: 0; width: 2px; height: 70px; } .scan-reticle::after { top: 34px; left: 0; height: 2px; width: 70px; }
.scan-reticle i { position: absolute; inset: 22px; border: 2px solid #4cc2ff; border-radius: 50%; }
.scan-read { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.scan-read span { background: rgba(0,0,0,.55); border-radius: 99px; padding: 4px 10px; font-size: 12px; font-family: var(--mono); }
.scan-big { height: 64px; font-size: 16px; border-radius: 14px; }
.scan-plan { width: 130px; height: 130px; border-radius: 10px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.2); position: absolute; right: 12px; top: calc(64px + var(--safe-t)); z-index: 3; }
.scan-panel { background: var(--bg); color: var(--text); position: absolute; inset: 0; z-index: 4; overflow: auto; }

/* ---------- responsive */
@media (max-width: 860px) {
  .topbar nav { margin-left: 0; }
  .topbar nav a span { display: none; }
  .ws-title { max-width: 120px; }
  .stepper { justify-content: flex-start; }
  .step { padding: 0 10px 0 5px; }
  .step:not(.on) span { display: none; }
  .ws-body { flex-direction: column-reverse; }
  .ws-panel { width: auto; border-right: 0; border-top: 1px solid var(--line); height: 44%; flex: none; transition: height .2s; }
  .ws.panel-min .ws-panel { height: 48px; }
  .ws.panel-max .ws-panel { height: 82%; }
  .ws-handle { display: flex; justify-content: center; padding: 6px 0 0; cursor: pointer; touch-action: none; }
  .ws-handle::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); }
  .ws-panel-head { padding: 6px 14px 8px; }
  .ws-panel-body { padding: 4px 14px calc(20px + var(--safe-b)); }
  .tabs { margin: 0 -14px 10px; }
  .te { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) auto; }
  .te-side { max-height: none; }
  .modal-back { padding: 0; align-items: end; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; max-height: 94dvh; }
  .modal.full, .modal.wide { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .modal-foot { padding-bottom: calc(12px + var(--safe-b)); }
  .hide-m { display: none !important; }
  .page-head .grow { flex-basis: 100%; }
  .te-preview { max-height: 38vh; }
  .minimap { width: 110px; height: 110px; }
}
@media (min-width: 861px) { .show-m { display: none !important; } }
@media (hover: none) { .btn:hover { background: var(--panel-2); } .btn.primary:hover { background: var(--accent); } }
