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

:root {
  --bg: #f5f5f7; --surface: #ffffff; --border: #e2e2e5; --border-hover: #d0d0d5;
  --text: #1d1d1f; --text-dim: #6e6e73; --text-muted: #aeaeb2;
  --accent: #3a3aff; --accent-dim: #2c2cd6; --accent-bg: #eeeeff;
  --green: #34c759; --green-bg: #eafbef; --red: #ff3b30; --red-bg: #ffeeed;
  --yellow: #ff9f0a; --yellow-bg: #fff7e6;
  --radius: 10px; --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Header */
header { display: flex; align-items: flex-start; justify-content: space-between; padding: 16px 0; margin-bottom: 28px; gap: 24px; }
.brand { display: flex; align-items: flex-start; }
.brand-logo { width: min(280px, 38vw); line-height: 0; flex-shrink: 0; }
.brand-logo img { width: 100%; height: auto; display: block; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.session-id-badge { font-size: 11px; font-family: 'SF Mono', 'Cascadia Code', monospace; background: var(--accent-bg); color: var(--accent); padding: 4px 10px; border-radius: 6px; font-weight: 500; cursor: pointer; user-select: all; }
.session-id-badge:hover { background: var(--accent); color: #fff; }

select, input, textarea, button { font-family: var(--font); font-size: 14px; }
textarea { resize: vertical; }

.hidden { display: none !important; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; color: var(--text-dim); margin-bottom: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.form-group textarea, .form-group input[type="number"], .form-group input[type="text"] { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 12px 14px; border-radius: var(--radius); transition: border-color 0.15s; }
.form-group textarea:focus, .form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,58,255,0.1); }
.form-group textarea { min-height: 60px; }
.form-group .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.inline-row { display: flex; gap: 24px; align-items: flex-start; }
.inline-row .form-group { margin-bottom: 0; }
.inline-row input[type="number"] { width: 80px; }
.model-selector { min-width: 360px; flex: 1; }
.model-selector select { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 12px 14px; border-radius: var(--radius); transition: border-color 0.15s; }
.model-selector select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,58,255,0.1); }
.toggle-row { display: flex !important; align-items: center; gap: 10px; margin-top: 10px; color: var(--text); font-size: 13px; font-weight: 600; text-transform: none !important; letter-spacing: 0 !important; cursor: pointer; }
.toggle-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Language selector */
.lang-selector { margin-bottom: 16px; }
.lang-btns { display: flex; gap: 4px; margin-top: 6px; }
.lang-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); padding: 7px 16px; border-radius: var(--radius); cursor: pointer; font-weight: 500; font-size: 13px; transition: all 0.15s; }
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
.lang-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* Dropzone */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--text-muted); cursor: pointer; transition: all 0.2s; font-size: 13px; }
.dropzone:hover { border-color: var(--accent); color: var(--text-dim); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.dropzone-small { padding: 16px; font-size: 12px; }

.ref-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ref-thumb { position: relative; width: 80px; height: 80px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-thumb .remove { position: absolute; top: 2px; right: 2px; background: rgba(255,255,255,0.9); border: none; color: var(--red); cursor: pointer; font-size: 14px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* Buttons */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 14px 24px; border-radius: var(--radius); cursor: pointer; font-weight: 700; font-size: 15px; width: 100%; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 7px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.15s; }
.btn-small:hover { border-color: var(--accent); color: var(--accent); }

#session-select { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 7px 12px; border-radius: var(--radius); max-width: 300px; font-size: 13px; }

@media (max-width: 900px) {
  header { flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: flex-start; flex-wrap: wrap; }
  .brand-logo { width: min(240px, 60vw); }
}

/* Step trail */
.step-trail { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; }
.step-trail li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-radius: var(--radius); border-left: 3px solid var(--border); box-shadow: var(--shadow-sm); }
.step-trail li[data-status="running"] { border-left-color: var(--accent); background: var(--accent-bg); }
.step-trail li[data-status="done"] { border-left-color: var(--green); }
.step-trail li[data-status="awaiting_approval"] { border-left-color: var(--yellow); background: var(--yellow-bg); }
.step-trail li[data-status="error"] { border-left-color: var(--red); background: var(--red-bg); }
.step-name { flex: 1; font-weight: 500; }
.step-status { font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.3px; }
li[data-status="running"] .step-status { color: var(--accent); }
li[data-status="done"] .step-status { color: var(--green); }
li[data-status="awaiting_approval"] .step-status { color: var(--yellow); }

/* Logs */
.log-area { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; max-height: 300px; overflow-y: auto; font-size: 12px; color: var(--text-dim); font-family: 'SF Mono', 'Cascadia Code', monospace; box-shadow: var(--shadow-sm); }
.log-area div { margin-bottom: 2px; white-space: pre-wrap; word-break: break-word; }

/* Error banner */
.error-banner { background: var(--red-bg); border: 1px solid rgba(255,59,48,0.28); color: var(--red); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.error-banner-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.error-banner-message { font-size: 13px; line-height: 1.5; }

/* Gate */
.gate { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-top: 20px; box-shadow: var(--shadow-md); }
.gate-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.gate-subtitle { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }
.gate-stats { font-size: 13px; margin-bottom: 14px; }
.gate-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin: 12px 0 4px; border-top: 1px solid var(--border); padding-top: 8px; font-weight: 600; }
.gate-actions { margin-top: 20px; }

.ref-upload-inline { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }

/* Angle tabs */
.angle-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.angle-tab { background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); padding: 7px 16px; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 500; transition: all 0.15s; }
.angle-tab:hover { border-color: var(--accent); color: var(--accent); }
.angle-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.angle-tab .count { font-size: 10px; opacity: 0.7; }

