:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-header: #FFFFFF;
  --ink: #000000;
  --ink-muted: #475569;
  --divider: #d1d5db;
  --accent: #3E53E9;
  --accent-soft: rgba(62, 83, 233, 0.1);
  --accent-ink: #FFFFFF;
  --danger: #ef4444;
  --success: #22c55e;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* Global Resets */
* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 0.9rem;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Typography */
h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
}

/* Top Navigation */
.top-nav {
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  height: 32px;
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

.brand-kicker {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 800;
}

.template-name-input {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  height: auto !important;
  font-size: 0.95rem !important;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-links a {
  text-decoration: none;
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.top-links a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Layout Grid */
.studio-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 332px;
  height: calc(100vh - 64px);
  background: #f1f5f9;
}

/* Rails */
.left-rail,
.right-rail {
  background: var(--surface);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}

.right-rail {
  border-right: none;
  border-left: 1px solid var(--divider);
}

.rail-section {
  padding: 26px 16px;
  border-bottom: 1px solid var(--divider);
}

.rail-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  margin-bottom: 18px;
}

/* Center Pane */
.center-pane {
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  overflow-y: auto;
}

/* AI Studio Panel */
.ai-studio-panel {
  background: #ffffff;
  border-bottom: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
}

.ai-studio-tabs {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 0 24px;
  border-bottom: 1px solid var(--divider);
  background: #ffffff;
}

.ai-tab {
  appearance: none;
  background: #ffffff !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #475569 !important;
  cursor: pointer;
  height: auto;
  border-radius: 0;
}

.ai-tab:hover {
  background: #f3f4f6 !important;
  color: #1f2937 !important;
}

.ai-tab.active {
  background: #ffffff !important;
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}

.ai-studio-content {
  padding: 28px 24px 30px;
}

.sora-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sora-prompt-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.sora-prompt-row textarea {
  flex: 1;
}

.sora-generate-btn {
  white-space: nowrap;
}

.preset-first-panel {
  padding: 0;
  background: #ffffff;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 2px;
}

.preset-first-head h2 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.preset-first-head p {
  font-size: 0.88rem;
  color: var(--ink-muted);
  margin: 6px 0 24px;
}

.ai-brief-panel {
  display: grid;
  gap: 20px;
}

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

.field span {
  font-size: 0.8rem;
  font-weight: 600;
}

input,
select,
textarea {
  background: #f8fafc;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--ink);
  outline: none;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--accent);
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
}

.preset-upload-panel {
  background: #f8fafc;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 16px 16px 18px;
}

.preset-upload-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 14px;
}

.preset-upload-actions {
  display: flex;
  gap: 8px;
}

.preset-upload-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.preset-upload-thumb {
  margin: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--divider);
  flex-shrink: 0;
  position: relative;
  background: #e2e8f0;
}

.preset-upload-thumb img,
.preset-upload-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preset-upload-empty {
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-align: center;
  flex: 1;
  padding: 12px;
}

.preset-media-library {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.preset-media-library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.preset-media-library-head > span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.preset-prompt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 2px;
}

