/* ── Design tokens ── */
:root {
  --primary:       #4f46e5;
  --primary-light: #e0e7ff;
  --primary-dark:  #3730a3;
  --success:       #059669;
  --success-light: #d1fae5;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --muted:         #6b7280;
  --muted-light:   #f3f4f6;

  --bg:      #f3f4f6;
  --surface: #ffffff;
  --border:  #e5e7eb;
  --text:    #111827;
  --text-2:  #374151;
  --text-3:  #6b7280;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12), 0 4px 6px rgba(0,0,0,.07);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  box-sizing: border-box;
}

*, *::before, *::after { box-sizing: inherit; margin: 0; padding: 0; }
body { background: var(--bg); min-height: 100vh; }

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 32px; height: 32px;
  background: var(--primary); color: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 18px; color: var(--text); }
.header-stats { flex: 1; display: flex; gap: 20px; font-size: 13px; color: var(--text-3); }
.stat { display: flex; align-items: center; gap: 5px; }
.stat-value { font-weight: 600; color: var(--text-2); }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s, opacity .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover:not(:disabled){ background: var(--muted-light); }
.btn-ghost     { background: transparent; color: var(--text-3); }
.btn-ghost:hover:not(:disabled)    { background: var(--muted-light); color: var(--text-2); }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-light); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-lg  { padding: 10px 20px; font-size: 14px; }

