:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --surface-2: #1e1e2e;
  --accent: #00ff88;
  --accent-dim: #00c46a;
  --info: #00d4ff;
  --warn: #ff9f43;
  --danger: #ff4466;
  --focus: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --text: #ffffff;
  --text-muted: #a0a0b0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Mono', 'Menlo', monospace;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  background: var(--surface);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { flex: 1; font-size: 20px; font-weight: 700; letter-spacing: 0.12em; }
.header-meta { font-size: 13px; color: var(--accent-dim); letter-spacing: 0.15em; }
.back-btn {
  background: transparent;
  color: var(--text);
  border: 2px solid transparent;
  font-size: 20px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

/* --- Focus --- */
.focusable {
  outline: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.focusable:focus {
  border-color: var(--focus);
  box-shadow: 0 0 14px var(--focus-glow);
}

/* --- Home --- */
.home-content {
  flex: 1;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.intro { color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.intro code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-size: 13px;
}
.capability { display: flex; flex-direction: column; gap: 8px; }
.cap-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 14px;
}
.cap-val { color: var(--accent-dim); font-weight: 700; letter-spacing: 0.1em; }
.cap-val.ok { color: var(--accent); }
.cap-val.no { color: var(--danger); }
.hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  border-left: 3px solid var(--info);
}

.nav-bar {
  padding: 14px 18px;
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  gap: 10px;
}
.nav-btn {
  flex: 1;
  min-height: 56px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.15em;
}
.nav-btn.primary {
  background: var(--accent);
  color: #001a0d;
}
.nav-btn.primary:focus { background: #33ffaa; }

/* --- Diagnostic body --- */
.diag-body {
  flex: 1;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

/* Axis cards (primary readouts) */
.axis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.axis-card {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.axis-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  font-weight: 700;
}
.axis-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.axis-hint {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* --- 3D scene --- */
.scene {
  height: 220px;
  width: 100%;
  perspective: 900px;
  perspective-origin: 50% 35%;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(0,212,255,0.07), transparent 60%);
  border-radius: 12px;
  overflow: hidden;
}

/* Isometric "world": static camera tilt — looks down at ~25° from the
   front-right. Everything inside (glasses, floor) lives in this frame, so
   device rotations on the glasses happen relative to a tilted world view. */
.scene-world {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(25deg) rotateY(-25deg);
}

/* A real 3D floor laid flat, ~80px below the glasses */
.scene-floor3d {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 360px;
  height: 360px;
  margin: -180px 0 0 -180px;
  background-image:
    linear-gradient(rgba(0,212,255,0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.22) 1px, transparent 1px);
  background-size: 36px 36px;
  transform: translateY(80px) rotateX(90deg);
  opacity: 0.55;
  pointer-events: none;
}

.scene-compass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--info);
  letter-spacing: 0.15em;
  z-index: 2;
}
.cdir {
  position: absolute;
  background: var(--bg);
  padding: 1px 6px;
  border: 1px solid rgba(0,212,255,0.3);
  border-radius: 4px;
}
.cdir-n { top: 8px;     left: 50%; transform: translateX(-50%); }
.cdir-s { bottom: 8px;  left: 50%; transform: translateX(-50%); }
.cdir-e { right: 8px;   top: 50%;  transform: translateY(-50%); }
.cdir-w { left: 8px;    top: 50%;  transform: translateY(-50%); }

.glasses {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 70px;
  margin: -35px 0 0 -100px;
  transform-style: preserve-3d;
  transition: transform 0.04s linear;
}

.lens {
  position: absolute;
  top: 8px;
  width: 72px;
  height: 50px;
  border: 3px solid var(--accent);
  border-radius: 12px;
  background: rgba(0, 255, 136, 0.08);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}
.lens-left { left: 6px; }
.lens-right { right: 6px; }

.bridge {
  position: absolute;
  top: 22px;
  left: 78px;
  width: 44px;
  height: 6px;
  border-top: 3px solid var(--accent);
}

/* Temples (arms): horizontal bars rotated 90° around the vertical axis so
   their length runs straight back from each outer lens edge into -Z.
   They inherit preserve-3d from .glasses, so they rotate with the head pose. */
.temple {
  position: absolute;
  top: 22px;
  width: 110px;
  height: 7px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-dim) 35%, var(--accent-dim) 100%);
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(0, 255, 136, 0.25);
}
.temple-left {
  left: 6px;
  transform-origin: 0 50%;
  transform: rotateY(90deg);
}
.temple-right {
  right: 6px;
  transform-origin: 100% 50%;
  transform: rotateY(-90deg);
}

/* Ear tips — small caps at the back end of each arm to mark which way is
   "behind the head". They sit at the far end of the rotated temples. */
.temple::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}
.temple-left::after  { right: -4px; }
.temple-right::after { left: -4px;  }

/* Hinge dots at the front of each arm */
.temple::before {
  content: '';
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--info);
  box-shadow: 0 0 4px var(--info);
}
.temple-left::before  { left: -2px;  }
.temple-right::before { right: -2px; }

/* Axis arrows extending from glasses center, in glasses local frame */
.ax {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 2px;
  transform-origin: 0 50%;
  pointer-events: none;
}
.ax i {
  display: block;
  height: 100%;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
}
.ax span {
  position: absolute;
  right: -22px;
  top: -8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0 3px;
  background: var(--bg);
}
.ax-x { color: var(--danger); transform: translate(0, -1px); }
.ax-y { color: var(--accent); transform: translate(0, -1px) rotateZ(-90deg); }
.ax-z { color: var(--info);   transform: translate(0, -1px) rotateY(-90deg); }

/* --- Secondary data rows --- */
.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 12px;
}
.data-label { color: var(--text-muted); }
.data-value {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
