/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f1f5f9;
  color: #1a1a2e;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }

header {
  background: #1e3a5f;
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
header h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: .02em; }
header a.home-link { font-size: .85rem; opacity: .7; margin-left: auto; }
header a.home-link:hover { opacity: 1; }
header .btn { color: #fff; border-color: rgba(255,255,255,.35); background: transparent; }
header .btn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.6); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 6px;
  border: none;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary   { background: #1e3a5f; color: #fff; }
.btn-primary:hover:not(:disabled)   { background: #163050; }
.btn-accent    { background: #f97316; color: #fff; }
.btn-accent:hover:not(:disabled)    { background: #ea6a0a; }
.btn-ghost     { background: transparent; color: #1e3a5f; border: 1px solid #cbd5e1; }
.btn-ghost:hover:not(:disabled)     { background: #f1f5f9; }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-danger:hover:not(:disabled)    { background: #dc2626; }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: #475569; }
.form-group input[type=text],
.form-group input[type=number],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #1e3a5f;
}
.form-group textarea { resize: vertical; min-height: 120px; }
.form-row { display: flex; gap: .75rem; align-items: flex-end; }
.form-row .form-group { flex: 1; margin-bottom: 0; }

/* ── Status dots ──────────────────────────────────────────────────────────── */
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-pending { background: #9ca3af; }
.dot-running { background: #f59e0b; animation: pulse 1s infinite; }
.dot-done    { background: #22c55e; }
.dot-error   { background: #ef4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ── Project list (index) ─────────────────────────────────────────────────── */
.project-list { display: flex; flex-direction: column; gap: .75rem; }

.project-item {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow .15s;
}
.project-item:hover { box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.project-item .project-name { font-weight: 600; font-size: .95rem; }
.project-item .project-meta { font-size: .8rem; color: #64748b; margin-top: .15rem; }
.project-item .stage-dots { display: flex; gap: .4rem; margin-left: auto; }

.empty-state { text-align: center; color: #94a3b8; padding: 3rem 0; font-size: .95rem; }

/* ── Stage section ────────────────────────────────────────────────────────── */
.stage {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.stage-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  user-select: none;
}
.stage-header h2 { font-size: 1rem; font-weight: 600; }
.stage-header .stage-status { margin-left: .25rem; }

.stage-collapse-icon {
  margin-left: auto;
  font-size: .7rem;
  color: #94a3b8;
  transition: transform .2s;
  flex-shrink: 0;
}
.stage.collapsed .stage-collapse-icon { transform: rotate(-90deg); }
.stage.collapsed .stage-body { display: none; }
.stage.collapsed .stage-header { border-bottom: none; }
.stage-header .model-select { margin-left: auto; }
.stage-header .btn-ghost { margin-left: 0; }

.model-select {
  font-size: .78rem;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: .25rem .5rem;
  cursor: pointer;
  outline: none;
  max-width: 170px;
}
.model-select:focus { border-color: #6366f1; }

.stage-body { padding: 1.25rem; }

.stage-run-row { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; }

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress-wrap { margin-bottom: 1rem; }
.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: .4rem;
}
.progress-fill {
  height: 100%;
  background: #1e3a5f;
  border-radius: 99px;
  transition: width .4s ease;
  width: 0%;
}
.progress-step { font-size: .8rem; color: #64748b; }

/* ── Result area ──────────────────────────────────────────────────────────── */
.result-area { margin-top: .5rem; }
.result-area textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: .75rem;
  font-size: .85rem;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  color: #1a1a2e;
  resize: vertical;
  min-height: 200px;
  line-height: 1.5;
}
.result-area textarea:focus { outline: none; border-color: #1e3a5f; }

.stage-output {
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: .75rem;
  font-size: .82rem;
  font-family: inherit;
  color: #1e293b;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
}

.result-info { font-size: .8rem; color: #64748b; margin-bottom: .5rem; }
.result-info .badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-grey  { background: #f1f5f9; color: #64748b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }

.revise-row {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
  margin-bottom: .5rem;
}
.revise-row input {
  flex: 1;
  padding: .5rem .75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: .875rem;
  font-family: inherit;
}
.revise-row input:focus { outline: none; border-color: #1e3a5f; }

.result-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }

/* ── Stage 4 extras ───────────────────────────────────────────────────────── */
.preferences-section { margin-bottom: 1rem; }

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  color: #94a3b8;
  font-size: .9rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-top: 1rem;
}
.dropzone:hover, .dropzone.dragover { border-color: #1e3a5f; background: #f8fafc; }
.dropzone input { display: none; }

.review-history { margin-top: 1.25rem; }
.review-history h3 { font-size: .9rem; font-weight: 600; margin-bottom: .75rem; color: #475569; }
.review-entry {
  background: #f8fafc;
  border-radius: 6px;
  padding: .75rem 1rem;
  margin-bottom: .75rem;
  font-size: .85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  border-left: 3px solid #1e3a5f;
}

/* ── Sitemap tree ─────────────────────────────────────────────────────────── */
.sitemap-tree { margin: .5rem 0 1rem; }
.sitemap-page {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .65rem .85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  margin-bottom: .5rem;
}
.sitemap-page-title {
  font-size: .88rem; font-weight: 600; color: #1e293b;
  flex-shrink: 0; min-width: 120px;
}
.sitemap-page-slug {
  font-size: .78rem; color: #94a3b8; font-family: monospace;
}
.sitemap-page-purpose { font-size: .83rem; color: #475569; flex: 1; }
.sitemap-page-blocks {
  font-size: .75rem; color: #94a3b8;
  flex-shrink: 0;
}

/* ── Playwright tools ─────────────────────────────────────────────────────── */
.playwright-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .75rem;
}
.playwright-tool-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: .85rem 1rem;
}
.playwright-tool-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0;
}
.playwright-tool-header strong { font-size: .875rem; color: #1e293b; }

/* ── Modal (prompt editor) ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%; max-width: 680px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b; }
.modal-body { padding: 1.25rem; flex: 1; overflow-y: auto; }
.modal-body textarea {
  width: 100%; height: 360px;
  border: 1px solid #cbd5e1; border-radius: 6px;
  padding: .75rem; font-family: monospace; font-size: .85rem;
  line-height: 1.6; resize: vertical;
}
.modal-body textarea:focus { outline: none; border-color: #1e3a5f; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #e2e8f0;
  display: flex; gap: .5rem; justify-content: flex-end;
}

/* ── New project form ─────────────────────────────────────────────────────── */
.new-project-wrap { margin-bottom: 2rem; }
.new-project-toggle {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.new-project-toggle h2 { font-size: 1.1rem; font-weight: 700; }

#new-project-form { display: none; }
#new-project-form.open { display: block; }

.mode-row { display: flex; gap: 1rem; }
.mode-option {
  flex: 1; border: 1px solid #cbd5e1; border-radius: 6px;
  padding: .75rem; cursor: pointer; font-size: .875rem; text-align: center;
  transition: border-color .15s, background .15s;
}
.mode-option.selected { border-color: #1e3a5f; background: #eff6ff; font-weight: 500; }

.max-pages-row { display: flex; gap: .75rem; align-items: center; margin-top: .5rem; font-size: .875rem; color: #475569; }
.max-pages-row input[type=number] { width: 80px; }
.max-pages-row label { display: flex; align-items: center; gap: .35rem; cursor: pointer; }

/* ── Project header ───────────────────────────────────────────────────────── */
.project-meta-bar {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem;
}
.project-meta-bar h1 { font-size: 1.3rem; font-weight: 700; }
.project-meta-bar .meta-info { font-size: .8rem; color: #64748b; }

.tool-tokens {
  margin-top: .4rem;
  font-size: .78rem;
  color: #64748b;
}

/* ── Block Plan ───────────────────────────────────────────────────────────── */
.block-plan-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: .9rem 1rem;
  margin-bottom: .65rem;
  background: #f8fafc;
}
.block-plan-name {
  font-weight: 700;
  font-size: .9rem;
  color: #1e3a5f;
  margin-bottom: .55rem;
}
.block-plan-row {
  display: flex;
  gap: .6rem;
  margin-bottom: .3rem;
  font-size: .82rem;
  line-height: 1.45;
  align-items: flex-start;
}
.block-plan-label {
  flex-shrink: 0;
  width: 100px;
  font-weight: 600;
  color: #475569;
}
.strategy-row {
  display: flex;
  gap: .6rem;
  margin-bottom: .45rem;
  font-size: .82rem;
  line-height: 1.5;
  align-items: flex-start;
  padding-bottom: .45rem;
  border-bottom: 1px solid #f1f5f9;
}
.strategy-row:last-child { border-bottom: none; }
.strategy-label {
  flex-shrink: 0;
  width: 120px;
  font-weight: 600;
  color: #1e3a5f;
}

.block-accent {
  display: inline-block;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 4px;
  padding: .1rem .45rem;
  font-size: .76rem;
  margin: .1rem .2rem .1rem 0;
}

/* ── Stage 3 per-page list ────────────────────────────────────────────────── */
#stage3-page-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }

.page-gen-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.page-gen-info { flex: 1; min-width: 0; }
.page-gen-name { font-weight: 600; font-size: .9rem; display: block; }
.page-gen-purpose {
  font-size: .78rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.page-gen-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: #1e3a5f; color: #fff;
  padding: .65rem 1.1rem; border-radius: 8px;
  font-size: .875rem; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slide-in .2s ease;
  z-index: 2000;
}
.toast.error { background: #ef4444; }
@keyframes slide-in { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Stage log ────────────────────────────────────────────────────────────── */
.stage-log {
  margin-top: .75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  font-size: .8rem;
}
.stage-log summary {
  padding: .45rem .75rem;
  cursor: pointer;
  color: #64748b;
  user-select: none;
  background: #f8fafc;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.stage-log summary::-webkit-details-marker { display: none; }
.stage-log summary::before {
  content: '▶';
  font-size: .65rem;
  transition: transform .15s;
}
.stage-log[open] summary::before { transform: rotate(90deg); }
.log-badge {
  background: #e2e8f0;
  color: #475569;
  border-radius: 99px;
  padding: .05rem .45rem;
  font-size: .72rem;
  font-weight: 600;
  margin-left: auto;
}
.log-entries {
  max-height: 220px;
  overflow-y: auto;
  padding: .6rem .75rem;
  background: #0f172a;
  color: #94a3b8;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: .78rem;
  line-height: 1.7;
}
.log-line { white-space: pre-wrap; word-break: break-all; }
.log-line.log-ok     { color: #4ade80; }
.log-line.log-error  { color: #f87171; }
.log-line.log-info   { color: #60a5fa; }
.log-line.log-warn   { color: #fbbf24; }
.tok-summary { color: #94a3b8; font-size: .75rem; font-family: monospace; }

/* ── Ideas cards ─────────────────────────────────────────────────────────── */
.idea-card {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: .85rem 1rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.idea-card:hover { border-color: #93c5fd; background: #eff6ff; }
.idea-card.checked { border-color: #3b82f6; background: #eff6ff; }
.idea-card input[type=checkbox] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #3b82f6;
  cursor: pointer;
}
.idea-card-body { flex: 1; }
.idea-card-title { font-weight: 600; font-size: .9rem; color: #1e293b; margin-bottom: .25rem; }
.idea-card-desc { font-size: .82rem; color: #475569; line-height: 1.5; margin-bottom: .25rem; }
.idea-card-impact { font-size: .78rem; color: #2563eb; }
.idea-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: #e2e8f0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  color: #64748b;
  margin-top: 2px;
}
.idea-card.checked .idea-num { background: #3b82f6; color: #fff; }

/* ── Materials cards ─────────────────────────────────────────────────────── */
.material-card {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: .85rem 1rem;
  transition: border-color .15s, background .15s;
}
.material-card:hover { border-color: #93c5fd; background: #eff6ff; }
.material-card.checked { border-color: #3b82f6; background: #eff6ff; }
.material-card-body { flex: 1; }
.material-card-title { font-weight: 600; font-size: .9rem; color: #1e293b; margin-bottom: .25rem; }
.material-card-desc { font-size: .82rem; color: #475569; line-height: 1.5; margin-bottom: .3rem; }
.material-card-why { font-size: .78rem; color: #059669; line-height: 1.4; }
.material-type-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: .35rem;
}
.badge-video     { background: #fef3c7; color: #b45309; }
.badge-photo     { background: #d1fae5; color: #065f46; }
.badge-testimonial { background: #ede9fe; color: #5b21b6; }
.badge-case_study { background: #e0f2fe; color: #0369a1; }
.badge-document  { background: #f3f4f6; color: #374151; }
.badge-infographic { background: #fce7f3; color: #9d174d; }
.badge-screenshot { background: #f0fdf4; color: #166534; }
.badge-certificate { background: #fff7ed; color: #9a3412; }
.badge-other     { background: #f1f5f9; color: #475569; }
.priority-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px;
}
.priority-high   { background: #ef4444; }
.priority-medium { background: #f59e0b; }
.priority-low    { background: #94a3b8; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: #94a3b8; font-size: .85rem; }
hr { border: none; border-top: 1px solid #e2e8f0; margin: 1rem 0; }
