/* ============================================================================
   Kahani Studio — Multi-Profile Creative Storytelling Workshop
   Per-Profile Visual Worlds (Kathputli • Doodle Comedy • Storybook Watercolor)
   Responsive Across Laptop, iPad Portrait/Landscape, and iPhone Mobile
   ============================================================================ */

:root,
:root[data-theme="aurora"] {
  --paper: #fffaf2;
  --sidebar: #fff1df;
  --rail: #fff6ea;
  --surface: #ffffff;
  --soft: #fcecd8;
  --soft-blue: #fff8ee;
  --hover: #fae1c4;
  --line: #eedbc4;
  --line-strong: #e2c7a7;

  --ink: #2b1e16;
  --ink-2: #574134;
  --ink-muted: #826a5b;

  --accent: #eb5e28;
  --accent-dark: #c94614;
  --accent-soft: #ffede3;
  --accent-pill: #ffd9c4;
  --accent-line: #f8a882;
  --accent-teal: #1b998b;
  --accent-berry: #e63975;
  --accent-gold: #f4a21d;
  --sparkle-grad: linear-gradient(135deg, #ff8c24 0%, #ff4d7e 52%, #7c5cff 100%);
  --btn-lip: rgba(185, 58, 12, 0.28);

  --chat-bg:
    radial-gradient(ellipse 62% 46% at 12% 8%, rgba(255, 174, 52, 0.22), transparent 62%),
    radial-gradient(ellipse 56% 44% at 90% 10%, rgba(255, 93, 143, 0.16), transparent 60%),
    radial-gradient(ellipse 64% 48% at 50% 96%, rgba(46, 196, 182, 0.15), transparent 62%),
    radial-gradient(rgba(235, 94, 40, 0.13) 1.3px, transparent 1.3px),
    #fffbf5;
  --chat-bg-size: 100% 100%, 100% 100%, 100% 100%, 22px 22px, 100% 100%;
  --topbar-bg: rgba(255, 250, 242, 0.88);
  --dock-bg: linear-gradient(180deg, rgba(255, 251, 245, 0) 0%, rgba(255, 251, 245, 0.92) 26%, rgba(255, 251, 245, 0.99) 100%);
  --assistant-card: rgba(255, 255, 255, 0.94);
  --assistant-border: rgba(232, 206, 178, 0.90);
  --user-bubble-bg: linear-gradient(135deg, #ffe9d6 0%, #ffe0ec 100%);
  --user-bubble-ink: #381e12;

  --sage: #15803d;
  --sage-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --display: "Fredoka", "Nunito", "Noto Sans Devanagari", -apple-system, BlinkMacSystemFont, sans-serif;
  --sans: "Nunito", "Noto Sans Devanagari", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --shadow-xs: 0 2px 4px rgba(105, 58, 22, 0.08);
  --shadow-sm: 0 4px 12px rgba(105, 58, 22, 0.10), 0 1px 2px rgba(105, 58, 22, 0.06);
  --shadow-md: 0 12px 28px rgba(105, 58, 22, 0.13), 0 3px 8px rgba(105, 58, 22, 0.06);
  --shadow-fab: 0 4px 0 rgba(235, 94, 40, 0.22), 0 8px 18px rgba(235, 94, 40, 0.16);
  --focus-ring: 0 0 0 3.5px rgba(235, 94, 40, 0.24);
}

:root[data-theme="warm"] {
  --paper: #fdf8ec;
  --sidebar: #f4ebd4;
  --rail: #f9f2e1;
  --surface: #ffffff;
  --soft: #efe3c6;
  --soft-blue: #fbf5e6;
  --hover: #e7d8b5;
  --line: #e2d3b0;
  --line-strong: #d0bc91;

  --ink: #272017;
  --ink-2: #544738;
  --ink-muted: #7c6d59;

  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #e0f6f3;
  --accent-pill: #c2ebe5;
  --accent-line: #6ec4b9;
  --sparkle-grad: linear-gradient(135deg, #0d7a72 0%, #1d8a82 48%, #d95d1e 100%);
  --btn-lip: rgba(15, 118, 110, 0.28);

  --chat-bg:
    radial-gradient(ellipse 65% 45% at 16% 8%, rgba(244, 162, 29, 0.18), transparent 62%),
    radial-gradient(ellipse 58% 42% at 86% 16%, rgba(46, 196, 182, 0.14), transparent 60%),
    radial-gradient(ellipse 60% 45% at 50% 95%, rgba(235, 94, 40, 0.10), transparent 62%),
    radial-gradient(rgba(130, 102, 58, 0.14) 1.2px, transparent 1.2px),
    #fdf8ec;
  --chat-bg-size: 100% 100%, 100% 100%, 100% 100%, 24px 24px, 100% 100%;
  --topbar-bg: rgba(253, 248, 236, 0.88);
  --dock-bg: linear-gradient(180deg, rgba(253, 248, 236, 0) 0%, rgba(253, 248, 236, 0.94) 28%, rgba(253, 248, 236, 0.99) 100%);
  --assistant-card: rgba(255, 255, 255, 0.93);
  --assistant-border: rgba(210, 189, 146, 0.84);
  --user-bubble-bg: linear-gradient(135deg, #d7f3ef 0%, #fdf0cc 100%);
  --user-bubble-ink: #172b28;
}

:root[data-theme="dark"] {
  --paper: #141126;
  --sidebar: #1b1733;
  --rail: #19152f;
  --surface: #231e40;
  --soft: #2c264f;
  --soft-blue: #201b3a;
  --hover: #352e5e;
  --line: #362f5c;
  --line-strong: #4a4178;

  --ink: #f8f5ff;
  --ink-2: #ded8f5;
  --ink-muted: #b8b0da;

  --accent: #ff9f43;
  --accent-dark: #f0831c;
  --accent-soft: rgba(255, 159, 67, 0.18);
  --accent-pill: rgba(255, 159, 67, 0.26);
  --accent-line: rgba(255, 159, 67, 0.48);
  --sparkle-grad: linear-gradient(135deg, #ff9f43 0%, #ff5d8f 54%, #9b7bff 100%);
  --btn-lip: rgba(0, 0, 0, 0.45);

  --chat-bg:
    radial-gradient(ellipse 68% 48% at 16% 8%, rgba(255, 159, 67, 0.16), transparent 62%),
    radial-gradient(ellipse 55% 44% at 86% 14%, rgba(255, 93, 143, 0.15), transparent 60%),
    radial-gradient(ellipse 60% 45% at 50% 96%, rgba(124, 92, 255, 0.16), transparent 62%),
    radial-gradient(rgba(255, 224, 150, 0.16) 1.2px, transparent 1.2px),
    #131024;
  --chat-bg-size: 100% 100%, 100% 100%, 100% 100%, 26px 26px, 100% 100%;
  --topbar-bg: rgba(21, 17, 40, 0.86);
  --dock-bg: linear-gradient(180deg, rgba(19, 16, 36, 0) 0%, rgba(19, 16, 36, 0.92) 28%, rgba(19, 16, 36, 0.99) 100%);
  --assistant-card: rgba(35, 30, 64, 0.88);
  --assistant-border: rgba(84, 73, 138, 0.72);
  --user-bubble-bg: linear-gradient(135deg, rgba(255, 159, 67, 0.26) 0%, rgba(255, 93, 143, 0.24) 100%);
  --user-bubble-ink: #fff7eb;

  --sage: #58d68d;
  --sage-soft: rgba(88, 214, 141, 0.18);
  --danger: #ff7b89;
  --danger-soft: rgba(255, 123, 137, 0.18);

  --shadow-xs: 0 2px 5px rgba(0, 0, 0, 0.36);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.44);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.54);
  --shadow-fab: 0 4px 0 rgba(0, 0, 0, 0.42), 0 8px 18px rgba(0, 0, 0, 0.36);
  --focus-ring: 0 0 0 3.5px rgba(255, 159, 67, 0.30);
}

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

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Subtle Google-style scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

.hidden { display: none !important; }
.muted { color: var(--ink-muted); font-size: 13px; }
.mono { font-family: var(--mono); font-size: 11.5px; color: var(--ink-muted); }

/* ==================== MAIN 3-COLUMN RESIZABLE WORKSPACE ==================== */
.studio-layout {
  --left-w: 248px;
  --right-w: 396px;
  display: grid;
  grid-template-columns: var(--left-w) 6px minmax(340px, 1fr) 6px var(--right-w);
  height: 100vh;
  overflow: hidden;
  background: var(--paper);
}
.studio-layout.left-collapsed {
  grid-template-columns: 0px 0px minmax(340px, 1fr) 6px var(--right-w);
}
.studio-layout.right-collapsed {
  grid-template-columns: var(--left-w) 6px minmax(340px, 1fr) 0px 0px;
}
.studio-layout.left-collapsed.right-collapsed {
  grid-template-columns: 0px 0px 1fr 0px 0px;
}
.studio-layout.left-collapsed .sidebar,
.studio-layout.left-collapsed #resizer-left,
.studio-layout.right-collapsed .stage-column,
.studio-layout.right-collapsed #resizer-right {
  overflow: hidden;
  padding: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
}

/* Interactive Drag-to-Resize Splitter Handles */
.panel-resizer {
  position: relative;
  width: 6px;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
  z-index: 15;
  transition: background 0.15s ease;
}
.panel-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2.5px;
  width: 1px;
  background: var(--line);
  transition: background 0.15s ease, width 0.15s ease, left 0.15s ease;
}
.panel-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 1px;
  width: 4px;
  height: 44px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: transparent;
  transition: background 0.15s ease;
}
.panel-resizer:hover::before,
.panel-resizer.dragging::before {
  background: var(--accent);
  width: 2px;
  left: 2px;
}
.panel-resizer:hover::after,
.panel-resizer.dragging::after {
  background: var(--accent);
}
body.is-resizing {
  user-select: none;
  cursor: col-resize;
}
body.is-resizing iframe,
body.is-resizing canvas {
  pointer-events: none;
}

