/* Edgemode Agent: deep-navy control-room palette with an electric cobalt accent (same as Code Studio) */
:root {
  --bg: #0c1018; --panel: #121826; --panel2: #182033; --line: #243049; --fg: #e4e9f4; --muted: #8b97b0;
  --accent: #4c7dff; --accent2: #6b93ff; --ok: #2fd27a; --bad: #ff4d5e; --warn: #ffb648; --code: #0a0e16;
  --mono: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
a { color: var(--accent2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pre { white-space: pre-line; }
.spacer { flex: 1; }
.grow { flex: 1; }
.r { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- buttons & inputs ---------- */
.btn { background: var(--panel2); color: var(--fg); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 14px; cursor: pointer; font: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent2); }
.btn.danger { color: var(--bad); }
.btn.ok { background: #16794a; border-color: #1f9a5f; color: #fff; font-weight: 600; }
.btn.small { padding: 2px 9px; font-size: 12px; font-weight: 500; }
.btn.wide { width: 100%; justify-content: center; }
.icon-btn { background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: 7px;
  padding: 5px 8px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { color: var(--fg); border-color: var(--line); }
input, select, textarea { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; font: inherit; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: inherit; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--fg); font-weight: 400; font-size: 14px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; font-weight: 400; }
label.check input { width: auto; margin: 0; }

/* ---------- sidebar ---------- */
#side { width: 260px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 12px; gap: 10px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 4px 6px; }
.mark, .welcome-mark { background: var(--accent); color: #fff; font-weight: 800; border-radius: 8px;
  width: 34px; height: 34px; display: grid; place-items: center; font-size: 18px; }
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 10px; letter-spacing: 2px; }
.side-label { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 1px; margin: 6px 4px 0; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.chat-item { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 7px; cursor: pointer;
  color: var(--muted); }
.chat-item:hover { background: var(--panel2); color: var(--fg); }
.chat-item.active { background: var(--panel2); color: var(--fg); box-shadow: inset 2px 0 0 var(--accent); }
.chat-item .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-item .del { visibility: hidden; background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 2px; }
.chat-item:hover .del { visibility: visible; }
.chat-item .del:hover { color: var(--bad); }
.chat-item .spin { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.nav { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
.nav-btn { background: none; border: none; color: var(--muted); text-align: left; padding: 8px 10px; border-radius: 7px;
  cursor: pointer; font: inherit; }
.nav-btn:hover { color: var(--fg); background: var(--panel2); }
.nav-btn.active { color: var(--fg); background: var(--panel2); }
.acct { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); border-radius: 8px; padding: 8px 10px; cursor: pointer; font: inherit; font-size: 12px; text-align: left; }
.acct span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); flex: none; box-shadow: 0 0 6px var(--bad); }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

/* ---------- views ---------- */
.view { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel); min-height: 56px; }
.topbar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.title-wrap { flex: 1; min-width: 120px; }
.title-input { background: transparent; border: 1px solid transparent; font-size: 15px; font-weight: 600; padding: 5px 8px; }
.title-input:hover { border-color: var(--line); }
.top-controls { display: flex; gap: 10px; align-items: center; }
.ctl { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.ctl select { margin: 0; width: auto; max-width: 330px; padding: 5px 8px; font-size: 13px; }
.mobile-only { display: none; }

.chat-body { flex: 1; display: flex; min-height: 0; }
.transcript-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.transcript { flex: 1; overflow-y: auto; padding: 22px max(20px, calc((100% - 860px) / 2)) 10px; }

/* ---------- messages ---------- */
.msg { margin: 0 0 16px; }
.msg.user { display: flex; justify-content: flex-end; }
.bubble { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; padding: 9px 14px;
  max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.bubble .files { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); }
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 0 0 4px; }
.msg.assistant .md { overflow-wrap: anywhere; }
.reasoning { border-left: 2px solid var(--line); margin: 0 0 8px; padding: 0 0 0 10px; color: var(--muted); font-size: 13px; }
.reasoning summary { cursor: pointer; user-select: none; }
.reasoning .rbody { white-space: pre-wrap; max-height: 260px; overflow-y: auto; margin-top: 4px; }
.notice { color: var(--muted); font-size: 13px; text-align: center; margin: 4px 0 14px; }
.errorbox { background: rgba(255,77,94,.08); border: 1px solid rgba(255,77,94,.35); color: #ffc2c8; border-radius: 9px;
  padding: 9px 12px; margin: 0 0 14px; }
.errorbox a { color: #fff; }
.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 3px; background: var(--muted); border-radius: 50%;
  animation: pulse 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* tool cards */
.tool { border: 1px solid var(--line); border-radius: 9px; margin: 0 0 10px; background: var(--panel); overflow: hidden; }
.tool > summary { list-style: none; cursor: pointer; padding: 7px 11px; display: flex; gap: 8px; align-items: center; font-size: 13px; }
.tool > summary::-webkit-details-marker { display: none; }
.tool .ti { width: 18px; text-align: center; }
.tool .tn { font-family: var(--mono); color: var(--accent2); }
.tool .ta { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
.tool .ts { font-size: 11px; color: var(--muted); }
.tool.done .ts { color: var(--ok); } .tool.error .ts, .tool.denied .ts { color: var(--bad); }
.tool.running .ti { animation: pulse 1s infinite; }
.tool .tbody { border-top: 1px solid var(--line); padding: 8px 11px; }
.tool pre { margin: 6px 0 0; }
.tool.waiting { border-color: var(--warn); box-shadow: 0 0 0 1px rgba(255,182,72,.25); }

.approval { border: 1px solid var(--warn); border-radius: 10px; background: #1a1a14; padding: 12px 14px; margin: -4px 0 14px; }
.approval .ah { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.approval .ar { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.approval .preview { max-height: 380px; overflow: auto; }
.approval .buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.approval .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* markdown */
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 8px; line-height: 1.3; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
.md blockquote { border-left: 3px solid var(--line); margin: 0 0 10px; padding: 0 12px; color: var(--muted); }
.md table { border-collapse: collapse; margin: 0 0 10px; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 9px; }
.md th { background: var(--panel2); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.codeblock { position: relative; margin: 0 0 10px; }
.md pre code, pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; }
.codeblock .lang { position: absolute; top: 6px; left: 10px; font-size: 11px; color: var(--muted); }
.codeblock .copy { position: absolute; top: 4px; right: 6px; }
pre { background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 26px 12px 10px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.45; margin: 0; white-space: pre; }
pre.plain { padding-top: 10px; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow-y: auto; }
.d-add { color: #7ee2a8; background: rgba(47,210,122,.08); display: block; }
.d-del { color: #ff9aa4; background: rgba(255,77,94,.08); display: block; }
.d-hunk { color: var(--accent2); display: block; }
.tok-k { color: #c792ea; } .tok-s { color: #c3e88d; } .tok-c { color: #6a7a96; font-style: italic; } .tok-n { color: #f78c6c; }

/* composer */
.composer { margin: 0 max(20px, calc((100% - 860px) / 2)) 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 10px 8px 12px; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { border: none; background: transparent; resize: none; max-height: 260px; padding: 6px 2px; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.attachments { display: flex; gap: 6px; flex-wrap: wrap; }
.attachments:not(:empty) { padding: 4px 0; }
.composer.drag { border-color: var(--accent); background: #131c30; }

/* welcome */
.welcome { position: absolute; inset: 0 0 110px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px; pointer-events: none; }
.welcome > * { pointer-events: auto; }
.welcome h1 { font-size: 24px; font-weight: 600; margin: 14px 0 6px; }
.welcome p { max-width: 560px; margin: 0 0 18px; }
.welcome-mark { width: 52px; height: 52px; font-size: 26px; border-radius: 13px; }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 640px; }
.ex { background: var(--panel); border: 1px solid var(--line); color: var(--fg); border-radius: 10px; padding: 10px 12px;
  text-align: left; cursor: pointer; font: inherit; font-size: 13px; }
.ex:hover { border-color: var(--accent); }

/* right panel */
.panel { width: 300px; flex: none; border-left: 1px solid var(--line); background: var(--panel); padding: 12px;
  display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.panel .card { padding: 10px 12px; }
.panel.collapsed { display: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel .card { background: var(--bg); }
.card.grow { flex: 1; min-height: 160px; display: flex; flex-direction: column; }
.card-h { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--muted); text-transform: uppercase;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-h .btn { text-transform: none; letter-spacing: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats .k { font-size: 11px; color: var(--muted); } .stats .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 4px; background: var(--panel2); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.meter div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.tasks div { padding: 2px 0; color: var(--fg); }
.tasks .done { color: var(--muted); text-decoration: line-through; }
.tasks .in_progress { color: var(--accent2); font-weight: 600; }
.changed div { font-family: var(--mono); font-size: 11.5px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 0; direction: rtl; text-align: left; }
.ws-path { margin-bottom: 4px; word-break: break-all; }
.ws-files { overflow-y: auto; flex: 1; }
.ws-files .f { display: flex; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 5px; cursor: pointer; }
.ws-files .f:hover { background: var(--panel2); }
.ws-files .f .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-files .f .s { color: var(--muted); font-size: 11px; }

/* pages */
.page { flex: 1; overflow-y: auto; padding: 20px max(20px, calc((100% - 1100px) / 2)); display: flex; flex-direction: column; gap: 14px; }
#dashBody { display: flex; flex-direction: column; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 1px; margin-bottom: 6px; }
.kpi { font-size: 28px; font-weight: 600; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.small-kpi { font-size: 18px; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 11px; font-weight: 600; letter-spacing: 0;
  text-transform: none; background: rgba(255,77,94,.15); color: var(--bad); margin-right: 4px; }
.pill.ok { background: rgba(47,210,122,.14); color: var(--ok); }
.pill.warn { background: rgba(255,182,72,.14); color: var(--warn); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 6px 8px; border-bottom: 1px solid #1a2236; vertical-align: top; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; font-weight: 500; }
.settings h3 { margin: 0 0 4px; font-size: 14px; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 8px; }
.login-grid label { margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.form-grid label:has(textarea) { grid-column: 1 / -1; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; margin: 0; border-top: 1px solid var(--line); z-index: 2; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 16px; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: 80vw; }
.toast.bad { border-color: var(--bad); }

@media (max-width: 1100px) { .panel { display: none; } .panel.open { display: flex; position: absolute; right: 0; top: 56px; bottom: 0; z-index: 5; } }
@media (max-width: 800px) {
  #side { position: fixed; z-index: 10; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  #side.open { transform: none; }
  .mobile-only { display: inline-block; }
  .ctl span { display: none; }
  .grid3, .login-grid, .form-grid, .examples { grid-template-columns: 1fr; }
}

/* "+" media / documents in the prompt */
.plus-btn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2);
  color: var(--fg); font-size: 20px; line-height: 26px; padding: 0; cursor: pointer; flex: none; }
.plus-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent2); }
.plus-btn:disabled { opacity: .35; cursor: not-allowed; }
.mm-badge { font-size: 11px; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); white-space: nowrap; }
.mm-badge.mm { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.mm-badge.txt { color: var(--muted); }
.mchips { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.mchip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 3px 6px; font-size: 12px; color: var(--fg); }
.mchip img { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; }
.mchip .mi { font-size: 18px; }
.mchip .mn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mchip button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 2px; }
.mchip.busy { opacity: .55; }
.msent { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.msent img { max-width: 180px; max-height: 140px; border-radius: 8px; border: 1px solid var(--line); display: block; }
