/* ── Reset & Variables ─────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: 400;
  src: url('fonts/material-symbols-outlined.woff2') format('woff2');
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Видимый фокус для клавиатурной навигации */
:focus-visible {
  outline: 2px solid var(--accent-light, #66bb6a);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Убираем дефолтный outline везде (мы добавили свой через :focus-visible) */
:focus:not(:focus-visible) {
  outline: none;
}

:root {
  /* Backgrounds — чуть светлее чтобы снизить резкость тёмной темы */
  --bg:                #141f14;
  --bg2:               #1d2e1d;
  --bg3:               #263a26;
  --accent:            #4caf50;
  --accent-dark:       #388e3c;
  --accent-light:      #81c784;
  /* Текст — чуть менее яркий чтобы убрать harsh-контраст */
  --text:              #d8ecd9;
  --text-muted:        #789878;
  --border:            #335533;
  --shadow:            rgba(0,0,0,0.4);
  --radius:            12px;
  --sidebar-w:         240px;
  --user-bubble:       #2d6b31;
  --bot-bubble:        #1e3220;
  /* Состояния */
  --color-danger:          #ef5350;
  --color-danger-muted:    #ef9a9a;
  --color-upload:          #4dd0e1;
  --color-sent:            #66bb6a;
  --reaction-like-bg:      rgba(76, 175, 80, 0.15);
  --reaction-dislike-bg:   rgba(239, 83, 80, 0.15);
  --favorite-accent:       #ffd54f;
  --favorite-bg:           rgba(255, 213, 79, 0.16);
  --favorite-border:       rgba(255, 213, 79, 0.42);
  --moderation-btn-bg:     rgba(255, 112, 67, 0.10);
  --moderation-btn-hover:  rgba(255, 112, 67, 0.18);
  --moderation-btn-text:   #ffab91;
  --moderation-btn-border: rgba(255, 112, 67, 0.56);
  --moderation-btn-shadow: rgba(255, 112, 67, 0.18);
  --moderation-btn-active-bg: rgba(255, 112, 67, 0.14);
  --moderation-btn-active-text: #ffccbc;
  --moderation-btn-active-border: rgba(255, 171, 145, 0.62);
}

/* ── Light theme ──────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:                #f4f6f3;
  --bg2:               #ffffff;
  --bg3:               #edf1ed;
  --accent:            #2e7d32;
  --accent-dark:       #1b5e20;
  --accent-light:      #4caf50;
  --text:              #1a1a1a;
  --text-muted:        #6a7a6a;
  /* Граница чуть заметнее — не теряется на светлом фоне */
  --border:            #c8d0c4;
  --shadow:            rgba(0,0,0,0.10);
  /* user-bubble чуть насыщеннее чтобы выделялся */
  --user-bubble:       #c0e0c1;
  /* bot-bubble контрастнее на белом bg2 */
  --bot-bubble:        #e9f1e9;
  --color-danger:          #ef5350;
  --color-danger-muted:    #ef9a9a;
  --color-upload:          #4dd0e1;
  --color-sent:            #66bb6a;
  --reaction-like-bg:      rgba(46, 125, 50, 0.12);
  --reaction-dislike-bg:   rgba(239, 83, 80, 0.12);
  --favorite-accent:       #b26a00;
  --favorite-bg:           rgba(255, 193, 7, 0.18);
  --favorite-border:       rgba(255, 193, 7, 0.42);
  --moderation-btn-bg:     rgba(229, 57, 53, 0.08);
  --moderation-btn-hover:  rgba(229, 57, 53, 0.14);
  --moderation-btn-text:   #c62828;
  --moderation-btn-border: rgba(229, 57, 53, 0.40);
  --moderation-btn-shadow: rgba(229, 57, 53, 0.12);
  --moderation-btn-active-bg: rgba(229, 57, 53, 0.12);
  --moderation-btn-active-text: #b71c1c;
  --moderation-btn-active-border: rgba(198, 40, 40, 0.45);
}
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #bbb; }
[data-theme="light"] .scroll-bottom-btn { box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
[data-theme="light"] .msg-bubble pre { background: rgba(0,0,0,0.06); }
[data-theme="light"] .msg-bubble code { background: rgba(0,0,0,0.06); color: var(--accent-dark); }
[data-theme="light"] .msg-bubble a { color: var(--accent-dark); }
[data-theme="light"] .msg-row.user .msg-bubble { color: var(--text); }
[data-theme="light"] .msg-row.bot .msg-bubble { color: var(--text); }
[data-theme="light"] .msg-bubble strong { color: var(--accent-dark); }

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  /* НЕ ставим position:fixed — это ломает visualViewport на iOS */
}

/* ── Auth Page ─────────────────────────────────────────────────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-logo {
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-light);
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 20px;
}

.auth-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.btn-yandex {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #FC3F1D;
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 8px;
  transition: background 0.2s;
  width: 100%;
  justify-content: center;
}

.btn-yandex:hover {
  background: #e0361a;
}

/* OAuth icon-only row on login page */
.oauth-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 4px 0;
}

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.oauth-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.oauth-btn:active { transform: scale(0.96); }

