:root {
  --bg: #f9f8f5;
  --bg-elev: #ffffff;
  --bg-side: #f1efe9;
  --bg-hover: #e8e5dc;
  --bg-user: #ece9e1;
  --bg-code: #1f2328;
  --border: #e0ddd3;
  --text: #1f1e1c;
  --muted: #75736c;
  --accent: #c96442;
  --accent-hover: #b4573a;
  --danger: #c0392b;
  --warn-bg: #fff4d6;
  --warn-text: #7a5a00;
  --err-bg: #fde8e6;
  --err-text: #9b2c20;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 24px rgba(0,0,0,.06);
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262624;
    --bg-elev: #30302e;
    --bg-side: #1f1e1d;
    --bg-hover: #3a3936;
    --bg-user: #383733;
    --bg-code: #1a1a19;
    --border: #45443f;
    --text: #ecebe6;
    --muted: #a3a199;
    --accent: #d97757;
    --accent-hover: #e48a6c;
    --warn-bg: #3d3420;
    --warn-text: #f0d48a;
    --err-bg: #44231f;
    --err-text: #f3a99f;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error-text { color: var(--err-text); min-height: 1.2em; margin: 0; }

.app { display: flex; height: 100dvh; overflow: hidden; }

/* Buttons */
.btn { border: 1px solid var(--border); background: var(--bg-elev); border-radius: 10px; padding: 8px 14px; cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; text-align: left; }
.btn.ghost:hover { background: var(--bg-hover); }
.icon-btn { border: none; background: transparent; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 17px; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.mobile-only { display: none; }

/* Sidebar */
.sidebar { width: 272px; flex: none; background: var(--bg-side); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 12px; gap: 8px; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 600; font-size: 16px; padding: 6px 4px; display: flex; gap: 8px; align-items: center; }
.logo { color: var(--accent); font-size: 20px; }
.new-chat { width: 100%; text-align: left; font-weight: 500; }
.search { width: 100%; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-elev); }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.conv-group { font-size: 12px; color: var(--muted); padding: 10px 8px 4px; font-weight: 500; }
.conv-item { display: flex; align-items: center; gap: 4px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-hover); font-weight: 500; }
.conv-item .title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-item .actions { display: none; gap: 2px; }
.conv-item:hover .actions, .conv-item.active .actions { display: flex; }
.conv-item .actions button { border: none; background: transparent; cursor: pointer; color: var(--muted); padding: 0 4px; border-radius: 4px; }
.conv-item .actions button:hover { color: var(--text); background: var(--bg); }
.sidebar-bottom { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 8px; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--bg); min-height: 56px; }
.selectors { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1; min-width: 0; }
.sel { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sel select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font-size: 14px; max-width: 200px; }
.toggle { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elev); }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.ctx-meter { font-size: 12px; color: var(--muted); white-space: nowrap; padding: 0 6px; }

