/* ── Reset & tokens (shared with main app) ────────────────────────────────── */

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

:root {
  --bg:          #0f1117;
  --bg-2:        #171b26;
  --bg-3:        #1e2235;
  --bg-4:        #252a40;
  --border:      #2c3150;
  --text:        #e2e6f3;
  --text-muted:  #7a82a0;
  --text-dim:    #4a5070;
  --accent:      #5b7cf8;
  --accent-dim:  #3a52c0;
  --success:     #34d399;
  --warn:        #fbbf24;
  --danger:      #f87171;

  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "Fira Code", Consolas, monospace;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

#sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-title { font-size: 18px; font-weight: 700; }
.app-sub   { font-size: 11px; color: var(--text-muted); margin: 2px 0 12px;
             letter-spacing: .04em; text-transform: uppercase; }

#session-list { overflow-y: auto; flex: 1; padding: 8px 0; }

.empty-state  { color: var(--text-muted); padding: 24px 16px; font-size: 13px; }
.hidden       { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .12s, opacity .12s;
  white-space: nowrap;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dim); }
.btn-ghost    { background: var(--bg-4); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-3); }
.btn-full     { width: 100%; }
.btn-sm       { padding: 4px 10px; font-size: 12px; }

/* ── Welcome ─────────────────────────────────────────────────────────────── */

#main { display: flex; flex-direction: column; overflow: hidden; }

.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
}
.welcome-inner h2 { font-size: 20px; color: var(--text-dim); margin-bottom: 8px; }
.welcome-inner p  { font-size: 13px; max-width: 360px; line-height: 1.7; }

/* ── Chat pane ───────────────────────────────────────────────────────────── */

.chat-pane {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message            { display: flex; }
.message-user       { justify-content: flex-end; }
.message-assistant  { justify-content: flex-start; }

.message-body {
  display: flex;
  flex-direction: column;
  max-width: 68%;
}
.message-user .message-body      { align-items: flex-end; }
.message-assistant .message-body { align-items: flex-start; }

.msg-speaker {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
  user-select: text;
}

.message-bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.message-user .message-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message-assistant .message-bubble {
  background: var(--bg-3);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.message-bubble.typing { color: var(--text-muted); font-style: italic; }

/* ── Gate bar ────────────────────────────────────────────────────────────── */

.gate-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 28px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.gate-status        { font-size: 12px; color: var(--text-muted); margin-left: 4px; }
.gate-ready         { color: var(--success); }
.gate-partial       { color: var(--warn); }

/* ── Input bar ───────────────────────────────────────────────────────────── */

.input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 28px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 14px;
  resize: none;
  outline: none;
  line-height: 1.5;
}
.chat-input:focus { border-color: var(--accent); }

/* ── Artifact cards ──────────────────────────────────────────────────────── */

.artifact {
  width: 100%;
  flex-shrink: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 4px 0;
  overflow: hidden;
}

.artifact-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
}

.artifact-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: var(--text-muted);
}

.artifact-id {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-dim);
}

.artifact-parent {
  font-size: 10px;
  color: var(--text-dim);
}

.artifact-header .btn {
  margin-left: auto;
}

.artifact-body {
  padding: 14px 16px;
}

