/* Monica Ai + Music Studio — iSweet skin (X-style dark chrome)
   Mobile (Android / iPhone): maximized fullscreen, native-app feel
   Desktop (Windows / macOS): centered window panel */

:root {
  --ym-isweet-bg: #000000;
  --ym-isweet-panel: #0a0a0a;
  --ym-isweet-surface: #16181c;
  --ym-isweet-border: #2f3336;
  --ym-isweet-text: #e7e9ea;
  --ym-isweet-muted: #71767b;
  --ym-isweet-blue: #1d9bf0;
  --ym-isweet-purple: #7856ff;
  --ym-isweet-purple-soft: rgba(120, 86, 255, 0.14);
  --ym-isweet-radius: 20px;
  --ym-isweet-shadow: 0 28px 90px rgba(0, 0, 0, 0.72);
  --ym-isweet-touch: 44px;
}

/* ── Scroll lock (iOS / Android — prevent page bounce behind overlay) ── */
html.ym-isweet-locked,
html.ym-isweet-locked body {
  overflow: hidden !important;
  width: 100% !important;
  overscroll-behavior: none;
}

html.ym-isweet-locked:not(.ym-isweet-locked-android) body {
  position: fixed !important;
  height: 100% !important;
  touch-action: manipulation;
  -webkit-overflow-scrolling: auto;
}

/* Android: avoid position:fixed on body — breaks child position:fixed overlays */
html.ym-isweet-locked-android,
html.ym-isweet-locked-android body {
  height: 100% !important;
  touch-action: manipulation;
}

html.ym-isweet-locked-android body {
  position: relative !important;
}

/* ── Hide app chrome while Monica / Studio owns the screen on phones ── */
body.ym-isweet-shell.ym-isweet-mobile.ym-monica-active #yal-mnav,
body.ym-isweet-shell.ym-isweet-mobile.ym-monica-active #yal-fab,
body.ym-isweet-shell.ym-isweet-mobile.ym-monica-active .yal-mnav-backdrop,
body.ym-isweet-shell.ym-isweet-mobile.ymm-studio-active #yal-mnav,
body.ym-isweet-shell.ym-isweet-mobile.ymm-studio-active #yal-fab,
body.ym-isweet-shell.ym-isweet-mobile.ymm-studio-active .yal-mnav-backdrop {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* ── Desktop backdrop dim ── */
body.ym-isweet-shell.ym-isweet-desktop.ym-monica-active::before,
body.ym-isweet-shell.ym-isweet-desktop.ymm-studio-active::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 8999;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  pointer-events: none;
}

/* ── Mobile: edge-to-edge maximized (visible viewport on iOS Safari) ── */
body.ym-isweet-shell.ym-isweet-mobile.ym-monica-active #ym-monica,
body.ym-isweet-shell.ym-isweet-mobile.ymm-studio-active #ymm-studio,
body.ym-isweet-shell.ym-isweet-android.ym-isweet-mobile.ym-monica-active #ym-monica,
body.ym-isweet-shell.ym-isweet-android.ym-isweet-mobile.ymm-studio-active #ymm-studio {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  transform: none !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  z-index: 12850 !important;
  height: 100vh !important;
  height: 100dvh !important;
  height: 100svh !important;
  height: var(--ym-vv-height, 100dvh) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  visibility: visible !important;
  opacity: 1 !important;
}

/* iOS: pin to visual viewport when keyboard opens */
body.ym-isweet-shell.ym-isweet-ios.ym-isweet-mobile.ym-monica-active #ym-monica,
body.ym-isweet-shell.ym-isweet-ios.ym-isweet-mobile.ymm-studio-active #ymm-studio {
  top: var(--ym-vv-offset-top, 0) !important;
  bottom: auto !important;
  height: var(--ym-vv-height, 100dvh) !important;
}

