:root {
  --bg: #f7f5f1;
  --panel: #ffffff;
  --ink: #1f1b16;
  --muted: #6b6255;
  --accent: #8a6d3b;
  --accent-dark: #5c4a29;
  --border: #e4ddd0;
  --card-shadow: 0 1px 3px rgba(31,27,22,0.06), 0 8px 24px rgba(31,27,22,0.05);
  font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { font-weight: 700; font-size: 20px; letter-spacing: 0.04em; color: var(--accent-dark); }
.brand-sub { font-size: 12px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.mode-pill {
  font-size: 11px; letter-spacing: 0.08em; padding: 6px 12px; border-radius: 999px;
  background: #f1ece1; color: var(--accent-dark); border: 1px solid var(--border);
}

.layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 20px;
  padding: 24px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; box-shadow: var(--card-shadow);
}
.form-panel h1 { font-size: 19px; margin: 0 0 6px; }
.lede { color: var(--muted); font-size: 13px; margin: 0 0 18px; line-height: 1.5; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
select, textarea, input[type="file"] {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px;
  font-size: 14px; background: #fbfaf7; color: var(--ink); width: 100%; font-family: inherit;
}
textarea { resize: vertical; }

.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.photo-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px; background: var(--accent-dark);
  color: #fff; font-weight: 600; letter-spacing: 0.04em; cursor: pointer; font-size: 13px;
  margin-top: 6px; transition: opacity .15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.cost-note { font-size: 11px; color: var(--muted); margin-top: 8px; text-align: center; }

.empty-state, .loading-state, .error-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state h2 { color: var(--ink); font-size: 16px; letter-spacing: 0.06em; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border);
  border-top-color: var(--accent); margin: 0 auto 14px; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { color: #a33; }

.field-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }
.photo-analysis-box {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
  background: #f7f5f1; font-size: 12.5px; line-height: 1.5;
}
.photo-analysis-box b { display: block; font-size: 10.5px; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
.photo-analysis-row { margin-bottom: 6px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fffdfa;
  display: flex; flex-direction: column; gap: 8px;
}
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(138,109,59,0.25); }
.card-header { display: flex; justify-content: space-between; align-items: center; }
.card-num { font-weight: 700; font-size: 12px; color: var(--accent-dark); letter-spacing: 0.06em; }
.card-angle { font-size: 13px; font-weight: 600; }
.card-row { font-size: 12.5px; line-height: 1.45; }
.card-row b { display: block; font-size: 10.5px; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
.card-cost { font-size: 12px; color: var(--accent-dark); font-weight: 600; margin-top: 4px; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-secondary, .btn-select {
  flex: 1; padding: 9px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; letter-spacing: 0.03em;
}
.btn-secondary { background: #f1ece1; border: 1px solid var(--border); color: var(--accent-dark); }
.btn-select { background: var(--accent-dark); border: none; color: #fff; }
.btn-select:disabled { opacity: 0.6; cursor: default; }

.modal { position: fixed; inset: 0; background: rgba(20,17,12,0.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 24px; max-width: 640px; width: 100%; max-height: 82vh; overflow: auto; position: relative; }
.modal-close { position: absolute; top: 12px; right: 14px; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-box pre { white-space: pre-wrap; font-size: 12.5px; background: #f7f5f1; padding: 14px; border-radius: 8px; line-height: 1.5; }
.next-phase-badge {
  display: inline-block; margin-top: 14px; padding: 8px 14px; border-radius: 8px;
  background: #eee; color: #999; font-size: 12px; font-weight: 600; letter-spacing: 0.05em;
  border: 1px dashed #ccc; cursor: not-allowed;
}

/* ---- PHASE B: video generation panel (SAFE MODE) ---- */
.phaseb-panel { margin-top: 12px; padding: 12px; border: 1px solid #444; border-radius: 6px; background: #1a1a1a; }
.phaseb-title { font-weight: 700; letter-spacing: 0.05em; margin-bottom: 6px; }
.phaseb-config { font-size: 0.85em; opacity: 0.85; margin-bottom: 4px; }
.phaseb-cost { font-size: 0.9em; margin-bottom: 8px; }
.phaseb-status { font-size: 0.9em; margin-bottom: 8px; opacity: 0.9; }
.phaseb-blocked { font-size: 0.9em; margin-bottom: 8px; color: #ff6b6b; border-left: 3px solid #ff6b6b; padding-left: 8px; }
.phaseb-confirm { font-size: 0.9em; margin: 8px 0; color: #ffcc66; }
.phaseb-progress { font-size: 0.9em; margin: 8px 0; opacity: 0.85; }
.phaseb-actions { margin-top: 6px; }
