/* Ken — white frosted glass. One stylesheet, every page.
   Principles: near-white canvas with soft color fields behind glass; hairline borders; one ink color for actions;
   generous space; sentence-case headings; quiet text. */

:root {
  --canvas: #f2f2f4;
  --ink: #0b0d12;
  --text: #16181d;
  --muted: #6b7280;
  --faint: #9ca3af;
  --hair: rgba(17, 24, 39, 0.07);
  --hair-strong: rgba(17, 24, 39, 0.12);
  --glass: rgba(255, 255, 255, 0.56);
  --glass-hi: rgba(255, 255, 255, 0.78);
  --glass-edge: rgba(255, 255, 255, 0.9);
  --blur: blur(28px) saturate(180%);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 12px 40px -12px rgba(17, 24, 39, 0.12);
  --accent: #5b5bd6;
  --ok: #0f9f6e;
  --warn: #c2410c;
  --live: #ef4444;
  --r-lg: 22px;
  --r: 16px;
  --r-sm: 12px;
  --side: 268px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  background-color: var(--canvas);
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14.5px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--faint); font-size: 13px; margin: 6px 4px 0; }
.warn { color: var(--warn); }

/* ---------- glass ---------- */
.glass, .task, .connector, .entries li, .sidebar, .composer, .insight-card, .menu {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border-radius: var(--r);
}
.pad { padding: 20px; }

/* ---------- app shell: left sidebar on every page ---------- */
body.shell { padding-left: calc(var(--side) + 24px); }
.side-account { display: contents; }
.sidebar {
  position: fixed; z-index: 20; top: 12px; bottom: 12px; left: 12px; width: var(--side);
  border-radius: var(--r-lg); padding: 14px 10px; display: flex; flex-direction: column; gap: 6px;
}
.side-brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px 10px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: -0.02em; color: var(--ink); }
.logo-mark { width: 24px; height: 24px; border-radius: 8px; background: var(--ink); box-shadow: inset 0 0 0 5px var(--ink), inset 0 0 0 7px #fff; }
.side-section { font-size: 12px; color: var(--faint); padding: 14px 12px 4px; font-weight: 500; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px;
  color: var(--text); font-size: 14px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.side-link svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.side-link:hover { background: rgba(17, 24, 39, 0.045); text-decoration: none; box-shadow: none; }
button.side-link { font-family: inherit; font-weight: 400; justify-content: flex-start; }
.side-link.active { background: rgba(255, 255, 255, 0.85); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--hair); font-weight: 500; }
.side-link .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-scroll { flex: 1; overflow-y: auto; margin: 0 -2px; padding: 0 2px; }
.side-foot { border-top: 1px solid var(--hair); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.vault-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); margin-left: auto; }
.vault-dot.ok { background: var(--ok); }
.vault-dot.locked { background: var(--warn); }
.menu-btn { display: none; }

@media (max-width: 860px) {
  body.shell { padding-left: 0; padding-top: 64px; }
  .sidebar { transform: translateX(calc(-100% - 24px)); transition: transform 0.25s ease; }
  body.nav-open .sidebar { transform: none; }
  .menu-btn {
    display: inline-flex; position: fixed; z-index: 21; top: 12px; left: 12px;
  }
}

