/* Чат за онлайн-столом (shared/chat-ui.js). Размеры и состояния взяты из макета Claude Design. */
:root {
  --ch-av-l: 0.86;
  --ch-warn: oklch(0.5 0.15 50);
  --ch-danger: oklch(0.5 0.17 25);
  --ch-scrim: oklch(0.2 0.015 260 / .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ch-av-l: 0.4; --ch-warn: oklch(0.78 0.12 70); --ch-danger: oklch(0.75 0.13 25); }
}
:root[data-theme="dark"] { --ch-av-l: 0.4; --ch-warn: oklch(0.78 0.12 70); --ch-danger: oklch(0.75 0.13 25); }

/* Кнопка «💬» в шапке */
.ch-btn { position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; outline-offset: 2px; }
.ch-badge { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; box-sizing: border-box; padding: 0 5px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--surface); font-size: 12px; font-weight: 700; line-height: 18px; animation: ch-pulse .5s ease-out 1; }
@keyframes ch-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@keyframes ch-msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ch-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ch-side-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ch-toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Плашка о новом сообщении */
.ch-toast { position: fixed; z-index: 40; top: 62px; right: 8px; max-width: 240px; min-height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; box-shadow: 0 6px 18px oklch(0.3 0.02 260 / .2); animation: ch-toast-in .2s ease-out; cursor: pointer; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (max-width: 359px) { .ch-toast { max-width: 200px; } }
@media (min-width: 700px) { .ch-toast { max-width: 300px; } }

/* Панель чата */
.ch-panel { background: var(--surface); color: var(--ink); border: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; box-sizing: border-box; font-size: 15px; line-height: 1.35; }
.ch-panel.in-lobby { border-radius: 20px; height: 330px; flex: none; width: 100%; }
@media (max-width: 359px) { .ch-panel.in-lobby { height: 276px; } }
.ch-panel.as-sheet { position: fixed; left: 0; right: 0; bottom: 0; height: 60%; z-index: 20; border-radius: 24px 24px 0 0; border-width: 1px 0 0; animation: ch-sheet-in .3s ease-out; }
.ch-panel.as-sheet.turn { height: 46%; }
.ch-panel.as-side { position: fixed; top: 0; right: 0; bottom: 0; width: 340px; z-index: 20; border-width: 0 0 0 1px; border-radius: 0; animation: ch-side-in .3s ease-out; }
@media (min-width: 700px) { .app.ch-side, #app.ch-side { padding-right: 356px; } }
.ch-scrim { position: fixed; inset: 0; z-index: 10; background: var(--ch-scrim); }
.ch-head { display: flex; align-items: center; gap: 2px; padding: 4px 6px 4px 14px; border-bottom: 1px solid var(--line); flex: none; }
.ch-title { flex: 1; font-weight: 700; font-size: 16px; }
.ch-icon { width: 44px; height: 44px; border-radius: 14px; border: 0; background: transparent; color: var(--ink); font-size: 18px; cursor: pointer; }
.ch-icon[aria-expanded="true"] { background: var(--accent-soft); }
.ch-link { min-height: 44px; padding: 0 10px; border-radius: 14px; border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 700; cursor: pointer; }
.ch-settings { padding: 6px 14px; border-bottom: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; flex: none; }
.ch-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; border: 0; background: transparent; color: var(--ink); font-size: 14px; text-align: left; cursor: pointer; padding: 0; }
.ch-switch b { flex: none; min-width: 44px; text-align: center; padding: 4px 8px; border-radius: 12px; font-size: 12px; border: 1px solid var(--accent); background: transparent; color: var(--ink); }
.ch-switch[aria-checked="true"] b { background: var(--accent); color: var(--accent-ink); }
.ch-settings .ch-link { text-align: left; padding: 0; }
.ch-hidden { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; color: var(--muted); font-size: 14px; }
.ch-primary { min-height: 44px; padding: 0 20px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; cursor: pointer; }
.ch-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ch-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.ch-empty { margin: auto; text-align: center; color: var(--muted); font-size: 14px; }
.ch-row { display: flex; flex-direction: column; gap: 0; animation: ch-msg-in .2s ease-out; }
.ch-row.mine { align-items: flex-end; }
.ch-row.other { align-items: flex-start; }
.ch-sys { align-self: center; text-align: center; font-size: 12px; color: var(--muted); padding: 4px 10px; }
.ch-from { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.ch-row.mine .ch-from { flex-direction: row-reverse; }
.ch-av { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: none; color: oklch(0.3 0.04 260); background: oklch(var(--ch-av-l) 0.08 var(--ch-hue, 200)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ch-av { color: oklch(0.95 0.02 90); } }
:root[data-theme="dark"] .ch-av { color: oklch(0.95 0.02 90); }
.ch-name { font-size: 12px; font-weight: 700; color: var(--muted); }
.ch-row.mine .ch-name { color: var(--accent); }
.ch-line { display: flex; align-items: flex-start; max-width: 100%; }
.ch-row.mine .ch-line { flex-direction: row-reverse; }
.ch-bubble { max-width: calc(100% - 44px); box-sizing: border-box; padding: 7px 12px 6px; font-size: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; }
.ch-row.mine .ch-bubble { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 16px 16px 4px 16px; }
.ch-row.mine.err .ch-bubble { border-color: var(--ch-danger); }
.ch-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.ch-meta { display: flex; justify-content: flex-end; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.ch-dots { flex: none; width: 44px; height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.ch-retry { min-height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--ch-danger); background: transparent; color: var(--ch-danger); font-weight: 700; font-size: 14px; cursor: pointer; }
.ch-copy { min-height: 44px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; cursor: pointer; box-shadow: 0 4px 12px oklch(0.3 0.02 260 / .15); }
.ch-below { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); min-height: 44px; padding: 0 16px; border-radius: 22px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 4px 14px oklch(0.3 0.02 260 / .3); white-space: nowrap; }
.ch-form { flex: none; padding: 8px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.ch-inputrow { display: flex; gap: 8px; }
.ch-input { flex: 1; min-width: 0; height: 44px; box-sizing: border-box; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 0 12px; font-size: 16px; font-family: inherit; outline-offset: 2px; }
.ch-input.warn { border-color: var(--ch-warn); }
.ch-send { flex: none; width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 700; cursor: pointer; }
.ch-send[aria-disabled="true"] { background: var(--line); color: var(--muted); cursor: default; }
.ch-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.ch-counter.warn { color: var(--ch-warn); font-weight: 700; }
.ch-btn:focus-visible, .ch-panel button:focus-visible, .ch-input:focus-visible, .ch-toast:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .ch-row, .ch-panel, .ch-toast, .ch-badge { animation: none !important; } }