/* ==================== LEFT NAVIGATION RAIL (Google Material 3) ==================== */
.sidebar {
  position: relative;
  background: var(--sidebar);
  padding: 18px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  min-width: 0;
}
.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: var(--sparkle-grad);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(235, 94, 40, 0.26);
  flex-shrink: 0;
  transform: rotate(-3deg);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.brand:hover .brand-icon {
  transform: rotate(4deg) scale(1.08);
}
.brand-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.15;
}

.brand-status {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--sage);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.brand-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage);
  display: inline-block;
  box-shadow: 0 0 0 3px var(--sage-soft);
}

/* Tactile Storybook Primary Action Button ("Create New Reel") */
.btn-create-reel {
  width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  border: 2px solid transparent;
  background: var(--sparkle-grad);
  color: #fff;
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 0 rgba(154, 44, 82, 0.30), 0 8px 18px rgba(235, 94, 40, 0.22);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.14s ease, filter 0.14s ease;
}
.btn-create-reel span {
  color: #fff3b0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.btn-create-reel:hover {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(154, 44, 82, 0.28), 0 12px 22px rgba(235, 94, 40, 0.28);
}
.btn-create-reel:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(154, 44, 82, 0.30);
}

.sidebar-group { display: flex; flex-direction: column; gap: 6px; }
.group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  padding: 0 12px;
}

.reel-list { display: flex; flex-direction: column; gap: 3px; }

.reel-item {
  width: 100%;
  text-align: left;
  padding: 9px 12px 9px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.14s ease, color 0.14s ease;
}
.reel-item-main {
  min-width: 0;
  flex: 1;
}
.item-del-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.14s ease, background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.reel-item:hover .item-del-btn,
.reel-item.active .item-del-btn,
.bumper-lib-card:hover .item-del-btn,
.bumper-lib-card.active .item-del-btn {
  opacity: 0.78;
}
.item-del-btn:hover {
  opacity: 1 !important;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.25);
}
@media (hover: none) {
  .item-del-btn { opacity: 0.78; }
}
.bumper-subbar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.reel-item:hover { background: var(--hover); }
.reel-item.active {
  background: var(--accent-pill);
  color: var(--ink);
}
.reel-item-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reel-item.active .reel-item-name { color: var(--accent-dark); }
.reel-item-meta { font-size: 11px; color: var(--ink-muted); margin-top: 1px; }
.reel-item.active .reel-item-meta { color: var(--ink-2); }

.sidebar-bottom {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.theme-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 4px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}
.theme-btn:hover { color: var(--ink); }
.theme-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

.btn-console-toggle {
  width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.14s ease, color 0.14s ease;
}
.btn-console-toggle:hover { background: var(--hover); color: var(--ink); }
.sidebar-bottom-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sidebar-bottom-row .btn-console-toggle {
  flex: 1;
  justify-content: center;
}

.mobile-only-btn { display: none !important; }
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  z-index: 55;
}
.mobile-bottom-nav { display: none; }

/* ==================== CENTER CHAT WORKSPACE (Antigravity Style) ==================== */
.chat-column {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--chat-bg);
  background-size: var(--chat-bg-size);
  position: relative;
  min-width: 0;
}

.top-bar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.panel-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.14s ease;
}
.panel-toggle-btn:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.panel-toggle-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.top-title-block { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; min-width: 0; flex: 1; overflow: hidden; }
.top-title-block h1 {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 0;
}

.flow-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-dark);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-export {
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--btn-lip), var(--shadow-xs);
  transition: background 0.14s ease, transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.14s ease;
  flex-shrink: 0;
  white-space: nowrap;
}
.btn-export:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--btn-lip), var(--shadow-sm);
}
.btn-export:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--btn-lip);
}

/* Chat Feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msg {
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: msgSlideIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; width: 100%; }

.msg-who {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.msg.assistant .msg-who::before {
  content: var(--profile-emoji, "🎭");
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: var(--sparkle-grad);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(235, 94, 40, 0.25);
}

.msg-bubble {
  padding: 13px 18px;
  border-radius: 22px;
  line-height: 1.65;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg.user .msg-bubble {
  background: var(--user-bubble-bg);
  color: var(--user-bubble-ink);
  border: 1.5px solid var(--accent-line);
  border-bottom-right-radius: 6px;
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  white-space: pre-wrap;
}
.msg.assistant .msg-bubble {
  background: var(--assistant-card);
  backdrop-filter: blur(10px);
  border: 1.5px solid var(--assistant-border);
  border-top-left-radius: 6px;
  padding: 15px 20px;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ==================== CLEAN GOOGLE-STYLE MARKDOWN TYPOGRAPHY ==================== */
.md-content > *:first-child { margin-top: 0 !important; }
.md-content > *:last-child { margin-bottom: 0 !important; }
.md-content p { margin: 0 0 0.7em 0; }
.md-content h1, .md-content h2, .md-content h3, .md-content h4 {
  font-family: var(--display);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin: 0.95em 0 0.45em;
}
.md-content h1 { font-size: 1.3em; border-bottom: 1px solid var(--line); padding-bottom: 0.25em; }
.md-content h2 { font-size: 1.14em; color: var(--accent-dark); }
.md-content h3 { font-size: 1.03em; }
.md-content strong { font-weight: 600; color: var(--ink); }
.md-content em { font-style: italic; }
.md-content ul, .md-content ol {
  margin: 0.45em 0 0.75em 1.35em;
  padding: 0;
}
.md-content li { margin: 0.26em 0; }
.md-content blockquote {
  margin: 0.65em 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: var(--soft-blue);
  border-radius: 0 10px 10px 0;
  color: var(--ink-2);
}
.md-content code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--accent-dark);
}
.md-content pre {
  margin: 0.65em 0;
  padding: 12px 14px;
  background: #202124;
  color: #e8eaed;
  border-radius: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}
.md-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
}
.md-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.9em 0;
}

