/* =====================================================================
   MOTION STUDIO BY CAPT v2.0 — MODERN CREATIVE STUDIO DESIGN SYSTEM
   Layered Obsidian surfaces · Clean Sans UI · Monospace for code/metrics
   ===================================================================== */

:root {
  --bg-app: #09090b;
  --bg-panel: #111114;
  --bg-elevated: #17171c;
  --bg-input: #0c0c0f;
  --bg-hover: #1f1f26;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --text-main: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.12);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.65);
  --shadow-stage: 0 20px 60px rgba(0, 0, 0, 0.55);

  --stage-bar-bg: rgba(17, 17, 20, 0.72);
  --stage-canvas-bg: #09090b;
  --stage-canvas-dot: rgba(255, 255, 255, 0.06);
  --empty-card-bg: rgba(17, 17, 20, 0.86);
  --code-text: #c7d2fe;
  --prompt-text: #cbd5e1;
  --scrubber-track: rgba(255, 255, 255, 0.12);
  --modal-foot-bg: rgba(9, 9, 11, 0.45);
  --backdrop-overlay: rgba(5, 5, 8, 0.76);
  --rec-bg: rgba(34, 211, 238, 0.07);
  --rec-bg-hover: rgba(34, 211, 238, 0.12);
  --rec-border: rgba(34, 211, 238, 0.28);
  --rec-text: #a5f3fc;
  --opt-active-text: #e0e7ff;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ================= LIGHT MODE DESIGN TOKENS ================= */
:root[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-input: #ffffff;
  --bg-hover: #e2e8f0;

  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.18);

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.11);
  --accent-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

  --cyan: #0891b2;
  --cyan-soft: rgba(8, 145, 178, 0.11);
  --red-soft: rgba(239, 68, 68, 0.10);

  --shadow-lg: 0 20px 54px rgba(15, 23, 42, 0.16);
  --shadow-stage: 0 14px 40px rgba(15, 23, 42, 0.12);

  --stage-bar-bg: rgba(255, 255, 255, 0.88);
  --stage-canvas-bg: #e2e8f0;
  --stage-canvas-dot: rgba(15, 23, 42, 0.11);
  --empty-card-bg: rgba(255, 255, 255, 0.92);
  --code-text: #312e81;
  --prompt-text: #334155;
  --scrubber-track: rgba(15, 23, 42, 0.14);
  --modal-foot-bg: #f8fafc;
  --backdrop-overlay: rgba(15, 23, 42, 0.45);
  --rec-bg: rgba(8, 145, 178, 0.08);
  --rec-bg-hover: rgba(8, 145, 178, 0.14);
  --rec-border: rgba(8, 145, 178, 0.28);
  --rec-text: #0e7490;
  --opt-active-text: #3730a3;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  height: 100dvh;
  width: 100%;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, label, .topbar, .stage-bar, .timeline-bar, .mobile-bottom-nav {
  user-select: none;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.show-xs { display: none; }

/* Custom sleek scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* ================= APP SHELL ================= */
#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  background: var(--bg-app);
  padding-top: env(safe-area-inset-top);
}

/* ================= TOP STUDIO BAR ================= */
.topbar {
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(79, 70, 229, 0.32));
}

.brand-mark svg {
  width: 32px;
  height: 32px;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  white-space: nowrap;
}

.brand-by {
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.version-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.project-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  max-width: 300px;
}

.project-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}
.project-dot.live {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
.project-dot.exporting {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

#active-project-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  padding-left: 6px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-grad);
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.09);
  transform: translateY(-0.5px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-main);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* Theme Toggle Icon Button */
.icon-only-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-only-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.icon-only-btn .icon-moon { display: none; }
.icon-only-btn .icon-sun { display: block; }
:root[data-theme="light"] .icon-only-btn .icon-sun { display: none; }
:root[data-theme="light"] .icon-only-btn .icon-moon { display: block; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.btn-danger-soft {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.btn-danger-soft:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.24);
  color: #fff;
}

.btn-xs {
  height: 26px;
  padding: 0 10px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn-full {
  width: 100%;
  height: 38px;
}

.text-danger { color: #f87171; }
.text-danger:hover { color: #fca5a5 !important; }

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.16);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

/* ================= MAIN STUDIO LAYOUT ================= */
.studio-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 388px 1fr;
  overflow: hidden;
  transition: grid-template-columns 0.2s ease;
}

.studio-layout.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

.studio-layout.sidebar-collapsed .sidebar {
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.icon-only-btn.active {
  color: var(--accent-hover);
  border-color: rgba(99, 102, 241, 0.5);
  background: var(--accent-soft);
}

/* Mobile bottom navigation (hidden on desktop) */
.mobile-bottom-nav {
  display: none;
}

/* ================= LEFT SIDEBAR ================= */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.tab-btn {
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 999px;
}
.tab-btn.active .tab-count {
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.tab-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cards inside Sidebar */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.micro-label {
  font-size: 11px;
  color: var(--text-muted);
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brief-quality-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 999px;
}
.brief-quality-badge.good {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
}
.brief-quality-badge.warn {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
}

textarea, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#creative-brief {
  padding: 10px 11px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
  min-height: 82px;
}

.chip-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: rgba(99, 102, 241, 0.55);
  color: var(--text-main);
  background: var(--accent-soft);
}

.inline-alert {
  font-size: 11.5px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 8px;
}
.inline-alert.warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fcd34d;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

select {
  height: 34px;
  padding: 0 28px 0 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.prompt-output-card {
  flex: 1;
  min-height: 170px;
}

#generated-prompt {
  flex: 1;
  min-height: 130px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--prompt-text);
  resize: vertical;
}

/* ================= CODE TAB ================= */
.pane-code-layout {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.code-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-editor-wrap {
  flex: 1;
  min-height: 220px;
  display: flex;
}

#html-input {
  flex: 1;
  height: 100%;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--code-text);
  resize: none;
}

