:root {
  --bg-root: #0d1117;
  --bg-surface: #151b23;
  --bg-elevated: #1c2430;
  --bg-hover: #242e3d;
  --border: #2a3444;
  --border-subtle: #1f2835;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.45);
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-script: 'Courier Prime', 'Courier New', Courier, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ==================== HEADER ==================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 40;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 8px;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.brand-name {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -2px;
}

.project-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.project-select {
  max-width: 210px;
  font-weight: 600;
}

.header-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-root);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

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

.tab-btn.active {
  background: var(--bg-elevated);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.lang-switch {
  display: inline-flex;
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ==================== BUTTONS & INPUTS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

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

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
}

.btn-full {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ai {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}

.btn-ai:hover:not(:disabled) {
  filter: brightness(1.1);
}

.script-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-ghost.danger:hover {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
}

.btn-link {
  background: none;
  border: none;
  color: #60a5fa;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

.icon-btn-sm {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.icon-btn-sm:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.input-sm,
select.input-sm,
textarea.input-sm {
  background: var(--bg-root);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  width: 100%;
}

.input-sm:focus,
select.input-sm:focus,
textarea.input-sm:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.22);
}

.input-sm.center {
  text-align: center;
}

.input-xs {
  background: var(--bg-root);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 12px;
  width: 54px;
  text-align: center;
}

.badge-muted {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
}

/* Dropdowns */
.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 225px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  z-index: 80;
}

.dropdown-menu.dropdown-right {
  left: auto;
  right: 0;
}

.dropdown-menu.open {
  display: block;
}

.dropdown-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ==================== MAIN WORKSPACE ==================== */
.app-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 480px;
  padding: 40px 24px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.empty-state p {
  color: var(--text-secondary);
  margin: 0 0 20px;
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==================== VIEW 1: BREAKDOWN ==================== */
.breakdown-layout {
  display: grid;
  grid-template-columns: 270px 1fr 365px;
  height: 100%;
  min-height: 0;
}

.scene-nav-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.pane-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pane-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pane-title-row h3 {
  margin: 0;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.total-pgs-badge {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.filter-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--bg-root);
  color: var(--text-secondary);
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.scene-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scene-nav-item {
  display: flex;
  align-items: stretch;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 9px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.12s ease;
}

.scene-nav-item:hover {
  background: var(--bg-elevated);
}

.scene-nav-item.active {
  background: var(--bg-elevated);
  border-color: var(--accent);
}

.scene-color-bar {
  width: 5px;
  border-radius: 3px;
  border: 1px solid;
  flex-shrink: 0;
}

.scene-nav-main {
  flex: 1;
  min-width: 0;
}

.scene-nav-top {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
}

.scene-num-pill {
  color: #60a5fa;
  font-weight: 700;
  min-width: 20px;
}

.scene-ie {
  color: var(--text-secondary);
  font-size: 11px;
}

.scene-set-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-nav-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.tod-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--text-muted);
}

/* Center Screenplay Pane */
.script-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #10151d;
}

.script-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.script-nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.script-scene-indicator {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.script-tip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.tip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a855f7;
}

.script-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 26px 24px 64px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Authentic Screenplay Paper */
.screenplay-page {
  width: 100%;
  max-width: 740px;
  min-height: 520px;
  background: #ffffff;
  color: #111827;
  font-family: var(--font-script);
  font-size: 14.5px;
  line-height: 1.48;
  padding: 46px 58px 56px;
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  selection-background-color: #dbeafe;
}

.screenplay-page ::selection {
  background: #bfdbfe;
  color: #0f172a;
}

.sp-scene-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e2e8f0;
  letter-spacing: 0.01em;
}

.sp-scene-num-left,
.sp-scene-num-right {
  color: #64748b;
  font-size: 13px;
  user-select: none;
}

.sp-scene-heading-text {
  flex: 1;
}

.sp-para {
  margin: 0 0 13px;
  white-space: pre-wrap;
}

.sp-type-character {
  margin: 16px 0 0;
  padding-left: 34%;
  text-transform: uppercase;
  font-weight: 700;
}

.sp-type-parenthetical {
  margin: 0;
  padding-left: 25%;
  padding-right: 22%;
  color: #374151;
}

.sp-type-dialogue {
  margin: 0 0 12px;
  padding-left: 17%;
  padding-right: 17%;
}

.sp-type-transition {
  text-align: right;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 16px;
}

mark.script-tag {
  padding: 1px 3px;
  border-radius: 3px;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.12s ease;
}

mark.script-tag:hover {
  filter: brightness(0.92);
}