/* Android: always anchor top-left — vv offsetTop is unreliable */
body.ym-isweet-shell.ym-isweet-android.ym-isweet-mobile.ym-monica-active #ym-monica,
body.ym-isweet-shell.ym-isweet-android.ym-isweet-mobile.ymm-studio-active #ymm-studio {
  top: 0 !important;
  inset: 0 !important;
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-main,
body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-topbar {
  flex-shrink: 0;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-bottom: 8px;
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-chat {
  flex: 1 1 auto;
  min-height: 0;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-landing {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding:
    12px
    max(12px, env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-chat-input-wrap,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-chat-bottom {
  flex-shrink: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

body.ym-isweet-shell.ym-isweet-mobile.ym-isweet-kb-open #ym-monica .ym-chat-input-wrap,
body.ym-isweet-shell.ym-isweet-mobile.ym-isweet-kb-open #ym-monica .ym-chat-bottom {
  padding-bottom: 8px;
}

body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-layout {
  min-height: 0;
}

body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 0;
}

body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-rail {
  flex-shrink: 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  padding-left: max(4px, env(safe-area-inset-left, 0px));
  padding-right: max(4px, env(safe-area-inset-right, 0px));
}

body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-create-dock,
body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-player {
  flex-shrink: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

body.ym-isweet-shell.ym-isweet-mobile.ym-isweet-kb-open #ymm-studio .ymm-create-dock,
body.ym-isweet-shell.ym-isweet-mobile.ym-isweet-kb-open #ymm-studio .ymm-player {
  padding-bottom: 10px;
}

/* ── Touch targets (Apple HIG / Material 44px) ── */
body.ym-isweet-shell.ym-isweet-mobile #ym-monica button,
body.ym-isweet-shell.ym-isweet-mobile #ymm-studio button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-topbar button,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica #ym-back,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-chat-exit,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-ask-icon,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-ask-voice,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-ask-mode,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-close-chat,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-chat-top button,
body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-rail-btn,
body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-icon-btn,
body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-song-del {
  min-width: var(--ym-isweet-touch);
  min-height: var(--ym-isweet-touch);
}

/* iOS: 16px+ inputs prevent auto-zoom on focus */
body.ym-isweet-shell.ym-isweet-ios #ym-monica .ym-landing-input,
body.ym-isweet-shell.ym-isweet-ios #ym-monica .ym-chat-input,
body.ym-isweet-shell.ym-isweet-ios #ym-monica .ym-ask-bar input,
body.ym-isweet-shell.ym-isweet-ios #ym-monica .ym-ask-bar textarea,
body.ym-isweet-shell.ym-isweet-ios #ymm-studio textarea,
body.ym-isweet-shell.ym-isweet-ios #ymm-studio input,
body.ym-isweet-shell.ym-isweet-ios #ymm-studio select {
  font-size: 16px !important;
}

/* Android Chrome: smoother scrolling + text size adjust + 16px inputs (no zoom) */
body.ym-isweet-shell.ym-isweet-android #ym-monica,
body.ym-isweet-shell.ym-isweet-android #ymm-studio {
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body.ym-isweet-shell.ym-isweet-android #ym-monica .ym-landing-input,
body.ym-isweet-shell.ym-isweet-android #ym-monica .ym-chat-input,
body.ym-isweet-shell.ym-isweet-android #ym-monica .ym-ask-bar input,
body.ym-isweet-shell.ym-isweet-android #ym-monica .ym-ask-bar textarea,
body.ym-isweet-shell.ym-isweet-android #ymm-studio textarea,
body.ym-isweet-shell.ym-isweet-android #ymm-studio input,
body.ym-isweet-shell.ym-isweet-android #ymm-studio select {
  font-size: 16px !important;
}

/* Mobile perf: lighter universe FX */
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-universe-fx .yal-login-aurora,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-universe-fx .yal-login-orbit {
  opacity: 0.28 !important;
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-logo::before,
body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-logo::after {
  animation: none !important;
  display: none;
}

body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-logo {
  animation: ym-burst-in 0.5s ease both !important;
  margin-bottom: 24px;
}

body.ym-isweet-shell.ym-isweet-mobile #ymm-studio .ymm-ambient-canvas {
  opacity: 0.35;
}

@media (prefers-reduced-motion: reduce) {
  body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-logo,
  body.ym-isweet-shell.ym-isweet-mobile #ym-monica .ym-logo-icon {
    animation: none !important;
  }
}

/* ── Desktop: regular windowed panel ── */
body.ym-isweet-shell.ym-isweet-desktop.ym-monica-active #ym-monica {
  position: fixed !important;
  inset: auto !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  width: min(980px, 94vw) !important;
  height: min(860px, 92dvh) !important;
  max-width: 980px !important;
  max-height: 92dvh !important;
  border-radius: var(--ym-isweet-radius) !important;
  border: 1px solid var(--ym-isweet-border) !important;
  box-shadow: var(--ym-isweet-shadow) !important;
  overflow: hidden !important;
}

body.ym-isweet-shell.ym-isweet-desktop.ymm-studio-active #ymm-studio {
  position: fixed !important;
  inset: auto !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) scale(1.02) !important;
  width: min(1120px, 96vw) !important;
  height: min(900px, 92dvh) !important;
  max-width: 1120px !important;
  max-height: 92dvh !important;
  border-radius: var(--ym-isweet-radius) !important;
  border: 1px solid var(--ym-isweet-border) !important;
  box-shadow: var(--ym-isweet-shadow) !important;
  overflow: hidden !important;
}

body.ym-isweet-shell.ym-isweet-desktop.ymm-studio-active #ymm-studio.open {
  transform: translate(-50%, -50%) scale(1) !important;
}

/* ── iSweet chrome — Monica Ai ── */
body.ym-isweet-shell #ym-monica {
  background: var(--ym-isweet-bg) !important;
  color: var(--ym-isweet-text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

body.ym-isweet-shell #ym-monica .ym-topbar {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.55)) !important;
  border-bottom: 1px solid var(--ym-isweet-border);
}

body.ym-isweet-shell #ym-monica #ym-back,
body.ym-isweet-shell #ym-monica .ym-chat-exit {
  border-color: var(--ym-isweet-border) !important;
  background: var(--ym-isweet-surface) !important;
  color: var(--ym-isweet-text) !important;
}

