:root {
  --bg-primary: #09090b;
  --bg-secondary: #121215;
  --bg-tertiary: #1a1a1e;
  --bg-input: #202025;
  --text-primary: #f8f9fa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #1a5eff;
  --accent-hover: color-mix(in srgb, var(--accent) 82%, white);
  --accent-light: color-mix(in srgb, var(--accent) 18%, transparent);
  --danger: #ef4444;
  --border: #26262a;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 300px;
}

:root[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-input: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.01em;
}

body.font-small {
  font-size: 0.85rem;
}
body.font-small .msg-bubble {
  font-size: 0.85rem;
  padding: 8px 12px;
}

body.font-large {
  font-size: 1.05rem;
}
body.font-large .msg-bubble {
  font-size: 1.05rem;
  padding: 12px 16px;
}

.lucide {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  stroke-width: 2;
  flex-shrink: 0;
}

/* Формы, Инпуты, Селекты */
label {
  display: block;
  width: 100%;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input, select, textarea {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border) !important;
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none !important;
  box-sizing: border-box;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-light) !important;
  background-color: var(--bg-input) !important;
}

input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus {
  background-color: var(--bg-input) !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  transition: background-color 5000s ease-in-out 0s;
}

textarea {
  resize: vertical;
  min-height: 75px;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  padding-right: 36px !important;
}

select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.form-col {
  min-width: 0;
}

.account-edit-box {
  margin-top: 12px;
  background: var(--bg-secondary);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Shimmer Скелетон */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-input) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}
.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}
.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.skeleton-line {
  height: 12px;
  border-radius: 6px;
}
.skeleton-line.short { width: 45%; }
.skeleton-line.long { width: 80%; }

/* Боковое меню (Sidebar) */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  z-index: 150;
  transition: transform var(--transition);
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 140;
  display: none;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sidebar-backdrop.active {
  display: block;
}
.sidebar-header {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.sidebar-header .logo {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.search-wrap {
  padding: 10px 12px;
  display: flex;
  gap: 6px;
}
.search-wrap input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.characters-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.characters-list::-webkit-scrollbar {
  width: 4px;
}
.characters-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}
.char-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.char-item:hover {
  background: var(--bg-tertiary);
}
.char-item.active {
  background: var(--accent-light);
  box-shadow: inset 3px 0 0 var(--accent);
}
.char-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}
.char-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.char-avatar svg {
  width: 24px !important;
  height: 24px !important;
  color: var(--text-secondary);
}
.char-info {
  flex: 1;
  min-width: 0;
}
.char-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.char-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: var(--transition);
  flex-shrink: 0;
}
.char-item:hover .char-actions {
  opacity: 1;
}
.char-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 5px;
  border-radius: 6px;
  transition: var(--transition);
}
.char-action-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}
.char-action-btn.delete:hover {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}

/* Главная область и Вкладки (Tabs) */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-primary);
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.tab-view {
  display: none;
  flex: 1;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}
.tab-view.active {
  display: flex;
}
.tab-view-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-primary);
  flex-shrink: 0;
}
.tab-view-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-view-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 120px;
  max-width: 650px;
  margin: 0 auto;
  width: 100%;
}

/* Шапка чата */
.chat-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-primary);
  flex-shrink: 0;
  height: 62px;
  z-index: 1000 !important;
  overflow: visible !important;
}
.chat-header .current-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-header .current-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.chat-header .current-avatar svg {
  width: 22px !important;
  height: 22px !important;
}
.header-titles {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  overflow: hidden;
}
.chat-header .current-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-header .current-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-right-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}
.chat-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.chat-search-wrap input {
  display: none;
  position: absolute;
  right: 34px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.8rem;
  width: 150px;
  outline: none;
}
.chat-search-wrap.open input {
  display: block;
}
.btn-header-menu, .icon-btn-ghost {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-header-menu:hover, .icon-btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.btn-header-menu.active {
  color: var(--accent);
}
.header-menu-wrap {
  position: relative;
  z-index: 1005 !important;
}

/* Выпадающее меню с опциями */
.header-dropdown {
  position: absolute;
  top: 44px;
  right: 0;
  background: rgba(20, 20, 24, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.85);
  min-width: 240px;
  z-index: 99999 !important;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
:root[data-theme="light"] .header-dropdown {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.header-dropdown.open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}
.header-dropdown button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 11px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  white-space: nowrap;
}
.header-dropdown button:hover {
  background: var(--bg-tertiary);
}
.header-dropdown button.danger {
  color: var(--danger);
}
.header-dropdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3px 0;
}

