/* ==========================================================================
   RAY-BAN DISPLAY 600×600 SIMULATOR STYLESHEET
   ========================================================================== */

:root {
  --bg-canvas: #f8fafc;
  --surface-card: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-dark: #090d16;
  --surface-lens: #000000;
  
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --text-light: #f1f5f9;

  --meta-blue: #0081fb;
  --meta-blue-subtle: #e8f3ff;
  --meta-blue-glow: rgba(0, 129, 251, 0.3);
  
  --emerald: #10b981;
  --border-line: #e2e8f0;
  --border-dark: #1e293b;

  --font-display: "Syne", sans-serif;
  --font-body: "Space Grotesk", sans-serif;
  --font-mono: "DM Mono", monospace;
}

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

html, body {
  width: 100vw;
  min-height: 100vh;
  background-color: var(--bg-canvas);
  color: var(--text-dark);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.sim-app-shell {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-line);
}

.sim-brand h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sim-brand span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sim-header-tags {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-tag {
  background: var(--meta-blue-subtle);
  color: var(--meta-blue);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
}

.btn-back {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dark);
  text-decoration: none;
}

.btn-back:hover {
  color: var(--meta-blue);
}

/* Workspace Grid */
.sim-workspace-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  margin-top: 24px;
  align-items: center;
  min-height: calc(100vh - 114px);
}

/* Sidebar */
.sim-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-box {
  background: var(--surface-card);
  border: 1px solid var(--border-line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.panel-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--meta-blue);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.app-button-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-select-btn {
  background: var(--surface-subtle);
  border: 1px solid var(--border-line);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.app-select-btn strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dark);
}

.app-select-btn small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.app-select-btn:hover {
  border-color: var(--text-dark);
}

.app-select-btn.active {
  background: var(--meta-blue-subtle);
  border-color: var(--meta-blue);
}

.app-select-btn.active strong {
  color: var(--meta-blue);
}
.app-button-list{max-height:420px;overflow:auto}

.env-button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.env-btn {
  background: var(--surface-subtle);
  border: 1px solid var(--border-line);
  border-radius: 6px;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.15s ease;
}

.env-btn:hover {
  border-color: var(--text-dark);
}

.env-btn.active {
  background: var(--text-dark);
  color: #ffffff;
  border-color: var(--text-dark);
}

.scene-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-line);
}

.url-loader {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.url-loader input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--border-line);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text-dark);
  padding: 0 12px;
  font: 0.74rem var(--font-mono);
  outline: 0;
}

.url-loader input:focus {
  border-color: var(--meta-blue);
  box-shadow: 0 0 0 3px rgba(0, 129, 251, .12);
}

.url-loader button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--meta-blue);
  color: #fff;
  cursor: pointer;
  padding: 0 12px;
  font: 700 .68rem var(--font-mono);
}

.url-warning {
  margin-top: 10px;
  border: 1px solid rgba(245, 158, 11, .45);
  border-radius: 8px;
  background: rgba(245, 158, 11, .1);
  color: #92400e;
  padding: 10px;
  font-size: .72rem;
  line-height: 1.35;
}

.url-warning.is-danger {
  border-color: rgba(239, 68, 68, .45);
  background: rgba(239, 68, 68, .1);
  color: #991b1b;
}

/* Simulator Viewport Stage */
.sim-viewport-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100%;
}

.rayban-hardware-bezel {
  position: relative;
  background: var(--surface-dark);
  border: 4px solid var(--border-dark);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: min(560px, 100%);
}

.bezel-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.rb-script {
  font-family: cursive;
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
}

.rb-sub {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
}

.bezel-telemetry {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
}

.camera-led-bulb {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 6px #ffffff;
}

.battery-readout {
  color: var(--emerald);
}

.res-chip {
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 5px;
  border-radius: 3px;
  color: #ffffff;
}