.oauth-ico {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.oauth-yandex { background: #FC3F1D; }
.oauth-vk     { background: #0077ff; }
.oauth-google  { background: #ffffff; border: 1px solid #d1d5db; }
.oauth-tg     { background: #54a9eb; }

.auth-footer {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.auth-footer a {
  color: var(--accent-light);
}

.staging-demo-card {
  margin: 0 0 18px;
  padding: 16px;
  text-align: left;
  background: linear-gradient(180deg, rgba(76, 175, 80, 0.14), rgba(76, 175, 80, 0.06));
  border: 1px solid rgba(129, 199, 132, 0.28);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.staging-demo-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(129, 199, 132, 0.14);
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.staging-demo-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.staging-demo-text {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.staging-demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.staging-demo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s ease, transform 0.15s ease;
}

.staging-demo-link:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.staging-demo-link--ghost {
  background: transparent;
  color: var(--accent-light);
  border: 1px solid var(--border);
}

.staging-demo-link--ghost:hover {
  background: rgba(129, 199, 132, 0.08);
}

/* Форма авторизации — токенные стили (без хардкодированных цветов в HTML) */
.auth-bot-message {
  display: none;
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--accent-light);
  font-size: 14px;
  text-align: center;
}

.auth-divider {
  margin: 14px 0 8px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.auth-input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: inherit;
  width: 100%;
}

.auth-input::placeholder { color: var(--text-muted); }

.auth-submit {
  padding: 12px 14px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
}

.auth-submit:hover    { background: var(--accent-dark); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-status { min-height: 18px; font-size: 13px; color: var(--text-muted); }
.auth-status--error   { color: var(--color-danger-muted); }
.auth-status--success { color: var(--accent-light); }

/* ── Cabinet Layout ────────────────────────────────────────────────────────── */

.cabinet-page {
  display: flex;
  height: 100%;
  width: 100%;
  max-width: 100vw;
  /* JS перезапишет html.style.height через visualViewport */
  overflow: hidden;
  overflow-x: clip;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  transition: transform 0.25s;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-light);
  flex: 1;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.user-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg3);
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:hover {
  background: var(--bg3);
  color: var(--text);
}

.nav-btn.active {
  background: rgba(76, 175, 80, 0.15);
  color: var(--accent-light);
}

.nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg3);
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}

.nav-btn.active .nav-count {
  background: rgba(76, 175, 80, 0.18);
  color: var(--accent-light);
}

.nav-icon { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; display:flex; align-items:center; justify-content:center; }

/* Topics in sidebar */
.topic-main { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.topic-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-icon { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; display:flex; align-items:center; justify-content:center; }
.topic-btn.active .topic-icon { color: #fff; }

.sidebar-topics {
  padding: 0 12px;
  margin: 4px 0;
}
.topics-header {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 8px 4px;
  letter-spacing: 0.5px;
}
.topics-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topic-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.topic-btn:hover { background: var(--bg3); }
.topic-btn.active {
  background: var(--accent);
  color: #fff;
}
.topic-btn .topic-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg3);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.topic-btn.active .topic-count {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.btn-logout {
  margin: 12px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-logout:hover {
  background: rgba(255,50,50,0.1);
  color: var(--color-danger-muted);
  border-color: #c62828;
}

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: clip;
  position: relative;
  min-height: 0; /* важно для вложенного overflow в flex на iOS */
  min-width: 0;
  max-width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent-light);
  flex: 1;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 2.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Tab content */
.tab-content {
  display: none;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0; /* иначе на мобиле может не скроллиться */
  min-width: 0;
  max-width: 100%;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
  display:flex;
  align-items:center;
  justify-content:center;
}

.card-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* важно для мобильного grid: не давать полям раздвигать контейнер по ширине */
.form-grid > * {
  min-width: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.form-group label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group input.readonly {
  color: var(--text-muted);
  cursor: default;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover { background: var(--accent-dark); }
/* Тактильная обратная связь на мобильных */
.btn-primary:active { background: var(--accent-dark); transform: scale(0.97); }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover { background: var(--bg3); }

.save-status {
  font-size: 13px;
  color: var(--accent-light);
}

/* Channel items */
.channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.channel-item:last-child { border-bottom: none; }

.channel-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-icon {
  font-size: 24px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
}

.tg-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='120' y1='240' x2='120' y2='0' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%231d93d2'/%3E%3Cstop offset='1' stop-color='%2338b0e3'/%3E%3C/linearGradient%3E%3C/defs%3E%3Ccircle cx='120' cy='120' r='120' fill='url(%23g)'/%3E%3Cpath d='M81.2 128.8l14.2 39.4s1.8 3.7 3.7 3.7 30.3-29.5 30.3-29.5l31.5-60.9-79.2 38.2z' fill='%23c8daea'/%3E%3Cpath d='M100.1 138.9l-2.7 29s-1.1 8.9 7.8 0 17.4-15.8 17.4-15.8' fill='%23a9c6d8'/%3E%3Cpath d='M81.5 130.2l-29.3-9.5s-3.5-1.4-2.4-4.6c.2-.7.7-1.2 2.1-2.2 6.5-4.5 120.1-45.4 120.1-45.4s3.2-1.1 5.1-.4a2.8 2.8 0 011.9 2.1 9.4 9.4 0 01.3 2.6c0 .7-.1 1.4-.2 2.5-.7 11.2-21.4 94.5-21.4 94.5s-1.2 4.9-5.7 5a8.1 8.1 0 01-5.9-2.3c-8.7-7.5-38.8-27.7-45.5-32.2a1.3 1.3 0 01-.5-.9c-.1-.5.4-1 .4-1s52.4-46.6 53.8-51.5c.1-.4-.3-.6-.8-.4-3.5 1.3-63.8 39.4-70.5 43.6a3.2 3.2 0 01-1.5.1z' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  border-radius: 50%;
}

.yandex-icon {
  background-image: url("icons/yandex.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px 24px;
  border-radius: 8px;
}

.vk-icon {
  background-image: url("icons/vk.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px 24px;
  border-radius: 8px;
}

.google-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23FFC107' d='M43.6 20.5H42V20H24v8h11.3C33.7 32.7 29.3 36 24 36c-6.6 0-12-5.4-12-12s5.4-12 12-12c3 0 5.7 1.1 7.8 2.9l5.7-5.7C34 6.1 29.3 4 24 4 12.9 4 4 12.9 4 24s8.9 20 20 20 20-8.9 20-20c0-1.3-.1-2.4-.4-3.5z'/%3E%3Cpath fill='%23FF3D00' d='M6.3 14.7l6.6 4.8C14.7 15 19 12 24 12c3 0 5.7 1.1 7.8 2.9l5.7-5.7C34 6.1 29.3 4 24 4c-7.7 0-14.3 4.4-17.7 10.7z'/%3E%3Cpath fill='%234CAF50' d='M24 44c5.2 0 9.9-2 13.4-5.2l-6.2-5.2C29.2 35.1 26.7 36 24 36c-5.3 0-9.8-3.3-11.5-8l-6.6 5.1C9.2 39.5 16 44 24 44z'/%3E%3Cpath fill='%231976D2' d='M43.6 20.5H42V20H24v8h11.3c-.8 2.3-2.2 4.2-4.1 5.6l.1-.1 6.2 5.2C37.1 39 44 34 44 24c0-1.3-.1-2.4-.4-3.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 24px 24px;
  border-radius: 8px;
}

.max-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80' fill='none'%3E%3Cpath d='M60 0H20C9 0 0 9 0 20v40c0 11 9 20 20 20h40c11 0 20-9 20-20V20C80 9 71 0 60 0z' fill='url(%23a)'/%3E%3Cpath d='M60 0H20C9 0 0 9 0 20v40c0 11 9 20 20 20h40c11 0 20-9 20-20V20C80 9 71 0 60 0z' fill='url(%23b)'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M40.7 70.3c-6 0-8.8-.9-13.7-4.4-3 3.9-12.8 7-13.2 1.8 0-4-1-7.3-1.9-11-.4-1.5-.8-3-1.2-4.7-1-3.8-1.4-8.4-1.4-12 0-17.3 14.2-30.4 31-30.4 16.9 0 30.1 13.7 30.1 30.5.1 16.6-13.3 30.1-29.9 30.2zm.2-45.7c-8.2-.4-14.6 5.3-16 14.2-1.2 7.4.8 16.3 2.6 16.8.8.2 3-1.5 4.3-2.9 2.2 1.5 4.8 2.4 7.4 2.7 8.5.4 15.8-6.1 16.4-14.6.3-8.5-6.3-15.7-14.8-16.2z' fill='white'/%3E%3Cdefs%3E%3ClinearGradient id='a' x1='9.4' y1='60.8' x2='80' y2='40' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%2344CCFF'/%3E%3Cstop offset='.66' stop-color='%235533EE'/%3E%3Cstop offset='1' stop-color='%239933DD'/%3E%3C/linearGradient%3E%3CradialGradient id='b' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(-1.9 -35.1) rotate(51.4) scale(97 40)'%3E%3Cstop stop-color='%2300F'/%3E%3Cstop offset='1' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  border-radius: 8px;
}

.channel-name {
  font-weight: 600;
  font-size: 14px;
}

.channel-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.channel-status.linked { color: var(--accent-light); }

.channel-actions {
  display: flex;
  gap: 8px;
}

.btn-link {
  background: rgba(76, 175, 80, 0.15);
  color: var(--accent-light);
  border: 1px solid var(--accent-dark);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-link:hover { background: rgba(76, 175, 80, 0.28); }

.btn-unlink {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-unlink:hover {
  background: rgba(76, 175, 80, 0.12);
  border-color: var(--accent-dark);
  color: var(--accent-light);
}

/* Кнопка «Отвязать» когда это единственный способ входа */
.btn-unlink-last {
  opacity: 0.6;
  border-style: dashed;
}
.btn-unlink-last::after {
  content: ' warning';
  font-family: 'Material Symbols Outlined';
  font-size: 13px;
  vertical-align: middle;
  margin-left: 4px;
}

/* Search */
.search-toggle {
  background: none; border: none; color: var(--text-muted); font-size: 15px;
  cursor: pointer; padding: 6px 8px; transition: color 0.15s;
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
}
.search-toggle:hover { color: var(--accent-light); background: var(--bg3); }
.search-toggle .material-symbols-outlined { font-size: 20px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  display:flex;
  align-items:center;
  justify-content:center;
}
.icon-btn:hover { color: var(--accent-light); background: var(--bg3); }
.icon-btn:active { background: var(--bg3); transform: scale(0.92); }

.notification-bell {
  position: relative;
  overflow: visible;
}

.notification-bell.has-unread,
.notification-bell.is-open {
  color: var(--accent-light);
  background: var(--bg3);
}

.notification-bell.has-unread .material-symbols-outlined,
.notification-bell.is-open .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 450, 'GRAD' 0, 'opsz' 24;
}

.notification-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff7043, #ffb300);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.22);
}

.notifications-layer {
  position: absolute;
  inset: 64px 0 0 0;
  z-index: 30;
  pointer-events: none;
}

.notifications-layer.open {
  pointer-events: auto;
}

.notifications-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(7, 12, 7, 0.34);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.18s ease;
}

.notifications-layer.open .notifications-backdrop {
  opacity: 1;
}

.notifications-panel {
  position: absolute;
  top: 14px;
  right: 16px;
  width: min(400px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 104px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(129, 199, 132, 0.18);
  background:
    radial-gradient(circle at top right, rgba(129, 199, 132, 0.16), transparent 42%),
    linear-gradient(180deg, rgba(38, 58, 38, 0.98), rgba(20, 31, 20, 0.98));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  transform: translateY(-8px) scale(0.98);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

[data-theme="light"] .notifications-panel {
  border-color: rgba(76, 175, 80, 0.18);
  background:
    radial-gradient(circle at top right, rgba(76, 175, 80, 0.10), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 246, 243, 0.98));
  box-shadow: 0 18px 44px rgba(18, 33, 20, 0.12);
}

.notifications-layer.open .notifications-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.notifications-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.notifications-panel-copy {
  min-width: 0;
}

.notifications-panel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.02em;
}

.notifications-panel-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.notifications-close-btn {
  flex-shrink: 0;
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 72px;
  max-height: min(472px, calc(100dvh - 182px));
  padding-right: 2px;
}

.notifications-empty {
  padding: 24px 18px;
  border-radius: 16px;
  border: 1px dashed rgba(129, 199, 132, 0.22);
  background: rgba(129, 199, 132, 0.05);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

[data-theme="light"] .notifications-empty {
  border-color: rgba(46, 125, 50, 0.16);
  background: rgba(76, 175, 80, 0.05);
}

.notification-item {
  width: 100%;
  border: 1px solid rgba(129, 199, 132, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 14px 15px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

[data-theme="light"] .notification-item {
  background: rgba(255, 255, 255, 0.82);
}

.notification-item:hover {
  transform: translateY(-1px);
  border-color: rgba(129, 199, 132, 0.26);
  background: rgba(129, 199, 132, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .notification-item:hover {
  background: rgba(76, 175, 80, 0.08);
}

.notification-item.is-unread {
  border-color: rgba(255, 183, 77, 0.34);
  background:
    linear-gradient(135deg, rgba(255, 183, 77, 0.14), rgba(255, 112, 67, 0.06)),
    rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .notification-item.is-unread {
  background:
    linear-gradient(135deg, rgba(255, 183, 77, 0.18), rgba(255, 112, 67, 0.08)),
    rgba(255, 255, 255, 0.9);
}

.notification-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.notification-item-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.notification-item-eyebrow .material-symbols-outlined {
  font-size: 17px;
}

.notification-item-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff7043, #ffca28);
  box-shadow: 0 0 0 4px rgba(255, 183, 77, 0.12);
  flex-shrink: 0;
}

.notification-item-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.notification-item-summary {
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.notification-item-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.notification-item-source {
  min-width: 0;
}

.notification-item-time {
  white-space: nowrap;
}

.search-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--bg2); border-bottom: 1px solid var(--border);
}
.search-input {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 14px; outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-close {
  background: none; border: none; color: var(--text-muted); font-size: 16px;
  cursor: pointer; padding: 4px;
}
.search-count {
  font-size: 12px; color: var(--text-muted); white-space: nowrap; min-width: 50px; text-align: center;
}
.search-nav-btn {
  background: none; border: none; color: var(--text-muted); font-size: 12px;
  cursor: pointer; padding: 2px 6px; border-radius: 4px; transition: background 0.12s;
}
.search-nav-btn:hover { background: var(--bg3); color: var(--text); }
.search-nav-btn .material-symbols-outlined,
.search-close .material-symbols-outlined,
.reply-bar-close .material-symbols-outlined,
.photo-preview-close .material-symbols-outlined,
.voice-cancel-btn .material-symbols-outlined,
.sidebar-close .material-symbols-outlined,
.hamburger .material-symbols-outlined,
.scroll-bottom-btn .material-symbols-outlined {
  font-size: 18px;
  vertical-align: middle;
}
.search-hit.active { background: var(--hover, var(--bg3)); }
.search-results-wrap {
  width: 100%; max-height: 35vh; position: relative;
}
.search-results {
  width: 100%; max-height: 35vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.search-results-wrap::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 24px;
  background: linear-gradient(transparent, var(--bg2)); pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
}
.search-results-wrap.has-scroll::after { opacity: 1; }
.search-hit {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.12s;
}
.search-hit:hover { background: var(--bg3); }
.search-hit-role {
  font-size: 10px; color: var(--text-muted); flex-shrink: 0; width: 14px; text-align: center;
}
.search-hit-text {
  font-size: 13px; color: var(--text); line-height: 1.3;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-hit-text mark { background: var(--accent); color: #000; border-radius: 2px; padding: 0 1px; }
.search-hit-meta {
  font-size: 10px; color: var(--text-muted); flex-shrink: 0; white-space: nowrap;
}
.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.search-empty-state .material-symbols-outlined {
  font-size: 32px;
  opacity: 0.5;
}

.hidden { display: none !important; }

/* ── Chat ──────────────────────────────────────────────────────────────────── */

#tab-chat {
  padding: 0;
}

#tab-chat.active {
  gap: 0;
}

.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: auto;
}

/* Welcome screen inside chat */
.chat-welcome {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
}

.chat-welcome-icon { font-size: 48px; }

.chat-welcome-title {
  font-size: 18px;
  color: var(--accent-light);
  font-weight: 600;
}

.chat-welcome-text {
  font-size: 14px;
  max-width: 300px;
}

/* Message rows */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgFadeIn 0.2s ease;
  touch-action: pan-y;
}

.msg-row.user { justify-content: flex-end; }
.msg-row.user > div { margin-left: auto; }
.msg-row.bot  { justify-content: flex-start; }

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--bg2);
}

.msg-bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
  min-width: max(60px, 38vw);
  position: relative;
}

.msg-bubble.has-time {
  padding-bottom: 2px;
}

.msg-time-inside {
  position: absolute;
  right: 10px;
  bottom: 6px;
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
}

.msg-time-spacer {
  display: inline-block;
  width: 46px;
  height: 1px;
  vertical-align: baseline;
  pointer-events: none;
}

.msg-row.user .msg-bubble {
  background: var(--user-bubble);
  color: var(--text);
  border-bottom-right-radius: 5px;
  margin-left: auto;
}

.msg-row.bot .msg-bubble {
  background: var(--bot-bubble);
  color: var(--text);
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border);
}

/* Markdown content inside bubble */
.msg-bubble strong { color: var(--accent); font-weight: 700; }
.msg-bubble em { font-style: italic; }
/* Ссылки в сообщениях — подчёркнуты и выделены цветом в обеих темах */
.msg-bubble a {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: break-word;
}
.msg-bubble a:hover { opacity: 0.85; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin: 8px 0 4px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--accent);
}
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 15px; }
.msg-bubble ul, .msg-bubble ol {
  margin: 6px 0;
  padding-left: 0;
  list-style: none;
}
.msg-bubble ul { counter-reset: none; }
.msg-bubble ol { counter-reset: msg-bubble-ol; }
.msg-bubble li {
  position: relative;
  margin: 3px 0;
  padding-left: 18px;
}
.msg-bubble ul > li::before {
  content: '•';
  position: absolute;
  left: 0;
  top: 0;
}
.msg-bubble ol > li::before {
  counter-increment: msg-bubble-ol;
  content: counter(msg-bubble-ol) '.';
  position: absolute;
  left: 0;
  top: 0;
}
.msg-bubble code {
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  color: var(--accent-light);
}
.msg-bubble pre {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 13px;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble p { margin: 4px 0; }
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.msg-row.user .msg-meta { justify-content: flex-end; }

.msg-reply-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.15s;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.msg-reply-btn:hover { color: var(--accent-light); }
.msg-copy-btn.copied { color: var(--accent-light); opacity: 1; }
.msg-favorite-btn {
  min-width: 26px;
  height: 24px;
  padding: 0 5px;
  border: 1px solid transparent;
  border-radius: 999px;
}
.msg-favorite-btn .material-symbols-outlined,
.content-viewer-favorite .material-symbols-outlined {
  transition: font-variation-settings 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.msg-favorite-btn.is-active {
  color: var(--favorite-accent);
  opacity: 1;
  background: var(--favorite-bg);
  border-color: var(--favorite-border);
}
.msg-favorite-btn.is-active .material-symbols-outlined,
.content-viewer-favorite.is-active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 24;
  transform: scale(1.03);
}
.msg-favorite-btn.is-pending,
.content-viewer-favorite.is-pending {
  opacity: 0.72;
}

/* Reaction buttons */
.reaction-btns,
.msg-reactions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
}
.reaction-btns { margin-left: 4px; margin-top: 0; }
.reaction-btn,
.msg-react-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.4;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  line-height: 1;
  color: var(--text-muted);
}
.reaction-btn { font-size: 13px; padding: 0 2px; border-radius: 0; display:inline-flex; align-items:center; justify-content:center; }
.reaction-btn .material-symbols-outlined { font-size: 18px; }
.reaction-btn-label {
  display: none;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.reaction-btn--moderation {
  opacity: 1;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  gap: 0;
  color: var(--moderation-btn-text);
  background: var(--moderation-btn-bg);
  border: 1px solid var(--moderation-btn-border);
  box-shadow: 0 2px 8px var(--moderation-btn-shadow);
}
.reaction-btn--moderation .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}
.reaction-btn--moderation:hover:not(:disabled) {
  background: var(--moderation-btn-hover);
  color: var(--moderation-btn-text);
  border-color: var(--moderation-btn-text);
  transform: translateY(-1px) scale(1.04);
}
.msg-reply-btn .material-symbols-outlined,
.msg-quote .material-symbols-outlined { font-size: 14px; vertical-align: middle; margin-right: 2px; }
.msg-reply-btn .material-symbols-outlined { margin-right: 0; }
.msg-react-btn:hover { opacity: 0.8; background: var(--hover, var(--bg3)); }
.reaction-btn:hover:not(:disabled) { opacity: 1; transform: scale(1.2); color: var(--accent-light); }
.msg-react-btn.active,
.reaction-btn:disabled { cursor: default; }
.msg-react-btn.active { opacity: 1; }
.msg-react-btn.reacted { pointer-events: none; }
.reaction-btn.reaction-active-like,
.msg-react-btn.reaction-active-like {
  opacity: 1;
  color: var(--accent-light);
  background: var(--reaction-like-bg);
  border-radius: 12px;
  padding: 2px 6px;
}
.reaction-btn.reaction-active-dislike,
.msg-react-btn.reaction-active-dislike {
  opacity: 1;
  color: var(--color-danger);
  background: var(--reaction-dislike-bg);
  border-radius: 12px;
  padding: 2px 6px;
}
[data-theme="light"] .reaction-btn,
[data-theme="light"] .msg-react-btn { opacity: 0.55; }
[data-theme="light"] .reaction-btn--moderation {
  opacity: 1;
  color: var(--moderation-btn-text);
}
[data-theme="light"] .reaction-btn:hover:not(:disabled),
[data-theme="light"] .msg-react-btn:hover { opacity: 1; }

/* Dislike reasons panel */
.dislike-reasons {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: msgFadeIn 0.2s ease;
}
.dislike-reasons-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.dislike-reasons-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dislike-reason-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.dislike-reason-btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent);
  color: #fff;
}
.dislike-comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.dislike-comment-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.4;
}
.dislike-comment-input:focus {
  outline: none;
  border-color: var(--accent);
}
.dislike-comment-send {
  align-self: flex-end;
  padding: 6px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.dislike-comment-send:hover {
  background: var(--accent-light);
}
.dislike-reasons-thanks {
  font-size: 13px;
  color: var(--accent-light);
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
[data-theme="light"] .dislike-reason-btn {
  background: var(--bg3);
}
[data-theme="light"] .dislike-reason-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Moderation */
.reaction-btn.reaction-active-moderation {
  opacity: 1;
  color: var(--moderation-btn-active-text);
  background: var(--moderation-btn-active-bg);
  border-radius: 999px;
  border: 1px solid var(--moderation-btn-active-border);
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
}
.moderation-panel {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.moderation-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.moderation-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.moderation-close-btn:hover {
  color: var(--text);
}
.moderation-comment-input {
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  font-family: inherit;
  outline: none;
}
.moderation-comment-input:focus {
  border-color: var(--accent);
}
.moderation-send-btn {
  align-self: flex-end;
  padding: 6px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.moderation-send-btn:hover {
  background: var(--accent-light);
}
.dislike-reason-btn--moderation {
  border: 1px solid var(--accent);
  color: var(--accent-light);
}
.dislike-reason-btn--moderation:hover {
  background: var(--accent);
  color: #000;
}
[data-theme="light"] .dislike-reason-btn--moderation {
  background: var(--bg3);
  border-color: var(--accent);
  color: var(--accent);
}
[data-theme="light"] .dislike-reason-btn--moderation:hover {
  background: var(--accent);
  color: #fff;
}

/* Scroll to bottom button */
.scroll-bottom-btn,
.scroll-top-btn {
  position: absolute;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(129, 199, 132, 0.26);
  background: color-mix(in srgb, var(--bg2) 84%, transparent);
  color: var(--accent-light);
  font-size: 18px;
  cursor: pointer;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  opacity: 0.94;
}
.scroll-bottom-btn {
  bottom: 120px;
}
.scroll-top-btn {
  bottom: 24px;
}
.scroll-bottom-btn:hover,
.scroll-top-btn:hover {
  background: color-mix(in srgb, var(--bg3) 92%, transparent);
  border-color: rgba(129, 199, 132, 0.4);
  opacity: 1;
  transform: translateY(-1px);
}
.scroll-bottom-btn.hidden,
.scroll-top-btn.hidden { display: none; }

.materials-card,
#tab-drugs .materials-card,
.content-viewer-scroll {
  position: relative;
}

.reading-resume-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(129, 199, 132, 0.24);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(129, 199, 132, 0.12), rgba(77, 208, 225, 0.08));
  transition: opacity 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.reading-resume-panel.is-collapsed {
  opacity: 0.74;
  border-style: dashed;
  background: linear-gradient(135deg, rgba(129, 199, 132, 0.07), rgba(77, 208, 225, 0.04));
}

.reading-resume-panel.hidden {
  display: none;
}

#tab-materials.is-history-view .materials-toolbar,
#tab-materials.is-history-view #readingResumePanel,
#tab-materials.is-history-view .materials-card > .card-title,
#tab-materials.is-history-view .materials-card > .card-desc {
  display: none;
}

.materials-history-section {
  border: 0;
  background: transparent;
  padding: 2px 0 0;
  gap: 14px;
}

.materials-history-section .reading-resume-head {
  align-items: flex-start;
  border-bottom: 1px solid rgba(129, 199, 132, 0.16);
  padding-bottom: 10px;
}

.materials-history-section .reading-resume-kicker {
  font-size: 18px;
}

.reading-resume-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reading-resume-kicker {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.reading-resume-hint,
.reading-resume-empty,
.reading-resume-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.reading-resume-subtitle {
  font-weight: 700;
  color: var(--text-secondary, var(--text-muted));
}

.reading-resume-toggle,
.reading-history-link,
.reading-history-back {
  border: 1px solid rgba(129, 199, 132, 0.28);
  border-radius: 999px;
  background: rgba(129, 199, 132, 0.08);
  color: var(--accent-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  min-height: 34px;
  padding: 7px 11px;
}

.reading-resume-toggle .material-symbols-outlined {
  font-size: 18px;
}

.reading-history-link {
  align-self: center;
  width: 100%;
  max-width: 320px;
}

.reading-resume-toggle:hover,
.reading-history-link:hover,
.reading-history-back:hover {
  border-color: rgba(129, 199, 132, 0.5);
  background: rgba(129, 199, 132, 0.14);
}

.reading-resume-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.reading-resume-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  color: var(--text);
  padding: 10px;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  position: relative;
}

.reading-resume-open {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.reading-bookmark-remove {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.reading-bookmark-remove .material-symbols-outlined {
  font-size: 18px;
}

.reading-bookmark-remove:hover {
  color: var(--color-danger-muted);
  border-color: rgba(239, 83, 80, 0.36);
}

.reading-resume-item:hover {
  border-color: rgba(129, 199, 132, 0.45);
}

.reading-resume-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reading-resume-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.reading-resume-meta {
  min-height: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.reading-resume-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent);
}

.reading-resume-badge .material-symbols-outlined {
  font-size: 14px;
  font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 20;
}

#materialsScrollTopBtn,
#drugsScrollTopBtn {
  position: sticky;
  margin-left: auto;
  margin-top: calc(100dvh - 260px);
}

#contentViewer {
  --content-viewer-scrolltop-base: 24px;
  --content-viewer-scrolltop-range: 88px;
  --content-viewer-scrolltop-offset: calc(var(--content-viewer-scrolltop-base) + (var(--content-viewer-footer-visibility, 1) * var(--content-viewer-scrolltop-range)));
}

#contentViewerScrollTopBtn {
  position: absolute;
  right: 20px;
  bottom: var(--content-viewer-scrolltop-offset);
  z-index: 26;
}

#contentViewerBookmark {
  position: absolute;
  top: calc(var(--content-viewer-header-space) + 10px);
  right: 14px;
  z-index: 27;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  padding: 0 13px;
  box-shadow: 0 10px 24px rgba(6, 11, 7, 0.22);
}

