:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f1f3f6; --text: #16181d; --muted: #646b78; --border: #dfe3ea;
  --accent: #4f6bed; --accent-ink: #ffffff; --ok: #12a17d; --warn: #c27c0e; --err: #d1435b; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --lane-0: #4f6bed; --lane-1: #d9822b; --lane-2: #12a17d; --lane-3: #a35bd6; --lane-4: #d1435b; --lane-5: #2a9dc4;
  --radius: 12px; --sidebar: 268px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --text: #e7e9ee; --muted: #9aa1ad; --border: #2a2f3a;
    --accent: #7b8ff5; --accent-ink: #0f1115; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* buttons */
.btn { border: 1px solid var(--border); background: var(--panel); border-radius: 8px; padding: 6px 12px; line-height: 1.3; }
.btn:hover:not(:disabled) { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.small { padding: 3px 8px; font-size: 13px; border-radius: 6px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn.danger { color: var(--err); }
.btn.on { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border-color: var(--accent); }
.input, .textarea, .select { width: 100%; border: 1px solid var(--border); background: var(--panel); border-radius: 8px; padding: 8px 10px; }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card form { display: grid; gap: 10px; margin-top: 18px; }
.err-text { color: var(--err); font-size: 14px; min-height: 1em; }

/* layout */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100vh; }
.sidebar { border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { padding: 14px; display: grid; gap: 10px; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-flex; gap: 2px; } .brand-mark i { width: 5px; height: 14px; border-radius: 2px; display: block; }
.conv-list { overflow-y: auto; padding: 4px 8px; flex: 1; }
.conv-item { display: flex; align-items: center; gap: 4px; border-radius: 8px; padding: 7px 8px; cursor: pointer; }
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.conv-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.conv-item .x { visibility: hidden; }
.conv-item:hover .x { visibility: visible; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 14px; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.sidebar-foot .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mobile-top { display: none; }

/* new conversation */
.new-wrap { overflow-y: auto; padding: 32px 24px 48px; }
.new-inner { max-width: 860px; margin: 0 auto; display: grid; gap: 18px; }
.new-inner h1 { font-size: 26px; margin: 0; }
.section-title { font-weight: 600; margin: 0 0 8px; display: flex; align-items: baseline; gap: 8px; }

/* model picker */
.picker { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.picker-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); align-items: center; }
.picker-bar .input { flex: 1 1 220px; }
.chip { border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.picker-selected { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); min-height: 46px; align-items: center; }
.sel-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; background: var(--panel-2); border: 1px solid var(--border); }
.sel-chip button { border: 0; background: transparent; padding: 0 6px; font-size: 15px; line-height: 1; color: var(--muted); }
.picker-list { max-height: 360px; overflow-y: auto; }
.model-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: start; }
.model-row:last-child { border-bottom: 0; }
.model-row:hover { background: var(--panel-2); }
.model-row.disabled { opacity: .45; cursor: not-allowed; }
.model-row input { margin-top: 4px; }
.model-name { font-weight: 600; font-size: 14px; }
.model-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.model-desc { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { font-size: 12px; text-align: right; white-space: nowrap; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); margin-right: 3px; }
.tag.free { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); font-weight: 600; }

