/* One light design system, shared by both chat surfaces. */
:root {
  color-scheme: light;
  --ink: #233246;
  --muted: #64748b;
  --line: #e5eaf0;
  --accent: #087e8b;
  --soft: #eaf6f6;
  --app-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: #f5f7fa;
}
* { box-sizing: border-box; }
body { margin: 0; height: var(--app-height); overflow: hidden; line-height: 1.5; }
button, input, textarea, select { font: inherit; color: var(--ink); }
button, select, summary { cursor: pointer; }
button { border: 0; background: none; }
button:disabled { cursor: not-allowed; opacity: .45; }
input, textarea, select { border: 1px solid #dce3eb; border-radius: 9px; background: #fff; padding: 10px 12px; min-width: 0; }
input::placeholder, textarea::placeholder { color: #7d8b9c; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: 3px solid #087e8b18; }
:focus-visible { outline: 3px solid #0e899c60; outline-offset: 2px; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }
.workspace-bar { height: 64px; display: flex; align-items: center; padding: 0 26px; gap: 22px; background: #fff; border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 750; }
.brand-icon { display: inline-grid; place-items: center; background: var(--accent); color: #fff; width: 32px; height: 32px; border-radius: 10px; font-weight: 700; }
.workspace-caption, .device-label { font-size: 12px; color: var(--muted); }
.device-label { margin-left: auto; }
.version-label { font-size: 11px; color: var(--accent); padding: 3px 8px; border-radius: 5px; background: var(--soft); }
.app-frame { min-height: 0; overflow: hidden; }
.agent-frame { height: calc(var(--app-height) - 64px); display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.contact-sidebar { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); min-width: 0; min-height: 0; background: #fff; border-right: 1px solid var(--line); }
.sidebar-top { display: flex; justify-content: space-between; align-items: center; padding: 22px 20px 14px; }
.sidebar-top h2 { font-size: 20px; }
.sidebar-filters { display: grid; gap: 14px; padding: 0 20px 16px; }
.stats-strip { display: flex; gap: 10px; }
.stat-chip { flex: 1; display: flex; justify-content: space-between; align-items: center; background: #f5f7fa; border-radius: 8px; padding: 9px 12px; font-size: 12px; color: var(--muted); }
.stat-chip strong { font-size: 17px; color: var(--ink); }
.search-input { width: 100%; background: #fafbfc; }
.filter-row { display: flex; padding: 3px; background: #f1f4f7; border-radius: 9px; }
.filter-btn { flex: 1; padding: 7px; border-radius: 7px; color: var(--muted); font-size: 12px; }
.active-filter { background: #fff; color: var(--accent); box-shadow: 0 1px 4px #24354512; font-weight: 650; }
.channel-filter { padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.channel-filter select { font-size: 12px; padding: 6px 9px; }
.contact-list { overflow: auto; min-height: 0; padding: 8px; }
.contact-card { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; width: 100%; text-align: left; padding: 14px 10px; border: 1px solid transparent; border-radius: 10px; margin-bottom: 3px; }
.contact-card:hover { background: #f5f8fa; }
.contact-card.active { background: var(--soft); border-color: #c1e2e3; }
.contact-avatar, .service-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #eff3f8; color: #526680; font-size: 13px; font-weight: 700; }
.contact-avatar.telegram { background: #e9f4ff; color: #2478bc; }
.contact-copy { min-width: 0; }
.contact-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.contact-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.contact-status-wrap { display: flex; gap: 5px; flex-shrink: 0; color: var(--muted); font-size: 10px; }
.contact-card p { margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #586b81; font-size: 12px; }
.contact-card small { display: block; margin-top: 6px; font-size: 10px; color: #6b7c90; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge { font-style: normal; color: #fff; background: var(--accent); border-radius: 12px; padding: 0 5px; }
.chat-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: #fff; }
.chat-header { flex: 0 0 auto; min-height: 76px; padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.chat-header > div:first-child, .chat-header-info { min-width: 0; }
.chat-header-info strong { font-size: 16px; }
.chat-header-info p { font-size: 12px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.client-meta { flex: 0 0 auto; max-height: 36%; overflow: auto; margin: 0; background: #fafcfd; border-bottom: 1px solid var(--line); font-size: 12px; }
.client-meta.empty-state { display: none; }
.meta-summary { position: sticky; top: 0; z-index: 1; background: #fafcfd; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding: 12px 28px; list-style: none; }
.meta-summary::-webkit-details-marker { display: none; }
.meta-summary-item { min-width: 0; max-width: 100%; }
.meta-summary-item span { margin-right: 7px; color: var(--muted); }
.meta-summary-item strong { font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.meta-expand-text { margin-left: auto; color: var(--accent); white-space: nowrap; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; padding: 0 28px; }
.meta-grid > div { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.meta-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.meta-grid strong { font-weight: 500; overflow-wrap: anywhere; }
.note-editor { display: flex; gap: 8px; padding: 12px 28px; }
.note-editor input { flex: 1; }
.message-list { flex: 1 1 0; min-height: 0; overflow: auto; padding: 26px 32px; display: flex; flex-direction: column; gap: 20px; background: #f8fafc; overscroll-behavior: contain; }
.conversation-empty, .message-list > .empty-state { margin: auto; text-align: center; color: var(--muted); padding: 25px 12px; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border: 1px solid #dce8eb; border-radius: 20px; background: #fff; color: var(--accent); font-size: 30px; margin: 0 auto 18px; }
.conversation-empty h2 { color: #40556a; font-size: 18px; font-weight: 600; margin-bottom: 9px; }
.conversation-empty p { font-size: 13px; line-height: 1.9; }
.list-empty { padding: 40px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.list-empty span, .list-empty strong { display: block; margin-bottom: 8px; }
.bubble-row { max-width: min(78%, 600px); display: flex; flex-direction: column; gap: 7px; }
.from-self { align-self: flex-end; }
.from-other { align-self: flex-start; }
.bubble-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 10px; color: var(--muted); }
.from-self .bubble-meta { justify-content: flex-end; }
.bubble { padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 3px 14px 14px 14px; overflow-wrap: anywhere; }
.bubble p { white-space: pre-wrap; }
.from-self .bubble { background: var(--soft); border-color: #cce7e7; color: #164a50; border-radius: 14px 3px 14px 14px; }
.message-link { color: inherit; text-decoration: underline; }
.bubble-image, .bubble-video { display: block; max-width: min(100%, 320px); max-height: 400px; border-radius: 8px; }
.file-card { display: flex; flex-direction: column; gap: 5px; color: inherit; text-decoration: none; }
.file-card span { font-size: 11px; }
.composer { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 16px 28px 20px; background: #fff; }
.composer-inline { display: flex; gap: 10px; align-items: flex-end; }
.composer-field { flex: 1; min-width: 0; }
.composer-field textarea { display: block; width: 100%; min-height: 44px; max-height: 140px; resize: none; background: #fafbfc; }
.send-btn, .primary-btn { background: var(--accent); color: #fff; border-radius: 9px; padding: 11px 17px; font-weight: 600; white-space: nowrap; }
.send-btn { min-height: 44px; }
.send-btn:hover:not(:disabled), .primary-btn:hover { background: #066772; }
.ghost-btn, .back-btn { border: 1px solid #dce3eb; background: #fff; color: #40556a; border-radius: 8px; padding: 8px 12px; white-space: nowrap; }
.ghost-btn:hover, .back-btn:hover { background: #f0f5f7; }
.icon-tool-btn { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: 9px; border: 1px solid #dce3eb; background: #fff; font-size: 24px; color: #536c81; cursor: pointer; }
.toolbar:has(.is-empty), .toolbar:has(.quick-reply-bar:empty) { display: none; }
.quick-reply-bar { display: flex; overflow: auto; gap: 7px; margin-bottom: 10px; }
.quick-reply-chip { flex-shrink: 0; max-width: 250px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: #486477; font-size: 12px; }
.login-overlay, .settings-overlay { position: fixed; inset: 0; z-index: 100; background: #26394c40; display: grid; place-items: center; padding: 20px; }
.login-overlay { background: #f4f7fa; z-index: 110; overflow: auto; }
.login-card, .settings-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 16px 55px #24354514; }
.login-card { width: min(400px, 100%); padding: 36px; }
.login-mark { width: 46px; height: 46px; font-size: 22px; margin-bottom: 14px; }
.section-eyebrow { color: var(--accent); font-size: 11px; letter-spacing: .08em; }
.login-card h1 { font-size: 24px; margin: 9px 0; }
.login-description { color: var(--muted); margin-bottom: 28px; font-size: 13px; }
.login-card label { display: grid; gap: 7px; margin-bottom: 16px; font-size: 12px; }
.login-card .primary-btn { width: 100%; margin-top: 7px; }
.error-text, .danger-item { color: #b53939; }
.settings-card { width: min(700px, 100%); max-height: calc(var(--app-height) - 40px); overflow: auto; padding: 28px; }
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.settings-head h2 { font-size: 22px; }
.brand-badge { display: none; }
.settings-tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 24px; gap: 6px; }
.settings-tabs button { padding: 12px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.settings-tabs button.active { color: var(--accent); border-color: var(--accent); }
.settings-section { min-height: 255px; }
.settings-section h3 { font-size: 16px; margin-bottom: 16px; }
.settings-section label { display: block; font-size: 12px; margin-bottom: 6px; }
.settings-section input:not([type=checkbox]), .settings-section textarea { width: 100%; margin-bottom: 14px; }
.settings-section textarea { resize: vertical; min-height: 100px; }
.settings-section button { margin-bottom: 8px; }
.settings-section .switch-line { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.switch-line input { width: 20px; height: 20px; accent-color: var(--accent); }
.tips-text { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 6px 0 16px; }
#telegramStatus { border-radius: 8px; background: #f0f6f8; padding: 12px; color: #466474; margin-bottom: 18px; font-size: 13px; }
.settings-feedback { color: var(--accent); font-size: 13px; margin-top: 12px; }
.relay-settings { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 20px; }
#telegramRelayStatus { color: var(--accent); font-size: 13px; margin-bottom: 10px; overflow-wrap: anywhere; }
.binding-instructions { padding: 14px; border: 1px solid #cce7e7; background: #f5fbfb; border-radius: 9px; margin-top: 10px; }
.binding-instructions a { font-weight: 600; }
#telegramBindingCommand { font-size: 12px; }
.quick-reply-editor { display: flex; align-items: baseline; gap: 8px; }
.quick-reply-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.quick-reply-item .ghost-btn { margin: 0; }
.floating-menu-root { position: fixed; inset: 0; z-index: 120; }
.floating-menu-backdrop { position: absolute; inset: 0; }
.floating-menu-panel { position: absolute; width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 8px 32px #24354524; }
.floating-menu-sheet { left: 50%; bottom: 20px; transform: translateX(-50%); }
.floating-menu-title { color: var(--muted); padding: 8px; font-size: 11px; }
.floating-menu-item { display: block; width: 100%; text-align: left; border-radius: 7px; padding: 10px; }
.floating-menu-item:hover { background: #f3f7f9; }
.client-page { padding: 24px; display: grid; place-items: center; }
.client-frame { width: min(860px, 100%); height: min(900px, calc(var(--app-height) - 48px)); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px #23324608; }
.client-frame .chat-panel { height: 100%; }
.service-avatar { color: var(--accent); background: var(--soft); }
.back-btn, .mobile-only, .mobile-overlay { display: none; }
* { scrollbar-width: thin; scrollbar-color: #cbd5df transparent; }
@media (max-width: 1100px) { .agent-frame { grid-template-columns: 285px minmax(0, 1fr); } .meta-summary-item:nth-child(3) { display: none; } }
@media (max-width: 768px) {
  .workspace-bar { height: 52px; padding: 0 14px; gap: 12px; }
  .workspace-caption, .version-label { display: none; }
  .agent-frame { height: calc(var(--app-height) - 52px); grid-template-columns: minmax(0, 1fr); }
  .contact-sidebar { position: fixed; inset: 0 auto 0 0; width: min(90vw, 360px); height: var(--app-height); z-index: 60; visibility: hidden; transform: translateX(-100%); transition: transform .18s ease; }
  .contact-sidebar.mobile-open { visibility: visible; transform: translateX(0); }
  .mobile-overlay { display: block; position: fixed; inset: 0; z-index: 50; background: #23324640; }
  .back-btn, .mobile-only { display: inline-block; }
  .mobile-only { margin-top: 20px; }
  .chat-header { min-height: 66px; padding: 12px 14px; }
  .chat-header-info strong { font-size: 14px; }
  .meta-summary { padding: 10px 14px; gap: 8px; }
  .meta-summary-item:nth-child(2), .meta-summary-item:nth-child(3) { display: none; }
  .meta-grid { grid-template-columns: 1fr 1fr; padding: 0 14px; }
  .note-editor { padding: 12px 14px; }
  .message-list { padding: 18px 14px; }
  .bubble-row { max-width: 88%; }
  .composer { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .composer-inline { gap: 7px; }
  input, textarea, select { font-size: 16px; }
  .composer-field textarea { font-size: 16px; }
  .send-btn { padding: 11px 12px; font-size: 13px; }
  .client-page { padding: 0; }
  .client-frame { width: 100%; height: var(--app-height); border: none; border-radius: 0; box-shadow: none; }
  .settings-overlay { padding: 10px; }
  .settings-card { padding: 20px 16px; max-height: calc(var(--app-height) - 20px); }
  .settings-tabs { gap: 0; overflow: auto; }
  .settings-tabs button { flex: 1; padding: 10px 6px; font-size: 12px; }
  .login-card { padding: 28px 24px; }
  .floating-menu-panel { left: 12px !important; right: 12px; width: auto; top: auto !important; bottom: 12px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
