:root {
  --bg: #ffffff;
  --surface: #fafbfc;
  --surface-2: #f4f6fa;
  --border: #e6e9f0;
  --border-strong: #cfd4df;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --accent: #a855f7;
  --accent-light: #f3e8ff;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Pretendard Variable", Pretendard, "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); }

.container { max-width: 1440px; margin: 0 auto; padding: 0 28px; }

/* ── HERO ────────────────────────────────────────────────────── */
.hero {
  padding: 48px 0 40px;
  background: linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; top: -240px; right: -180px;
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.14), transparent 70%);
  pointer-events: none;
}
.hero::after {
  content: ""; position: absolute; bottom: -260px; left: -120px;
  width: 540px; height: 540px;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.12), transparent 70%);
  pointer-events: none;
}
.hero-inner { position: relative; display: flex; flex-direction: column; gap: 22px; }
.hero-brand { display: flex; align-items: center; gap: 18px; }
.hero-logo {
  font-size: 44px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  width: 76px; height: 76px;
  display: grid; place-items: center;
  border-radius: 20px;
  color: white;
  box-shadow: 0 10px 28px rgba(79, 70, 229, 0.35);
}
.hero-title {
  font-size: 38px; font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.08;
}
.hero-title .grad {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-subtitle { font-size: 15px; color: var(--text-muted); margin-top: 6px; }
.hero-pillars { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 7px 14px;
  border-radius: 999px;
  background: white;
  color: var(--primary);
  font-size: 12px; font-weight: 600;
  border: 1px solid rgba(79, 70, 229, 0.22);
  box-shadow: var(--shadow-sm);
}

/* ── MAIN LAYOUT ─────────────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 32px;
  padding-top: 32px;
  padding-bottom: 56px;
}
@media (max-width: 1024px) {
  .main { grid-template-columns: 1fr; }
  .sidebar { position: static !important; max-height: none !important; }
}

.sidebar {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 20px; align-self: start;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding-right: 6px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.card, .card-flat {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-flat { padding: 20px 22px; }

.card-header { margin-bottom: 16px; }
.card-header h2 {
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text);
}
.card-header h2 small {
  font-size: 11px; color: var(--text-muted);
  font-weight: 500; text-transform: none; letter-spacing: 0;
  margin-left: auto;
}
.step {
  width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border-radius: 7px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28);
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 7px;
}
.field label small { font-weight: 400; color: var(--text-subtle); }
.field output {
  font-weight: 700; color: var(--primary);
  font-variant-numeric: tabular-nums;
}

select, input[type="text"], input[type="number"], textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: white; font: inherit; font-size: 14px; color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 48px; }
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
input[type="range"] { padding: 0; width: 100%; accent-color: var(--primary); }

.radio-group { display: flex; gap: 8px; }
.radio-chip { flex: 1; display: block; position: relative; cursor: pointer; }
.radio-chip input { position: absolute; opacity: 0; pointer-events: none; }
.radio-chip span {
  display: block; padding: 10px 12px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  transition: all 0.15s; background: white;
}
.radio-chip input:checked + span {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border-color: transparent;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.meta {
  font-size: 12px; color: var(--text-muted);
  margin-top: 10px; line-height: 1.55;
}

/* ── GREIMAS SQUARE ──────────────────────────────────────────── */
.greimas {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin: 12px 0 2px;
}
.g-cell {
  padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  min-height: 70px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.g-cell.g-s1 {
  border-color: rgba(79, 70, 229, 0.28);
  background: linear-gradient(135deg, var(--primary-light), #ffffff);
}
.g-cell.g-s2 {
  border-color: rgba(168, 85, 247, 0.28);
  background: linear-gradient(135deg, var(--accent-light), #ffffff);
}
.g-cell.g-ns1 { background: linear-gradient(135deg, #f8fafc, #ffffff); }
.g-cell.g-ns2 { background: linear-gradient(135deg, #f8fafc, #ffffff); }
.g-label {
  display: block; font-size: 10px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 5px;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.g-value {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text); line-height: 1.35;
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn-primary {
  width: 100%; padding: 13px 16px; margin-top: 8px;
  border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; font-weight: 700; font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.28);
  font-family: inherit;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.38);
}
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err {
  margin-top: 12px; padding: 10px 12px;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--danger); font-size: 13px; line-height: 1.5;
}

/* ── RESULTS ─────────────────────────────────────────────────── */
.results { display: flex; flex-direction: column; gap: 16px; }

/* Pipeline */
.pipeline-title {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 14px;
}
.pipeline-stages {
  display: flex; justify-content: space-between; align-items: center;
  position: relative;
}
.pipeline-stages::before {
  content: ""; position: absolute;
  top: 14px; left: 4%; right: 4%;
  height: 2px; background: var(--border);
  z-index: 0;
}
.stage {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 1; gap: 8px;
}
.stage-dot {
  width: 30px; height: 30px;
  background: white; border: 2px solid var(--border);
  border-radius: 50%; position: relative;
  transition: all 0.3s;
}
.stage-label {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.stage.active .stage-dot {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
  box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.18);
  animation: pulse 1.2s ease-in-out infinite;
}
.stage.done .stage-dot {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
}
.stage.done .stage-dot::after {
  content: "✓"; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: white; font-size: 14px; font-weight: 700;
}
.stage.active .stage-label, .stage.done .stage-label { color: var(--primary); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.18); }
  50%      { box-shadow: 0 0 0 11px rgba(79, 70, 229, 0.08); }
}

/* Empty state */
.empty {
  text-align: center; padding: 72px 28px;
  background: white;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.empty-icon { font-size: 60px; margin-bottom: 14px; }
.empty h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.empty p { color: var(--text-muted); font-size: 14px; line-height: 1.7; }

/* Summary bar */
.summary {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.summary-metric { display: flex; flex-direction: column; }
.summary-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.summary-value {
  font-size: 24px; font-weight: 800;
  color: var(--text); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.summary-value-sm { font-size: 15px; font-weight: 700; }

/* ── SEED CARD ───────────────────────────────────────────────── */
.seeds { display: flex; flex-direction: column; gap: 18px; }

.seed-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
  overflow: hidden;
  position: relative;
}
.seed-card::before {
  content: ""; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0; transition: opacity 0.2s;
}
.seed-card:hover {
  box-shadow: var(--shadow-md);
}
.seed-card:hover::before { opacity: 1; }

.seed-head {
  display: flex; align-items: flex-start; gap: 18px;
  margin-bottom: 16px;
}
.seed-rank-block { min-width: 54px; }
.seed-rank-label {
  font-size: 10px; color: var(--text-muted);
  text-transform: uppercase; font-weight: 700;
  letter-spacing: 0.06em; display: block; margin-bottom: 2px;
}
.seed-rank {
  font-size: 32px; font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em; line-height: 1;
}
.seed-info { flex: 1; min-width: 0; }
.seed-id {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px; color: var(--text-muted);
  background: var(--surface-2); padding: 4px 9px;
  border-radius: 5px; display: inline-block;
  margin-bottom: 9px;
}
.seed-rules { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px; font-weight: 600;
  padding: 4px 9px; border-radius: 5px;
  background: var(--accent-light); color: #7e22ce;
  border: 1px solid rgba(168, 85, 247, 0.28);
}

.final-gauge {
  width: 86px; height: 86px;
  position: relative; flex-shrink: 0;
}
.final-gauge svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.final-gauge-track { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.final-gauge-fill {
  fill: none; stroke-width: 8; stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-out;
}
.final-gauge-text {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
}
.final-gauge-value {
  font-size: 19px; font-weight: 800;
  color: var(--text); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.final-gauge-label {
  font-size: 9px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-top: 3px;
}

.seed-concept {
  font-size: 14.5px; line-height: 1.75;
  color: var(--text);
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--surface) 0%, #ffffff 100%);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 18px;
  word-break: keep-all;
}

.seed-section-title {
  font-size: 10.5px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 18px 0 10px;
}

/* ── TIMELINE ────────────────────────────────────────────────── */
.timeline {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.timeline-bar {
  height: 42px; display: flex;
  border-radius: 8px; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
.beat-seg {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 10px; overflow: hidden; white-space: nowrap;
  transition: filter 0.15s;
  cursor: default;
}
.beat-seg:hover { filter: brightness(0.94); }
.beat-seg-name {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.18);
  overflow: hidden; text-overflow: ellipsis;
}
.beat-seg-time {
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.88);
  font-family: "JetBrains Mono", monospace;
}
.timeline-scale {
  margin-top: 8px; position: relative; height: 20px;
}
.timeline-tick {
  position: absolute; top: 0;
  transform: translateX(-50%);
  font-size: 10px; color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
}
.timeline-tick::before {
  content: ""; display: block;
  width: 1px; height: 5px; background: var(--border-strong);
  margin: 0 auto 3px;
}

.beats-detail {
  margin-top: 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.beat-row {
  display: grid; grid-template-columns: 72px 130px 1fr;
  gap: 12px; padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  align-items: start; font-size: 12.5px;
}
.beat-row:last-child { border-bottom: 0; }
.beat-row-time {
  font-family: "JetBrains Mono", monospace;
  color: var(--text-muted); font-weight: 600;
  font-size: 11.5px;
}
.beat-row-name {
  font-weight: 700; color: var(--primary);
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.beat-row-content {
  color: var(--text);
  line-height: 1.55;
  white-space: pre-line;        /* preserve SHOT/ACTION/SOUND/DURATION line breaks */
  font-size: 12px;
  font-family: "JetBrains Mono", ui-monospace, "Pretendard Variable", sans-serif;
}
.beat-row-content::first-line { font-weight: 600; }

/* ── SCORES ──────────────────────────────────────────────────── */
.scores-section {
  display: grid; grid-template-columns: 220px 1fr;
  gap: 22px; margin-top: 16px; padding-top: 18px;
  border-top: 1px solid var(--border);
}
.radar-wrap { position: relative; height: 220px; }
.scores-table {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; align-content: start;
}
.score-item {
  padding: 9px 12px; background: var(--surface); border-radius: 7px;
  display: flex; justify-content: space-between; align-items: center;
}
.score-item-label {
  font-size: 10.5px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.score-item-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 13.5px; font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── PRODUCT PROMPT ─────────────────────────────────────────── */
#productPrompt {
  font-family: inherit;
  min-height: 86px;
  line-height: 1.55;
}
#productPrompt::placeholder {
  color: var(--text-subtle);
  font-size: 12.5px;
  line-height: 1.6;
}
.product-presets,
.tension-presets,
.persona-presets {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px;
}
.tension-preview {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.preset-chip-inline {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.preset-chip-inline:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-1px);
}
.product-status {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.status-idle    { background: var(--text-subtle); }
.status-dot.status-loading { background: var(--warn); animation: pulse-dot 1.2s ease-in-out infinite; }
.status-dot.status-ready   { background: var(--success); }
.status-dot.status-error   { background: var(--danger); }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
.status-text { color: var(--text); line-height: 1.45; }
.status-text strong { color: var(--primary); }

/* ── MODAL ──────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: grid; place-items: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative;
  width: 100%; max-width: 640px;
  max-height: 90vh;
  background: white;
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: popIn 0.2s cubic-bezier(0.22, 1.2, 0.36, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn  { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.modal-head h3 {
  flex: 1;
  font-size: 17px; font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.modal-head h3 small {
  display: block; margin-top: 4px;
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
}
.modal-x {
  width: 32px; height: 32px;
  border: none; background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px; color: var(--text-muted);
  transition: all 0.15s;
}
.modal-x:hover { background: var(--surface-2); color: var(--danger); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-foot .btn-primary { width: auto; min-width: 200px; margin-top: 0; }

.form-row {
  display: grid; grid-template-columns: 1fr 140px; gap: 12px;
}
@media (max-width: 540px) {
  .form-row { grid-template-columns: 1fr; }
}

/* parts list inside modal */
.parts-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 8px;
}
.part-row {
  display: grid; grid-template-columns: 140px 1fr 32px; gap: 8px;
  align-items: center;
}
.part-row input {
  padding: 8px 10px; font-size: 13px;
}
.part-row .part-del {
  width: 32px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text-muted); font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.part-row .part-del:hover {
  border-color: var(--danger); color: var(--danger);
  background: #fef2f2;
}

.btn-ghost {
  padding: 9px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: white; color: var(--text-muted);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-ghost:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-light);
  border-style: solid;
}

/* presets */
.preset-details {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--surface);
}
.preset-details summary {
  cursor: pointer; font-weight: 600;
  color: var(--text); font-size: 13px;
}
.preset-details[open] summary { margin-bottom: 10px; color: var(--primary); }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.preset-chip {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white; color: var(--text);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-family: inherit;
}
.preset-chip:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* wow anchor badge on seed cards */
.seed-anchor {
  margin: 8px 0 14px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
  border-radius: 7px;
  font-size: 12px; line-height: 1.5;
  color: #78350f;
}
.seed-anchor::before {
  content: "⚡ 와우 앵커: ";
  font-weight: 700; color: #92400e;
}

/* Creative constraints — the 6 hard imperatives injected per seed */
.constraints {
  margin: 10px 0 16px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  border: 1px solid #86efac;
  border-radius: 10px;
}
.constraints-head {
  font-size: 11px; font-weight: 700;
  color: #14532d;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.constraints-head small {
  font-weight: 500; color: var(--text-muted);
  letter-spacing: 0; text-transform: none;
}
.constraints-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
}
.constraint-chip {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 10px;
  background: white;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
}
.constraint-key {
  font-weight: 700; color: #166534;
  flex-shrink: 0;
  min-width: 72px;
}
.constraint-val {
  color: var(--text); font-weight: 500;
}

/* ── BEAT MEDIA (fal.ai images + videos) ─────────────────────── */
.beat-row {
  /* override: add 4th column for media slot */
  grid-template-columns: 72px 130px 1fr 200px !important;
}
.beat-media {
  display: flex; flex-direction: column; gap: 6px;
  align-items: stretch;
  min-width: 0;
}
.media-status {
  font-size: 10.5px; font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  line-height: 1.4;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
}
.media-idle      { color: var(--text-subtle); }
.media-loading   { color: #b45309; background: #fef3c7; border-color: #fcd34d; border-style: solid;
                   animation: mediaPulse 1.8s ease-in-out infinite; }
.media-error-msg { color: var(--danger); background: #fef2f2; border-color: #fecaca; border-style: solid; }
@keyframes mediaPulse { 0%,100% {opacity:1;} 50% {opacity:0.65;} }

.media-thumb {
  position: relative;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f172a;
}
.media-thumb img,
.media-thumb video {
  display: block; width: 100%; height: auto;
  max-height: 140px; object-fit: cover;
  background: #0f172a;
}
.media-download {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  background: rgba(255,255,255,0.88);
  border-radius: 4px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: var(--primary); text-decoration: none;
  transition: all 0.15s;
}
.media-download:hover { background: white; transform: scale(1.1); }

.media-controls {
  display: flex; flex-direction: column; gap: 4px;
}
.btn-media {
  padding: 5px 8px;
  font-size: 10.5px; font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white; color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-align: left;
}
.btn-media:hover:not(:disabled) {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-light);
}
.btn-media:disabled {
  opacity: 0.5; cursor: not-allowed;
}

@media (max-width: 820px) {
  .beat-row { grid-template-columns: 70px 1fr !important; }
  .beat-row-name    { grid-column: 2; }
  .beat-row-content { grid-column: 1 / 3; padding-top: 2px; }
  .beat-media       { grid-column: 1 / 3; }
}

/* ── FINAL STITCH (combine all beat videos) ──────────────────── */
.final-stitch {
  margin: 6px 0 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 100%);
  border: 1px solid #c4b5fd;
  border-radius: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.stitch-progress {
  font-size: 12px; color: var(--text-muted);
}
.btn-stitch {
  align-self: flex-start;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.btn-stitch:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}
.btn-stitch:disabled {
  opacity: 0.5; cursor: not-allowed;
  background: var(--surface-2); color: var(--text-subtle);
  box-shadow: none;
}
.stitch-thumb { max-width: 100%; }
.stitch-thumb video {
  width: 100%; max-height: 360px; height: auto;
  object-fit: contain;
  background: #0f172a;
}
.stitch-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.btn-stitch-download {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--success);
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px; font-weight: 700;
  font-family: inherit;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.28);
  transition: all 0.15s;
}
.btn-stitch-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(16, 185, 129, 0.4);
}

/* Per-beat regen download button — replaces the old ↗ open icon */
.media-download {
  /* upgrade existing style: now a download (proxy) anchor */
  font-weight: 800;
}

/* AETHER 5-generator metacognitive provenance (compact one-liner) */
.aether-provenance {
  margin-top: 14px;
  padding: 8px 12px;
  background: linear-gradient(90deg, #f5f3ff 0%, #ffffff 100%);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted); line-height: 1.5;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.02em;
}

/* Tournament winner panel — LLM judge picks structurally most emergent */
.tournament {
  margin: 12px 0 14px;
  padding: 12px 14px;
  border: 1px solid #facc15;
  border-left: 3px solid #ca8a04;
  background: linear-gradient(180deg, #fffce8 0%, #ffffff 100%);
  border-radius: var(--radius-sm);
  display: grid; gap: 8px;
}
.tournament-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
}
.tournament-badge {
  font-weight: 800;
  color: #854d0e;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.02em;
  background: #fef9c3;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #facc15;
}
.tournament-label {
  color: var(--text-muted);
  font-size: 12px;
}
.tournament-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  font-size: 12.5px;
  line-height: 1.55;
}
.tournament-key {
  font-weight: 700;
  color: #854d0e;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tournament-val { color: var(--text); word-break: keep-all; }
.tournament-val-invention {
  font-weight: 600;
  color: #1f2937;
  font-style: italic;
}
.tournament-val-muted { color: var(--text-muted); }

/* AETHER 5-element metacognitive critique panel */
.critique {
  margin-top: 12px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid #6366f1;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fafaff 0%, #ffffff 100%);
  padding: 0;
  overflow: hidden;
}
.critique[open] { box-shadow: 0 1px 3px rgba(99,102,241,0.08); }
.critique-summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 700;
  color: #4338ca;
  letter-spacing: 0.01em;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  user-select: none;
}
.critique-summary::-webkit-details-marker { display: none; }
.critique-summary::after {
  content: "▾";
  font-size: 11px; color: var(--text-muted);
  transition: transform 0.18s;
}
.critique[open] .critique-summary::after { transform: rotate(180deg); }
.critique-verdict {
  font-size: 10.5px; font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  font-family: "JetBrains Mono", monospace;
}
.critique-verdict-pass {
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
}
.critique-verdict-revise {
  background: #fef3c7; color: #b45309; border: 1px solid #fcd34d;
}
.critique-body {
  padding: 4px 14px 14px;
  border-top: 1px dashed var(--border);
}
.critique-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.critique-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 7px 10px;
  background: #ffffff;
  border: 1px solid #f1f5ff;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.55;
}
.critique-key {
  font-weight: 700;
  color: #4338ca;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.critique-val {
  color: var(--text);
  word-break: keep-all;
}
.critique-brief {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  display: grid; gap: 4px;
}
.critique-brief-label {
  font-size: 10.5px; font-weight: 700;
  color: #92400e;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.critique-brief-text {
  font-size: 12.5px;
  color: #78350f;
  line-height: 1.6;
}

/* Raw model output (collapsible reference) */
.raw-details {
  margin-top: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fbfbfd;
  padding: 10px 14px;
}
.raw-details summary {
  cursor: pointer; font-weight: 600;
  color: var(--text-muted); font-size: 12px;
  letter-spacing: 0.02em;
  user-select: none;
}
.raw-details[open] summary { margin-bottom: 10px; color: var(--primary); }
.raw-body {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0;
}

/* ── OHAENG (5-element) STORY SPINE ─────────────────────────── */
.scene-summary {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #fefce8 0%, #fff7ed 100%);
  border-left: 4px solid #f59e0b;
  border-radius: 0 10px 10px 0;
}
.scene-summary-badge {
  font-size: 11px; font-weight: 700;
  color: #92400e; letter-spacing: 0.08em;
  text-transform: uppercase; flex-shrink: 0;
}
.scene-summary-text {
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.02em;
  color: #78350f; line-height: 1.3;
}

/* Ohaeng flow diagram above timeline */
.ohaeng-flow {
  display: flex; align-items: center; gap: 2px;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.ohaeng-node {
  display: inline-flex; flex-direction: column; align-items: center;
  min-width: 56px;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 11px; font-weight: 600;
  background: white;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.ohaeng-node-emoji { font-size: 20px; line-height: 1; margin-bottom: 2px; }
.ohaeng-node-kr    { font-size: 10px; font-weight: 700; color: var(--text); font-family: "JetBrains Mono", monospace; }
.ohaeng-arrow {
  display: inline-flex; align-items: center;
  flex-shrink: 0;
  padding: 0 2px;
  font-size: 11px; font-weight: 700;
}
.ohaeng-arrow.sheng { color: #16a34a; }   /* 상생 - green */
.ohaeng-arrow.ke    { color: #dc2626; }   /* 상극 - red */
.ohaeng-arrow-glyph {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
}
.ohaeng-arrow-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.03em; margin-left: 2px;
  text-transform: uppercase;
}
.ohaeng-node.wow {
  border-color: #f59e0b; background: #fef3c7;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

/* Beat segments now colored per element */
.beat-seg.el-wood  { background: linear-gradient(135deg, #16a34a, #22c55e); }
.beat-seg.el-fire  { background: linear-gradient(135deg, #ef4444, #f87171); }
.beat-seg.el-earth { background: linear-gradient(135deg, #b45309, #d97706); }
.beat-seg.el-metal { background: linear-gradient(135deg, #64748b, #94a3b8); }
.beat-seg.el-water { background: linear-gradient(135deg, #0284c7, #0ea5e9); }

/* Beat row gets element chip */
.beat-element-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  background: white; border: 1px solid var(--border);
  font-family: "JetBrains Mono", monospace;
  color: var(--text);
  margin-right: 4px;
}
.beat-element-chip.el-wood  { background: #dcfce7; border-color: #86efac; color: #14532d; }
.beat-element-chip.el-fire  { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.beat-element-chip.el-earth { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.beat-element-chip.el-metal { background: #e5e7eb; border-color: #9ca3af; color: #1f2937; }
.beat-element-chip.el-water { background: #dbeafe; border-color: #93c5fd; color: #1e3a8a; }
.beat-relation-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: 6px;
  font-family: "JetBrains Mono", monospace;
}
.beat-relation-tag.sheng { background: #dcfce7; color: #14532d; }
.beat-relation-tag.ke    { background: #fee2e2; color: #7f1d1d; }

/* Beat color palette (6 beats, indigo → rose) */
.beat-color-0 { background: #6366f1; }
.beat-color-1 { background: #8b5cf6; }
.beat-color-2 { background: #a855f7; }
.beat-color-3 { background: #d946ef; }
.beat-color-4 { background: #ec4899; }
.beat-color-5 { background: #f43f5e; }

/* ── FOOTER ──────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding-top: 28px; padding-bottom: 44px;
  display: flex; flex-direction: column; gap: 14px;
}
.foot-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  background: var(--surface);
}
.foot-details summary {
  cursor: pointer; font-weight: 700;
  color: var(--text); font-size: 14px;
}
.foot-details[open] summary { margin-bottom: 14px; }
.foot-body ul {
  list-style: none;
  display: flex; flex-direction: column; gap: 10px;
  font-size: 13px; color: var(--text-muted);
  padding: 4px 0;
}
.foot-body li strong { color: var(--text); font-weight: 700; }

.rules-table { display: grid; gap: 2px; font-size: 12px; }
.rule-row {
  display: grid;
  grid-template-columns: 230px 1.2fr 1.6fr 200px;
  padding: 9px 8px;
  border-bottom: 1px dashed var(--border);
  gap: 12px; align-items: start;
}
.rule-row:last-child { border-bottom: 0; }
.rule-row.header {
  font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; font-size: 10px;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-strong);
}
.rule-id {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; font-weight: 700;
  color: var(--primary);
}
.rule-anchor {
  font-size: 10.5px; color: var(--text-subtle);
  font-family: "JetBrains Mono", monospace;
}

.foot-meta {
  font-size: 12px; color: var(--text-subtle);
  text-align: center; padding: 14px 0;
}
.foot-meta a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 820px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .scores-section { grid-template-columns: 1fr; }
  .rule-row { grid-template-columns: 1fr; gap: 4px; }
  .hero-title { font-size: 30px; }
  .beats-detail .beat-row { grid-template-columns: 70px 1fr; }
  .beat-row-name { grid-column: 2; }
  .beat-row-content { grid-column: 1 / 3; padding-top: 2px; }
}