/* ---------- page scaffolding ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 28px 24px 120px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 4px; }
.section-head.spaced { margin-top: 22px; }
.spaced-sm { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.actions-row { display: flex; justify-content: flex-end; gap: 8px; }
.grow { flex: 1 1 180px; }
.short { width: 96px; }

.banner {
  position: fixed; z-index: 30; top: 16px; left: 50%; transform: translateX(-50%);
  max-width: min(640px, calc(100% - 32px)); padding: 10px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--shadow); border: 1px solid var(--glass-edge); font-size: 13.5px; color: var(--text);
}
.banner.error { color: var(--warn); }

/* ---------- controls ---------- */
button, .linkbtn {
  font: inherit; font-size: 14px; font-weight: 500; border-radius: 999px; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--hair-strong); background: rgba(255, 255, 255, 0.7); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button:hover, .linkbtn:hover { background: #fff; box-shadow: var(--shadow-sm); text-decoration: none; }
button:active { transform: translateY(1px); }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
button.primary:hover { background: #262a33; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: rgba(17, 24, 39, 0.05); box-shadow: none; }
.icon-btn { width: 38px; height: 38px; padding: 0; border-radius: 50%; }
.icon-btn svg { width: 18px; height: 18px; }
.small-btn { padding: 4px 12px; font-size: 13px; }
.small-btn.active { border-color: var(--accent); color: var(--accent); }

input, select, textarea {
  font: inherit; color: var(--text); width: 100%;
  background: rgba(255, 255, 255, 0.7); border: 1px solid var(--hair-strong); border-radius: var(--r-sm); padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; background: #fff; border-color: rgba(91, 91, 214, 0.5); box-shadow: 0 0 0 4px rgba(91, 91, 214, 0.12); }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--ink); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.row { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 400; font-size: 14px; }
select[multiple] { padding: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 4px 12px; font-size: 12.5px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(17, 24, 39, 0.05); align-self: flex-start; }
.seg label { flex-direction: row; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 13.5px; }
.seg label:has(input:checked) { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.seg input { display: none; }
button.primary.danger { background: var(--warn); border-color: var(--warn); }

/* vault modal (vault.js) */
.modal {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; padding: 22px;
  border: 1px solid var(--hair); border-radius: var(--r); background: #fff; color: var(--text); box-shadow: var(--shadow);
  display: none; flex-direction: column; gap: 14px;
}
.modal[open] { display: flex; }
.modal::backdrop { background: rgba(17, 24, 39, 0.28); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close { font-size: 20px; line-height: 1; padding: 2px 10px; }
.modal p { margin: 0; }
.modal-msg { font-size: 13.5px; color: var(--ok); }
.modal-msg.error { color: var(--warn); }

/* Settings → Reset or restore the vault (vault.js renderRecovery) */
.recovery summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
.recovery[open] summary { margin-bottom: 12px; }
.recovery h3 { margin: 0 0 4px; }
.recovery .hint { margin: 0 0 10px; }
.recovery .modal-msg { margin: 0 0 10px; }

/* Settings → AI: radio list, each option expands to its model and key */
.ai-options { display: flex; flex-direction: column; gap: 8px; }
.ai-option { border: 1px solid var(--hair-strong); border-radius: var(--r-sm); background: var(--glass-hi); }
.ai-option.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.1); }
.ai-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.ai-head input[type="radio"] { margin: 0; flex: none; }
.ai-title { flex: 1; min-width: 0; }
.ai-title .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-tag { font-size: 11.5px; color: var(--muted); background: rgba(17, 24, 39, 0.05); padding: 1px 8px; border-radius: 999px; margin-left: 4px; }
.ai-caret { color: var(--faint); font-size: 18px; transition: transform 0.15s; }
.ai-caret.open { transform: rotate(90deg); }
.ai-body { padding: 0 14px 14px 40px; gap: 10px; }
.ai-body p { margin: 0; }
.seg label:has(input:disabled) { cursor: default; }
.seg label:has(input:disabled:not(:checked)) { opacity: 0.45; }
#storage .seg label { padding: 4px 12px; font-size: 13px; }

.compose { display: flex; gap: 6px; padding: 6px 6px 6px 16px; border-radius: 999px; align-items: center; }
.compose input { border: 0; background: transparent; box-shadow: none; padding: 8px 0; }
.compose input:focus { box-shadow: none; background: transparent; }
.answer { padding: 14px 18px; white-space: pre-wrap; }

/* ---------- lists & cards ---------- */
.list, .tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task { padding: 16px 18px; }
.task .head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.task .instr { font-weight: 500; }
.task .result { margin-top: 8px; white-space: pre-wrap; }
.task .steps { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); max-height: 200px; overflow-y: auto; }
.task .links { margin-top: 10px; display: flex; gap: 10px; font-size: 13px; flex-wrap: wrap; align-items: center; color: var(--faint); }
.task details summary { cursor: pointer; margin-top: 8px; color: var(--muted); font-size: 13px; }
.state { font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: rgba(17, 24, 39, 0.05); color: var(--muted); white-space: nowrap; }
.state.running { background: rgba(91, 91, 214, 0.1); color: var(--accent); }
.state.awaiting_approval { background: rgba(194, 65, 12, 0.08); color: var(--warn); }
.state.done { background: rgba(15, 159, 110, 0.1); color: var(--ok); }
.state.failed, .state.rejected { background: rgba(194, 65, 12, 0.08); color: var(--warn); }
.approval { margin-top: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(194, 65, 12, 0.2); display: flex; flex-direction: column; gap: 8px; }
.approval .amount { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.approval label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.approval input.short { width: 110px; }
.draft .fields { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.draft textarea { min-height: 110px; }
/* Activity page: grouped feed, empty state, document drop zone */
.linkbtn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.linkbtn.primary:hover { background: #262a33; }
#needsWrap, #liveWrap, #recentWrap { display: flex; flex-direction: column; gap: 10px; }
#needsWrap + #liveWrap, #liveWrap + .empty-card, #needsWrap ~ #recentWrap { margin-top: 12px; }
.task .kind-label { font-size: 12px; color: var(--faint); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.empty-card { padding: 20px 22px; }
.empty-card h3 { margin: 0 0 4px; font-size: 16px; }
.empty-card p { margin: 0; }
.empty-card .examples { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.empty-card .examples li { display: flex; flex-direction: column; gap: 1px; }
.empty-card .examples a { color: var(--text); font-weight: 500; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 22px 16px; border: 1.5px dashed var(--hair-strong); border-radius: var(--r-sm); cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(91, 91, 214, 0.05); }
.entries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entries li { padding: 12px 14px; border-radius: var(--r-sm); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; box-shadow: var(--shadow-sm); background: var(--glass-hi); }
.entries .name { font-weight: 500; }
.entries .kind { font-size: 11.5px; color: var(--faint); margin-left: 8px; }
.entries .meta { grid-column: 1; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.entries .btns { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 4px; align-items: start; }

/* ---------- plugins ---------- */
.connector { padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; transition: box-shadow 0.2s ease, transform 0.2s ease; }
.connector:hover { box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05), 0 18px 48px -14px rgba(17, 24, 39, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.connector.on { background: var(--glass-hi); }
.connector-head { display: flex; align-items: flex-start; gap: 12px; }
.connector-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 600; font-size: 17px; color: var(--tint);
  background: color-mix(in srgb, var(--tint) 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tint) 18%, transparent);
}
.connector-title { flex: 1; min-width: 0; }
.connector-title h3 { font-size: 15px; line-height: 1.3; }
.connector-title p { margin: 3px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.connector-head .state { flex: none; margin-top: 1px; }
.connector-status { font-size: 13px; color: var(--muted); padding: 8px 12px; border-radius: 10px; background: rgba(17, 24, 39, 0.035); overflow-wrap: anywhere; white-space: pre-line; }
.connector-warn {
  font-size: 12.5px; line-height: 1.5; color: #9a3412; padding: 9px 12px; border-radius: 10px;
  background: rgba(194, 65, 12, 0.06); border: 1px solid rgba(194, 65, 12, 0.14);
}
.connector .qr, .plug-modal .qr { align-self: center; padding: 10px; background: #fff; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--hair); }
.connector .qr svg, .connector .qr img, .plug-modal .qr svg, .plug-modal .qr img { display: block; width: 180px; height: 180px; }
.connector .devcode, .plug-modal .devcode { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px var(--hair); }
.connector .devcode code, .plug-modal .devcode code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; font-weight: 600; letter-spacing: 0.14em;
  white-space: nowrap; color: var(--ink); user-select: all;
}
.connector-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hair); }
.connector-form { display: flex; gap: 8px; flex: 1 1 100%; }
.connector-form input { padding: 7px 12px; font-size: 14px; }
.connector-form button { flex: none; padding: 6px 16px; font-size: 13px; }
.connector-fields { display: flex; flex-direction: column; gap: 8px; flex: 1 1 100%; }
.connector-fields label { display: flex; flex-direction: column; gap: 3px; }
.connector-fields input { padding: 7px 12px; font-size: 14px; }
.connector-fields button { align-self: flex-start; padding: 6px 16px; font-size: 13px; }
.linkbtn.small-btn { padding: 4px 12px; font-size: 13px; }
.danger-ghost { background: transparent; border-color: transparent; color: var(--muted); }
/* directory: search, category chips, compact tiles; a sheet per plugin */
.plugins-page { max-width: 1080px; }
.plug-toolbar { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 26px; }
.plug-search {
  display: flex; flex-direction: row; align-items: center; gap: 8px; max-width: 460px; padding: 0 14px; border-radius: 999px;
  background: var(--glass-hi); border: 1px solid var(--hair-strong); box-shadow: var(--shadow-sm); color: var(--faint);
}
.plug-search:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--muted); }
.plug-search svg { width: 16px; height: 16px; flex: none; }
.plug-search input, .plug-search input:focus { border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none; padding: 10px 0; font: inherit; font-size: 14.5px; font-weight: 400; width: 100%; color: var(--text); }
.plug-cats { gap: 6px; }
.plug-section { display: flex; align-items: baseline; gap: 8px; padding: 0 2px; margin: 0 0 8px; }
.plug-section h2 { font-size: 14px; }
.plug-grid + .plug-section { margin-top: 28px; }
.plug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 6px; }
.plug-tile {
  display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 10px 12px; text-align: left;
  border-radius: 14px; border: 1px solid transparent; background: transparent; box-shadow: none; font-weight: 400;
  justify-content: flex-start;
}
.plug-tile:hover { background: var(--glass-hi); border-color: var(--hair); box-shadow: var(--shadow-sm); }
.plug-tile .connector-icon { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; }
.plug-tile-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.plug-tile-name { font-size: 14px; font-weight: 500; color: var(--ink); line-height: 1.35; }
.plug-tile-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plug-add {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; line-height: 1;
  color: var(--muted); border: 1px solid var(--hair-strong); opacity: 0; transition: opacity 0.15s ease;
}
.plug-tile:hover .plug-add, .plug-tile:focus-visible .plug-add { opacity: 1; }
.plug-dot { flex: none; width: 8px; height: 8px; margin: 0 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(15, 159, 110, 0.15); }
.plug-empty { color: var(--muted); padding: 40px 4px; }
@media (hover: none) { .plug-add { opacity: 1; } }

.plug-modal { width: min(540px, calc(100vw - 32px)); gap: 16px; padding: 22px 22px 20px; }
.plug-modal-head { display: flex; align-items: center; gap: 14px; }
.connector-icon.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 22px; }
.plug-modal-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.plug-modal-title h2 { font-size: 19px; }
.plug-modal-desc { color: var(--text); font-size: 14.5px; }
.plug-modal-actions { margin-top: 0; }
.plug-guide { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 14px; background: rgba(17, 24, 39, 0.03); border: 1px solid var(--hair); }
.plug-guide-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.plug-tabs { display: flex; gap: 4px; }
.plug-tabs .chip-btn { padding: 3px 11px; font-size: 12.5px; }
.plug-reveal { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 14px; background: rgba(15, 159, 110, 0.06); border: 1px solid rgba(15, 159, 110, 0.22); }
.plug-reveal .plug-copy > .muted { color: var(--ok); font-weight: 600; }
.plug-copy { display: flex; flex-direction: column; gap: 4px; }
.plug-copy-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 10px; background: #fff; border: 1px solid var(--hair-strong); }
.plug-copy-row code { flex: 1; min-width: 0; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; color: var(--ink); }
.plug-copy-row .small-btn { flex: none; }
.plug-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.5; }
.plug-steps li::marker { color: var(--muted); font-weight: 500; }
.plug-note { font-size: 12.5px; color: var(--muted); }
.primary-link { align-self: flex-start; background: var(--ink); border-color: var(--ink); color: #fff; font-size: 13.5px; padding: 7px 16px; }
.primary-link:hover { background: #262a33; color: #fff; }
.danger-ghost:hover { background: rgba(194, 65, 12, 0.07); color: var(--warn); box-shadow: none; }

/* ---------- chat ---------- */
.chat-main { min-height: 100vh; display: flex; flex-direction: column; }
.chat-top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 24px 10px; }
.chat-top .model { font-size: 13px; color: var(--muted); }
.chat-top .right { display: flex; gap: 6px; align-items: center; }
.thread { flex: 1; width: min(780px, calc(100% - 32px)); margin: 0 auto; padding: 8px 0 18px; display: flex; flex-direction: column; gap: 18px; }
.msg { line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 78%; background: var(--ink); color: #f5f5f7; padding: 10px 16px; border-radius: 20px 20px 6px 20px; }
.msg.assistant { align-self: stretch; padding: 0 2px; }
.msg.assistant.pending { color: var(--faint); }
.msg .tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tool-chip { font-size: 12px; color: var(--muted); padding: 3px 10px; border-radius: 999px; background: rgba(17, 24, 39, 0.05); white-space: nowrap; }
/* step trail: the chips, and on click every step with what it looked for and found */
.trail { margin-bottom: 8px; white-space: normal; }
.trail > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.trail > summary::-webkit-details-marker { display: none; }
.trail > summary .tools { margin: 0; }
.trail-sum { font-size: 12px; color: var(--faint); }
.trail-sum::after { content: ' ›'; display: inline-block; transition: transform 0.15s; }
.trail[open] .trail-sum::after { transform: rotate(90deg); }
.trail > summary:hover .tool-chip { background: rgba(17, 24, 39, 0.08); }
.trail-steps { margin: 8px 0 4px; padding: 10px 14px 10px 30px; border: 1px solid var(--hair); border-radius: var(--r-sm); background: var(--glass-hi); font-size: 13px; line-height: 1.5; display: flex; flex-direction: column; gap: 8px; }
.trail-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.trail-head strong { font-weight: 600; color: var(--text); }
.trail-arg { color: var(--muted); }
.trail-ms { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.trail-result { color: var(--faint); font-size: 12.5px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* approval cards: a message Ken drafted, acted on right in the chat */
.act-cards { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; white-space: normal; }
.act-card { border: 1px solid var(--hair-strong); border-radius: var(--r); background: var(--glass-hi); backdrop-filter: var(--blur); box-shadow: var(--shadow-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; max-width: 560px; }
.msg.assistant.pending .act-card { color: var(--text); margin-top: 10px; }
.act-card.attn { border-color: rgba(194, 65, 12, 0.35); }
.act-head { display: flex; align-items: center; gap: 10px; }
.act-kind { font-weight: 600; font-size: 13.5px; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-state { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: rgba(17, 24, 39, 0.05); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.act-state.run { background: rgba(91, 91, 214, 0.1); color: var(--accent); }
.act-state.attn { background: rgba(194, 65, 12, 0.1); color: var(--warn); }
.act-state.ok { background: rgba(15, 159, 110, 0.1); color: var(--ok); }
.act-subject { font-size: 13px; font-weight: 500; }
.act-body { font-size: 13.5px; color: var(--text); white-space: pre-wrap; max-height: 180px; overflow-y: auto; }
.act-note { font-size: 12.5px; color: var(--warn); }
.act-buttons { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.act-buttons button { font-size: 13px; padding: 6px 14px; }
.act-edit { margin-left: auto; font-size: 12.5px; color: var(--muted); text-decoration: none; }
.act-edit:hover { text-decoration: underline; }
.insight-card { align-self: flex-start; max-width: 86%; padding: 12px 16px; border-radius: 18px; display: flex; gap: 12px; align-items: flex-start; }
.insight-card .ear { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; background: rgba(91, 91, 214, 0.12); color: var(--accent); }
.insight-card .ear svg { width: 14px; height: 14px; }
.insight-card .body { font-weight: 500; color: var(--ink); }
.insight-card .meta { font-size: 12px; color: var(--faint); margin-top: 2px; }
.insight-card.answer .ear { background: rgba(15, 159, 110, 0.12); color: var(--ok); }
.heard { align-self: center; font-size: 12.5px; color: var(--faint); max-width: 80%; text-align: center; }

.empty-hero { margin: 16vh auto 0; text-align: center; width: min(640px, calc(100% - 32px)); }
.empty-hero h1 { font-size: 30px; letter-spacing: -0.03em; }
.empty-hero p { color: var(--muted); margin: 8px 0 0; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.suggest button { font-weight: 400; color: var(--muted); }

.composer {
  position: fixed; z-index: 10; bottom: 20px;
  left: calc(var(--side) + 24px + (100% - var(--side) - 24px) / 2); transform: translateX(-50%);
  width: min(780px, calc(100% - var(--side) - 64px));
  /* Single line = 40px buttons + 2×6px padding + 2×1px border = 54px tall, so a 27px radius is an exact pill.
     Multi-line input grows the bar and keeps the same corner radius. */
  --btn: 40px;
  border-radius: calc(var(--btn) / 2 + 7px); padding: 6px; display: flex; align-items: flex-end; gap: 4px; background: var(--glass-hi);
}
@media (max-width: 860px) { .composer { left: 50%; width: calc(100% - 24px); } }
/* flex: none stops the textarea (width: 100%) from squeezing the buttons into ovals. */
.composer .icon-btn { flex: none; width: var(--btn); height: var(--btn); aspect-ratio: 1; border-radius: 50%; }
.composer .icon-btn:active { transform: none; }
.composer textarea {
  border: 0; border-radius: 0; background: transparent; resize: none; display: block;
  height: var(--btn); min-height: var(--btn); max-height: 200px; padding: 9px 8px; line-height: 22px; font-size: 15px;
}
.composer textarea:focus { box-shadow: none; background: transparent; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }

/* ---------- AI billing (settings) ---------- */
.budget-line { font-weight: 500; color: var(--ink); }
.budget-track { height: 6px; border-radius: 999px; background: rgba(17, 24, 39, 0.07); overflow: hidden; }
.budget-fill { height: 100%; width: 0; background: var(--ink); border-radius: 999px; transition: width 0.4s; }
.budget-fill.over { background: var(--live); }
.key-row { display: flex; gap: 8px; align-items: flex-end; }
.key-row label { flex: 1; }
.key-row .small-btn { margin-bottom: 6px; }

/* ---------- usage page ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; border-radius: 18px; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.usage-block { margin-bottom: 26px; }
.usage-block > .section-head { margin-bottom: 10px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; margin-top: 12px; overflow-x: auto; }
.bar { flex: 1 0 18px; max-width: 42px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bar-fill { width: 100%; border-radius: 5px 5px 2px 2px; background: var(--ink); opacity: 0.82; }
.bar:hover .bar-fill { opacity: 1; }
.bar-day { font-size: 10.5px; color: var(--faint); }
.table-wrap { overflow-x: auto; border-radius: 18px; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.usage-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 12px 14px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.usage-table td { padding: 10px 14px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.usage-table tr:last-child td { border-bottom: 0; }
.usage-table tr.current td { color: var(--muted); }
.usage-table tr.picked td { font-weight: 600; color: var(--ink); }
.usage-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
#modelPick { flex: 1; min-width: 240px; }

/* keeps the last message clear of the fixed composer */
.composer-spacer { flex: none; height: 120px; }
.composer textarea:first-child { padding-left: 16px; }

.spin { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 1.6px solid var(--hair-strong); border-top-color: var(--ink); animation: spin 0.8s linear infinite; }
.mark { flex: none; width: 12px; text-align: center; font-size: 12px; line-height: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* chat: live steps inside the pending reply */
.steps { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
.step { display: flex; align-items: center; gap: 10px; }
.step.done { color: var(--faint); }
.step .mark { color: var(--faint); }


/* page fade-in */
.page, .thread { animation: fade 0.25s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.avatar { width: 18px; height: 18px; border-radius: 50%; flex: none; }

/* ---------- Live ---------- */
.live-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.live-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.listen-btn .live-dot { background: var(--faint); box-shadow: none; }
.listen-btn.on .live-dot { background: var(--live); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.voice-btn svg { width: 16px; height: 16px; }
.voice-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.voice-btn.on:hover { background: #262a33; }
.live-page { max-width: 1240px; }

/* what's being heard: big quiet type straight on the canvas, with a small level wave while listening */
.live-hearing { display: flex; align-items: flex-start; gap: 14px; padding: 2px 4px 22px; }
.wave { flex: none; display: inline-flex; align-items: center; gap: 3px; height: 26px; }
.wave i { width: 3px; height: 6px; border-radius: 2px; background: var(--faint); opacity: 0.6; transition: background 0.2s; }
.live-hearing.on .wave i { background: var(--live); opacity: 0.85; animation: level 1.1s ease-in-out infinite; }
.live-hearing.on .wave i:nth-child(2) { animation-delay: -0.85s; }
.live-hearing.on .wave i:nth-child(3) { animation-delay: -0.35s; }
.live-hearing.on .wave i:nth-child(4) { animation-delay: -0.6s; }
@keyframes level { 0%, 100% { height: 6px; } 50% { height: 20px; } }
.live-transcript {
  margin: 0; font-size: 19px; line-height: 1.45; letter-spacing: -0.01em; color: var(--ink);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
}
.live-transcript.idle { color: var(--faint); }

/* one sheet, two columns split by a hairline — Insights to read, Conversation to follow */
.live-sheet {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); border-radius: var(--r-lg);
  height: max(440px, calc(100dvh - 300px)); overflow: hidden;
}
.live-col { min-width: 0; min-height: 0; overflow-y: auto; padding: 22px 26px 26px; }
.live-convo { border-left: 1px solid var(--hair); background: rgba(255, 255, 255, 0.28); }
.col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.eyebrow { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.col-meta { font-size: 12px; color: var(--faint); }
@media (max-width: 1000px) {
  .live-sheet { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .live-col { overflow: visible; }
  .live-convo { border-left: 0; border-top: 1px solid var(--hair); }
}

.take-topic { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; color: var(--ink); margin-bottom: 14px; }
.take-points { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 15.5px; line-height: 1.55; color: var(--text); }
.take-points li { position: relative; padding-left: 18px; animation: fade 0.3s ease-out; }
.take-points li::before { content: ''; position: absolute; left: 2px; top: 0.68em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.7; }
.take-empty { margin: 0; line-height: 1.6; max-width: 46ch; }
.research-line { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 12.5px; color: var(--faint); }

/* context stream: compact rows under Insights */
.live-stream { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--hair); }
.live-stream .col-head { margin-bottom: 6px; }
.stream-list { list-style: none; margin: 0; padding: 0; }
.stream-list li { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid var(--hair); animation: fade 0.25s ease-out; }
.stream-list li:last-child { border-bottom: 0; }
.stream-list .via { flex: none; width: 64px; font-size: 11.5px; font-weight: 500; color: var(--faint); }
.stream-list .text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.stream-list .when { flex: none; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* conversation feed: each question with its answer indented underneath, hairlines between */
.feed { list-style: none; margin: 0; padding: 0; }
.feed .item { padding: 14px 0; border-bottom: 1px solid var(--hair); animation: fade 0.25s ease-out; }
.feed .item:first-child { padding-top: 2px; }
.feed .item:last-child { border-bottom: 0; }
.feed .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--faint); margin-bottom: 3px; }
.feed .via { font-weight: 500; }
.feed .q { font-weight: 500; color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; }
.feed .a, .feed .text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.feed .a { margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--hair-strong); color: var(--text); }
.feed .a.answer { border-left-color: rgba(15, 159, 110, 0.45); }
.feed .status { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.feed .status.warn { color: var(--warn); }
.feed .asked.done .status { color: var(--ok); }
.feed .re { margin-top: 4px; font-size: 12.5px; color: var(--faint); overflow-wrap: anywhere; }
.feed .response.answer .via { color: var(--ok); }
.feed .response.proactive .via { color: var(--accent); }
.feed .response.proactive .text { padding-left: 12px; border-left: 2px solid rgba(91, 91, 214, 0.45); }
.feed-empty { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 46ch; }

/* ---------- loops page ---------- */
.loops-page { max-width: 1320px; }
.loops-add { margin-bottom: 16px; }
.loops-add .lens-pick { width: auto; border: 0; background: rgba(17, 24, 39, 0.05); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.loops-stats { margin-bottom: 18px; }
.loops-intro { margin: 0 4px 12px; }
.loops-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1200px) { .loops-board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .loops-board { grid-template-columns: 1fr; } }
.loops-closed { margin-top: 24px; }
.loops-closed summary { cursor: pointer; padding: 0 4px; }
.loop-empty { padding: 14px 6px; }
.loop, .insight, .note { padding: 13px 15px; display: flex; flex-direction: column; gap: 5px; border-radius: var(--r); }
.loop.urgent { box-shadow: var(--shadow), inset 3px 0 0 var(--warn); }
.loop.closed, .insight.closed { opacity: 0.6; }
.insight.fresh { box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
.loop-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.loop-age { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.loop-age.warn { color: var(--warn); font-weight: 500; }
.loop-title, .insight-text { font-weight: 500; color: var(--ink); line-height: 1.4; }
.insight-text { font-size: 14.5px; }
.loop-next { font-size: 13.5px; color: var(--text); }
.loop-quote { color: var(--ok); font-weight: 500; }
.agent-line { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: rgba(17, 24, 39, 0.055); color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.warnchip { background: rgba(194, 65, 12, 0.08); color: var(--warn); }
.loop-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; align-items: center; }
.loop-actions .small-btn { padding: 3px 10px; font-size: 12.5px; }
.loop-actions .small-btn.active { background: rgba(91, 91, 214, 0.1); }
.loop-panel { margin-top: 8px; }
.loop-panel textarea { min-height: 60px; }
.loop-details summary { cursor: pointer; margin-top: 4px; }
.loop-sources { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.src-text { font-size: 12.5px; white-space: pre-wrap; color: var(--text); max-height: 120px; overflow: hidden; }
.loop-edit { margin-top: 8px; }
.loop-edit input { padding: 7px 10px; font-size: 13.5px; }
.habit.done-today { opacity: 0.75; }
.streak { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--warn); }
.habit-dots { display: flex; gap: 4px; margin: 4px 0 2px; }
.habit-dots .dot { width: 13px; height: 13px; border-radius: 4px; background: rgba(17, 24, 39, 0.09); cursor: pointer; }
.habit-dots .dot.done { background: var(--ok); }
.habit-dots .dot.off { background: transparent; box-shadow: inset 0 0 0 1px var(--hair-strong); }
.procure { padding: 14px 16px; }
.procure-head { margin-bottom: 8px; }
.procure-table td, .procure-table th { padding: 8px 10px; text-align: left; vertical-align: top; }
.procure-table tr.best td { background: rgba(15, 159, 110, 0.07); }
.procure-table tr.best td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.loops-runbar { margin: 4px 4px 14px; align-items: center; }
.memo { margin-bottom: 12px; }
.memo summary { cursor: pointer; }
.memo-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.memo-head h2 { flex: 1; }
.prose p { margin: 0 0 8px; }
.prose ul { margin: 0 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.tensions { padding: 10px 14px; border-radius: var(--r-sm); background: rgba(194, 65, 12, 0.05); }
.tensions ul { margin: 6px 0 0; padding-left: 18px; }
.lens-details summary { cursor: pointer; }
.lens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.lens-box { padding: 10px 12px; border-radius: var(--r-sm); background: rgba(255, 255, 255, 0.6); border: 1px solid var(--hair); }
.lens-box ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.lens-name { font-size: 12.5px; font-weight: 600; }
.lens-critic { color: #b42318; }
.lens-analyst { color: #475467; }
.lens-operator { color: #5b5bd6; }
.lens-money { color: #0f9f6e; }
.lens-strategist { color: #7a2e98; }
.lens-people { color: #b54708; }
.lens-coach { color: #0e7490; }
.mini-select { width: auto; padding: 5px 10px; font-size: 13px; border-radius: 999px; }
.note-text { white-space: pre-wrap; max-height: 180px; overflow-y: auto; }
.journal summary { cursor: pointer; }
.journal .prose { margin-top: 8px; font-size: 14px; }
.short-time { width: 120px; }
.procure-table td.small { white-space: normal; min-width: 200px; max-width: 360px; }
.loops-page #tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.loops-page #tabs label { white-space: nowrap; }
@media (max-width: 700px) { .loops-page #tabs label { padding: 5px 11px; } }
@media (max-width: 700px) {
  .loops-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .loops-stats .stat { padding: 12px 14px; }
  .loops-stats .stat-value { font-size: 20px; }
}

/* ---------- projects (pm) ---------- */
.pm-page #tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.pm-page #tabs label { white-space: nowrap; }
.health { font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; white-space: nowrap; background: rgba(17, 24, 39, 0.05); color: var(--muted); }
.health.on_track { background: rgba(15, 159, 110, 0.1); color: var(--ok); }
.health.at_risk { background: rgba(202, 138, 4, 0.12); color: #a16207; }
.health.blocked { background: rgba(239, 68, 68, 0.1); color: #b42318; }
.health.done { background: rgba(91, 91, 214, 0.1); color: var(--accent); }
.pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pm-card { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; border-radius: var(--r); color: inherit; text-decoration: none; transition: transform 0.15s, box-shadow 0.15s; }
.pm-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.pm-card.archived { opacity: 0.6; }
.pm-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pm-card-head h3 { margin: 0; font-size: 16px; }
.pm-chips { gap: 6px; }
.pm-status { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pm-counts { display: flex; flex-wrap: wrap; gap: 10px; }
.pm-suggest { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pm-suggest .chip { margin-left: 8px; }
.pm-form textarea { width: 100%; }
.pm-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.pm-form label.row { flex-direction: row; align-items: center; }
.pm-watch { align-self: flex-end; padding-bottom: 8px; }
.pm-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.pm-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pm-title h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.pm-statusbox { margin-bottom: 18px; }
.pm-cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .pm-cols { grid-template-columns: 1fr; } }
.pm-list { display: flex; flex-direction: column; border-radius: var(--r); overflow: hidden; }
.pm-item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--hair); align-items: flex-start; }
.pm-item:last-child { border-bottom: 0; }
.pm-item.critical { box-shadow: inset 3px 0 0 var(--warn); }
.pm-item.flash { box-shadow: inset 3px 0 0 var(--accent); background: rgba(91, 91, 214, 0.06); }
.pm-side-head { display: flex; align-items: baseline; gap: 8px; margin: 14px 2px 6px; }
.pm-side-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.pm-answer { display: flex; flex-direction: column; gap: 6px; padding: 0 14px 12px; }
.pm-answer textarea { width: 100%; }
.party-row { align-items: center; }
.pm-item.closed { opacity: 0.65; }
.pm-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pm-item-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 500; }
.pm-item-title a.chip { text-decoration: none; }
.pm-done-text { text-decoration: line-through; }
.pm-item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pm-item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 46%; }
.pm-inline { width: 130px; padding: 3px 8px; font-size: 12.5px; border-radius: 8px; }
.pm-date { width: 140px; }
.pm-owner { width: 140px; }
.pm-trail summary { cursor: pointer; }
.pm-trail > div, .pm-trail > a { margin-top: 4px; }
.pm-add { flex-wrap: wrap; margin-bottom: 10px; gap: 8px; }
.pm-add .grow { min-width: 180px; }
.pm-decisions { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
.pm-price-add { margin-top: 8px; gap: 6px; }
.pm-price-add input { width: auto; flex: 1 1 90px; }
.pm-search { margin-bottom: 8px; }
.pm-thread { padding: 10px 14px; border-radius: var(--r-sm); }
.pm-thread > summary { cursor: pointer; list-style: none; }
.pm-thread > summary::-webkit-details-marker { display: none; }
.pm-thread-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-comm { padding: 8px 0; border-top: 1px solid var(--hair); display: flex; flex-direction: column; gap: 4px; }
.pm-comm:first-of-type { margin-top: 8px; }
.pm-comm-summary { font-size: 14px; }
.pm-comm details summary { cursor: pointer; }
.pm-facts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.pm-facts li { display: flex; gap: 8px; align-items: flex-start; }
.pm-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.ok { color: var(--ok); }
@media (max-width: 700px) {
  .pm-item { flex-direction: column; }
  .pm-item-actions { max-width: 100%; justify-content: flex-start; }
  .pm-page #tabs label { padding: 5px 11px; }
  .pm-grid { grid-template-columns: 1fr; }
}
.pm-agent { padding-left: 8px; border-left: 2px solid rgba(91, 91, 214, 0.35); }

/* ---------- sidebar: Live mic, account menu ---------- */
.side-brand-actions { display: flex; gap: 2px; }
.side-icon {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 10px;
  border: 0; background: none; color: var(--muted); cursor: pointer; box-shadow: none;
}
.side-icon svg { width: 18px; height: 18px; }
.side-icon:hover { background: rgba(17, 24, 39, 0.06); color: var(--ink); text-decoration: none; }
.side-icon.active { background: rgba(239, 68, 68, 0.1); color: var(--live); }
.side-foot { position: relative; }
.account-btn { padding: 8px 10px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; flex: none; object-fit: cover; }
.avatar-blank { display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 600; }
.avatar-blank:empty { background: rgba(17, 24, 39, 0.1); }
.account-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30; padding: 6px;
  display: flex; flex-direction: column; gap: 2px; background: var(--glass-hi); border-radius: var(--r-sm);
}
.account-menu[hidden] { display: none; }
.menu-sep { height: 1px; background: var(--hair); margin: 4px 6px; }

/* chat composer: Live mic next to send */
.composer a.icon-btn { display: inline-grid; place-items: center; color: var(--muted); text-decoration: none; }
.composer a.icon-btn:hover { color: var(--live); background: rgba(239, 68, 68, 0.08); }
.composer a.icon-btn svg { width: 19px; height: 19px; }

/* ---------- markdown (assistant replies) ---------- */
.md { white-space: normal; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5, .md h6 { margin: 18px 0 6px; letter-spacing: -0.01em; color: var(--ink); line-height: 1.3; }
.md h3 { font-size: 18px; }
.md h4 { font-size: 16px; }
.md h5, .md h6 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0 0; }
.md strong { font-weight: 600; color: var(--ink); }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; padding: 1px 5px; border-radius: 6px; background: rgba(17, 24, 39, 0.06); }
.md pre { margin: 0 0 10px; padding: 12px 14px; border-radius: var(--r-sm); background: rgba(17, 24, 39, 0.05); overflow-x: auto; }
.md pre code { padding: 0; background: none; white-space: pre; }
.md blockquote { margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--hair-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--hair); margin: 14px 0; }
.md a { overflow-wrap: anywhere; }
.md-table { overflow-x: auto; margin: 0 0 10px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { padding: 6px 12px; border-bottom: 1px solid var(--hair); text-align: left; }
.md th { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.insight-card .body .md p { margin-bottom: 4px; }

/* ---------- work board (Projects → Work) ---------- */
.work-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.work-summary { font-size: 15px; }
.work-filters { gap: 6px; margin-bottom: 16px; }
.chip-btn {
  font: inherit; font-size: 13px; font-weight: 400; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--hair-strong); background: transparent; color: var(--text); box-shadow: none;
}
.chip-btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-btn.on .muted { color: rgba(255, 255, 255, 0.65); }
.stage { font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: rgba(17, 24, 39, 0.06); color: var(--muted); }
.stage.s-researching, .stage.s-idea { background: rgba(17, 24, 39, 0.06); color: var(--muted); }
.stage.s-quoting, .stage.s-in_progress { background: rgba(91, 91, 214, 0.1); color: var(--accent); }
.stage.s-deciding, .stage.s-waiting { background: rgba(202, 138, 4, 0.13); color: #a16207; }
.stage.s-ordered { background: rgba(14, 116, 144, 0.1); color: #0e7490; }
.stage.s-blocked { background: rgba(239, 68, 68, 0.1); color: #b42318; }
.stage.s-done { background: rgba(15, 159, 110, 0.1); color: var(--ok); }
.path { display: inline-flex; gap: 3px; align-items: center; }
.path i { width: 14px; height: 4px; border-radius: 2px; background: rgba(17, 24, 39, 0.1); }
.path i.on { background: var(--accent); }
.spaced-bottom { margin-bottom: 18px; }

/* ---------- agents page ---------- */
.agents-page #tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.agents-page #tabs label { white-space: nowrap; }
.seg-count:not(:empty) { min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.agents-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat.attn .stat-value { color: var(--warn); }
.agents-page section > div + div { margin-top: 18px; }
.agents-narrow { max-width: 760px; }
.agents-narrow > .section-head + .muted { margin: 0 0 12px; }
.task.compact { cursor: pointer; padding: 12px 18px; }
.task.compact .result, .task.compact > .muted.small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task.compact .result { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.task.compact:not(.expanded) .links, .task.compact:not(.expanded) details, .task.compact:not(.expanded) .approval { display: none; }
.task.compact.expanded .result, .task.compact.expanded > .muted.small { display: block; -webkit-line-clamp: unset; }
@media (max-width: 700px) {
  .agents-page #tabs label { padding: 5px 11px; }
  .agents-stats { gap: 10px; }
  .agents-stats .stat { padding: 12px 14px; }
  .agents-stats .stat-value { font-size: 20px; }
  .agents-stats .stat-sub, .agents-page .section-head > .muted.small { display: none; }
}
#projectTabName { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* ---------- Board (projects.html): read-first cards, seller tables ---------- */
.tell-bar { display: flex; gap: 8px; padding: 6px; border-radius: 999px; margin-bottom: 14px; }
.tell-bar input { flex: 1; border: 0; background: transparent; padding: 8px 12px; }
.tell-bar input:focus { box-shadow: none; }
.board-q { margin: 0; padding-left: 18px; color: #a16207; }
.board-q li::marker { content: '?  '; font-weight: 600; }
.link-btn { font: inherit; font-size: 12.5px; font-weight: 500; padding: 0; border: 0; background: none; box-shadow: none; color: var(--accent); cursor: pointer; }
.link-btn.muted { color: var(--faint); }
.link-btn:hover { text-decoration: underline; }
.link-btn:active { transform: none; }
@media (max-width: 700px) {
  .tell-bar { border-radius: var(--r); }
}

/* ---------- Board: one page — to buy (every price per item), in progress, coming up, done ---------- */
.pm-page { max-width: 1180px; }
.faint { color: var(--faint); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mprice { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.board-head { align-items: flex-start; }
.board-links { display: flex; gap: 4px; flex-wrap: wrap; }
.board-links a { padding: 6px 12px; border-radius: 999px; font-size: 13.5px; color: var(--muted); }
.board-links a:hover { color: var(--ink); background: rgba(17, 24, 39, 0.05); text-decoration: none; }
.board-links a.on { color: var(--ink); background: rgba(17, 24, 39, 0.07); }
.board-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: -4px 4px 18px; }
.bfilter { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.bfilter .chip-btn { padding: 3px 11px; font-size: 12.5px; }
.bmove-wrap { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.bball { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.bball.you { background: #fdab3d; color: #fff; }
.bball.them { background: rgba(87, 155, 252, 0.16); color: #2f6fd1; }
.bprices .bquote-opt { font-weight: 400; white-space: normal; margin-top: 1px; }
.bprices tr.bquote-more td { border-top: 0; padding-top: 2px; }
.mseller .bball { margin-left: 6px; }

.bsection { margin-bottom: 34px; }
.bsection-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.bsection-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.bcount { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bcards { display: flex; flex-direction: column; gap: 14px; }

.bcard { background: #fff; border: 1px solid var(--hair-strong); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; }
.bcard.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.bcard.closed { opacity: 0.7; }
.bcard-head { display: flex; gap: 20px; padding: 16px 18px; cursor: pointer; }
.bcard-head:hover { background: #fafafb; }
.bcard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.bcard-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.bcard-title h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.bcard-main p { margin: 0; font-size: 13.5px; line-height: 1.45; }
.bnext { color: var(--ink); }
.blabel { display: inline-block; min-width: 38px; margin-right: 8px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.bstatus { color: var(--muted); }
.bfacts { color: var(--muted); font-size: 12.5px !important; }

.bpill { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; color: color-mix(in srgb, var(--c) 70%, #000); background: color-mix(in srgb, var(--c) 16%, #fff); }
.byou { font-size: 12px; font-weight: 600; color: var(--warn); background: rgba(194, 65, 12, 0.08); border-radius: 999px; padding: 2px 9px; }
.bwait { font-size: 12px; color: var(--muted); }
.bqs { font-size: 12px; color: #a16207; background: rgba(234, 179, 8, 0.14); border-radius: 999px; padding: 2px 9px; }

.bbest { flex: none; min-width: 120px; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.bbest-price { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.bbest-none { font-size: 13.5px; color: var(--faint); }
.bbest-sub { font-size: 12px; color: var(--muted); }
.bchat { align-self: flex-end; display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 4px 10px; border: 1px solid var(--hair-strong); border-radius: 999px; font-size: 12.5px; color: inherit; text-decoration: none; background: #fff; white-space: nowrap; }
.bchat:hover { background: #f3f4f6; }
.bchat svg { width: 14px; height: 14px; }
.mpanel-head .bchat { align-self: center; margin-top: 0; }

.bprices { border-top: 1px solid var(--hair-strong); overflow-x: auto; }
.bprices table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.bprices th { text-align: left; font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 8px 14px; background: #fafafb; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.bprices td { padding: 9px 14px; border-bottom: 1px solid var(--hair); vertical-align: top; }
.bprices tr:last-child td { border-bottom: 0; }
.bprices th:first-child, .bprices td:first-child { padding-left: 18px; }
.bprices .bseller { font-weight: 500; white-space: nowrap; }
.bprices .bprice { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bprices th.bprice { font-weight: 500; }
.bprices .bnote { color: var(--muted); min-width: 180px; }
.bprices .bupd { color: var(--muted); white-space: nowrap; text-align: right; }
.bprices tr.dead td { color: var(--faint); }
.bprices tr.dead .bprice { text-decoration: line-through; }
.bprices tr.noted td { background: #fcfcfd; }
.blowest { margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--ok); background: rgba(15, 159, 110, 0.1); border-radius: 999px; padding: 1px 7px; }
.bstate { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.bdot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.bprices-empty { border-top: 1px solid var(--hair); padding: 10px 18px; font-size: 13px; color: var(--faint); }

.btimeline { display: flex; flex-direction: column; padding: 4px 0; }
.bt-row { display: grid; grid-template-columns: 140px 1fr auto; gap: 14px; align-items: baseline; padding: 10px 18px; font: inherit; font-size: 13.5px; text-align: left; border: 0; border-radius: 0; background: none; box-shadow: none; cursor: pointer; color: inherit; }
.bt-row + .bt-row { border-top: 1px solid var(--hair); }
.bt-row:hover:not(:disabled) { background: rgba(17, 24, 39, 0.03); }
.bt-row:active { transform: none; }
.bt-row:disabled { cursor: default; opacity: 1; }
.bt-when { font-weight: 600; font-variant-numeric: tabular-nums; }
.bt-row.late .bt-when { color: var(--warn); }
.bt-what { display: flex; gap: 8px; align-items: center; }
.bt-meta { color: var(--muted); font-size: 12.5px; }

.bdone summary { cursor: pointer; font-size: 14px; color: var(--muted); padding: 4px 0; }
.bdone-list { display: flex; flex-direction: column; margin-top: 8px; background: #fff; border: 1px solid var(--hair-strong); border-radius: 12px; overflow: hidden; }
.bdone-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; font: inherit; font-size: 13.5px; text-align: left; border: 0; border-radius: 0; background: none; box-shadow: none; cursor: pointer; color: var(--muted); }
.bdone-row + .bdone-row { border-top: 1px solid var(--hair); }
.bdone-row:hover { background: #fafafb; }
.bdone-row .grow { flex: 1; }

@media (max-width: 760px) {
  .bcard-head { flex-direction: column; gap: 10px; padding: 14px; }
  .bbest { text-align: left; flex-direction: row; align-items: baseline; gap: 10px; }
  .bbest .bchat { margin: 0 0 0 auto; align-self: center; }
  .bt-row { grid-template-columns: 1fr; gap: 2px; }
  .bprices .bnote { min-width: 140px; }
}

/* side panel */
.mpanel { position: fixed; z-index: 25; top: 12px; right: 12px; bottom: 12px; width: min(440px, calc(100vw - 24px)); overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; background: #fff; border-radius: var(--r-lg); border: 1px solid var(--hair-strong); box-shadow: 0 24px 60px -20px rgba(17, 24, 39, 0.28); }
.mpanel[hidden] { display: none; }
.mpanel h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.mpanel h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mpanel-head { display: flex; align-items: flex-start; gap: 10px; }
.mpanel-status .bpill { height: 28px; padding: 0 14px; font-size: 13px; }
.mpanel-text { margin: 0; font-size: 15px; line-height: 1.55; }
.mpanel-dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; padding: 14px 16px; font-size: 13.5px; background: #fafafb; border-radius: 12px; }
.mpanel-dl dt { color: var(--muted); }
.mpanel-dl dd { margin: 0; }
.mpanel-dl dd.warn { color: var(--warn); font-weight: 600; }
.mpanel-sellers { display: flex; flex-direction: column; border: 1px solid var(--hair); border-radius: 12px; overflow: hidden; }
.mseller { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; font-size: 13.5px; }
.mseller + .mseller { border-top: 1px solid var(--hair); }
.mseller.v-declined, .mseller.v-passed { color: var(--faint); }
.mdot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; margin-top: 6px; }
.mpanel-tell { display: flex; gap: 6px; }
.mpanel-tell input { flex: 1; min-width: 0; }
.mfeed { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--hair); display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.mpanel-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hair); }
@media (min-width: 1400px) { body.panel-open .pm-page { margin-right: 470px; } }

/* ---------- WeChat page: the server's WeChat window, live ---------- */
.wx-page { display: flex; flex-direction: column; height: 100vh; padding: 16px 20px 16px 0; box-sizing: border-box; gap: 12px; }
.wx-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wx-bar h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.wx-state { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: rgba(17, 24, 39, 0.06); color: var(--muted); }
.wx-state.ok { background: rgba(7, 193, 96, 0.12); color: #068a46; }
.wx-state.warn { background: rgba(202, 138, 4, 0.12); color: #a16207; }
.wx-state.bad { background: rgba(239, 68, 68, 0.1); color: #b42318; }
.wx-paste { display: flex; gap: 6px; flex: 1; min-width: 280px; }
.wx-paste input { flex: 1; min-width: 0; }
.wx-screen { flex: 1; min-height: 0; position: relative; border-radius: var(--r); overflow: hidden; background: #f2f2f4; border: 1px solid var(--hair-strong); }
.wx-screen:fullscreen { border-radius: 0; }
.wx-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; }
@media (max-width: 860px) { .wx-page { padding: 8px 12px 12px; height: calc(100vh - 64px); } }

/* A check (CAPTCHA) mirrored into a plugin card */
.chal { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.chal-img:not([src]) { display: none; }
.chal-img { display: block; min-width: 120px; max-width: 100%; border-radius: 10px; border: 1px solid var(--hair-strong); cursor: grab; touch-action: none; user-select: none; -webkit-user-drag: none; background: #fff; min-height: 60px; }
.chal-img:active { cursor: grabbing; }

/* ---------------- Context page (the shared pool) ---------------- */
.ctx-sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 10px; }
.ctx-src { padding: 10px 12px; border-radius: var(--r-sm); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ctx-src-top { display: flex; align-items: center; gap: 7px; }
.ctx-src-top strong { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-src-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-src .link-btn { align-self: flex-start; padding: 0; margin-top: 2px; }
.ctx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.ctx-src.on .ctx-dot { background: var(--ok); }
.ctx-src.err .ctx-dot { background: var(--warn); }
.ctx-src.off { opacity: 0.6; }
.ctx-meta { padding: 0 4px 14px; }
.ctx-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.ctx-filters #q { flex: 1 1 260px; border-radius: 999px; padding: 8px 14px; }
.ctx-noise { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ctx-noise input { width: auto; }
.ctx-list { display: flex; flex-direction: column; }
.ctx-day { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 18px 4px 6px; }
.ctx-item { border-bottom: 1px solid var(--hair); }
.ctx-item.noise { opacity: 0.55; }
.ctx-row { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 64px 84px minmax(0, 1fr); gap: 10px; width: 100%; padding: 10px 4px; align-items: baseline; }
.ctx-row:hover { background: rgba(17, 24, 39, 0.025); }
.ctx-time { white-space: nowrap; }
.ctx-app { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ctx-who { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-sum { font-size: 14px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ctx-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.ctx-proj { background: rgba(91, 91, 214, 0.1); color: var(--accent); }
.ctx-track { background: rgba(15, 159, 110, 0.1); color: var(--ok); }
.ctx-act { background: rgba(194, 65, 12, 0.08); color: var(--warn); }
.ctx-detail { padding: 0 4px 14px 168px; display: flex; flex-direction: column; gap: 10px; }
.ctx-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; max-height: 360px; overflow-y: auto; padding: 10px 12px; border-radius: var(--r-sm); background: rgba(17, 24, 39, 0.035); }
.ctx-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .ctx-row { grid-template-columns: 52px minmax(0, 1fr); }
  .ctx-app { display: none; }
  .ctx-detail { padding-left: 4px; }
}

/* ---------- plans page (layout only: rows, chips and cards are the Context page's) ---------- */
.plans-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.plans-tree { padding: 8px; display: flex; flex-direction: column; gap: 1px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.plans-folder { all: unset; box-sizing: border-box; cursor: pointer; padding: 6px 10px; border-radius: var(--r-sm); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plans-folder:hover { background: rgba(17, 24, 39, 0.04); }
.plans-folder.on { background: rgba(17, 24, 39, 0.07); color: var(--ink); font-weight: 500; }
.plans-list .ctx-row { grid-template-columns: 96px 84px minmax(0, 1fr); }
.plans-page .md-table tr.muted td { color: var(--faint); }
.plans-page .md-table td:first-child, .plans-page .md-table td:nth-child(5) { white-space: nowrap; }
.plans-settings { max-width: 560px; }
@media (max-width: 860px) {
  .plans-grid { grid-template-columns: minmax(0, 1fr); }
  .plans-tree { position: static; max-height: 240px; }
}
@media (max-width: 640px) {
  .plans-list .ctx-row { grid-template-columns: 52px minmax(0, 1fr); }
}

/* chat opened from a Board item */
.about-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border: 1px solid var(--hair-strong); border-radius: 999px; font-size: 13px; background: #fff; }
.about-chip a { color: var(--muted); text-decoration: none; }
.about-chip a:hover { text-decoration: underline; }

/* Board items laid out for the decision: measure columns with their arithmetic, the as-quoted price demoted */
.bprices td.bseller { min-width: 150px; }
.bprices .bmeasure .bhow { font-weight: 400; white-space: normal; max-width: 220px; margin-top: 2px; }
.bprices th.bmeasure { cursor: help; }
.bprices .bquoted { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mbreak { margin: 6px 0; }
.mbreak summary { cursor: pointer; }
.mbreak-t { width: 100%; border-collapse: collapse; margin: 4px 0; font-size: 13px; }
.mbreak-t td { padding: 2px 4px; border-bottom: 1px solid var(--line, rgba(0, 0, 0, 0.06)); }
.mbreak-t td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mmeasures { margin: 4px 0 8px; padding-left: 18px; }
.mmeasures li { margin: 2px 0; }

/* ---------- embedded in the chat canvas (projects.html / loops.html ?embed=<id>) ---------- */
body.embed.shell { padding: 0; background: #fff; }
body.embed > :not(#embedRoot):not(#banner) { display: none !important; }
#embedRoot { padding: 18px 20px 28px; }
body.embed #itemPanel { position: static; width: auto; inset: auto; padding: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; background: transparent; }
body.embed #itemPanel .bchat, body.embed #itemPanel .mpanel-head > .icon-btn { display: none; }
body.embed #embedRoot > .loop { box-shadow: none; }

/* ---------- pages opened over a running Live session (live-host.js) ---------- */
.live-host { position: fixed; inset: 0; z-index: 60; background: var(--canvas); }
.lh-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
body.live-away { overflow: hidden; }
.lh-pill {
  position: absolute; z-index: 2; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--shadow); border: 1px solid var(--glass-edge);
}
.lh-pill button { border: 0; background: none; padding: 5px 12px; font-size: 13px; }
.lh-pill button:hover { background: rgba(17, 24, 39, 0.05); }
.lh-back { gap: 8px; color: var(--ink); }
.lh-toggle { color: var(--muted); font-weight: 400; }
.lh-pill .live-dot { background: var(--faint); box-shadow: none; }
.lh-pill.on .live-dot { background: var(--live); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); animation: blink 1.6s ease-in-out infinite; }
.lh-flash {
  position: absolute; z-index: 2; top: 56px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 32px));
  padding: 10px 14px; border-radius: var(--r-sm); text-align: left; justify-content: flex-start; font-weight: 400; font-size: 13.5px; line-height: 1.45;
  background: rgba(255, 255, 255, 0.94); color: var(--text);
}
.live-mic.live-on { position: relative; color: var(--live); }
.live-mic.live-on::after { content: ''; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--live); animation: blink 1.6s ease-in-out infinite; }

/* ---------- History (history.html): past chats and Live conversations ---------- */
.hist-search { width: min(340px, 100%); }
.hist-tabs { margin-bottom: 14px; }
.hist { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.hist.with-view { grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); }
.hist-list { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hist-day { padding-left: 4px; }
.hist-row { display: flex; align-items: center; gap: 6px; border-radius: var(--r-sm); }
.hist-row:hover, .hist-row.active { background: var(--glass-hi); box-shadow: var(--shadow-sm); }
.hist-row .danger-ghost { opacity: 0; }
.hist-row:hover .danger-ghost, .hist-row .danger-ghost:focus { opacity: 1; }
.hist-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 9px 12px;
  background: transparent; border: 0; box-shadow: none; border-radius: var(--r-sm); color: var(--text); text-align: left; font: inherit; font-weight: 400;
}
.hist-main:hover { background: transparent; box-shadow: none; text-decoration: none; }
.hist-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-snippet { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hist-meta { color: var(--faint); font-size: 12px; }
.hist mark { background: rgba(91, 91, 214, 0.16); color: inherit; border-radius: 3px; padding: 0 1px; }
.hist-view { padding: 18px 20px; position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; min-width: 0; }
.hist-view-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 10px 16px; padding-bottom: 12px; border-bottom: 1px solid var(--hair); }
.hist-view-head h2 { margin: 0; }
.hist-view-head p { margin: 2px 0 0; }
.hist-back { display: none; }
.hist-lines { overflow-y: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.hist-line { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; line-height: 1.5; }
.hist-t { color: var(--faint); font-size: 12px; padding-top: 2px; font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .hist.with-view { grid-template-columns: minmax(0, 1fr); }
  .hist.with-view .hist-list { display: none; }
  .hist-back { display: inline-flex; }
  .hist-view { position: static; max-height: none; }
  .hist-row .danger-ghost { opacity: 1; }
}
