/*
 * Intelligence: Open WebUI's layout (sidebar, centred thread, rounded composer) in the
 * portfolio's colours (black + #52c234 green). Standalone it has a solid background; embedded
 * in the portfolio (html.embedded) it goes see-through so the page's green code-swirl shows
 * behind it, with frosted panels to keep text readable.
 */
:root {
  --bg: #050705;
  --bg-side: #0b0f0b;
  --bg-elev: #141a14;
  --bg-hover: rgba(82, 194, 52, 0.08);
  --bg-active: rgba(82, 194, 52, 0.14);
  --line: rgba(82, 194, 52, 0.16);
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #e9f0e8;
  --muted: #8f9a8e;
  --accent: #52c234;
  --accent-2: #6fe04f;
  --accent-deep: #03a003;
  --glow: 0 0 18px rgba(82, 194, 52, 0.35);
  --danger: #ef6b6b;
  --radius: 14px;
  --side-w: 260px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

/* Embedded: transparent page, frosted panels. */
html.embedded {
  --bg: transparent;
  --bg-side: rgba(4, 8, 4, 0.72);
  --bg-elev: rgba(14, 20, 14, 0.78);
}
html.embedded body { background: transparent; }

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(82, 194, 52, 0.35); }
* { scrollbar-width: thin; scrollbar-color: rgba(82, 194, 52, 0.25) transparent; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 20px; letter-spacing: 0.2px; }
.brand.small { font-size: 15px; }
.brand-mark { color: var(--accent); text-shadow: var(--glow); }