/* ==================== ANTIGRAVITY LIVE TASK & THINKING ACCORDION ==================== */
.work-card {
  background: var(--assistant-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  max-width: 680px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.work-card.active {
  border-color: var(--accent-line);
  background: var(--soft-blue);
  box-shadow: 0 2px 12px rgba(26, 115, 232, 0.12);
}

.work-head {
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.work-head-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sparkle-grad);
  flex-shrink: 0;
  animation: pulseGlow 1.3s ease-in-out infinite;
}
.done-check {
  color: var(--sage);
  font-weight: 700;
  flex-shrink: 0;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(0.9); opacity: 0.6; box-shadow: 0 0 0 0 rgba(26, 115, 232, 0.45); }
  50% { transform: scale(1.18); opacity: 1; box-shadow: 0 0 0 6px rgba(26, 115, 232, 0); }
}

.work-timer {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.work-body {
  border-top: 1px solid var(--line);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.work-card.collapsed .work-body { display: none; }

.resumed-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}

.work-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.work-step-icon { width: 15px; text-align: center; flex-shrink: 0; }
.work-step.running .work-step-icon { color: var(--accent); animation: spinSlow 1.4s linear infinite; }
.work-step.done .work-step-icon { color: var(--sage); }
.work-step.error .work-step-icon { color: var(--danger); }
.work-step-dur { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-muted); }

@keyframes spinSlow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.work-thinking-excerpt {
  font-size: 12px;
  color: var(--ink-muted);
  font-style: italic;
  line-height: 1.45;
  max-height: 76px;
  overflow-y: auto;
  padding-left: 10px;
  border-left: 2px solid var(--accent-line);
}

.btn-stop-job {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  border-color: #f6aea9 !important;
}

/* ==================== COMPOSER DOCK (Google / Gemini Pill Input) ==================== */
.composer-dock {
  padding: 12px 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--dock-bg);
}

.generate-banner {
  background: var(--assistant-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-xs);
}
.generate-banner-text { display: flex; flex-direction: column; gap: 2px; }
.generate-banner-text strong { font-family: var(--display); font-size: 14px; color: var(--ink); }
.generate-banner-text span { font-size: 12.5px; color: var(--ink-2); }

.btn-generate-reel {
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  background: var(--sparkle-grad);
  color: #fff;
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(26, 115, 232, 0.28);
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn-generate-reel:hover { filter: brightness(1.06); }
.btn-generate-reel:active { transform: translateY(1px); }

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.prompt-chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--line);
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.prompt-chip:hover {
  border-color: var(--accent-line);
  color: var(--accent-dark);
  background: var(--accent-soft);
  transform: translateY(-2px);
}
.prompt-chip:active { transform: translateY(1px); }

.composer-box {
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 26px;
  padding: 13px 17px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus-ring), var(--shadow-md);
}

.context-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.ctx-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
}
.ctx-pill button {
  border: none;
  background: transparent;
  color: inherit;
  font-weight: 700;
  cursor: pointer;
}

#chat-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  background: transparent;
}
#chat-input::placeholder { color: var(--ink-muted); }

.composer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.composer-tools { display: flex; gap: 6px; }

.tool-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.tool-btn:hover { background: var(--hover); color: var(--ink); }
.tool-btn.recording { background: var(--danger-soft); color: var(--danger); border-color: #f6aea9; }

.btn-send {
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.14s ease;
}
.btn-send:hover { background: var(--accent-dark); }
.btn-send:disabled { opacity: 0.42; cursor: not-allowed; }

/* Behind-the-Scenes Agent Console Drawer */
.console-drawer {
  border-top: 1px solid var(--line-strong);
  background: #202124;
  color: #e8eaed;
  max-height: 190px;
  display: flex;
  flex-direction: column;
}
.console-head {
  padding: 7px 16px;
  font-size: 11.5px;
  color: #9aa0a6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3c4043;
}
.console-close { border: none; background: transparent; color: #9aa0a6; cursor: pointer; }
.console-log {
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.48;
}

/* ==================== RIGHT INSPECTOR: REEL STAGE & ARTIFACT ==================== */
.stage-column {
  background: var(--rail);
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-width: 0;
}

.artifact-mode-bar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* Material 3 Segmented Button */
.artifact-tabs {
  display: inline-flex;
  background: var(--sidebar);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}

.artifact-tab {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s ease;
}
.artifact-tab.active {
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: var(--shadow-xs);
}

.artifact-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage);
  display: inline-block;
}

.right-mode-pane {
  display: none;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}
.right-mode-pane.active { display: flex; }

.btn-pill-accent {
  padding: 6px 13px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-pill-accent:hover { background: var(--accent-dark); }

/* Collaborative Story Artifact Card */
.artifact-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.artifact-card-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--soft-blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.artifact-title {
  font-family: var(--display);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.artifact-status {
  font-size: 11.5px;
  color: var(--ink-muted);
}
.artifact-status.saved { color: var(--sage); font-weight: 600; }
.artifact-actions { display: flex; gap: 6px; flex-shrink: 0; }

.artifact-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
}

.artifact-editor {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--surface);
}

.artifact-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--soft-blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Preview auto-refresh floating toast */
.preview-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(32, 33, 36, 0.9);
  color: #f8f9fa;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 6;
}

.phone-frame { cursor: zoom-in; }

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
#btn-larger-view {
  flex-shrink: 0;
  white-space: nowrap;
}
.mobile-add-lang-pill {
  display: none;
}

.lang-bar { display: flex; flex-wrap: wrap; gap: 5px; }

.lang-pill {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.lang-pill:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.lang-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-pill-soft {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s ease;
}
.btn-pill-soft:hover {
  border-color: var(--accent-line);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.stage-viewer-wrap { display: flex; flex-direction: column; gap: 7px; flex-shrink: 0; }

.phone-frame {
  height: clamp(230px, 40vh, 420px);
  width: auto;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  border-radius: 26px;
  overflow: hidden;
  background: #141028;
  border: 4px solid #3c261b;
  box-shadow: 0 0 0 2px rgba(244, 162, 29, 0.36), 0 16px 38px rgba(105, 58, 22, 0.24), 0 6px 16px rgba(15, 23, 42, 0.22);
  position: relative;
}
#stage-canvas, #stage-mp4-preview {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.empty-stage-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, #0f172a 0%, #172554 55%, #1e1b4b 100%);
  color: #f8fafc;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}
.empty-icon { font-size: 28px; color: #8ab4f8; }
.empty-title { font-family: var(--display); font-size: 18px; font-weight: 600; }
.empty-stage-overlay p { font-size: 12.5px; color: #cbd5e1; line-height: 1.5; }

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px 11px;
  box-shadow: var(--shadow-xs);
}

.btn-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--sparkle-grad);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 3px 0 rgba(154, 44, 82, 0.28), 0 5px 12px rgba(235, 94, 40, 0.26);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.14s ease;
}
.btn-play:hover { filter: brightness(1.06); transform: scale(1.07); }
.btn-play:active { transform: scale(0.95); }

.scrub-area { flex: 1; display: flex; flex-direction: column; gap: 2px; }
input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
#timeline-scrubber, #large-timeline-scrubber { width: 100%; accent-color: var(--accent); cursor: pointer; }
.scrub-labels { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.now-playing-scene {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  flex: 1;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-quick-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* Visual Selector (Scenes | Characters | Dialogues) */
.selector-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  flex: 1 1 220px;
  min-height: 220px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.selector-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 1px solid var(--line);
  background: var(--soft-blue);
}

.sel-tab {
  border: none;
  background: transparent;
  padding: 9px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.sel-tab:hover { color: var(--ink); }
.sel-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-bottom-color: var(--accent);
}

.sel-body {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}
.sel-body.active { display: flex; }

.sel-hint { font-size: 11.5px; color: var(--ink-muted); line-height: 1.4; }

.scene-chips { display: flex; flex-direction: column; gap: 6px; }

.scene-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--rail);
  cursor: pointer;
  transition: all 0.14s ease;
}
.scene-chip:hover { border-color: var(--line-strong); background: var(--soft-blue); }
.scene-chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.scene-chip input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.scene-chip-info { flex: 1; min-width: 0; }
.scene-chip-title { font-weight: 600; font-size: 12.5px; color: var(--ink); }
.scene-chip-sub { font-size: 11px; color: var(--ink-muted); }

.char-cards { display: flex; flex-direction: column; gap: 6px; }

