[hidden] { display: none !important; }
:root {
  --bg: #0b0b0c; --side: #111113; --panel: #18181b; --line: #26262b;
  --bubble-ai: #1b1b1f; --bubble-me: #2b2b31; --text: #ececf1; --muted: #8b8b95;
  --accent: #f5a524; --danger: #ef4444; --ok: #22c55e;
  --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: #7cb7ff; }
#app { display: grid; grid-template-columns: 290px 1fr; height: 100dvh; }

/* ---------- stranska vrstica ---------- */
#sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.side-actions { display: flex; gap: 6px; }
.icon-btn { background: transparent; border: 0; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 17px; color: var(--muted); flex: none; }
.icon-btn:hover { background: #ffffff12; color: var(--text); }
.icon-btn.round { background: #ffffff14; color: var(--text); }
.icon-btn.send { background: var(--text); color: #000; }
.icon-btn.active { background: var(--accent); color: #000; }
#searchBox { padding: 0 12px 8px; }
#searchBox input, dialog input, dialog select, dialog textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 11px; font: inherit; }
#searchResults { overflow: auto; max-height: 40vh; border-bottom: 1px solid var(--line); }
.search-hit { padding: 8px 14px; cursor: pointer; font-size: 13px; }
.search-hit:hover { background: #ffffff0d; }
.search-hit b { color: var(--accent); }
#agentList { flex: 1; overflow: auto; padding: 4px 8px; }
.agent-item { display: flex; gap: 11px; align-items: center; padding: 9px 10px; border-radius: 12px; cursor: pointer; position: relative; }
.agent-item:hover { background: #ffffff0a; }
.agent-item.active { background: #ffffff14; }
.agent-item .meta { min-width: 0; flex: 1; }
.agent-item .name { font-weight: 600; font-size: 14.5px; display: flex; justify-content: space-between; gap: 6px; }
.agent-item .name time { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.agent-item .preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-item .typing-mini { color: var(--accent); }
.unread { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; flex: none; overflow: hidden; background: #333; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: 14px; }
.avatar.xl { width: 84px; height: 84px; font-size: 44px; }
.side-bottom { display: flex; gap: 8px; align-items: center; padding: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pill { background: #ffffff10; border: 0; border-radius: 999px; padding: 7px 13px; font-size: 13.5px; }
.pill:hover { background: #ffffff1c; }
.monitor-dot { width: 10px; height: 10px; border-radius: 50%; background: #444; margin-left: auto; }
.monitor-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.monitor-dot.err { background: var(--danger); }

/* ---------- pogovor ---------- */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
#chatHeader { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: relative; min-height: 58px; }
.chat-title { display: flex; align-items: center; gap: 9px; background: #ffffff0d; border-radius: 999px; padding: 4px 14px 4px 4px; font-weight: 600; margin: 0 auto; cursor: pointer; }
.chat-title .sub { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.head-actions { display: flex; gap: 2px; position: absolute; right: 10px; }
.back { display: none; position: absolute; left: 8px; font-size: 28px; }
.menu { position: absolute; right: 12px; top: 52px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; z-index: 20; display: flex; flex-direction: column; min-width: 220px; box-shadow: 0 10px 30px #0008; }
.menu button { background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 8px; }
.menu button:hover { background: #ffffff12; }
#messages { flex: 1; overflow-y: auto; padding: 18px max(16px, calc((100% - 820px) / 2)) 10px; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; }
.empty { position: absolute; inset: 58px 0 80px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 20px; pointer-events: none; }
.empty .avatar { margin: 0 auto 10px; }
.empty h3 { color: var(--text); margin: 6px 0; }

.msg { display: flex; flex-direction: column; max-width: min(78%, 640px); position: relative; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg + .msg.gap { margin-top: 8px; }
.bubble { padding: 9px 14px; border-radius: var(--radius); background: var(--bubble-ai); border: 1px solid #ffffff0a; word-wrap: break-word; overflow-wrap: anywhere; position: relative; }
.user .bubble { background: var(--bubble-me); }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble code { background: #ffffff14; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.bubble pre { background: #0d0d0f; border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; font-size: 12.5px; margin: 6px 0; }
.bubble pre code { background: none; padding: 0; }
.code-wrap { position: relative; }
.code-tools { display: flex; gap: 6px; margin: -2px 0 6px; flex-wrap: wrap; }
.code-tools button { background: #ffffff12; border: 0; border-radius: 8px; padding: 4px 10px; font-size: 12.5px; }
.code-tools button.run { background: var(--ok); color: #000; font-weight: 600; }
.py-result { border-left: 3px solid var(--ok); padding: 6px 10px; margin-top: 6px; background: #0d0d0f; border-radius: 6px; font-size: 12.5px; }
.py-result pre { margin: 0; border: 0; padding: 0; white-space: pre-wrap; background: none; }
.py-result.err { border-color: var(--danger); }
.msg-images { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; justify-content: flex-end; }
.msg-images img { max-width: 220px; max-height: 260px; border-radius: 12px; cursor: zoom-in; border: 1px solid var(--line); background: #fff; }
.assistant .msg-images { justify-content: flex-start; }
.msg-files { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.reactions { position: absolute; bottom: -10px; right: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; font-size: 13px; cursor: pointer; }
.user .reactions { right: auto; left: 8px; }
.msg.has-react { margin-bottom: 10px; }
.msg-actions { display: none; position: absolute; top: -14px; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px; z-index: 5; }
.assistant .msg-actions { right: -10px; } .user .msg-actions { left: -10px; }
.msg:hover .msg-actions, .msg.show-actions .msg-actions { display: flex; }
.msg-actions button { background: none; border: 0; width: 28px; height: 26px; border-radius: 999px; font-size: 13px; }
.msg-actions button:hover { background: #ffffff18; }
.msg-time { font-size: 11px; color: var(--muted); margin: 2px 8px 0; }
.consult { font-size: 13px; background: #ffffff08; border: 1px dashed #ffffff22; border-radius: 12px; padding: 6px 10px; margin-bottom: 4px; }
.consult summary { cursor: pointer; color: var(--muted); }
.consult .q { color: var(--muted); margin: 6px 0; white-space: pre-wrap; }
.consult .a { white-space: pre-wrap; }
.tools-used { font-size: 11px; color: var(--muted); margin: 2px 8px 0; }
.event { align-self: center; max-width: 90%; font-size: 12.5px; color: var(--muted); background: #ffffff08; border-radius: 12px; padding: 5px 12px; white-space: pre-wrap; cursor: pointer; }
.event.collapsed { max-height: 2.9em; overflow: hidden; }
.error { align-self: center; color: #fca5a5; background: #ef44441a; border: 1px solid #ef444444; border-radius: 12px; padding: 7px 12px; font-size: 13.5px; max-width: 90%; }
.pyresult-msg .bubble { background: #0f1a12; border-color: #22c55e33; font-size: 13px; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--muted); margin: 10px 0 4px; }
.typing .bubble { display: flex; gap: 4px; align-items: center; padding: 13px 16px; }
.typing .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing .dot:nth-child(2) { animation-delay: .2s; } .typing .dot:nth-child(3) { animation-delay: .4s; }
.typing .who { font-size: 12px; color: var(--muted); margin-left: 6px; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- vnos ---------- */
#composer { padding: 8px max(12px, calc((100% - 840px) / 2)) max(12px, env(safe-area-inset-bottom)); }
.bar { display: flex; align-items: flex-end; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 5px 6px; }
#input { flex: 1; background: none; border: 0; color: var(--text); font: inherit; resize: none; max-height: 180px; padding: 8px 4px; outline: none; }
#attachPreview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.att { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; font-size: 12px; }
.att img { height: 56px; border-radius: 6px; display: block; }
.att button { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #444; font-size: 11px; }
#btnMic.listening { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* ---------- dialogi ---------- */
dialog { background: var(--side); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(560px, 94vw); max-height: 90dvh; }
dialog::backdrop { background: #000a; }
dialog form { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
dialog h2 { margin: 0 0 4px; font-size: 19px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
dialog label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
dialog label.chk input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
legend { color: var(--text); font-weight: 600; padding: 0 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.row { display: flex; gap: 12px; align-items: center; }
.grow { flex: 1; }
.avatar-edit { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.small-btn { background: #ffffff14; border: 0; border-radius: 8px; padding: 6px 11px; font-size: 13px; color: var(--text); cursor: pointer; align-self: flex-start; display: inline-block; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.dialog-actions button { border: 0; border-radius: 10px; padding: 9px 16px; background: #ffffff14; }
.dialog-actions .primary { background: var(--text); color: #000; font-weight: 600; }
.danger { color: var(--danger) !important; background: #ef44441a !important; }
.mem-item { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.mem-item span { flex: 1; }
.mem-item button { background: none; border: 0; color: var(--muted); }
.test-out { font-size: 12.5px; }
code.copyable { display: block; word-break: break-all; background: var(--panel); padding: 8px; border-radius: 8px; cursor: copy; font-size: 12px; }
.react-picker { position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px; display: flex; gap: 2px; box-shadow: 0 8px 24px #000a; }
.react-picker button { background: none; border: 0; font-size: 20px; width: 36px; height: 36px; border-radius: 50%; }
.react-picker button:hover { background: #ffffff18; }
#toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 9px 16px; border-radius: 12px; z-index: 60; font-size: 14px; box-shadow: 0 8px 24px #000a; }
.lightbox { position: fixed; inset: 0; background: #000e; display: grid; place-items: center; z-index: 70; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 94vh; }

/* ---------- telefon ---------- */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #main { display: none; }
  #app.show-chat #sidebar { display: none; }
  #app.show-chat #main { display: flex; }
  .back { display: inline-grid; }
  .msg { max-width: 86%; }
  .msg-images img { max-width: 160px; }
  .chat-title { margin: 0 auto; }
}
