:root {
  --bg: #1a1a2e; --bg-card: #16213e; --bg-hover: #1e2a4a;
  --border: rgba(255,255,255,0.08);
  --text: #e0e0e0; --text-dim: #7a7a9a;
  --accent: #ffc000; --accent-dim: rgba(255,192,0,0.15);
  --danger: #ff4757; --success: #2ed573; --info: #007aff;
  --logo-bg: transparent;
  --logo-border: transparent;
  --logo-shadow: none;
}
* { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; background:var(--bg); color:var(--text); font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; font-size:14px; }
[x-cloak] { display:none !important; }
[data-pwd="1"] { -webkit-text-security: disc; }
[data-pwd="0"] { -webkit-text-security: none; }

/* ═══ Layout ═══ */
#app { display:flex; flex-direction:column; height:100vh; overflow:hidden; }
.app-header { display:flex; align-items:center; padding:0 16px; height:64px; flex-shrink:0; background:var(--bg-card); border-bottom:1px solid var(--border); gap:12px; z-index:100; }
.app-header .header-info { margin-left:auto; display:flex; align-items:center; gap:12px; font-size:12px; color:var(--text-dim); }
.header-theme-picker { position:relative; flex-shrink:0; }
.header-icon-btn { width:36px; height:36px; display:flex; align-items:center; justify-content:center; border:1px solid transparent; background:transparent; color:var(--text-dim); cursor:pointer; border-radius:8px; transition:.15s; }
.header-icon-btn:hover { background:var(--bg-hover); color:var(--accent); border-color:var(--border); }
.header-icon-btn svg { width:20px; height:20px; }
.theme-menu { position:absolute; top:calc(100% + 8px); right:0; background:var(--bg-card); border:1px solid var(--border); border-radius:8px; min-width:200px; padding:4px; box-shadow:0 4px 16px rgba(0,0,0,0.4); z-index:200; }
.theme-menu-title { font-size:11px; color:var(--text-dim); padding:6px 10px 4px; letter-spacing:0.5px; text-transform:uppercase; }
.theme-menu-item { width:100%; display:flex; align-items:center; gap:10px; padding:8px 10px; border:none; background:transparent; color:var(--text); cursor:pointer; border-radius:6px; font-size:13px; text-align:left; transition:.1s; }
.theme-menu-item:hover { background:var(--bg-hover); }
.theme-menu-item.active { background:var(--accent-dim); color:var(--accent); }
.theme-swatch { width:18px; height:18px; border-radius:50%; border:1px solid var(--border); flex-shrink:0; }
.swatch-Стандарт { background:#1a1a2e; }
.swatch-Стандарт-светлая { background:#f0f0f5; }
.swatch-Деловой { background:#1e1e1e; }
.swatch-Киберпанк { background:linear-gradient(135deg,#ffc000 0%,#0a0a0a 50%,#00ccff 100%); }
.theme-name { flex:1; }
.theme-check { color:var(--accent); font-weight:700; }
.header-role-badge { position:relative; flex-shrink:0; width:36px; height:36px; display:flex; align-items:center; justify-content:center; border-radius:8px; cursor:default; transition:.15s; }
.header-role-badge svg { width:22px; height:22px; }
.header-role-badge.role-super { color:#ffc000; background:rgba(255,192,0,0.1); border:1px solid rgba(255,192,0,0.3); }
.header-role-badge.role-admin { color:#a0a0b0; background:var(--bg-hover); border:1px solid var(--border); }
.header-role-badge.role-super:hover { background:rgba(255,192,0,0.18); }
.role-letter { position:absolute; z-index:2; font-size:11px; font-weight:900; color:#0a0a0a; line-height:1; top:50%; left:50%; transform:translate(-50%,-50%); margin-top:5px; text-shadow:0 0 1px rgba(255,255,255,0.4); pointer-events:none; }
.app-body { display:flex; flex:1; min-height:0; height:calc(100vh - 1px); }

/* ═══ Sidebar ═══ */
.sidebar { width:90px; flex-shrink:0; display:flex; flex-direction:column; align-items:center; padding:8px 0; gap:4px; background:var(--bg-card); border-radius:12px; margin:15px; z-index:50; overflow:visible; align-self:stretch; }
.sidebar-btn { width:40px; height:40px; display:flex; flex-direction:column; align-items:center; justify-content:center; border:none; background:transparent; color:var(--text-dim); cursor:pointer; border-radius:8px; font-size:10px; gap:2px; transition:.15s; position:relative; }
.sidebar-btn:hover { background:var(--bg-hover); color:var(--text); }
.sidebar-btn.active { background:var(--accent-dim); color:var(--accent); }
.sidebar-btn svg { width:20px; height:20px; }
.sidebar-label { font-size:8px; letter-spacing:0.5px; margin-top:1px; }
.sidebar-logo { padding:10px 0 18px; display:flex; align-items:center; justify-content:center; }
body.theme-Стандарт-светлая .hex-dark { display:none !important; }
body.theme-Стандарт-светлая .hex-light { display:block !important; }
.sidebar-unread { position:absolute; top:2px; right:2px; width:16px; height:16px; border-radius:50%; background:var(--danger); color:#fff; font-size:9px; display:flex; align-items:center; justify-content:center; }

.sidebar-gear-wrap { /* margin-top:auto; */ padding:4px 0; position:relative; }

.sidebar-dropdown { position:fixed; bottom:52px; left:52px; background:var(--bg-card); border:1px solid var(--border); border-radius:8px; min-width:200px; z-index:200; padding:4px; box-shadow:0 4px 16px rgba(0,0,0,0.3); max-height:calc(100vh - 70px); overflow-y:auto; }
.sidebar-dropdown button { width:100%; text-align:left; border:none; padding:6px 12px; }
.sidebar-dropdown hr { border-color:var(--border); margin:4px 0; }

/* ═══ Main ═══ */
.main-content { flex:1; display:flex; flex-direction:column; min-height:0; overflow:hidden; }
.tab-content { flex:1; display:flex; flex-direction:column; min-height:0; overflow:hidden; }

/* ═══ Chat ═══ */
.chat-body { display:flex; flex:1; min-height:0; overflow:hidden; }
.chat-threads-sidebar { width:220px; flex-shrink:0; display:flex; flex-direction:column;  background:var(--bg-card); border-radius:12px; margin:15px 15px 15px 0; }
.chat-threads-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; flex-shrink:0; }
.chat-threads-header h3 { font-size:13px; color:var(--text-dim); letter-spacing:1px; }
.chat-threads-list { flex:1; overflow-y:auto; padding:4px 0; }
.chat-thread-item { display:flex; align-items:center; padding:10px 16px; cursor:pointer; gap:8px; border-left:2px solid transparent; transition:.1s; }
.chat-thread-item:hover { background:var(--bg-hover); }
.chat-thread-item.active { background:var(--accent-dim); border-color:var(--accent); }
.chat-thread-title { flex:1; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-item-del { background:none; border:none; color:var(--text-dim); cursor:pointer; font-size:12px; padding:2px 4px; opacity:0; transition:.15s; }
.chat-thread-item:hover .chat-item-del, .chat-thread-item.active .chat-item-del { opacity:0.6; }
.chat-item-del:hover { opacity:1 !important; color:var(--danger); }

.chat-main { flex:1; display:flex; flex-direction:column; min-height:200px; position:relative; }
.chat-main-header { display:flex; align-items:center; justify-content:space-between; padding:8px 16px; flex-shrink:0; }
.chat-main-header h3 { font-size:14px; display:flex; align-items:center; gap:8px; flex:1; min-width:0; }
.chat-main-header .btns { display:flex; gap:4px; flex-shrink:0; }
.chat-header-prefix { flex-shrink:0; }
@keyframes thinkPulse { 0%,100% { opacity:0.5; } 50% { opacity:1; } }
.chat-thinking-indicator { color:var(--accent); animation:thinkPulse 1.5s ease-in-out infinite; }
.chat-header-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:224px; }

.chat-messages-wrap { flex:1; display:flex; min-height:0; position:relative; }
.chat-messages { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:8px; scroll-behavior:smooth; min-height:0; }

.message { max-width:80%; padding:10px 14px; border-radius:8px; font-size:13px; line-height:1.5; word-break:break-word; }
.message.user { align-self:flex-end; background:var(--accent-dim); border:1px solid rgba(255,192,0,0.2); border-bottom-right-radius:2px; }
.message.assistant { align-self:flex-start; background:var(--bg-card); border:1px solid var(--border); border-bottom-left-radius:2px; }
.msg-content p { margin:4px 0; }
.msg-content code { background:var(--bg); padding:2px 6px; border-radius:4px; font-size:12px; }
.msg-content pre { background:var(--bg); padding:12px; border-radius:6px; overflow-x:auto; margin:8px 0; }
.msg-time { font-size:10px; color:var(--text-dim); margin-top:4px; display:flex; gap:6px; align-items:center; }
.msg-actions { display:flex; gap:4px; margin-top:4px; }
.msg-action-btn { background:transparent; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; width:26px; height:26px; border-radius:4px; display:flex; align-items:center; justify-content:center; transition:.15s; }
.msg-action-btn:hover { border-color:var(--accent); color:var(--accent); }

.reminder-notif, .meeting-notif { align-self:center; background:rgba(0,122,255,0.1); border:1px solid rgba(0,122,255,0.2); border-radius:8px; padding:8px 12px; font-size:12px; display:flex; align-items:center; gap:8px; }
.doc-banner { display:flex; align-items:center; justify-content:space-between; padding:8px 14px; background:rgba(0,122,255,0.12); border-radius:8px; margin:6px 12px; font-size:13px; flex-shrink:0; }

/* ═══ Share (diary/calendar → user) ═══ */
.entry-share-btn { background:transparent; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; width:24px; height:24px; border-radius:4px; font-size:13px; margin-left:auto; flex-shrink:0; display:flex; align-items:center; justify-content:center; transition:.15s; }
.entry-share-btn:hover { border-color:var(--accent); color:var(--accent); background:var(--accent-dim); }
.share-user-item { background:var(--bg-card); border:1px solid var(--border); }
.share-user-item:hover { border-color:var(--accent); background:var(--accent-dim); }
.share-user-item.selected { border-color:var(--accent); background:var(--accent-dim); color:var(--accent); }
.cal-share-btn { background:transparent; border:none; color:var(--text-dim); cursor:pointer; font-size:11px; padding:0 2px; flex-shrink:0; opacity:0.6; transition:.15s; }
.cal-share-btn:hover { opacity:1; color:var(--accent); }

/* ═══ Shared With Me Tab ═══ */
.shared-content { flex:1; overflow-y:auto; padding:0 16px 16px; }
.shared-card { background:var(--bg-card); border:1px solid var(--border); border-radius:8px; padding:12px; margin-bottom:8px; }
.shared-card-header { display:flex; align-items:center; gap:6px; font-size:12px; margin-bottom:6px; }
.shared-card-body { font-size:13px; line-height:1.5; color:var(--text); padding:8px; background:var(--bg); border-radius:6px; margin:6px 0; word-break:break-word; white-space:pre-wrap; }
.shared-card-actions { display:flex; gap:6px; margin-top:8px; }
.doc-upload { padding:8px 16px; text-align:center; flex-shrink:0; }

.chat-input-wrap { flex:0 0 auto; display:block; min-height:90px; padding:12px 16px 16px; background:var(--bg); border-top:1px solid var(--border); }
.chat-input-wrap.has-doc { background:rgba(0,122,255,0.06); }
.chat-input-row { display:flex; gap:8px; align-items:flex-end; max-width:800px; margin:0 auto; background:var(--bg-card); border:1px solid var(--border); border-radius:16px; padding:8px 8px 8px 16px; box-shadow:0 2px 12px rgba(0,0,0,0.15); }
.chat-input-row:focus-within { border-color:var(--accent); }
.chat-input-row.doc-attached { border-color:var(--accent); background:rgba(0,122,255,0.04); }
.btn-show-more { background:var(--accent-dim); border:1px solid var(--accent); color:var(--accent); cursor:pointer; padding:6px 12px; border-radius:6px; font-size:12px; margin-top:6px; transition:.15s; }
.btn-show-more:hover { background:var(--accent); color:#fff; }
.chat-input-form { flex:1; display:flex; min-width:0; }
.chat-textarea { flex:1; background:transparent; border:none; color:var(--text); padding:8px 0; font-size:14px; outline:none; resize:none; font-family:inherit; line-height:1.5; min-height:54px; max-height:108px; width:100%; }
.chat-textarea::placeholder { color:var(--text-dim); }
.chat-textarea:disabled { opacity:0.5; }
.btn-send { padding:8px 20px; background:var(--accent); color:var(--bg); border:none; border-radius:10px; font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap; flex-shrink:0; align-self:flex-end; }
.btn-send:hover { opacity:0.85; }
.btn-send:disabled { opacity:0.4; cursor:not-allowed; }
.voice-btn { width:32px; height:32px; border-radius:50%; background:transparent; border:none; color:var(--text-dim); cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:.15s; align-self:flex-end; margin-bottom:4px; }
.voice-btn:hover { color:var(--accent); background:var(--bg-hover); }
.voice-btn.recording { color:var(--danger); animation:pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.scroll-down-btn { position:absolute; bottom:60px; right:20px; width:36px; height:36px; border-radius:50%; background:var(--accent); color:var(--bg); border:none; cursor:pointer; z-index:10; font-size:18px; display:flex; align-items:center; justify-content:center; box-shadow:0 2px 8px rgba(0,0,0,0.3); }

.chat-history-wrap { width:0; overflow:hidden; display:flex; flex-direction:column; border-left:1px solid var(--border); background:var(--bg-card); transition:width .2s; flex-shrink:0; }
.chat-history-wrap.open { width:320px; }
.chat-history-wrap .ch-header { display:flex; align-items:center; justify-content:space-between; padding:10px 16px; border-bottom:1px solid var(--border); flex-shrink:0; }
.chat-history-wrap .ch-header span { font-size:12px; color:var(--text-dim); letter-spacing:1px; }
.chat-history-list { flex:1; overflow-y:auto; padding:4px 0; }
.chat-history-item { display:flex; align-items:center; padding:8px 16px; cursor:pointer; gap:8px; border-left:2px solid transparent; transition:.1s; }
.chat-history-item:hover { background:var(--bg-hover); }
.chat-history-item.active { background:var(--accent-dim); border-color:var(--accent); }
.chat-history-item .h-role { font-size:10px; color:var(--accent); width:16px; font-weight:700; }
.chat-history-item .h-text { flex:1; font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-history-item .h-time { font-size:10px; color:var(--text-dim); }

.chat-empty { display:flex; align-items:center; justify-content:center; flex:1; color:var(--text-dim); flex-direction:column; gap:8px; }

/* ═══ Diary ═══ */
.diary-header { display:flex; align-items:center; justify-content:space-between; padding:16px; flex-shrink:0; }
.diary-header h2 { font-size:16px; }
.diary-filters { display:flex; gap:8px; padding:0 16px 12px; flex-wrap:wrap; flex-shrink:0; }
.diary-content { flex:1; overflow-y:auto; padding:0 16px 16px; }
.entry-card { background:var(--bg-card); border:1px solid var(--border); border-radius:8px; padding:12px 16px; margin-bottom:8px; cursor:pointer; transition:.15s; }
.entry-card:hover { border-color:var(--accent); }
.entry-title { font-size:14px; font-weight:500; }
.entry-preview { font-size:12px; color:var(--text-dim); margin-top:4px; line-height:1.4; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.entry-meta { font-size:11px; color:var(--text-dim); margin-top:4px; display:flex; gap:6px; align-items:center; }

/* ═══ Calendar ═══ */
.cal-grid { flex:1; display:flex; flex-direction:column; min-height:0; }
.cal-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; flex-shrink:0; }
.cal-header h3 { font-size:16px; }
.cal-weekdays { display:grid; grid-template-columns:repeat(7,1fr); text-align:center; font-size:11px; color:var(--text-dim); padding:4px 0; border-bottom:1px solid var(--border); flex-shrink:0; }
.cal-days { flex:1; display:grid; grid-template-columns:repeat(7,1fr); grid-template-rows:repeat(6,1fr); overflow:hidden; min-height:420px; }
.cal-day {  border-bottom:1px solid var(--border); padding:6px 8px; cursor:pointer; display:flex; flex-direction:column; gap:3px; transition:.1s; overflow:hidden; }
.cal-day:hover { background:var(--bg-hover); }
.cal-day.other { opacity:0.3; }
.cal-day.today { background:var(--accent-dim); }
.cal-day-num { font-weight:600; font-size:12px; padding:2px; }
.cal-event { font-size:10px; color:var(--bg); padding:1px 4px; border-radius:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; cursor:pointer; }
.cal-share-btn { background:transparent; border:none; color:var(--text-dim); cursor:pointer; font-size:11px; padding:0 2px; flex-shrink:0; opacity:0.6; transition:.15s; }
.cal-share-btn:hover { opacity:1; color:var(--accent); }
.cal-day-events { display:flex; flex-direction:column; gap:1px; margin-top:2px; overflow:hidden; }

/* Mini calendar */
.cal-mini { width:220px; flex-shrink:0;  display:flex; flex-direction:column; padding:8px; background:var(--bg-card); border-radius:12px; margin:15px 15px 15px 0; }
.cal-mini-header { display:flex; align-items:center; justify-content:space-between; padding:4px 0 8px; font-size:13px; font-weight:500; }
.cal-mini-arrow { background:none; border:none; color:var(--text-dim); cursor:pointer; padding:2px 6px; font-size:11px; }
.cal-mini-arrow:hover { color:var(--accent); }
.cal-mini-wd { display:grid; grid-template-columns:repeat(7,1fr); text-align:center; font-size:9px; color:var(--text-dim); padding:2px 0; }
.cal-mini-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; }
.cal-mini-day { text-align:center; padding:3px 0; font-size:11px; cursor:pointer; border-radius:50%; width:28px; height:28px; line-height:22px; margin:1px auto; position:relative; transition:.1s; }
.cal-mini-day:hover { background:var(--bg-hover); }
.cal-mini-day.other { opacity:0.3; }
.cal-mini-day.today { font-weight:700; border:1px solid var(--accent); }
.cal-mini-day.sel { background:var(--accent); color:var(--bg); font-weight:600; }
.cal-mini-dot { position:absolute; bottom:2px; left:50%; transform:translateX(-50%); width:4px; height:4px; border-radius:50%; background:var(--accent); }

/* Week view */
.cal-week-hdr { display:grid; grid-template-columns:50px repeat(7,1fr); border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--bg); z-index:2; }
.cal-week-hdr-day { text-align:center; padding:4px 0; cursor:pointer; }
.cal-week-hdr-wd { font-size:10px; color:var(--text-dim); }
.cal-week-hdr-num { font-size:14px; font-weight:600; border-radius:50%; width:28px; height:28px; line-height:28px; margin:2px auto; }
.cal-week-hdr-num.today { background:var(--accent); color:var(--bg); }
.cal-week-body { display:grid; grid-template-columns:50px repeat(7,1fr); }
.cal-week-times { display:contents; }
.cal-week-time { font-size:10px; color:var(--text-dim); padding:2px 4px; border-top:1px solid var(--border); height:48px; text-align:right; }
.cal-week-cols { display:contents; }
.cal-week-col { display:contents; position:relative; }
.cal-week-ev { font-size:10px; padding:1px 4px; border-radius:3px; cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--bg); margin:1px; z-index:1; }
.cal-week-slot { border-top:1px solid var(--border); height:48px; }

/* Year view */
.cal-year-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.cal-year-month { text-align:center; cursor:pointer; padding:6px; border-radius:8px; transition:.1s; }
.cal-year-month:hover { background:var(--bg-hover); }
.cal-year-mn { font-size:12px; font-weight:500; margin-bottom:4px; }
.cal-year-days { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; font-size:9px; }
.cal-year-d { border-radius:50%; padding:1px; }
.cal-year-d.has { background:var(--accent); color:var(--bg); font-weight:600; }

/* ═══ Messenger ═══ */
.msg-layout { display:flex; flex:1; min-height:0; }
.msg-sidebar { width:300px; flex-shrink:0; display:flex; flex-direction:column;  background:var(--bg-card); border-radius:12px; margin:15px 15px 15px 0; }
.msg-sidebar-header { display:flex; align-items:center; padding:12px 16px; gap:8px; border-bottom:1px solid var(--border); }
.msg-sidebar-header input { flex:1; background:var(--bg); border:1px solid var(--border); color:var(--text); padding:8px 12px; border-radius:6px; font-size:12px; outline:none; }
.msg-chat-list { flex:1; overflow-y:auto; }
.msg-chat-item { display:flex; align-items:center; padding:10px 16px; cursor:pointer; gap:10px; border-left:2px solid transparent; transition:.1s; }
.msg-chat-item:hover { background:var(--bg-hover); }
.msg-chat-item.active { background:var(--accent-dim); border-color:var(--accent); }
.msg-avatar { width:40px; height:40px; border-radius:50%; background:var(--bg-hover); display:flex; align-items:center; justify-content:center; font-size:16px; flex-shrink:0; position:relative; overflow:hidden; }
.msg-avatar .dot { position:absolute; bottom:0; right:0; width:12px; height:12px; border-radius:50%; border:2px solid var(--bg-card); }
.msg-avatar .dot.on { background:var(--success); }
.msg-avatar.notes { background:var(--accent-dim); color:var(--accent); }
.msg-avatar img.avatar-img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.msg-ci { flex:1; min-width:0; }
.msg-ci-name { font-size:13px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.msg-ci-preview { font-size:11px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.msg-unread { background:var(--accent); color:var(--bg); font-size:10px; padding:2px 6px; border-radius:10px; flex-shrink:0; }

.msg-main { flex:1; display:flex; flex-direction:column; min-height:0; position:relative; }
.msg-main-header { display:flex; align-items:center; padding:8px 16px; border-bottom:1px solid var(--border); gap:10px; flex-shrink:0; }
.msg-main-header .av { width:34px; height:34px; border-radius:50%; background:var(--bg-hover); display:flex; align-items:center; justify-content:center; flex-shrink:0; overflow:hidden; }
.msg-main-header .nm { font-weight:500; }
.msg-main-header .st { font-size:11px; color:var(--text-dim); }
.msg-bubbles { flex:1; overflow-y:auto; padding:16px; padding-bottom:70px; display:flex; flex-direction:column; min-height:0; position:relative; }
.msg-bubble { max-width:70%; padding:8px 12px; border-radius:12px; font-size:13px; line-height:1.4; margin-top:4px; }
.msg-bubbles .msg-bubble:first-of-type { margin-top:0; }
.msg-bubble.own { align-self:flex-end; background:var(--accent-dim); border:1px solid rgba(255,192,0,0.2); border-bottom-right-radius:2px; }
.msg-bubble.them { align-self:flex-start; background:var(--bg-card); border:1px solid var(--border); border-bottom-left-radius:2px; }
.msg-bubble.grouped { margin-top:2px; }
.msg-bubble.grouped.own { border-top-right-radius:2px; }
.msg-bubble.grouped.them { border-top-left-radius:2px; }
.msg-reply-preview { font-size:11px; color:var(--text); padding:4px 8px; margin-bottom:4px; border-left:3px solid var(--accent); border-radius:0 4px 4px 0; background:rgba(255,255,255,0.03); cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; transition:.1s; display:block; width:100%; text-align:left; border:none; font-family:inherit; line-height:1.3; }
.msg-reply-preview:hover { background:rgba(255,255,255,0.06); }
.msg-bubble.own .msg-reply-preview { border-left-color:var(--accent); }
.date-separator { display:flex; align-items:center; justify-content:center; margin:8px 0; }
.date-separator span { font-size:11px; color:var(--text-dim); background:var(--bg-card); padding:2px 12px; border-radius:10px; border:1px solid var(--border); }
.msg-bubble .b-time { font-size:9px; color:var(--text-dim); margin-top:2px; gap:2px; display:flex; align-items:center; }
.msg-bubble.own .b-time { justify-content:flex-end; }
.doc-fragment-badge { display:inline-block; font-size:10px; padding:1px 6px; margin:0 2px; border-radius:8px; background:rgba(0,113,227,0.15); color:var(--accent); border:1px solid rgba(0,113,227,0.3); vertical-align:middle; font-weight:500; }
.msg-bubble.them .b-time { justify-content:flex-start; }
.msg-actions-row { display:flex; align-items:center; gap:4px; margin-top:2px; }
.msg-bubble.own .msg-actions-row { flex-direction:row-reverse; }
.msg-msg-actions { display:flex; gap:2px; }
.msg-act-btn { background:transparent; border:none; color:var(--text-dim); cursor:pointer; font-size:11px; padding:1px 3px; border-radius:3px; line-height:1; transition:.1s; }
.msg-act-btn:hover { background:var(--bg-hover); color:var(--accent); }
.msg-reply-bar { display:flex; align-items:center; padding:6px 12px; background:var(--bg-card); border-top:2px solid var(--accent); border-left:1px solid var(--border);  margin:0; gap:8px; flex-shrink:0; }
.msg-empty { display:flex; align-items:center; justify-content:center; flex:1; color:var(--text-dim); }
.emoji-picker { position:absolute; bottom:44px; left:0; background:var(--bg-card); border:1px solid var(--border); border-radius:12px; padding:8px; width:320px; max-height:240px; overflow-y:auto; display:flex; flex-wrap:wrap; gap:4px; z-index:100; box-shadow:0 4px 24px rgba(0,0,0,0.3); }
.emoji-picker::-webkit-scrollbar { width:4px; }
.emoji-picker::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
.emoji-picker button { font-size:22px; width:36px; height:36px; display:flex; align-items:center; justify-content:center; border:none; background:transparent; cursor:pointer; border-radius:6px; padding:0; transition:.1s; }
.emoji-picker button:hover { background:var(--bg-hover); }
.msg-search-bar { display:flex; align-items:center; padding:6px 12px; background:var(--bg-card); border-bottom:1px solid var(--border); gap:8px; flex-shrink:0; }

/* ═══ Auth ═══ */
.auth-screen { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:var(--bg); z-index:1000; }
.auth-box { background:var(--bg-card); border:1px solid var(--border); border-radius:12px; padding:32px; width:360px; max-width:90vw; }
.auth-box h1 { text-align:center; font-size:18px; color:var(--accent); margin-bottom:24px; letter-spacing:2px; text-transform:uppercase; border-bottom:1px solid var(--border); padding-bottom:16px; }
.tabs { display:flex; border-bottom:1px solid var(--border); margin-bottom:20px; }
.tabs button { flex:1; padding:10px; background:transparent; border:none; color:var(--text-dim); cursor:pointer; font-size:13px; text-transform:uppercase; letter-spacing:1px; border-bottom:2px solid transparent; margin-bottom:-1px; transition:.15s; }
.tabs button.active { color:var(--accent); border-color:var(--accent); }
.auth-box form { display:flex; flex-direction:column; gap:12px; }
.password-field { position:relative; }
.password-field input { width:100%; background:var(--bg); border:1px solid var(--border); color:var(--text); padding:10px 14px; border-radius:6px; font-size:14px; outline:none; }
.password-field input:focus { border-color:var(--accent); }
.eye-toggle { position:absolute; right:10px; top:50%; transform:translateY(-50%); background:none; border:none; color:var(--text-dim); cursor:pointer; display:flex; align-items:center; padding:4px; }
.invite-field input { width:100%; background:var(--bg); border:1px solid var(--border); color:var(--text); padding:10px 14px; border-radius:6px; font-size:14px; outline:none; }
.invite-field input:focus { border-color:var(--accent); }
.remember-me { display:flex; align-items:center; }
.remember-me label { display:flex; align-items:center; gap:8px; cursor:pointer; font-size:12px; color:var(--text-dim); }
.remember-me input[type="checkbox"] { width:auto; }
.auth-box .error { color:var(--danger); font-size:12px; text-align:center; margin-top:8px; }
.copyright { text-align:center; margin-top:16px; padding-top:16px; border-top:1px solid var(--border); }
.copyright a { color:var(--text-dim); font-size:11px; text-decoration:none; }
.copyright a:hover { color:var(--accent); }
.setup-overlay { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:var(--bg); z-index:1001; }
.setup-box { background:var(--bg-card); border:1px solid var(--border); border-radius:12px; padding:32px; width:360px; max-width:90vw; }
.setup-box h1 { font-size:18px; color:var(--accent); margin-bottom:8px; }
.setup-box h2 { font-size:18px; color:var(--accent); margin-bottom:8px; }
.setup-box form { display:flex; flex-direction:column; gap:8px; }
.setup-row { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.setup-input { width:100%; background:var(--bg); border:1px solid var(--border); color:var(--text); padding:8px 12px; border-radius:6px; font-size:13px; outline:none; }
.setup-input:focus { border-color:var(--accent); }
.setup-seed-box { background:var(--bg); border:1px solid rgba(255,68,68,0.2); border-radius:8px; padding:12px; margin:8px 0; }
.setup-seed-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.setup-seed-words { display:flex; flex-wrap:wrap; gap:4px; margin-bottom:8px; }
.setup-seed-word { background:var(--bg-card); border:1px solid var(--border); border-radius:4px; padding:3px 8px; font-size:12px; font-family:monospace; color:var(--accent); }
.setup-seed-warning { font-size:11px; color:#ff4444; text-align:center; }
.setup-buttons { display:flex; gap:8px; justify-content:flex-end; margin-top:12px; }

/* ═══ Inputs ═══ */
input, select, textarea { background:var(--bg); border:1px solid var(--border); color:var(--text); padding:8px 12px; border-radius:6px; font-size:13px; outline:none; transition:.15s; }
input:focus, select:focus, textarea:focus { border-color:var(--accent); }
textarea { resize:vertical; font-family:inherit; }
label { font-size:12px; color:var(--text-dim); margin-bottom:4px; display:block; }

/* ═══ Buttons ═══ */
.btn { padding:8px 16px; border-radius:6px; border:1px solid var(--border); background:transparent; color:var(--text); cursor:pointer; font-size:13px; transition:.15s; white-space:nowrap; display:inline-flex; align-items:center; gap:4px; }
.btn:hover { border-color:var(--accent); color:var(--accent); }
.btn:disabled { opacity:0.4; cursor:not-allowed; }
.btn-primary { background:var(--accent); color:var(--bg); border:1px solid var(--accent); font-weight:600; }
.btn-primary:hover { opacity:0.85; background:var(--accent); }
.btn-danger { color:var(--danger); } .btn-danger:hover { color:#ff6b6b; background:transparent; border-color:var(--danger); }
.btn-small { padding:4px 10px; font-size:11px; }
.btn-icon { background:transparent; border:1px solid var(--border); color:var(--text-dim); cursor:pointer; width:30px; height:30px; border-radius:6px; display:inline-flex; align-items:center; justify-content:center; transition:.15s; font-size:14px; }
.btn-icon:hover { border-color:var(--accent); color:var(--accent); }
.btn-icon.active { background:var(--accent-dim); border-color:var(--accent); color:var(--accent); }

/* ═══ Modals ═══ */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; z-index:999; }
.modal-box { background:var(--bg-card); border:1px solid var(--border); border-radius:12px; padding:24px; width:480px; max-width:90vw; max-height:80vh; overflow-y:auto; }
.modal-box h2 { font-size:16px; margin-bottom:16px; }
.modal-box input, .modal-box select, .modal-box textarea { width:100%; margin-bottom:8px; }
.modal-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:16px; }

/* ═══ Settings tabs ═══ */
.stab { padding:16px; overflow-y:auto; display:flex; flex-direction:column; gap:12px; }
.stab h2 { font-size:16px; }
.card { background:var(--bg-card); border:1px solid var(--border); border-radius:8px; padding:16px; }
.card h3 { margin-bottom:12px; font-size:14px; }
.card label { display:block; }
.card .flex { display:flex; align-items:center; gap:8px; }
.card input, .card select { background:var(--bg); }

/* ═══ Preprocessing LLM card ═══ */
.preprocess-card { border-left:3px solid var(--info); }
.preprocess-card .preprocess-row { display:flex; gap:8px; align-items:flex-end; flex-wrap:wrap; }
.preprocess-card .preprocess-row > * { flex:1; min-width:120px; }
.preprocess-card .preprocess-label { font-size:11px; color:var(--text-dim); display:block; margin-bottom:2px; }
.preprocess-card .preprocess-input, .preprocess-card .preprocess-select { width:100%; padding:6px 8px; background:var(--bg-card); border:1px solid var(--border); border-radius:4px; color:var(--text); font-size:13px; }
.preprocess-card .preprocess-hint { font-size:10px; color:var(--text-dim); margin-top:2px; }
.preprocess-card .preprocess-test-result { margin-top:6px; padding:6px 8px; background:var(--bg); border-radius:4px; font-size:11px; }

.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }

/* ═══ Loading ═══ */
.loading-screen { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:var(--bg); z-index:2000; flex-direction:column; gap:16px; }
.spinner { width:32px; height:32px; border:3px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite; }
.spinner.small { width:14px; height:14px; border-width:2px; display:inline-block; vertical-align:middle; }
@keyframes spin { to { transform:rotate(360deg); } }
.doc-preloader { display:flex; align-items:center; gap:8px; padding:8px 12px; color:var(--text-dim); font-size:13px; font-style:italic; }
.doc-preloader .step { display:inline-block; }

/* ═══ Badges ═══ */
.badge { padding:1px 6px; border-radius:4px; font-size:10px; display:inline-block; }
.badge.work { background:rgba(0,122,255,0.15); color:#5ac8fa; }
.badge.personal { background:rgba(255,192,0,0.15); color:var(--accent); }

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:var(--text-dim); }

/* ═══ Responsive ═══ */
@media (max-width:768px) {
  .sidebar { flex-direction:row; width:100%; height:52px; border-right:none; border-top:1px solid var(--border); position:fixed; bottom:0; left:0; padding:0 8px; gap:0; overflow-x:auto; overflow-y:hidden; z-index:100; justify-content:space-evenly; margin:0; border-radius:0; }
  .sidebar-btn { width:44px; height:44px; flex-shrink:0; }
  .sidebar-logo { padding:0; width:40px; }
  .sidebar-mobile-hide { display:none !important; }
  .app-body { flex-direction:column-reverse; }
  .main-content { padding-bottom:52px; }
  .chat-body { flex-direction:column; }
  .chat-threads-sidebar { position:fixed; left:0; top:64px; bottom:52px; width:0; overflow:hidden; z-index:90; transition:width .25s; border-right:none; box-shadow:4px 0 16px rgba(0,0,0,0.3); margin:0; border-radius:0; }
  .chat-threads-sidebar.open { width:260px; }
  .chat-threads-sidebar .chat-threads-header .sidebar-close { display:inline-flex; }
  .chat-history-wrap.open { position:fixed; right:0; top:64px; bottom:52px; width:280px; border-radius:8px 0 0 8px; box-shadow:-4px 0 16px rgba(0,0,0,0.3); }
  .chat-history-wrap:not(.open) { height:0; min-height:0; }
  .msg-layout { flex-direction:column; }
  .msg-sidebar { width:100%; flex:2; min-height:0; margin:0; border-radius:0; }
  .msg-sidebar.mobile-hide { display:none; }
  .msg-main { flex:1; }
  .chat-input-wrap { padding-bottom: calc(16px + 52px); }
  .msg-bubbles { padding-bottom: calc(70px + 52px); }
  .cal-day { min-height:50px; }
  .cal-mini { display:none; }
  .cal-year-grid { grid-template-columns:repeat(2,1fr); }
  .message { max-width:90%; }
  .grid-2 { grid-template-columns:1fr; }
  .auth-box { margin:16px; }
  .chat-header-title { max-width:192px; }
}

@media (min-width:769px) {
  .chat-threads-sidebar .chat-threads-header .sidebar-close { display:none; }
  .menu-mobile-btn { display:none !important; }
  .mobile-only { display:none !important; }
}
@media (max-width:768px) {
  .mobile-only { display:inline-flex; }
}
@media (max-width:480px) {
  .app-header .header-info { gap:4px; }
  .app-header .header-info .geo { display:none; }
  .cal-day { min-height:30px; font-size:10px; }
}

/* ═══ Theme: Стандарт - светлая ═══ */
body.theme-Стандарт-светлая {
  --bg: #f0f0f5; --bg-card: #ffffff; --bg-hover: #e8e8f0;
  --border: rgba(0,0,0,0.1);
  --text: #1a1a2e; --text-dim: #6e6e7a;
  --accent: #0071e3; --accent-dim: rgba(0,113,227,0.12);
  --danger: #dc3545; --success: #28a745; --info: #007aff;
}

/* ═══ Theme: Деловой (minimal, no borders) ═══ */
body.theme-Деловой {
  --bg: #121212; --bg-card: #1e1e1e; --bg-hover: #2a2a2a;
  --border: transparent;
  --text: #f0f0f0; --text-dim: #888;
  --accent: #4a90d9; --accent-dim: rgba(74,144,217,0.15);
  --danger: #e53935; --success: #4caf50; --info: #4a90d9;
}

/* ═══ Theme: Киберпанк (Cyberpunk 2077) ═══ */
body.theme-Киберпанк {
  --bg: #0a0a0a; --bg-card: rgba(255,255,255,0.05); --bg-hover: rgba(255,255,255,0.1);
  --border: #333;
  --text: #fff; --text-dim: #888;
  --accent: #ffc000; --accent-dim: rgba(255,196,0,0.2);
  --danger: #ff4444; --success: #00ff88; --info: #00ccff;
}
body.theme-Киберпанк {
  background:
    linear-gradient(rgba(255,196,0,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,196,0,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  background-color: #0a0a0a;
}
body.theme-Киберпанк::before {
  content:''; position:fixed; inset:0; z-index:9999; pointer-events:none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.03) 2px, rgba(255,255,255,0.03) 4px);
  animation: scanlineScroll 8s linear infinite;
}
@keyframes scanlineScroll {
  from { background-position: 0 0; }
  to { background-position: 0 20px; }
}
body.theme-Киберпанк .sidebar-btn.active {
  box-shadow: 0 0 10px var(--accent), 0 0 20px rgba(255,196,0,0.3);
  border: 1px solid var(--accent);
}
body.theme-Киберпанк .btn-primary {
  background: var(--accent); color: #000; font-weight:700;
  box-shadow: 0 0 8px rgba(255,196,0,0.4);
  border: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}
body.theme-Киберпанк .card {
  border: 1px solid rgba(255,196,0,0.15);
  box-shadow: 0 0 4px rgba(255,196,0,0.05);
}
body.theme-Киберпанк input, body.theme-Киберпанк textarea, body.theme-Киберпанк select {
  border: 1px solid rgba(255,196,0,0.2);
  background: rgba(0,0,0,0.4);
  color: #fff;
}
body.theme-Киберпанк input:focus, body.theme-Киберпанк textarea:focus, body.theme-Киберпанк select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(255,196,0,0.3);
  outline: none;
}
body.theme-Киберпанк .app-header {
  border-bottom: 1px solid rgba(255,196,0,0.15);
  box-shadow: 0 1px 8px rgba(255,196,0,0.08);
}
body.theme-Киберпанк .sidebar {
  border-right: 1px solid rgba(255,196,0,0.15);
}
body.theme-Киберпанк .modal-overlay {
  backdrop-filter: blur(4px);
}
body.theme-Киберпанк .modal-box {
  border: 1px solid var(--accent);
  box-shadow: 0 0 20px rgba(255,196,0,0.15);
}
body.theme-Киберпанк h2, body.theme-Киберпанк h3 {
  text-transform: uppercase;
  letter-spacing: 2px;
}
body.theme-Киберпанк .msg-bubble.own {
  border: 1px solid rgba(255,196,0,0.3);
  box-shadow: 0 0 6px rgba(255,196,0,0.1);
}
body.theme-Киберпанк .btn {
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}
body.theme-Киберпанк ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
body.theme-Киберпанк ::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.3);
}
body.theme-Киберпанк ::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}
@keyframes neonPulse {
  0%, 100% { text-shadow: 0 0 8px rgba(255,196,0,0.4); }
  50% { text-shadow: 0 0 16px rgba(255,196,0,0.8), 0 0 24px rgba(255,196,0,0.3); }
}

/* ═══ Logo ═══
   Базовая структура:
     .logo-container — обёртка (фон задаётся через --logo-bg или утилитные классы)
     .logo           — сам <img>
   Утилитные классы фона:
     .logo-bg-none      — без фона (прозрачно)
     .logo-bg-card      — сплошной цвет карточки (var(--bg-card))
     .logo-bg-glow      — мягкое свечение accent-цветом
     .logo-bg-gradient  — диагональный градиент accent → bg-card
     .logo-bg-radial    — радиальный градиент (центрированное свечение)
*/
.logo-container {
  text-align:center;
  margin-bottom:16px;
  padding:20px;
  border-radius:12px;
  background: var(--logo-bg, transparent);
  border: 1px solid var(--logo-border, transparent);
  box-shadow: var(--logo-shadow, none);
  transition: background .3s, box-shadow .3s, border-color .3s;
}
.logo-container.logo-bg-none { background:transparent; border-color:transparent; box-shadow:none; }
.logo-container.logo-bg-card { --logo-bg: var(--bg-card); --logo-border: var(--border); }
.logo-container.logo-bg-glow { --logo-bg: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%); --logo-shadow: 0 0 24px var(--accent-dim); }
.logo-container.logo-bg-gradient { --logo-bg: linear-gradient(135deg, var(--accent-dim) 0%, var(--bg-card) 100%); --logo-border: var(--border); }
.logo-container.logo-bg-radial { --logo-bg: radial-gradient(circle at center, var(--accent) 0%, var(--bg-card) 70%); --logo-border: var(--accent); --logo-shadow: 0 0 30px var(--accent-dim); }

.logo { display:block; max-width:100%; height:auto; }
.logo-auth { width:280px; margin:0 auto; }
.logo-header { height:70px; width:auto; flex-shrink:0; top:15px; position:relative; }
.logo-as-bg { background-image:url('/static/logo.svg'); background-repeat:no-repeat; background-position:center; background-size:contain; }
.logo-as-bg.logo-as-bg-sm { background-size:60px auto; }
.logo-as-bg.logo-as-bg-lg { background-size:280px auto; }

/* Тема: Киберпанк — неоновая пульсация логотипа в шапке */
body.theme-Киберпанк .app-header .logo {
  text-shadow: 0 0 10px rgba(255,196,0,0.5);
  animation: neonPulse 3s ease-in-out infinite;
}

/* Тема: Стандарт-светлая — логотип с тёплым радиальным свечением */
body.theme-Стандарт-светлая .logo-container:not(.logo-bg-none) {
  --logo-bg: radial-gradient(circle at 50% 50%, rgba(0,113,227,0.08) 0%, transparent 70%);
  --logo-border: rgba(0,113,227,0.15);
}

/* Тема: Деловой — минималистичный фон карточки */
body.theme-Деловой .logo-container:not(.logo-bg-none) {
  --logo-bg: var(--bg-hover);
  --logo-border: transparent;
}

/* Тема: Киберпанк — неоновое радиальное свечение под лого */
body.theme-Киберпанк .logo-container:not(.logo-bg-none) {
  --logo-bg: radial-gradient(circle, rgba(255,196,0,0.15) 0%, transparent 70%);
  --logo-border: rgba(255,196,0,0.4);
  --logo-shadow: 0 0 20px rgba(255,196,0,0.2), inset 0 0 20px rgba(255,196,0,0.05);
}

/* Setup page */
.setup-box h2 { font-size:18px; color:var(--accent); margin-bottom:8px; }
.setup-box form { display:flex; flex-direction:column; gap:8px; }
.setup-row { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.setup-input { width:100%; background:var(--bg); border:1px solid var(--border); color:var(--text); padding:8px 12px; border-radius:6px; font-size:13px; outline:none; }
.setup-input:focus { border-color:var(--accent); }
.setup-seed-box { background:var(--bg); border:1px solid rgba(255,68,68,0.2); border-radius:8px; padding:12px; margin:8px 0; }
.setup-seed-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.setup-seed-words { display:flex; flex-wrap:wrap; gap:4px; margin-bottom:8px; }
.setup-seed-word { background:var(--bg-card); border:1px solid var(--border); border-radius:4px; padding:3px 8px; font-size:12px; font-family:monospace; color:var(--accent); }
.setup-seed-warning { font-size:11px; color:#ff4444; text-align:center; }
.setup-buttons { display:flex; gap:8px; justify-content:flex-end; margin-top:12px; }

/* ═══ Toast notifications ═══ */
@keyframes toastIn {
  from { opacity:0; transform:translateX(-20px); }
  to { opacity:1; transform:translateX(0); }
}
@keyframes toastOut {
  from { opacity:1; transform:translateX(0); }
  to { opacity:0; transform:translateX(-20px); }
}
@media (max-width:768px) {
  [x-show="toasts.length>0"] { left:10% !important; width:80% !important; max-width:80% !important; }
}

/* Landscape mobile — bottom bar like portrait */
@media (max-height:520px) {
  .sidebar { flex-direction:row; width:100%; height:52px; border-right:none; border-top:1px solid var(--border); position:fixed; bottom:0; left:0; padding:0 8px; gap:0; overflow-x:auto; overflow-y:hidden; z-index:100; justify-content:space-evenly; margin:0; border-radius:0; }
  .sidebar-btn { width:44px; height:44px; flex-shrink:0; }
  .sidebar-logo { padding:0; width:40px; }
  .sidebar-mobile-hide { display:none !important; }
  .app-body { flex-direction:column-reverse; }
  .main-content { padding-bottom:52px; }
  .chat-body { flex-direction:column; }
  .chat-input-wrap { padding-bottom: calc(16px + 52px); }
  .msg-bubbles { padding-bottom: calc(70px + 52px); }
  .msg-layout { flex-direction:column; }
  .msg-sidebar { width:100%; flex:2; min-height:0; margin:0; border-radius:0; }
   .msg-sidebar.mobile-hide { display:none; }
  .msg-main { flex:1; }
  .chat-threads-sidebar { position:fixed; left:0; top:64px; bottom:52px; width:0; overflow:hidden; z-index:90; transition:width .25s; border-right:none; box-shadow:4px 0 16px rgba(0,0,0,0.3); margin:0; border-radius:0; }
  .chat-threads-sidebar.open { width:260px; }
  .chat-threads-sidebar .chat-threads-header .sidebar-close { display:inline-flex; }
  .chat-history-wrap.open { position:fixed; right:0; top:64px; bottom:52px; width:280px; border-radius:8px 0 0 8px; box-shadow:-4px 0 16px rgba(0,0,0,0.3); }
  .chat-history-wrap:not(.open) { height:0; min-height:0; }
  .cal-day { min-height:50px; }
  .cal-mini { display:none; }
  .cal-year-grid { grid-template-columns:repeat(2,1fr); }
  .message { max-width:90%; }
  .grid-2 { grid-template-columns:1fr; }
  .auth-box { margin:16px; }
  .chat-header-title { max-width:192px; }
  .mobile-only { display:inline-flex !important; }
  .menu-mobile-btn { display:inline-flex !important; }
}

/* ═══ Billing ═══ */
.billing-table-wrap { overflow-x:auto; }
.billing-table { width:100%; border-collapse:collapse; font-size:13px; }
.billing-table th { text-align:left; padding:6px 10px; border-bottom:2px solid var(--border); color:var(--text-dim); font-size:11px; cursor:pointer; user-select:none; white-space:nowrap; }
.billing-table th:hover { color:var(--accent); }
.billing-table th.sorted { color:var(--accent); }
.billing-table td { padding:5px 10px; border-bottom:1px solid var(--border); }
.billing-table tbody tr:hover { background:var(--bg-hover); }