.char-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--rail);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.14s ease;
}
.char-card:hover { border-color: var(--accent-line); background: var(--soft-blue); }
.char-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.char-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #202124;
  flex-shrink: 0;
}
.char-name { font-weight: 600; font-size: 13px; color: var(--ink); }
.char-role { font-size: 11.5px; color: var(--ink-muted); }

.story-readout { display: flex; flex-direction: column; gap: 8px; }
.story-line-card {
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--rail);
  border: 1px solid var(--line);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.story-line-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-dark);
}

/* ==================== MATERIAL 3 MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.45);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px 26px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  gap: 15px;
  animation: modalPop 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-wide { max-width: 780px; }

.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--soft); color: var(--ink-2); cursor: pointer; font-weight: 700;
  transition: background 0.14s ease;
}
.modal-close:hover { background: var(--hover); color: var(--ink); }

.simple-form { display: flex; flex-direction: column; gap: 11px; }
.simple-form label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.simple-form input {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  outline: none;
}
.simple-form input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

.lang-choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-choice {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.lang-choice.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }

.btn-create-submit, .btn-export-big {
  padding: 11px 20px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.14s ease;
}
.btn-create-submit:hover, .btn-export-big:hover { background: var(--accent-dark); }

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 9px;
}
.lang-card-btn {
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: all 0.14s ease;
}
.lang-card-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.export-top-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.export-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px; }
.export-field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.export-field select {
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}

.voice-master-card {
  background: var(--soft-blue);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voice-master-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
.voice-master-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.voice-master-controls select {
  flex: 1;
  min-width: 240px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}
.voice-key-row input {
  width: 100%;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--accent-line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
}
.voice-master-note { font-size: 12px; line-height: 1.4; }

.btn-audio-upgrade {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  background: var(--soft-blue);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}
.btn-audio-upgrade:hover {
  background: var(--hover);
  transform: translateY(-1px);
}
.btn-audio-upgrade.upgraded {
  background: var(--sparkle-grad);
  color: #fff;
  border-color: transparent;
}

.audio-upgrade-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.audio-upgrade-lang-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.audio-upgrade-lang-wrap select,
.audio-more-row select {
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.audio-tier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 720px) {
  .audio-tier-grid { grid-template-columns: 1fr; }
}
.audio-tier-card {
  text-align: left;
  padding: 12px 13px;
  border-radius: 15px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.audio-tier-card:hover {
  border-color: var(--accent-line);
  background: var(--soft-blue);
}
.audio-tier-card.selected {
  border-color: var(--accent);
  background: var(--soft-blue);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}
.audio-tier-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
.audio-tier-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.audio-tier-pill.local {
  background: rgba(16, 185, 129, 0.16);
  color: #059669;
}
.audio-tier-pill.paid {
  background: rgba(99, 102, 241, 0.16);
  color: var(--accent);
}
.audio-tier-pill.draft {
  background: var(--hover);
  color: var(--ink-2);
}
.audio-tier-pill.soon {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}
.audio-tier-card.coming-soon {
  opacity: 0.78;
}
.audio-key-unlock {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-2);
}
.audio-key-unlock summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.audio-tier-cost {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.audio-tier-title {
  font-size: 14px;
  font-weight: 700;
}
.audio-tier-desc {
  font-size: 11.5px;
  line-height: 1.38;
  color: var(--ink-2);
}

.audio-more-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.audio-more-row select { flex: 1; }

.audio-key-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.audio-key-head a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.audio-cast-details {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 9px 12px;
  background: var(--surface);
  font-size: 12.5px;
}
.audio-cast-details summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.audio-cast-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.audio-cast-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--soft-blue);
  border: 1px solid var(--line);
}
.audio-cast-row label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
}
.audio-cast-row select {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}

.audio-bumper-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}

.audio-upgrade-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.audio-upgrade-status {
  font-size: 12.5px;
  line-height: 1.45;
  min-height: 18px;
}
.audio-upgrade-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--soft-blue);
  border: 1px solid var(--line);
}

.lang-pill-group {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.lang-pill-group.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lang-pill-group .lang-pill-main {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 8px 5px 11px;
  cursor: pointer;
}
.lang-pill-group.active .lang-pill-main {
  color: var(--accent-dark);
}
.lang-pill-act {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  padding: 5px 7px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.14s ease, background 0.14s ease;
}
.lang-pill-act:hover {
  color: var(--accent-dark);
  background: var(--hover);
}
.lang-pill-act.del:hover {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.12);
}

.edit-lang-list {
  max-height: 56vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}
.edit-lang-scene {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--soft-blue);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.edit-lang-scene-head {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}
.edit-lang-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edit-lang-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.edit-lang-speaker {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
}
.edit-lang-controls {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.edit-lang-controls select {
  padding: 4px 7px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 11.5px;
}
.edit-lang-row textarea {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.stitch-progress {
  background: var(--soft-blue); border: 1px solid var(--line); border-radius: 16px; padding: 15px;
}
.stitch-row { display: flex; gap: 14px; align-items: center; }
.stitch-thumb {
  width: 72px; aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden;
  background: #141c38; border: 2px solid var(--line-strong); flex-shrink: 0;
}
.stitch-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stitch-info { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.stitch-msg { font-weight: 600; font-size: 14px; }
.progress-bar { width: 100%; height: 8px; border-radius: 999px; background: var(--hover); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--sparkle-grad); transition: width 0.2s ease; }
.stitch-meta { display: flex; justify-content: space-between; font-size: 12px; }

.export-ready { display: flex; flex-direction: column; gap: 12px; }
.ready-pill { padding: 10px 14px; border-radius: 12px; background: var(--sage-soft); color: var(--sage); font-weight: 600; }
.ready-layout { display: grid; grid-template-columns: 190px 1fr; gap: 16px; }
.ready-layout video { width: 100%; aspect-ratio: 9 / 16; border-radius: 14px; background: #000; }
.ready-details { display: flex; flex-direction: column; gap: 11px; }
.download-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-block { display: flex; flex-direction: column; gap: 4px; }
.copy-head { display: flex; justify-content: space-between; align-items: center; }
.copy-block label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.copy-block input, .copy-block textarea {
  width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--rail); color: var(--ink); font-size: 12.5px;
}
.btn-tiny {
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.btn-tiny:hover { border-color: var(--accent-line); color: var(--accent-dark); background: var(--accent-soft); }

/* Larger Cinema Video View Modal — Zero Overflow, Single-Row Header, Tall Sharp 9:16 Stage */
.large-view-shell {
  width: min(740px, 94vw);
  height: min(92vh, 880px);
  max-height: 94vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px 20px 16px;
  box-shadow: 0 28px 72px rgba(32, 33, 36, 0.34);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.large-view-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.large-view-title-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.large-view-head h3 {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.large-view-title-wrap .muted {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.large-view-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}
.large-view-head-actions .btn-pill-soft,
.large-view-head-actions .btn-pill-accent {
  white-space: nowrap;
}
.large-stage-center {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.large-phone-frame {
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 20px;
  overflow: hidden;
  background: #101836;
  border: 4px solid #202124;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.26);
  position: relative;
}
#large-stage-canvas, #large-mp4-preview {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.large-player-controls { width: 100%; flex-shrink: 0; }

/* Intro / Outro / Vocal Sound Library Modal */
.sound-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sound-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
}
.sound-current-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--sage);
  background: var(--sage-soft);
  padding: 2px 10px;
  border-radius: 999px;
}
.sound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.sound-card {
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.sound-card:hover { border-color: var(--accent-line); background: var(--soft-blue); }
.sound-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.sound-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sound-card-name { font-weight: 600; font-size: 13px; color: var(--ink); line-height: 1.25; }
.sound-card-desc { font-size: 11.5px; color: var(--ink-muted); line-height: 1.35; }
.sound-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
}

