:root {
  --bg: #0b1018; --panel: rgba(15, 23, 42, 0.92); --card: rgba(30, 41, 59, 0.7); --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --primary: #3b82f6; --accent: #10b981; --warn: #fbbf24; --bad: #f87171;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); touch-action: none; overscroll-behavior: none; }
#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 7px 11px; border-radius: 7px; border: 1px solid var(--border); background: #1e293b; color: var(--text); font: 600 12.5px var(--font); cursor: pointer; text-decoration: none; user-select: none; }
.btn:hover { background: #273449; }
.btn-sm { padding: 5px 8px; font-size: 11.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #04140e; }
.grow { flex: 1; }

#panel { position: fixed; top: 0; left: 0; bottom: 0; width: 330px; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 10; backdrop-filter: blur(6px); transition: transform .2s; }
body.panel-collapsed #panel { transform: translateX(-290px); }
body.panel-collapsed #btnTogglePanel { transform: rotate(180deg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.brand { display: flex; gap: 8px; align-items: center; }
.brand img { width: 30px; height: 30px; }
.brand h1 { font-size: 14px; margin: 0; }
.brand small { color: var(--muted); }
.head-actions { display: flex; gap: 4px; }
.panel-body { overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 9px; touch-action: pan-y; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.card-title { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #cbd5e1; }
.row { display: flex; gap: 6px; align-items: center; }
.wrap { flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 3px; }
.frow { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.frow b { color: #93c5fd; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--primary); }
select { width: 100%; padding: 6px; border-radius: 6px; background: #0f172a; color: var(--text); border: 1px solid var(--border); }
.check { display: flex; align-items: center; gap: 5px; font-size: 12px; cursor: pointer; }
.hint { color: var(--muted); font-size: 11.5px; }
.caps { font-size: 11px; color: var(--muted); }
.info { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.ok { color: var(--accent); }
.warn { color: var(--warn); }

#hud { position: fixed; right: 12px; bottom: 12px; width: 300px; background: rgba(15, 23, 42, 0.82); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; z-index: 5; display: none; flex-direction: column; gap: 5px; pointer-events: none; }
body.has-model #hud { display: flex; }
.hud-row { display: flex; justify-content: space-between; font-weight: 600; }
.hud-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hud-grid small { display: block; color: var(--muted); font-size: 10px; }
.hud-grid b { font-size: 16px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.seat { color: var(--accent); font-weight: 600; min-height: 0; }

#reticle { position: fixed; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border: 2px solid rgba(255,255,255,.9); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.5); z-index: 4; pointer-events: none; display: none; transition: transform .1s; }
body.has-model #reticle { display: block; }
#reticle.active { border-color: var(--accent); transform: scale(1.7); }

#touchStick { position: fixed; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(15,23,42,.25); z-index: 6; pointer-events: none; display: none; }
#touchStick.show { display: block; }
#touchKnob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.5); }

/* ----- Modo Cardboard: solo el canvas a pantalla completa ----- */
.exit-vr { display: none; }
body.mode-cardboard #panel, body.mode-cardboard #hud, body.mode-cardboard #reticle { display: none !important; }
body.mode-cardboard .exit-vr { display: block; position: fixed; top: 6px; left: 50%; transform: translateX(-50%); z-index: 20; padding: 6px 12px; border-radius: 0 0 8px 8px; border: none; background: rgba(0,0,0,.55); color: #fff; font: 600 12px var(--font); opacity: .6; }
body.mode-cardboard::after { content: ''; position: fixed; top: 8%; bottom: 8%; left: 50%; width: 2px; margin-left: -1px; background: #000; z-index: 15; pointer-events: none; }

#dropOverlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 8; background: radial-gradient(circle at 60% 40%, #1e293b, #0b1018); padding-left: 330px; }
body.panel-collapsed #dropOverlay { padding-left: 40px; }
.drop-box { text-align: center; max-width: 420px; padding: 28px; border: 2px dashed var(--border); border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.drop-box img { width: 60px; }
.drop-box h2 { margin: 0; }
.drop-box p { color: var(--muted); margin: 0 0 6px; }

#progress { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(2, 6, 23, .6); }
.progress-box { width: min(420px, 90vw); background: #0f172a; border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.bar { height: 8px; background: #1e293b; border-radius: 4px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .15s; }

#helpModal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(2,6,23,.7); }
.modal-box { background: #0f172a; border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; max-width: 760px; max-height: 90vh; overflow: auto; }
.modal-box table { border-collapse: collapse; width: 100%; font-size: 12px; }
.modal-box th, .modal-box td { border-bottom: 1px solid var(--border); padding: 5px 8px; text-align: left; }
.modal-box code { background: #1e293b; padding: 1px 5px; border-radius: 4px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #0f172a; border: 1px solid var(--border); padding: 9px 16px; border-radius: 8px; opacity: 0; transition: all .25s; z-index: 50; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
  #panel { width: 88vw; }
  body.panel-collapsed #panel { transform: translateX(calc(-88vw + 40px)); }
  #dropOverlay { padding-left: 0; }
  #hud { width: auto; left: 50px; right: 8px; bottom: 8px; font-size: 11px; }
}