/* Лента закрепленных сообщений */
.pinned-ribbon {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--text-secondary);
  z-index: 15;
}
.pinned-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}
.pinned-chip:hover {
  background: var(--bg-input);
  border-color: var(--accent);
  color: var(--text-primary);
}

@keyframes msgPulseHighlight {
  0% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.message-container.highlight-pulse .msg-bubble {
  animation: msgPulseHighlight 1.5s ease-out;
}

/* Сообщения */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 10;
}
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.message-container {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: fadeIn 0.25s ease;
}
.message-container.user {
  align-self: flex-end;
  align-items: flex-end;
}
.message-container.assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.message {
  display: flex;
  gap: 8px;
  width: 100%;
}
.message-container.user .message {
  flex-direction: row-reverse;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  overflow: hidden;
  cursor: pointer;
}
.msg-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.msg-avatar svg {
  width: 16px !important;
  height: 16px !important;
}
.msg-content-wrapper {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 38px);
}
.msg-bubble {
  padding: 10px 15px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 0.92rem;
  word-break: break-word;
  white-space: pre-wrap;
}
.message-container.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message-container.assistant .msg-bubble {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.msg-bubble pre {
  background: rgba(0, 0, 0, 0.25);
  padding: 10px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.msg-bubble code {
  font-family: monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}
.msg-bubble strong {
  font-weight: 700;
}
.msg-bubble em, .rp-action {
  font-style: italic;
  color: color-mix(in srgb, var(--text-primary) 75%, var(--accent));
  opacity: 0.95;
}
.msg-quote {
  color: var(--accent);
  font-weight: 500;
}
.msg-bubble mark {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.msg-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 0 2px;
}
.message-container.user .msg-bottom-row {
  flex-direction: row-reverse;
}
.msg-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
}
.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: var(--transition);
}
.message-container:hover .msg-actions {
  opacity: 1;
}
.msg-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.msg-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* Свайпы ответов */
.msg-swipe-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.msg-swipe-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 10px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.msg-swipe-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Рейтинг */
.msg-rating {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding: 2px 4px;
  border-radius: 8px;
  background: var(--bg-input);
}
.msg-rating button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 2px;
  font-size: 0.75rem;
  line-height: 1;
  transition: color 0.15s;
}
.msg-rating button:hover, .msg-rating button.active {
  color: #f59e0b;
}

/* Индикатор набора */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 6px 2px;
}
.typing-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.3s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* Поле ввода сообщения */
.chat-input-area {
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  padding: 8px 16px 88px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  transition: padding-bottom 0.15s ease;
  z-index: 25;
}
.chat-input-row {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-wrap: nowrap;
  background: var(--bg-tertiary);
  border-radius: 24px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--border);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
  transition: var(--transition);
}
.chat-input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 3px 14px var(--accent-light);
}
.chat-input-area textarea {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  border: none !important;
  background: transparent !important;
  color: var(--text-primary) !important;
  resize: none;
  font-family: inherit;
  font-size: 0.92rem;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.45;
  outline: none !important;
  box-shadow: none !important;
}
.btn-attach {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-attach:hover {
  color: var(--text-primary);
  background: var(--bg-input);
}
.btn-attach.recording {
  color: var(--danger);
  animation: pulseRed 1.4s infinite;
}

@keyframes pulseRed {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-send:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}
.btn-send:active {
  transform: scale(0.96);
}
.btn-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.char-counter {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 8px;
  font-weight: 500;
}

/* Нижняя навигация Liquid Glass + Sliding Tab */
.glass-nav-container {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 900;
  align-items: center;
  transition: all var(--transition);
}
.glass-nav-pill {
  position: relative;
  display: flex;
  background: rgba(22, 22, 26, 0.78);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-radius: var(--radius-pill);
  padding: 5px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.09);
}
:root[data-theme="light"] .glass-nav-pill {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.glass-nav-indicator {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  background: var(--bg-input);
  border-radius: 20px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
  z-index: 1;
}

.nav-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  cursor: pointer;
  transition: color var(--transition);
  border-radius: 20px;
  gap: 2px;
}
.nav-item:hover {
  color: var(--text-primary);
}
.nav-item.active {
  color: var(--text-primary);
}
.nav-item .nav-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.glass-action-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c5cfc);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--accent-light);
  border: 2px solid rgba(255, 255, 255, 0.12);
  transition: all 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex-shrink: 0;
}
.glass-action-btn:hover {
  transform: scale(1.06);
}
.glass-action-btn:active {
  transform: scale(0.95);
}
.glass-action-btn .lucide {
  width: 22px;
  height: 22px;
  stroke-width: 2.5;
}