/* Reply quote */
.reply-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom)) 16px;
  background: var(--bg3);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  font-size: 13px;
  color: var(--text-muted);
}
.reply-bar.active { display: flex; }
.reply-bar-text {
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}
.reply-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 10px 12px;
}
.reply-bar-close:hover { color: var(--color-danger-muted); }

.content-context-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(76, 175, 80, 0.08);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}
.content-context-bar.active { display: flex; }
.content-context-bar-copy {
  flex: 1;
  min-width: 0;
}
.content-context-bar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.content-context-bar-text {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.content-context-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
}
.content-context-bar-close:hover { color: var(--color-danger-muted); }

.msg-content-context {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.18);
}
.msg-content-context .material-symbols-outlined {
  font-size: 18px;
  color: var(--accent);
}
.msg-content-context-copy {
  min-width: 0;
}
.msg-content-context-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.msg-content-context-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.msg-content-context-summary {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Quote inside bubble */
.msg-quote {
  border-left: 3px solid var(--accent);
  background: rgba(76, 175, 80, 0.1);
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: var(--accent-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  overflow: hidden;
}

.msg-quote > span:last-child,
.msg-quote > :not(.msg-quote-thumb):not(.material-symbols-outlined) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-quote:hover {
  background: rgba(76, 175, 80, 0.2);
}
.msg-quote-thumb {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Highlight animation for scrolled-to message */
@keyframes msgHighlight {
  0% { background: rgba(76, 175, 80, 0.3); }
  100% { background: transparent; }
}
.msg-row.highlighted .msg-bubble {
  animation: msgHighlight 1.5s ease-out;
}
/* Подсветка фото — полупрозрачный overlay поверх изображения */
.msg-photo-placeholder {
  position: relative;
}
.msg-photo-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(76, 175, 80, 0);
  pointer-events: none;
  transition: background 0.3s ease;
}
.msg-row.highlighted .msg-photo-placeholder::after {
  animation: photoOverlayHighlight 1.5s ease-out;
}
@keyframes photoOverlayHighlight {
  0%   { background: rgba(76, 175, 80, 0.35); }
  60%  { background: rgba(76, 175, 80, 0.15); }
  100% { background: rgba(76, 175, 80, 0); }
}

.channel-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--text-muted);
}