/* Tab Navigation */
.work-tabs {
  display: flex;
  gap: 8px;
  background: #ffffff;
  border-bottom: 1px solid var(--divider);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.tab {
  appearance: none;
  background: #ffffff !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.88rem;
  color: #475569 !important;
  cursor: pointer;
  height: auto;
}

.tab:hover {
  background: #f3f4f6 !important;
  color: #1f2937 !important;
}

.tab.active {
  background: #ffffff !important;
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}

/* Preview Stage */
.preview-stage {
  width: 420px;
  height: 746px;
  background: #000000;
  margin: 40px auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.preview-note {
  text-align: center;
  padding: 14px 24px;
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  color: #92400e;
  font-size: 0.8rem;
  font-weight: 500;
}

.scene-tree {
  display: grid;
  gap: 10px;
}

.scene-controls {
  margin-top: 10px;
}

/* Sidebar Lists */
.scene-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scene-item-wrap {
  display: flex;
  flex-direction: column;
}

.scene-item {
  appearance: none;
  width: 100%;
  min-height: 34px;
  height: auto;
  background: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: #1e293b !important;
  text-align: left;
  box-shadow: none;
}

.scene-item:hover {
  background: #f1f5f9;
  color: #0f172a !important;
}

.scene-item.active {
  background: #dbe4ff;
  color: #1e293b !important;
  font-weight: 700;
}

.scene-caret {
  margin-right: 8px;
  font-family: monospace;
  opacity: 0.5;
}

.scene-delete-btn {
  opacity: 0;
  transition: opacity 0.2s;
}

.scene-item:hover .scene-delete-btn {
  opacity: 1;
}

.scene-elements-list {
  list-style: none;
  padding: 4px 0 4px 28px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scene-elements-nested li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.scene-element-label {
  appearance: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #475569 !important;
  cursor: pointer;
  height: auto;
}

.scene-element-label:hover {
  background: #f1f5f9;
  color: var(--ink) !important;
}

button.scene-element-remove,
button.scene-element-remove:hover,
button.scene-element-remove:focus,
button.scene-element-remove:active {
  width: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0;
  border: none !important;
  border-radius: 999px;
  background: transparent !important;
  color: #94a3b8 !important;
  -webkit-text-fill-color: #94a3b8 !important;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
  opacity: 0.85;
}

button.scene-element-remove:hover,
button.scene-element-remove:focus {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  -webkit-text-fill-color: #b91c1c !important;
  opacity: 1;
}

.add-element-link {
  appearance: none;
  background: none;
  border: 1px dashed var(--divider);
  color: var(--accent) !important;
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 8px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  height: auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.add-element-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent) !important;
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #FFFFFF !important;
}

button:hover {
  background: #2D41D6;
  border-color: #2D41D6;
  box-shadow: 0 4px 12px rgba(62, 83, 233, 0.25);
}

button:active {
  transform: scale(0.98);
}

button.secondary {
  background: #fff;
  border-color: var(--divider);
  color: var(--ink) !important;
}

button.secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

button.add-element-link,
button.add-element-link:hover,
button.add-element-link:focus,
button.add-element-link:active,
button.add-element-link:disabled {
  background: transparent !important;
  border: 1px dashed var(--divider) !important;
  color: var(--accent) !important;
  -webkit-text-fill-color: var(--accent) !important;
  opacity: 1 !important;
}

button.add-element-link:hover,
button.add-element-link:focus {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
}

button.add-element-link .add-element-link-label {
  color: var(--accent) !important;
  -webkit-text-fill-color: var(--accent) !important;
  opacity: 1 !important;
  font-weight: 600;
  line-height: 1.2;
}

button.tab,
button.tab:hover,
button.tab:focus,
button.tab:active {
  background: #ffffff !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  color: #475569 !important;
  -webkit-text-fill-color: currentColor !important;
  opacity: 1 !important;
}

button.tab:hover,
button.tab:focus {
  background: #f3f4f6 !important;
  color: #1f2937 !important;
}

button.tab.active,
button.tab.active:hover,
button.tab.active:focus {
  background: #ffffff !important;
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}

button.ai-tab,
button.ai-tab:hover,
button.ai-tab:focus,
button.ai-tab:active {
  background: #ffffff !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  color: #475569 !important;
  -webkit-text-fill-color: currentColor !important;
  opacity: 1 !important;
}

button.ai-tab:hover,
button.ai-tab:focus {
  background: #f3f4f6 !important;
  color: #1f2937 !important;
}

button.ai-tab.active,
button.ai-tab.active:hover,
button.ai-tab.active:focus {
  background: #ffffff !important;
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}

.icon-add-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0.9rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.file-selector {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
  border: 1px solid var(--divider);
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
}

.file-selector:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.file-selector input[type="file"] {
  display: none;
}

/* Inspector */
.card {
  padding: 26px 18px;
  border-bottom: 1px solid var(--divider);
}

.card h3 {
  font-size: 0.88rem;
  margin-bottom: 18px;
}

.inspector-form,
.form-grid,
.lookup-grid {
  display: grid;
  gap: 14px;
}

.field-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inspector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}

.inspector-form h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  margin: 8px 0 2px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop:not([hidden]) {
  display: flex;
}

.modal-shell {
  background: #ffffff;
  width: min(800px, 90%);
  max-height: 80vh;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--divider);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 24px;
}

.element-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.element-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #000000 !important;
  height: auto;
  min-height: 120px;
  transition: all 0.2s;
}

.element-card span {
  color: #000000 !important;
}

.element-card .element-icon {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.element-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.element-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent);
}

.element-description {
  background: #f8fafc;
  padding: 20px;
  border-radius: var(--radius-md);
  color: #000000 !important;
}

.element-description * {
  color: #000000 !important;
}

.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Status / JSON Views */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
}

.view.active {
  display: flex;
}

.json-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--divider);
}

.timeline-panel {
  display: grid;
  gap: 16px;
  padding: 0 24px 28px;
  background: #ffffff;
  border-top: 1px solid var(--divider);
}

.timeline-summary {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.timeline-controls {
  display: grid;
  gap: 8px;
}

.timeline-canvas,
.timelineCheckpoints,
.timeline-warnings {
  padding: 0;
}

.view {
  display: none;
  flex-direction: column;
}

.view.active {
  display: flex;
}

#recipeInput {
  display: block;
  width: 420px;
  height: 746px;
  margin: 20px auto;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 32px;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  line-height: 1.6;
  background: #ffffff;
  color: #0f172a;
  resize: none;
  outline: none;
}