/* ==================== SIDEBAR NAV + REEL INTRO/OUTRO STRIP ==================== */
.sidebar-nav-btn {
  width: 100%;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: all 0.14s ease;
}
.sidebar-nav-btn:hover { background: var(--hover); color: var(--ink); }
.sidebar-nav-btn.active {
  background: var(--accent-pill);
  color: var(--accent-dark);
}
.sidebar-nav-btn .nav-icon { font-size: 15px; line-height: 1; }
.sidebar-nav-btn .nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-muted);
}
.sidebar-nav-btn.active .nav-badge {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.reel-bumper-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 9px;
  border-radius: 12px;
  background: var(--soft-blue);
  border: 1px solid var(--line);
}
.reel-bumper-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.reel-bumper-lbl {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
  width: 54px;
  flex-shrink: 0;
}
.reel-bumper-row select {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 500;
}
.scene-chip.is-bumper {
  border-style: dashed;
  background: var(--soft-blue);
}
.bumper-chip-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  flex-shrink: 0;
}

/* ==================== DEDICATED INTROS & OUTROS STUDIO VIEW ==================== */
.studio-layout.bumpers-mode {
  grid-template-columns: var(--left-w) 6px minmax(0, 1fr) !important;
}
.studio-layout.bumpers-mode.left-collapsed {
  grid-template-columns: 0px 0px minmax(0, 1fr) !important;
}
.studio-layout.bumpers-mode > .sidebar { grid-column: 1; }
.studio-layout.bumpers-mode > #resizer-left { grid-column: 2; }
.studio-layout.bumpers-mode > .bumpers-studio { grid-column: 3; }
.studio-layout.bumpers-mode .chat-column,
.studio-layout.bumpers-mode #resizer-right,
.studio-layout.bumpers-mode .stage-column {
  display: none !important;
}

.bumpers-studio {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--chat-bg);
  background-size: var(--chat-bg-size);
  min-width: 0;
}

.bumpers-topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.bumpers-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.bumpers-topbar-left h2 {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.2;
}
.bumpers-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bumpers-workspace {
  --b-left-w: 254px;
  --b-right-w: 328px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--b-left-w) 6px minmax(260px, 1fr) 6px var(--b-right-w);
  gap: 0;
  overflow: hidden;
}

.bumpers-list-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  padding: 14px 12px;
  background: var(--rail);
  border-right: 1px solid var(--line);
}

.bumpers-chat-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.bumper-composer-dock {
  padding: 10px 22px 18px;
}
#bumper-chat-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  background: transparent;
}
#bumper-chat-input::placeholder { color: var(--ink-muted); }

.bumpers-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--rail);
  border-left: 1px solid var(--line);
}
.bumper-preview-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bumper-phone-frame {
  height: clamp(270px, 48vh, 450px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 20px;
  overflow: hidden;
  background: #101836;
  border: 3.5px solid #202124;
  box-shadow: 0 14px 36px rgba(26, 115, 232, 0.16), 0 6px 18px rgba(15, 23, 42, 0.24);
  position: relative;
  flex-shrink: 0;
}
.bumper-meta-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-xs);
}
.bumper-meta-summary {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.bumper-meta-summary strong { color: var(--ink); font-size: 13.5px; }
.bumper-meta-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.bumper-meta-actions .btn-export {
  flex: 1;
  padding: 7px 12px;
  font-size: 12px;
}
.bumper-filter-bar {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 2px;
  box-sizing: border-box;
}
.bumper-filter-bar .artifact-tab {
  justify-content: center;
  padding: 5px 5px;
  font-size: 11px;
  gap: 3px;
  min-width: 0;
  white-space: nowrap;
}
.bumper-chat-subbar {
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bumper-chat-subbar-title {
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bumper-reels-box {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bumper-reels-head {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-muted);
}
.bumper-reels-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 120px;
  overflow-y: auto;
}
.bumper-reel-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 9px;
  background: var(--rail);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.bumper-reel-check:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.bumper-reel-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.bumpers-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  padding: 0 4px;
}
.bumpers-cards {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
.bumper-lib-card {
  padding: 11px 13px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--assistant-card);
  backdrop-filter: blur(10px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.14s ease;
  text-align: left;
}
.bumper-lib-card:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.bumper-lib-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}
.bumper-lib-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bumper-lib-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.bumper-lib-name {
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--ink);
}
.bumper-lib-meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.bumper-lib-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.bumper-mini-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink-2);
}
.bumper-mini-badge.is-default {
  background: var(--sage-soft);
  color: var(--sage);
}
.bumper-mini-badge.is-attached {
  background: var(--accent);
  color: #fff;
}

.bumpers-editor-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bumpers-editor-card {
  background: var(--assistant-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--assistant-border);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}
.bumpers-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.bumper-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px 14px;
}
.bf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bf-span-2 { grid-column: span 2; }
.bf-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.bf-field input[type="text"],
.bf-field select {
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  outline: none;
}
.bf-field input[type="text"]:focus,
.bf-field select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.bf-color-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.bf-color-row input[type="color"] {
  width: 28px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
}
.swatch-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.swatch-dot:hover { transform: scale(1.15); }
.bf-sound-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.bf-sound-row select { flex: 1; min-width: 0; }