.error-panel {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.error-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.error-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #fca5a5;
}

.error-msg {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #fecaca;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 92px;
  overflow-y: auto;
}

/* ================= LIBRARY TAB ================= */
.subtab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}

.subtab-btn {
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.subtab-btn.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.lib-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lib-utility-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.lib-utility-row .text-danger {
  margin-left: auto;
}

.library-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lib-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.lib-card:hover {
  border-color: rgba(99, 102, 241, 0.45);
}

.lib-card-body {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 11px;
  padding: 10px;
  align-items: center;
}

.lib-thumb {
  width: 88px;
  height: 54px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background-color: #141418;
  background-image:
    linear-gradient(45deg, #1d1d24 25%, transparent 25%),
    linear-gradient(-45deg, #1d1d24 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1d1d24 75%),
    linear-gradient(-45deg, transparent 75%, #1d1d24 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.lib-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.lib-thumb-fallback {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.lib-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lib-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.lib-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 10px;
}

.lib-actions .btn {
  flex: 1;
}

.lib-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* ================= RIGHT VIEWPORT (FULL-HEIGHT STAGE) ================= */
.viewport {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-app);
  position: relative;
}

.stage-bar {
  height: 46px;
  min-height: 46px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--stage-bar-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stage-bar-left,
.stage-bar-center,
.stage-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mono-pill {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.mono-pill strong {
  color: var(--text-main);
  font-weight: 600;
}

.mono-pill.clickable {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mono-pill.clickable:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.res-sub {
  color: var(--text-muted);
  font-size: 10.5px;
}

.api-pill {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: var(--cyan-soft);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 6px;
}
.api-pill.active { display: inline-flex; }
.api-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

/* Backdrop Swatch Switcher */
.backdrop-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.swatch-btn {
  width: 24px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.swatch-btn:hover { background: rgba(255, 255, 255, 0.08); }
.swatch-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: block;
}
.swatch-alpha-dark {
  background-color: #16161b;
  background-image:
    linear-gradient(45deg, #2b2b34 25%, transparent 25%),
    linear-gradient(-45deg, #2b2b34 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2b2b34 75%),
    linear-gradient(-45deg, transparent 75%, #2b2b34 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}
.swatch-alpha-light {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%),
    linear-gradient(-45deg, #cbd5e1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cbd5e1 75%),
    linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}
.swatch-black { background: #000000; }
.swatch-white { background: #ffffff; }
.swatch-green { background: #00b140; }

.icon-pill-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-pill-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--bg-hover);
}
.icon-pill-btn.active {
  color: var(--accent-hover);
  border-color: rgba(99, 102, 241, 0.55);
  background: var(--accent-soft);
}

/* Performance Popover */
.perf-popover-wrap {
  position: relative;
}

.popover-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popover-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.popover-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ================= CENTERED STAGE CANVAS AREA ================= */
.stage-canvas-area {
  flex: 1;
  min-height: 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--stage-canvas-bg);
  background-image: radial-gradient(var(--stage-canvas-dot) 1px, transparent 1px);
  background-size: 20px 20px;
}

#preview-stage-frame {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-stage);
  transition: background-color 0.2s ease;
}

/* Stage Backdrop Themes */
#preview-stage-frame.bg-alpha-dark {
  background-color: #121216;
  background-image:
    linear-gradient(45deg, #1b1b22 25%, transparent 25%),
    linear-gradient(-45deg, #1b1b22 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1b1b22 75%),
    linear-gradient(-45deg, transparent 75%, #1b1b22 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#preview-stage-frame.bg-alpha-light {
  background-color: #f4f4f5;
  background-image:
    linear-gradient(45deg, #d4d4d8 25%, transparent 25%),
    linear-gradient(-45deg, #d4d4d8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d4d4d8 75%),
    linear-gradient(-45deg, transparent 75%, #d4d4d8 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#preview-stage-frame.bg-solid-black {
  background: #000000;
}

#preview-stage-frame.bg-solid-white {
  background: #ffffff;
}

#preview-stage-frame.bg-solid-green {
  background: #00b140;
}

#preview-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
  background: transparent !important;
  color-scheme: normal;
  will-change: transform;
  transform: translateZ(0);
}
#preview-iframe.active { display: block; }

/* Welcoming Empty State */
.empty-state {
  text-align: center;
  max-width: 390px;
  padding: 28px 24px;
  border-radius: 14px;
  background: var(--empty-card-bg);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: var(--accent-hover);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.empty-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.empty-desc strong { color: var(--text-main); }

.empty-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Safe-Area & Rule-of-Thirds Overlay */
.stage-grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.grid-thirds-v1, .grid-thirds-v2 {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(34, 211, 238, 0.25);
}
.grid-thirds-v1 { left: 33.333%; }
.grid-thirds-v2 { left: 66.666%; }

.grid-thirds-h1, .grid-thirds-h2 {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: rgba(34, 211, 238, 0.25);
}
.grid-thirds-h1 { top: 33.333%; }
.grid-thirds-h2 { top: 66.666%; }

.grid-safe-box {
  position: absolute;
  inset: 8%;
  border: 1px dashed rgba(250, 204, 21, 0.45);
  border-radius: 4px;
}

/* ================= BOTTOM STUDIO TIMELINE ================= */
.timeline-bar {
  height: 56px;
  min-height: 56px;
  padding: 0 18px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.transport-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.transport-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.transport-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.transport-btn.play {
  width: 36px;
  background: var(--accent-grad);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}
.transport-btn.play:hover {
  filter: brightness(1.1);
}
.transport-btn.play .icon-pause { display: none; }
.transport-btn.play .icon-play { display: block; }
.transport-btn.play.is-playing .icon-play { display: none; }
.transport-btn.play.is-playing .icon-pause { display: block; }

.timecode {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}

.timecode strong {
  color: var(--text-main);
  font-weight: 600;
  min-width: 3.2ch;
  text-align: right;
}

.time-sep {
  color: var(--text-muted);
  margin: 0 5px;
}

.time-unit {
  color: var(--text-muted);
  margin-left: 1px;
}

.time-total-input {
  box-sizing: content-box;
  width: 4ch;
  min-width: 3ch;
  height: 22px;
  padding: 0 3px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.time-total-input::-webkit-inner-spin-button,
.time-total-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.time-total-input:hover {
  border-color: var(--border);
  background: var(--bg-elevated);
  color: var(--text-main);
}
.time-total-input:focus {
  border-color: var(--accent);
  background: var(--bg-input);
  color: var(--text-main);
}

.frame-tag {
  margin-left: 8px;
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
}

.scrubber-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

#timeline-scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--scrub-pct, 0%),
    var(--scrubber-track) var(--scrub-pct, 0%),
    var(--scrubber-track) 100%
  );
  outline: none;
  cursor: pointer;
}

#timeline-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s;
}
#timeline-scrubber::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

#timeline-scrubber::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent);
  cursor: pointer;
}

.loop-pill {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.loop-pill input { display: none; }
.loop-pill:has(input:checked) {
  border-color: rgba(99, 102, 241, 0.5);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* ================= MODALS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--backdrop-overlay);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.export-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.preset-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-main);
  font-family: var(--font-sans);
}
.preset-btn:hover { border-color: var(--border-strong); }
.preset-btn .p-name {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 3px;
}
.preset-btn .p-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
}
.preset-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.35);
}
.preset-btn.active .p-meta { color: var(--accent-hover); }

.rec-banner {
  width: 100%;
  background: var(--rec-bg);
  border: 1px solid var(--rec-border);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--rec-text);
  font-family: var(--font-sans);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.rec-banner:hover { background: var(--rec-bg-hover); }

.engine-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.12);
  color: var(--cyan);
  white-space: nowrap;
}

.toggle-row {
  display: grid;
  gap: 8px;
}
.toggle-row.cols-2 { grid-template-columns: 1fr 1fr; }
.toggle-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.toggle-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

.opt-btn {
  height: 36px;
  padding: 0 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.opt-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}
.opt-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--opt-active-text);
}
.opt-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.summary-bar {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.summary-caption {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.helper-text {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.bulk-items-box {
  min-height: 84px;
  max-height: 165px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bulk-empty {
  margin: auto;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.bulk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
}

.bulk-row-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* Progress Box */
.progress-box {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.prog-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}
.prog-label.error { color: #fca5a5; }

.prog-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-hover);
}

.prog-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.prog-fill {
  width: 0%;
  height: 100%;
  background: var(--accent-grad);
  border-radius: 999px;
  transition: width 0.12s linear;
}

.prog-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--modal-foot-bg);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Light mode polish for toast, scrollbar & alerts */
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.16); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.28); }
:root[data-theme="light"] .inline-alert.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
}
:root[data-theme="light"] .brief-quality-badge.good { color: #15803d; }
:root[data-theme="light"] .brief-quality-badge.warn { color: #b45309; }
:root[data-theme="light"] .chip { background: #ffffff; }
:root[data-theme="light"] #toast.success { color: #0e7490; background: #ecfeff; }
:root[data-theme="light"] #toast.error { color: #991b1b; background: #fef2f2; }

/* ================= FLOATING TOAST ================= */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  z-index: 2000;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.success {
  border-color: rgba(34, 211, 238, 0.5);
  color: #ecfeff;
}
#toast.error {
  border-color: rgba(239, 68, 68, 0.65);
  background: #1c1014;
  color: #fecaca;
}

/* ================= APP-FRIENDLY RESPONSIVE SHELL ================= */
@keyframes sheetSlideUp {
  from { transform: translateY(28px); opacity: 0.4; }
  to   { transform: translateY(0); opacity: 1; }
}

@media (max-width: 900px) {
  .desktop-only-btn,
  .topbar-divider,
  .version-pill,
  .project-pill .status-label {
    display: none !important;
  }

  .topbar {
    height: 52px;
    min-height: 52px;
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-left,
  .topbar-right {
    gap: 8px;
  }

  .brand-name {
    font-size: 14px;
  }

  .project-pill {
    max-width: 145px;
    padding: 4px 8px;
  }

  /* Single-screen native app container (no outer page scroll) */
  .studio-layout,
  .studio-layout.sidebar-collapsed {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    flex: 1;
    min-height: 0;
    width: 100%;
    border-right: none;
    border-bottom: none;
    opacity: 1 !important;
    pointer-events: auto !important;
    display: none;
  }

  .sidebar-tabs {
    display: none;
  }

  .pane-scroll {
    padding: 14px 14px 20px;
    -webkit-overflow-scrolling: touch;
  }

  .viewport {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: none;
  }

  /* Show ONLY the active app view */
  #app-shell[data-mobile-view="preview"] .viewport {
    display: flex;
  }
  #app-shell[data-mobile-view="brief"] .sidebar,
  #app-shell[data-mobile-view="code"] .sidebar,
  #app-shell[data-mobile-view="library"] .sidebar {
    display: flex;
  }

  /* Sleek horizontally scrollable stage utility bar */
  .stage-bar {
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: flex-start;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .stage-bar::-webkit-scrollbar { display: none; }
  .stage-bar-left,
  .stage-bar-center,
  .stage-bar-right {
    flex-shrink: 0;
  }

  .stage-canvas-area {
    padding: 14px;
    flex: 1;
    min-height: 0;
  }

  /* Touch-friendly timeline bar */
  .timeline-bar {
    height: auto;
    min-height: 58px;
    padding: 8px 12px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .transport-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .transport-btn.play {
    width: 42px;
  }

  #timeline-scrubber {
    height: 8px;
  }
  #timeline-scrubber::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }

  /* Fixed Native Bottom App Navigation Bar */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    min-height: calc(60px + env(safe-area-inset-bottom));
    flex-shrink: 0;
    z-index: 30;
  }

  .mnav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 46px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
  }

  .mnav-btn.active {
    color: var(--accent-hover);
    background: var(--accent-soft);
  }

  #toast {
    bottom: calc(74px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 28px);
    text-align: center;
  }

  .export-two-col {
    grid-template-columns: 1fr;
  }
  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Native Mobile Bottom-Sheet Modals & Compact Phone Header */
@media (max-width: 600px) {
  .hide-xs { display: none !important; }
  .show-xs { display: inline !important; }

  .project-pill { display: none; }

  .topbar .btn-secondary {
    width: 34px;
    padding: 0;
  }

  .topbar .btn-primary {
    padding: 0 12px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-box {
    max-width: 100%;
    max-height: 88dvh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    animation: sheetSlideUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .modal-head {
    position: relative;
    padding-top: 22px;
  }
  .modal-head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: var(--border-strong);
  }

  .modal-foot {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .modal-foot .btn {
    flex: 1;
    height: 40px;
  }

  .empty-state {
    padding: 20px 18px;
  }
}