.status-output {
  background: #0f172a;
  color: #94a3b8;
  padding: 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  min-height: 120px;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* Vertical Scene List specific restoration */
#sceneList li .scene-item {
  border-radius: 4px;
  margin: 2px 0;
  color: #1e293b !important;
}

#sceneList li .scene-item strong {
  font-weight: 500;
  color: inherit !important;
}

#sceneList li .scene-item.active,
#sceneList li .scene-item.active *,
#sceneList li .scene-item:hover,
#sceneList li .scene-item:hover * {
  color: inherit !important;
}

#sceneList li .scene-item,
#sceneList li .scene-item * {
  text-shadow: none !important;
  opacity: 1 !important;
}

#sceneList .scene-caret,
#sceneList .scene-delete-btn,
#sceneList .scene-item span {
  color: inherit !important;
}

#sceneList .scene-elements-list .scene-element-label {
  color: var(--ink-muted) !important;
}

#sceneList .scene-elements-list .scene-element-label:hover,
#sceneList .scene-elements-list li.active .scene-element-label {
  color: var(--ink) !important;
}

/* Footer Tip */
.footer {
  height: 32px;
  background: #f1f5f9;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.template-empty,
.inspector-empty,
.timeline-empty {
  font-size: 0.85rem;
  color: var(--ink-muted);
  background: var(--surface-header);
  border: 1px dashed var(--divider);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}

.save-template-button {
  width: 100%;
  margin-top: 8px;
}

#userTemplateList {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-template-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

button.saved-template-load {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
  color: #0f172a !important;
  border: 1px solid #d7dee8 !important;
  min-height: 64px;
  height: auto;
  justify-content: flex-start;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

button.saved-template-load:hover,
button.saved-template-load:focus {
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 100%) !important;
  border-color: #94a3b8 !important;
  transform: none;
}

button.saved-template-load .saved-template-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

button.saved-template-load strong,
button.saved-template-load small {
  color: inherit !important;
}

button.saved-template-load strong {
  display: block;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
}

button.saved-template-load small {
  display: block;
  font-size: 0.72rem;
  color: #64748b !important;
  letter-spacing: 0.01em;
}

button.saved-template-delete {
  min-width: 68px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  align-self: center;
}
/* Guided Builder */
.guided-builder-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
}

.builder-header {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--divider);
}

.builder-step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid var(--divider);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.step-dot.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  transform: scale(1.1);
}

.step-dot.completed {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--divider);
}

.step-dot.completed + .step-line,
.step-dot.active + .step-line {
  background: var(--accent);
}

#builderTitle {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

.builder-nav {
  display: flex;
  gap: 12px;
}

.builder-content {
  padding: 40px 32px;
  min-height: 400px;
}

.builder-step {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.builder-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 48px;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.format-card {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  height: 130px;
  color: var(--ink) !important;
  line-height: 1.4;
}

.format-card:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(62, 83, 233, 0.15);
}

.format-card.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.format-card strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.format-card small {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.builder-asset-selection {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.asset-actions-row {
  display: flex;
  gap: 12px;
}

.builder-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
  min-height: 80px;
}

.builder-thumb {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--divider);
  position: relative;
  transition: transform 0.2s ease;
}

.builder-thumb:hover {
  transform: scale(1.05);
}

.builder-thumb img,
.builder-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.builder-thumb .remove-thumb {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.9);
  color: var(--ink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--divider);
  padding: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.starter-templates-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--divider);
}

.starter-templates-section > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.template-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.template-chip {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: 99px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink) !important;
  cursor: pointer;
  height: auto;
  transition: all 0.2s ease;
}

.template-chip:hover {
  border-color: var(--accent);
  color: var(--accent) !important;
  background: var(--accent-soft);
}

.ai-brief-bar {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ai-magic-btn {
  background: var(--ink);
  color: #fff;
  border: none;
  width: auto;
  margin: 0 auto;
  padding: 0 32px;
  height: 44px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 99px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ai-magic-btn:hover {
  background: #1e293b;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.ai-status-text {
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-align: center;
  margin-top: 8px;
}

.storyboard-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.storyboard-item {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 24px;
  align-items: center;
  transition: border-color 0.2s ease;
}

.storyboard-item:hover {
  border-color: var(--accent);
}

.storyboard-preview {
  width: 160px;
  aspect-ratio: 16/9;
  background: #f1f5f9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--divider);
}

.storyboard-preview img,
.storyboard-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.storyboard-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.storyboard-details h4 {
  font-size: 0.95rem;
}

.storyboard-edit-fields {
  display: grid;
  gap: 8px;
}

.storyboard-edit-fields input,
.storyboard-edit-fields textarea {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.tiny-btn {
  height: 28px;
  font-size: 0.75rem;
  padding: 0 10px;
}

.empty-hint {
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
}
