/* Mandor: neutral greys with one blue accent. Green, amber and red only mark
   status (pills, tags, badges); Claude, agy and Devin are small colored dots.
   Light and dark follow the OS. The CSP allows no inline styles: every style
   lives here. */
:root {
  color-scheme: light;
  --bg: #f6f6f8; --card: #ffffff; --line: #e3e3e8; --text: #18181b; --muted: #5f5f6a;
  --accent: #2557d6; --accent-strong: #1d47b3; --accent-bg: #edf2fe; --on-accent: #ffffff;
  --ok: #157a3c; --ok-bg: #e9f8ef; --bad: #b42323; --bad-bg: #fdeeee;
  --warn: #8f520a; --warn-bg: #fdf4e3; --info: var(--accent); --info-bg: var(--accent-bg);
  --bar: #3f3f46; --bar-bg: #f0f0f3; --me: #edf2fe; --agent: #ffffff; --note: #fdf8ec;
  --screen-bg: #111114; --screen-fg: #e4e4e7;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05);
  --t-claude: #d97757; --t-agy: #0d9488; --t-devin: #7c3aed;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0d10; --card: #16161a; --line: #2a2a31; --text: #ececf1; --muted: #a3a3b0;
    --accent: #7aa2ff; --accent-strong: #a3bfff; --accent-bg: #1a2340; --on-accent: #0b1020;
    --ok: #5ad68a; --ok-bg: #11271a; --bad: #f58a8a; --bad-bg: #2e1616;
    --warn: #f2bd4b; --warn-bg: #2b2311;
    --bar: #d4d4d8; --bar-bg: #222228; --me: #1a2340; --agent: #16161a; --note: #26220f;
    --screen-bg: #08080a; --screen-fg: #e4e4e7;
    --shadow: none;
    --t-claude: #e08a6a; --t-agy: #2dd4bf; --t-devin: #a78bfa;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
a.block { display: block; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 14px; }
.num { font-variant-numeric: tabular-nums; }
.sprite { display: none; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { margin: 0; font-size: 20px; font-weight: 650; text-wrap: balance; }
h2 { margin: 0; font-size: 14px; font-weight: 600; text-wrap: balance; }
h3 { margin: 14px 0 6px; font-size: 13px; }

/* -- shell: sidebar + content ------------------------------------------------ */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px;
  padding: 16px 12px; background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.brand-text strong { font-size: 15px; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--text); color: var(--card); flex: none; }
.logo .ico { width: 22px; height: 22px; }
.nav-toggle { display: none; margin-left: auto; border: 0; background: none; color: var(--text); padding: 6px;
  border-radius: 8px; cursor: pointer; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 10px 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tabs button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; font: inherit; text-align: left;
  border: 0; background: none; color: var(--text); padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.tabs button:hover { background: var(--bg); }
.tabs button.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.tabs button span:first-of-type { flex: 1; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 10px 4px 0;
  border-top: 1px solid var(--line); color: var(--muted); }
button.link { display: inline-flex; align-items: center; gap: 8px; font: inherit; border: 0; background: none;
  color: inherit; padding: 6px 4px; border-radius: 6px; cursor: pointer; }
.side button.link:hover { color: var(--text); }
.side button.link.on { color: var(--accent); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--bar-bg);
  color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: center; }
.count:empty { display: none; }
.count.warn { background: var(--warn-bg); color: var(--warn); }

.content { min-width: 0; }
.content main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 32px; display: flex; flex-direction: column; gap: 16px; }
.tab { display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; }
.page-head .actions { margin: 0 0 0 auto; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; padding: 10px 12px; gap: 0; overflow: visible;
    border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .brand-text { flex-direction: row; align-items: center; gap: 8px; }
  .nav-toggle { display: block; }
  .tabs, .side-foot, .side-sessions { display: none; }
  body.nav-open .tabs { display: flex; padding-top: 10px; max-height: 70vh; overflow-y: auto; }
  body.nav-open .side-foot { display: flex; }
  body.nav-open .side-sessions { display: none !important; }
  body.sessions-open .tabs, body.sessions-open .side-foot { display: none !important; }
  body.sessions-open .side-sessions { display: flex !important; max-height: 75vh; overflow-y: auto; padding-top: 10px; }
  body.nav-open .side-backdrop, body.sessions-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 9; border: 0; background: rgba(0, 0, 0, .4); }
  .content main { padding: 16px; }
  #tab-home .page-head { display: none; }
}