/* ---------- login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 520px at 50% 0%, rgba(82, 194, 52, 0.12), transparent 65%), var(--bg); }
html.embedded .login { background: transparent; }
.login-card { width: min(380px, 100%); background: rgba(8, 12, 8, 0.82); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 40px rgba(82, 194, 52, 0.08); backdrop-filter: blur(14px); animation: rise 380ms ease-out; }
.login-sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-soft); border-radius: 12px; color: var(--text); padding: 12px 14px; font: inherit; }
.login-form input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(82, 194, 52, 0.15); }
.login-form input.code { letter-spacing: 6px; font-family: var(--mono); font-size: 20px; text-align: center; }
.login-hint { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.login-error { min-height: 1.2em; margin: 2px 0; color: var(--danger); font-size: 13px; }
.btn-primary { background: var(--accent); color: #031003; border-radius: 12px; padding: 11px 16px; font-weight: 600; transition: box-shadow 160ms, background 160ms; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); box-shadow: var(--glow); }
.btn-ghost { color: var(--muted); border-radius: 12px; padding: 9px 14px; }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- shell ---------- */
.shell { display: flex; height: 100%; }
.sidebar { width: var(--side-w); flex: none; background: var(--bg-side); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; padding: 10px 10px 8px; transition: margin 200ms ease; backdrop-filter: blur(16px); }
body.no-sidebar .sidebar { margin-left: calc(-1 * var(--side-w)); }
@media (min-width: 761px) { body:not(.no-sidebar) .topbar .sidebar-toggle { display: none; } }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px 8px; }
.new-chat { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; text-align: left; font-weight: 500; font-size: 14px; }
.new-chat:hover { background: var(--bg-hover); }
.new-chat svg { color: var(--accent); }
.side-search { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; padding: 7px 10px; border-radius: 12px; color: var(--muted); background: rgba(255, 255, 255, 0.03); border: 1px solid transparent; }
.side-search:focus-within { border-color: var(--line); }
.side-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; font-size: 14px; }
.side-search input::-webkit-search-cancel-button { filter: grayscale(1); }
.chat-list { flex: 1; overflow-y: auto; margin-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.chat-group { font-size: 12px; font-weight: 500; color: var(--muted); padding: 12px 10px 4px; }
.chat-empty { font-size: 13px; color: var(--muted); padding: 10px; }
.chat-item { display: flex; align-items: center; border-radius: 10px; }
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); box-shadow: inset 2px 0 0 var(--accent); }
.chat-open { flex: 1; min-width: 0; text-align: left; padding: 7px 10px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #d4ddd3; }
.chat-del { opacity: 0; padding: 4px 8px; color: var(--muted); display: grid; place-items: center; }
.chat-item:hover .chat-del, .chat-item.active .chat-del { opacity: 1; }
.chat-del:hover { color: var(--danger); }
.sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 10px 6px 2px; border-top: 1px solid var(--line-soft); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-deep), var(--accent-2)); color: #031003; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.who { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cfd8ce; }
.icon-btn { padding: 6px 7px; border-radius: 10px; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 60px 10px 14px; height: 56px; }
.top-model { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-picker { position: relative; }
.model-btn { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; padding: 7px 12px; border-radius: 10px; }
.model-btn:hover { background: var(--bg-hover); }
.caret { color: var(--muted); font-size: 12px; }
.model-menu { display: none; position: absolute; top: 46px; left: 0; z-index: 20; width: 340px; max-width: calc(100vw - 40px); background: rgba(10, 14, 10, 0.96); border: 1px solid var(--line); border-radius: 16px; padding: 6px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); backdrop-filter: blur(16px); }
.model-menu.open { display: block; animation: rise 140ms ease-out; }
.menu-head { color: var(--muted); font-size: 12px; padding: 8px 10px 6px; }
.menu-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; padding: 9px 10px; border-radius: 10px; }
.menu-item:hover:not(:disabled) { background: var(--bg-hover); }
.menu-item.active { opacity: 1; }
.mi-label { font-weight: 500; }
.mi-desc { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.check { color: var(--accent); }
.status-pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line-soft); color: var(--muted); white-space: nowrap; }
.status-pill::before { content: "●"; margin-right: 6px; }
.s-ready::before, .s-unknown::before { color: var(--accent); text-shadow: var(--glow); }
.s-loading::before { color: #f5b942; animation: pulse 1s infinite; }
.s-error::before, .s-stopped::before { color: var(--danger); }

/* ---------- messages ---------- */
.messages { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.thread { max-width: 800px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 26px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--bg-elev); border: 1px solid var(--line-soft); padding: 10px 16px; border-radius: 22px; max-width: 78%; white-space: pre-wrap; word-wrap: break-word; backdrop-filter: blur(10px); }
.msg.assistant { display: flex; gap: 14px; }
.bot-avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.4); display: grid; place-items: center; color: var(--accent); font-size: 13px; margin-top: 2px; box-shadow: 0 0 12px rgba(82, 194, 52, 0.25); }
.bot-col { flex: 1; min-width: 0; }
html.embedded .bot-col { text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9); }
.copy-btn { font-size: 12.5px; }
.msg-actions { margin-top: 4px; opacity: 0; transition: opacity 120ms; }
.msg.assistant:hover .msg-actions { opacity: 1; }
.msg-error { color: var(--danger); font-size: 14px; margin-top: 6px; }
.think { margin-bottom: 10px; color: var(--muted); }
.think summary { cursor: pointer; font-size: 14px; user-select: none; list-style: none; }
.think summary::before { content: "▸ "; }
.think[open] summary::before { content: "▾ "; }
.think-body { margin-top: 6px; padding-left: 12px; border-left: 2px solid var(--line); white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; max-height: 320px; overflow-y: auto; }
.typing { display: inline-flex; gap: 4px; padding: 10px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: 0.2s; } .typing i:nth-child(3) { animation-delay: 0.4s; }

/* markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md .md-h { margin: 20px 0 8px; line-height: 1.3; }
.md h2 { font-size: 1.35em; } .md h3 { font-size: 1.15em; } .md h4, .md h5, .md h6 { font-size: 1em; }
.md-list { margin: 0 0 12px; padding-left: 24px; } .md-list li { margin: 3px 0; }
.md-list li::marker { color: var(--accent); }
.md blockquote { margin: 0 0 12px; padding-left: 14px; border-left: 3px solid var(--line); color: #cfd8ce; }
.md hr { border: 0; border-top: 1px solid var(--line-soft); margin: 18px 0; }
.md-link { color: var(--accent-2); text-decoration: none; } .md-link:hover { text-decoration: underline; }
.md-code-inline { font-family: var(--mono); font-size: 0.88em; background: rgba(82, 194, 52, 0.1); color: #c9f5bb; padding: 1px 6px; border-radius: 6px; }
.md-codeblock { margin: 0 0 14px; border-radius: 12px; overflow: hidden; background: rgba(0, 0, 0, 0.75); border: 1px solid var(--line); text-shadow: none; }
.md-codeblock-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: rgba(82, 194, 52, 0.06); font-size: 12px; color: var(--muted); }
.md-copy { font-size: 12px; color: var(--muted); padding: 2px 6px; border-radius: 6px; } .md-copy:hover { color: var(--text); background: var(--bg-hover); }
.md-codeblock pre { margin: 0; padding: 14px; overflow-x: auto; font: 13.5px/1.55 var(--mono); }
.md-table-wrap { overflow-x: auto; margin: 0 0 14px; }
.md-table { border-collapse: collapse; font-size: 14px; background: rgba(0, 0, 0, 0.4); }
.md-table th, .md-table td { border: 1px solid var(--line-soft); padding: 6px 12px; text-align: left; }
.md-table th { background: rgba(82, 194, 52, 0.08); }

/* welcome (Open WebUI-style: model badge, greeting, suggestions, composer below) */
.welcome { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 0 16px 24px; text-align: center; }
.welcome-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.welcome-mark { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; color: var(--accent);
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.5); box-shadow: 0 0 24px rgba(82, 194, 52, 0.35); }
.welcome-model { font-size: 15px; color: var(--muted); }
.welcome h1 { font-size: 30px; font-weight: 600; margin: 0 0 18px; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9); }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: min(800px, 100%); }
.suggestion { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 9px 14px; border-radius: 14px; min-width: 170px;
  background: rgba(10, 14, 10, 0.6); border: 1px solid var(--line-soft); backdrop-filter: blur(10px); transition: border-color 150ms, background 150ms; }
.suggestion:hover { border-color: var(--line); background: rgba(82, 194, 52, 0.08); }
.sg-title { font-size: 14px; font-weight: 500; }
.sg-sub { font-size: 12.5px; color: var(--muted); }
.main.empty .messages { flex: 1; }
.main.empty .composer { flex: 1; justify-content: flex-start; padding-top: 6px; }

/* composer */
.composer { display: flex; flex-direction: column; align-items: center; padding: 0 16px 10px; }
.composer-box { width: min(800px, 100%); background: var(--bg-elev); border-radius: 28px; padding: 12px 12px 8px 18px; border: 1px solid var(--line-soft);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); backdrop-filter: blur(16px); transition: border-color 150ms, box-shadow 150ms; }
.composer-box:focus-within { border-color: var(--line); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(82, 194, 52, 0.15), 0 0 30px rgba(82, 194, 52, 0.12); }
.composer textarea { width: 100%; resize: none; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; line-height: 1.5; max-height: 220px; padding: 2px 0; }
.composer textarea::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }
.chip { font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-soft); color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.on { color: var(--accent-2); border-color: rgba(82, 194, 52, 0.4); background: rgba(82, 194, 52, 0.1); }
.send { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #031003; display: grid; place-items: center; transition: box-shadow 150ms, background 150ms; }
.send:hover { background: var(--accent-2); box-shadow: var(--glow); }
.disclaimer { color: #6f796e; font-size: 12px; margin: 8px 0 0; }
html.embedded .disclaimer { color: #8f9a8e; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }

/* modal / toast */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 50; animation: fade 120ms; backdrop-filter: blur(3px); }
.modal { width: min(440px, calc(100% - 32px)); background: rgba(10, 14, 10, 0.96); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); }
.modal h3 { margin: 0 0 8px; font-size: 17px; } .modal p { color: #c9d2c8; margin: 0 0 18px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(10, 14, 10, 0.96); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; animation: rise 160ms ease-out; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

@media (max-width: 760px) {
  .sidebar { position: absolute; z-index: 30; height: 100%; box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5); background: rgba(4, 8, 4, 0.96); }
  body:not(.sidebar-open) .sidebar { margin-left: calc(-1 * var(--side-w)); }
  .msg.user .bubble { max-width: 88%; }
  .welcome h1 { font-size: 24px; }
  .suggestion { min-width: 0; flex: 1 1 140px; }
  .top-model { font-size: 14px; }
}

/* model switcher in the composer row */
.composer-row .model-btn { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 5px 12px; border-radius: 999px; color: var(--text); max-width: 320px; min-width: 0; }
.composer-row .model-btn > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-row .model-btn:hover { background: var(--bg-hover); }
.model-menu.up { top: auto; bottom: calc(100% + 8px); }

/* model-switch progress (same line as the Open WebUI pipe, plus a real bar) */
.switch-bar { width: min(800px, calc(100% - 32px)); margin: 0 auto 6px; padding: 10px 14px; border-radius: 14px;
  background: rgba(8, 12, 8, 0.82); border: 1px solid var(--line); backdrop-filter: blur(14px); font-size: 13.5px; animation: rise 160ms ease-out; }
.switch-bar[hidden] { display: none; }
.sb-line { display: flex; align-items: center; gap: 10px; }
.sb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-blocks { color: var(--accent); letter-spacing: 1px; font-size: 12px; text-shadow: var(--glow); }
.sb-pct { font-family: var(--mono); color: var(--accent-2); min-width: 3.5ch; text-align: right; }
.sb-track { height: 4px; margin: 8px 0 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.sb-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-deep), var(--accent-2)); box-shadow: var(--glow); transition: width 900ms linear; }
.sb-sub { color: var(--muted); font-size: 12.5px; }
.switch-bar.done { border-color: rgba(82, 194, 52, 0.5); color: var(--accent-2); }
.switch-bar.failed { border-color: rgba(239, 107, 107, 0.5); color: var(--danger); }
@media (max-width: 520px) { .sb-blocks { display: none; } }

