/* Dynamic AI build progress (components/app/buildProgress/*). Light app theme: reuses the
   existing tokens (--primary-accent / --secondary-accent / --text-dark / --text-muted) with the
   same fallbacks as nd-common.css; transparent panel so it blends with the preview area. */
.nbp {
  --nbp-accent: var(--primary-accent, #f04438);
  --nbp-accent-2: var(--secondary-accent, #f77d6d);
  --nbp-accent-soft: rgba(240, 68, 56, 0.1);
  --nbp-text: var(--text-dark, #121212);
  --nbp-muted: var(--text-muted, #5a5a5c);
  --nbp-surface: #ffffff;
  --nbp-surface-2: #f6f6f7;
  --nbp-border: rgba(18, 18, 18, 0.08);
  --nbp-ok: #15803d;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px;
  border-radius: 20px;
  background: transparent;
  border: 1px solid var(--nbp-border);
  color: var(--nbp-text);
  text-align: left;
}
.nbp-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nbp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.nbp-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--nbp-text); }
.nbp-sub { margin: 2px 0 0; font-size: 13px; color: var(--nbp-muted); }
.nbp-outcome { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; border: 1px solid var(--nbp-border); }
.nbp-outcome--success { background: rgba(21, 128, 61, 0.08); color: var(--nbp-ok); }
.nbp-outcome--failed, .nbp-outcome--timeout { background: var(--nbp-accent-soft); color: #b42318; }
.nbp-outcome--cancelled { background: var(--nbp-surface-2); color: var(--nbp-muted); }
.nbp-body { display: grid; grid-template-columns: 1fr 190px; gap: 20px; align-items: start; }
.nbp-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (max-width: 640px) { .nbp-body { grid-template-columns: 1fr; } .nbp-phone { margin: 0 auto; } }

/* Robot */
.nbp-robot { width: 44px; height: 44px; flex-shrink: 0; }
.nbp-robot-head, .nbp-robot-body { fill: var(--nbp-surface); stroke: var(--nbp-accent); stroke-width: 2.5; }
.nbp-robot-antenna { stroke: var(--nbp-accent); stroke-width: 2.5; }
.nbp-robot-light { fill: var(--nbp-accent); animation: nbp-pulse 1.6s ease-in-out infinite; }
.nbp-robot-eye { fill: var(--nbp-text); animation: nbp-blink 4s infinite; transform-origin: center; transform-box: fill-box; }
.nbp-robot--failed .nbp-robot-eye, .nbp-robot--timeout .nbp-robot-eye { fill: var(--nbp-accent); }
.nbp-robot--success .nbp-robot-eye { fill: var(--nbp-ok); }

/* Progress */
.nbp-progress-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--nbp-muted); margin-bottom: 6px; }
.nbp-progress-pct { font-weight: 700; color: var(--nbp-text); }
.nbp-progress-track { position: relative; height: 8px; border-radius: 999px; background: rgba(18, 18, 18, 0.08); overflow: hidden; }
.nbp-progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--nbp-accent), var(--nbp-accent-2)); transition: width 0.45s ease; }
.nbp-progress--indeterminate .nbp-progress-fill { width: 35%; position: absolute; left: -35%; animation: nbp-indeterminate 1.6s ease-in-out infinite; }
.nbp-progress--success .nbp-progress-fill { background: var(--nbp-ok); }
.nbp-progress--failed .nbp-progress-fill, .nbp-progress--timeout .nbp-progress-fill { background: var(--nbp-accent); }