/* -- common ------------------------------------------------------------------ */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; font-weight: 500;
  font-size: 12px; background: var(--bar-bg); color: var(--muted); white-space: nowrap; }
.pill::before, .tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok, .tag.done { background: var(--ok-bg); color: var(--ok); }
.pill.bad, .tag.failed { background: var(--bad-bg); color: var(--bad); }
.pill.warn, .tag.waiting { background: var(--warn-bg); color: var(--warn); }
.pill.info, .tag.running { background: var(--info-bg); color: var(--info); }
.tag.stopped { background: var(--bar-bg); color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 9px; border-radius: 999px;
  background: var(--bar-bg); color: var(--muted); white-space: nowrap; }
.tag.plain::before { display: none; }
.tool { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tool::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); flex: none; }
.tool.claude { --dot: var(--t-claude); }
.tool.agy { --dot: var(--t-agy); }
.tool.devin { --dot: var(--t-devin); }
.banner { margin: 16px 24px 0; padding: 10px 14px; border-radius: 8px; background: var(--info-bg); color: var(--info); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.info { background: var(--info-bg); color: var(--info); }
@media (max-width: 860px) { .banner { margin: 12px 16px 0; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0;
  box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head > :nth-child(2) { margin-left: auto; }
.card-head h2 + .muted { margin-left: 4px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bar { height: 6px; border-radius: 3px; background: var(--bar-bg); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--bar); opacity: .75; transition: width .4s; }
.bar span.hot { background: var(--bad); opacity: 1; }
.meter { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.meter + p { margin: 0 0 6px 72px; }
details.more { margin-top: 8px; }
details.more > summary { font-size: 12.5px; color: var(--muted); cursor: pointer; margin-bottom: 6px; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kind { display: inline-flex; gap: 6px; align-items: baseline; padding: 1px 8px; border-radius: 999px; background: var(--bar-bg); font-size: 12px; }
.kind-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.label { color: var(--muted); }
.prov { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; font-size: 11.5px;
  font-weight: 600; color: var(--muted); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.table-wrap { overflow-x: auto; margin: 0 -16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: var(--accent-bg); }
td.title-cell { white-space: normal; min-width: 180px; overflow-wrap: anywhere; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

/* -- home: chat beside a rail of status cards ---------------------------------- */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.rail { display: flex; flex-direction: column; gap: 16px; }
.rail .card { padding: 14px 16px; }
.list { display: flex; flex-direction: column; margin: 0 -16px -14px; }
.item { display: flex; flex-direction: column; gap: 3px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: 13px;
  text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; font: inherit; color: inherit; }
button.item { cursor: pointer; }
button.item:hover { background: var(--bg); }
.item .line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .line .right { margin-left: auto; }
.item.empty { color: var(--muted); }
@media (max-width: 1100px) { .home { grid-template-columns: 1fr; } }

.events { max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.ev { border-left: 3px solid var(--line); padding: 4px 10px; }
.ev-in { border-color: var(--info); }
.ev-out { border-color: var(--ok); }
.ev-say { border-color: var(--warn); }
.ev-head { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.ev-tool { font-family: var(--mono); color: var(--text); }
.ev-text, .ev-summary { white-space: pre-wrap; overflow-wrap: anywhere; }
.ev-summary { font-family: var(--mono); font-size: 12px; }
.ev-pre { margin: 4px 0 0; padding: 8px; background: var(--bar-bg); border-radius: 6px; white-space: pre-wrap;
  overflow-wrap: anywhere; font-size: 12px; max-height: 300px; overflow-y: auto; }
details summary { cursor: pointer; font-size: 12px; color: var(--muted); }

select { font: inherit; max-width: 100%; min-height: 32px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); }

.screen { margin: 0; padding: 12px; background: var(--screen-bg); color: var(--screen-fg); border-radius: 8px;
  font: 12px/1.35 var(--mono); overflow: auto; height: 72vh; white-space: pre; }
.screen-wrap { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.screen-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--bar-bg); font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--line); }
#selected-card .screen { height: auto; max-height: 48vh; border-radius: 0; }
.screen-badge { margin-left: 6px; font-size: 11px; vertical-align: middle; }

/* -- login page ------------------------------------------------------------------ */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 32px; max-width: 420px;
  width: 100%; text-align: center; box-shadow: var(--shadow); }
.login-box .logo { margin: 0 auto 12px; width: 44px; height: 44px; border-radius: 11px; }
.login-box .logo .ico { width: 28px; height: 28px; }
.login-box h1 { margin-bottom: 6px; }
.login-box .banner { margin: 12px 0; }
.widget { min-height: 48px; margin: 18px 0; display: flex; justify-content: center; }

/* -- buttons and forms ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font: inherit; font-size: 13px; font-weight: 500;
  padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 28px; padding: 0 10px; font-size: 12.5px; text-decoration: none; }
.btn .ico { width: 15px; height: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form input, .form textarea, .form select { font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); width: 100%; }
.form textarea { min-height: 70px; resize: vertical; font-family: var(--mono); font-size: 12px; }
.form textarea.json { min-height: 260px; }
.form .req > span::after { content: " *"; color: var(--bad); }   /* on the text: the label is a grid */
.tpl-desc { margin: 0; font-size: 12.5px; color: var(--muted); }
.err { color: var(--bad); white-space: pre-wrap; }
.okmsg { color: var(--ok); white-space: pre-wrap; }
.rules { margin: 4px 0 10px; padding: 8px; background: var(--bar-bg); border-radius: 6px; font: 12px/1.5 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 11.5px; padding: 0 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.audit { max-height: 40vh; }
.ev-deny { border-color: var(--bad); }
.ev-allow { border-color: var(--ok); }
.ev-admin { border-color: var(--info); }
.requests { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); }
.requests h3 { margin: 0 0 6px; font-size: 13px; color: var(--warn); }
.request { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 6px 0; border-top: 1px solid var(--line); }
.request:first-of-type { border-top: 0; }
.request > div:first-child { min-width: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
#vaultPanel .banner { margin: 0 0 8px; }
#vaultPanel h2 { margin-bottom: 8px; }
td .btn.small { margin-left: 6px; }
.form details.adv { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.form details.adv > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.form details.adv[open] > summary { margin-bottom: 10px; }

/* -- chat: conversation, tool activity, approvals --------------------------------- */
.chat-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 128px); min-height: 520px; }
.chat-card > * { flex: none; }
.chat-card > .chat { flex: 1 1 auto; min-height: 0; }
.chat-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--text); color: var(--card); }
.avatar.sm { width: 26px; height: 26px; border-radius: 7px; }
.avatar.sm .ico { width: 15px; height: 15px; }
.chat-who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.chat-status { font-size: 12px; color: var(--muted); }
.chat-status.info { color: var(--info); }
.chat-status.warn { color: var(--warn); font-weight: 600; }
.chat-status.bad { color: var(--bad); }
.chat-status.ok { color: var(--ok); }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
.chat { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.chat-empty { margin: auto; display: grid; gap: 4px; text-align: center; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.me { justify-content: flex-end; }
.bubble { max-width: min(78%, 720px); padding: 9px 12px; border-radius: 10px; background: var(--bar-bg); }
.msg.agent .bubble { background: var(--bar-bg); }
.msg.me .bubble { background: var(--me); }
.msg.note .bubble { background: var(--note); }
.msg.pending { opacity: .6; }
.bubble-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-text code { font: 12.5px var(--mono); padding: 1px 5px; border-radius: 4px; background: var(--card); }
.bubble-text pre.code { margin: 6px 0; padding: 10px 12px; border-radius: 8px; background: var(--screen-bg); color: var(--screen-fg);
  font: 12.5px/1.45 var(--mono); white-space: pre; overflow-x: auto; }
.file-link { display: inline-block; margin-top: 6px; font-size: 13px; }
.toolgroup { align-self: stretch; margin: 0 0 0 34px; padding: 6px 10px; border-radius: 8px; border-left: 2px solid var(--line); }
.toolgroup summary { font-size: 12.5px; }
.tool-row { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; font-size: 12.5px; min-width: 0; }
.tool-sum { color: var(--muted); font-family: var(--mono); overflow-wrap: anywhere; }
.typing { display: flex; align-items: center; gap: 4px; padding: 6px 16px 0; color: var(--muted); font-size: 12px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: dot 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.typing span { margin-left: 6px; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px 0; }
.chip { font: inherit; font-size: 12.5px; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--muted); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.composer { margin: 10px 16px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { display: block; width: 100%; resize: none; min-height: 44px; max-height: 200px; padding: 10px 12px 4px;
  border: 0; background: none; color: var(--text); font: inherit; }
.composer textarea:focus { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 4px 8px 8px; }
.attach { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--muted); cursor: pointer; }
.attach:hover { color: var(--text); background: var(--bar-bg); }
.attach input { display: none; }
.model-pick { position: relative; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border-radius: 999px; border: 0;
  background: var(--bar-bg); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.chip-btn .ico { width: 14px; height: 14px; }
.menu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 5; min-width: 220px; display: grid; padding: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); box-shadow: 0 6px 24px rgba(0, 0, 0, .12); }
.menu button { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.menu button:hover, .menu button.on { background: var(--bar-bg); }
.menu form { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.menu input { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--text); }
.send { margin-left: auto; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); cursor: pointer; }
#fileName, .chat-foot { margin: 0; padding: 0 16px 12px; }

.perm-dock { display: grid; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--warn-bg);
  max-height: 45%; overflow-y: auto; }
.perm-card { padding: 12px 14px; border-radius: 8px; background: var(--card); border: 1px solid var(--warn); }
.perm-card.allow { border-color: var(--ok); }
.perm-card.deny { border-color: var(--bad); }
.perm-card.gone { opacity: .7; border-color: var(--line); }
.perm-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.perm-head .ico { color: var(--warn); }
.perm-head .muted { margin-left: auto; }
.perm-desc { margin-top: 4px; }
.perm-input { margin: 8px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--screen-bg); color: var(--screen-fg);
  font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow-y: auto; }
.perm-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.perm-questions { display: grid; gap: 10px; margin-top: 8px; }
.perm-opts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* -- sidebar sessions -------------------------------------------------------- */
.side-sessions { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; margin-top: 4px; }
.side-sessions-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; gap: 6px; }
.side-sessions-title { display: flex; align-items: center; gap: 6px; }
.side-sessions-title strong { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.side-new-tray { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; background: var(--bar-bg); border-radius: 8px; }
.side-new-label { font-size: 11.5px; }
.side-project-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.side-sessions-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1 1 auto; min-height: 0; margin: 0 -4px; padding: 2px 4px; }
.side-empty { padding: 12px 6px; text-align: center; }

.session-row { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 7px 8px; border-radius: 7px;
  border: 1px solid transparent; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.session-row:hover { background: var(--bg); }
.session-row.active { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); font-weight: 500; }
.session-row-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.session-row-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.session-row.active .session-row-name { color: var(--accent); }
.session-row-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; min-width: 0; }
.session-row-time { margin-left: auto; flex: none; font-size: 11px; }
.session-state-pill { flex: none; font-size: 11px; padding: 0 6px; line-height: 1.4; gap: 4px; }
.session-state-pill .session-state-ico { font-style: normal; }

.proj-badge { display: inline-block; padding: 1px 5px; font-size: 11px; font-weight: 500; border-radius: 4px;
  background: var(--bar-bg); color: var(--muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-row.active .proj-badge { background: var(--card); color: var(--text); }

.side-backdrop { display: none; }

.chat-title-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; min-width: 0; max-width: min(50vw, 320px); }
.chat-title-btn:hover { border-color: var(--muted); }
.chat-title-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title-arrow { width: 14px; height: 14px; flex: none; color: var(--muted); }
.chat-top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.chat-tools-toggle { margin-left: 2px; }

@media (max-width: 860px) {
  .chat-card { height: calc(100dvh - 110px); min-height: 440px; }
  .chat { padding: 12px; }
  .chat-foot { display: none; }
  .bubble { max-width: 88%; }
  .chat-top { padding: 8px 12px; min-height: 44px; flex-wrap: nowrap; gap: 8px; }
  .chat-top .avatar { width: 28px; height: 28px; }
  .chat-top .avatar .ico { width: 16px; height: 16px; }
  .chat-title-btn { max-width: calc(100vw - 190px); }
  .quick, .perm-dock { padding-left: 12px; padding-right: 12px; }
  .composer { margin: 8px 12px 12px; }
}
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; } .bar span { transition: none; } }