/* composer row must fit a phone: the model chip shrinks (ellipsis), chips never wrap */
.composer-row .model-picker { min-width: 0; flex: 0 1 auto; }
.composer-row .chip { white-space: nowrap; flex: none; }
.composer-row .model-btn { flex: initial; max-width: min(320px, 100%); }
.send { flex: none; }
@media (max-width: 420px) {
  .composer-box { padding-left: 14px; }
  .composer-row { gap: 6px; }
}

/* ---------- attachments (+ menu, chips) ---------- */
.plus-wrap { position: relative; flex: none; }
.plus-btn { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line-soft); }
.plus-btn:hover { color: var(--accent); border-color: var(--line); background: var(--bg-hover); }
.plus-menu { display: none; position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 25; width: 270px; padding: 6px;
  background: rgba(10, 14, 10, 0.97); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); backdrop-filter: blur(16px); }
.plus-menu.open { display: block; animation: rise 140ms ease-out; }
.plus-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 10px; text-align: left; font-size: 14px; }
.plus-item:hover { background: var(--bg-hover); }
.plus-item svg { color: var(--accent); }
.plus-note { display: flex; gap: 8px; align-items: flex-start; margin: 4px 4px 2px; padding: 8px 6px 2px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; line-height: 1.4; }
.plus-note svg { flex: none; color: var(--accent); margin-top: 1px; }
.attach-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 10px; }
.attach-row[hidden] { display: none; }
.att-chip { display: flex; align-items: center; gap: 9px; max-width: 280px; padding: 6px 8px 6px 6px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-soft); }
.att-chip.ok { border-color: rgba(82, 194, 52, 0.3); }
.att-chip.bad { border-color: rgba(239, 107, 107, 0.45); }
.att-chip.bad .att-detail { color: var(--danger); white-space: normal; }
.att-thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--line-soft); }
.att-icon { width: 36px; height: 36px; border-radius: 8px; flex: none; display: grid; place-items: center; color: var(--accent); background: rgba(82, 194, 52, 0.1); }
.att-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.att-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-detail { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.att-x, .att-dl { flex: none; padding: 4px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.att-x:hover { color: var(--danger); background: rgba(239, 107, 107, 0.1); }
.att-dl:hover { color: var(--accent); background: var(--bg-hover); }
.att-spin { width: 16px; height: 16px; flex: none; margin-left: auto; border-radius: 50%; border: 2px solid rgba(82, 194, 52, 0.25); border-top-color: var(--accent); animation: spin 800ms linear infinite; }
.msg.user { flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-atts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 78%; }
.msg-atts .att-chip { background: var(--bg-elev); backdrop-filter: blur(10px); }
.composer-box.drop { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(82, 194, 52, 0.25), 0 0 30px rgba(82, 194, 52, 0.2); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 760px) { .msg-atts { max-width: 92%; } .att-chip { max-width: 100%; } }

/* ---------- live "Thinking" dropdown (Open WebUI-style) ---------- */
.think summary { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 8px; border-radius: 999px; border: 1px solid transparent; }
.think summary:hover { border-color: var(--line-soft); background: rgba(255, 255, 255, 0.03); color: var(--text); }
.think[open] summary { border-color: var(--line-soft); }
.think-label { font-size: 14px; }
.think summary.thinking .think-label, .think.pending .think-label {
  background: linear-gradient(90deg, var(--muted) 0%, var(--accent-2) 50%, var(--muted) 100%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.think.pending { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 8px; color: var(--muted); }
.think-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: var(--glow); animation: pulse 1s infinite; flex: none; }
.think-body.live::after { content: "▍"; color: var(--accent); animation: blink 1s infinite both; margin-left: 1px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- voice, audio capture, reference chats ---------- */
.mic-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.mic-btn:hover { color: var(--text); background: var(--bg-hover); }
.mic-btn.rec { width: auto; min-width: 34px; padding: 0 10px; color: #fff; background: rgba(239, 107, 107, 0.85); animation: pulse 1.4s infinite; }
.mic-btn.busy { color: var(--accent); }
.rec-time { font: 12.5px var(--mono); }
.rec-bar { display: flex; align-items: center; gap: 10px; width: min(800px, 100%); margin: 0 auto 8px; padding: 8px 12px; border-radius: 14px;
  background: rgba(8, 12, 8, 0.85); border: 1px solid rgba(239, 107, 107, 0.45); font-size: 13.5px; backdrop-filter: blur(12px); }
.rec-bar .think-dot { background: var(--danger); box-shadow: 0 0 12px rgba(239, 107, 107, 0.6); }
.rec-bar span:nth-child(2) { flex: 1; }
.ref-modal { width: min(520px, calc(100% - 32px)); }
.ref-search { width: 100%; margin-bottom: 10px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.04); color: var(--text); font: inherit; }
.ref-search:focus { outline: none; border-color: var(--line); }
.ref-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.ref-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border-radius: 10px; text-align: left; }
.ref-item:hover { background: var(--bg-hover); }
.ref-title { font-size: 14px; }
.ref-meta { font-size: 12px; color: var(--muted); }

/* ---------- notes / knowledge / webpage modals ---------- */
.side-link { color: #cfd8ce; }
.side-link svg { color: var(--accent); }
.lib-modal { width: min(860px, calc(100% - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.lib-head { display: flex; align-items: center; justify-content: space-between; }
.lib-head h3 { margin: 0; }
.lib-split { display: flex; gap: 14px; min-height: 380px; flex: 1; min-height: 0; }
.lib-list { width: 220px; flex: none; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; border-right: 1px solid var(--line-soft); padding-right: 10px; }
.lib-new { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; color: var(--accent-2); font-size: 14px; }
.lib-new:hover, .lib-item:hover { background: var(--bg-hover); }
.lib-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 10px; border-radius: 10px; text-align: left; }
.lib-item.active { background: var(--bg-active); box-shadow: inset 2px 0 0 var(--accent); }
.lib-editor { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.lib-title, .lib-body { width: 100%; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-soft); border-radius: 10px; color: var(--text); font: inherit; padding: 9px 12px; }
.lib-title { font-weight: 600; }
.lib-body { flex: 1; min-height: 260px; resize: vertical; line-height: 1.55; }
.lib-title:focus, .lib-body:focus { outline: none; border-color: var(--line); }
.lib-status { font-size: 12.5px; color: var(--accent-2); }
.lib-kb-head { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-height: 34px; }
.lib-kb-head .btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 13px; }
.btn-ghost.danger:hover { color: var(--danger); }
.lib-docs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.lib-doc { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.02); }
.lib-doc.busy { color: var(--muted); font-size: 13px; }
@media (max-width: 680px) { .lib-split { flex-direction: column; } .lib-list { width: auto; max-height: 160px; border-right: 0; border-bottom: 1px solid var(--line-soft); padding: 0 0 8px; } }
.lib-doc .att-meta { flex: 1; }
.lib-doc .att-x { margin-left: auto; }

/* Usage windows under the composer (lab accounts) */
.disclaimer.usage { margin-bottom: 0; }
.disclaimer.usage[hidden] { display: none; }
.disclaimer.usage.full { color: var(--danger); }
