/* Story Engine — calm dark theme. Design intent: low-glare and readable —
 * near-neutral charcoal surfaces, desaturated accents, no glow effects,
 * sans-serif for UI text with monospace reserved for data (tables, code,
 * source quotes). Type sizes stay >= 12px. */
:root {
  --bg: #15171d;
  --bg-panel: #1c1f27;
  --bg-inset: #171920;
  --line: #2c303a;
  --line-strong: #3a3f4c;
  --text: #d5d9e0;
  --dim: #9298a3;
  --accent: #85b8e8;
  --accent-deep: #3f7cb8;
  --gold: #d3b46a;
  --green: #7cbf8e;
  --red: #d98a80;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: Consolas, "Cascadia Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.6;
}

main { max-width: 1060px; margin: 0 auto; padding: 0 20px 48px; }

/* ---------- header ---------- */
.app-header {
  max-width: 1060px;
  margin: 0 auto;
  padding: 30px 20px 8px;
}
.title-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent);
}
.phase-badge {
  font-size: 12px;
  color: var(--gold);
  border: 1px solid rgba(211, 180, 106, 0.45);
  border-radius: 999px;
  padding: 3px 11px;
}
.tagline { color: var(--dim); margin: 8px 0 20px; max-width: 640px; }

/* ---------- stepper ---------- */
.stepper {
  list-style: none;
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 0 0 22px;
  flex-wrap: wrap;
}
.stepper li {
  font-size: 13px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 13px 5px 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-inset);
}
.stepper li span {
  display: inline-block;
  width: 20px; height: 20px;
  text-align: center; line-height: 20px;
  border-radius: 5px;
  background: var(--line);
  font-size: 12px;
}
.stepper li.current { color: var(--text); border-color: var(--accent-deep); }
.stepper li.current span { background: var(--accent); color: #15171d; }
.stepper li.done { color: var(--green); }
.stepper li.done span { background: var(--green); color: #15171d; }
.stepper li.skipped { opacity: 0.4; text-decoration: line-through; }

/* ---------- screens & panels ---------- */
.screen { display: none; }
.screen.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
  margin-bottom: 18px;
}
h2 { font-size: 19px; font-weight: 600; margin: 0 0 16px; }
h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; margin: 0 0 12px; color: var(--dim); }
.dim { color: var(--dim); font-size: 13.5px; font-weight: normal; }
.hidden { display: none !important; }

/* ---------- inputs ---------- */
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 18px 0 7px;
}
.field-label:first-child { margin-top: 0; }
.req { color: var(--dim); font-weight: 400; font-size: 12.5px; letter-spacing: 0; text-transform: none; }
textarea, input[type="text"] {
  width: 100%;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  resize: vertical;
}
textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(63, 124, 184, 0.18);
}
.inp-missing { border-color: rgba(211, 180, 106, 0.55) !important; border-style: dashed !important; }
#inp-desc { font-family: var(--sans); font-size: 14.5px; }

/* ---------- buttons ---------- */
.btn {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent-deep); background: #1e222b; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #f2f6fa;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #4d8cc9; border-color: #4d8cc9; color: #fff; }
.btn-big { padding: 12px 28px; font-size: 15.5px; }
.btn-wide { width: 100%; margin-top: 12px; }
.btn.confirmed { border-color: rgba(124, 191, 142, 0.6); color: var(--green); }
.action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.action-row .btn-primary { margin-left: auto; }

.mode-toggle { display: flex; gap: 10px; margin: 20px 0 6px; }
.mode-on { border-color: var(--accent-deep); color: var(--accent); font-weight: 600; background: rgba(63, 124, 184, 0.12); }

/* ---------- samples ---------- */
.samples { margin-top: 22px; }
#sample-chips { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.chip:hover { border-color: var(--accent-deep); }
.chip-hint { color: var(--dim); font-size: 12px; }

/* ---------- messages / kv ---------- */
.msg { border-radius: 8px; padding: 12px 16px; margin: 12px 0; font-size: 14px; line-height: 1.55; }
.msg-ok { background: rgba(124, 191, 142, 0.08); border: 1px solid rgba(124, 191, 142, 0.35); }
.msg-warn { background: rgba(211, 180, 106, 0.08); border: 1px solid rgba(211, 180, 106, 0.35); }
.msg-error { background: rgba(217, 138, 128, 0.09); border: 1px solid rgba(217, 138, 128, 0.4); }
.msg .btn { margin-left: 10px; }

