/* Mobile workspace: one compact header; the app owns the rest of the screen.
   Loaded after critical-bootstrap-css so its fixed iframe heights cannot win. */
.mobile-preview-toggle, .mobile-menu-backdrop { display: none; }
@media (max-width: 768px) {
  html, body { height: 100%; min-height: 0; overflow: hidden; }
  body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  .navbar {
    flex: 0 0 auto;
    height: calc(52px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    gap: 4px;
  }
  .navbar-right { gap: 4px; }
  .navbar-right #auth-container { display: none !important; } /* Account stays in Menu. */
  .navbar-right .mobile-preview-toggle,
  .navbar-right .mobile-chat-toggle {
    display: inline-flex !important;
    width: auto !important;
    min-width: 48px;
    height: 44px !important;
    flex: 0 0 auto;
    padding: 0 10px;
    justify-content: center;
    font-size: 13px;
  }
  .navbar-right .mobile-menu-toggle {
    width: 44px !important; height: 44px !important; flex: 0 0 44px;
  }
  .main-layout { flex: 1 1 0; height: auto; min-height: 0; width: 100%; overflow: hidden; }
  .editor-panel { height: 100%; min-height: 0; padding: 0; border: 0; }
  .editor-content { flex: 1 1 0; min-height: 0; }
  .editor-tabs, .preview-toolbar, .status-bar, .studio-footer { display: none; }
  .preview-stage,
  .preview-stage.preview-phone,
  .preview-stage.preview-tablet { padding: 0; min-height: 0; overflow: hidden; }
  /* A saved desktop device setting must not add a frame inside a real phone. */
  .preview-stage iframe#preview-frame {
    display: block; width: 100%; max-width: 100%; height: 100%; min-height: 0;
    flex: 1 1 0; border-radius: 0; box-shadow: none;
  }
  .editor-panel { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .chat-panel {
    top: calc(52px + env(safe-area-inset-top, 0px));
    max-width: none; min-width: 0; min-height: 0; padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow: hidden;
  }
  .chat-overlay { top: calc(52px + env(safe-area-inset-top, 0px)); }
  #model-selector-wrap { display: none; } /* The locked model picker is not an action. */
  .chat-header, .chat-input-area { flex-shrink: 0; }
  .chat-messages { min-height: 0; }
  .mobile-close { display: inline-flex; min-height: 44px; }
  .mobile-actions-menu {
    top: calc(52px + env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 60px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }
  .mobile-menu-backdrop:not(.hidden) {
    display: block; position: fixed; inset: calc(52px + env(safe-area-inset-top, 0px)) 0 0;
    z-index: 99998; border: 0; background: rgba(0, 0, 0, .12); cursor: default;
  }
  .mobile-actions-menu button, #m-auth-section a { min-height: 44px; }
  .mobile-actions-menu > * { flex-shrink: 0; }
  .mobile-actions-menu button:disabled { opacity: .45; cursor: default; }
  body:has(.chat-panel.mobile-open) #mobile-chat-toggle,
  body:not(:has(.chat-panel.mobile-open)):has(#pane-preview.active) #mobile-preview-toggle {
    background: var(--accent); color: white; border-color: transparent;
  }
  .empty-preview { top: 0; padding: 24px 16px; overflow-y: auto; }
  #auth-overlay { overflow-y: auto; }
}
@media (max-width: 768px) and (max-height: 600px) {
  .empty-preview { justify-content: flex-start; padding: 16px; }
  .empty-icon { font-size: 32px; margin-bottom: 8px; }
  .empty-actions { margin-top: 12px; gap: 8px; }
  .chat-suggestions { display: none; }
}

/* Calm, phone-first chat; navigation lives only in the top bar. */
.studio-brand-short { display: none; }
.chat-welcome { margin: auto; padding: 24px 12px; text-align: center; }
.chat-welcome .welcome-symbol { color: #a78bfa; font-size: 36px; margin-bottom: 16px; }
.chat-welcome h2 { font-size: 23px; line-height: 1.2; letter-spacing: -.6px; margin: 0 0 12px; color: #f8fafc; }
.chat-welcome p { font-size: 14px; line-height: 1.7; color: #94a3b8; }
@media (max-width: 768px) {
  .navbar-left .navbar-logo { max-width: none; font-size: 14px; letter-spacing: -.4px; }
  .navbar-right { gap: 2px; }
  .navbar-right .mobile-menu-toggle { order: 3; }
  .navbar-right .mobile-chat-toggle { order: 1; }
  .navbar-right .mobile-preview-toggle { order: 2; }
  .chat-panel { bottom: auto; height: calc(var(--chat-viewport-height, 100dvh) - 52px - env(safe-area-inset-top, 0px)); }
  .chat-header { display: none; }
  .chat-messages { order: 1; padding: 20px 16px; }
  .chat-generating { order: 2; flex-shrink: 1; min-height: 0; overflow-y: auto; }
  .chat-suggestions {
    order: 3; display: flex; flex-wrap: nowrap; flex: 0 0 auto; gap: 8px;
    overflow-x: auto; border: 0; padding: 10px 16px; scrollbar-width: thin;
  }
  .chat-suggestions .chip { flex: 0 0 auto; min-height: 44px; padding: 10px 14px; border-radius: 14px; font-size: 13px; }
  .chat-panel:has(.message) .chat-suggestions { display: none; }
  .chat-input-area { order: 4; padding: 12px 14px; border-top: 0; background: #0a0e23; }
  .chat-input-row { padding: 6px; border: 1px solid #39405e; border-radius: 20px; background: #11172d; gap: 6px; }
  .chat-input-row:focus-within { border-color: #a78bfa; }
  .chat-input-area textarea { min-width: 0; min-height: 60px; max-height: 120px; font-size: 16px; line-height: 1.5; padding: 10px; background: transparent; border: 0; border-radius: 0; }
  .chat-input-area textarea:focus { box-shadow: none; border: 0; }
  .chat-input-area .btn-send { width: 44px; height: 44px; min-height: 44px; border-radius: 14px; margin: 0 2px 2px 0; }
  .message { max-width: 100%; }
  .message-avatar { display: none; }
  .message-content { font-size: 15px; line-height: 1.65; }
  .chat-welcome h2 { font-size: 28px; }
  .chat-welcome p { font-size: 15px; }
}
@media (max-width: 359px) {
  .studio-brand-full { display: none; }
  .studio-brand-short { display: inline; }
}
@media (max-width: 768px) and (max-height: 550px) {
  .chat-welcome { padding: 8px; }
  .chat-welcome .welcome-symbol { font-size: 24px; margin-bottom: 8px; }
  .chat-welcome h2 { font-size: 22px; margin-bottom: 8px; }
  .chat-welcome p { font-size: 13px; }
  .chat-suggestions { display: none; }
  .chat-messages { padding: 12px; }
}
@media (max-width: 768px) {
  .chat-compact-viewport .chat-suggestions { display: none; }
  .chat-compact-viewport .chat-welcome { padding: 8px; }
  .chat-compact-viewport .welcome-symbol { display: none; }
  .chat-compact-viewport .chat-welcome h2 { font-size: 22px; margin-bottom: 8px; }
  .chat-compact-viewport .chat-welcome p { font-size: 13px; }
}

/* Empty preview: one purpose and one next step, without competing actions. */
#empty-preview {
  padding: 32px 24px; gap: 0;
  background: radial-gradient(ellipse at 50% 42%, rgba(139,92,246,.055), transparent 60%), #05060f;
}
#empty-preview .preview-placeholder-icon {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; margin-bottom: 24px;
  border: 1px solid rgba(167,139,250,.18); border-radius: 20px;
  color: #a78bfa; background: rgba(139,92,246,.07);
}
#empty-preview h3 {
  margin: 0 0 12px; max-width: 360px;
  color: #f1f5f9; font-size: clamp(23px, 5.6vw, 28px); line-height: 1.25;
  font-weight: 600; letter-spacing: -.6px; text-align: center;
}
#empty-preview p { margin: 0; color: #94a3b8; font-size: 15px; line-height: 1.7; }
#empty-preview .empty-actions { margin-top: 28px; width: min(100%, 260px); }
#empty-preview .empty-actions .btn {
  justify-content: center; gap: 12px; min-height: 52px; padding: 14px 20px;
  border-radius: 14px; font-size: 15px; font-weight: 600;
  background: #8b5cf6; box-shadow: 0 6px 20px rgba(139,92,246,.16);
}
#empty-preview .empty-actions .btn:hover { background: #7c3aed; transform: none; }
#empty-preview .empty-actions .btn:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 4px; }
@media (max-width: 768px) and (max-height: 600px) {
  #empty-preview { justify-content: center; padding: 20px; }
  #empty-preview .preview-placeholder-icon { width: 48px; height: 48px; margin-bottom: 16px; border-radius: 15px; }
  #empty-preview .empty-actions { margin-top: 20px; }
}
@media (max-width: 768px) and (max-height: 360px) {
  #empty-preview { justify-content: flex-start; }
  #empty-preview .preview-placeholder-icon { display: none; }
}

/* Generation reports observed progress, never simulated stages or games. */
#chat-generating { display: flex; flex-direction: column; gap: 12px; padding: 18px; margin: 12px 16px; border: 1px solid #39405e; border-radius: 16px; background: #11172d; color: #e2e8f0; font: 14px/1.6 Inter,system-ui,sans-serif; }
#chat-generating.hidden { display: none; }
#chat-generating::before { display: none; animation: none; }
#chat-generating p { margin: 0; }
#chat-generating .generation-heading { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-weight: 600; font-size: 16px; }
#chat-generating .model-badge { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #312451; box-shadow: none; }
#generation-metrics { color: #c4b5fd; font-variant-numeric: tabular-nums; font-size: 13px; }
#chat-generating .generation-help,#chat-generating small { color: #94a3b8; font-size: 12px; }
.generation-next { border-top: 1px solid #39405e; padding-top: 8px; }
.generation-next summary { cursor: pointer; min-height: 44px; padding: 10px 0; color: #c4b5fd; }
.generation-next label { display: block; margin: 10px 0 6px; }
#generation-note { width: 100%; box-sizing: border-box; min-height: 70px; padding: 10px; border: 1px solid #475569; border-radius: 10px; background: #0a0e23; color: #fff; font: 16px/1.5 system-ui; resize: vertical; }
body.is-generating #empty-preview { display: none; }
@media (max-width:768px) {
  body.is-generating .chat-messages { flex: 0 1 120px; }
  body.is-generating #chat-generating { flex: 1 1 auto; min-height: 0; overflow: auto; margin: 8px 12px; }
  body.is-generating .chat-input-area { display: none; }
}
#preview-skeleton { align-items: center; justify-content: center; text-align: center; gap: 16px; overflow: auto; padding: 24px; }
#preview-skeleton h3 { color: #f1f5f9; font-size: 24px; }
#preview-skeleton p { max-width: 420px; color: #94a3b8; line-height: 1.6; }
#preview-skeleton .btn { min-height: 48px; padding: 12px 18px; border-radius: 14px; }
@media (max-height:400px) { #preview-skeleton { justify-content: flex-start; gap: 10px; } }
@media (max-width:768px) {
  .chat-panel:not(.mobile-open) { pointer-events: none; }
  .chat-panel.mobile-open { pointer-events: auto; }
}

/* Saved work is available immediately; recovery never blocks the workspace. */
.draft-recovery-card {
  flex: 0 0 auto; box-sizing: border-box; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; min-width: 0;
  margin: 12px; padding: 14px 16px; border: 1px solid #34304c;
  border-radius: 14px; background: #111426; color: #f1f5f9;
}
.draft-recovery-copy { min-width: 0; flex: 1 1 0; }
.draft-recovery-card h2 { margin: 0 0 5px; font-size: 16px; font-weight: 600; line-height: 1.35; letter-spacing: -.2px; overflow-wrap: anywhere; }
.draft-recovery-card p { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; color: #a3aec2; font-size: 13px; line-height: 1.4; }
.draft-recovery-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.draft-recovery-age { color: #8591a8; white-space: nowrap; }
.draft-recovery-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.draft-recovery-actions .btn { min-height: 44px; padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.4; white-space: normal; }
.draft-recovery-actions .btn-primary { background: #8b5cf6; box-shadow: none; }
.draft-recovery-actions .btn-secondary { background: transparent; border-color: #41445b; color: #cbd5e1; }
.draft-recovery-actions .btn:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }
@media (max-width:768px) {
  .draft-recovery-card { flex-direction: column; align-items: stretch; gap: 12px; margin: 10px 12px; padding: 14px; max-height: 45dvh; overflow: auto; }
  .draft-recovery-copy { flex: 0 0 auto; }
  .draft-recovery-actions { flex-shrink: 0; }
  .draft-recovery-actions .btn { flex: 1 1 0; min-width: 0; }
}
@media (min-width:769px) and (max-width:1100px) {
  .draft-recovery-card { flex-wrap: wrap; }
  .draft-recovery-copy { flex-basis: 100%; }
}
@media (max-width:768px) and (max-height:400px) {
  .draft-recovery-card { padding: 8px 12px; gap: 6px; margin: 6px 10px; }
}
@media (min-width:769px) {
  .navbar-right .mobile-chat-toggle, .navbar-right .mobile-menu-toggle { display: none !important; }
}
.generation-resolved-label { display: block; margin-bottom: 8px; color: #a7c4b2; font-size: 12px; line-height: 1.5; }
.generation-resolved-error .message-content { border-color: #33443d; }
.vibe-view-result-btn { min-height: 48px; white-space: normal; }