/* Thinking animation */
.msg-row.thinking .msg-bubble {
  padding: 12px 16px;
}

.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: dotBounce 1.2s infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.thinking-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* Chat input bar */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-wrap {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px 14px;
  display: flex;
  align-items: flex-end;
  transition: border-color 0.2s;
}

.chat-input-wrap:focus-within {
  border-color: var(--accent);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  resize: none;
  max-height: 120px;
  min-height: 22px;
  overflow-y: auto;
  font-family: inherit;
}

.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.chat-send-btn:hover { background: var(--accent); }
.chat-send-btn:active { transform: scale(0.92); }

/* Спиннер во время обработки сообщения */
.chat-send-btn:disabled {
  background: var(--bg2);
  opacity: 0.7;
  cursor: not-allowed;
  position: relative;
}
.chat-send-btn:disabled .material-symbols-outlined { opacity: 0; }
.chat-send-btn:disabled::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: send-btn-spin 0.7s linear infinite;
}
@keyframes send-btn-spin {
  to { transform: rotate(360deg); }
}

/* ── Attach button ─────────────────────────────────────────────────────────── */

.chat-attach-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.chat-attach-btn:hover { color: var(--accent); background: var(--bg); }
.chat-attach-btn:active { color: var(--accent); background: var(--bg); transform: scale(0.92); }
.chat-attach-btn .material-symbols-outlined,
.chat-voice-btn .material-symbols-outlined,
.chat-send-btn .material-symbols-outlined {
  font-size: 20px;
}

