/* Hermes-Dev — dark, dense, monospace-accented. Its own token set (not the AI OS dashboard's). */
:root {
  --bg: #08090c;
  --bg-1: #0e1015;
  --bg-2: #14171e;
  --bg-3: #1b1f28;
  --line: #232835;
  --line-2: #2e3444;
  --text: #e8ebf2;
  --text-2: #a9b0c0;
  --text-3: #6f788c;
  --accent: #4f6bff;
  --accent-2: #8197ff;
  --accent-bg: rgba(79, 107, 255, 0.14);
  --ok: #3ccf8e;
  --warn: #f2b84b;
  --bad: #ff5d6c;
  --info: #57b6ff;
  --radius: 8px;
  --radius-sm: 5px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-bg); }

/* ---------- primitives ---------- */
.label { font: 600 10.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 6px 0 0; font-size: 12.5px; }
.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--text-3); }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .mission:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #3d58f0; border-color: #3d58f0; }
.btn-danger { color: var(--bad); border-color: rgba(255, 93, 108, 0.4); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-2); }
.btn-block { width: 100%; justify-content: center; height: 36px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 7px 9px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-narrow { flex: 0 0 130px !important; }
.check { display: flex; gap: 8px; align-items: center; margin: 0 0 4px; cursor: pointer; }
.check-hint { margin: 0 0 12px 24px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.pill { font: 600 10.5px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.st-researching, .st-planning, .st-building, .st-shipping { color: var(--info); border-color: rgba(87, 182, 255, 0.4); }
.st-awaiting_approval { color: var(--warn); border-color: rgba(242, 184, 75, 0.5); background: rgba(242, 184, 75, 0.08); }
.st-done { color: var(--ok); border-color: rgba(60, 207, 142, 0.4); }
.st-failed, .st-rejected { color: var(--bad); border-color: rgba(255, 93, 108, 0.4); }
.st-cancelled { color: var(--text-3); }

/* ---------- sign-in ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, rgba(79, 107, 255, 0.18), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login-card .muted { margin: 6px 0 22px; }

/* ---------- layout ---------- */
.app { display: grid; height: 100%; grid-template-columns: 280px minmax(0, 1fr) minmax(360px, 42%); grid-template-rows: 52px minmax(0, 1fr); grid-template-areas: "top top top" "side main pane"; }
.top { grid-area: top; display: flex; align-items: center; gap: 18px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.side { grid-area: side; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--bg-1); }
.main { grid-area: main; overflow: auto; padding: 18px 22px 40px; min-width: 0; }
.pane { grid-area: pane; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg-1); }

.brand { display: flex; align-items: center; gap: 8px; font: 700 13px/1 var(--mono); letter-spacing: 0.14em; white-space: nowrap; }
.brand-lg { font-size: 16px; }
.brand-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; background: var(--accent); color: #fff; letter-spacing: 0; font-size: 12px; }
.brand-slash { color: var(--accent-2); }
.project-switch { display: flex; align-items: center; gap: 8px; }
.project-switch select { width: auto; min-width: 140px; padding: 4px 8px; }
.credits { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.meter { width: 140px; height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--ok); transition: width 0.3s; }
.meter-fill.warn { background: var(--warn); }
.meter-fill.bad { background: var(--bad); }
.credits-num { font: 12px/1 var(--mono); color: var(--text-2); white-space: nowrap; }
.top-actions { display: flex; gap: 6px; flex-shrink: 0; }
/* The header is full at ~1100px since the Proposals button: drop the credits caption (the meter, its
   number and its tooltip stay) rather than let the page scroll sideways. */
@media (max-width: 1180px) and (min-width: 981px) {
  .top { gap: 12px; }
  .credits > .label { display: none; }
  #paletteBtn { display: none; }          /* Ctrl/⌘+K still opens the palette */
}
@media (max-width: 980px) {
  .top-actions { flex-wrap: wrap; flex-shrink: 1; min-width: 0; }
}

/* ---------- sidebar ---------- */
.search { margin: 12px 12px 8px; width: calc(100% - 24px) !important; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.chip { font: 600 11px/1 var(--mono); padding: 5px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2); cursor: pointer; }
.chip-on { background: var(--accent-bg); border-color: var(--accent); color: var(--text); }
.missions { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.mission { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 4px 10px; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.mission:hover { background: var(--bg-2); }
.mission.sel { background: var(--bg-3); border-color: var(--line-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--text-3); }
.dot.st-researching, .dot.st-planning, .dot.st-building, .dot.st-shipping { background: var(--info); box-shadow: 0 0 0 3px rgba(87, 182, 255, 0.15); }
.dot.st-awaiting_approval { background: var(--warn); box-shadow: 0 0 0 3px rgba(242, 184, 75, 0.2); }
.dot.st-done { background: var(--ok); }
.dot.st-failed, .dot.st-rejected { background: var(--bad); }
.mission-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.mission-sub { grid-column: 2; display: flex; gap: 8px; font: 11px/1.3 var(--mono); color: var(--text-3); }
.side-empty { padding: 18px 14px; color: var(--text-3); }

/* ---------- main ---------- */
.empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--text-2); max-width: 440px; margin: 0 auto; }
.empty-mark { font: 700 44px/1 var(--mono); color: var(--line-2); margin-bottom: 10px; }
.m-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 16px; }
.m-title-row { display: flex; align-items: center; gap: 12px; }
.m-title { font-size: 18px; line-height: 1.3; margin: 0; flex: 1; min-width: 0; }
.m-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font: 12px/1.4 var(--mono); color: var(--text-2); }
.m-meta b { color: var(--text-3); font-weight: 500; }
.m-actions { display: flex; gap: 6px; margin-top: 12px; }
.approval { border: 1px solid rgba(242, 184, 75, 0.45); background: rgba(242, 184, 75, 0.06); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; }
.approval-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.changes { margin-top: 10px; }
.section-label { font: 600 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin: 18px 0 10px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.ev { position: relative; padding: 0 0 12px 22px; border-left: 1px solid var(--line-2); margin-left: 4px; }
.ev:last-child { border-left-color: transparent; }
.ev::before { content: ""; position: absolute; left: -5px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line-2); }
.ev.ev-good::before { border-color: var(--ok); }
.ev.ev-bad::before { border-color: var(--bad); }
.ev.ev-wait::before { border-color: var(--warn); }
.ev.ev-run::before { border-color: var(--info); }
.ev-line { display: flex; gap: 10px; align-items: baseline; }
.ev-time { font: 11px/1.4 var(--mono); color: var(--text-3); white-space: nowrap; }
.ev-text { color: var(--text); }
.ev-detail { margin-top: 4px; font: 12px/1.45 var(--mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.runs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.run { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-1); cursor: pointer; }
.run:hover { border-color: var(--line-2); }
.run-kind { font: 600 10.5px/1 var(--mono); text-transform: uppercase; color: var(--text-3); }
.run-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-cost { font: 12px/1 var(--mono); color: var(--text-2); }

/* ---------- right pane ---------- */
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tab { font: 600 11.5px/1 var(--mono); letter-spacing: 0.04em; padding: 9px 12px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--text-3); cursor: pointer; }
.tab:hover { color: var(--text-2); }
.tab-on { color: var(--text); border-bottom-color: var(--accent); }
.pane-body { overflow: auto; padding: 16px 18px 40px; flex: 1; min-height: 0; min-width: 0; }
/* Grid and flex items default to min-width:auto, so one long log or diff line would widen the whole
   column and scroll the PAGE sideways. Zero it everywhere a wide <pre> can live. */
