:root {
  --bg: #0b0d12;
  --panel: #121722;
  --panel-2: #171d2b;
  --border: #243049;
  --text: #e8edf7;
  --muted: #93a0ba;
  --cyan: #5fd4ff;
  --violet: #9b87ff;
  --green: #7dffb2;
  --amber: #ffcc66;
  --danger: #ff7b7b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, sans-serif; }

.app { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #0f1420, #0b0d12);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(95,212,255,.2), rgba(155,135,255,.25));
  border: 1px solid var(--border);
  color: var(--cyan);
  font-size: 20px;
}
.brand h1 { margin: 0; font-size: 18px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.nav-list { display: flex; flex-direction: column; gap: 8px; flex: 1; overflow: auto; }
.nav-item {
  text-align: left; width: 100%; padding: 12px 14px; border-radius: 12px;
  background: transparent; border: 1px solid transparent; color: var(--text);
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.03); border-color: var(--border); }
.nav-item.active { background: rgba(95,212,255,.08); border-color: rgba(95,212,255,.35); }

.main { padding: 28px; overflow: auto; }
.topbar { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 24px; align-items: start; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.top-refresh { flex-shrink: 0; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.topbar h2 { margin: 0; font-size: 28px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 10px; border-radius: 999px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.chip.highlight { color: var(--cyan); border-color: rgba(95,212,255,.35); }

.view { display: none; }
.view.active { display: block; }

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

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: rgba(95,212,255,.35); }
.card h3 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 14px; cursor: pointer;
}
.tab.active { color: var(--text); border-color: rgba(155,135,255,.45); background: rgba(155,135,255,.12); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel h3, .panel h4 { margin-top: 0; }
.panel p, .panel li { color: #c9d3ea; line-height: 1.6; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.phase-list { display: flex; flex-direction: column; gap: 12px; }
.phase-item { padding: 14px; border-radius: 14px; background: rgba(255,255,255,.02); border: 1px solid var(--border); }
.phase-item h4 { margin: 0 0 8px; color: var(--cyan); }

.analysis-content { white-space: pre-wrap; line-height: 1.65; color: #d8e0f2; font-size: 14px; }
.analysis-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.analysis-prompt-list { display: flex; flex-direction: column; gap: 12px; }
.analysis-prompt-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--panel-2);
}
.analysis-prompt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.analysis-prompt-text {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.analysis-prompt-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.scene-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.scene-card.canonical { border-color: rgba(125,255,178,.35); }
.scene-preview {
  aspect-ratio: 16/9;
  background: #090b10;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.scene-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.scene-body h4 { margin: 0; font-size: 15px; word-break: break-word; }
.scene-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.scene-prompt-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.scene-prompt {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.scene-feedback {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  border: 1px solid rgba(95, 212, 255, 0.25);
  border-radius: 10px;
  background: rgba(95, 212, 255, 0.04);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.scene-refine-notes {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(125, 255, 178, 0.08);
  border: 1px solid rgba(125, 255, 178, 0.25);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.scene-refine-notes.hidden { display: none; }
.scene-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: rgba(95,212,255,.35); }
.btn.primary { background: rgba(95,212,255,.12); border-color: rgba(95,212,255,.45); color: var(--cyan); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.canonical { color: var(--green); border-color: rgba(125,255,178,.35); }

.session-list { display: flex; flex-direction: column; gap: 10px; }
.session-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.02);
  cursor: pointer;
}
.session-item.active { border-color: rgba(155,135,255,.45); }

.message {
  padding: 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.message.user { background: rgba(95,212,255,.06); }
.message.assistant { background: rgba(155,135,255,.06); }
.message-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.settings { margin: 0; padding: 12px; }
.settings h3 { margin: 0 0 6px; font-size: 14px; }
.settings-copy { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.settings-input {
  width: 100%; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: #0b0f18; color: var(--text);
}
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: #101522; border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
}
.toast.hidden { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
