:root {
  --bg-0: #0a1116;
  --bg-1: #101b23;
  --panel: rgba(14, 28, 36, 0.82);
  --panel-border: rgba(151, 215, 239, 0.28);
  --text: #eaf4f7;
  --muted: #9cb8c6;
  --good: #29d3a3;
  --warn: #f6b55f;
  --bad: #ff6d6f;
  --cyan: #67d9ff;
  --amber: #f7a641;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Crimson Pro", serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 12%, #13344a 0%, transparent 38%),
    radial-gradient(circle at 85% 4%, #3f2d1f 0%, transparent 30%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  position: relative;
  overflow-x: hidden;
}

.mesh,
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.mesh {
  background: linear-gradient(110deg, transparent 45%, rgba(103, 217, 255, 0.06) 55%, transparent 64%);
}

.grain {
  opacity: 0.2;
  background-image: radial-gradient(rgba(255, 255, 255, 0.15) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
  mix-blend-mode: soft-light;
}

.deck {
  position: relative;
  z-index: 2;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 45px rgba(3, 10, 14, 0.4);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.26em;
  color: var(--cyan);
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.04em;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: #f4fdff;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.hero-meta {
  text-align: right;
  align-self: center;
}

.pulse-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Rajdhani", sans-serif;
  font-weight: 600;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(246, 181, 95, 0.7);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(103, 217, 255, 0.5);
  }
  70% {
    box-shadow: 0 0 0 13px rgba(103, 217, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(103, 217, 255, 0);
  }
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.control-group.compact {
  font-family: "Rajdhani", sans-serif;
  color: var(--muted);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

select,
button {
  font-family: "Rajdhani", sans-serif;
}

select {
  border: 1px solid rgba(103, 217, 255, 0.35);
  border-radius: 10px;
  background: rgba(10, 21, 28, 0.9);
  color: #d7eaf2;
  padding: 6px 8px;
}

.btn {
  border: 1px solid rgba(233, 249, 255, 0.25);
  background: rgba(17, 34, 45, 0.95);
  color: #ecf7fb;
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.btn-disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-disabled:hover,
.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.45);
}

.btn:active {
  transform: translateY(0);
}

.btn-start {
  border-color: rgba(41, 211, 163, 0.6);
  box-shadow: inset 0 0 0 1px rgba(41, 211, 163, 0.25);
}

.btn-stop {
  border-color: rgba(255, 109, 111, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 109, 111, 0.2);
}

.btn-ghost {
  border-color: rgba(103, 217, 255, 0.35);
}

.btn.small {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.card {
  padding: 16px;
  min-height: 140px;
}

.status-card {
  border-left: 4px solid rgba(246, 181, 95, 0.5);
}

.status-card.good {
  border-left-color: rgba(41, 211, 163, 0.9);
}

.status-card.warn {
  border-left-color: rgba(246, 181, 95, 0.9);
}

.status-card.bad {
  border-left-color: rgba(255, 109, 111, 0.9);
}

.big {
  margin: 8px 0 4px;
  font-family: "Rajdhani", sans-serif;
  font-size: 2rem;
  line-height: 1;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.mono {
  font-family: "Rajdhani", sans-serif;
}

.grid-details {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 2fr);
  gap: 12px;
}

.detail {
  padding: 14px 16px;
}

.state-list {
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.state-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(10, 23, 30, 0.58);
}

.state-list dt {
  color: var(--muted);
}

.state-list dd {
  margin: 0;
  text-align: right;
  font-family: "Rajdhani", sans-serif;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 0;
}

.terminal {
  margin: 10px 14px 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(103, 217, 255, 0.25);
  background: rgba(4, 12, 16, 0.93);
  color: #c3f4df;
  font-family: "Rajdhani", sans-serif;
  font-size: 0.95rem;
  line-height: 1.3;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 280px;
}

.terminal.tall {
  max-height: 420px;
}

.markdown-view {
  margin: 10px 14px 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(103, 217, 255, 0.25);
  background: rgba(4, 12, 16, 0.93);
  color: #d7ebf4;
  overflow: auto;
  max-height: 320px;
  line-height: 1.4;
}

.ideas-view {
  max-height: 65vh;
}

.markdown-view h1,
.markdown-view h2,
.markdown-view h3,
.markdown-view h4,
.markdown-view h5,
.markdown-view h6 {
  margin: 0.35rem 0 0.55rem;
  font-family: "Rajdhani", sans-serif;
  color: #f3fbff;
}

.markdown-view p {
  margin: 0.3rem 0 0.55rem;
}

.markdown-view ul {
  margin: 0.35rem 0 0.65rem 1.1rem;
  padding: 0;
}

.markdown-view li {
  margin: 0.18rem 0;
}

.markdown-view code {
  font-family: "Rajdhani", sans-serif;
  background: rgba(103, 217, 255, 0.12);
  border: 1px solid rgba(103, 217, 255, 0.28);
  border-radius: 6px;
  padding: 0.05rem 0.3rem;
  color: #b9f6df;
}

.markdown-view pre {
  margin: 0.4rem 0 0.8rem;
  padding: 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(103, 217, 255, 0.22);
  background: rgba(9, 20, 27, 0.96);
  white-space: pre-wrap;
}

.markdown-view pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.markdown-view a {
  color: #67d9ff;
  text-decoration: none;
  border-bottom: 1px dashed rgba(103, 217, 255, 0.5);
}

.markdown-view a:hover {
  color: #9fecff;
}

.hidden {
  display: none;
}

.reveal-1,
.reveal-2,
.reveal-3,
.reveal-4,
.reveal-5,
.reveal-6 {
  animation: reveal 480ms ease both;
}

.reveal-2 { animation-delay: 80ms; }
.reveal-3 { animation-delay: 130ms; }
.reveal-4 { animation-delay: 180ms; }
.reveal-5 { animation-delay: 230ms; }
.reveal-6 { animation-delay: 280ms; }

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .grid-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero {
    flex-direction: column;
  }
  .hero-meta {
    text-align: left;
  }
  .grid-cards {
    grid-template-columns: 1fr;
  }
}

/* === Director — Human Directive panel === */
.director .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.director-hint {
  margin: 6px 0 14px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.director-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 68px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(6, 15, 20, 0.6);
  color: var(--text);
  font-family: "Rajdhani", system-ui, sans-serif;
  font-size: 0.98rem;
  line-height: 1.45;
}

.director-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(103, 217, 255, 0.18);
}

.director-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.director-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}