/* conversation */
.conv-head { border-bottom: 1px solid var(--border); background: var(--panel); padding: 10px 16px; display: grid; gap: 8px; }
.conv-title-row { display: flex; align-items: center; gap: 10px; }
.conv-title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; background: transparent; padding: 2px 4px; border-radius: 6px; }
.conv-title:focus { outline: 1px solid var(--border); }
.stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.stats b { color: var(--text); font-weight: 600; }
.lanes-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lane-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; background: var(--panel); }
.lane-chip.paused { opacity: .6; border-style: dashed; }
.lane-chip.removed { display: none; }
.lane-chip .dot, .card .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.context-panel { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.context-panel summary { cursor: pointer; font-weight: 600; }
.ctx-item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--border); }
.ctx-item:first-of-type { border-top: 0; }
.ctx-item .body { flex: 1; min-width: 0; }
.ctx-item .snip { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.thread { flex: 1; overflow-y: auto; padding: 18px 16px 28px; }
.turn { max-width: 1500px; margin: 0 auto 26px; }
.user-msg { max-width: 760px; margin: 0 0 12px auto; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border)); padding: 10px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn-meta { text-align: right; font-size: 12px; color: var(--muted); margin: -6px 0 10px; }
.lanes { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 12px; align-items: start; }
.lane-tabs { display: none; }
.card { background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--lane, var(--accent)); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.card.is-final { outline: 2px solid var(--ok); }
.card-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.card-head .name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.generating { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.badge.completed { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.badge.failed { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.badge.rate_limited { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.badge.final { color: var(--ok); border: 1px solid var(--ok); background: transparent; }
.card-body { padding: 10px 14px; min-height: 64px; overflow-wrap: anywhere; }
.card-body h1, .card-body h2 { font-size: 1.15em; margin: .8em 0 .4em; } .card-body h3, .card-body h4 { font-size: 1.02em; margin: .8em 0 .3em; }
.card-body.md > :first-child { margin-top: 0; } .card-body.md > :last-child { margin-bottom: 0; }
.card-body pre { background: var(--panel-2); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.card-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.card-body table { border-collapse: collapse; display: block; overflow-x: auto; }
.card-body th, .card-body td { border: 1px solid var(--border); padding: 4px 8px; }
.card-body.collapsed { max-height: 420px; overflow: hidden; mask-image: linear-gradient(#000 80%, transparent); }
.expand { margin: 0 14px 6px; }
.thinking { margin: 8px 14px 0; font-size: 13px; color: var(--muted); }
.thinking summary { cursor: pointer; }
.thinking pre { white-space: pre-wrap; max-height: 220px; overflow-y: auto; background: var(--panel-2); padding: 8px; border-radius: 8px; font-size: 12px; }
.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.err-box { margin: 10px 14px; padding: 8px 10px; border-radius: 8px; font-size: 13px; background: color-mix(in srgb, var(--err) 10%, transparent); color: var(--err); }
.err-box.warn { background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--text); }
.err-box.warn .err-title { color: var(--warn); }
.card-meta { padding: 0 14px 6px; font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.card-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--border); }
.empty-thread { max-width: 520px; margin: 60px auto; text-align: center; color: var(--muted); }

/* composer */
.composer { border-top: 1px solid var(--border); background: var(--panel); padding: 10px 16px 14px; }
.composer-inner { max-width: 1100px; margin: 0 auto; display: grid; gap: 6px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer .textarea { resize: none; min-height: 46px; max-height: 240px; }
.composer-meta { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.composer-meta .select { width: auto; padding: 4px 8px; }
.pin-note { font-size: 13px; color: var(--accent); }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(10,12,16,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 760px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head h2 { font-size: 17px; margin: 0; flex: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: grid; gap: 14px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.out-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.out-item .q { font-size: 13px; color: var(--muted); }
.ctx-msg { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.ctx-msg .role { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ctx-msg pre { white-space: pre-wrap; margin: 4px 0 0; font-size: 13px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
#toast.show { opacity: 1; }

/* mobile */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .layout.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .mobile-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel); }
  .new-wrap { padding: 20px 16px 40px; }
  .thread { padding: 14px 12px 24px; }
  .conv-head, .composer { padding-left: 12px; padding-right: 12px; }
  .lanes { display: block; }
  .lanes .card { display: none; }
  .lanes .card.tab-active { display: flex; }
  .lane-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; }
  .lane-tabs button { flex: none; border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 4px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
  .lane-tabs button.on { border-color: var(--lane); background: color-mix(in srgb, var(--lane) 14%, var(--panel)); font-weight: 600; }
  .model-row { grid-template-columns: 22px 1fr; }
  .conv-head { gap: 6px; padding-top: 8px; padding-bottom: 8px; }
  .conv-title { display: none; }
  .main:has(.conv-head) .mobile-top { padding-right: 84px; }
  .conv-title-row { position: absolute; right: 12px; top: 8px; }
  .lanes-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .lane-chip { flex: none; }
  .stats { gap: 10px; font-size: 12px; }
  .main { position: relative; }
  .model-row .price { grid-column: 2; text-align: left; }
}

/* rate limits & recovery */
.tag.busy { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); font-weight: 600; }
.tag.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.err-box { display: grid; gap: 6px; }
.err-title { font-weight: 600; }
.err-box .alts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; color: var(--text); }
.err-box .alts .btn { color: var(--text); }
.err-box details.tech { font-size: 12px; opacity: .85; }
.err-box details.tech summary { cursor: pointer; }
.err-box details.tech div { margin-top: 4px; overflow-wrap: anywhere; color: var(--muted); }
.retrying { display: grid; gap: 4px; font-size: 14px; }
.retry-bar { height: 3px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.retry-bar i { display: block; height: 100%; background: var(--warn); }

/* session notice */
.notice { background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin-bottom: 14px; }

/* free & best */
.rank { display: inline-block; min-width: 26px; text-align: center; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.best-note { padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel-2); }

/* skills */
.skills { border-top: 1px solid var(--border); padding: 8px 10px; max-height: 38vh; display: flex; flex-direction: column; min-height: 0; }
.skills-head { display: flex; align-items: center; gap: 4px; padding: 0 2px 6px; font-size: 14px; }
.skills-list { overflow-y: auto; display: grid; gap: 2px; font-size: 14px; }
.skill-row { display: flex; align-items: center; gap: 4px; border-radius: 6px; padding: 2px 4px; }
.skill-row:hover { background: var(--panel-2); }
.skill-row.on { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.skill-row label { flex: 1; display: flex; gap: 6px; align-items: center; cursor: pointer; min-width: 0; }
.skill-row label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-row [data-edit-skill] { visibility: hidden; }
.skill-row:hover [data-edit-skill] { visibility: visible; }
.skills-on { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; color: var(--muted); }
@media (hover: none) { .skill-row [data-edit-skill] { visibility: visible; } }
.skills-sub { padding: 0 2px 4px; font-size: 12px; }

/* send-to chips */
.send-to { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.to-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 13px; color: var(--muted); }
.to-chip:hover { background: var(--panel-2); }
.to-chip.on { color: var(--text); border-color: var(--lane, var(--accent)); background: color-mix(in srgb, var(--lane, var(--accent)) 12%, var(--panel)); font-weight: 600; }
.to-chip.paused:not(.on) { border-style: dashed; }
.to-chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* replies */
.reply-note { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 6px 8px; background: var(--panel-2); font-size: 13px; }
.reply-note .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; }
.reply-note .snip { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reply-quote { display: flex; gap: 6px; max-width: 760px; margin: 0 0 4px auto; font-size: 12px; color: var(--muted); text-decoration: none; border-left: 3px solid var(--lane, var(--accent)); padding: 2px 8px; }
.reply-quote b { color: var(--text); white-space: nowrap; }
.reply-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-quote:hover span { color: var(--text); }
.card.flash { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); transition: box-shadow .3s; }

/* automatic stand-ins */
.badge.standin { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); max-width: 50%; overflow: hidden; text-overflow: ellipsis; }
.err-box .switched { font-size: 13px; color: var(--text); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); border-radius: 6px; padding: 6px 8px; }

/* live connection */
.conn { display: none; background: color-mix(in srgb, var(--warn) 14%, var(--panel)); color: var(--text); font-size: 13px; text-align: center; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.conn.show { display: block; }

/* edit last message */
.user-msg { position: relative; }
.user-msg .edit-btn { position: absolute; left: -64px; top: 6px; opacity: 0; transition: opacity .15s; }
.user-msg:hover .edit-btn, .user-msg .edit-btn:focus { opacity: 1; }
@media (hover: none), (max-width: 820px) { .user-msg .edit-btn { position: static; opacity: 1; margin-left: 6px; } }
.user-edit { max-width: 760px; margin: 0 0 12px auto; display: grid; gap: 6px; }
.edit-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.edit-actions .muted { margin-right: auto; }

/* code blocks */
.code-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: .6em 0; }
.code-wrap pre { margin: 0; border-radius: 0; }
.code-wrap pre code.hljs { background: transparent; padding: 0; }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 2px 10px; background: var(--panel-2); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* memory */
.memory { border: 1px dashed var(--border); border-radius: 8px; padding: 4px 10px; }
.memory summary { cursor: pointer; }
.memory .md { margin: 6px 0; }

/* search */
.search-wrap { padding: 0 14px 6px; }
.search-wrap .input { padding: 6px 10px; font-size: 14px; }
.conv-item .hit { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 2px; }

/* compare */
.compare h1 { margin: 0; }
.cmp-h { font-size: 17px; margin: 22px 0 6px; }
.cmp-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table.cmp { border-collapse: collapse; width: 100%; font-size: 14px; }
.cmp th, .cmp td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.cmp thead th { background: var(--panel-2); font-weight: 600; white-space: nowrap; }
.cmp tbody th { font-weight: 500; color: var(--muted); white-space: nowrap; }
.cmp tr.sec td { background: var(--panel-2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cmp td.best { background: color-mix(in srgb, var(--ok) 12%, transparent); font-weight: 600; }
.cmp .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cmp tr:last-child td, .cmp tr:last-child th { border-bottom: 0; }
.h2h { display: grid; gap: 8px; }
.h2h-row { display: grid; grid-template-columns: minmax(0, 180px) minmax(60px, 1fr) minmax(0, 180px); gap: 4px 10px; align-items: center; font-size: 14px; }
.h2h-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .h2h-name.r { text-align: right; }
.h2h-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--panel-2); }
.h2h-bar i { display: block; height: 100%; }
.h2h-score { grid-column: 1 / -1; text-align: center; font-size: 13px; }
.compare { min-width: 0; } .compare > * { min-width: 0; }
.meter { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); }
@media (max-width: 820px) { .h2h-row { grid-template-columns: 1fr 1fr; } .h2h-bar { grid-column: 1 / -1; order: 3; } .h2h-score { order: 4; } }

/* personal key */
.key-box { display: grid; gap: 6px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.key-row { display: flex; gap: 6px; flex-wrap: wrap; }
.key-row .input { flex: 1 1 220px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* attachments */
.attach-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.att-chip { position: relative; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; padding: 4px 26px 4px 4px; max-width: 260px; overflow: hidden; }
.att-chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; }
.att-icon { width: 40px; height: 40px; display: grid; place-items: center; background: var(--panel-2); border-radius: 6px; font-size: 20px; flex: none; }
.att-meta { display: grid; min-width: 0; }
.att-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip.failed { border-color: var(--err); } .att-chip.failed .att-sub { color: var(--err); }
.att-chip.processing .att-sub { color: var(--accent); }
.att-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--panel-2); }
.att-bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.att-x { position: absolute; top: 2px; right: 4px; border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px; }
.att-x:hover { color: var(--text); }
.attach-btn { padding: 6px 10px; font-size: 16px; }
.vision-note { color: var(--muted); } .vision-note:empty { display: none; }
.dropping { outline: 3px dashed var(--accent); outline-offset: -8px; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.new-box { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 8px; display: grid; gap: 8px; }
.new-box .textarea { border: 0; padding: 4px; }
.new-box .textarea:focus { outline: none; }
.new-box-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.turn-atts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 760px; margin: 0 0 6px auto; }
.att-thumb img { display: block; max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--border); object-fit: cover; }
.att-file { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; padding: 6px 10px; font-size: 13px; color: var(--text); text-decoration: none; max-width: 320px; }
.att-file span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file:hover { background: var(--panel-2); }

/* evaluation */
.eval-who { font-size: 14px; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.eval-cands, .eval-crit { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; cursor: pointer; }
.chk .dot { width: 9px; height: 9px; border-radius: 50%; }
.eval-rec { border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--border)); background: color-mix(in srgb, var(--ok) 7%, var(--panel)); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; margin-bottom: 10px; }
.eval-rec-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.eval-rec-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.eval-rec-main .dot { width: 10px; height: 10px; border-radius: 50%; }
.eval-rec-main .big { font-size: 24px; font-weight: 700; margin-left: 6px; }
.score { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cmp tr.total td, .cmp tr.total th { border-top: 2px solid var(--border); }
.turn-tools { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; }
.badge.eval { color: var(--text); background: var(--panel-2); }
.badge.eval.rec { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); font-weight: 600; }

/* metrics: chart tokens (validated palette: blue/orange categorical, one-hue blue sequential) */
.viz-root { --series-1: #2a78d6; --series-2: #eb6834; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #5598e7; --seq-4: #256abf; --seq-5: #104281; --grid: #e6e4df; --axis: #6b6a66; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .viz-root { --series-1: #3987e5; --series-2: #d95926; --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4; --grid: #2e2e2b; --axis: #a3a29a; } }
.nav-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.metrics h1 { margin: 0; }
.m-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.m-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.m-filters .select { width: auto; max-width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 5px 10px; font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--panel-2); color: var(--text); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.m-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; min-width: 0; }
.m-card .cmp-wrap { border: 0; border-radius: 0; }
.m-card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.m-card-head h2 { font-size: 16px; margin: 0; flex: 1; }
.legend { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .dot-l { border-radius: 50%; background: var(--series-1); } .legend .dot-l.hollow { background: transparent; border: 2px solid var(--series-1); width: 8px; height: 8px; }
.chart { min-width: 0; overflow: hidden; }
.chart svg { display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .axis { fill: var(--axis); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .label { fill: var(--text); font-size: 12px; }
.chart .range { stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; opacity: .45; }
.chart .p50 { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
.chart .p95 { fill: var(--panel); stroke: var(--series-1); stroke-width: 2; }
.chart .hit:hover path, .chart .hit:hover .p50 { filter: brightness(1.12); }
.chart .hit:hover > rect { fill: color-mix(in srgb, var(--text) 4%, transparent); }
#viz-tip { position: fixed; z-index: 70; pointer-events: none; opacity: 0; transition: opacity .1s; background: var(--panel); color: var(--text); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0,0,0,.15); border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.5; }
#viz-tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
table.heat td.hcell { text-align: center; font-variant-numeric: tabular-nums; color: #0b0b0b; font-weight: 600; }
table.heat td.hcell.dark { color: #ffffff; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) table.heat td.hcell { color: #ffffff; } :root:where(:not([data-theme="light"])) table.heat td.hcell.dark { color: #0b0b0b; } }
.heat-legend { display: flex; align-items: center; gap: 3px; }
.heat-legend i { width: 22px; height: 10px; display: inline-block; border-radius: 2px; }

#m-body { display: grid; gap: 14px; min-width: 0; }
.m-card .meter i, .metrics .meter i { background: var(--series-1); }
.m-card > * { min-width: 0; }
#ch-heat { overflow-x: auto; }

/* price watches */
.count-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; margin-left: 4px; }
.w-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.w-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 0; display: grid; gap: 8px; min-width: 0; }
.w-card.paused { opacity: .75; }
.w-card .card-actions { margin: 0 -14px; }
.w-top { display: flex; gap: 8px; align-items: flex-start; }
.w-name { font-weight: 600; color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-name:hover { text-decoration: underline; }
.w-mid { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.w-price { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.good { color: #0ca30c; font-weight: 600; } .bad { color: #d03b3b; font-weight: 600; }
.spark { min-width: 0; }
.spark svg { display: block; width: 100%; }
.spark .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .end { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
.spark .target { stroke: var(--muted); stroke-dasharray: 3 3; stroke-width: 1; }
.w-preview { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.w-title { font-weight: 600; }
.w-cond { display: grid; gap: 6px; }
.input.inline { width: 110px; display: inline-block; padding: 3px 6px; margin: 0 4px; }
.notif { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.notif.unread b::after { content: " •"; color: var(--accent); }
.n-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); font-size: 12px; flex: none; }
.watch-chip { border-color: var(--accent); }

/* The hidden attribute must always win over component display rules. */
[hidden] { display: none !important; }

/* agents hub */
.ask-agent { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; }
.ask-agent .textarea { border: 0; font-size: 16px; resize: none; } .ask-agent .textarea:focus { outline: none; }
.ag-bar { display: flex; gap: 8px; align-items: flex-end; } .ag-examples { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.ag-tabs { align-self: start; }
.plan-card { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); border-radius: 10px; padding: 12px; display: grid; gap: 10px; background: color-mix(in srgb, var(--accent) 4%, var(--panel)); }
.plan-head { display: flex; gap: 8px; align-items: center; } .plan-name { font-weight: 600; }
.pf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mon { margin-bottom: 12px; } .mon-name { font-size: 15px; }
.mon-items { display: grid; gap: 2px; }
.mon-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border); transition: opacity .25s; }
.mon-item.dim { opacity: .55; } .mon-item.gone { opacity: 0; }
.mi-title { font-weight: 600; color: var(--text); text-decoration: none; } .mi-title:hover { text-decoration: underline; }
.mi-reason { color: var(--muted); } .mi-fb { display: flex; gap: 2px; flex: none; }
.pre { white-space: pre-line; }
.notice-inline { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 6px; padding: 6px 8px; }
@media (max-width: 820px) { .pf-row { grid-template-columns: 1fr; } .ag-bar { flex-direction: column; align-items: stretch; } }

.eval-log { background: var(--panel-2); border-radius: 8px; padding: 8px; font-size: 12px; max-height: 200px; overflow: auto; white-space: pre-wrap; }

/* feedback */
.fb-kind { justify-self: start; }
.fb-shot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fb-shot img { max-height: 90px; border-radius: 6px; border: 1px solid var(--border); }
.fb-status { width: auto; padding: 2px 6px; font-size: 12px; height: fit-content; }

/* agents page, cleaned up */
.agents { gap: 14px; }
.ag-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.ag-head h1 { margin: 0; } .ag-head p { margin: 2px 0 0; font-size: 14px; }
.ag-tabs button { position: relative; }
.tab-dot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--err); }
.ag-new { position: relative; display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 6px 6px 6px 12px; }
.ag-new:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ag-new-icon { color: var(--muted); font-size: 18px; }
.ag-new .input { border: 0; padding: 6px 2px; font-size: 15px; background: transparent; } .ag-new .input:focus { outline: none; }
.ag-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow), 0 8px 24px rgba(0,0,0,.12); z-index: 20; padding: 4px; display: grid; }
.ag-suggest button { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; font-size: 14px; color: var(--text); }
.ag-suggest button:hover { background: var(--panel-2); }
.ag-list { display: grid; gap: 8px; }
.ag-row { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ag-row.paused { opacity: .7; }
.ag-row-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.ag-row-head:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.ag-kind { width: 32px; height: 32px; border-radius: 8px; background: var(--panel-2); display: grid; place-items: center; flex: none; }
.ag-row-main { flex: 1; min-width: 0; display: grid; }
.ag-row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ag-count { font-size: 12px; color: var(--muted); min-width: 16px; text-align: right; }
.new-pill { font-size: 12px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.ag-warn { color: var(--warn); }
.ag-chev { color: var(--muted); width: 12px; }
.ag-row-body { border-top: 1px solid var(--border); padding: 4px 12px 10px 54px; }
.ag-foot { padding-top: 8px; } .ag-none { padding: 10px 0; }
.mon-item { display: flex; gap: 8px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--border); }
.mon-item:first-child { border-top: 0; }
.mi-main { flex: 1; min-width: 0; }
.mi-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.mi-reason { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mi-reason::before { content: "✓ "; color: var(--ok); }
.mi-fb { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.mon-item:hover .mi-fb, .mi-fb:focus-within, .mi-fb .on { opacity: 1; }
@media (hover: none) { .mi-fb { opacity: 1; } }
.icon-btn { border: 0; background: transparent; border-radius: 6px; padding: 3px 6px; font-size: 14px; line-height: 1; filter: grayscale(1); opacity: .7; }
.icon-btn:hover { background: var(--panel-2); filter: none; opacity: 1; }
.icon-btn.on { filter: none; opacity: 1; background: color-mix(in srgb, var(--accent) 14%, transparent); }
.pop-menu { position: fixed; z-index: 80; min-width: 170px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; display: grid; }
.pop-menu button { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; font-size: 14px; color: var(--text); }
.pop-menu button:hover { background: var(--panel-2); } .pop-menu button.danger { color: var(--err); }
.ag-group { display: grid; gap: 2px; margin-bottom: 12px; }
.ag-group-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 4px 4px; }
.alert-row { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; background: var(--panel); border: 1px solid var(--border); }
.alert-row + .alert-row { margin-top: 4px; }
.alert-row:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.alert-row.unread { border-left: 3px solid var(--accent); }
.ar-icon { width: 28px; text-align: center; flex: none; }
.ar-main { flex: 1; min-width: 0; display: grid; }
.ar-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-body { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ag-empty { text-align: center; padding: 48px 16px; display: grid; justify-items: center; gap: 4px; }
.ag-empty-icon { font-size: 28px; } .ag-empty p { max-width: 420px; margin: 4px 0 0; }
.w-card .card-actions { display: flex; }
@media (max-width: 820px) { .ag-meta { display: none; } .ag-row-body { padding-left: 12px; } }

.ag-new .btn { white-space: nowrap; }
.sidebar-foot { gap: 2px; }
.sidebar-foot .btn { white-space: nowrap; padding: 3px 7px; }
.sidebar-foot .who { display: flex; align-items: center; gap: 8px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 25%, var(--panel-2)); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }

.w-card { grid-template-columns: minmax(0, 1fr); }
.w-card > * { min-width: 0; }
.w-top > div { min-width: 0; }

.ag-quick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: -4px; }
.ag-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ag-type { display: grid; gap: 4px; text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; color: var(--text); }
.ag-type:hover { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.ag-type-icon { font-size: 22px; }

.src-list { display: grid; gap: 6px; margin-top: 6px; }
.src-item { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.src-item input { margin-top: 3px; }
.src-companies { margin-top: 2px; } .src-companies summary { cursor: pointer; color: var(--accent); }

.comp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; } .comp-chips .sel-chip { font-size: 12px; padding: 1px 2px 1px 8px; }
.src-companies .key-row { margin-top: 4px; } .src-companies .input { padding: 4px 8px; font-size: 13px; }

/* pinned memory */
.memory-panel { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); background: color-mix(in srgb, var(--accent) 5%, var(--panel)); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.memory-panel > summary { cursor: pointer; font-weight: 600; }
.mem-body { display: grid; gap: 6px; padding: 6px 0 2px; }
.mem-body > .btn { justify-self: start; }
.pin-item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--border); }
.pin-src { flex: none; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--lane); color: var(--text); background: color-mix(in srgb, var(--lane) 12%, transparent); white-space: nowrap; }
.pin-text { flex: 1; min-width: 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pin-actions { display: flex; flex: none; }
.mem-sub summary { cursor: pointer; color: var(--muted); }
.user-msg .msg-tools { position: absolute; left: -132px; top: 4px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.user-msg:hover .msg-tools, .user-msg .msg-tools:focus-within { opacity: 1; }
.user-msg.pinned { border-color: var(--accent); }
.pin-badge { float: right; margin-left: 8px; }
@media (hover: none), (max-width: 820px) { .user-msg .msg-tools { position: static; opacity: 1; margin-top: 4px; } }

/* free trial */
.trial-note { font-size: 13px; padding: 6px 10px; margin-bottom: 8px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 8%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); }
.trial-note.out { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.trial-hint { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.warn-text { color: var(--warn); font-weight: 600; }
.fb-kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-kind { display: flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 14px; }

/* more than 3 models: three columns visible, the rest scroll to the right */
.lanes.scroll { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: calc((100% - 24px) / 3); overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 8px; overscroll-behavior-x: contain; }
.lanes.scroll > .card { scroll-snap-align: start; }
.lane-nav { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin: 0 0 6px; }
.lane-nav .lane-pos { margin-right: 6px; }
@media (max-width: 820px) { .lane-nav { display: none; } }
.col-count { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.col-count .input { padding: 4px 6px; }

/* ---- Assistants (RAG builder) ---- */
.rag-wrap { max-width: 920px; margin: 0 auto; padding: 24px 20px 60px; }
.rag-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rag-head h1 { margin: 0; font-size: 22px; flex: 0 1 auto; }
.rag-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 18px; }
.rag-new { display: grid; grid-template-columns: 1fr 200px; gap: 8px; align-items: center; margin: 14px 0 20px; }
.rag-new label { grid-column: 1 / -1; }
.rag-new .btn { grid-column: 1 / -1; justify-self: start; }
.rag-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.rag-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); text-decoration: none; color: inherit; }
.rag-card:hover { border-color: var(--accent); }
.rag-drop { border: 2px dashed var(--border); border-radius: 10px; padding: 22px; text-align: center; margin: 10px 0; }
.rag-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.rag-paste { margin: 10px 0 16px; } .rag-paste .input, .rag-paste .textarea { margin: 8px 0; }
.rag-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rag-table th, .rag-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.rag-model { max-width: 360px; margin-bottom: 12px; }
.rag-turn { margin: 0 0 18px; }
.rag-q { background: var(--panel-2); border-radius: 10px; padding: 8px 12px; display: inline-block; max-width: 90%; }
.rag-a { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0 4px; background: var(--panel); line-height: 1.5; }
.rag-a.refused { border-style: dashed; }
.cite { display: inline-block; min-width: 16px; text-align: center; background: var(--accent); color: var(--accent-ink); border-radius: 8px; font-size: 11px; padding: 0 4px; margin: 0 1px; cursor: help; }
.rag-src { margin: 6px 0; font-size: 13px; }
.rag-snip { border-left: 3px solid var(--border); padding: 4px 10px; margin: 6px 0; white-space: pre-wrap; }
.rag-ask { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: 0; background: var(--bg, var(--panel)); padding-top: 8px; }
.rag-form { display: grid; gap: 14px; max-width: 640px; }
.rag-field { display: grid; gap: 4px; }
.rag-field > span { font-weight: 600; font-size: 14px; }
.rag-code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.rag-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.rag-stats > div { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; }
.rag-stats b { font-size: 22px; }
@media (max-width: 820px) { .rag-new { grid-template-columns: 1fr; } }

.rag-scroll { overflow-x: auto; }
.rag-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.rag-cell { min-width: 180px; font-size: 13px; }
.rag-table tr.draft { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.rag-gate { border: 1px solid var(--border); border-left-width: 4px; border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.rag-gate.ok { border-left-color: var(--ok); } .rag-gate.bad { border-left-color: var(--err); } .rag-gate.na { border-left-color: var(--muted); }
.rag-top { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.rag-ring { width: 130px; height: 130px; flex: none; }
.rag-top-text { flex: 1; min-width: 260px; display: grid; gap: 8px; }
.rag-run { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rag-progress { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.rag-progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.rag-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.rag-metric { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 2px; }
.rag-metric b { font-size: 22px; }
.rag-chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 10px; white-space: nowrap; }
.rag-chip.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.rag-chip.bad { background: color-mix(in srgb, var(--err) 16%, transparent); color: var(--err); }
.rag-chip.na { background: var(--panel-2); color: var(--muted); }
.rag-rules .grp td { background: var(--panel-2); font-weight: 600; font-size: 13px; }
.rag-sugg { display: grid; gap: 8px; }
.rag-card2 { display: flex; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.rag-card2.sevhi { border-left-color: var(--err); } .rag-card2.sevmid { border-left-color: var(--warn); }
.rag-trend { position: relative; max-width: 640px; margin: 4px 0 12px; } .rag-trend svg { width: 100%; height: auto; } .rag-trend .hit { cursor: pointer; outline: none; }
.rag-trend .hit:focus { stroke: var(--accent); stroke-width: 2; }
.rag-tip { position: absolute; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; pointer-events: none; }
.rag-out { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin: 6px 0; background: var(--panel); } .rag-out summary { cursor: pointer; }
.rag-gaps { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 8px 0; background: var(--panel); display: grid; gap: 4px; }
.rag-lr { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; } .rag-lr .input { width: 220px; display: inline-block; }
.err-box { border: 1px solid var(--err); border-radius: 8px; padding: 10px 12px; background: color-mix(in srgb, var(--err) 8%, transparent); }

.rag-rules td:nth-child(2), .rag-rules td:nth-child(3), .rag-rules td:nth-child(4) { white-space: nowrap; }
.rag-rules td.small { white-space: normal; }
.rag-rules td:nth-child(2) { white-space: normal; }
.rag-gate.stop { border-left-color: var(--err); }
.rag-sep { border-top: 1px solid var(--border); margin: 2px 0; }

/* Let the page area shrink below its widest table, which then scrolls inside .rag-scroll */
.main { min-width: 0; }
.rag-wrap, .rag-scroll { min-width: 0; max-width: 100%; }
.rag-rules td.wrap { white-space: normal; min-width: 120px; }

/* Try tab: compare models side by side */
.rag-picks { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.rag-pick { display: inline-flex; gap: 2px; align-items: center; }
.rag-pick .select { width: auto; max-width: 280px; }
.rag-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; margin: 8px 0 4px; }
.rag-col { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rag-col.err { border-style: dashed; }
.rag-colhead { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.rag-col .rag-a { border: none; background: none; padding: 0; margin: 0; }
.rag-doc { margin: 6px 0 10px; }