.bf-narration-box {
  background: var(--soft-blue);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bf-narration-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink);
}
.bf-vo-lang-tabs {
  display: flex;
  gap: 5px;
}
.bf-vo-lang-tabs .btn-tiny.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.bf-narration-box textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
  outline: none;
}
.bf-narration-box textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.bf-narration-row {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}
.bf-narration-row select {
  flex: 1;
  min-width: 140px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
}
.bf-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  padding-top: 2px;
}
.bf-checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.bumper-editor-actions {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.bumper-editor-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-danger-soft {
  color: var(--danger) !important;
  border-color: rgba(197, 34, 31, 0.3) !important;
}
.btn-danger-soft:hover {
  background: var(--danger-soft) !important;
  border-color: var(--danger) !important;
}

#bumper-preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.bumpers-preview-col .player-controls { width: 100%; max-width: 320px; }

@media (max-width: 1240px) {
  .flow-pill { display: none; }
}
/* ==================== iPad Landscape Responsive Tuning (901px–1180px) ==================== */
@media (max-width: 1180px) and (min-width: 901px) {
  .studio-layout { --left-w: 204px; --right-w: 334px; grid-template-columns: var(--left-w) 6px minmax(300px, 1fr) 6px var(--right-w); }
  .bumpers-workspace { --b-left-w: 226px; --b-right-w: 280px; }
  .top-bar { padding: 10px 14px; gap: 8px; }
  .top-title-block h1 { font-size: 16.5px; }
  .btn-audio-upgrade { max-width: 168px; overflow: hidden; text-overflow: ellipsis; padding: 7px 11px; font-size: 12px; }
  .btn-export { padding: 8px 13px; font-size: 12.5px; }
  .chat-feed { padding: 18px 20px 14px; }
  .composer-dock { padding: 8px 16px 14px; }
  .panel-toggle-btn { width: 38px; height: 38px; }
}
@media (max-width: 620px) {
  .large-view-head { flex-wrap: wrap; }
  .large-view-head-actions { width: 100%; justify-content: flex-end; }
}

/* ==================== iPhone & iPad Portrait Native-App Layout (<= 900px) ==================== */
@media (max-width: 900px) {
  html, body {
    height: 100dvh;
    overflow: hidden;
  }
  .studio-layout,
  .studio-layout.bumpers-mode,
  .studio-layout.left-collapsed,
  .studio-layout.bumpers-mode.left-collapsed {
    display: flex !important;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }
  .panel-resizer { display: none !important; }
  .mobile-only-btn { display: grid !important; }
  #btn-toggle-right { display: none !important; }

  /* Slide-over Sidebar Drawer (strictly fixed so it NEVER consumes flex height on mobile!) */
  .sidebar,
  .studio-layout.left-collapsed .sidebar,
  .studio-layout.bumpers-mode.left-collapsed .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(304px, 85vw);
    z-index: 60;
    transform: translateX(-105%);
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.30);
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom)) !important;
    overflow-y: auto !important;
    border-right: 1px solid var(--line) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  .studio-layout.mobile-drawer-open .sidebar,
  .studio-layout.left-collapsed.mobile-drawer-open .sidebar {
    transform: translateX(0);
  }

  /* Reel Mode: Single Full-Height Active Tab + Bottom Native Nav */
  .chat-column,
  .stage-column,
  .studio-layout.right-collapsed .stage-column {
    flex: 1;
    min-height: 0;
    height: auto;
    width: 100%;
    border: none;
    opacity: 1 !important;
    pointer-events: auto !important;
    overflow: hidden;
  }
  .studio-layout:not(.bumpers-mode)[data-mobile-reel-tab="chat"] .stage-column { display: none !important; }
  .studio-layout:not(.bumpers-mode)[data-mobile-reel-tab="stage"] .chat-column,
  .studio-layout:not(.bumpers-mode)[data-mobile-reel-tab="artifact"] .chat-column { display: none !important; }

  /* Reclaim full vertical space on Mobile/iPad Portrait: hide desktop Stage/Story bar since bottom nav handles it! */
  .studio-layout:not(.bumpers-mode) .stage-column {
    padding-top: max(10px, env(safe-area-inset-top));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .stage-column .artifact-mode-bar {
    display: none !important;
  }
  .mobile-add-lang-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1.5px dashed var(--accent-line);
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
  }
  #pane-right-stage {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 18px;
  }
  #pane-right-stage .stage-viewer-wrap {
    flex-shrink: 0;
  }
  #pane-right-stage .phone-frame {
    height: clamp(280px, 46dvh, 430px);
    max-height: 46dvh;
  }
  #pane-right-stage .selector-panel {
    flex: 0 0 auto;
    min-height: 240px;
    overflow: visible;
  }
  #pane-right-stage .sel-body {
    max-height: 360px;
  }

  .top-bar {
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    gap: 8px;
  }
  .top-title-block { gap: 8px; }
  .top-title-block h1 { font-size: 15.5px; min-width: 0; }
  .top-actions { gap: 6px; }
  .panel-toggle-btn { width: 38px; height: 38px; }
  .btn-audio-upgrade {
    max-width: 126px;
    padding: 7px 10px;
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .btn-export {
    padding: 8px 12px;
    font-size: 12px;
  }
  .flow-pill { display: none; }
  .chat-feed { padding: 14px 14px 10px; }
  .composer-dock { padding: 8px 12px 10px; }
  .quick-prompts {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .quick-prompts::-webkit-scrollbar { display: none; }
  .prompt-chip { flex-shrink: 0; }
  #chat-input, #bumper-chat-input { font-size: 16px; } /* Prevents iOS Safari zoom on tap */

  /* Intros & Outros Mode on Mobile: Single Active Tab + Bottom Nav */
  .bumpers-studio {
    flex: 1;
    min-height: 0;
    height: auto;
    width: 100%;
  }
  .bumpers-topbar {
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    gap: 8px;
  }
  .bumpers-topbar .muted { display: none; }
  .bumpers-topbar-left h2 { font-size: 16px; }
  .bumpers-workspace {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .bumpers-list-col,
  .bumpers-chat-col,
  .bumpers-preview-col {
    flex: 1;
    min-height: 0;
    width: 100%;
    border: none;
  }
  .bumpers-studio[data-mobile-bumper-tab="list"] .bumpers-chat-col,
  .bumpers-studio[data-mobile-bumper-tab="list"] .bumpers-preview-col { display: none !important; }
  .bumpers-studio[data-mobile-bumper-tab="chat"] .bumpers-list-col,
  .bumpers-studio[data-mobile-bumper-tab="chat"] .bumpers-preview-col { display: none !important; }
  .bumpers-studio[data-mobile-bumper-tab="preview"] .bumpers-list-col,
  .bumpers-studio[data-mobile-bumper-tab="preview"] .bumpers-chat-col { display: none !important; }

  /* Native 4-Tab Bottom Navigation Bar (iPhone & iPad Portrait) */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1.5px solid var(--line);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    z-index: 40;
  }
  .studio-layout.bumpers-mode > #mobile-nav-reel { display: none !important; }
  .mobile-nav-tab {
    border: 1.5px solid transparent;
    background: transparent;
    color: var(--ink-muted);
    font-family: var(--display);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 4px;
    min-height: 48px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
  }
  .mobile-nav-tab .mnav-ico {
    font-size: 17px;
    line-height: 1;
  }
  .mobile-nav-tab .mnav-lbl {
    line-height: 1.1;
    white-space: nowrap;
  }
  .mobile-nav-tab.active {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-dark);
  }
}

/* iPad Portrait Comfortable Centering (640px–900px, flattened for max browser compatibility) */
@media (min-width: 640px) and (max-width: 900px) {
  .chat-feed,
  .composer-dock {
    max-width: 720px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
  #pane-right-stage,
  #pane-right-artifact {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
  }
  #pane-right-stage .phone-frame {
    height: clamp(360px, 50dvh, 520px);
    max-height: 52dvh;
  }
}

/* ============================================================================
   Playful Creative Storybook Polish + Rich Inline Chat Media Showcase
   ============================================================================ */

.btn-send,
.btn-create-submit,
.btn-export-big {
  font-family: var(--display);
  box-shadow: 0 3px 0 var(--btn-lip), var(--shadow-xs);
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.14s ease, box-shadow 0.14s ease;
}
.btn-send:hover,
.btn-create-submit:hover,
.btn-export-big:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--btn-lip), var(--shadow-sm);
}
.btn-send:active,
.btn-create-submit:active,
.btn-export-big:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--btn-lip);
}

.btn-audio-upgrade {
  font-family: var(--display);
  border-width: 1.5px;
  box-shadow: 0 2px 0 var(--line-strong);
}
.btn-audio-upgrade.upgraded {
  box-shadow: 0 3px 0 rgba(154, 44, 82, 0.28), 0 6px 14px rgba(235, 94, 40, 0.22);
}

.modal-card {
  border-width: 2px;
  border-radius: 28px;
}
.scene-chip,
.char-card,
.bumper-lib-card {
  border-width: 1.5px;
  border-radius: 15px;
}
.scene-chip:hover,
.char-card:hover {
  transform: translateY(-1px);
}
.bumper-phone-frame {
  border-radius: 26px;
  border: 4px solid #3c261b;
  box-shadow: 0 0 0 2px rgba(244, 162, 29, 0.36), 0 16px 38px rgba(105, 58, 22, 0.24);
}
.reel-item {
  border-radius: 16px;
}
.reel-item.active {
  border-color: var(--accent-line);
  box-shadow: 0 2px 0 rgba(235, 94, 40, 0.14);
}
.sidebar-nav-btn {
  border-radius: 16px;
}
.flow-pill {
  font-family: var(--display);
  border-width: 1.5px;
}
.artifact-card,
.selector-panel {
  border-width: 1.5px;
  border-radius: 20px;
}

/* ==================== INLINE CHAT MEDIA SHOWCASE (Audio, Images, Puppets) ==================== */
.chat-media-grid {
  display: grid;
  gap: 12px;
  margin: 12px 0 4px;
}
.chat-media-grid.cm-grid-single {
  grid-template-columns: minmax(0, 1fr);
}
.chat-media-grid.cm-grid-multi {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.cm-card {
  background: var(--soft-blue);
  border: 1.5px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xs);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s ease, box-shadow 0.15s ease;
}
.cm-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.cm-badge {
  font-family: var(--display);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--accent-line);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Audio Player Card */
.cm-audio-card {
  padding: 11px 13px;
  gap: 9px;
}
.cm-audio-card.is-playing {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.cm-audio-row {
  display: flex;
  align-items: center;
  gap: 11px;
}
.cm-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--sparkle-grad);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 rgba(154, 44, 82, 0.25), 0 4px 10px rgba(235, 94, 40, 0.22);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cm-play-btn:hover { transform: scale(1.08); }
.cm-play-btn:active { transform: scale(0.95); }
.cm-audio-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cm-audio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.cm-audio-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cm-audio-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.3;
}
.cm-audio-track {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.cm-audio-bar {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
  cursor: pointer;
}
.cm-audio-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--sparkle-grad);
  transition: width 0.1s linear;
}
.cm-audio-time {
  font-size: 10.5px;
  flex-shrink: 0;
}