/* ── Voice button ──────────────────────────────────────────────────────────── */

.chat-voice-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  position: relative;
}
.chat-voice-btn:hover { color: var(--accent); background: var(--bg); }
.chat-voice-btn:active { transform: scale(0.92); background: var(--bg); }
.chat-voice-btn.recording {
  color: var(--color-danger);
  animation: pulse-voice 1s ease-in-out infinite;
}

.chat-voice-btn.uploading::after,
.chat-voice-btn.sent::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  pointer-events: none;
}

.chat-voice-btn.uploading::after {
  border: 2px solid rgba(77, 208, 225, 0.28);
  border-top-color: var(--color-upload);
  animation: spin-ring 0.9s linear infinite;
}

.chat-voice-btn.sent {
  color: var(--color-sent);
}

.chat-voice-btn.sent::after {
  border: 2px solid var(--color-sent);
  animation: sent-pop 0.45s ease-out;
}

@keyframes pulse-voice {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes spin-ring {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes sent-pop {
  0% { transform: scale(0.72); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Photo analysis spinner ─────────────────────────────────────────────────── */
.thinking-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(77,208,225,0.25);
  border-top-color: var(--color-upload);
  flex-shrink: 0;
  animation: spin-ring 0.8s linear infinite;
}

.thinking-timer {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ── Pipeline block tracker ────────────────────────────────────────────────── */
.pipeline-tracker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* На узких экранах не выходим за пределы пузыря */
  min-width: min(180px, 70vw);
}

.pipeline-block {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  transition: opacity 0.2s;
}

.pipeline-block.pending {
  opacity: 0.35;
}

.pipeline-block.skipped {
  opacity: 0.4;
}

.pipeline-block.done .pipeline-label {
  color: var(--text-muted);
}

.pipeline-block.active .pipeline-label {
  color: var(--accent);
  font-weight: 500;
}

.pipeline-meta-block {
  margin-top: 10px;
}

.pipeline-meta-title {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.pipeline-trace {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pipeline-stage-history .pipeline-trace {
  gap: 7px;
}

.pipeline-trace-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(124, 179, 66, 0.28);
  background: rgba(124, 179, 66, 0.12);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.pipeline-stage-chip {
  border-color: rgba(79, 140, 255, 0.28);
  background: rgba(79, 140, 255, 0.12);
}

.pipeline-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pipeline-icon .thinking-spinner {
  width: 14px;
  height: 14px;
}

.pipeline-icon .material-symbols-outlined {
  font-size: 16px;
  line-height: 1;
}

.pipeline-icon-done {
  color: var(--accent);
}

.pipeline-icon-skip {
  color: var(--text-muted);
  opacity: 0.5;
}

.pipeline-icon-pending {
  color: var(--text-muted);
  opacity: 0.3;
}

.pipeline-label {
  font-size: 12px;
  color: var(--text-secondary, var(--text-muted));
  white-space: nowrap;
}

/* Hide voice btn on desktop (hover-capable devices) */
@media (hover: hover) and (pointer: fine) {
  .chat-voice-btn { display: none; }
}

/* ── Photo preview ─────────────────────────────────────────────────────────── */

.chat-photo-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom)) 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
}
.chat-photo-preview.hidden { display: none; }
.chat-photo-preview img {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}
.photo-preview-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 10px 12px;
}
.photo-preview-close:hover { color: var(--text); }

/* ── Voice recording indicator ─────────────────────────────────────────────── */

.chat-voice-recording {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
}
.chat-voice-recording.hidden { display: none; }

.voice-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-danger);
  animation: pulse-voice 1s ease-in-out infinite;
}

