:root {
  color-scheme: light;
  --bg: #f2f2f3; --sidebar: #e7e7e8; --surface: #fafafb; --text: #1e1e20; --muted: #58585a;
  --border: #d5d5d7; --accent: #007cc3; --accent-hover: #00679f; --accent-text: #fff; --gray: #58585a;
  --link: #007cc3; --user-bubble: #e0eff8; --code-bg: #ebebec; --error: #b42318; --ok: #2e7d32;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #262624; --sidebar: #1f1f1d; --surface: #30302e; --text: #eceae4; --muted: #a19e96;
    --border: #3d3d3a; --accent-hover: #1a8fd1; --link: #4aa8e0; --user-bubble: #3a3936; --code-bg: #1d1d1b;
    --error: #f97066; --ok: #81c784;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--link); }

.btn { font: inherit; font-size: 15px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.big { padding: 14px 20px; font-size: 16px; width: 100%; max-width: 340px; }
.btn.link { border: none; background: none; color: var(--link); padding: 8px; }
.icon-btn { font: inherit; font-size: 20px; width: 44px; height: 44px; border: none; background: none; color: var(--text); border-radius: 10px; cursor: pointer; }
.input { width: 100%; font: inherit; font-size: 15px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.msg { min-height: 20px; font-size: 14px; }
.msg.error { color: var(--error); }

.center-view { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 20px; gap: 8px; }
.center-view h1 { margin: 4px 0; font-size: 26px; }
.logo-big { font-size: 44px; color: var(--accent); }
.list { list-style: none; padding: 0; margin: 12px 0; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
.list li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: left; cursor: pointer; }

/* Chat */
.chat-view { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 4px; padding: calc(6px + env(safe-area-inset-top)) 6px 6px; background: var(--sidebar); border-bottom: 1px solid var(--border); }
.topbar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.topbar .title span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.topbar .title small { color: var(--muted); font-size: 12px; }
.banner { background: var(--gray); color: #fff; text-align: center; font-size: 13px; padding: 4px; }
.messages { flex: 1; overflow-y: auto; padding: 16px 14px; -webkit-overflow-scrolling: touch; }
.welcome { text-align: center; color: var(--muted); margin-top: 18vh; }
.msg-user { display: flex; justify-content: flex-end; margin: 14px 0; }
.msg-user .bubble { background: var(--user-bubble); border-radius: 16px; padding: 9px 14px; max-width: 88%; white-space: pre-wrap; word-wrap: break-word; }
.msg-ai { margin: 14px 0 20px; word-wrap: break-word; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md { margin: 6px 0; }
.md pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 13px; }
.md code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; }
.md :not(pre) > code { background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 8px; }
.thinking { font-size: 14px; color: var(--muted); margin: 6px 0; }
.thinking .body { white-space: pre-wrap; border-left: 2px solid var(--border); padding-left: 10px; margin-top: 4px; }
.tool { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; margin: 4px 0; max-width: 100%; }
.tool.ok .icon { color: var(--ok); } .tool.fail { color: var(--error); }
.tool .detail { flex-basis: 100%; font-size: 13px; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { font-size: 14px; color: var(--muted); margin: 6px 0; }
.notice.error { color: var(--error); }
.typing { display: flex; gap: 4px; padding: 6px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--sidebar); border-top: 1px solid var(--border); }
.composer textarea { flex: 1; font: inherit; font-size: 16px; resize: none; max-height: 160px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 18px; padding: 9px 14px; outline: none; }
.send { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; border: none; background: var(--accent); color: #fff; font-size: 17px; cursor: pointer; }
.send:disabled { opacity: .4; }
.send.stop { background: var(--gray); }

/* Drawer */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; }
.drawer-panel { position: absolute; top: 0; bottom: 0; left: 0; width: 86%; max-width: 360px; background: var(--sidebar); padding: calc(10px + env(safe-area-inset-top)) 14px 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; font-size: 18px; }
.drawer-head b { color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.drawer h3 { margin: 8px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chats { max-width: none; margin: 0; flex: 1; }
.chats li { padding: 10px 12px; }
.chats li.active { border-color: var(--accent); }
.chats small { display: block; color: var(--muted); font-size: 12px; }
.drawer-foot { display: flex; justify-content: space-between; }

/* Potvrzení */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.dialog { background: var(--bg); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.dialog h2 { margin: 0 0 10px; font-size: 18px; }
.confirm-text { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; max-height: 50vh; overflow-y: auto; margin: 0; }
.dialog-buttons { display: flex; gap: 10px; margin-top: 14px; }
.dialog-buttons .btn { flex: 1; padding: 13px; }
