:root {
  --bg: #0b0d12;
  --panel: #11141b;
  --card: #161a23;
  --card-2: #1c2230;
  --border: #242b3a;
  --text: #e7ecf3;
  --muted: #8a93a6;
  --yaw: #ef4444;
  --pitch: #22c55e;
  --roll: #3b82f6;
  --warn: #ef4444;
  --warn-2: #b91c1c;
  --accent: #6366f1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #0f1218;
  border-bottom: 1px solid var(--border);
  z-index: 5;
  position: relative;
}

.title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.title p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.legend {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 12px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-yaw { background: var(--yaw); }
.dot-pitch { background: var(--pitch); }
.dot-roll { background: var(--roll); }

.label-yaw { color: var(--yaw); font-weight: 600; }
.label-pitch { color: var(--pitch); font-weight: 600; }
.label-roll { color: var(--roll); font-weight: 600; }

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
}

#canvas-wrap {
  position: relative;
  background: radial-gradient(ellipse at center, #131826 0%, #07080c 90%);
  overflow: hidden;
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.lock-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 28px rgba(239, 68, 68, 0.4);
  backdrop-filter: blur(8px);
  z-index: 3;
  max-width: 90%;
  text-align: center;
}
.lock-banner.hidden {
  display: none;
}

.panel {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.card-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.device-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.phone-icon { font-size: 16px; }

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider-switch {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #2a3041;
  transition: .2s;
  border-radius: 999px;
}
.slider-switch:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background-color: #fff;
  transition: .2s;
  border-radius: 50%;
}
.switch input:checked + .slider-switch {
  background-color: var(--accent);
}
.switch input:checked + .slider-switch:before {
  transform: translateX(20px);
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #2a3041;
  border-radius: 999px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform .05s, background .15s;
}
.btn:active { transform: scale(0.98); }
.btn-warn {
  background: var(--warn);
  color: #fff;
}
.btn-warn:hover { background: var(--warn-2); }
.btn-ghost {
  background: #2a3041;
  color: var(--text);
}
.btn-ghost:hover { background: #353c50; }

.readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.readout {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.r-label {
  font-size: 11px;
  margin-bottom: 4px;
}
.r-val {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
}

.quat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.quat {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}
.quat span:last-child {
  color: var(--text);
}

.hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.try-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.try-list li {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.4;
}
.try-list em {
  color: var(--text);
  font-style: normal;
  font-weight: 600;
}
.step {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.footer-note {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin: 4px 0 8px;
}

/* Mobile layout */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh 45vh;
    grid-template-rows: 55dvh 45dvh;
  }
  .panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .topbar {
    height: 56px;
  }
  .title h1 { font-size: 16px; }
  .title p { font-size: 11px; }
  .legend { display: none; }
  .layout {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
  }
}