.voice-timer {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.voice-cancel-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}
.voice-cancel-btn:hover { color: var(--color-danger); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  /* Mobile keyboard: align against visualViewport height set by JS */
  align-items: center;
}

/* Moderation modal overlay: JS управляет top/left/width/height через visualViewport */
#moderationModal {
  /* Сбрасываем inset чтобы JS смог перезаписать top/left/width/height */
  inset: auto;
  /* Начальные значения — при отсутствии visualViewport (десктоп) покрываем весь экран */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 600;
}

/* Moderation modal: compact, text-left */
.modal--moderation {
  text-align: left;
  padding: 16px 18px;
  max-width: 360px;
  width: calc(100% - 40px);
  max-height: calc(100% - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Плавное появление — JS управляет opacity через style, transition даёт анимацию */
  transition: opacity 0.15s ease;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 12px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.link-code {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent-light);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  font-family: monospace;
}

/* Link code container */
.link-code-container {
  background: var(--bg);
  border: 1px solid var(--accent-dark);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.link-code-label {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-copy-code {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-light);
  font-size: 13px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-copy-code:hover {
  border-color: var(--accent);
  background: var(--bg3);
}

.btn-copy-code.copied {
  background: var(--accent-dark);
  border-color: var(--accent);
  color: #fff;
}

/* Steps */
.link-steps {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  text-align: left;
}

.link-steps-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  margin-bottom: 10px;
}

.link-step-item {
  font-size: 13px;
  color: var(--text);
  padding: 4px 0;
  display: flex;
  gap: 8px;
  line-height: 1.5;
}

.link-step-num {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.btn-open-bot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dark);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 12px;
  margin-bottom: 14px;
  transition: background 0.15s;
  width: 100%;
  justify-content: center;
}

.btn-open-bot:hover { background: var(--accent); }

/* Waiting spinner */
.link-waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 14px;
}

.link-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-feedback {
  margin-top: 14px;
  font-size: 13px;
  min-height: 20px;
}

/* Feedback status */
.feedback-status { font-size: 13px; min-height: 18px; }
.feedback-status.ok { color: var(--accent-light); }
.feedback-status.error { color: var(--color-danger-muted); }