/* ── Analysis banner ── */
.analysis-banner {
  background: var(--primary-light);
  border-bottom: 1px solid #c7d2fe;
  padding: 10px 24px;
  font-size: 13px; color: var(--primary-dark);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.analysis-banner strong { font-weight: 600; }
.cp-tag {
  background: var(--primary); color: #fff;
  padding: 2px 8px; border-radius: 12px;
  font-size: 12px; font-weight: 500;
}

/* ── Main ── */
.main { max-width: 1100px; margin: 0 auto; padding: 24px 24px 80px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 80px 24px; }
.empty-icon  { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; }
.empty-state p  { color: var(--text-3); margin-bottom: 24px; font-size: 15px; }
.empty-actions  { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── Task list ── */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.task-card:hover     { box-shadow: var(--shadow); border-color: #d1d5db; }
.task-card.completed { opacity: .55; }
.task-card.deferred  { opacity: .45; }
.task-card.awaiting  { border-left: 3px solid #a855f7; }

.task-rank { font-size: 18px; font-weight: 700; color: var(--primary); text-align: center; line-height: 1; }
.task-rank.no-rank { color: var(--muted); font-size: 14px; font-weight: 400; }
.task-main { min-width: 0; }

.task-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-name {
  font-size: 15px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px;
}
.task-name.strike { text-decoration: line-through; color: var(--text-3); }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 500; white-space: nowrap; flex-shrink: 0;
}
.cat-badge          { background: var(--muted-light); color: var(--text-3); }
.status-backlog     { background: var(--muted-light);   color: var(--muted); }
.status-in-progress { background: #dbeafe;              color: #1d4ed8; }
.status-blocked     { background: var(--danger-light);  color: var(--danger); }
.status-completed   { background: var(--success-light); color: var(--success); }
.status-deferred    { background: #f1f5f9;              color: #64748b; }
.status-awaiting    { background: #f3e8ff;              color: #7e22ce; }

.awaiting-desc {
  font-size: 12px;
  color: #7e22ce;
  margin: 3px 0 1px;
  font-style: italic;
}

.wsjf-chip { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 12px; white-space: nowrap; }
.wsjf-high   { background: var(--primary-light); color: var(--primary); }
.wsjf-medium { background: var(--warning-light); color: var(--warning); }
.wsjf-low    { background: var(--muted-light);   color: var(--muted); }

.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.task-score-detail { font-size: 11px; color: var(--text-3); font-family: "SFMono-Regular", Consolas, monospace; }
.task-dep          { font-size: 11px; color: #9ca3af; }
.task-note { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 480px; margin-top: 2px; }

.flag { font-size: 11px; padding: 1px 6px; border-radius: 10px; font-weight: 500; }
.flag-cp     { background: #fef9c3; color: #854d0e; }
.flag-decomp { background: #fce7f3; color: #9d174d; }
.flag-bn     { background: #fef3c7; color: #92400e; }

.domino-tag { font-size: 11px; color: #7c3aed; font-weight: 600; padding: 1px 6px; background: #ede9fe; border-radius: 10px; }

.task-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.icon-btn {
  width: 30px; height: 30px;
  border: none; background: transparent; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-3); transition: background .12s;
}
.icon-btn:hover { background: var(--muted-light); color: var(--text-2); }
.icon-btn-await { color: #7e22ce; }
.icon-btn-await:hover { background: #f3e8ff; color: #6b21a8; }

/* ── Overlay / Modal ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 680px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
}
.modal-wide { max-width: 820px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.close-btn {
  width: 32px; height: 32px; border: none; background: transparent; border-radius: 6px;
  font-size: 16px; cursor: pointer; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.close-btn:hover { background: var(--muted-light); color: var(--text-2); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-top: 1px solid var(--border); flex-shrink: 0; gap: 12px;
}
.modal-footer-right { display: flex; gap: 8px; margin-left: auto; }

/* ── Form ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.req   { color: var(--danger); }
.input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: var(--surface); width: 100%;
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.textarea  { resize: vertical; min-height: 72px; }
.field-hint { font-size: 12px; color: var(--text-3); }

/* ── Wizard ── */
.modal-wizard { max-width: 600px; }

.wizard-header {
  padding: 18px 24px 0;
  flex-shrink: 0;
  border-bottom: none;
}
.wizard-header-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.wizard-step-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3);
}
.wizard-progress-track {
  height: 3px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.wizard-progress-fill {
  height: 100%; background: var(--primary); border-radius: 2px;
  transition: width .35s ease; width: 0%;
}

.wizard-body  { padding: 22px 24px 16px; overflow-y: auto; flex: 1; }
.wstep        { display: flex; flex-direction: column; gap: 0; }

.step-q {
  font-size: 20px; font-weight: 700; color: var(--text);
  margin-bottom: 8px; line-height: 1.25;
}
.step-subq {
  font-size: 14px; font-weight: 600; color: var(--text-2);
  margin-top: 22px; margin-bottom: 10px;
}
.step-hint {
  font-size: 13px; color: var(--text-3);
  margin-bottom: 16px; line-height: 1.6;
  padding: 10px 14px;
  background: var(--muted-light);
  border-radius: var(--radius);
  border-left: 3px solid var(--border);
}
.optional-label { font-size: 13px; font-weight: 400; color: var(--text-3); }

.wizard-name-input { font-size: 16px; padding: 12px 14px; margin-bottom: 4px; }

/* Type cards */
.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.type-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 13px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
}
.type-card:hover  { border-color: var(--primary); background: var(--primary-light); transform: translateY(-1px); }
.type-card.active { border-color: var(--primary); background: var(--primary-light); }
.type-card-wide   { grid-column: span 2; flex-direction: row; align-items: center; gap: 10px; }
.type-icon  { font-size: 20px; line-height: 1; }
.type-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.type-desc  { font-size: 11px; color: var(--text-3); line-height: 1.4; }

/* Choice cards */
.choice-list { display: flex; flex-direction: column; gap: 7px; }

.choice-card {
  display: grid; grid-template-columns: 22px 1fr; gap: 13px; align-items: center;
  padding: 13px 16px;
  border: 2px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color .15s, background .15s, transform .1s;
}
.choice-card:hover  { border-color: var(--primary); background: #fafbff; transform: translateX(2px); }
.choice-card.active { border-color: var(--primary); background: var(--primary-light); }

.choice-dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.dot-green  { background: #22c55e; }
.dot-yellow { background: #eab308; }
.dot-orange { background: #f97316; }
.dot-red    { background: #ef4444; }
.dot-black  { background: #1f2937; }

.choice-label { font-size: 14px; font-weight: 600; color: var(--text-2); line-height: 1.2; }
.choice-desc  { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.4; }

/* WSJF result on step 6 */
.wsjf-result {
  background: var(--primary-light); border: 1px solid #c7d2fe;
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 18px;
}
.wsjf-result-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.wsjf-result-score { font-size: 28px; font-weight: 800; line-height: 1; }
.wsjf-result-label { font-size: 13px; color: var(--primary-dark); }
.wsjf-result-breakdown { font-size: 11px; color: var(--text-3); font-family: "SFMono-Regular", Consolas, monospace; }

/* Wizard footer */
.wizard-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.wizard-nav { display: flex; gap: 8px; margin-left: auto; }

/* ── Report modal ── */
.report-toolbar { margin-bottom: 12px; }
.report-pre {
  background: var(--muted-light); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  font-size: 13px; font-family: "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
  max-height: 60vh; overflow-y: auto; color: var(--text-2);
}

/* ── Toasts ── */
#toasts {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 999;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease; max-width: 320px;
}
.toast-success { background: #ecfdf5; color: #065f46; border-left: 4px solid var(--success); }
.toast-error   { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.toast-info    { background: var(--primary-light); color: var(--primary-dark); border-left: 4px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Spinner ── */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── How it works ── */
.how-it-works { margin-top: 48px; text-align: left; max-width: 680px; margin-left: auto; margin-right: auto; }
.how-it-works h3 {
  text-align: center; font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3); margin-bottom: 20px;
}
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 16px; }
.how-icon { font-size: 24px; margin-bottom: 8px; }
.how-item strong { display: block; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
.how-item p { font-size: 12px; color: var(--text-3); line-height: 1.5; margin: 0; }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .header-stats { display: none; }
  .header { padding: 0 16px; }
  .main   { padding: 16px 16px 60px; }
  .field-row { grid-template-columns: 1fr; }
  .task-card { grid-template-columns: 28px 1fr auto; gap: 8px; padding: 12px; }
  .task-name { max-width: 200px; }
  .how-grid  { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: 1fr; }
  .type-card-wide { grid-column: span 1; }
  .score-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .header-actions .btn-ghost { display: none; }
}