/* 600x600 Viewport */
.optical-lens-viewport {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-lens); /* Pure black optical base */
  border: 1px solid var(--border-dark);
  isolation: isolate;
}

.env-backdrop-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 180ms ease, filter 180ms ease;
}

.env-black {
  background: #000000;
}

.hud-screen-iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: 2;
  mix-blend-mode: screen; /* Emulates RGB waveguide additive light */
}
.hud-frame-scale { position: absolute; inset: 0; width: 600px; height: 600px; transform-origin: top left; overflow: hidden; z-index: 1; mix-blend-mode: normal; opacity: 1; filter: none; transition: opacity 180ms ease, filter 180ms ease; }
.optical-lens-viewport{background:#000}.optical-lens-viewport[data-scene="tokyo"]{background:linear-gradient(150deg,#091d42 0 38%,#ee4f75 38% 43%,#151b35 43% 70%,#4cb9c5 70%)}.optical-lens-viewport[data-scene="cafe"]{background:linear-gradient(135deg,#c99b6f 0 25%,#4b5961 25% 29%,#d7b887 29% 66%,#47545c 66%)}.optical-lens-viewport[data-scene="subway"]{background:linear-gradient(90deg,#273345 0 18%,#d39d59 18% 21%,#18202e 21% 79%,#d39d59 79% 82%,#273345 82%)}.optical-lens-viewport[data-scene="lab"]{background:linear-gradient(145deg,#172d38,#346d76 45%,#17202f 46% 72%,#b3d6d3 72%)}.optical-lens-viewport[data-scene="webcam"]{background:#1e293b}.optical-lens-viewport.is-opaque{background:#000}.optical-lens-viewport:after{content:"";position:absolute;inset:0;pointer-events:none;background:linear-gradient(135deg,rgba(255,255,255,.16),transparent 32%,rgba(0,0,0,.2));z-index:0}.optical-lens-viewport.is-opaque:after{display:none}
.optical-lens-viewport.is-additive .env-backdrop-layer { opacity: 1; filter: brightness(.9) saturate(1.08); }
.optical-lens-viewport.is-opaque .env-backdrop-layer { opacity: 0; }
.hud-screen-iframe.is-additive { mix-blend-mode: screen; background: transparent; }
.hud-screen-iframe.is-opaque { mix-blend-mode: normal; background: #000; }
.hud-frame-scale.is-additive { mix-blend-mode: screen; }
.hud-frame-scale.is-additive.is-external-app { opacity: .72; filter: brightness(1.22) contrast(1.08) saturate(1.18); }
.hud-frame-scale.is-opaque { mix-blend-mode: normal; opacity: 1; filter: none; }
.blend-mode-control { display: flex; align-items: center; gap: 4px; margin-left: auto; margin-right: 12px; }
.blend-label { color: #64748b; font: 0.58rem var(--font-mono); margin-right: 3px; }
.blend-btn { background: #1e293b; border: 1px solid #334155; border-radius: 3px; color: #94a3b8; cursor: pointer; font: 0.55rem var(--font-mono); padding: 7px 8px; }
.blend-btn:hover { border-color: #fff; color: #fff; }
.blend-btn.active { background: var(--meta-blue); border-color: var(--meta-blue); color: #fff; }

.gyro-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-right: 10px;
  color: #94a3b8;
  font: .56rem var(--font-mono);
}

.gyro-controls > span {
  color: #e5f46b;
}

.gyro-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.gyro-controls input {
  width: 62px;
  accent-color: #e5f46b;
}

.gyro-orbit {
  --gyro-pitch: 0deg;
  --gyro-roll: 0deg;
  position: static;
  z-index: 1;
  width: 118px;
  min-height: 108px;
  align-self: flex-start;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(23, 212, 228, .32);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(16, 21, 34, .78), rgba(6, 10, 18, .58));
  box-shadow: 0 16px 36px rgba(0, 0, 0, .24), inset 0 0 24px rgba(23, 212, 228, .06);
  cursor: grab;
  touch-action: none;
  user-select: none;
  perspective: 520px;
}

.gyro-orbit:focus-visible {
  outline: 2px solid #e5f46b;
  outline-offset: 3px;
}

.gyro-orbit.is-dragging {
  cursor: grabbing;
  border-color: rgba(229, 244, 107, .7);
}

.gyro-stage {
  position: relative;
  width: 76px;
  height: 72px;
  transform: rotateX(var(--gyro-pitch)) rotateY(var(--gyro-roll));
  transform-style: preserve-3d;
  transition: transform .08s linear;
}

.axis-ring,
.gyro-capsule {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
}

.axis-ring {
  width: 74px;
  height: 74px;
  border: 1px solid rgba(23, 212, 228, .5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.axis-x {
  border-color: rgba(229, 244, 107, .64);
  transform: translate(-50%, -50%) rotateY(70deg);
}

.axis-y {
  transform: translate(-50%, -50%) rotateX(68deg);
}

.axis-z {
  border-color: rgba(255, 255, 255, .25);
  transform: translate(-50%, -50%) rotateZ(38deg);
}

.gyro-capsule {
  width: 24px;
  height: 54px;
  border-radius: 999px;
  transform: translate(-50%, -50%) rotateZ(-18deg);
  background: linear-gradient(90deg, #151b27 0 12%, #273143 38%, #0a0d13 100%);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: inset 8px 0 14px rgba(255, 255, 255, .08), inset -8px 0 18px rgba(0, 0, 0, .5), 0 0 30px rgba(23, 212, 228, .16);
}

.gyro-capsule i {
  position: absolute;
  left: 50%;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: #e5f46b;
  box-shadow: 0 0 20px rgba(229, 244, 107, .72);
}

.gyro-orbit small {
  color: #17d4e4;
  font: 7px var(--font-mono);
  letter-spacing: .14em;
  text-align: center;
}

/* Bottom Controls */
.bezel-bottom-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px 10px;
  padding-top: 6px;
  color: #94a3b8;
  font-family: var(--font-mono);
  font-size: 0.62rem;
}

.bezel-hint-text {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  line-height: 1.25;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--meta-blue);
  box-shadow: 0 0 6px var(--meta-blue);
}

/* Virtual D-Pad */
.virtual-dpad-module {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dpad-row {
  display: flex;
  gap: 2px;
}

.dpad-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  transition: all 0.1s ease;
}

.dpad-btn:hover {
  border-color: #ffffff;
}

.dpad-btn:active {
  background: var(--meta-blue);
}

.dpad-btn.up, .dpad-btn.down { width: 38px; height: 20px; }
.dpad-btn.left, .dpad-btn.right { width: 22px; height: 30px; }
.dpad-btn.enter {
  width: 50px;
  height: 30px;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  background: var(--meta-blue);
  border-color: var(--meta-blue);
}

@media(max-width: 860px) {
  .sim-workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media(max-width: 1180px) and (min-width: 861px) {
  .sim-app-shell { padding: 20px; }
  .sim-workspace-grid { grid-template-columns: 270px minmax(0, 1fr); gap: 20px; }
  .rayban-hardware-bezel { max-width: min(540px, 100%); }
  .gyro-controls { width: 100%; margin: 0; justify-content: center; }
  .bezel-bottom-bar { grid-template-columns: 1fr auto; }
  .blend-mode-control, .gyro-controls, .virtual-dpad-module, .gyro-orbit { margin: 0; }
  .gyro-orbit { grid-column: 1; grid-row: 2 / span 2; }
}

@media(max-width: 860px) {
  .sim-app-shell { padding: 18px; overflow-x: hidden; }
  .sim-header { gap: 12px; flex-wrap: wrap; }
  .sim-header-tags { margin-left: auto; }
  .sim-workspace-grid { width: 100%; max-width: 100%; gap: 20px; }
  .sim-viewport-stage, .rayban-hardware-bezel { width: 100%; max-width: 100%; min-width: 0; }
  .rayban-hardware-bezel { padding: 10px; }
  .optical-lens-viewport { width: min(100%, 600px); margin: 0 auto; }
  .bezel-bottom-bar { gap: 12px; align-items: flex-end; }
}

@media(max-width: 480px) {
  .sim-header-tags { width: 100%; justify-content: space-between; }
  .sim-brand h1 { font-size: 1.05rem; }
  .sim-workspace-grid { margin-top: 16px; }
  .env-button-grid { grid-template-columns: 1fr; }
  .bezel-bottom-bar { align-items: center; }
  .bezel-hint-text { font-size: .55rem; }
}

/* Mobile refinement for the standalone simulator. */
@media(max-width: 860px) {
  html,
  body {
    overflow-x: hidden;
  }

  .sim-app-shell {
    width: 100%;
    max-width: none;
    padding: 14px;
  }

  .sim-header {
    align-items: flex-start;
  }

  .sim-brand {
    min-width: 0;
  }

  .sim-brand h1 {
    line-height: 1;
  }

  .sim-header-tags {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .meta-tag,
  .btn-back {
    font-size: .65rem;
  }

  .sim-sidebar {
    order: 2;
  }

  .sim-viewport-stage {
    order: 1;
  }

  .sim-workspace-grid {
    display: flex;
    flex-direction: column;
  }

  .panel-box {
    padding: 14px;
  }

  .app-button-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
  }

  .app-select-btn {
    min-height: 74px;
  }

  .rayban-hardware-bezel {
    border-radius: 14px;
    padding: 10px;
  }

  .bezel-top-bar {
    gap: 10px;
  }

  .brand-signature {
    min-width: 0;
  }

  .rb-script {
    font-size: .95rem;
  }

  .rb-sub {
    display: block;
    margin-left: 0;
    font-size: .6rem;
  }

  .optical-lens-viewport {
    width: min(100%, calc(100vw - 52px));
  }

  .bezel-bottom-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }

  .bezel-hint-text {
    order: 3;
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .blend-mode-control {
    order: 1;
    margin: 0;
  }

  .gyro-controls {
    order: 2;
    width: 100%;
    justify-content: center;
    margin: 0;
  }

  .virtual-dpad-module {
    order: 3;
  }

  .gyro-orbit {
    width: 108px;
    min-height: 104px;
    order: 2;
  }

  .gyro-stage {
    width: 68px;
    height: 64px;
  }

  .axis-ring {
    width: 66px;
    height: 66px;
  }

  .gyro-capsule {
    width: 22px;
    height: 48px;
  }
}

@media(max-width: 520px) {
  .sim-app-shell {
    padding: 12px;
  }

  .sim-header-tags {
    align-items: stretch;
  }

  .meta-tag,
  .btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
  }

  .app-button-list,
  .env-button-grid {
    grid-template-columns: 1fr;
  }

  .rayban-hardware-bezel {
    width: 100%;
    border-width: 3px;
  }

  .bezel-top-bar {
    align-items: flex-start;
  }

  .bezel-telemetry {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .optical-lens-viewport {
    width: min(100%, calc(100vw - 44px));
  }

  .blend-mode-control {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .blend-btn {
    flex: 1 1 120px;
    min-height: 34px;
  }

  .gyro-controls label,
  .gyro-controls input {
    width: 100%;
  }

  .gyro-orbit {
    display: none;
  }

  .virtual-dpad-module {
    width: 100%;
  }

  .dpad-btn.up,
  .dpad-btn.down {
    width: 56px;
    height: 28px;
  }

  .dpad-btn.left,
  .dpad-btn.right {
    width: 40px;
    height: 42px;
  }

  .dpad-btn.enter {
    width: 88px;
    height: 42px;
  }
}