/* Floating Tag Popover */
.tag-popover {
  position: fixed;
  z-index: 120;
  width: 390px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  animation: popIn 0.12s ease-out;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tag-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tag-popover-title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-popover-name-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.tag-global-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.tag-cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  max-height: 260px;
  overflow-y: auto;
}

.tag-cat-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s ease;
}

.tag-cat-btn:hover {
  background: var(--cat-bg);
  color: var(--cat-text);
  border-color: var(--cat-color);
}

.tag-cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-cat-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-cat-btn kbd {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-family: inherit;
}

/* Right Breakdown Sheet Pane */
.sheet-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  min-height: 0;
}

.sheet-banner {
  padding: 12px 14px;
  flex-shrink: 0;
}

.sheet-banner-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.sheet-scene-badge {
  font-weight: 800;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 5px;
}

.sheet-ie-tod {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex: 1;
}

.sheet-eighths-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
}

.sheet-banner-set {
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.silent-cast-alert {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  padding: 9px 10px;
}

.silent-cast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: #fcd34d;
  margin-bottom: 6px;
}

.silent-cast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.silent-cast-chip {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fef3c7;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.silent-cast-chip:hover {
  background: rgba(245, 158, 11, 0.35);
}

.sheet-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.field > span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-span-2 {
  grid-column: span 2;
}

.eighths-stepper {
  display: grid;
  grid-template-columns: 26px 1fr 26px;
  gap: 4px;
}

.step-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 5px;
  cursor: pointer;
  font-weight: 700;
}

.step-btn:hover {
  background: var(--bg-hover);
}

.sheet-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.sheet-section-title h4 {
  margin: 0;
  font-size: 13px;
}

.quick-add-bar {
  display: grid;
  grid-template-columns: 115px 1fr auto;
  gap: 5px;
}

.sheet-elements-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.muted-empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 16px 8px;
  margin: 0;
}

.cat-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.cat-group-count {
  color: var(--text-muted);
  font-weight: 600;
}

.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.element-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.cast-id-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 4px;
  background: #ef4444;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
}

.chip-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.chip-remove:hover {
  color: #f87171;
}

/* ==================== VIEW 2: STRIPBOARD ==================== */
.stripboard-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.stripboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.sb-stats-row,
.sb-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sb-controls-row select.input-sm {
  width: auto;
  max-width: 170px;
}

.kpi-pill {
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 12px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.kpi-pill strong {
  font-size: 13.5px;
  color: #fff;
}

.kpi-pill span {
  color: var(--text-secondary);
  font-size: 11.5px;
}

.sb-legend-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px;
  background: #11161e;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 8px;
}

.sb-legend-items {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-chip i {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid;
  display: inline-block;
}

.sb-main-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}

.sb-main-grid.with-inspector {
  grid-template-columns: 1fr 340px;
}

.sb-board-column {
  overflow-y: auto;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.strip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
}

/* Classic Production Strip */
.strip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: grab;
  user-select: none;
  position: relative;
  transition: transform 0.1s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.strip-row:active {
  cursor: grabbing;
}

.strip-row.dragging {
  opacity: 0.4;
}

.strip-row.dimmed {
  opacity: 0.26;
}

.strip-row.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.strip-row.drop-before::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: #38bdf8;
  border-radius: 2px;
  box-shadow: 0 0 8px #38bdf8;
}

.strip-row.drop-after::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: #38bdf8;
  border-radius: 2px;
  box-shadow: 0 0 8px #38bdf8;
}

.strip-scene.compact {
  padding: 5px 10px;
}

.drag-handle {
  opacity: 0.45;
  font-weight: 800;
  letter-spacing: -1px;
  cursor: grab;
  flex-shrink: 0;
}

