:root {
  --bg: #0a0e0a;
  --bg-desk: #04070a;
  --bg-panel: #060a06;
  --fg: #c8e6c8;
  --fg-dim: #6a8a6a;
  --accent: #7af07a;
  --accent-glow: rgba(122, 240, 122, 0.35);
  --warn: #f0b97a;
  --err: #f07a7a;
  --panel: #0b140b;
  --panel-sel: #16281a;
  --rule: #1c3a1c;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  background: var(--bg-desk);
  color: var(--fg);
  margin: 0;
  padding: 0;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code",
               "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at top, rgba(10,30,10,0.6) 0%, transparent 60%),
    radial-gradient(ellipse at bottom, rgba(0,15,0,0.4) 0%, transparent 60%);
}

#desk {
  max-width: 1360px;
  margin: 28px auto;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.4),
    0 20px 60px rgba(0,0,0,0.6),
    0 0 40px rgba(122,240,122,0.04);
  overflow: hidden;
}

#desk-chrome {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  padding: 8px 14px;
  border-bottom: 1px solid var(--rule);
  color: var(--fg-dim);
  font-size: 12px;
}
.desk-dots { display: flex; gap: 6px; }
.desk-dots .dot { width: 11px; height: 11px; border-radius: 50%; background: #2a2a2a; }
.desk-dots .dot.red    { background: #e14545; }
.desk-dots .dot.yellow { background: #e1a645; }
.desk-dots .dot.green  { background: #45c745; }
.desk-title {
  flex: 1;
  text-align: center;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.desk-session {
  color: var(--fg-dim);
  font-size: 11.5px;
  min-width: 14ch;
  text-align: right;
}

/* -------- 3-column grid: scenarios | terminal | mission image -------- */

#desk-grid {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 0;
  height: 78vh;
  min-height: 0;
}

#side-scenarios,
#side-mission {
  background: var(--bg-panel);
  padding: 14px 14px 12px 14px;
  display: flex;
  flex-direction: column;
}

#side-scenarios { border-right: 1px solid var(--rule); }
#side-mission   { border-left: 1px solid var(--rule); }

.side-head {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.scenario-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
}

.scenario-card {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--rule);
  padding: 8px 10px;
  text-align: left;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  border-radius: 2px;
  transition: background 80ms linear, border-color 80ms linear;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scenario-card:hover,
.scenario-card:focus {
  background: #121a12;
  border-color: var(--accent);
  outline: none;
}
.scenario-card.selected {
  background: var(--panel-sel);
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.scenario-card.active {
  background: var(--panel-sel);
  border-color: var(--accent);
  border-left: 2px solid var(--accent);
}
.scenario-card .scenario-title {
  color: var(--accent);
  font-size: 12.5px;
  line-height: 1.3;
}
.scenario-card .scenario-meta {
  color: var(--fg-dim);
  font-size: 10.5px;
  letter-spacing: 0.3px;
  text-transform: lowercase;
  margin-top: 2px;
}

.side-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  display: flex;
  gap: 6px;
}
.start-btn,
.end-btn {
  flex: 1;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 7px 0;
  font: inherit;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  transition: background 80ms linear, color 80ms linear;
}
.start-btn:disabled,
.end-btn:disabled {
  color: var(--fg-dim);
  border-color: var(--rule);
  cursor: not-allowed;
}
.start-btn:not(:disabled):hover,
.end-btn:not(:disabled):hover {
  background: var(--accent);
  color: var(--bg);
}
.end-btn { color: var(--warn); border-color: var(--warn); }
.end-btn:not(:disabled):hover { background: var(--warn); color: var(--bg); }
.end-btn:disabled { color: var(--fg-dim); border-color: var(--rule); }

/* -------- center: terminal -------- */

#main-terminal {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  min-height: 0;
  overflow: hidden;
}

#terminal-head {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--fg-dim);
  font-size: 12.5px;
  padding: 0 2px 10px 2px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 12px;
}
#terminal-head .ind {
  width: 8px;
  height: 8px;
  background: var(--rule);
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 150ms linear, box-shadow 150ms linear;
}
#terminal-head .ind.live {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
#terminal-head .t-title { color: var(--accent); font-weight: 600; }
#terminal-head .t-note {
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 11.5px;
  font-style: italic;
}

#output {
  flex: 1;
  min-height: 0;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 2px 2px 10px 2px;
  overflow-y: auto;
}
#output .user      { color: var(--fg); }
#output .user::before { content: "$ "; color: var(--accent); }
#output .assistant { color: var(--fg); }
#output .system    { color: var(--fg-dim); font-style: italic; }
#output .err       { color: var(--err); }
#output .turn      { margin-bottom: 12px; }
#output .pending   {
  color: var(--accent);
  animation: pending-blink 1.6s ease-in-out infinite;
  letter-spacing: 1.5px;
  font-style: italic;
}
#output .pending::after {
  content: "...";
  display: inline-block;
  margin-left: 2px;
  animation: pending-dots 1.6s steps(4, end) infinite;
  width: 2ch;
  overflow: hidden;
  vertical-align: bottom;
}
@keyframes pending-blink {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1.0; }
}
@keyframes pending-dots {
  0%   { width: 0; }
  25%  { width: 0.6ch; }
  50%  { width: 1.2ch; }
  75%  { width: 1.8ch; }
  100% { width: 2.4ch; }
}

#input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--rule);
  padding: 8px 2px 2px 2px;
  margin-top: 6px;
  flex-shrink: 0;
}
.prompt { color: var(--accent); font-weight: bold; }
#input {
  flex: 1;
  background: transparent;
  color: var(--fg);
  border: none;
  outline: none;
  font: inherit;
}
#input:disabled { opacity: 0.4; }

/* -------- right: mission image panel -------- */

.mission-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
  position: relative;
}
.mission-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mission-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  text-align: center;
  padding: 20px;
  gap: 12px;
}
.placeholder-glyph {
  font-size: 48px;
  color: var(--rule);
  opacity: 0.6;
}
.placeholder-label {
  font-size: 11.5px;
  text-transform: lowercase;
  letter-spacing: 0.3px;
}

.mission-meta {
  color: var(--fg-dim);
  font-size: 11.5px;
  padding: 8px 2px 0 2px;
  border-top: 1px solid var(--rule);
}
.mission-meta .meta-title {
  color: var(--accent);
  font-size: 12.5px;
  margin-bottom: 4px;
}

@media (max-width: 1024px) {
  #desk-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  #side-scenarios,
  #side-mission { border: none; border-bottom: 1px solid var(--rule); }
  #main-terminal { min-height: 60vh; overflow: visible; }
}