/* /command menu above the chat composer (bridge dashboard) */
.cmd-menu { display: grid; max-height: 260px; overflow-y: auto; margin: 0 16px 6px; padding: 4px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); }
.cmd-menu .cmd { display: block; width: 100%; text-align: left; padding: 6px 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.cmd-menu .cmd.active, .cmd-menu .cmd:hover { background: var(--bar-bg); }

/* -- agents: catalog list and one agent's detail ------------------------------------ */
.agents { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .agents { grid-template-columns: 1fr; } }
.agent-list { display: flex; flex-direction: column; gap: 2px; margin: -10px; }
.agent-btn { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 0; border-radius: 7px; background: none;
  font: inherit; color: inherit; text-align: left; cursor: pointer; }
.agent-btn:hover { background: var(--bg); }
.agent-btn[aria-pressed="true"] { background: var(--accent-bg); }
.agent-btn .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.agent-btn .name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mini { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--card); font-size: 12.5px; font-weight: 650; }
.mini.main, .big.main { background: var(--text); color: var(--card); border-color: var(--text); }
.main-badge { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 4px; background: var(--text); color: var(--card); }
.agent-detail { padding: 0; overflow: hidden; }
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px; border-bottom: 1px solid var(--line); }
.detail-head .big { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 18px; font-weight: 700; }
.detail-head .who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.detail-head h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.detail-head .right { margin-left: auto; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border-bottom: 1px solid var(--line); }
.stats-row > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-right: 1px solid var(--line); }
.stats-row > div:last-child { border-right: 0; }
.stats-row .k, .col .k { font-size: 12px; color: var(--muted); }
.stats-row .v { font-size: 17px; font-weight: 600; }
.source { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 16px; background: var(--bg);
  border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.subtabs { display: flex; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.subtabs button { border: 0; border-bottom: 2px solid transparent; background: none; padding: 10px 8px; font: inherit;
  color: var(--muted); cursor: pointer; white-space: nowrap; }
.subtabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.subtabs .n { margin-left: 5px; font-size: 11.5px; font-weight: 400; color: var(--muted); }
.prose { padding: 16px; max-width: 80ch; }
.prose .bubble-text { line-height: 1.6; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; padding: 16px; }
.col h3 { margin: 0 0 8px; }
.col .k { margin: 8px 0 4px; }
.col p { margin: 8px 0 0; }
.rulechips { display: flex; flex-wrap: wrap; gap: 5px; }
.rulechip { font: 12px var(--mono); padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg);
  overflow-wrap: anywhere; }
.rulechip.deny { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.skills { padding: 0 16px 8px; }
.skills > p { margin: 16px 0; }
.skill { display: flex; flex-direction: column; gap: 3px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.skill:last-child { border-bottom: 0; }
.mono { font-family: var(--mono); }
.agent-detail .table-wrap { margin: 0; }
.runform { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px 12px; align-items: center; padding: 16px;
  border-bottom: 1px solid var(--line); background: var(--accent-bg); }
.runform label { font-size: 12.5px; color: var(--muted); }
.runform select, .runform input, .runform textarea { font: inherit; min-height: 32px; padding: 4px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--card); color: var(--text); width: 100%; max-width: 520px; }
.runform textarea { max-width: none; resize: vertical; }
.runform .acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 600px) { .runform { grid-template-columns: 1fr; } }

/* -- settings: automatic code review --------------------------------------------- */
.review-card { display: flex; flex-direction: column; gap: 10px; }
.review-card > p { margin: 0; }
.review-card .check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 14px; }
.review-grid label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.review-grid input, .review-grid select, .review-card td input, .review-card td select { font: inherit; min-height: 32px;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); max-width: 100%; }
.triggers { margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.triggers legend { padding: 0 4px; font-size: 12.5px; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; }
.review-card h3 { margin: 0; }
.review-card .card-head { margin-bottom: 0; }
.review-card tbody tr { cursor: default; }
.review-card tbody tr:hover { background: none; }
.review-card td { vertical-align: middle; }
.hooks { display: grid; gap: 10px; }
.hook { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.hook code { font-size: 12.5px; overflow-wrap: anywhere; }
.hook p { margin: 6px 0 0; }
.review-card .actions { margin: 4px 0 0; align-items: center; }

/* -- knowledge: folder tree, reader, table of contents --------------------------- */
.kb-card { container: kb / inline-size; padding: 14px; }
.kb-card .card-head { justify-content: flex-start; }
#knowledgeInfo { margin-right: auto; }
.kb { position: relative; display: grid; grid-template-columns: 280px minmax(0, 1fr) 210px; height: calc(100vh - 140px);
  min-height: 420px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.btn.small { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 12.5px; text-decoration: none; }
.btn .ico { width: 14px; height: 14px; }
.kb-card .kb-folders, .kb-backdrop { display: none; }

.kb-tree { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--card); }
.kb-tree-top { display: grid; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.kb-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kb-home { display: inline-flex; align-items: center; gap: 7px; min-width: 0; border: 0; background: none; font: inherit;
  font-weight: 600; color: var(--text); padding: 3px 5px; border-radius: 7px; cursor: pointer; }
.kb-home:hover { background: var(--accent-bg); }
.kb-home .ico { color: var(--accent); }
#kbCount { margin-left: auto; white-space: nowrap; }
.kb-search { display: flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.kb-search:focus-within { border-color: var(--accent); }
.kb-search .ico { width: 15px; height: 15px; color: var(--muted); }
.kb-search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 13px; color: var(--text); }
.kb-search input:focus { outline: none; }
.kb-list { flex: 1; overflow: auto; padding: 6px; }
.kb-row { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 28px; border: 0; background: none; font: inherit;
  font-size: 13px; color: var(--text); text-align: left; cursor: pointer; border-radius: 7px;
  padding: 3px 8px 3px calc(8px + var(--depth, 0) * 14px); }
.kb-row:hover { background: var(--bar-bg); }
.kb-row .ico { width: 15px; height: 15px; color: var(--muted); }
.kb-dir svg + svg { color: var(--accent); }
.kb-dir > svg:first-child { transition: transform .12s; }
.kb-dir[aria-expanded="true"] > svg:first-child { transform: rotate(90deg); }
.kb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-n { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.kb-gap { width: 15px; flex: none; }
.kb-row.active { background: var(--accent-bg); color: var(--accent-strong); font-weight: 600; }
.kb-row.active .ico { color: var(--accent-strong); }
.kb-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--muted); }
.kb-dot.done { background: var(--ok); }
.kb-dot.running { background: var(--info); }
.kb-dot.waiting { background: transparent; box-shadow: inset 0 0 0 1.5px var(--warn); }
.kb-hit { flex-direction: column; align-items: stretch; gap: 0; padding: 5px 9px; }
.kb-hit .kb-name { white-space: normal; }
.kb-path { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-hit mark, .md mark { background: var(--warn-bg); color: inherit; border-radius: 3px; }
.kb-pad { margin: 6px 8px; }
.kb-images { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); cursor: pointer; }

.kb-doc { position: relative; min-width: 0; overflow: auto; padding: 16px 28px 40px; }
.kb-head { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.kb-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 12.5px; color: var(--muted); }
.kb-crumb { border: 0; background: none; font: inherit; color: var(--muted); padding: 1px 4px; border-radius: 5px; cursor: pointer; }
.kb-crumb:hover { color: var(--accent); background: var(--accent-bg); }
.kb-sep { opacity: .6; }
.kb-here { padding: 1px 4px; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.kb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kb-when { margin-right: auto; }
.kb-props { display: grid; gap: 6px; margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.kb-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kb-k { margin-left: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kb-k:first-child { margin-left: 0; }
.tag.plain { background: var(--bar-bg); color: var(--text); }
.kb-more dd { text-align: left; }

.md { max-width: 76ch; font-size: 14.5px; line-height: 1.7; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { color: var(--text); text-transform: none; letter-spacing: normal; line-height: 1.3; text-wrap: balance; }
.md h1 { margin: 18px 0 8px; font-size: 24px; }
.md h2 { margin: 26px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line); font-size: 19px; font-weight: 650; }
.md h3 { margin: 20px 0 6px; font-size: 16px; }
.md h4, .md h5, .md h6 { margin: 16px 0 4px; font-size: 14.5px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 2px 0; }
.md li > ul, .md li > ol { margin: 2px 0; }
.md li.kb-task { list-style: none; }
.md li.kb-task > input { margin: 0 6px 0 -20px; vertical-align: middle; accent-color: var(--accent); }
.md hr { margin: 20px 0; border: 0; border-top: 1px solid var(--line); }
.md blockquote { margin: 10px 0; padding: 2px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.md code { padding: 1px 5px; border-radius: 5px; background: var(--bar-bg); font: .88em var(--mono); }
.md pre code { padding: 0; background: none; font-size: inherit; }
.md del { color: var(--muted); }
.md a { overflow-wrap: anywhere; }
.md-table { margin: 10px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
.md table { font-size: 13.5px; }
.md th, .md td { min-width: 70px; padding: 6px 10px; white-space: normal; overflow-wrap: break-word; }
.md th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: 12.5px; }
.md tbody tr { cursor: auto; }
.md tbody tr:hover { background: none; }
.md tr:last-child td { border-bottom: 0; }
.md .al-center { text-align: center; }
.md .al-right { text-align: right; }
.md-code { margin: 10px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; }
.md-code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 12px;
  background: var(--bar-bg); font-size: 12px; color: var(--muted); }
.md-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; background: var(--bg); font: 12.5px/1.55 var(--mono); }
.md-img { display: inline-block; max-width: 100%; }
.md img { max-width: 100%; max-height: 70vh; width: auto; height: auto; border: 1px solid var(--line); border-radius: 8px; vertical-align: middle; }
.callout { margin: 12px 0; padding: 8px 14px; border-left: 4px solid var(--info); border-radius: 10px; background: var(--info-bg); }
.callout-title { display: flex; align-items: center; gap: 8px; margin: 2px 0 4px; font-weight: 600; color: var(--info); }
details > summary.callout-title { font-size: inherit; color: var(--info); }
.callout p { margin: 4px 0; }
.callout.ok { border-color: var(--ok); background: var(--ok-bg); }
.callout.ok .callout-title { color: var(--ok); }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); }
.callout.warn .callout-title { color: var(--warn); }
.callout.bad { border-color: var(--bad); background: var(--bad-bg); }
.callout.bad .callout-title { color: var(--bad); }
.callout.neutral { border-color: var(--muted); background: var(--bar-bg); }
.callout.neutral .callout-title { color: var(--text); }
.md-details { margin: 10px 0; padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px; }
.md-details > summary { font-size: 14px; font-weight: 600; color: var(--text); }
.md-html { color: var(--muted); white-space: pre-wrap; font: 12.5px/1.5 var(--mono); }
.kb-link { text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.kb-link:hover { border-bottom-color: var(--accent); }
.kb-missing { color: var(--muted); border-bottom: 1px dashed var(--muted); cursor: help; }
.kb-embed { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 7px; }
.kb-embed .ico { width: 14px; height: 14px; color: var(--muted); }

.kb-toc { overflow: auto; padding: 14px 10px; border-left: 1px solid var(--line); font-size: 12.5px; }
.kb-toc h3 { margin: 0 0 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kb-toc button { display: block; width: 100%; padding: 3px 8px; border: 0; border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
  background: none; font: inherit; line-height: 1.4; color: var(--muted); text-align: left; cursor: pointer; }
.kb-toc button.l3 { padding-left: 18px; }
.kb-toc button:hover { background: var(--bar-bg); color: var(--text); }
.kb-toc button.on { border-left-color: var(--accent); color: var(--accent-strong); font-weight: 600; }

.kb-home-view h1 { margin: 6px 0 2px; }
.kb-home-view > p { margin: 0 0 14px; }
.kb-home-view h2 { margin: 22px 0 8px; }
.kb-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.kb-tile { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.kb-tile:hover { border-color: var(--accent); }
.kb-tile span { color: var(--muted); font-size: 12.5px; }
.kb-recent { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.kb-recent button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 12px; padding: 8px 12px; border: 0;
  border-bottom: 1px solid var(--line); background: var(--card); font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.kb-recent button:last-child { border-bottom: 0; }
.kb-recent button:hover { background: var(--accent-bg); }
.kb-r-title { overflow: hidden; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.kb-r-path { grid-column: 1; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.kb-r-when { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--muted); font-size: 12px; }

@container kb (max-width: 1000px) {
  .kb { grid-template-columns: 250px minmax(0, 1fr); }
  .kb-toc { display: none; }
}
@container kb (max-width: 640px) {
  .kb-card .kb-folders { display: inline-flex; }
  .kb { grid-template-columns: minmax(0, 1fr); }
  .kb-tree { position: absolute; inset: 0 auto 0 0; z-index: 3; width: min(300px, 88%); box-shadow: var(--shadow);
    transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
  .kb.drawer-open .kb-tree { transform: none; visibility: visible; }
  .kb.drawer-open .kb-backdrop { display: block; position: absolute; inset: 0; z-index: 2; border: 0; background: rgba(0, 0, 0, .35); }
  .kb-doc { padding: 12px 14px 32px; }
  .md h1 { font-size: 21px; }
}
@media (max-width: 860px) { .kb { height: calc(100vh - 190px); } }
@media (prefers-reduced-motion: reduce) { .kb-tree, .kb-dir > svg:first-child { transition: none; } }
#codeView { margin-left: auto; }
#codeNote { margin: 0 0 8px; }
.code-groups { display: flex; flex-direction: column; gap: 8px; }
details.proj { border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
details.proj > summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 12px;
  font-size: 13px; color: var(--text); list-style: none; }
details.proj > summary::-webkit-details-marker { display: none; }
details.proj > summary::before { content: "▸"; color: var(--muted); width: 10px; }
details.proj[open] > summary::before { content: "▾"; }
details.proj[open] > summary { border-bottom: 1px solid var(--line); }
.proj-name { font-weight: 600; overflow-wrap: anywhere; }
.proj-meta { margin-left: auto; }
details.proj .table-wrap { margin: 0; }
details.proj table { table-layout: fixed; }
details.proj col.c-status { width: 300px; }
@media (max-width: 640px) { details.proj col.c-status { width: 46%; } }
details.proj table th.section { padding-top: 7px; padding-bottom: 7px; background: var(--bg); }
details.proj .chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
details.proj tr.merged td { color: var(--muted); }
.mr-num { color: var(--muted); margin-right: 6px; }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 7px; background: var(--bar-bg); }
.seg button { border: 0; border-radius: 5px; background: none; padding: 3px 11px; font: inherit; font-size: 12.5px;
  color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* -- Schedules ----------------------------------------------------------- */
.schedules-split { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; margin: 16px 24px; }
@media (max-width: 860px) { .schedules-split { grid-template-columns: minmax(0, 1fr); margin: 12px 16px; } }
.schedule-list { display: flex; flex-direction: column; gap: 8px; }
.schedule-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s; }
.schedule-item:hover { border-color: var(--muted); }
.schedule-item.active { border-color: var(--accent); background: var(--bg); }
.schedule-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.schedule-name { font-size: 13.5px; font-weight: 600; }
.schedule-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin: 16px 0; padding: 12px; background: var(--bg); border-radius: 8px; }
.meta-row { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.meta-val { font-size: 13px; font-weight: 500; }
.prompt-section, .history-section { margin-top: 18px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; color: var(--muted); }
.prompt-box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-family: monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; }
.summary-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea { font: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); outline: none; }
.form-check { flex-direction: row; align-items: center; gap: 8px; margin-top: 4px; }
.form-check label { color: var(--text); font-size: 13px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.schedule-top { flex-wrap: wrap; }
.schedule-top .schedule-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.choice-list { display: grid; gap: 10px; margin-top: 12px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer; }
.choice:hover, .choice:focus-visible { border-color: var(--accent); }
.detail-card > .review-card { border: 0; padding: 0; background: none; box-shadow: none; }