/* Brief cards */
.brief-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 8px; transition: border-color 0.15s; }
.brief-card[data-decision="approved"] { border-color: var(--green); background: var(--green-bg); }
.brief-card[data-decision="rejected"] { border-color: var(--red); background: var(--red-bg); }
.brief-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.brief-id { font-size: 12px; color: var(--accent); font-weight: 600; }
.brief-hook { font-size: 11px; padding: 3px 8px; background: var(--accent-bg); color: var(--accent); border-radius: 4px; font-weight: 500; }
.brief-style { font-size: 11px; padding: 3px 8px; background: #f0f0ff; border-radius: 4px; color: #6b6bff; font-weight: 500; }
.brief-concept { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.brief-rationale { font-size: 12px; color: var(--text); margin-bottom: 10px; }

.brief-text-overlay { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.brief-text-overlay-compact { margin-bottom: 12px; }
.brief-text-overlay .headline { font-weight: 700; font-size: 14px; }
.brief-text-overlay .subheadline { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.brief-text-overlay .subheadline-empty { color: var(--text-muted); font-style: italic; }

.brief-spec-grid, .creative-spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-bottom: 10px; }
.brief-spec, .creative-spec { background: rgba(255,255,255,0.65); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.brief-spec .label, .creative-spec .label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 3px; font-weight: 700; }
.brief-spec .value, .creative-spec .value { display: block; font-size: 12px; color: var(--text); line-height: 1.45; }

.brief-prompt-block, .creative-prompt-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.brief-prompt-block summary, .creative-prompt-block summary { cursor: pointer; padding: 10px 12px; font-size: 12px; font-weight: 700; color: var(--text-dim); list-style: none; }
.brief-prompt-block summary::-webkit-details-marker, .creative-prompt-block summary::-webkit-details-marker { display: none; }
.brief-prompt-caption { padding: 0 12px 8px; font-size: 11px; color: var(--text-muted); }
.brief-prompt-text, .creative-prompt-text { padding: 0 12px 12px; font-size: 12px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }

.feedback-editor { margin-bottom: 10px; }
.feedback-editor-row { display: flex; gap: 8px; margin-bottom: 8px; }
.feedback-kind-select { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 12px; }
.feedback-kind-select:focus, .feedback-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,58,255,0.08); }
.feedback-input { width: 100%; min-height: 72px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 12px; line-height: 1.5; resize: vertical; }

.brief-actions { display: flex; gap: 8px; }
.btn-approve, .btn-reject { padding: 8px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.btn-approve:hover, .btn-approve.active { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.btn-reject:hover, .btn-reject.active { background: var(--red-bg); border-color: var(--red); color: var(--red); }

/* Results */
.results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.results-model { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model-chip { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.model-id { font-size: 12px; color: var(--text-dim); font-family: 'SF Mono', 'Cascadia Code', monospace; }
.results-stats { font-size: 13px; }
.export-actions { display: flex; gap: 8px; }

.verdict-filters { display: flex; gap: 4px; margin-bottom: 16px; }
.filter-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); padding: 7px 16px; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 500; transition: all 0.15s; }
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* Creative grid */
.creative-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.creative-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s; }
.creative-card:hover { box-shadow: var(--shadow-md); }
.creative-card.verdict-pass { border-color: var(--green); }
.creative-card.verdict-weak { border-color: var(--yellow); }
.creative-card.verdict-kill { border-color: var(--red); opacity: 0.6; }
.creative-card.verdict-rework { border-color: var(--red); }

.creative-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--bg); }
.creative-img-placeholder { width: 100%; aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; background: var(--bg); color: var(--text-muted); font-size: 13px; }

.creative-info { padding: 14px; }
.creative-info .brief-id { margin-bottom: 4px; }
.creative-info .headline { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.creative-info .subheadline { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.creative-info .meta { font-size: 12px; color: var(--text-dim); }

.verdict-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 4px; text-transform: uppercase; }
.verdict-badge.pass { background: var(--green-bg); color: var(--green); }
.verdict-badge.weak { background: var(--yellow-bg); color: var(--yellow); }
.verdict-badge.kill { background: var(--red-bg); color: var(--red); }
.verdict-badge.rework { background: var(--red-bg); color: var(--red); }

.mike-reason { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.mike-fix { font-size: 12px; color: var(--yellow); margin-top: 4px; }
.mike-panel { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); }
.mike-summary { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.mike-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.mike-row:first-child { margin-top: 0; }
.mike-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); font-weight: 700; }
.mike-value { font-size: 11px; font-weight: 700; color: var(--text); }
.creative-extra-block { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.creative-extra-block summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-dim); list-style: none; }
.creative-extra-block summary::-webkit-details-marker { display: none; }

.creative-card-actions { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 14px; }
.creative-card-actions .btn-small { width: 100%; text-align: center; }
.feedback-kind-select-result { margin-top: 2px; }
.feedback-input-result { min-height: 84px; }
.regen-chat-input { min-height: 96px; }