.director-actions .muted {
  font-size: 0.82rem;
}

.panel-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-toggle {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  line-height: 1;
  cursor: pointer;
  font-size: 0.8rem;
  transition: transform 140ms ease, background 140ms ease;
}

.collapse-toggle[aria-expanded="true"] {
  transform: rotate(90deg);
  background: rgba(255, 255, 255, 0.1);
}

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 6px;
  height: 26px;
  padding: 0 10px;
  line-height: 1;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 140ms ease;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.collapsible.collapsed {
  display: none;
}

.collapse-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-head .collapse-toggle {
  width: 22px;
  height: 22px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.settings-label code {
  font-size: 0.72rem;
  opacity: 0.6;
}

.settings-row input[type="text"] {
  flex: 0 0 auto;
  width: 240px;
  max-width: 45%;
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
}

.settings-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent, #4ade80);
}

.director-current {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(151, 215, 239, 0.14);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}

.director-current-text {
  flex-basis: 100%;
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(6, 15, 20, 0.5);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  max-height: 320px;
  overflow-y: auto;
}

.director-templates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  font-size: 0.82rem;
}

.tpl-btn-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tpl-btn {
  font-family: "Rajdhani", system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(151, 215, 239, 0.28);
  background: rgba(151, 215, 239, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tpl-btn:hover {
  background: rgba(151, 215, 239, 0.18);
  border-color: rgba(151, 215, 239, 0.5);
}

.badge {
  font-family: "Rajdhani", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
}

.badge-none {
  color: var(--muted);
  border-color: rgba(156, 184, 198, 0.4);
}

.badge-pending {
  color: var(--amber);
  border-color: rgba(247, 166, 65, 0.6);
  background: rgba(247, 166, 65, 0.12);
}

.badge-done {
  color: var(--good);
  border-color: rgba(41, 211, 163, 0.6);
  background: rgba(41, 211, 163, 0.12);
}

/* === Cost & Credits panel === */
.cost .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cost-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 640px) {
  .cost-grid { grid-template-columns: repeat(2, 1fr); }
}

.cost-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(6, 15, 20, 0.5);
  border: 1px solid rgba(151, 215, 239, 0.14);
}

.cost-num {
  font-family: "Rajdhani", system-ui, sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.cost-stat .muted {
  font-size: 0.78rem;
}

.cost-foot {
  margin-top: 14px;
  font-size: 0.82rem;
}
.cost-foot b { color: var(--text); font-weight: 700; }