/* Image Preview Card */
.cm-img-btn {
  position: relative;
  border: none;
  padding: 0;
  background: #141028;
  cursor: zoom-in;
  display: block;
  width: 100%;
  overflow: hidden;
}
.cm-img-btn img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.cm-img-btn:hover img {
  transform: scale(1.03);
}
.cm-img-zoom-pill {
  position: absolute;
  right: 9px;
  bottom: 9px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(20, 16, 40, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}
.cm-img-caption {
  padding: 9px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cm-img-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.cm-img-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.cm-img-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
}

/* Live Articulated Profile-Native Character Card */
.cm-char-stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 11;
  max-height: 240px;
  background: var(--soft-blue);
  overflow: hidden;
}
.cm-char-canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.cm-char-float-badge {
  position: absolute;
  top: 8px;
  left: 8px;
}
.cm-char-info {
  padding: 9px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cm-char-title {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.cm-char-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.35;
}
.cm-char-swatches {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 3px;
}
.cm-swatch {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid rgba(43, 30, 22, 0.35);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35);
}
.cm-voice-chip {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

/* Card Footer Actions (Hear Voice + One-Tap Pick Option) */
.cm-card-foot {
  padding: 8px 11px 10px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}
.cm-mini-audio-btn,
.cm-pick-btn {
  border-radius: 999px;
  font-family: var(--display);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  cursor: pointer;
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.14s ease;
}
.cm-mini-audio-btn {
  border: 1.5px solid var(--line-strong);
  background: var(--soft-blue);
  color: var(--ink);
}
.cm-mini-audio-btn:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.cm-pick-btn {
  margin-left: auto;
  border: none;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 0 var(--btn-lip);
}
.cm-pick-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}
.cm-pick-btn:active {
  transform: translateY(1px);
}

/* Full-Screen Image Lightbox */
.cm-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(18, 14, 34, 0.78);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 22px;
}
.cm-lightbox-shell {
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 26px;
  max-width: min(92vw, 760px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.45);
  animation: modalPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cm-lightbox-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cm-lightbox-caption {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.cm-lightbox-body {
  padding: 14px;
  background: #120e24;
  display: grid;
  place-items: center;
  overflow: auto;
}
.cm-lightbox-img {
  max-width: 100%;
  max-height: 76vh;
  border-radius: 14px;
  display: block;
}

/* ============================================================================
   Kahani Studio — Netflix-Style Animation Profile Switcher & Picker Overlay
   ============================================================================ */

.profile-switch-pill {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 16px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 2px 0 var(--line);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.14s ease, box-shadow 0.14s ease;
}
.profile-switch-pill:hover {
  border-color: var(--profile-accent, var(--accent));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(105, 58, 22, 0.12);
}
.profile-switch-emoji {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--profile-accent, var(--accent)) 18%, var(--soft));
  border: 1.5px solid color-mix(in srgb, var(--profile-accent, var(--accent)) 45%, transparent);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.profile-switch-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.profile-switch-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.profile-switch-name {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-switch-arrow {
  font-size: 14px;
  font-weight: 700;
  color: var(--profile-accent, var(--accent));
  padding: 2px 5px;
}

/* Full-Screen Netflix-Style Profile Picker */
.profile-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 160;
  background: color-mix(in srgb, var(--paper) 90%, rgba(16, 12, 32, 0.4));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  overflow-y: auto;
}
.profile-picker-shell {
  margin: auto 0;
  width: 100%;
  max-width: 1040px;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 32px;
  padding: 28px 32px 32px;
  box-shadow: 0 28px 72px rgba(20, 14, 42, 0.24);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modalPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#modal-new-profile {
  z-index: 180;
}
.profile-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.profile-picker-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-picker-logo {
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(235, 94, 40, 0.25);
}
.profile-picker-kicker {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.profile-picker-head h2 {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
}
.profile-picker-lead {
  font-size: 14px;
  color: var(--ink-2);
  max-width: 720px;
}

.profile-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 14px;
}

.profile-tile {
  background: var(--soft-blue);
  border: 2px solid var(--line-strong);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.16s ease, box-shadow 0.16s ease;
}
.profile-tile:hover {
  transform: translateY(-5px) scale(1.015);
  border-color: var(--tile-accent, var(--accent));
  box-shadow: 0 14px 30px rgba(20, 14, 42, 0.16);
}
.profile-tile.is-active {
  border-color: var(--tile-accent, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tile-accent, var(--accent)) 22%, transparent), var(--shadow-sm);
}
.profile-tile-art {
  position: relative;
  width: 100%;
  aspect-ratio: 14 / 11;
  background: #141028;
  overflow: hidden;
}
.profile-tile-canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.profile-tile-emoji {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
  display: grid;
  place-items: center;
  font-size: 19px;
}
.profile-tile-active-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tile-accent, var(--accent));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
}
.profile-tile-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #dc2626;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
}
.profile-tile-body {
  padding: 13px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.profile-tile-title {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.profile-tile-sub {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--tile-accent, var(--accent-dark));
}
.profile-tile-desc {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.42;
  margin-top: 2px;
}
.profile-tile-foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
}
.profile-tile-count {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.profile-tile-enter {
  color: var(--tile-accent, var(--accent));
  font-family: var(--display);
}

.profile-tile-add {
  border-style: dashed;
  background: transparent;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 18px;
  gap: 8px;
  min-height: 240px;
}
.profile-add-plus {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px dashed var(--accent-line);
  color: var(--accent);
  font-size: 28px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.profile-select,
.profile-textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  outline: none;
}
.profile-select:focus,
.profile-textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.profile-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.profile-form-row > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

@media (max-width: 720px) {
  .profile-picker-overlay {
    padding: 14px;
  }
  .profile-picker-shell {
    padding: 18px 16px 20px;
    border-radius: 24px;
  }
  .profile-picker-head h2 {
    font-size: 20px;
  }
  .profile-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 12px;
  }
}

/* ==================== DUAL-TRACK VOICE ENGINE SWITCHER & DIALOGUE EDITOR BAR ==================== */
.provider-track-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 2px;
  flex-wrap: wrap;
}
.provider-track-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-right: 2px;
}
.provider-track-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--display);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s ease;
}
.provider-track-pill:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.provider-track-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}
.provider-track-pill.is-master.active {
  background: var(--sparkle-grad);
  border-color: transparent;
}
.provider-track-pill.is-cta {
  border-style: dashed;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.edit-lang-engine-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--soft-blue);
  border: 1.5px solid var(--line);
}
.edit-lang-engine-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.edit-lang-override-chk {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
}
.edit-lang-override-chk input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

/* ==================== ACCESSIBILITY FOCUS RINGS ==================== */
button:focus-visible,
[role="button"]:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ============================================================================
   PER-PROFILE VISUAL STUDIO ATMOSPHERES (Distinct Creative Worlds!)
   ============================================================================ */