/* Модальные окна */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  width: 92%;
  max-width: 440px;
  box-shadow: var(--shadow);
  max-height: 86vh;
  max-height: 86dvh;
  overflow-y: auto;
}
.modal h3 {
  margin-bottom: 14px;
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}
.modal-buttons button, .btn-primary, .btn-secondary {
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.ut-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  width: 100%;
}
.ut-add-row input {
  flex: 1;
  margin: 0 !important;
}
.ut-add-row button {
  flex-shrink: 0;
  height: 42px;
  min-width: 42px;
  border-radius: var(--radius-sm);
}

.color-picker-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.color-btn:hover {
  transform: scale(1.1);
}

/* Плеер Unchainetidey */
.ut-mini-player {
  position: fixed;
  right: 18px;
  bottom: 90px;
  z-index: 99999 !important;
  width: 240px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  display: none;
}
.ut-mini-player.visible {
  display: block;
}
.ut-mini-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: grab;
  background: var(--bg-tertiary);
}
.ut-mini-title {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ut-mini-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.ut-mini-body {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ut-mini-playbtn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ut-mini-more {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.ut-mini-extra {
  display: none;
  padding: 0 14px 14px;
}
.ut-mini-extra.open {
  display: block;
}
.ut-speed-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.ut-speed-row button {
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
}
.ut-speed-row button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.ut-track-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  margin-bottom: 6px;
  border: 1px solid var(--border);
}
.ut-track-info {
  flex: 1;
  min-width: 0;
}
.ut-track-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ut-track-src {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.ut-track-actions {
  display: flex;
  gap: 4px;
}
.ut-track-actions button {
  background: var(--bg-input);
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-primary);
  transition: var(--transition);
}
.ut-playlist-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.ut-playlist-tab {
  padding: 4px 10px;
  border-radius: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--text-secondary);
}
.ut-playlist-tab.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
  padding: 24px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 24, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 99999;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
:root[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.92);
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 16px) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}
.mobile-only {
  display: none;
}