/* Timeline */
.nbp-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.nbp-stage { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--nbp-muted); }
.nbp-stage-icon { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; border: 1.5px solid rgba(18, 18, 18, 0.18); background: var(--nbp-surface); }
.nbp-stage-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(18, 18, 18, 0.22); }
.nbp-stage-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--nbp-accent-soft); border-top-color: var(--nbp-accent); animation: nbp-spin 0.8s linear infinite; }
.nbp-stage--running { color: var(--nbp-text); font-weight: 600; }
.nbp-stage--running .nbp-stage-icon { border-color: var(--nbp-accent); }
.nbp-stage--completed { color: var(--nbp-text); }
.nbp-stage--completed .nbp-stage-icon { border-color: var(--nbp-accent); background: var(--nbp-accent); color: #fff; }
.nbp-stage--failed { color: #b42318; font-weight: 600; }
.nbp-stage--failed .nbp-stage-icon { border-color: #b42318; background: #b42318; color: #fff; }
.nbp-stage--skipped { opacity: 0.55; text-decoration: line-through; }

/* Stats */
.nbp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 0; }
.nbp-stat { padding: 8px 10px; border-radius: 10px; background: var(--nbp-surface); border: 1px solid var(--nbp-border); }
.nbp-stat dt { font-size: 11px; color: var(--nbp-muted); margin: 0; }
.nbp-stat dd { margin: 2px 0 0; font-size: 14px; font-weight: 700; color: var(--nbp-text); word-break: break-word; }
.nbp-message { margin: 0; font-size: 12px; color: var(--nbp-muted); }

/* Phone (light frame like the design-preview phones) */
.nbp-phone { position: relative; width: 190px; height: 380px; border-radius: 34px; padding: 10px; background: var(--nbp-surface); border: 1px solid var(--nbp-border); box-shadow: 0 8px 24px rgba(18, 18, 18, 0.08); }
.nbp-phone-notch { position: absolute; top: 14px; left: 50%; width: 64px; height: 16px; margin-left: -32px; border-radius: 999px; background: #1a1a1a; z-index: 2; }
.nbp-phone-screen { position: relative; height: 100%; border-radius: 26px; overflow: hidden; background: var(--nbp-surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 34px 14px 16px; }
.nbp-sim-glow { position: absolute; inset: -30%; background: radial-gradient(circle at 50% 40%, var(--nbp-accent-soft), transparent 60%); animation: nbp-pulse 4s ease-in-out infinite; }
.nbp-sim-particles i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--nbp-accent-2); opacity: 0.5; animation: nbp-float 5s ease-in-out infinite; }
.nbp-sim-particles i:nth-child(1) { left: 18%; top: 22%; } .nbp-sim-particles i:nth-child(2) { left: 72%; top: 30%; animation-delay: 1s; }
.nbp-sim-particles i:nth-child(3) { left: 40%; top: 78%; animation-delay: 2s; } .nbp-sim-particles i:nth-child(4) { left: 82%; top: 70%; animation-delay: 3s; }
.nbp-sim-particles i:nth-child(5) { left: 10%; top: 60%; animation-delay: 4s; }
.nbp-sim-blocks { position: absolute; inset: 0; pointer-events: none; }
.nbp-sim-blocks span { position: absolute; width: 22px; height: 14px; border-radius: 4px; border: 1px solid rgba(240, 68, 56, 0.35); background: var(--nbp-accent-soft); animation: nbp-float 6s ease-in-out infinite; }
.nbp-sim-blocks span:nth-child(1) { left: 12%; top: 14%; } .nbp-sim-blocks span:nth-child(2) { right: 10%; top: 46%; animation-delay: 2s; }
.nbp-sim-blocks span:nth-child(3) { left: 20%; bottom: 14%; animation-delay: 4s; }
.nbp-sim-skeleton, .nbp-sim-code, .nbp-sim-tiles, .nbp-sim-nodes { position: relative; width: 100%; z-index: 1; }
.nbp-sim-card { display: flex; gap: 8px; align-items: center; padding: 8px; margin-bottom: 8px; border-radius: 10px; background: var(--nbp-surface); border: 1px solid var(--nbp-border); animation: nbp-shimmer 2.4s ease-in-out infinite; }
.nbp-sim-card-thumb { width: 26px; height: 26px; border-radius: 8px; background: var(--nbp-accent-soft); flex-shrink: 0; }
.nbp-sim-card-lines { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.nbp-sim-card-lines i { display: block; height: 5px; border-radius: 3px; background: rgba(18, 18, 18, 0.1); }
.nbp-sim-card-lines i:last-child { width: 60%; }
.nbp-sim-code span { display: block; height: 6px; margin: 0 0 7px; border-radius: 3px; background: linear-gradient(90deg, var(--nbp-accent), var(--nbp-accent-2)); opacity: 0.3; animation: nbp-type 2.8s ease-in-out infinite; transform-origin: left; }
.nbp-sim-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nbp-sim-tiles span { aspect-ratio: 1; border-radius: 10px; background: var(--nbp-surface); border: 1px solid rgba(240, 68, 56, 0.3); animation: nbp-float 4s ease-in-out infinite; }
.nbp-sim-nodes { height: 120px; }
.nbp-sim-nodes line { stroke: rgba(240, 68, 56, 0.45); stroke-width: 1.5; stroke-dasharray: 4 4; animation: nbp-dash 2s linear infinite; }
.nbp-sim-nodes circle { fill: var(--nbp-surface); stroke: var(--nbp-accent); stroke-width: 2; animation: nbp-pulse 2s ease-in-out infinite; }
.nbp-sim-ring { position: relative; z-index: 1; width: 64px; height: 64px; }
.nbp-sim-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.nbp-sim-ring-track { fill: none; stroke: rgba(18, 18, 18, 0.08); stroke-width: 5; }
.nbp-sim-ring-fill { fill: none; stroke: var(--nbp-accent); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 0.45s ease; }
.nbp-sim-ring--pulse svg { animation: nbp-spin 1.6s linear infinite; }
.nbp-sim-ring-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--nbp-text); }
.nbp-sim-stage { position: relative; z-index: 1; margin: 0; font-size: 11px; font-weight: 600; text-align: center; color: var(--nbp-muted); }

@keyframes nbp-spin { to { transform: rotate(360deg); } }
@keyframes nbp-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes nbp-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.15); } }
@keyframes nbp-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes nbp-shimmer { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
@keyframes nbp-type { 0% { transform: scaleX(0.2); opacity: 0.15; } 50% { transform: scaleX(1); opacity: 0.5; } 100% { transform: scaleX(1); opacity: 0.15; } }
@keyframes nbp-dash { to { stroke-dashoffset: -16; } }
@keyframes nbp-indeterminate { 0% { left: -35%; } 100% { left: 100%; } }

/* Pre-payment DeferredBuildPanel: fills the preview area (loader + ready view). */
.ws-deferred-build { width: 100%; padding: 12px 16px; box-sizing: border-box; }
.ws-deferred-build--full { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.ws-deferred-build--full > .nbp { flex: 1 1 auto; max-width: none; }
.nbp-deferred-grid { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.4fr) 190px; gap: 18px; align-items: start; margin-top: 16px; }
@media (max-width: 900px) { .nbp-deferred-grid { grid-template-columns: 1fr; } .nbp-deferred-grid .nbp-phone { margin: 0 auto; } }
.nbp-editor { border-radius: 14px; border: 1px solid var(--nbp-border); background: var(--nbp-surface); overflow: hidden; min-width: 0; }
.nbp-editor-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--nbp-border); background: var(--nbp-surface-2); }
.nbp-editor-bar i { width: 9px; height: 9px; border-radius: 50%; background: rgba(18, 18, 18, 0.15); }
.nbp-editor-bar i:first-child { background: var(--nbp-accent); }
.nbp-editor-file { margin-left: 8px; font-size: 11px; color: var(--nbp-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nbp-editor-body {
  position: relative;
  height: auto;
  min-height: 0;
  max-height: 340px;
  overflow: hidden;
}
.nbp-editor-body::after { content: ''; position: absolute; inset: 0 0 auto; height: 28px; background: linear-gradient(var(--nbp-surface), transparent); z-index: 1; pointer-events: none; }
.nbp-editor-scroll { position: relative; top: auto; left: auto; right: auto; bottom: auto; padding: 10px 12px 14px; }
.nbp-editor-line { display: flex; gap: 10px; padding: 0 12px; font: 11.5px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; }
.nbp-editor-ln { width: 18px; text-align: right; color: rgba(18, 18, 18, 0.35); flex-shrink: 0; }
.nbp-editor-code { color: var(--nbp-text); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nbp-editor-caret { color: var(--nbp-accent); animation: nbp-blink-cursor 1s steps(1) infinite; }
.nbp-tabs { display: flex; gap: 6px; padding: 4px; margin: 0 0 12px; border-radius: 12px; background: var(--nbp-surface-2, #f6f6f7); border: 1px solid rgba(18, 18, 18, 0.08); width: max-content; }
.nbp-tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-muted, #5a5a5c); cursor: pointer; }
.nbp-tab.is-active { background: #fff; color: var(--text-dark, #121212); box-shadow: 0 1px 3px rgba(18, 18, 18, 0.12); }
.nbp-tab:focus-visible { outline: 2px solid var(--primary-accent, #f04438); outline-offset: 2px; }
.nbp-ready { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; min-height: 0; }
.nbp-ready .nbp-robot { width: 72px; height: 72px; }
.nbp-ready .nbp-title { font-size: 22px; }
.nbp-ready-actions { display: flex; gap: 10px; margin-top: 6px; }

/* DeferredBuildPanel bottom: stats, screen chips, build console (fills remaining height). */
.ws-deferred-build--full > .nbp--deferred { display: flex; flex-direction: column; min-height: 100%; box-sizing: border-box; }
.nbp-deferred-bottom { flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; margin-top: 16px; min-height: 220px; }
.nbp-deferred-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .nbp-deferred-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.nbp-deferred-stats dd { font-variant-numeric: tabular-nums; font-size: 18px; }
.nbp-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.nbp-chip { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--nbp-border); background: var(--nbp-surface); color: var(--nbp-muted); }
.nbp-chip--generating { border-color: var(--nbp-accent); color: var(--nbp-text); animation: nbp-pulse 1.4s ease-in-out infinite; }
.nbp-chip--done { background: var(--nbp-accent-soft); border-color: rgba(240, 68, 56, 0.35); color: var(--nbp-text); }
.nbp-chip--done::before { content: '✓ '; color: #b42318; }
.nbp-terminal { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 160px; border-radius: 14px; border: 1px solid var(--nbp-border); background: var(--nbp-surface); overflow: hidden; }
.nbp-terminal-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 10px 14px; font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--nbp-muted); scroll-behavior: smooth; }
.nbp-terminal-line { white-space: pre-wrap; animation: nbp-fade-in 0.35s ease both; }
.nbp-terminal-line.is-ok { color: var(--nbp-ok); }
.nbp-terminal-cursor { color: var(--nbp-accent); animation: nbp-blink-cursor 1s steps(1) infinite; }
@keyframes nbp-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes nbp-blink-cursor { 50% { opacity: 0; } }

/* ---- Fit-to-panel layout for the pre-payment panel (no outer scroll, nothing clipped). ----
   .ws-canvas is a flex column with overflow:hidden; while the full-size panel shows, it takes the
   flex:1 slot and the (empty) preview stage beneath it is hidden. */
/* Hide the design strip while the prep panel fills the column. Specificity must beat
   .nd-app .design-preview-panel .ws-canvas-design-mode .ws-canvas-stage { display:flex },
   or the phones stay visible, get squeezed, and cover the progress card. */
.nd-app .design-preview-panel .ws-canvas:has(> .ws-deferred-build--full) > .ws-canvas-stage,
.nd-app .design-preview-panel .ws-canvas.ws-canvas-design-mode:has(> .ws-deferred-build--full) > .ws-canvas-stage,
.nd-app .design-preview-panel .ws-canvas.ws-canvas-design-mode.ws-canvas--scroll:has(> .ws-deferred-build--full) > .ws-canvas-stage,
.ws-canvas:has(> .ws-deferred-build--full) > .ws-canvas-stage,
.nd-app .design-preview-panel .ws-canvas:has(> .ws-live-build--full) > .ws-canvas-stage,
.nd-app .design-preview-panel .ws-canvas.ws-canvas-design-mode:has(> .ws-live-build--full) > .ws-canvas-stage,
.nd-app .design-preview-panel .ws-canvas.ws-canvas-design-mode.ws-canvas--scroll:has(> .ws-live-build--full) > .ws-canvas-stage,
.ws-canvas:has(> .ws-live-build--full) > .ws-canvas-stage,
.ws-canvas.ws-canvas--live-build > .ws-canvas-stage {
  display: none !important;
}
.ws-canvas.ws-canvas--live-build > .ws-live-build--full {
  flex: 1 1 0 !important;
  min-height: min(68vh, 720px);
  height: auto;
  max-height: 100%;
  overflow: hidden;
}
/* Live stream-design build: give the build console more height than the deferred paywall panel. */
.ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-deferred-bottom {
  flex: 1 1 0;
  min-height: 0;
  max-height: min(300px, 46cqh);
}
.ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-chips {
  max-height: 5.5rem;
}
.ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-terminal {
  flex: 1 1 0;
  min-height: 150px;
  max-height: min(240px, 36cqh);
}
.ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-terminal-body {
  min-height: 6.5rem;
}
.ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-editor-body {
  max-height: min(200px, 28cqh);
}
.ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-deferred-grid {
  align-items: stretch;
}
.ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: stretch;
}
.ws-deferred-build--full {
  flex: 1 1 0; height: 100%; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; padding: 10px 12px; container-type: size; container-name: nbpdeferred;
}

/* Live stream-design build — same fit-to-panel layout as deferred (no outer scroll). */
.ws-live-build--full {
  flex: 1 1 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  box-sizing: border-box;
  container-type: size;
  container-name: nbpdeferred;
}

/* Gemini build complete: hide empty Figma strip / owl arrows above the URL card. */
.nd-app .design-preview-panel .ws-canvas-stage:has(.ws-generated-app-ready) .design-mode-gallery,
.nd-app .design-preview-panel .ws-canvas-stage:has(.ws-generated-app-ready) .design-slide-controls,
.nd-app .design-preview-panel .ws-canvas.ws-canvas-design-mode:has(.ws-generated-app-ready) .design-slide-controls {
  display: none !important;
}
.nd-app .design-preview-panel .ws-canvas:has(.ws-generated-app-ready) {
  --nd-hide-design-carousel: 1;
}
.nd-app .design-preview-panel .ws-canvas:has(.ws-generated-app-ready).ws-canvas-design-mode {
  /* Drop design-mode carousel layout when only the URL card is shown. */
}
.nd-app .design-preview-panel .ws-canvas:has(.ws-generated-app-ready) > .ws-canvas-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
.nd-app .design-preview-panel .ws-canvas-stage:has(.ws-gemini-sandpack-stage--phone) {
  overflow: hidden;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  min-height: 0;
}
/* Live demo URL row (Gemini Sandpack post-build — below design subbar). */
.ws-canvas-demo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(238, 238, 238, 1);
  background: #fff;
  flex-shrink: 0;
  min-width: 0;
}
.ws-canvas-demo-bar__label {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: rgba(80, 80, 80, 1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ws-canvas-demo-bar__input {
  flex: 1 1 180px;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(232, 232, 232, 1);
  background: rgba(251, 251, 251, 1);
  font-size: 12px;
  color: rgba(60, 60, 60, 1);
}
.ws-canvas-demo-bar__copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(232, 232, 232, 1);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: rgba(80, 80, 80, 1);
}
.ws-canvas-demo-bar__copy:hover { background: rgba(212, 78, 82, 0.06); border-color: rgba(212, 78, 82, 0.35); }
.ws-canvas-demo-bar__open {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(212, 78, 82, 1);
  color: #fff !important;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none !important;
  white-space: nowrap;
}
.ws-canvas-demo-bar__open:hover { opacity: 0.94; color: #fff !important; }
.nd-app .design-preview-panel .ws-canvas-stage:has(.ws-gemini-sandpack-stage--workspace-phone),
.ws-canvas-stage:has(.ws-gemini-sandpack-stage--workspace-phone) {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  align-self: stretch;
  width: 100%;
  padding: 2px 4px 4px;
  background: rgba(251, 251, 251, 1);
}
.ws-gemini-sandpack-stage--workspace-phone {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  height: 100%;
  overflow: hidden;
}
.ws-gemini-sandpack-stage--embed.ws-gemini-sandpack-stage--workspace-phone {
  align-items: center;
  align-self: stretch;
}
.ws-gemini-sandpack-stage--workspace-phone .gemini-sandpack-preview--phone:not(.gemini-sandpack-preview--fit-container) {
  box-sizing: border-box;
  width: min(390px, calc(100cqw - 16px), calc((100cqh - 24px) * 390 / 844));
  height: auto;
  max-width: min(390px, calc(100cqw - 16px));
  max-height: min(844px, calc(100cqh - 16px));
  aspect-ratio: 390 / 844;
  flex: 0 0 auto;
  padding: 8px;
}
.ws-gemini-sandpack-stage--workspace-phone .gemini-sandpack-preview--fit-container {
  box-sizing: border-box;
  flex: 0 0 auto;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  margin: auto;
  padding: 4px;
  width: min(calc(100cqw - 4px), calc((100cqh - 4px) * 390 / 844), 520px);
  height: auto;
  aspect-ratio: 390 / 844;
}
.gemini-sandpack-preview--no-bezel .gemini-sandpack-preview__bezel-top {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
}
.ws-gemini-sandpack-stage--workspace-phone .gemini-sandpack-preview--no-bezel {
  padding-top: 4px;
}
.ws-gemini-sandpack-stage--workspace-phone .gemini-sandpack-preview--no-bezel .gemini-sandpack-preview__screen {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: clamp(28px, 7%, 38px);
}
.ws-canvas-stage:has(.ws-gemini-sandpack-stage--workspace-phone) {
  container-type: size;
  container-name: wsphone;
}

@media (max-width: 991px) {
  .nd-app .design-preview-panel .ws-canvas-stage:has(.ws-gemini-sandpack-stage--workspace-phone),
  .ws-canvas-stage:has(.ws-gemini-sandpack-stage--workspace-phone) {
    container-type: inline-size;
    container-name: wsphone;
    flex: 0 0 auto;
    height: auto;
    min-height: min(72dvh, 640px);
    overflow: visible;
  }
  .ws-gemini-sandpack-stage--workspace-phone,
  .ws-gemini-sandpack-stage--embed.ws-gemini-sandpack-stage--workspace-phone {
    flex: 0 0 auto;
    height: auto;
    min-height: min(72dvh, 640px);
    max-height: none;
    width: min(100%, 360px);
  }
  .ws-gemini-sandpack-stage--workspace-phone .gemini-sandpack-preview--fit-container,
  .ws-gemini-sandpack-stage--workspace-phone .gemini-sandpack-preview--phone:not(.gemini-sandpack-preview--fit-container) {
    width: min(100%, 360px);
    max-width: 360px;
    height: auto;
    max-height: none;
    aspect-ratio: 390 / 844;
  }
}

.ws-gemini-sandpack-stage--embed.ws-gemini-sandpack-stage--phone {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  min-height: 0;
  padding: 8px 12px 0;
  box-sizing: border-box;
}
.ws-generated-app-ready--with-phone {
  min-height: 0;
  flex: none;
  width: 100%;
  padding: 12px 16px 20px;
}
.ws-generated-app-ready--with-phone .ws-generated-app-ready-card {
  width: min(560px, 100%);
  padding: 20px 22px 18px;
}
.ws-generated-app-ready--with-phone .ws-generated-app-ready-badge {
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  font-size: 20px;
}
.ws-generated-app-ready--with-phone .ws-generated-app-ready-lead {
  font-size: 13px;
  margin-bottom: 12px;
}
.gemini-sandpack-preview {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.gemini-sandpack-preview.gemini-sandpack-preview--phone:not(.gemini-sandpack-preview--fit-container) {
  width: min(390px, calc(100% - 16px));
  max-width: 390px;
  height: auto;
  flex: 0 0 auto;
}
.gemini-sandpack-preview--fit-container.gemini-sandpack-preview--phone {
  max-width: 100%;
  flex: 0 0 auto;
}

/* Full-page Gemini preview: centered iPhone-class viewport (390×844 logical px). */
.gemini-preview-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: #0d1117;
  overflow: hidden;
}
.gemini-preview-page__header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #e4e4e7;
  font-size: 14px;
}
.gemini-preview-page__retry {
  margin-left: auto;
  font-size: 13px;
  color: #fca5a5;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.gemini-preview-page__main {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}
.gemini-preview-page__main--phone {
  width: 100%;
}
.gemini-preview-page__status {
  padding: 24px;
  color: #a1a1aa;
  text-align: center;
}
.gemini-preview-error { color: #fca5a5; }

.gemini-sandpack-preview--phone:not(.gemini-sandpack-preview--fit-container) {
  flex: none;
  display: flex;
  flex-direction: column;
  position: relative;
  box-sizing: border-box;
  width: min(390px, calc(100% - 16px));
  height: auto;
  aspect-ratio: 390 / 844;
  max-width: 390px;
  max-height: min(844px, calc(100dvh - 88px), calc(100% - 16px));
  padding: 10px;
  border-radius: 44px;
  background: linear-gradient(165deg, #2a2a2e 0%, #121214 55%, #0a0a0b 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 24px 48px rgba(0, 0, 0, 0.55);
}
.gemini-sandpack-preview--fit-container.gemini-sandpack-preview--phone {
  flex: none;
  display: flex;
  flex-direction: column;
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  border-radius: clamp(28px, 6vw, 44px);
  padding: clamp(6px, 1.2vw, 10px);
  background: linear-gradient(165deg, #2a2a2e 0%, #121214 55%, #0a0a0b 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 24px 48px rgba(0, 0, 0, 0.55);
}
/* Decorative island sits in bezel chrome — never over app content. */
.gemini-sandpack-preview__bezel-top {
  flex: none;
  position: relative;
  height: 24px;
  width: 100%;
  margin-bottom: 2px;
  pointer-events: none;
}
.gemini-sandpack-preview__bezel-top::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 4px;
  width: 84px;
  height: 20px;
  margin-left: -42px;
  border-radius: 999px;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.gemini-sandpack-preview--phone .gemini-sandpack-preview__screen {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border-radius: 34px;
  overflow: hidden;
  background: #09090b;
  isolation: isolate;
}
.gemini-sandpack-preview--phone .gemini-sp-phone-layout,
.gemini-sandpack-preview--phone .sp-wrapper,
.gemini-sandpack-preview--phone .sp-layout,
.gemini-sandpack-preview--phone .sp-stack,
.gemini-sandpack-preview--phone .sp-preview,
.gemini-sandpack-preview--phone .sp-preview-container {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  flex: 1 1 auto !important;
  overflow: hidden !important;
  background: #09090b !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.gemini-sandpack-preview--phone .sp-preview-iframe,
.gemini-sandpack-preview--phone .sp-preview iframe {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  border: 0 !important;
  overflow: hidden !important;
  background: #09090b !important;
}
.gemini-sandpack-preview--phone .sp-preview-iframe {
  overflow: clip !important;
}
.gemini-sandpack-preview--phone .sp-preview-actions,
.gemini-sandpack-preview--phone .sp-navigation {
  display: none !important;
}
/* Keep Sandpack resize observer in the tree so the preview reflows when the phone frame resizes. */
.gemini-sandpack-preview--phone .sp-resize-observer {
  position: absolute !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  z-index: -1 !important;
}
/* Workspace panel: scale phone frame to available height (no scroll bleed). */
.ws-gemini-sandpack-stage--phone .gemini-sandpack-preview--phone {
  width: min(390px, calc(100vw - 48px), calc((100dvh - 340px) * 390 / 844));
  height: min(844px, calc(100dvh - 340px), calc((100vw - 48px) * 844 / 390));
}
.ws-deferred-build--full > .nbp--deferred,
.ws-deferred-build--full > .nbp-ready,
.ws-live-build--full > .nbp--live-build {
  flex: 1 1 0; min-height: 0; height: auto; max-width: none; overflow: hidden;
  display: flex; flex-direction: column; padding: 14px; gap: 10px; border-radius: 16px;
}
.nbp--deferred {
  min-height: 0;
  overflow: hidden;
}
.nbp--deferred > .nbp-head,
.nbp--deferred > .nbp-progress {
  flex: 0 0 auto;
  margin: 0;
}
.nbp--deferred .nbp-head { gap: 10px; }
.nbp--deferred .nbp-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nbp--deferred .nbp-head > div { min-width: 0; }
.nbp--deferred .nbp-deferred-grid {
  flex: 1 1 0;
  min-height: 0;
  max-height: 54cqh;
  margin: 0;
  gap: 12px;
  align-items: stretch;
  overflow: hidden;
  grid-template-columns: minmax(150px, 1fr) minmax(0, 1.4fr) auto;
  grid-template-rows: minmax(0, 1fr);
}
.nbp--deferred .nbp-deferred-grid > * { min-height: 0; min-width: 0; }
.nbp--deferred .nbp-timeline { overflow-y: auto; gap: 6px; }
.nbp--deferred .nbp-editor { display: flex; flex-direction: column; min-height: 0; }
.nbp--deferred .nbp-editor-body {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: min(220px, 30cqh);
}
.nbp--deferred .nbp-phone {
  height: 100%;
  max-height: 100%;
  width: auto;
  aspect-ratio: 1 / 2;
  padding: 6px;
  border-radius: 26px;
  box-sizing: border-box;
}
.nbp--deferred .nbp-phone-screen { border-radius: 20px; padding: 26px 8px 10px; gap: 8px; }
.nbp--deferred .nbp-phone-notch { top: 9px; width: 44px; height: 11px; margin-left: -22px; }
.nbp--deferred .nbp-deferred-bottom {
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(240px, 40cqh);
  margin: 0;
  gap: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.nbp--deferred .nbp-deferred-stats {
  flex: 0 0 auto;
  margin: 0;
}
.nbp--deferred .nbp-chips {
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 4.25rem;
  padding: 0 0 2px;
  scrollbar-width: thin;
  gap: 6px;
}
.nbp--deferred .nbp-stat { padding: 6px 10px; }
.nbp--deferred .nbp-chip {
  flex: 0 1 auto;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nbp--deferred .nbp-terminal {
  flex: 1 1 0;
  min-height: 72px;
  max-height: 100%;
  overflow: hidden;
}
.ws-deferred-build--full .nbp-tabs { flex: none; margin-bottom: 8px; }
.ws-deferred-build--full > .nbp-ready { justify-content: center; align-items: center; min-height: 0; }

/* Short panels (< 600px tall): compact, no code editor, console limited to a few lines. */
@container nbpdeferred (max-height: 600px) {
  .nbp--deferred, .ws-deferred-build--full > .nbp-ready { padding: 10px; gap: 8px; }
  .nbp--deferred .nbp-robot { width: 32px; height: 32px; }
  .nbp--deferred .nbp-title { font-size: 15px; }
  .nbp--deferred .nbp-sub { font-size: 12px; }
  .nbp--deferred .nbp-deferred-grid { grid-template-columns: minmax(0, 1fr) auto; max-height: 50cqh; }
  .nbp--deferred .nbp-deferred-bottom { max-height: min(180px, 42cqh); }
  .nbp--deferred .nbp-chips { max-height: 3rem; }
  .nbp--deferred .nbp-editor { display: none; }
  .nbp--deferred .nbp-stage { font-size: 12px; }
  .nbp--deferred .nbp-stage-icon { width: 16px; height: 16px; }
  .nbp--deferred .nbp-deferred-stats dd { font-size: 15px; }
  .nbp--deferred .nbp-stat dt { font-size: 10px; }
  .nbp--deferred .nbp-terminal { flex: 0 1 auto; max-height: calc(4 * 1.6em + 46px); }
  .nbp--deferred .nbp-terminal-body { font-size: 11px; line-height: 1.6; padding: 6px 10px; }
  .nbp-ready .nbp-robot { width: 48px; height: 48px; }
  .nbp-ready .nbp-title { font-size: 18px; }
}
/* Very short (< 440px, e.g. 510x410 panel): no phone; steps in two columns. */
@container nbpdeferred (max-height: 440px) {
  .nbp--deferred .nbp-deferred-grid { grid-template-columns: minmax(0, 1fr); flex: 0 1 auto; }
  .nbp--deferred .nbp-phone { display: none; }
  .nbp--deferred .nbp-timeline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; }
  .nbp--deferred .nbp-stage-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nbp--deferred .nbp-progress-head { margin-bottom: 4px; }
  .nbp--deferred .nbp-terminal { max-height: calc(3 * 1.6em + 40px); min-height: 56px; }
  .nbp--deferred .nbp-editor-bar { padding: 4px 10px; }
  .nbp-ready .nbp-robot { width: 40px; height: 40px; }
}
/* Narrow panels: drop the code editor (< 560px) and then the phone (< 420px); stats 2x2 (< 380px). */
@container nbpdeferred (max-width: 560px) {
  .nbp--deferred .nbp-deferred-grid { grid-template-columns: minmax(0, 1fr) auto; }
  .nbp--deferred .nbp-editor { display: none; }
}
@container nbpdeferred (max-width: 420px) {
  .nbp--deferred .nbp-deferred-grid { grid-template-columns: minmax(0, 1fr); }
  .nbp--deferred .nbp-phone { display: none; }
}
@container nbpdeferred (max-width: 380px) {
  .nbp--deferred .nbp-deferred-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nbp--deferred .nbp-timeline { grid-template-columns: minmax(0, 1fr); }
}

/* Phones and short tablets: the preview column is height:auto, so size-containment
   (container-type: size) collapses this panel and the 3-col desktop grid overlaps.
   Stack the live/deferred build UI and let the page scroll. */
@media (max-width: 991px) {
  .ws-canvas.ws-canvas--live-build > .ws-live-build--full,
  .ws-live-build--full,
  .ws-deferred-build,
  .ws-deferred-build--full {
    container-type: normal !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    flex: 0 0 auto !important;
    padding: 8px;
  }
  .ws-live-build--full > .nbp--live-build,
  .ws-live-build--full > .nbp--live-build.nbp--deferred,
  .ws-deferred-build--full > .nbp--deferred,
  .ws-deferred-build--full > .nbp-ready {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    flex: 0 0 auto !important;
    padding: 12px;
    gap: 12px;
  }
  .nbp--deferred,
  .nbp--live-build.nbp--deferred {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }
  .nbp--deferred .nbp-title { white-space: normal; font-size: 16px; }
  .nbp--deferred .nbp-sub { white-space: normal; }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-deferred-grid,
  .nbp--deferred .nbp-deferred-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    align-items: stretch !important;
    flex: 0 0 auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    gap: 12px;
  }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-editor,
  .nbp--deferred .nbp-editor {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100%;
    min-height: 0 !important;
    max-height: none !important;
    align-self: stretch;
    position: relative;
  }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-editor-body,
  .nbp--deferred .nbp-editor-body {
    flex: 0 0 auto;
    height: 148px !important;
    max-height: 148px !important;
    overflow: hidden;
  }
  .nbp--deferred .nbp-editor-file {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .nbp--deferred .nbp-timeline {
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important;
    max-height: none !important;
    gap: 8px;
  }
  .nbp--deferred .nbp-stage-label { white-space: normal; }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-phone,
  .nbp--deferred .nbp-phone {
    display: flex !important;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    width: min(180px, 56vw) !important;
    height: auto !important;
    max-height: none !important;
    aspect-ratio: 1 / 2;
    margin: 0 auto !important;
  }
  .nbp--deferred .nbp-phone-screen {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    height: 100%;
    flex: 1 1 auto;
    min-height: 0;
  }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-deferred-bottom,
  .nbp--deferred .nbp-deferred-bottom {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0;
    gap: 10px;
  }
  .nbp--deferred .nbp-deferred-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-chips,
  .nbp--deferred .nbp-chips {
    max-height: none !important;
    overflow: visible !important;
    flex-wrap: wrap;
  }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-terminal,
  .nbp--deferred .nbp-terminal {
    flex: 0 0 auto !important;
    min-height: 88px;
    max-height: 160px !important;
  }
  .nd-app .design-preview-panel .ws-canvas-subbar,
  .ws-canvas-subbar {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 8px;
  }
  .nd-app .design-preview-panel .ws-canvas-crumb,
  .ws-canvas-crumb {
    flex: 1 1 140px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nbp-tabs--subbar { margin: 0; }
  .ws-canvas-actions { margin-left: auto; }
}

@media (max-width: 480px) {
  .nbp--deferred .nbp-phone,
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-phone {
    width: min(160px, 52vw) !important;
  }
  .nbp--deferred .nbp-robot { width: 32px; height: 32px; }
  .nbp--deferred .nbp-title { font-size: 15px; }
  .nbp--deferred .nbp-deferred-stats dd { font-size: 15px; }
  .ws-deferred-build--full > .nbp-ready .nbp-title { font-size: 18px; }
  .nbp-tabs--subbar .nbp-tab { padding: 5px 8px; font-size: 11px; }
  .ws-canvas.ws-canvas--live-build .nbp--deferred .nbp-editor-body,
  .nbp--deferred .nbp-editor-body {
    height: 120px !important;
    max-height: 120px !important;
  }
}

@media (max-width: 360px) {
  .ws-live-build--full { padding: 6px; }
  .ws-live-build--full > .nbp--live-build { padding: 10px; }
  .ws-deferred-build--full,
  .ws-deferred-build { padding: 6px; }
  .ws-deferred-build--full > .nbp--deferred { padding: 10px; }
}

/* Locked "Download App" buttons (header + chat REVIEW DESIGN card). */
.ws-canvas-action.primary:disabled, .home-msg-action:disabled { opacity: 0.5; cursor: not-allowed; }


/* Ready-view tabs in the canvas subbar (fixed-size header row; never affects the stage height). */
.nbp-tabs--subbar { margin: 0 8px 0 auto; padding: 3px; flex-shrink: 0; }
.nbp-tabs--subbar .nbp-tab { padding: 5px 10px; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .nbp *, .nbp *::before, .nbp *::after { animation: none !important; transition: none !important; }
  .nbp-progress--indeterminate .nbp-progress-fill { left: 0; width: 100%; opacity: 0.45; }
  .nbp-terminal-body { scroll-behavior: auto; }
}