.pane, .main, .side, .md, .code, .stat { min-width: 0; }
.code, .md pre { max-width: 100%; }
.pane-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.pane-tools select { width: auto; }

.md { line-height: 1.6; }
.md h2, .md h3, .md h4, .md h5 { margin: 1.2em 0 0.5em; line-height: 1.3; }
.md h2 { font-size: 15px; } .md h3 { font-size: 14px; } .md h4, .md h5 { font-size: 13px; color: var(--text-2); }
.md p, .md ul, .md ol, .md blockquote { margin: 0 0 0.8em; }
.md ul, .md ol { padding-left: 1.3em; }
.md code { font: 12px/1.4 var(--mono); background: var(--bg-3); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--line-2); padding-left: 10px; color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--line); }

.code { font: 12px/1.5 var(--mono); white-space: pre; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 0; overflow: auto; }
.code .ln { display: block; padding: 0 12px; min-height: 1.5em; }
.diff .add { background: rgba(60, 207, 142, 0.1); color: #8ff0c1; }
.diff .del { background: rgba(255, 93, 108, 0.1); color: #ffa3ad; }
.diff .hunk { color: var(--accent-2); }
.diff .file { color: var(--text); font-weight: 700; background: var(--bg-3); }
.stat { font: 12px/1.5 var(--mono); color: var(--text-2); white-space: pre-wrap; margin: 0 0 12px; }
.note { padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); color: var(--text-2); }

/* ---------- dialogs ---------- */
.dialog { width: min(560px, calc(100vw - 32px)); background: var(--bg-1); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px; padding: 22px; }
.dialog::backdrop { background: rgba(4, 5, 8, 0.7); }
.dialog-title { margin: 0 0 16px; font-size: 16px; }

/* Goals & proposals (P4) */
.dialog-wide { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head .dialog-title { margin: 0; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font: 700 11px/1 var(--mono); }
.prop-draft { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.prop-draft select { width: auto; min-width: 0; }
.proposals, .goals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.proposal { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg-2); padding: 12px 14px; min-width: 0; }
.proposal-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 10px; }
.proposal-title { flex: 1 1 140px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.proposal-mission { margin: 8px 0 6px; overflow-wrap: anywhere; }
.proposal .muted { margin: 2px 0; overflow-wrap: anywhere; }
.goal { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; }
/* The text keeps at least ~140px: on a narrow screen the buttons wrap below it rather than squeezing
   it into a one-character column (a note row has a pill and two buttons). */
.goal { flex-wrap: wrap; }
.goal-text { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.goal-off { opacity: 0.55; }
.note-edit { flex-wrap: wrap; }
.note-edit input { flex: 1; min-width: 180px; }
.dismiss-why { flex-wrap: wrap; align-items: center; }
.goal-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.goal-form select { width: auto; min-width: 0; }
.goal-form input { flex: 1; min-width: 180px; }
.palette { padding: 0; width: min(620px, calc(100vw - 32px)); }
.palette-input { border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 12px 12px 0 0 !important; padding: 14px 16px !important; font-size: 14px; box-shadow: none !important; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.palette-item.on, .palette-item:hover { background: var(--bg-3); }
.palette-item .hint { font: 11.5px/1.4 var(--mono); color: var(--text-3); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--line-2); padding: 9px 14px; border-radius: var(--radius); opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; }
.toast.bad { border-color: var(--bad); }

/* ---------- narrow screens: one column, the pane under the mission ---------- */
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; grid-template-areas: "top" "side" "main" "pane"; height: auto; }
  .top { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .credits { margin-left: 0; }
  .side { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { padding: 16px; overflow: visible; }
  .pane { border-left: 0; border-top: 1px solid var(--line); min-height: 50vh; }
  .run { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .run .run-cost { display: none; }
}

/* Projects panel (O1) */
.badge-ok, .badge-warn { margin-left: 6px; padding: 0 7px; font-weight: 600; letter-spacing: .02em; }
.badge-ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.proj-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.proj-form .field-narrow { flex: 0 0 150px; }
.proj-form textarea, .proj-form input[type="text"] { width: 100%; box-sizing: border-box; }
.advanced textarea { width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 12px; margin-top: 6px; }
#projList code { font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .proj-form .field-row { flex-direction: column; } .proj-form .field-narrow { flex: 1 1 auto; } }
