/* Mobile keeps the same cosmic direction with room for text and touch. */
.nav-toggle { display: none; }

@media (max-width: 900px) {
  :root { --mobile-gutter: max(20px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  /* Clip the root, not a scrolling ancestor of the sticky opening. */
  html, body { width: 100%; min-width: 0; max-width: 100%; overflow-x: hidden; }
  @supports (overflow: clip) {
    html, body { overflow-x: clip; }
    .site { overflow-x: clip; }
  }
  html { scroll-padding-top: calc(88px + env(safe-area-inset-top)); }
  .site, main, .journey, .stage { width: 100%; min-width: 0; max-width: 100%; }
  .cosmos-ui { contain: paint; }
  .wrap, .navin, .engineStage { width: calc(100% - var(--mobile-gutter) * 2); }
  .wrap, .head > *, .ba > *, .ppt-layout > *, .showcase-stage > *, .process-wrap > * { min-width: 0; }
  .nav { padding: calc(10px + env(safe-area-inset-top)) 0 10px; }
  .navin { gap: 10px; flex-wrap: wrap; }
  .brand { min-height: 44px; flex-shrink: 0; }
  .brand span { display: none; }
  .nav .cta { order: 1; margin-left: auto; padding: 10px 12px; font-size: .875rem; }
  .nav-toggle { order: 2; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 999px; color: #e5edf7; background: #090d15; font-size: .875rem; cursor: pointer; }
  .nav .links { order: 4; flex: 0 0 100%; display: none; gap: 0; padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: #090d15; max-height: calc(100svh - 140px); overflow-y: auto; }
  .nav.menu-open .links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav.menu-open { background: rgba(3, 4, 7, .96); }
  .nav .links a { display: flex; align-items: center; min-height: 48px; padding: 12px; font-size: .875rem; line-height: 1.5; border-radius: 10px; }
  .nav .links a:active { background: rgba(134, 216, 255, .08); }

  /* Small viewport units keep Safari's toolbar from moving the arrival. */
  #space { left: 0; right: auto; width: 100%; max-width: 100%; height: 100lvh; }
  .journey { height: calc((100 + var(--travel-vh) + var(--hold-vh)) * 1svh); }
  .stage { height: 100svh; }
  .prompt { padding: 88px var(--mobile-gutter) 32px; line-height: 1.8; font-size: .875rem; }
  .hero { grid-template-columns: minmax(0, 1fr); min-width: 0; max-width: 100%; padding: calc(80px + env(safe-area-inset-top)) var(--mobile-gutter) calc(20px + env(safe-area-inset-bottom)); gap: 12px; }
  .hero-copy, .moon-slot, .hero-footer { grid-column: 1; min-width: 0; max-width: 100%; }
  .hero .hero-copy > .ey { max-width: 100%; font-size: .75rem; line-height: 1.5; letter-spacing: .06em; }
  .hero h1 { font-size: clamp(2rem, 10.4vw, 4.5rem); line-height: 1.05; margin: 8px 0 10px; }
  .hero .hero-description { font-size: 1.125rem; line-height: 1.4; max-width: 38rem; }
  .hero .hero-moon { width: min(560px, 70vw, calc(100svh - 400px)); width: min(560px, 90cqw, 95cqh); touch-action: pan-y pinch-zoom; }
  .hero-footer .heroactions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 26rem); gap: 10px; }
  .hero-footer .heroactions .btn { width: 100%; min-width: 0; min-height: 48px; padding: 12px 10px; font-size: .875rem; line-height: 1.5; white-space: normal; }
  .hero-footer .micro { max-width: 100%; font-size: .75rem; line-height: 1.5; letter-spacing: .06em; margin-top: 14px; }
  .moon-hint { font-size: .75rem; line-height: 1.5; margin-bottom: 10px; }

  .sec { padding: 80px 0; }
  .head { gap: 20px; margin-bottom: 36px; }
  .ey { font-size: .75rem; line-height: 1.7; letter-spacing: .1em; }
  .head h2, .showcase-top h2, .engineText h2, .ba h2, .process-intro h2 { font-size: clamp(1.75rem, 7.6vw, 3.25rem); line-height: 1.1; letter-spacing: -.045em; overflow-wrap: anywhere; }
  .studio .head h2, .web-design .head h2, .ppt-system .head h2, .pricing-section .head h2, .ba h2, .process-intro h2 { font-size: clamp(1.75rem, 7.6vw, 3.25rem); line-height: 1.1; }
  .head p, .engineText p, .project-meta p, .contact p, .ba p, .process-intro p, .pc p { font-size: 1rem; line-height: 1.8; }
  .service-paths h3, .web-explained h3 { overflow-wrap: anywhere; }
  .section-link { max-width: 100%; padding: 10px 0; }
  .demo-stage { height: clamp(340px, 65svh, 580px); }
  .demo-bar, .demo-footer { flex-wrap: wrap; font-size: .75rem; line-height: 1.7; letter-spacing: .02em; }
  .demo-bar button, .demo-footer a { min-height: 44px; font-size: .875rem; display: inline-flex; align-items: center; }
  .demo-footer a { flex-shrink: 1; }
  .demo-invitation { left: 22px; right: 22px; bottom: 24px; }
  .demo-invitation > span { font-size: clamp(1.5rem, 6vw, 2rem); overflow-wrap: anywhere; }

  .ppt-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ppt-tab { min-width: 0; min-height: 58px; padding: 12px; font-size: .875rem; line-height: 1.6; overflow-wrap: anywhere; border-color: var(--line); }
  .ppt-stage { position: relative; isolation: isolate; min-width: 0; border-radius: 18px; }
  .ppt-chrome { height: auto; min-height: 48px; padding: 12px 16px; flex-wrap: wrap; gap: 8px 14px; font-size: .75rem; line-height: 1.6; letter-spacing: .02em; }
  .ppt-chrome > div { display: none; }
  .ppt-viewport { min-height: 0; }
  .ppt-slide { min-height: 0; padding: 24px 18px 40px; gap: 24px; grid-template-columns: minmax(0, 1fr); }
  .demo-copy h3 { font-size: clamp(1.5rem, 6.2vw, 2.5rem); line-height: 1.2; overflow-wrap: anywhere; }
  .demo-copy p { font-size: 1rem; line-height: 1.7; }
  .demo-copy small { font-size: .75rem; }
  .motion-scene, .data-scene, .editable-scene { height: clamp(220px, 65vw, 330px); }
  .timeline { left: 20px; right: 20px; bottom: 18px; }
  .interactive-scene { height: auto; display: flex; flex-direction: column; }
  .interactive-tabs { flex-wrap: wrap; gap: 8px; padding: 14px; }
  .hotspot { min-height: 44px; padding: 10px 12px; font-size: .875rem; line-height: 1.5; }
  .interactive-card { position: relative; inset: auto; margin: 0 14px 14px; padding: 18px; }
  .interactive-card small { font-size: .75rem; }
  .interactive-card strong { font-size: clamp(1.375rem, 5.5vw, 2rem); line-height: 1.25; overflow-wrap: anywhere; }
  .interactive-card p { font-size: 1rem; line-height: 1.7; }
  .ppt-foot { flex-wrap: wrap; padding: 14px; gap: 8px 12px; font-size: .75rem; line-height: 1.6; letter-spacing: .02em; }
  .data-kpi small { font-size: .75rem; }

  .engineStage { padding: 80px 0; gap: 24px; }
  .engine-note { font-size: .875rem; line-height: 1.6; }
  .motion-deck { height: 400px; }
  .motion-slide, .motion-shadow { width: 90%; aspect-ratio: auto; min-height: 300px; }
  .slide-grid { min-height: 300px; height: auto; }
  .slide-copy { min-width: 0; padding: 24px; gap: 16px; }
  .slide-copy h3 { font-size: clamp(1.5rem, 5.8vw, 2.5rem); line-height: 1.15; overflow-wrap: anywhere; }
  .slide-copy p { font-size: 1rem; line-height: 1.65; margin: 0; }
  .slide-kicker { font-size: .75rem; line-height: 1.6; letter-spacing: .04em; }

  .showcase-top { margin-bottom: 32px; }
  .showcase-index { font-size: 3rem; margin-top: 20px; }
  .project-meta h3 { font-size: clamp(1.75rem, 7vw, 3rem); line-height: 1.2; overflow-wrap: anywhere; }
  .project-tags span { font-size: .75rem; line-height: 1.5; letter-spacing: .04em; }
  .project-tab { width: 48px; height: 48px; flex-shrink: 0; font-size: .875rem; }
  .showcase-stage { gap: 28px; }
  .project-hall { height: auto; aspect-ratio: 16 / 9; margin: 0; }
  .hall-card { width: 100%; border-radius: 12px; }
  .hall-card.center { transform: translate(-50%, -50%); }
  .hall-card.left, .hall-card.right { opacity: 0; visibility: hidden; pointer-events: none; }
  .project-hall::before, .project-hall::after { display: none; }
  .hall-fallback { padding: 18px; }
  .hall-fallback strong { font-size: clamp(1.25rem, 5.8vw, 2rem); line-height: 1.15; }
  .hall-fallback i { margin-top: 12px; }
  .compare { aspect-ratio: 16 / 9; }
  .compare-top, .compare-foot { flex-wrap: wrap; gap: 8px; font-size: .75rem; line-height: 1.6; letter-spacing: .02em; }
  .compare-top b { font-weight: 400; }
  .labels { left: 12px; right: 12px; top: 12px; gap: 14px; font-size: .75rem; letter-spacing: 0; }
  .labels span:last-child { text-align: right; }
  .range { touch-action: pan-y pinch-zoom; margin: 0; }
  .handle { width: 44px; height: 44px; }
  .compare:focus-within { outline: 2px solid #b9e8ff; outline-offset: -3px; }
  .process-wrap { gap: 36px; }
  .process-ascent { padding-left: 28px; }
  .pc { min-height: 0; padding: 14px 0 48px; }
  .pc:before { left: -22px; }
  .pc small { font-size: .75rem; }
  .pc h3 { font-size: clamp(1.75rem, 7vw, 2.5rem); line-height: 1.2; overflow-wrap: anywhere; }
  .pc-visual { height: 140px; }
  .plan-caption p { font-size: 1rem; }
  .console-price { font-size: clamp(3rem, 14vw, 4rem); }
  .panel-heading h3 { font-size: clamp(1.5rem, 7vw, 2.5rem); overflow-wrap: anywhere; }
  .ppt-adjustments { flex-wrap: wrap; }
  .contact { padding: 88px 0; }
  .contact h2 { font-size: clamp(2rem, 8.4vw, 4rem); line-height: 1.1; overflow-wrap: anywhere; }
  .actions { margin: 28px auto 0; }
  .actions .btn { min-height: 48px; font-size: .875rem; line-height: 1.5; }
  .footer { padding: 28px 0 calc(28px + env(safe-area-inset-bottom)); font-size: .75rem; line-height: 1.9; letter-spacing: .04em; }
  .footer a { display: inline-block; padding: 12px 0; }
  .whatsapp-float { width: 52px; height: 52px; min-height: 52px; padding: 0; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
  .whatsapp-float > span { display: none; }
}

@media (max-width: 560px) {
  .nav .cta { display: none; }
  .nav-toggle { margin-left: auto; }
  .nav.menu-open .cta { display: inline-flex; order: 5; margin: 0; width: 100%; justify-content: center; }
  .hero .hero-description { font-size: 1rem; }
  .hero-footer .heroactions { gap: 8px; }
  .hero-footer .heroactions .btn { padding: 10px 8px; }
  .demo-invitation b { font-size: .875rem; padding: 12px 16px; }
}

@media (max-width: 380px) {
  :root { --mobile-gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right)); }
}

@media (pointer: coarse) {
  .glow-orb { display: none; }
  .hero .hero-moon, .range { touch-action: pan-y pinch-zoom; }
}

@media (max-width: 900px) and (max-height: 650px) {
  .hero { padding-top: calc(74px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .hero-copy > .ey, .hero-footer .micro { display: none; }
  .hero .hero-description { font-size: 1rem; }
  .moon-hint { margin-bottom: 8px; }
}

@media (max-width: 900px) and (min-width: 561px) and (max-height: 500px) {
  .hero { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); column-gap: 20px; }
  .hero .hero-copy { grid-column: 1; grid-row: 1; }
  .hero h1 { font-size: clamp(1.75rem, min(5vw, 10svh), 2.75rem); }
  .hero .hero-description { line-height: 1.3; }
  .moon-slot { grid-column: 2; grid-row: 1 / 3; }
  .hero .hero-footer { grid-column: 1; grid-row: 2; justify-content: end; }
  .moon-hint { display: none; }
}
