/* ==========================================================================
   Chat v novém designu. Staví na site.css (proměnné, tlačítka, modaly, štítky).
   Třídy a ID odpovídají app.js – neměnit bez úpravy skriptu.
   ========================================================================== */

body.page-chat { height: 100vh; height: 100dvh; overflow: hidden; }
.page-chat .site-nav { border-bottom-color: var(--line); background: rgba(14, 15, 17, .92); }
.page-chat .nav-inner { max-width: 1640px; }
.page-chat main { position: fixed; inset: 72px 0 0; display: flex; }
.chat-app { flex: 1; min-width: 0; min-height: 0; width: 100%; max-width: 1640px; margin: 0 auto; padding: 0 var(--gutter); display: flex; flex-direction: column; position: relative; }

/* ---------------------------------------------------------------- lišta */
.chat-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; }
.chat-bar-left, .chat-bar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-bar-left { flex: 1; }
.picker-btn { gap: 8px; }
.picker-count { font: 500 12px var(--mono); color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 6px; }
.picker-btn .arrow { display: inline-flex; color: var(--muted); transition: transform .2s; }
.picker-btn .arrow .icon { width: 15px; height: 15px; }
.picker-btn .arrow.show { transform: rotate(180deg); }
.model-chips { display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.model-chips::-webkit-scrollbar { display: none; }
.model-chip {
    flex: none; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 12px;
    border-radius: 999px; background: var(--card); border: 1px solid var(--line-2); font-size: 14px; color: var(--text-2);
}
.model-chip img { width: 17px; height: 17px; object-fit: contain; }
.model-chip button { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--dim); }
.model-chip button:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.model-chip .icon { width: 13px; height: 13px; }