.strip-scn-num {
  font-weight: 800;
  min-width: 34px;
  text-align: center;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.strip-ie {
  font-weight: 800;
  font-size: 11px;
  min-width: 48px;
  text-align: center;
  opacity: 0.8;
  flex-shrink: 0;
}

.strip-main-info {
  flex: 1;
  min-width: 0;
}

.strip-set-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.strip-set-name {
  font-weight: 800;
  letter-spacing: 0.01em;
}

.strip-synopsis {
  font-size: 11.5px;
  opacity: 0.78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.strip-synopsis-inline {
  font-size: 11.5px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.strip-tod-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  min-width: 64px;
  text-align: center;
  flex-shrink: 0;
}

.strip-eighths {
  font-family: var(--font-script);
  font-weight: 700;
  min-width: 48px;
  text-align: right;
  font-size: 12.5px;
  flex-shrink: 0;
}

.strip-cast-pills {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 90px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.strip-cast-pill {
  background: #1e293b;
  color: #f8fafc;
  font-size: 10.5px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  display: inline-grid;
  place-items: center;
}

.strip-extra-badge {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.65;
  min-width: 26px;
  text-align: center;
}

.strip-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.55;
  transition: opacity 0.12s;
}

.strip-row:hover .strip-actions {
  opacity: 1;
}

.strip-icon-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.strip-icon-btn:hover {
  background: rgba(0, 0, 0, 0.18);
}

/* Day Break Strip (Classic MMS Black Bar) */
.strip-daybreak {
  background: #090d14;
  color: #f8fafc;
  border: 1px solid #334155;
  border-left: 5px solid #ef4444;
  padding: 7px 12px;
  margin: 4px 0 8px;
}

.daybreak-title {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #f8fafc;
}

.daybreak-date-input {
  background: #151d2b;
  border: 1px solid #334155;
  color: #cbd5e1;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11.5px;
  font-family: inherit;
}

.daybreak-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.daybreak-pill {
  background: #1e293b;
  color: #e2e8f0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 700;
}

.daybreak-del {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.daybreak-del:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

/* Banner Strip */
.strip-banner {
  background: #422006;
  color: #fef3c7;
  border: 1px solid #b45309;
  border-left: 5px solid #f59e0b;
  padding: 5px 12px;
}

.banner-icon {
  font-size: 13px;
}

.banner-label-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: #fef3c7;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 4px;
  outline: none;
}

.banner-label-input:hover,
.banner-label-input:focus {
  background: rgba(0, 0, 0, 0.25);
  border-color: rgba(245, 158, 11, 0.5);
}

/* Boneyard */
.boneyard-section {
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color 0.15s, background 0.15s;
}

.boneyard-section.drag-over-zone,
.strip-list.drag-over-zone {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.boneyard-header h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.boneyard-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.boneyard-empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 14px;
}

/* Stripboard Quick Inspector */
.sb-inspector {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sb-inspector-banner {
  padding: 14px;
}

.sb-inspector-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.sb-inspector-set {
  font-size: 15px;
  font-weight: 800;
  margin-top: 4px;
}

.sb-inspector-meta {
  font-size: 11.5px;
  opacity: 0.78;
  margin-top: 3px;
}

.sb-inspector-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inspector-synopsis {
  margin: 0;
  color: var(--text-primary);
  font-size: 12.5px;
}

.inspector-notes {
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.inspector-elements {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==================== VIEW 3: DOOD ==================== */
.dood-shell,
.elements-shell {
  padding: 20px 24px 36px;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dood-header,
.elements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.dood-header h2,
.elements-header h2 {
  margin: 0;
  font-size: 19px;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.dood-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.inline-select select.input-sm {
  width: auto;
}

.dood-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.dood-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dood-table-wrap,
.elements-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
}

.dood-table,
.elements-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.dood-table th,
.dood-table td {
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  padding: 8px 10px;
  text-align: center;
}

.dood-table thead th {
  background: var(--bg-elevated);
  font-weight: 700;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 3;
}

.dood-table tfoot td {
  background: var(--bg-elevated);
  border-top: 2px solid var(--border);
}

.dood-table .col-id {
  width: 56px;
}

.dood-table .col-name {
  text-align: left;
  min-width: 185px;
  font-weight: 700;
}

.sticky-col {
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: 2;
}

.sticky-col-2 {
  position: sticky;
  left: 56px;
  background: var(--bg-surface);
  z-index: 2;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.2);
}

thead .sticky-col,
thead .sticky-col-2,
tfoot .sticky-col,
tfoot .sticky-col-2 {
  background: var(--bg-elevated);
  z-index: 4;
}

.dood-day-num {
  font-weight: 800;
  font-size: 13px;
}

.dood-day-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.dood-code {
  display: inline-block;
  min-width: 34px;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.dood-code.code-sw,
.dood-code.code-wf,
.dood-code.code-swf {
  background: rgba(59, 130, 246, 0.24);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.dood-code.code-w {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.dood-code.code-h {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.hold-warn {
  color: #fbbf24;
  font-weight: 800;
}

.col-sum.strong {
  font-weight: 700;
}

.dood-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ==================== VIEW 4: ELEMENTS ==================== */
.scan-banner {
  background: rgba(245, 158, 11, 0.11);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scan-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: #fef3c7;
}

.scan-banner-btns {
  display: flex;
  gap: 6px;
}

.scan-matches-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scan-match-pill {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: #fde68a;
}

.elements-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.elements-toolbar #elements-search {
  max-width: 280px;
}

.elements-create-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.elements-create-bar select.input-sm {
  width: 170px;
}

.elements-create-bar input.input-sm {
  width: 190px;
}

.elements-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 99px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cat-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #fff;
}

.cat-tab span {
  opacity: 0.7;
  font-size: 11px;
}

.elements-table th,
.elements-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: middle;
}

.elements-table thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-inline-name {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 5px;
  width: 100%;
  outline: none;
}

.input-inline-name:hover {
  border-color: var(--border);
}

.input-inline-name:focus {
  background: var(--bg-root);
  border-color: var(--accent);
}

.cat-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 700;
}

.scene-ref-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.scene-ref-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: #93c5fd;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.scene-ref-pill:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.muted-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 3px;
}

.el-row-actions {
  text-align: right !important;
  white-space: nowrap;
}

/* ==================== DROP OVERLAY & TOASTS ==================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.84);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  z-index: 200;
  pointer-events: none;
}

.drop-overlay.visible {
  display: grid;
}

.drop-overlay-card {
  border: 2px dashed var(--accent);
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
}

.drop-overlay-icon {
  font-size: 44px;
  margin-bottom: 8px;
}

#toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-info {
  border-left: 4px solid var(--accent);
}

/* ==================== AI AUTO-BREAKDOWN MODAL ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 15, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 250;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.14s ease-out;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-subtitle {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 12.5px;
}

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

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

.ai-config-grid,
.ai-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ai-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.ai-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.ai-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.ai-info-box {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

.ai-error-box {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.ai-example-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 145px;
  overflow-y: auto;
}

.ai-example-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.ai-example-chip.checked {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ai-progress-box {
  text-align: center;
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ai-progress-title {
  font-size: 15px;
  font-weight: 700;
}

.ai-progress-scene {
  font-family: var(--font-script);
  font-size: 13px;
  color: var(--text-secondary);
}

.ai-progress-bar {
  width: 100%;
  max-width: 420px;
  height: 8px;
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.ai-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #3b82f6);
  transition: width 0.25s ease;
}

.ai-progress-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.ai-review-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}

.ai-review-bar-btns {
  display: flex;
  gap: 6px;
}

.ai-review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-review-scene-group {
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}

.ai-review-scene-head {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-review-items {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-sug-row {
  display: grid;
  grid-template-columns: 20px 155px 1fr minmax(0, 180px);
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.ai-sug-row.unchecked {
  opacity: 0.42;
}

.ai-sug-cat,
.ai-sug-name {
  background: var(--bg-root);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 12px;
  font-family: inherit;
  width: 100%;
}

.ai-sug-quote {
  font-family: var(--font-script);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== TUTORIAL MODAL ==================== */
.tutorial-modal-card {
  max-width: 680px;
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tutorial-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.tutorial-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.tutorial-step-content h4 {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--text-primary);
}

.tutorial-step-content p {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tutorial-step-content code {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-script);
  font-size: 11.5px;
  color: #93c5fd;
}

.tutorial-tip {
  font-size: 11.5px;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 6px;
  padding: 6px 9px;
}

/* ==================== PRINT STYLES (PDF EXPORT) ==================== */
@media print {
  body,
  #app-shell,
  .app-main {
    background: #fff !important;
    color: #000 !important;
    height: auto !important;
    overflow: visible !important;
  }

  .app-header,
  .stripboard-toolbar,
  .sb-legend-bar,
  .boneyard-section,
  .sb-inspector,
  .dood-actions,
  .strip-actions,
  .drag-handle,
  .daybreak-del,
  .scene-nav-pane,
  .script-toolbar,
  #toast-container {
    display: none !important;
  }

  .sb-board-column,
  .dood-shell,
  .elements-shell {
    overflow: visible !important;
    padding: 0 !important;
  }

  .strip-row {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    break-inside: avoid;
    border: 1px solid #cbd5e1 !important;
  }

  .dood-table th,
  .dood-table td {
    color: #000 !important;
    background: #fff !important;
    border: 1px solid #94a3b8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .dood-code {
    color: #000 !important;
  }

  .breakdown-layout {
    grid-template-columns: 1fr 300px !important;
  }

  .screenplay-page {
    box-shadow: none !important;
    padding: 12px !important;
  }
}

/* Responsive fallback for narrower windows */
@media (max-width: 1120px) {
  .breakdown-layout {
    grid-template-columns: 220px 1fr 310px;
  }
  .brand-sub {
    display: none;
  }
}