.kv-grid { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.kv { display: flex; gap: 14px; font-size: 14.5px; }
.kv-k {
  color: var(--dim);
  min-width: 150px;
  text-align: right;
  font-size: 13.5px;
}
.kv-v .lg-swatch { margin-right: 4px; }

.shape-btns { display: flex; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.shape-btns .btn-big { flex: 1; min-width: 220px; line-height: 1.45; }

.analyze-steps { color: var(--dim); font-size: 15px; }
.analyze-steps li { margin: 9px 0; opacity: 0.45; transition: opacity 0.2s; }
.analyze-steps li.az-active { color: var(--accent); opacity: 1; }
.analyze-steps li.az-active::after { content: ' …'; }
.analyze-steps li.az-done { color: var(--green); opacity: 0.9; }
.analyze-steps li.az-done::after { content: ' ✓'; }

.doc-cand-row { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.doc-cand { padding: 6px 12px; font-size: 13px; }

/* ---------- confirm grid ---------- */
.grid-scroll { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; }
.edit-grid { border-collapse: collapse; width: 100%; }
.edit-grid th, .edit-grid td { border: 1px solid var(--line); padding: 0; min-width: 110px; }
.edit-grid th { background: var(--bg-inset); position: relative; padding-top: 20px; }
.edit-grid input {
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 8px 10px;
  font-size: 13.5px;
  box-shadow: none;
}
.edit-grid th input { font-weight: 600; color: var(--accent); }
.edit-grid input:focus { background: rgba(133, 184, 232, 0.07); box-shadow: none; }
.edit-grid tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.015); }
.role-badge {
  position: absolute;
  top: 3px; left: 5px;
  font-size: 10.5px;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 0 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.role-primary { background: rgba(63, 124, 184, 0.35); color: #b8d5ef; }
.role-growth { background: rgba(124, 191, 142, 0.25); color: #a9d6b7; }
.role-extra { background: rgba(211, 180, 106, 0.22); color: #dfc890; }
.role-label, .role-player { background: var(--line); color: var(--dim); }
.role-period { background: rgba(143, 130, 200, 0.25); color: #c3bae0; }

/* ---------- milestones checklist ---------- */
.ms-head { margin-top: 30px; display: flex; align-items: center; gap: 12px; }
.count-chip {
  font-size: 12.5px;
  background: rgba(133, 184, 232, 0.1);
  border: 1px solid rgba(133, 184, 232, 0.35);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 12px;
}
.ms-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 15px;
  margin: 10px 0;
}
.ms-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 7px; accent-color: var(--accent-deep); }
.ms-main { flex: 1; }
.ms-top { display: flex; gap: 9px; align-items: center; }
.ms-period-chip {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(143, 130, 200, 0.2);
  color: #c3bae0;
  border-radius: 5px;
  padding: 3px 9px;
  white-space: nowrap;
}
.ms-title-inp { font-weight: 600; font-family: var(--sans); font-size: 14px; }
.ms-desc-inp { margin-top: 7px; font-size: 13px; font-family: var(--sans); }
.ms-src { color: var(--dim); font-size: 12px; margin-top: 7px; line-height: 1.5; }

/* ---------- render screen & chrome ---------- */
.render-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.render-title { color: var(--gold); font-size: 15px; }
.spacer { flex: 1; }

.stage-box {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #171a2e;
}
.stage { display: block; line-height: 0; }
.scene-canvas { display: block; image-rendering: pixelated; }

.stage-legend {
  position: absolute;
  right: 12px; top: 10px;
  display: flex;
  gap: 12px;
  font-size: 12px;
  background: rgba(18, 20, 30, 0.72);
  border-radius: 8px;
  padding: 5px 12px;
}
.lg-item { display: inline-flex; align-items: center; gap: 5px; }
.lg-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
}

.milestone-banner {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: 88%;
  background: rgba(18, 20, 30, 0.92);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 16px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.3s, transform 0.3s;
}
.milestone-banner.hidden { opacity: 0; transform: translateX(-50%) translateY(12px); pointer-events: none; display: block !important; }
.mb-period { font-family: var(--mono); font-size: 12px; color: var(--gold); margin-right: 8px; }
.mb-title { font-size: 13.5px; font-weight: 600; }
.mb-desc { font-size: 12.5px; color: var(--dim); }

.transport {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  flex-wrap: wrap;
}
.speed-select {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 14px;
}
.progress-outer {
  flex: 1;
  min-width: 140px;
  height: 8px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-inner {
  height: 100%;
  width: 0;
  background: var(--accent-deep);
  transition: width 0.15s linear;
}
.status-line { font-size: 13.5px; color: var(--gold); }

.lower-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 760px) { .lower-panels { grid-template-columns: 1fr; } }

.hud-cards { display: flex; flex-wrap: wrap; gap: 10px; }
.hud-card {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 16px;
  min-width: 110px;
}
.hud-label { font-size: 11.5px; color: var(--dim); letter-spacing: 0.6px; text-transform: uppercase; }
.hud-value { font-size: 17px; font-weight: 600; font-family: var(--mono); color: var(--accent); }

.ms-list { max-height: 240px; overflow-y: auto; }
.ms-empty { color: var(--dim); font-size: 13.5px; }
.ms-card {
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 13px;
  margin-bottom: 7px;
  cursor: pointer;
  font-size: 13.5px;
  transition: border-color 0.15s;
}
.ms-card:hover { border-color: var(--accent-deep); }
.ms-card-period { font-family: var(--mono); color: var(--gold); font-size: 12px; margin-right: 8px; }
.ms-card-title { font-weight: 600; }
.ms-card-desc { color: var(--dim); font-size: 12.5px; margin-top: 3px; }

.app-footer {
  max-width: 1060px;
  margin: 0 auto;
  padding: 12px 20px 34px;
  color: var(--dim);
  font-size: 13px;
}