.chat { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.empty { text-align: center; margin: 14vh auto 0; max-width: 520px; padding: 0 16px; }
.empty h2 { font-weight: 500; font-size: 28px; margin: 8px 0; font-family: Georgia, "Times New Roman", serif; }
.logo-big { font-size: 44px; color: var(--accent); line-height: 1; }
.messages { max-width: 800px; margin: 0 auto; padding: 24px 20px 40px; display: flex; flex-direction: column; gap: 22px; }

/* Messages */
.msg { position: relative; }
.msg.user { align-self: flex-end; max-width: 85%; }
.msg.user .bubble { background: var(--bg-user); border-radius: var(--radius); padding: 10px 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .att-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.msg.user .att-row img { max-height: 140px; max-width: 220px; border-radius: 10px; border: 1px solid var(--border); }
.msg.assistant { width: 100%; }
.msg .msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg.last .msg-actions { opacity: 1; }
.msg.user .msg-actions { justify-content: flex-end; }
.msg-actions button { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 3px 7px; border-radius: 6px; }
.msg-actions button:hover { background: var(--bg-hover); color: var(--text); }
.msg-meta { font-size: 12px; color: var(--muted); align-self: center; margin-left: 6px; }
.sys-note { align-self: center; font-size: 12px; color: var(--muted); border: 1px dashed var(--border); border-radius: 999px; padding: 3px 12px; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.md { word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .8em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .5em; line-height: 1.3; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; }
.md ul, .md ol { padding-left: 1.5em; margin: 0 0 .8em; }
.md li { margin: .2em 0; }
.md a { color: var(--accent); }
.md blockquote { border-left: 3px solid var(--border); margin: 0 0 .8em; padding: 0 1em; color: var(--muted); }
.md table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--bg-side); }
.md code { font-family: var(--mono); font-size: .88em; background: var(--bg-user); padding: .1em .35em; border-radius: 5px; }
.md pre { position: relative; background: var(--bg-code); color: #e6e6e6; border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 0 0 1em; }
.md pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }
.md pre .copy-code { position: absolute; top: 6px; right: 6px; border: none; background: rgba(255,255,255,.1); color: #ddd; border-radius: 6px; font-size: 12px; padding: 3px 8px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.md pre:hover .copy-code { opacity: 1; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md img { max-width: 100%; }

.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* Blocks inside assistant turn */
.block { margin: 0 0 12px; }
details.thinking, .tool-card, .note-card { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); font-size: 13.5px; }
details.thinking summary, .tool-card summary { cursor: pointer; padding: 7px 12px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
details.thinking summary::-webkit-details-marker, .tool-card summary::-webkit-details-marker { display: none; }
details.thinking summary::before, .tool-card summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 15px; }
details[open].thinking summary::before, details[open].tool-card summary::before { transform: rotate(90deg); }
details.thinking .thinking-body { padding: 4px 14px 12px; color: var(--muted); white-space: pre-wrap; max-height: 420px; overflow-y: auto; }
.tool-card .tool-body { padding: 4px 12px 10px; }
.tool-card .tool-label { font-weight: 500; color: var(--text); }
.tool-card .tool-sub { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.tool-card pre { background: var(--bg-code); color: #e6e6e6; padding: 10px 12px; border-radius: 8px; font: 12.5px/1.5 var(--mono); overflow-x: auto; max-height: 360px; margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.tool-card .status { font-size: 12px; margin-left: auto; flex: none; }
.status.ok { color: #2e8b57; } .status.err { color: var(--danger); } .status.run { color: var(--accent); }
.spinner { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.search-results { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; }
.search-results a { color: var(--text); text-decoration: none; display: block; padding: 4px 8px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results a:hover { background: var(--bg-hover); }
.search-results a small { color: var(--muted); margin-left: 6px; }
.citations { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.citations a { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; text-decoration: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citations a:hover { color: var(--text); background: var(--bg-hover); }
.note-card { padding: 7px 12px; color: var(--muted); }
.notice { border-radius: 10px; padding: 9px 14px; font-size: 14px; margin: 0 0 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.error { background: var(--err-bg); color: var(--err-text); }
.notice button { margin-left: auto; }
.aborted { opacity: .6; }
.working { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 8px; }

/* Composer */
.composer-wrap { padding: 0 20px 14px; max-width: 840px; width: 100%; margin: 0 auto; position: relative; }
.composer { display: flex; align-items: flex-end; gap: 6px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px; padding: 8px; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: none; outline: none; background: transparent; resize: none; max-height: 40vh; padding: 7px 6px; line-height: 1.5; }
.btn.send { width: 38px; height: 38px; padding: 0; border-radius: 12px; flex: none; font-size: 15px; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.attachments:empty { display: none; }
.att { position: relative; border: 1px solid var(--border); background: var(--bg-elev); border-radius: 10px; padding: 6px 28px 6px 8px; font-size: 13px; display: flex; align-items: center; gap: 6px; max-width: 240px; }
.att img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att button { position: absolute; top: 3px; right: 3px; border: none; background: transparent; cursor: pointer; color: var(--muted); }
.file-chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; font-size: 13px; background: var(--bg-elev); }
.drop-hint { position: absolute; inset: -60px 20px 14px; border: 2px dashed var(--accent); border-radius: 18px; background: color-mix(in srgb, var(--bg) 85%, transparent); display: grid; place-items: center; font-weight: 500; color: var(--accent); z-index: 5; }
.usage-bar { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; min-height: 18px; }

/* Drawer */
.drawer { width: 360px; flex: none; border-left: 1px solid var(--border); background: var(--bg-elev); display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.drawer-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span { font-weight: 500; }
.field textarea, .field input:not([type="checkbox"]):not([type="radio"]), .field select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); resize: vertical; }
.field small { font-size: 12px; line-height: 1.45; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input:disabled + * , .check:has(input:disabled) { opacity: .6; cursor: not-allowed; }
hr { border: none; border-top: 1px solid var(--border); width: 100%; margin: 0; }

/* Overlays */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.login-card { padding: 32px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 600; }
.login-card p { margin: 0; }
.login-card input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }
#login { background: var(--bg); }
.modal { width: min(720px, 100%); max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal > p { padding: 0 16px; }
.memory-list { overflow-y: auto; padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.memory-item { border: 1px solid var(--border); border-radius: 10px; }
.memory-item header { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font: 13px var(--mono); border-bottom: 1px solid var(--border); }
.memory-item pre { margin: 0; padding: 10px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; max-height: 240px; overflow-y: auto; }

/* Mobile */
@media (max-width: 860px) {
  .mobile-only { display: inline-block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .drawer { position: fixed; inset: 0 0 0 auto; width: min(380px, 100%); z-index: 40; box-shadow: var(--shadow); }
  .topbar { padding: 8px 10px; }
  .sel > span { display: none; }
  .sel select { max-width: 150px; }
  .ctx-meter { display: none; }
  .messages { padding: 16px 16px 32px; }
  .composer-wrap { padding: 0 10px 10px; }
  .msg.user { max-width: 92%; }
}

/* v2 additions */
.small { font-size: 12px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.budget-chip { border: 1px solid var(--border); background: var(--bg-elev); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; color: var(--text); white-space: nowrap; }
.budget-chip:empty { display: none; }
.budget-chip.low { border-color: var(--danger); color: var(--danger); }
.live-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 0 4px 8px; min-height: 20px; overflow: hidden; white-space: nowrap; }
.live-status .phase { overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.live-status .timer { font-variant-numeric: tabular-nums; flex: none; }
.modal.wide { width: min(980px, 100%); }
.modal-body { overflow-y: auto; padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-body > p { margin: 12px 0 0; }
.upload-box { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border: 1px dashed var(--border); border-radius: 12px; padding: 12px; }
.upload-box input[type=text], .upload-box input:not([type]) { flex: 1; min-width: 200px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); }
.upload-box input[type=file] { flex: 1; min-width: 200px; font-size: 13px; }
.progress { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.bar { height: 6px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.manual-list { display: flex; flex-direction: column; gap: 8px; }
.manual { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.manual .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.manual .product { font-weight: 600; }
.manual .meta { font-size: 12.5px; color: var(--muted); }
.manual .desc { font-size: 13px; color: var(--muted); }
.manual .acts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.manual .acts button { font-size: 12.5px; padding: 4px 10px; }
.manual pre.toc { margin: 6px 0 0; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; max-height: 320px; overflow-y: auto; background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.badge { font-size: 11px; border-radius: 99px; padding: 1px 8px; border: 1px solid var(--border); color: var(--muted); }
.badge.warn { border-color: #d4a017; color: var(--warn-text); background: var(--warn-bg); }
.price-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.price-table th, .price-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: right; white-space: nowrap; }
.price-table th:first-child, .price-table td:first-child { text-align: left; white-space: normal; }
.price-table td small { color: var(--muted); display: block; font-size: 12px; }
.price-table tr.current td { background: var(--bg-side); }
.table-wrap { overflow-x: auto; }
.thinking.update { border-style: dashed; }

/* Projects */
.proj-section { display: flex; flex-direction: column; gap: 2px; max-height: 38vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.proj-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 4px 2px 8px; }
.icon-btn.small { width: 26px; height: 26px; font-size: 15px; }
.proj-list { display: flex; flex-direction: column; gap: 1px; }
.proj-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.proj-item:hover { background: var(--bg-hover); }
.proj-item.active { background: var(--bg-hover); font-weight: 600; }
.proj-item .name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.proj-item .count { font-size: 11px; color: var(--muted); }
.proj-item .edit { border: none; background: transparent; color: var(--muted); cursor: pointer; display: none; padding: 0 4px; border-radius: 4px; }
.proj-item:hover .edit, .proj-item.active .edit { display: inline; }
.proj-item .edit:hover { color: var(--text); background: var(--bg); }
.conv-item .proj-ico { font-size: 12px; opacity: .8; }
.project-chip { border: 1px solid var(--border); background: var(--bg-side); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--text); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }
.project-chip:hover { background: var(--bg-hover); }
.project-body { padding-top: 14px; gap: 16px; }
.project-body .row { gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 160px; }
.icon-field { width: 76px; flex: none; }
.icon-field input { text-align: center; font-size: 18px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 12px; }
.manual-pick { display: flex; flex-direction: column; gap: 4px; padding: 4px 0 0 24px; max-height: 220px; overflow-y: auto; }
.manual-pick .grp { font-size: 12px; color: var(--muted); margin-top: 6px; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); }
.danger-text { color: var(--danger); }
.move-list { display: flex; flex-direction: column; gap: 4px; }
.move-list button { text-align: left; }
.move-list button.current { font-weight: 600; background: var(--bg-hover); }
.empty .proj-info { margin-top: 18px; text-align: left; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 14px; background: var(--bg-elev); }
.empty .proj-info pre { white-space: pre-wrap; font: inherit; margin: 6px 0 0; color: var(--muted); max-height: 160px; overflow: hidden; }
@media (max-width: 860px) { .project-chip { max-width: 130px; } }

/* Context menu */
.ctx-menu { position: fixed; z-index: 100; min-width: 220px; max-width: 320px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; }
.ctx-item { border: none; background: transparent; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-item:hover, .ctx-item:focus { background: var(--bg-hover); outline: none; }
.ctx-item.danger { color: var(--danger); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.conv-item .spinner { flex: none; }

/* Microphone */
.icon-btn.mic.recording { background: var(--danger); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.icon-btn.mic.busy { opacity: .6; cursor: progress; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 25%, transparent); } }

/* Generated files */
.files-bar { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.files-bar.inline { margin: 6px 0 2px; }
.files-title { font-size: 12px; color: var(--muted); font-weight: 500; }
.file-out { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px 6px 12px; background: var(--bg-elev); font-size: 14px; max-width: 560px; }
.file-out .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-out .btn { padding: 4px 10px; font-size: 13px; }
.file-out.gone { opacity: .55; }
/* MCP */
.mcp-list { display: flex; flex-direction: column; gap: 4px; }
.mcp-item { display: flex; align-items: center; gap: 8px; }
.mcp-item .mcp-url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcp-form { display: flex; flex-direction: column; gap: 6px; }
.mcp-form input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }

/* Skills & proposals */
.skills-list { display: flex; flex-direction: column; gap: 8px; }
.skill-item { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.skill-head { display: flex; align-items: center; gap: 8px; }
.skill-item a, .proposal a { color: var(--accent); word-break: break-all; }
.proposal { border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; margin: -6px 0 12px; background: var(--bg-elev); display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.proposal-title { font-weight: 600; }
.proposal-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.proposal-token { flex: 1; min-width: 180px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.ok-text { color: #2e8b57; }

/* Helper agents */
.sub-box { border: 1px dashed var(--accent); border-radius: 10px; padding: 7px 12px; margin: -6px 0 12px; font-size: 13px; background: var(--bg-elev); }
.sub-head { display: flex; align-items: center; gap: 6px; color: var(--text); }
.sub-steps { color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Local folder */
.folder-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.folder-bar[hidden] { display: none; }
.diff { max-height: 320px; overflow: auto; font: 12.5px/1.5 var(--mono); border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.diff > div { white-space: pre-wrap; overflow-wrap: anywhere; padding: 0 8px; min-height: 1.5em; }
.diff .add { background: rgba(46, 160, 67, .18); }
.diff .del { background: rgba(218, 54, 51, .16); }