/* výběr modelů */
.dropdown { position: relative; flex: none; }
.dropdown-content {
    position: absolute; top: calc(100% + 10px); left: 0; z-index: 30; width: 340px; max-height: min(62vh, 620px); overflow: auto; padding: 8px;
    background: var(--card); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
    opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .2s, transform .25s var(--ease), visibility .2s;
}
.dropdown-content.show { opacity: 1; visibility: visible; transform: none; }
.dropdown-head { display: flex; justify-content: space-between; padding: 8px 10px 10px; font-size: 13px; color: var(--muted); }
.dropdown-head .mono { font-size: 12px; color: var(--dim); }
.dropdown-item {
    position: relative; display: grid; grid-template-columns: 20px 20px 1fr auto; align-items: center; gap: 12px;
    padding: 10px; border-radius: 11px; cursor: pointer; font-size: 14.5px; color: var(--text-2); transition: background .15s;
}
.dropdown-item:hover { background: rgba(255, 255, 255, .04); }
.dropdown-item input { position: absolute; opacity: 0; pointer-events: none; }
.dropdown-item .check { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.dropdown-item .check .icon { width: 13px; height: 13px; stroke-width: 3; color: #fff; opacity: 0; }
.dropdown-item input:checked ~ .check { background: var(--accent); border-color: var(--accent); }
.dropdown-item input:checked ~ .check .icon { opacity: 1; }
.dropdown-item input:focus-visible ~ .check { box-shadow: 0 0 0 3px var(--accent-soft); }
.dropdown-item.toggled { color: var(--text); }
.dropdown-item .item-logo { width: 20px; height: 20px; object-fit: contain; }
.dropdown-item.unavailable, .dropdown-item.locked { color: var(--dim); }
.dropdown-item.unavailable { cursor: not-allowed; }
.dropdown-item.unavailable .item-logo, .dropdown-item.locked .item-logo { opacity: .5; }
.model-badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font: 600 11px var(--mono); letter-spacing: .04em; }
.model-badge .icon { width: 12px; height: 12px; }
.model-badge.pro { background: var(--accent-soft); color: var(--accent); }
.model-badge.soon { background: var(--card-3); color: var(--muted); }
.model-badge.own { background: var(--good-soft); color: var(--good); }
.dropdown-item:not(.locked) .icon-lock, .dropdown-item.locked .icon-pro { display: none; }
.dropdown-keys { width: 100%; margin-top: 6px; display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.dropdown-keys:hover { color: var(--text); }
.dropdown-keys .icon { width: 16px; height: 16px; }
.dropdown-keys .end { margin-left: auto; width: 14px; height: 14px; }

/* limity a nástroje */
.usage-status { display: flex; align-items: center; gap: 8px; min-width: 0; font: 500 12px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; }
.usage-status:empty { display: none; }
.usage-tier { font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; }
.usage-sep { color: var(--line-2); }
.usage-status a { color: var(--text-2); }
.usage-status a:hover { color: var(--accent); }
.usage-status .icon { width: 15px; height: 15px; color: var(--warn); }
.tool-btn {
    flex: none; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line-2); background: rgba(255, 255, 255, .02); font-size: 14px; color: var(--text-2); cursor: pointer;
    transition: color .2s, border-color .2s, background .2s;
}
.tool-btn:hover { color: var(--text); border-color: #45474e; }
.tool-btn .icon { width: 16px; height: 16px; }
.tool-btn.icon-only { width: 38px; padding: 0; justify-content: center; }
.tool-btn.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.tool-btn[data-unavailable] { opacity: .5; }
.keys-count { font: 600 11px var(--mono); color: var(--good); }
.memory-btn .switch { position: relative; width: 28px; height: 16px; border-radius: 99px; background: var(--line-2); transition: background .2s; }
.memory-btn .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .2s var(--ease), background .2s; }
.memory-btn.on .switch { background: var(--accent); }
.memory-btn.on .switch::after { transform: translateX(12px); background: #fff; }

/* ---------------------------------------------------------------- okna modelů */
.chat-stage { position: relative; flex: 1; min-height: 0; }
.chat-windows { height: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; padding-bottom: 12px; }
.is-empty .chat-windows { visibility: hidden; }
.chat-box-wrapper {
    min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    animation: rise .5s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.chat-box-wrapper.dragging { opacity: .4; border-style: dashed; border-color: var(--accent-line); }
.chat-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--line); }
.chat-logo { width: 20px; height: 20px; object-fit: contain; }
.chat-title { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-badge { font: 600 10.5px var(--mono); letter-spacing: .05em; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 2px 6px; }
.chat-tools { margin-left: auto; display: flex; gap: 2px; }
.chat-tool { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--dim); transition: color .2s, background .2s; }
.chat-tool:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.chat-tool .icon { width: 15px; height: 15px; }
.drag-handle { cursor: grab; }
.chat-box { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.chat-content { display: flex; flex-direction: column; gap: 16px; }
.chat-content:empty::before { content: "Waiting for your question"; display: block; padding: 24px 0; text-align: center; font: 400 12.5px var(--mono); color: var(--dim); }

/* zprávy */
.chat-message { font-size: 14.5px; line-height: 1.68; color: var(--text-2); overflow-wrap: anywhere; }
.chat-message .model-logo { display: none; }
.chat-message.user {
    align-self: flex-end; max-width: 92%; padding: 10px 14px; border-radius: 14px 14px 4px 14px;
    background: var(--card-3); border: 1px solid var(--line-2); color: var(--text); white-space: pre-wrap;
}
.animated-text > :first-child { margin-top: 0; }
.animated-text p { margin: 0 0 .75em; }
.animated-text p:last-child { margin-bottom: 0; }
.animated-text strong { color: var(--text); font-weight: 600; }
.animated-text ul, .animated-text ol { margin: 0 0 .75em; padding-left: 20px; }
.animated-text li + li { margin-top: 4px; }
.animated-text h3, .animated-text h4, .animated-text h5, .animated-text h6 { margin: 1em 0 .4em; font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.animated-text code { font-size: 12.5px; color: var(--text); background: var(--card-3); border-radius: 5px; padding: 1px 5px; }
.animated-text pre { margin: .6em 0 .9em; padding: 12px 14px; overflow-x: auto; background: #0b0c0e; border: 1px solid var(--line); border-radius: 10px; }
.animated-text pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; color: var(--text-2); }
.animated-text a { color: var(--text); border-bottom: 1px solid var(--line-2); }
a.cite {
    display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin: 0 1px;
    border-radius: 5px; background: var(--accent-soft); color: var(--accent) !important; border: 0 !important;
    font: 600 10.5px var(--mono); vertical-align: 2px; text-decoration: none;
}
a.cite:hover { background: var(--accent); color: #fff !important; }
.chat-message.error, .chat-message.locked { padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.chat-message.error { background: rgba(240, 122, 106, .08); border: 1px solid rgba(240, 122, 106, .3); color: #f3b4aa; }
.chat-message.locked { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text-2); }
.message-icon { display: inline-block; width: 15px; height: 15px; margin-right: 8px; vertical-align: -2px; }
.chat-message.locked .message-icon { color: var(--accent); }
.msg-note { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font: 400 12px var(--mono); color: var(--dim); }
.msg-note .icon { width: 14px; height: 14px; }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.msg-file { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px 0 4px; border-radius: 7px; background: var(--card); border: 1px solid var(--line-2); font: 500 12px var(--mono); color: var(--text-2); }
.msg-file img { width: 20px; height: 20px; border-radius: 4px; object-fit: cover; }
.msg-file .icon { width: 14px; height: 14px; margin-left: 4px; color: var(--accent); }
.msg-sources { border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); font-size: 13px; }
.msg-sources summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; list-style: none; font: 500 12px var(--mono); color: var(--muted); }
.msg-sources summary::-webkit-details-marker { display: none; }
.msg-sources summary .icon { width: 14px; height: 14px; color: var(--accent); }
.msg-sources[open] summary { border-bottom: 1px solid var(--line); }
.msg-sources ol { margin: 0; padding: 8px 12px 10px 30px; display: flex; flex-direction: column; gap: 6px; color: var(--dim); }
.msg-sources li a { color: var(--text-2); }
.msg-sources li a:hover { color: var(--accent); }
.msg-sources li span { display: block; font: 400 11.5px var(--mono); color: var(--dim); }
.typing-loader { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing-loader span { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: blink 1.2s infinite; }
.typing-loader span:nth-child(2) { animation-delay: .15s; }
.typing-loader span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 30% { background: var(--accent); transform: translateY(-3px); } }

/* ---------------------------------------------------------------- prázdný stav */
.chat-empty {
    position: absolute; inset: 0; z-index: 1; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px 0 40px;
}
.is-empty .chat-empty { display: flex; }
.chat-empty-title { margin: 22px 0 0; font-weight: 600; letter-spacing: -0.045em; line-height: 1.02; font-size: clamp(34px, 4.6vw, 64px); text-wrap: balance; }
.prompt-list { margin-top: 36px; display: grid; grid-template-columns: repeat(2, minmax(0, 320px)); gap: 10px; }
.prompt {
    display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px 18px; text-align: left; font-size: 14.5px; line-height: 1.45; color: var(--text-2);
    background: var(--card); border: 1px solid var(--line); border-radius: 16px; transition: border-color .2s, background .2s, color .2s;
}
.prompt:hover { border-color: var(--accent-line); background: var(--card-2); color: var(--text); }

/* přetažení souboru */
.drop-overlay {
    position: absolute; inset: 0 0 12px; z-index: 5; display: grid; place-items: center; border-radius: var(--radius);
    border: 1.5px dashed var(--accent); background: rgba(14, 15, 17, .86); opacity: 0; pointer-events: none; transition: opacity .15s;
}
.dropping .drop-overlay { opacity: 1; }
.drop-overlay div { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop-overlay .icon { width: 28px; height: 28px; color: var(--accent); margin-bottom: 6px; }
.drop-overlay strong { font-size: 18px; font-weight: 600; }
.drop-overlay span { font-size: 14px; color: var(--muted); }

/* ---------------------------------------------------------------- pole pro otázku */
.composer-wrap { flex: none; width: 100%; max-width: 860px; margin: 0 auto; padding-bottom: 12px; position: relative; }
.turn-actions { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.quorum-btn span { font-weight: 400; opacity: .78; margin-left: 2px; }
.quorum-btn.loading .icon { animation: spin 1s linear infinite; }
.quorum-btn:disabled { opacity: .7; }
.web-hint { display: flex; align-items: center; gap: 10px; margin: 0 auto 10px; width: fit-content; max-width: 100%; padding: 6px 6px 6px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line-2); font-size: 13.5px; color: var(--muted); }
.web-hint .icon { width: 15px; height: 15px; color: var(--accent); }
.web-hint button { height: 30px; padding: 0 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 500; }
.web-hint button:hover { background: var(--accent); color: #fff; }
.composer { background: var(--card); border: 1px solid var(--line-2); border-radius: 22px; transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer textarea {
    display: block; width: 100%; min-height: 56px; max-height: 200px; resize: none; border: 0; outline: 0; background: none; color: var(--text);
    padding: 16px 20px 4px; font: 400 15.5px/1.55 var(--sans); letter-spacing: -0.005em;
}
.composer textarea::placeholder { color: var(--dim); }
.composer-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px 10px 12px; }
.composer-hint { margin-left: auto; font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.composer-hint .kbd { font-size: 11px; padding: 1px 6px; }
.send { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; transition: background .2s, opacity .2s; }
.send:hover { background: var(--accent-2); }
.send .icon { width: 18px; height: 18px; stroke-width: 2.4; }
.composer.busy .send, .send:disabled { opacity: .45; cursor: default; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px 0; }
.attach-chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 4px 0 5px; border-radius: 9px; background: var(--card-3); border: 1px solid var(--line-2); font: 500 12.5px var(--mono); color: var(--text-2); max-width: 240px; }
.attach-chip img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
.attach-chip > .icon { width: 15px; height: 15px; color: var(--accent); margin-left: 4px; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--dim); }
.attach-chip button:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.attach-chip button .icon { width: 13px; height: 13px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; padding: 0 6px; }
.composer-note { margin: 0 0 0 auto; font-size: 12px; color: var(--dim); white-space: nowrap; }

/* ---------------------------------------------------------------- verdikt a sdílení */
.modal-content.wide { max-width: 820px; }
.modal-body { padding: 22px 26px; }
.modal-foot { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 26px; background: var(--card); border-top: 1px solid var(--line); }
.modal-note { margin: 0; font-size: 13px; color: var(--dim); }
.quorum-card { --g: var(--accent); }
.quorum-card.verdict-reached { --g: var(--good); }
.quorum-card.verdict-partial { --g: var(--warn); }
.quorum-card.verdict-split { --g: var(--bad); }
.quorum-head { display: flex; align-items: center; gap: 18px; padding: 18px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line); }
.quorum-gauge {
    flex: none; position: relative; width: 76px; height: 76px; border-radius: 50%;
    background: conic-gradient(var(--g) calc(var(--pct) * 1%), var(--line-2) 0);
}
.quorum-gauge::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--card-2); }
.quorum-gauge span { position: absolute; inset: 0; display: grid; place-items: center; font: 600 18px var(--mono); }
.quorum-verdict { display: block; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; color: var(--g); }
.quorum-sub { display: block; margin-top: 4px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.quorum-card .md { margin-top: 18px; font-size: 15px; line-height: 1.7; color: var(--text-2); }
.quorum-card .md p { margin: 0 0 .8em; }
.quorum-card .md strong { color: var(--text); }
.quorum-agree, .quorum-split { margin-top: 20px; }
.quorum-agree h3, .quorum-split h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font: 500 12.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.quorum-agree h3 .icon { width: 16px; height: 16px; color: var(--good); }
.quorum-split h3 .icon { width: 16px; height: 16px; color: var(--accent); }
.quorum-agree ul { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.quorum-agree li + li { margin-top: 5px; }
.split-item { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); }
.split-item + .split-item { margin-top: 8px; }
.split-item strong { display: block; font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.split-item p { margin: 6px 0 0; font-size: 14px; line-height: 1.55; color: var(--muted); }
.split-models { display: inline-block; margin-right: 6px; font: 600 11.5px var(--mono); color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 2px 7px; }
.quorum-none, .quorum-note { display: flex; align-items: flex-start; gap: 8px; margin: 18px 0 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.quorum-none .icon { color: var(--good); width: 16px; height: 16px; margin-top: 2px; }
.quorum-note .icon { color: var(--dim); width: 16px; height: 16px; margin-top: 2px; }
.share-preview { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); }
.share-link { margin-top: 16px; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg); }
.share-link > .icon { width: 16px; height: 16px; color: var(--muted); }
.share-link input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: 400 13.5px var(--mono); }
.share-actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
#share-modal .modal-note { margin-top: 14px; }

/* ---------------------------------------------------------------- responzivita */
@media (max-width: 1100px) {
    .composer-note { display: none; }
}
@media (max-width: 980px) {
    .chat-windows { grid-auto-columns: minmax(300px, 1fr); overflow-x: auto; scroll-snap-type: x mandatory; }
    .chat-box-wrapper { scroll-snap-align: start; }
}
@media (max-width: 720px) {
    .page-chat main { inset: 64px 0 0; }
    .chat-bar { flex-wrap: wrap; gap: 8px; padding: 10px 0; }
    .chat-bar-left { flex-basis: 100%; }
    .chat-bar-right { width: 100%; justify-content: flex-start; }
    .memory-btn span:last-child { display: none; }
    .chat-windows { grid-auto-columns: 86%; gap: 10px; }
    .composer-hint { display: none; }
    .composer-row .send { margin-left: auto; }
    .prompt-list { grid-template-columns: 1fr; width: 100%; }
    .chat-empty { justify-content: flex-start; padding-top: 24px; overflow-y: auto; }
    .quorum-btn span { display: none; }
    .composer-note { display: none; }
    .modal-body, .modal-head, .modal-foot { padding-left: 18px; padding-right: 18px; }
    .modal-foot { flex-direction: column; align-items: stretch; }
    .dropdown-content { width: min(340px, calc(100vw - 32px)); }
}