body.ym-isweet-shell #ym-monica .ym-ask-bar {
  background: var(--ym-isweet-panel) !important;
  border: 1px solid var(--ym-isweet-border) !important;
  box-shadow: none !important;
}

body.ym-isweet-shell #ym-monica .ym-quick-btn {
  background: var(--ym-isweet-surface) !important;
  border: 1px solid var(--ym-isweet-border) !important;
  color: var(--ym-isweet-text) !important;
}

body.ym-isweet-shell #ym-monica .ym-quick-btn:hover {
  background: var(--ym-isweet-purple-soft) !important;
  border-color: rgba(120, 86, 255, 0.45) !important;
}

body.ym-isweet-shell #ym-monica .ym-msg-user .ym-bubble {
  background: rgba(29, 155, 240, 0.12) !important;
  border-color: rgba(29, 155, 240, 0.28) !important;
}

body.ym-isweet-shell #ym-monica .ym-msg-assistant .ym-bubble {
  background: var(--ym-isweet-surface) !important;
  border: 1px solid var(--ym-isweet-border) !important;
}

body.ym-isweet-shell #ym-monica .ym-drawer {
  background: #000 !important;
  border-right: 1px solid var(--ym-isweet-border) !important;
}

body.ym-isweet-shell #ym-monica .ym-logo-text {
  background: linear-gradient(100deg, var(--ym-isweet-blue), var(--ym-isweet-purple), #f0249b) !important;
  background-size: 280% auto !important;
}

/* ── iSweet chrome — Music Studio ── */
body.ym-isweet-shell #ymm-studio {
  background: var(--ym-isweet-bg) !important;
  color: var(--ym-isweet-text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

body.ym-isweet-shell #ymm-studio .ymm-rail {
  background: #000 !important;
  border-right-color: var(--ym-isweet-border) !important;
  box-shadow: inset -1px 0 0 rgba(47, 51, 54, 0.8) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-rail-btn {
  color: var(--ym-isweet-muted) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-rail-btn.active,
body.ym-isweet-shell #ymm-studio .ymm-rail-btn:hover {
  background: var(--ym-isweet-purple-soft) !important;
  color: var(--ym-isweet-blue) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-card,
body.ym-isweet-shell #ymm-studio .ymm-studio-hero,
body.ym-isweet-shell #ymm-studio .ymm-player {
  background: var(--ym-isweet-panel) !important;
  border-color: var(--ym-isweet-border) !important;
  box-shadow: none !important;
}

body.ym-isweet-shell #ymm-studio .ymm-card label,
body.ym-isweet-shell #ymm-studio .ymm-section-title,
body.ym-isweet-shell #ymm-studio .ymm-studio-title-main {
  color: var(--ym-isweet-text) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-card textarea,
body.ym-isweet-shell #ymm-studio .ymm-card input,
body.ym-isweet-shell #ymm-studio .ymm-card select {
  background: var(--ym-isweet-surface) !important;
  border: 1px solid var(--ym-isweet-border) !important;
  color: var(--ym-isweet-text) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-tag {
  border-color: var(--ym-isweet-border) !important;
  background: var(--ym-isweet-surface) !important;
  color: var(--ym-isweet-muted) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-tag.on {
  background: var(--ym-isweet-purple-soft) !important;
  border-color: rgba(120, 86, 255, 0.5) !important;
  color: var(--ym-isweet-text) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-generate {
  background: linear-gradient(100deg, var(--ym-isweet-purple), var(--ym-isweet-blue)) !important;
  color: #fff !important;
}

body.ym-isweet-shell #ymm-studio .ymm-song-card {
  background: var(--ym-isweet-panel) !important;
  border-color: var(--ym-isweet-border) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-song-card.playing {
  border-color: rgba(120, 86, 255, 0.65) !important;
  box-shadow: 0 0 24px rgba(120, 86, 255, 0.2) !important;
}

body.ym-isweet-shell #ymm-studio .ymm-player {
  border-top-color: var(--ym-isweet-border) !important;
  background: rgba(0, 0, 0, 0.95) !important;
}

@media (max-width: 760px) {
  body.ym-isweet-shell #ymm-studio .ymm-layout {
    grid-template-columns: 64px 1fr;
  }

  body.ym-isweet-shell #ymm-studio .ymm-rail-label {
    font-size: 0.55rem;
  }

  body.ym-isweet-shell #ymm-studio .ymm-studio-hero {
    padding: 14px 10px 18px;
  }

  body.ym-isweet-shell #ym-monica .ym-logo-text {
    font-size: clamp(2.2rem, 10vw, 3rem) !important;
  }

  body.ym-isweet-shell #ym-monica .ym-quick-actions {
    gap: 8px;
    max-width: 100%;
  }

  body.ym-isweet-shell #ym-monica .ym-quick-btn {
    font-size: 0.82rem;
    padding: 10px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.ym-isweet-shell.ym-isweet-desktop.ymm-studio-active #ymm-studio.open {
    transform: translate(-50%, -50%) !important;
  }
}