/* 🖍️ DOODLE COMEDY ("Not Your Type" Comic Zine & Sketchbook Aesthetic) */
:root[data-profile-style="doodle_comedy"]:not([data-theme="dark"]) {
  --paper: #f8fafc;
  --sidebar: #eef2ff;
  --rail: #f1f5f9;
  --soft: #e0e7ff;
  --soft-blue: #fefce8;
  --hover: #dbeafe;
  --line: #cbd5e1;
  --line-strong: #1e293b;
  --sparkle-grad: linear-gradient(135deg, #2563eb 0%, #7c3aed 52%, #ec4899 100%);
  --chat-bg:
    linear-gradient(to right, rgba(37, 99, 235, 0.065) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 99, 235, 0.065) 1px, transparent 1px),
    radial-gradient(ellipse 58% 44% at 88% 10%, rgba(250, 204, 21, 0.22), transparent 60%),
    radial-gradient(ellipse 52% 42% at 14% 92%, rgba(236, 72, 153, 0.12), transparent 60%),
    #fbfdff;
  --chat-bg-size: 26px 26px, 26px 26px, 100% 100%, 100% 100%, 100% 100%;
  --topbar-bg: rgba(248, 250, 252, 0.92);
  --assistant-card: #ffffff;
  --assistant-border: #1e293b;
  --user-bubble-bg: #fef08a;
  --user-bubble-ink: #0f172a;
}
:root[data-profile-style="doodle_comedy"]:not([data-theme="dark"]) .msg.assistant .msg-bubble,
:root[data-profile-style="doodle_comedy"]:not([data-theme="dark"]) .composer-box,
:root[data-profile-style="doodle_comedy"]:not([data-theme="dark"]) .cm-card,
:root[data-profile-style="doodle_comedy"]:not([data-theme="dark"]) .profile-switch-pill {
  border: 2px solid #1e293b;
  box-shadow: 3px 3px 0 rgba(15, 23, 42, 0.14);
}
:root[data-profile-style="doodle_comedy"]:not([data-theme="dark"]) .msg.user .msg-bubble {
  border: 2px solid #1e293b;
  box-shadow: 3px 3px 0 rgba(15, 23, 42, 0.16);
}
:root[data-profile-style="doodle_comedy"]:not([data-theme="dark"]) .phone-frame {
  border: 4px solid #18181b;
  box-shadow: 6px 6px 0 rgba(37, 99, 235, 0.22), 0 14px 32px rgba(15, 23, 42, 0.18);
}
:root[data-profile-style="doodle_comedy"][data-theme="dark"] {
  --sparkle-grad: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #f472b6 100%);
  --chat-bg:
    linear-gradient(to right, rgba(56, 189, 248, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56, 189, 248, 0.08) 1px, transparent 1px),
    radial-gradient(ellipse 60% 45% at 88% 12%, rgba(244, 114, 182, 0.16), transparent 60%),
    #0f1424;
  --chat-bg-size: 28px 28px, 28px 28px, 100% 100%, 100% 100%;
}

/* 🎨 STORYBOOK WATERCOLOR (Dreamy Hand-Painted Botanical Atelier) */
:root[data-profile-style="storybook_watercolor"]:not([data-theme="dark"]) {
  --paper: #f7fcf9;
  --sidebar: #ebf7f2;
  --rail: #f2faf6;
  --soft: #ddf3ea;
  --soft-blue: #fefce8;
  --hover: #d1eee3;
  --line: #cde7dc;
  --line-strong: #9fd2bf;
  --sparkle-grad: linear-gradient(135deg, #14b8a6 0%, #f59e0b 52%, #fb7185 100%);
  --chat-bg:
    radial-gradient(ellipse 65% 50% at 12% 10%, rgba(167, 243, 208, 0.36), transparent 64%),
    radial-gradient(ellipse 58% 46% at 88% 14%, rgba(254, 240, 138, 0.34), transparent 62%),
    radial-gradient(ellipse 64% 48% at 50% 94%, rgba(251, 207, 232, 0.28), transparent 64%),
    #f9fdfb;
  --chat-bg-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  --topbar-bg: rgba(247, 252, 249, 0.88);
  --assistant-card: rgba(255, 255, 255, 0.92);
  --assistant-border: rgba(159, 210, 191, 0.72);
  --user-bubble-bg: linear-gradient(135deg, #ccfbf1 0%, #fef3c7 100%);
  --user-bubble-ink: #134e4a;
}
:root[data-profile-style="storybook_watercolor"]:not([data-theme="dark"]) .msg.assistant .msg-bubble,
:root[data-profile-style="storybook_watercolor"]:not([data-theme="dark"]) .composer-box,
:root[data-profile-style="storybook_watercolor"]:not([data-theme="dark"]) .cm-card {
  border-radius: 24px;
  box-shadow: 0 10px 28px rgba(15, 118, 110, 0.08);
}
:root[data-profile-style="storybook_watercolor"]:not([data-theme="dark"]) .phone-frame {
  border: 4px solid #115e59;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.22), 0 16px 38px rgba(15, 118, 110, 0.18);
}
:root[data-profile-style="storybook_watercolor"][data-theme="dark"] {
  --sparkle-grad: linear-gradient(135deg, #2dd4bf 0%, #fbbf24 52%, #fb7185 100%);
  --chat-bg:
    radial-gradient(ellipse 65% 50% at 15% 10%, rgba(20, 184, 166, 0.18), transparent 62%),
    radial-gradient(ellipse 56% 45% at 86% 16%, rgba(251, 191, 36, 0.14), transparent 60%),
    #0e1b1d;
  --chat-bg-size: 100% 100%, 100% 100%, 100% 100%;
}

/* ==========================================================================
   🎟 Studio Change Tickets (Story Companion requests -> owner review)
   ========================================================================== */
.nav-badge.hidden { display: none; }
#ticket-count-badge {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ticket-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 14px;
}
.ticket-filter {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}
.ticket-filter:hover { background: var(--hover); color: var(--ink); }
.ticket-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(62vh, 640px);
  overflow-y: auto;
  padding-right: 2px;
}
.ticket-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-muted);
  border: 1.5px dashed var(--line);
  border-radius: 16px;
}
.ticket-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 10px 12px;
}
.ticket-card.prio-high { border-left-color: #e5484d; }
.ticket-card.prio-normal { border-left-color: var(--accent); }
.ticket-card.prio-low { border-left-color: #8fb996; }
.ticket-card.status-done,
.ticket-card.status-rejected { opacity: 0.78; }
.ticket-head {
  all: unset;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  cursor: pointer;
}
.ticket-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.ticket-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.ticket-title {
  flex: 1;
  min-width: 0;
  font-weight: 650;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.ticket-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--ink);
}
.status-open .ticket-pill { background: #fff1c2; color: #7a5400; }
.status-approved .ticket-pill { background: #d8f5df; color: #1f6b35; }
.status-in_progress .ticket-pill { background: #dbeafe; color: #1e4fa3; }
.status-done .ticket-pill { background: #e7e5ff; color: #4b3fb5; }
.status-rejected .ticket-pill { background: #fde2e2; color: #9b1c1c; }
.ticket-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}
.ticket-detail { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.ticket-detail.hidden { display: none; }
.ticket-body {
  font-size: 13.5px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--hover);
  overflow-wrap: anywhere;
}
.ticket-note-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-muted); }
.ticket-note {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}
.ticket-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ticket-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-height: 34px;
}
.ticket-btn:hover { background: var(--hover); }
.ticket-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.ticket-btn:disabled { opacity: 0.55; cursor: progress; }
@media (max-width: 640px) {
  .ticket-head { flex-wrap: wrap; }
  .ticket-title { flex-basis: 100%; order: 3; }
  .ticket-btn { flex: 1 1 calc(50% - 6px); }
}

/* 📖 Quick Guide panel */
.guide-body {
  max-height: min(70vh, 720px);
  overflow-y: auto;
  padding-right: 4px;
  font-size: 14.5px;
  line-height: 1.6;
}
.guide-body h1 { font-size: 20px; margin: 4px 0 8px; }
.guide-body h2 { font-size: 16.5px; margin: 18px 0 6px; }
.guide-body hr { border: none; border-top: 1px dashed var(--line); margin: 14px 0; }
.guide-body ul,
.guide-body ol { padding-left: 22px; margin: 6px 0; }
.guide-body li { margin: 3px 0; }
.sidebar-bottom-row { flex-wrap: wrap; }
.guide-body > h1:first-child { display: none; }

/* 📱 Phone & iPad Persistent Access Modal */
#remote-live-badge {
  background: #1f8a4c;
  border-color: #1f8a4c;
  color: #fff;
}
.remote-access-body { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.remote-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--surface);
}
.remote-card.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface), var(--hover));
}
.remote-qr-col { flex-shrink: 0; }
.remote-qr-img {
  width: 148px;
  height: 148px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffaf2;
  display: block;
}
.remote-qr-img.small { width: 96px; height: 96px; }
.remote-info-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.remote-kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; color: var(--accent); }
.remote-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.remote-url-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.remote-url-input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.remote-health-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.remote-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
}
.remote-pill.ok { background: #dcfce7; border-color: #86efac; color: #166534; }
@media (max-width: 640px) {
  .remote-card { flex-direction: column; align-items: stretch; text-align: center; }
  .remote-qr-img { margin: 0 auto; }
  .remote-url-row { flex-direction: column; align-items: stretch; }
}