/* Стикеры */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
}
.sticker-item {
  width: 70px;
  height: 70px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
}
.sticker-item:hover {
  border-color: var(--accent);
}
.sticker-item img, .sticker-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Контекстное меню */
.context-menu {
  position: fixed;
  background: rgba(20, 20, 24, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 4px;
  z-index: 2500;
  box-shadow: var(--shadow);
}
.context-menu.hidden {
  display: none;
}
.context-menu button {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 12px;
  text-align: left;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.context-menu button:hover {
  background: var(--bg-tertiary);
}

/* Экран локальной блокировки аккаунта */
.account-lock-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.account-lock-overlay.hidden {
  display: none;
}
.account-lock-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.account-lock-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent), #7c5cfc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
}
.account-lock-avatar svg {
  width: 36px !important;
  height: 36px !important;
  color: #fff;
  flex-shrink: 0;
}
.account-lock-name {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 2px;
}
.account-lock-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}
.account-lock-card input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 12px;
  text-align: center;
}
.account-lock-remember {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.account-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}
.account-divider::after, .account-divider::before {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.account-forgot {
  display: block;
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}

/* Карточка профиля */
.account-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}
.account-profile-avatar {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
  background: var(--bg-input) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  border: 1px solid var(--border);
}
.account-profile-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.account-profile-avatar svg {
  width: 24px !important;
  height: 24px !important;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.account-profile-info {
  flex: 1;
  min-width: 0;
}
.account-profile-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.account-profile-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

img.verified-badge {
  width: 16px !important;
  height: 16px !important;
  margin-left: 4px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.sub-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-left: 6px;
  text-transform: uppercase;
}
.sub-lite {
  background: #333;
  color: #fff;
}
.sub-pro {
  background: linear-gradient(135deg, var(--accent), #7c5cfc);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Экран звонка */
.call-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #1a1030, #0f0f0f 70%);
  z-index: 2500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 60px 20px 40px;
  color: #fff;
  text-align: center;
}
.call-overlay.hidden {
  display: none;
}
.call-avatar-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 20px auto 0;
}
.call-avatar {
  width: 160px !important;
  height: 160px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  background: var(--bg-tertiary) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 3px solid var(--accent) !important;
  box-shadow: 0 0 40px rgba(26, 94, 255, 0.45);
  position: relative;
  z-index: 2;
}
.call-avatar img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.call-avatar svg {
  width: 65px !important;
  height: 65px !important;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.call-pulse-ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  opacity: 0;
  z-index: 1;
}
.call-overlay.listening .call-pulse-ring,
.call-overlay.speaking .call-pulse-ring {
  animation: pulseRing 1.6s ease-out infinite;
}

@keyframes pulseRing {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

.call-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 20px;
}
.call-status {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 6px;
  min-height: 20px;
}
.call-timer {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.call-caption {
  max-width: 90%;
  margin: 20px auto 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 16px;
  border-radius: 12px;
  min-height: 20px;
}
.call-controls {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-bottom: 10px;
}
.call-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.call-btn.mic {
  background: var(--bg-tertiary);
  color: #fff;
  border: 2px solid var(--border);
}
.call-btn.mic.active {
  background: var(--accent);
  border-color: var(--accent);
}
.call-btn.text {
  background: var(--bg-tertiary);
  color: #fff;
  border: 2px solid var(--border);
  width: 52px;
  height: 52px;
}
.call-btn.hangup {
  background: var(--danger);
  color: #fff;
  width: 70px;
  height: 70px;
}
.call-text-row {
  display: flex;
  gap: 8px;
  max-width: 90%;
  width: 100%;
  margin-top: 14px;
}
.call-text-row.hidden {
  display: none;
}
.call-text-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  outline: none;
}
.call-text-row button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.vp-avatar-wrap {
  width: 80px !important;
  height: 80px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, var(--accent), #7c5cfc) !important;
  margin: -50px auto 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  border: 4px solid var(--bg-secondary) !important;
  position: relative;
  z-index: 2;
}
.vp-avatar-wrap img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.vp-avatar-wrap svg {
  width: 36px !important;
  height: 36px !important;
  color: #fff;
  flex-shrink: 0;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    z-index: 150;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-only {
    display: flex !important;
  }
  .hide-mobile {
    display: none !important;
  }
  .mobile-menu-btn {
    display: flex !important;
  }
  .chat-header {
    padding: 8px 10px;
    gap: 8px;
  }
  .header-titles {
    max-width: 50%;
  }
  .btn-header-menu, .icon-btn-ghost {
    padding: 5px;
  }
  .glass-nav-container {
    width: 94%;
    bottom: 10px;
    gap: 6px;
    transition: transform 0.2s;
  }
  .glass-nav-pill {
    flex: 1;
    justify-content: space-between;
    padding: 4px;
  }
  .nav-item {
    padding: 6px;
    min-width: 48px;
  }
  .nav-item .nav-label {
    font-size: 0.6rem;
  }
  .glass-action-btn {
    width: 50px;
    height: 50px;
  }
  .glass-action-btn .lucide {
    width: 20px;
    height: 20px;
  }
  .chat-input-area {
    padding: 6px 8px 75px;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .chat-input-row {
    padding: 4px;
    gap: 4px;
    flex-wrap: nowrap;
  }
  .btn-send, .btn-attach {
    width: 34px;
    height: 34px;
    padding: 6px;
    flex-shrink: 0;
  }
  .btn-attach .lucide, .btn-send .lucide {
    width: 16px;
    height: 16px;
  }
  .message-container {
    max-width: 92%;
  }
  .modal {
    width: 94%;
    padding: 16px;
    border-radius: 20px;
  }
  .ut-mini-player {
    width: calc(100% - 32px);
    right: 16px;
    bottom: 78px;
  }
  body.keyboard-open .glass-nav-container,
  body.input-focused .glass-nav-container {
    display: none !important;
    opacity: 0;
    pointer-events: none;
  }
  body.keyboard-open .chat-input-area,
  body.input-focused .chat-input-area {
    padding-bottom: 6px !important;
  }
}
