:root {
  --bg: #040811;
  --panel: rgba(15, 21, 36, 0.7);
  --border: rgba(93, 225, 255, 0.2);
  --text: #eaf2ff;
  --muted: #8297bb;
  --accent: #5de1ff;
  --accent-glow: rgba(93, 225, 255, 0.5);
  --danger: #ff5d8f;
  --danger-glow: rgba(255, 93, 143, 0.5);
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: monospace;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  padding: 1.5rem;
}

.scene {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
}

.video-fab-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 0.9rem 1rem 0;
}

.video-fab {
  border: 1px solid var(--border);
  background: rgba(93, 225, 255, 0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.video-fab:hover {
  background: rgba(93, 225, 255, 0.14);
  transform: translateY(-1px);
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-modal.hidden {
  display: none;
}

.video-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 17, 0.78);
  backdrop-filter: blur(6px);
}

.video-dialog {
  position: relative;
  width: min(92vw, 980px);
  max-height: 88vh;
  padding: 0.9rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: rgba(10, 16, 30, 0.96);
  box-shadow: 0 30px 100px rgba(0,0,0,0.55);
}

.video-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.video-title {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

.video-close {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

#lang-video {
  width: 100%;
  display: block;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: #000;
  max-height: calc(88vh - 4rem);
}

@media (max-width: 640px) {
  .video-fab-wrap {
    padding: 0.7rem 0.75rem 0;
  }

  .video-fab {
    width: 100%;
  }

  .video-dialog {
    width: min(96vw, 980px);
    padding: 0.7rem;
  }
}

.kicker {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.lede {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0;
}

/* Interactive Panel */
.interactive-panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.3);
}

.tab {
  flex: 1;
  text-align: center;
  padding: 1rem;
  cursor: pointer;
  color: var(--muted);
  font-weight: bold;
  transition: all 0.3s;
}

.tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  background: rgba(93, 225, 255, 0.05);
}

.stage {
  position: relative;
  min-height: 500px;
  padding: 2rem;
}

.stage-view {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  animation: fadeIn 0.5s ease;
}

.stage-view.active {
  display: flex;
}

.stage-hint {
  text-align: center;
  color: var(--muted);
  max-width: 400px;
  margin-bottom: 2rem;
  line-height: 1.5;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Phone Mockup */
.phone-mock {
  width: 260px;
  height: 480px;
  border: 4px solid #333;
  border-radius: 2rem;
  background: #0a0e17;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  margin-bottom: 2rem;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  padding: 2rem 1.5rem;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.app-icon:hover {
  transform: scale(1.1);
}

.app-icon .icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.app-icon span:last-child {
  font-size: 0.7rem;
  color: #a0aec0;
}

/* App Falling Animation */
.app-icon.falling {
  animation: fall 1s forwards cubic-bezier(0.5, -0.5, 0.5, 1.5);
}

@keyframes fall {
  0% { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--dr)) scale(0); opacity: 0; }
}

/* Fake App UI */
.fake-app {
  position: absolute;
  inset: 0;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.fake-app.hidden { display: none; }

.fake-header {
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: bold;
}

.fake-header button {
  background: none; border: none; color: var(--accent); cursor: pointer; font-size: 1.2rem;
}

.fake-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.skeleton-line { height: 12px; background: rgba(255,255,255,0.05); border-radius: 4px; }
.skeleton-line.short { width: 60%; }

.fake-btn {
  padding: 0.8rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 0.5rem;
  cursor: pointer;
}

.btn-primary {
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  border: none;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 15px var(--accent-glow);
}

.btn-primary.btn-smash {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 15px var(--danger-glow);
}

.btn-primary:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
}

/* Intent Zone */
.intent-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  min-height: 400px;
  justify-content: flex-end;
}

.orb-container {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
}

.orb {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: all 0.5s ease;
}

.orb.processing {
  transform: scale(0.6);
}

.orb.processing .ring {
  border-color: var(--accent);
  animation-duration: 0.5s !important;
}

.ring {
  position: absolute;
  inset: 10%;
  border: 2px solid rgba(93, 225, 255, 0.3);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(93, 225, 255, 0.1) inset;
}

.r1 { animation: spin 4s linear infinite; }
.r2 { animation: spin 5s linear infinite reverse; transform: rotateX(60deg) rotateY(45deg); }
.r3 { animation: spin 6s linear infinite; transform: rotateX(45deg) rotateY(60deg); }

.core {
  position: absolute;
  inset: 35%;
  background: radial-gradient(circle, #fff, var(--accent) 40%, transparent 70%);
  border-radius: 50%;
  box-shadow: 0 0 40px var(--accent);
  animation: pulse 2s ease-in-out infinite alternate;
}

@keyframes spin {
  100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.7; }
  100% { transform: scale(1.1); opacity: 1; }
}

.intent-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 100%;
  max-width: 400px;
  z-index: 10;
}

.chip {
  background: rgba(15, 21, 36, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.8rem 1.2rem;
  border-radius: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-size: 0.9rem;
  backdrop-filter: blur(5px);
}

.chip:hover {
  background: rgba(93, 225, 255, 0.1);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.chip.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.dynamic-widget {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(20, 28, 48, 0.85);
  border: 1px solid var(--accent);
  border-radius: 1rem;
  padding: 1.5rem;
  width: 260px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 30px rgba(93, 225, 255, 0.1);
  backdrop-filter: blur(15px);
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 20;
}

.dynamic-widget.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.widget-title {
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.widget-body {
  color: #e2e8f0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.widget-action {
  margin-top: 1rem;
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  padding: 0.6rem;
  border-radius: 0.5rem;
  font-weight: bold;
  cursor: pointer;
}

/* Fix layout inside iframe */
html, body {
  background: transparent !important;
  color: #fff !important;
}

.scene {
  padding: 0;
  max-width: 100%;
}

.panel {
  background: rgba(15, 21, 36, 0.4);
}


/* Fix iframe sizing issues and keep contents centered */
html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.interactive-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: none;
  background: transparent;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: unset;
  padding: 1rem;
}

.stage-view {
  width: 100%;
  max-width: 600px;
}

/* Prevent vertical overflow */
.stage {
  overflow-y: auto;
  padding: 1rem 0.5rem;
}

.stage-view {
  min-height: 100%;
}

@media (max-height: 700px) {
  .phone-mock {
    transform: scale(0.85);
    transform-origin: center top;
    margin-bottom: 0;
  }
  
  .intent-zone {
    transform: scale(0.85);
    transform-origin: center bottom;
  }
  
  .orb-container {
    top: 30%;
  }
}


/* PC Optimization */
@media (min-width: 768px) {
  .stage {
    padding: 3rem 2rem;
  }
  
  .phone-mock {
    width: 320px;
    height: 600px;
    margin-bottom: 3rem;
  }
  
  .app-icon .icon {
    width: 64px;
    height: 64px;
    font-size: 2rem;
    border-radius: 16px;
  }
  
  .app-icon span:last-child {
    font-size: 0.85rem;
    margin-top: 0.2rem;
  }
  
  .btn-smash {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
  }
  
  .orb-container {
    width: 300px;
    height: 300px;
    top: 35%;
  }
  
  .intent-inputs {
    max-width: 600px;
    gap: 1.2rem;
  }
  
  .chip {
    padding: 1.2rem 1.8rem;
    font-size: 1.1rem;
    border-radius: 1.2rem;
  }
  
  .dynamic-widget {
    width: 340px;
    padding: 2rem;
  }
  
  .widget-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }
  
  .widget-body {
    font-size: 1.05rem;
  }
}