/* ── Sidebar overlay (mobile) ──────────────────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* На мобильных — более тонкий скроллбар, чтобы не занимал место */
@media (max-width: 480px) {
  ::-webkit-scrollbar { width: 3px; }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 680px) {
  html, body {
    overflow: hidden;
    width: 100%;
    height: 100%;
    height: 100dvh;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .sidebar-close { display: block; }

  .hamburger { display: flex; }

  .main-content {
    overflow: hidden;
    /* Гарантируем что main не раздвигается шире экрана */
    min-width: 0;
    max-width: 100vw;
  }

  /* Settings tab: скролл и нормальный padding на мобиле */
  #tab-settings {
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .tab-content { padding: 16px; }
  #tab-chat { padding: 0; }

  /* Profile form: одна колонка, поля не выезжают за экран */
  .form-grid {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
  }

  .form-group {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .form-group input,
  .form-group select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    /* Крупнее на мобиле чтобы iOS не зумил */
    font-size: 16px;
  }

  .form-actions {
    flex-wrap: wrap;
    gap: 10px;
  }

  .btn-primary {
    width: 100%;
    text-align: center;
  }

  /* Карточки: нет горизонтального переполнения */
  .card {
    padding: 14px;
    box-sizing: border-box;
    max-width: 100%;
    overflow: visible;
  }

  /* Channel items: кнопки не выезжают */
  .channel-item {
    gap: 8px;
    flex-wrap: nowrap;
  }

  .channel-info {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .channel-name,
  .channel-status {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .channel-actions {
    flex-shrink: 0;
  }

  .btn-link,
  .btn-unlink {
    padding: 7px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .chat-messages { padding: 12px 14px; }

  .chat-input-bar { flex-shrink: 0; }
}

/* ── Photo Lightbox ──────────────────────────────────────────────────────────── */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  /* iOS safe area — выступы экрана (чёлка, домашний индикатор) */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.photo-lightbox.hidden { display: none; }

.photo-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}

.photo-lightbox-img {
  position: relative;
  max-width: min(92vw, 900px);
  max-height: 88vh;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: lb-pop 0.18s ease-out;
  /* Разрешаем только pinch-zoom; вертикальный свайп обрабатывает наш JS */
  touch-action: pinch-zoom;
}
@keyframes lb-pop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.photo-lightbox-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  /* Учитываем safe-area: кнопки тулбара не должны скрываться под чёлкой */
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
}
.photo-lb-spacer { flex: 1; }
.photo-lb-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.32);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.photo-lb-btn:hover { background: rgba(0,0,0,0.6); }

/* ── Photo bubble (no background, like TG) ──────────────────────────────────── */
.msg-bubble-photo {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.msg-bubble-photo.has-time {
  padding-right: 0 !important;
  padding-bottom: 0 !important;
}

.msg-bubble-photo .msg-time-inside {
  right: 8px;
  bottom: 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
  border-radius: 10px;
  padding: 3px 6px;
  font-size: 10px;
  line-height: 1;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.msg-photo-thumb {
  display: block;
  max-width: 240px;
  max-height: 220px;
  width: 100%;
  border-radius: 14px;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.15s;
}
.msg-photo-thumb:active { opacity: 0.82; }

.msg-photo-caption {
  font-size: 13px;
  padding: 4px 2px 0;
  color: var(--text);
}

/* ── Email subject line ──────────────────────────────────────────────────────── */
.msg-email-subject {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
  margin-bottom: 5px;
}
.msg-email-subject .material-symbols-outlined {
  font-size: 14px;
  opacity: 0.7;
}

/* ── Photo lazy placeholder ──────────────────────────────────────────────────── */
.msg-photo-placeholder {
  max-width: min(200px, 55vw);
  width: 100%;
  height: 120px;
  box-sizing: border-box;
  border-radius: 14px;
  background: var(--bg);
  border: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.msg-photo-placeholder:hover { border-color: var(--accent); }

.msg-photo-placeholder.loaded-thumb {
  border: none;
}
.msg-photo-blur {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(8px);
  transform: scale(1.1);
}
.msg-photo-placeholder .msg-photo-dl-icon {
  font-size: 28px;
  opacity: 0.6;
  z-index: 1;
}
.msg-photo-placeholder.loaded-thumb .msg-photo-dl-icon {
  position: absolute;
  font-size: 24px;
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}
.msg-photo-dl-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Загрузка спиннер */
.msg-photo-placeholder.loading {
  border-color: var(--accent);
}
.msg-photo-placeholder.loading::after {
  content: '';
  position: absolute;
  width: 32px;
  height: 32px;
  border: 3px solid transparent;
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 2;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Загружено — без бордера */
.msg-photo-placeholder.loaded {
  width: auto;
  height: auto;
  border: none;
  background: transparent;
}

/* Date separators */
.date-sep {
  text-align: center;
  font-size: 12px;
  color: var(--muted, #888);
  margin: 12px 0 4px;
  padding: 2px 12px;
  user-select: none;
}
.date-sep span {
  background: var(--bg-secondary, rgba(0,0,0,0.05));
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
}

/* ── Related content cards ─────────────────────────────────────────────────── */
.related-content-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.related-content-block--articles {
  --related-section-accent: rgba(100, 181, 246, 0.42);
  --related-section-bg: rgba(100, 181, 246, 0.08);
}

.related-content-block--drugs {
  --related-section-accent: rgba(129, 199, 132, 0.42);
  --related-section-bg: rgba(129, 199, 132, 0.08);
}

.related-content-block--generic {
  --related-section-accent: rgba(255, 224, 130, 0.34);
  --related-section-bg: rgba(255, 224, 130, 0.08);
}

.related-content-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.related-content-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.related-content-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.related-content-block--articles .related-content-header,
.related-content-block--drugs .related-content-header,
.related-content-block--generic .related-content-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.related-content-block--articles .related-content-header::before,
.related-content-block--drugs .related-content-header::before,
.related-content-block--generic .related-content-header::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--related-section-accent, rgba(129, 199, 132, 0.42));
  box-shadow: 0 0 0 4px var(--related-section-bg, rgba(129, 199, 132, 0.08));
}

.related-content-block--articles .related-content-item,
.related-content-block--drugs .related-content-item,
.related-content-block--generic .related-content-item {
  background: linear-gradient(180deg, var(--related-section-bg, rgba(129, 199, 132, 0.08)), transparent 100%), var(--bg);
  border-color: var(--related-section-accent, var(--border));
}

.related-content-item--button {
  width: 100%;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  appearance: none;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.related-content-item--button:hover {
  transform: translateY(-1px);
  border-color: var(--related-section-accent, rgba(129, 199, 132, 0.45));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.related-content-item--button:active {
  transform: translateY(0);
}

.related-content-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 4px;
}

.related-content-type-icon {
  font-size: 14px;
  line-height: 1;
  color: inherit;
}

.related-content-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.related-content-title--link {
  color: var(--text);
  text-decoration: none;
}

.related-content-title--link:hover {
  text-decoration: underline;
}

.related-content-summary {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-content-cta {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.related-content-cta--link {
  text-decoration: none;
}

.related-content-cta--link:hover {
  text-decoration: underline;
}

.related-content-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 6px;
}

.related-content-meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(129, 199, 132, 0.12);
  border: 1px solid rgba(129, 199, 132, 0.28);
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
}

.related-content-meta-label {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.related-content-meta-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.related-content-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.related-content-source-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.related-content-source-link:hover {
  text-decoration: underline;
}

/* ── Content viewer ───────────────────────────────────────────────────────── */
.content-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 11, 7, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 24;
}

.content-viewer {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: min(560px, calc(100% - 24px));
  --content-viewer-header-space: 108px;
  --content-viewer-footer-space: 88px;
  --content-viewer-header-visibility: 1;
  --content-viewer-footer-visibility: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.26s ease, opacity 0.26s ease;
  z-index: 25;
}

.content-viewer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

body.content-viewer-open .content-viewer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.content-viewer-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: var(--content-viewer-header-space);
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg2) 94%, rgba(129, 199, 132, 0.16)), color-mix(in srgb, var(--bg2) 84%, transparent));
  backdrop-filter: blur(12px);
  overflow: hidden;
  opacity: var(--content-viewer-header-visibility, 1);
  transform: translateY(calc((1 - var(--content-viewer-header-visibility, 1)) * -100%));
  transition: opacity 0.08s linear, transform 0.08s linear, border-color 0.18s ease;
}

.content-viewer-back,
.content-viewer-source,
.content-viewer-favorite,
.content-viewer-bookmark,
.content-viewer-chat,
.content-viewer-discuss {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 11px;
  min-height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.content-viewer-back {
  width: 36px;
  min-width: 36px;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.content-viewer-back:hover,
.content-viewer-source:hover,
.content-viewer-favorite:hover,
.content-viewer-bookmark:hover,
.content-viewer-chat:hover,
.content-viewer-discuss:hover {
  border-color: rgba(129, 199, 132, 0.45);
}

.content-viewer-back:disabled,
.content-viewer-source[aria-disabled="true"],
.content-viewer-favorite:disabled,
.content-viewer-bookmark:disabled,
.content-viewer-chat:disabled,
.content-viewer-discuss:disabled,
.content-viewer-back.is-disabled,
.content-viewer-favorite.is-disabled,
.content-viewer-bookmark.is-disabled,
.content-viewer-chat.is-disabled,
.content-viewer-discuss.is-disabled {
  opacity: 0.58;
  cursor: default;
  border-color: var(--border);
}

.content-viewer-headcopy {
  min-width: 0;
  flex: 1;
}

.content-viewer-label {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(129, 199, 132, 0.12);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.content-viewer-title {
  margin-top: 3px;
  font-size: 16px;
  line-height: 1.28;
  font-weight: 700;
  color: var(--text);
}

.content-viewer-status {
  position: absolute;
  top: calc(var(--content-viewer-header-space) + 4px);
  left: 14px;
  right: 14px;
  z-index: 2;
  color: var(--text-muted);
  font-size: 12px;
}

.content-viewer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: calc(var(--content-viewer-header-space) + 8px) 14px calc(var(--content-viewer-footer-space) + 14px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.content-viewer-summary {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.content-viewer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  min-width: 0;
}

.content-viewer-meta-item {
  padding: 7px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 110px;
}

.content-viewer-meta-label {
  font-size: 10px;
  color: var(--text-muted);
}

.content-viewer-meta-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.content-viewer-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.62;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.content-viewer-placeholder {
  overflow: hidden;
}

.content-viewer-title.content-viewer-placeholder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content-viewer-meta.content-viewer-placeholder,
.content-viewer-body.content-viewer-placeholder {
  display: flex;
  flex-direction: column;
}

.content-viewer-meta.content-viewer-placeholder {
  gap: 8px;
  margin-bottom: 12px;
}

.content-viewer-skeleton-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.content-viewer-skeleton-line,
.content-viewer-skeleton-chip {
  display: block;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.14) 50%, rgba(255, 255, 255, 0.06) 100%);
  background-size: 220% 100%;
  animation: content-viewer-shimmer 1.35s ease-in-out infinite;
}

.content-viewer-skeleton-line {
  height: 12px;
}

.content-viewer-skeleton-line.is-short {
  width: 68%;
}

.content-viewer-skeleton-line.is-title {
  height: 14px;
}

.content-viewer-skeleton-line.is-title.is-short {
  width: 74%;
}

.content-viewer-skeleton-chip {
  height: 36px;
  width: 112px;
}

.content-viewer-skeleton-chip.is-wide {
  width: 148px;
}

@keyframes content-viewer-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.content-viewer-summary,
.content-viewer-body p,
.content-viewer-body li,
.content-viewer-body div,
.content-viewer-body span,
.content-viewer-body strong,
.content-viewer-body em,
.content-viewer-body b,
.content-viewer-body i {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.content-viewer-body > :first-child {
  margin-top: 0;
}

.content-viewer-body h1,
.content-viewer-body h2,
.content-viewer-body h3,
.content-viewer-body h4,
.content-viewer-body h5,
.content-viewer-body h6 {
  margin: 18px 0 8px;
  line-height: 1.3;
  color: var(--accent-light);
}

.content-viewer-body p,
.content-viewer-body ul,
.content-viewer-body ol,
.content-viewer-body blockquote,
.content-viewer-body picture,
.content-viewer-body img,
.content-viewer-body .card,
.content-viewer-body .alert,
.content-viewer-body .note,
.content-viewer-body .content-viewer-table-wrap {
  margin: 0 0 12px;
}

.content-viewer-body ul,
.content-viewer-body ol {
  padding-left: 20px;
}

.content-viewer-body li + li {
  margin-top: 8px;
}

.content-viewer-body a {
  color: var(--accent-light);
}

.content-viewer-body img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  display: block;
  border: 1px solid var(--border);
}

.content-viewer-body .content-viewer-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.content-viewer-body table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.content-viewer-body th,
.content-viewer-body td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}

.content-viewer-body .card,
.content-viewer-body .alert,
.content-viewer-body .note {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.content-viewer-body .text-muted,
.content-viewer-body .small {
  color: var(--text-muted);
}

.content-viewer-related {
  margin-top: 16px;
}

.content-viewer-error {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(239, 83, 80, 0.28);
  background: rgba(239, 83, 80, 0.08);
  color: var(--text);
}

.content-viewer-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: 8px;
  min-height: var(--content-viewer-footer-space);
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg2) 92%, transparent), var(--bg2) 28%);
  box-shadow: 0 -18px 28px rgba(6, 11, 7, 0.18);
  backdrop-filter: blur(12px);
  overflow: hidden;
  opacity: var(--content-viewer-footer-visibility, 1);
  transform: translateY(calc((1 - var(--content-viewer-footer-visibility, 1)) * 100%));
  transition: opacity 0.08s linear, transform 0.08s linear, border-color 0.18s ease;
}

