:root {
  --bg: #0c1017;
  --panel: #131a24;
  --panel2: #1a2331;
  --border: #263243;
  --text: #dbe4f0;
  --muted: #7d8ca0;
  --accent: #e8a33d;
  --green: #4cc38a;
  --red: #e5534b;
  --blue: #539bf5;
  --purple: #b083f0;
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px; min-height: 100vh;
}
.hidden { display: none !important; }
.sub { color: var(--muted); font-size: 12px; }
.error { color: var(--red); min-height: 1em; }

/* login */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 40px; text-align: center; width: 340px; }
.login-box h1 { margin-bottom: 8px; }
.login-box p { color: var(--muted); margin-bottom: 16px; }
.login-box input { width: 100%; margin-bottom: 12px; }

/* header */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 16px; }
.brand .sub { margin-left: 10px; }
nav button {
  background: none; border: none; color: var(--muted); font: inherit;
  padding: 8px 16px; cursor: pointer; border-radius: 6px;
}
nav button.active { color: var(--accent); background: var(--panel2); }
nav button:hover { color: var(--text); }
.header-right { display: flex; align-items: center; gap: 12px; }
#logout { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }

/* generic */
main.view { padding: 20px; max-width: 1500px; margin: 0 auto; }
input, textarea, select, button {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
button { cursor: pointer; }
button[type=submit] { background: var(--accent); color: #14100a; font-weight: 600; border: none; }
button[type=submit]:hover { filter: brightness(1.1); }

/* board */
.board-toolbar { margin-bottom: 16px; }
.stats { display: flex; gap: 18px; color: var(--muted); flex-wrap: wrap; }
.stats b { color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.card.hot { border-color: #3d5270; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-head h3 { font-size: 15px; }
.card-head h3 a { color: var(--text); text-decoration: none; }
.card-head h3 a:hover { color: var(--accent); }
.stage { font-size: 11px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.stage-deployed { background: #10301f; color: var(--green); }
.stage-active { background: #10233c; color: var(--blue); }
.stage-working { background: #2b2338; color: var(--purple); }
.stage-dormant, .stage-archived, .stage-idea { background: #262b33; color: var(--muted); }
.card .desc { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.card .gitline { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; }
.flag { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: #33231a; color: var(--accent); }
.flag.bad { background: #391f1e; color: var(--red); }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.card-foot .age { font-size: 11.5px; color: var(--muted); }
.card-foot button { font-size: 12px; padding: 4px 10px; }

/* arena */
.arena-layout { display: grid; grid-template-columns: 420px 1fr; gap: 20px; }
@media (max-width: 980px) { .arena-layout { grid-template-columns: 1fr; } }
.arena-left h2 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 10px; }
#mission-form { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
#mission-form .row { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.mission-list { display: flex; flex-direction: column; gap: 8px; }
.mission-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px;
}
.mission-item:hover, .mission-item.selected { border-color: var(--accent); }
.mstatus { font-size: 11px; padding: 2px 8px; border-radius: 10px; align-self: center; white-space: nowrap; }
.mstatus-queued { background: #33301a; color: #d9c34a; }
.mstatus-running { background: #10233c; color: var(--blue); animation: pulse 1.5s infinite; }
.mstatus-done { background: #10301f; color: var(--green); }
.mstatus-failed, .mstatus-cancelled { background: #391f1e; color: var(--red); }
@keyframes pulse { 50% { opacity: 0.55; } }
.mission-detail { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-height: 400px; }
.mission-detail h3 { margin-bottom: 6px; }
.mission-detail .meta { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.event-log { background: #0a0e14; border: 1px solid var(--border); border-radius: 8px; padding: 12px; max-height: 55vh; overflow-y: auto; font-size: 12.5px; line-height: 1.5; }
.ev { margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.ev .t { color: var(--muted); margin-right: 8px; }
.ev-tool { color: var(--blue); }
.ev-status { color: var(--accent); }
.ev-log { color: var(--text); }
.result-box { margin-top: 12px; background: var(--panel2); border-radius: 8px; padding: 12px; white-space: pre-wrap; font-size: 13px; }
.detail-actions { margin-top: 10px; display: flex; gap: 8px; }

/* maestro */
.chat { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 110px); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 10px 4px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: #23364f; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }
.msg.assistant.thinking { color: var(--muted); font-style: italic; }
.chat-input { display: flex; gap: 10px; padding: 12px 0; }
.chat-input textarea { flex: 1; resize: none; }