.artifact-summary .artifact-type    { color: var(--success); }
.artifact-options .artifact-type    { color: var(--accent); }
.artifact-export  .artifact-type    { color: var(--warn); }
.artifact-export-yt .artifact-type  { color: #f87171; }

.pipeline-btn { margin-top: 10px; }
.pipeline-status { display: inline-block; margin-left: 10px; font-size: 12px; color: var(--text-muted); }
.pipeline-status-running { color: var(--accent); }
.pipeline-status-ok      { color: var(--success); }
.pipeline-status-error   { color: #f87171; }
.pipeline-video-player { margin-top: 12px; }
.pipeline-video-thumb { position: relative; display: inline-block; border-radius: 6px; overflow: hidden; line-height: 0; }
.pipeline-video-preview { width: 240px; height: 135px; object-fit: cover; display: block; background: #000; border-radius: 6px; }
.pipeline-video-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff; text-shadow: 0 0 8px rgba(0,0,0,.8); pointer-events: none; }
.pipeline-video-actions { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.pipeline-video-download { font-size: 12px; color: var(--accent); text-decoration: none; }
.pipeline-video-download:hover { text-decoration: underline; }
.vb-editor-link { font-size: 12px; color: var(--success); text-decoration: none; font-weight: 500; }
.vb-editor-link:hover { text-decoration: underline; }
.yt-publish-row { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.yt-publish-status { font-size: 12px; }
.yt-status-running  { color: var(--accent); }
.yt-status-ok       { color: var(--success); }
.yt-status-error    { color: #f87171; }
.yt-status-published { color: var(--success); font-weight: 600; }
.btn-yt-confirm { background: #dc2626 !important; }

.export-path {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-4);
  padding: 1px 5px;
  border-radius: 4px;
}

.summary-direction {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.5;
}

.summary-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-weight: 600;
  margin: 10px 0 4px;
}

.summary-list {
  list-style: disc;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.summary-list.missing { color: var(--text-dim); }

.summary-updated-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 4px;
  padding: 1px 6px;
}

.summary-reset-notice {
  font-size: 11px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 10px;
}

.summary-changelog {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

/* ── Summary: new production-aware fields ─────────────────────────────────── */

.artifact-summary-legacy {
  border-color: color-mix(in srgb, var(--warn) 30%, var(--border));
}

.summary-schema-notice {
  font-size: 11px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 10px;
}

.summary-format-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
}

.summary-format-id {
  font-size: 11px;
  font-family: var(--mono);
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--text-muted);
}

.summary-format-fit {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 7px;
}
.summary-fit-fit     { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }
.summary-fit-partial { color: var(--warn);    background: color-mix(in srgb, var(--warn)    12%, transparent); border: 1px solid color-mix(in srgb, var(--warn)    30%, transparent); }
.summary-fit-reject  { color: var(--danger);  background: color-mix(in srgb, var(--danger)  12%, transparent); border: 1px solid color-mix(in srgb, var(--danger)  30%, transparent); }
.summary-fit-unknown { color: var(--text-dim); background: var(--bg-4); border: 1px solid var(--border); }

.summary-meta-chip {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
}

.summary-cta-chip {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.palette-entry {
  display: flex;
  align-items: center;
  gap: 5px;
}

.palette-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.15);
  flex-shrink: 0;
  display: inline-block;
}

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

.summary-handoff {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--bg-3);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
}

.summary-seed {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 6px;
}

.summary-visual-style {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 6px;
}

.summary-options-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.summary-options-old {
  opacity: 0.7;
}

/* ── Options grid (inside artifact-body) ─────────────────────────────────── */

.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.option-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.option-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  font-weight: 600;
}
.option-text  { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.option-chars { font-size: 11px; color: var(--text-muted); }
.option-why   { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.option-hypotheses {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.media-suggestions {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.media-suggestion-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.media-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  font-weight: 600;
}
.media-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── YAML block (inside export artifact) ─────────────────────────────────── */

.yaml-block {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  max-height: 260px;
  overflow-y: auto;
}
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.5;
}
.field-hint code {
  font-family: var(--mono);
  background: var(--bg-4);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

/* ── Session list items ──────────────────────────────────────────────────── */

.session-item {
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-item:hover  { background: var(--bg-3); }
.session-item.active { background: var(--bg-3); border-left-color: var(--accent); }
.session-item-body { flex: 1; min-width: 0; }
.session-item-id   { font-weight: 600; font-size: 13px; font-family: var(--mono); }
.session-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.session-del-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 3px;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.session-item:hover .session-del-btn { opacity: 1; }
.session-del-btn:hover { color: #ef4444; }

/* ── Campaign option extras ──────────────────────────────────────────────── */

.option-angle {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
}
.option-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 4px;
}

/* ── YouTube storyboard block ─────────────────────────────────────────────── */

.yt-block {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.yt-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #f87171;
  font-weight: 600;
}
.yt-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.yt-hook-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.yt-hook-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
  padding-top: 2px;
}
.yt-hook-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.storyboard-details { margin-top: 2px; }
.storyboard-summary {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding: 3px 0;
}
.storyboard-summary::-webkit-details-marker { display: none; }
.storyboard-summary::before { content: '+ '; }
details[open] .storyboard-summary::before { content: '- '; }
.storyboard-scroll {
  overflow-x: auto;
  margin-top: 6px;
}
.storyboard-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 11px;
  color: var(--text-muted);
}
.storyboard-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding: 3px 6px 4px 0;
  white-space: nowrap;
}
.storyboard-table td {
  padding: 3px 6px 3px 0;
  vertical-align: top;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  line-height: 1.4;
}
.sb-slot     { color: var(--text-dim); width: 24px; font-family: var(--mono); }
.sb-type     { white-space: nowrap; color: var(--accent); }
.sb-visual   { min-width: 120px; }
.sb-asset    { min-width: 100px; }
.sb-text     { min-width: 80px; color: var(--text-muted); }
.sb-duration { min-width: 52px; font-family: var(--mono); font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.yt-format-badge {
  display: inline-block;
  font-size: 9px;
  font-family: var(--mono);
  text-transform: none;
  letter-spacing: .03em;
  font-weight: 500;
  color: var(--accent-dim);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Export outcome form ─────────────────────────────────────────────────── */

.export-outcome {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.outcome-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  font-weight: 600;
}
.outcome-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.outcome-input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font);
  width: 100%;
  outline: none;
}
.outcome-input:focus { border-color: var(--accent); }
.outcome-textarea { resize: vertical; min-height: 52px; }
.outcome-save-status { font-size: 11px; color: var(--success); }

/* ── Logo upload (chat-inline) ─────────────────────────────────────────── */
.logo-upload-action {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.logo-upload-btn {
  cursor: pointer;
  border-style: dashed;
}
.logo-upload-btn:hover { background: var(--bg-3); }
.logo-upload-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Logo asset card (post-upload confirmation) ────────────────────────── */
.logo-asset-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  max-width: 300px;
}
.logo-card-thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  flex-shrink: 0;
}
.logo-card-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}
.logo-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.logo-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logo-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Asset requirements panel (in summary) ─────────────────────────────── */
.asset-requirements {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.asset-req-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-top: 4px;
}
.asset-req-label {
  font-weight: 600;
  min-width: 36px;
  color: var(--text);
}
.asset-req-slots {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}
.asset-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.asset-badge-ok   { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.asset-badge-warn { background: rgba(251, 191, 36, 0.15);  color: var(--warn); }

/* ── Template choice buttons ─────────────────────────────────────────────── */
.template-choice {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.template-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 14px;
  gap: 2px;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.template-btn-hint {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
}
.template-btn-active {
  background: rgba(99, 179, 237, 0.15);
  border-color: rgba(99, 179, 237, 0.5);
  color: var(--accent, #63b3ed);
}
.summary-template-label {
  font-size: 11px;
  font-weight: 600;
  background: rgba(99, 179, 237, 0.15);
  color: var(--accent, #63b3ed);
  border-radius: 4px;
  padding: 2px 7px;
}
