/* HarveyOS UI — MDH "Deep Space" tokens (source: ~/themes/mdh-design-tokens.css) */
:root {
  --bg-app: #08080C; --bg-surface: #111116; --bg-raised: #16161D;
  --border-subtle: #2A2A35; --border-focus: #9D4EDD;
  --text-main: #F5F5F5; --text-dim: #A1A1AA;
  --plum: #9D4EDD; --cyan: #00F5FF; --mint: #00FF9D; --crimson: #F0283A;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg-app); color: var(--text-main);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem; background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text-main); letter-spacing: .5px; }
.brand span, .plum { color: var(--plum); }
.topbar nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.topbar nav a {
  color: var(--text-dim); padding: .35rem .65rem; border-radius: 8px; font-size: .92rem;
}
.topbar nav a.on, .topbar nav a:hover {
  color: var(--text-main); background: var(--bg-raised); text-decoration: none;
}
.topbar nav a.on { box-shadow: inset 0 -2px 0 var(--plum); }

main { max-width: 1280px; margin: 0 auto; padding: 1.1rem 1.2rem; }
h1 { font-size: 1.4rem; margin: .6rem 0 1rem; }
h2 { font-size: 1.02rem; margin: 0 0 .6rem; }
.dim { color: var(--text-dim); font-weight: 400; }

.card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 1rem; margin-bottom: 1rem;
}
.card.hero { border-color: var(--plum); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

.statrow { display: flex; gap: .7rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: .6rem 1rem; min-width: 108px;
}
.stat b { font-size: 1.35rem; display: block; }
.stat span { color: var(--text-dim); font-size: .8rem; }
.stat.ok b { color: var(--mint); }
.stat.bad b { color: var(--crimson); }

.row { padding: .5rem 0; border-bottom: 1px solid var(--border-subtle); }
.row:last-child { border-bottom: none; }
.row.bad { border-left: 3px solid var(--crimson); padding-left: .5rem; }
.cardmeta { color: var(--text-dim); font-size: .78rem; margin-top: .25rem; }

.tag {
  display: inline-block; font-size: .72rem; padding: .1rem .45rem;
  border: 1px solid var(--border-subtle); border-radius: 6px;
  color: var(--text-dim); margin-right: .3rem; vertical-align: middle;
}
.risk-observe { color: var(--mint); border-color: var(--mint); }
.risk-draft { color: var(--cyan); border-color: var(--cyan); }
.risk-apply_with_approval { color: var(--plum); border-color: var(--plum); }
.risk-guarded_autopilot { color: #f5c542; border-color: #f5c542; }
.risk-never_auto { color: var(--crimson); border-color: var(--crimson); }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: .78rem;
     border-bottom: 1px solid var(--border-subtle); padding: .35rem .4rem; }
td { padding: .45rem .4rem; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
tr:last-child td { border-bottom: none; }

.okc { color: var(--mint); } .errc { color: var(--crimson); } .warnc { color: #f5c542; }
.err { color: var(--crimson); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem;
        white-space: pre-wrap; word-break: break-word; }
pre.mono { background: var(--bg-app); border: 1px solid var(--border-subtle);
           border-radius: 8px; padding: .6rem; overflow-x: auto; max-height: 320px; }
.md { font-size: .92rem; }

button, input {
  font: inherit; border-radius: 8px; border: 1px solid var(--border-subtle);
  background: var(--bg-raised); color: var(--text-main); padding: .45rem .8rem;
}
input:focus { outline: none; border-color: var(--border-focus); }
button { cursor: pointer; }
.btn-primary { background: var(--plum); border-color: var(--plum); color: #fff; font-weight: 600; }
.btn-secondary { background: transparent; border-color: var(--cyan); color: var(--cyan); }
.btn-danger { background: transparent; border-color: var(--crimson); color: var(--crimson); }
.btn-mini { font-size: .78rem; padding: .2rem .5rem; }
.inline-form { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }

.login-wrap { display: flex; justify-content: center; padding-top: 14vh; }
.login-card { width: 320px; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: .7rem; margin-top: 1rem; }

.foot { text-align: center; color: var(--text-dim); font-size: .78rem; padding: 1.2rem; }
details summary { cursor: pointer; color: var(--text-dim); }

/* ---------- wave 2: chat ---------- */
.chat-layout { display: grid; grid-template-columns: 320px minmax(0,1fr); gap: 1.1rem; align-items: start; }
@media (max-width: 760px) { .chat-layout { grid-template-columns: 1fr; } .chat-threads { order: 2; } }
.chat-threads .thread { display: block; padding: .45rem .5rem; border-radius: 8px;
  color: var(--text-main); font-size: .85rem; margin-top: .4rem; }
.chat-threads .thread span { display: block; font-size: .72rem; }
.chat-threads .thread.on, .chat-threads .thread:hover { background: var(--bg-raised); text-decoration: none; }
.chat-main { display: flex; flex-direction: column; min-height: 62vh; }
.chatlog { flex: 1; overflow-y: auto; max-height: 58vh; padding-right: .3rem; }
.msg { margin: .5rem 0; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg .bubble { max-width: 82%; padding: .55rem .8rem; border-radius: 12px;
  background: var(--bg-raised); border: 1px solid var(--border-subtle); font-size: .92rem; }
.msg.user .bubble { background: rgba(157, 78, 221, .16); border-color: var(--plum); }
.chatbar { display: flex; gap: .5rem; margin-top: .8rem; }
.model-pick { max-width: 210px; font-size: .78rem; color: var(--text-dim); }

/* ---------- palette (cmd-K) ---------- */
.palette-overlay { position: fixed; inset: 0; background: rgba(4,4,8,.72);
  backdrop-filter: blur(3px); z-index: 100; display: flex; justify-content: center; }
.palette-overlay[hidden] { display: none !important; }  /* author display beats [hidden] otherwise */
.palette-box { margin-top: 12vh; width: min(640px, 92vw); height: fit-content;
  background: var(--bg-surface); border: 1px solid var(--plum); border-radius: 14px;
  padding: .8rem; box-shadow: 0 18px 60px rgba(0,0,0,.6); }
.palette-box input { width: 100%; font-size: 1rem; padding: .6rem .8rem; }
.route-chip { display: inline-block; margin: .55rem 0 0; font-size: .78rem;
  padding: .25rem .6rem; border: 1px solid var(--border-subtle); border-radius: 999px; }
.pal-group { color: var(--text-dim); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; margin: .7rem 0 .2rem; }
.pal-item { display: block; padding: .35rem .5rem; border-radius: 8px; color: var(--text-main); font-size: .88rem; }
.pal-item:hover { background: var(--bg-raised); text-decoration: none; }
.palette-foot { font-size: .74rem; margin-top: .7rem; }

/* ---------- flightboard (mission board v2) ---------- */
.flightboard { background: linear-gradient(180deg, #07070B 0%, #0A0A10 100%);
  border-color: #23232e; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden; }
.fb-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: .6rem;
  border-bottom: 1px solid #1c1c26; padding-bottom: .45rem; }
.fb-title { color: var(--text-main); letter-spacing: .28em; font-size: .78rem; font-weight: 700; }
.fb-counts { font-size: .74rem; color: var(--text-dim); flex: 1; }
.fb-live { font-size: .72rem; color: var(--text-dim); }
.fb-live.on { color: var(--mint); animation: fbpulse 2s infinite; }
@keyframes fbpulse { 50% { opacity: .45; } }
.plum { color: var(--plum); }
.fb-cols { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 1.2rem; }
@media (max-width: 760px) { .fb-cols { grid-template-columns: minmax(0,1fr); } }
.fb-colhead { color: var(--text-dim); font-size: .66rem; letter-spacing: .22em;
  padding-bottom: .3rem; margin-bottom: .25rem; }
.fb-colhead .dim { letter-spacing: 0; text-transform: none; font-size: .7rem; }
.fb-row { display: grid; grid-template-columns: 58px 92px minmax(0,1fr) auto;
  gap: .55rem; align-items: baseline; font-size: .76rem; padding: .22rem .35rem;
  border-radius: 6px; border-left: 2px solid transparent; color: var(--text-main);
  text-decoration: none; }
.fb-row:hover { background: rgba(157,78,221,.08); text-decoration: none; }
.fb-row.is-bad { border-left-color: var(--crimson); background: rgba(240,40,58,.05); }
.fb-row.is-live { border-left-color: #f5c542; }
.fb-time { color: #6b6b78; font-size: .7rem; }
.fb-key { color: var(--cyan); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-obj { color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fb-status { font-size: .62rem; padding: .05rem .35rem; border-radius: 4px;
  border: 1px solid; justify-self: end; }
.fb-ok { color: var(--mint); border-color: rgba(0,255,157,.4); }
.fb-failed, .fb-blocked { color: var(--crimson); border-color: var(--crimson); }
.fb-running { color: #f5c542; border-color: #f5c542; animation: fbpulse 1.2s infinite; }
.fb-partial, .fb-skipped { color: var(--text-dim); border-color: var(--border-subtle); }
.fb-claude-strip { display: block; margin-top: .5rem; color: var(--plum); font-size: .76rem;
  border-top: 1px dashed #1c1c26; padding-top: .4rem; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  animation: fbpulse 1.6s infinite; }

/* role grid on models page */
.role-grid { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.role-grid label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--text-dim); }

/* ---------- wave 3: agent/skill forge ---------- */
.stack-form { display: flex; flex-direction: column; gap: .5rem; }
.stack-form textarea { font: inherit; border-radius: 8px; border: 1px solid var(--border-subtle);
  background: var(--bg-raised); color: var(--text-main); padding: .45rem .8rem; resize: vertical; }
.stack-form textarea:focus { outline: none; border-color: var(--border-focus); }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .15rem; margin-top: .4rem; }
.tool-check { font-size: .78rem; color: var(--text-dim); display: flex; gap: .35rem; align-items: center; }
.tool-check input { padding: 0; }

/* palette close affordance */
.palette-top { display: flex; gap: .5rem; align-items: center; }
.palette-top input { flex: 1; }
.palette-close { background: transparent; border: none; color: var(--text-dim);
  font-size: 1.05rem; padding: .4rem .55rem; line-height: 1; border-radius: 8px;
  flex: 0 0 auto; align-self: center; }
.palette-close:hover { color: var(--text-main); background: var(--bg-raised); }

/* rendered-markdown typography (briefs, journals, chat) */
.md h1, .md h2, .md h3 { margin: .9rem 0 .35rem; }
.md h2 { font-size: .98rem; color: var(--cyan); border-bottom: 1px solid var(--border-subtle); padding-bottom: .2rem; }
.md h3 { font-size: .9rem; color: var(--text-dim); }
.md ul, .md ol { margin: .3rem 0 .6rem; padding-left: 1.3rem; }
.md li { margin: .15rem 0; }
.md p { margin: .4rem 0; }
.md code { background: var(--bg-app); border: 1px solid var(--border-subtle);
  border-radius: 5px; padding: .05rem .35rem; font-size: .82em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--mint); }
.md blockquote { border-left: 3px solid var(--plum); margin: .5rem 0;
  padding: .2rem .8rem; color: var(--text-main); background: var(--bg-raised);
  border-radius: 0 8px 8px 0; }
.md strong { color: var(--text-main); }
.md table { margin: .5rem 0; }
.md hr { border: none; border-top: 1px solid var(--border-subtle); margin: .8rem 0; }


/* roster/library rows work inside any card, not just .chat-threads */
.card .thread { display: block; padding: .5rem .6rem; border-radius: 8px;
  color: var(--text-main); font-size: .9rem; margin-top: .35rem;
  border: 1px solid transparent; }
.card .thread span { display: block; font-size: .74rem; color: var(--text-dim); margin-top: .12rem; }
.card .thread.on { background: var(--bg-raised); border-color: var(--plum); }
.card .thread:hover { background: var(--bg-raised); text-decoration: none; }

/* forge forms: comfortable, not cramped */
.stack-form input, .stack-form textarea, .stack-form select {
  font-size: .95rem; padding: .55rem .8rem; width: 100%; }
.stack-form button { padding: .6rem 1rem; font-size: .95rem; }
.tool-grid { grid-template-columns: 1fr 1fr; gap: .3rem .8rem; padding: .4rem 0; }
.tool-check { font-size: .82rem; }

/* the 3 things + needle chips */
.thing { padding: .7rem 0; border-bottom: 1px solid var(--border-subtle); }
.thing:last-of-type { border-bottom: none; }
.thing-headline { font-size: 1.05rem; font-weight: 650; margin-bottom: .15rem; }
.prio-chip { background: rgba(157,78,221,.12); border: 1px solid var(--plum);
  color: var(--text-main); border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; }
.prio-chip:hover { background: rgba(240,40,58,.15); border-color: var(--crimson); text-decoration: line-through; }