.content-viewer-favorite {
  width: 36px;
  min-width: 36px;
  padding: 0;
}

.content-viewer-bookmark {
  min-width: 112px;
}

.content-viewer-favorite.is-active {
  color: var(--favorite-accent);
  background: var(--favorite-bg);
  border-color: var(--favorite-border);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.content-viewer-bookmark.is-active {
  color: var(--accent);
  background: rgba(129, 199, 132, 0.14);
  border-color: rgba(129, 199, 132, 0.42);
}

.content-viewer-bookmark.is-active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 24;
}

.content-viewer-bookmark.is-pending {
  opacity: 0.72;
}

.content-viewer-chat {
  min-width: 84px;
}

.content-viewer-discuss {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.content-viewer-discuss:hover {
  background: var(--accent-dark);
  border-color: transparent;
}

.content-viewer.content-viewer--chrome-hidden .content-viewer-header {
  border-bottom-color: transparent;
}

.content-viewer.content-viewer--chrome-hidden .content-viewer-footer {
  border-top-color: transparent;
}

@media (min-width: 981px) {
  .content-viewer {
    width: min(580px, 46%);
  }
}

@media (max-width: 980px) {
  .content-viewer {
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    --content-viewer-header-space: 100px;
    --content-viewer-footer-space: calc(84px + env(safe-area-inset-bottom));
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .content-viewer-header {
    padding-top: 10px;
  }

  .content-viewer-title {
    font-size: 16px;
  }

  .content-viewer-source {
    display: none;
  }

  .content-viewer-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .content-viewer-bookmark {
    min-width: 44px;
    padding: 0 11px;
  }

  .content-viewer-bookmark-label {
    display: none;
  }

  #materialsScrollTopBtn,
  #drugsScrollTopBtn {
    position: fixed;
    right: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    margin: 0;
    z-index: 30;
  }

  #contentViewer {
    --content-viewer-scrolltop-base: calc(20px + env(safe-area-inset-bottom));
    --content-viewer-scrolltop-range: 92px;
  }

  #contentViewerScrollTopBtn {
    position: absolute;
    right: 16px;
    bottom: var(--content-viewer-scrolltop-offset);
    margin: 0;
    z-index: 26;
  }
}

.favorites-card {
  gap: 12px;
}

.favorites-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.favorites-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.favorites-total {
  font-size: 13px;
  color: var(--text-muted);
}

.favorites-total strong {
  color: var(--text);
}

.favorites-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.favorites-filter-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.favorites-filter-btn span:last-child {
  color: var(--text);
}

.favorites-filter-btn.is-active {
  color: var(--accent-light);
  border-color: rgba(129, 199, 132, 0.45);
  background: rgba(129, 199, 132, 0.10);
}

.favorites-group {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  overflow: hidden;
}

.favorites-group summary {
  list-style: none;
}

.favorites-group summary::-webkit-details-marker {
  display: none;
}

.favorites-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}

.favorites-group-title-wrap,
.favorites-group-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.favorites-group-icon {
  color: var(--accent-light);
  font-size: 20px;
}

.favorites-group-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.favorites-group-count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg3);
  color: var(--text);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.favorites-group-chevron {
  color: var(--text-muted);
  transition: transform 0.18s ease;
}

.favorites-group[open] .favorites-group-header {
  border-bottom: 1px solid var(--border);
}

.favorites-group[open] .favorites-group-chevron {
  transform: rotate(180deg);
}

.favorites-list {
  display: flex;
  flex-direction: column;
}

.favorites-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: transparent;
}

.favorites-item:first-child {
  border-top: none;
}

.favorites-item-open {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.favorites-item:hover {
  background: var(--bg3);
}

.favorites-item-copy {
  flex: 1;
  min-width: 0;
}

.favorites-item-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.favorites-item-summary {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.favorites-item-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.favorites-item-remove {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--accent-light);
  cursor: pointer;
}

.favorites-item-remove:hover {
  background: rgba(76, 175, 80, 0.12);
}

.favorites-empty {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.materials-card {
  gap: 14px;
}

.materials-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(129, 199, 132, 0.16);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(129, 199, 132, 0.08), rgba(129, 199, 132, 0.03));
}

.materials-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.materials-source-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.materials-source-tabs .material-symbols-outlined {
  font-size: 16px;
}

.materials-toolbar-meta {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.catalog-search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.catalog-search-input:focus {
  border-color: var(--accent);
}

.materials-filter-btn {
  flex: 0 0 auto;
}

.materials-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.materials-feed-status {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed rgba(129, 199, 132, 0.24);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.materials-item {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.materials-item:hover {
  background: var(--bg3);
  border-color: rgba(129, 199, 132, 0.25);
  transform: translateY(-1px);
}

.materials-item.is-unread {
  border-color: rgba(129, 199, 132, 0.45);
  box-shadow: 0 0 0 1px rgba(129, 199, 132, 0.08) inset;
}

.materials-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.materials-item-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-light);
}

.materials-item-label .material-symbols-outlined {
  font-size: 18px;
}

.materials-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-light);
  box-shadow: 0 0 0 4px rgba(129, 199, 132, 0.14);
  flex: 0 0 auto;
}

.materials-item-title {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.materials-item-summary {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.materials-item-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .favorites-filter-btn {
    min-height: 32px;
    padding: 0 10px;
    font-size: 11px;
  }

  .favorites-group-header,
  .favorites-item {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ── Clarify quick-prompts (pipeline_clarify) ─────────────────────────── */
.clarify-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary, #f5f7fa);
  border-radius: 12px;
  margin: 8px 0;
}
.clarify-label {
  font-size: 13px;
  color: var(--text-secondary, #888);
  margin-bottom: 4px;
}
.clarify-btn {
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-primary, #222);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.clarify-btn:hover {
  background: var(--accent-light, #e8f4fd);
  border-color: var(--accent, #4a90e2);
}
