/* ==========================================================================
   Personal Telegram Archive - Mini App Design System
   Modern, cohesive Telegram Mini App UI inspired by reference layouts.
   ========================================================================== */

:root {
  color-scheme: dark;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-msg: 'Rubik', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', 'Segoe UI', Roboto, sans-serif;
  
  /* Color Palette - Dark Navy Foundation */
  --bg-base: #090e1a;
  --bg-gradient: radial-gradient(circle at 50% 0%, #162444 0%, #090e1a 75%);
  --surface: #121a2c;
  --surface-elevated: #18233a;
  --surface-hover: #1e2c48;
  --surface-active: #233454;
  --card-bg: #121a2c;
  --card-inner: #0e1524;
  
  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: #3b82f6;

  /* Typography */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverted: #090e1a;

  /* Vibrant Accents */
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --accent-text: #ffffff;
  --accent-subtle: rgba(59, 130, 246, 0.14);

  --cyan: #06b6d4;
  --cyan-subtle: rgba(6, 182, 212, 0.14);
  --cyan-text: #22d3ee;

  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.14);
  --success-text: #34d399;

  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.14);
  --warning-text: #fbbf24;

  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.14);
  --danger-text: #f87171;

  --purple: #8b5cf6;
  --purple-subtle: rgba(139, 92, 246, 0.14);
  --purple-text: #a78bfa;

  /* Sizing and Radii */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);

  --nav-height: 64px;
}

/* Telegram Theme Overrides & Light Mode */
body.light {
  color-scheme: light;
  --bg-base: #f4f6fa;
  --bg-gradient: radial-gradient(circle at 50% 0%, #e2e8f0 0%, #f4f6fa 75%);
  --surface: #ffffff;
  --surface-elevated: #f8fafc;
  --surface-hover: #f1f5f9;
  --surface-active: #e2e8f0;
  --card-bg: #ffffff;
  --card-inner: #f8fafc;

  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-hover: #cbd5e1;
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverted: #ffffff;

  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.2);
  --accent-text: #ffffff;
  --accent-subtle: rgba(37, 99, 235, 0.1);

  --cyan: #0891b2;
  --cyan-subtle: rgba(8, 145, 178, 0.1);
  --cyan-text: #0891b2;

  --success: #059669;
  --success-subtle: rgba(5, 150, 105, 0.1);
  --success-text: #059669;

  --warning: #d97706;
  --warning-subtle: rgba(217, 119, 6, 0.1);
  --warning-text: #b45309;

  --danger: #dc2626;
  --danger-subtle: rgba(220, 38, 38, 0.1);
  --danger-text: #dc2626;

  --purple: #7c3aed;
  --purple-subtle: rgba(124, 58, 237, 0.1);
  --purple-text: #7c3aed;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
}

/* Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--tg-theme-bg-color, var(--bg-base));
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--tg-theme-text-color, var(--text-primary));
  min-height: var(--tg-viewport-stable-height, 100dvh);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Allow text selection inside message bubbles, inputs, and diffs */
.msg-text, .diff-text, input, textarea, select {
  user-select: text;
  -webkit-user-select: text;
}

/* Shell Layout */
.shell {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: calc(14px + var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 0px))) 16px calc(var(--nav-height) + 28px + max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px)));
  min-height: var(--tg-viewport-stable-height, 100dvh);
  display: flex;
  flex-direction: column;
}

/* Focus Visibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Typography Helpers */
h1, h2, h3, h4, p {
  margin: 0;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin-bottom: 4px;
}

.page-header {
  margin: 4px 0 20px;
}

.page-title {
  font-size: clamp(24px, 6vw, 30px);
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 12px;
  gap: 12px;
}

.section-title h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.section-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s ease;
}

.text-link-btn:hover {
  opacity: 0.8;
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* Demo Strip */
.demo-strip {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(59, 130, 246, 0.08) 100%);
  border: 1px dashed rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.demo-strip-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-text);
}

.demo-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 8px var(--purple);
  animation: pulse-dot 2s infinite;
}

.demo-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.demo-select {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.demo-note {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* Hero Profile Block (Home Page) */
.hero-profile {
  margin-bottom: 16px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--accent) 100%);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.avatar--sm {
  width: 40px;
  height: 40px;
  font-size: 17px;
}

.profile-details {
  flex: 1;
  min-width: 0;
}

.profile-greeting {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.role-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.role--owner {
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.role--member {
  background: var(--purple-subtle);
  color: var(--purple-text);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Status Banner (Inspired by Reference Screenshot 3) */
.status-banner {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.status-banner.is-connected {
  background: linear-gradient(135deg, #132238 0%, #172c49 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

body.light .status-banner.is-connected {
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-banner.is-disconnected {
  background: linear-gradient(135deg, #241c2c 0%, #2f213b 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

body.light .status-banner.is-disconnected {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.pulse-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.pulse--green {
  background: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pulse--amber {
  background: var(--warning-subtle);
  color: var(--warning-text);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.pulse--green .pulse-dot {
  animation: pulse-dot 2s infinite;
}

.status-heartbeat {
  font-size: 11px;
  font-weight: 600;
}

.heartbeat--online {
  color: var(--success-text);
}

.heartbeat--offline {
  color: var(--text-muted);
}

.status-banner-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.status-banner-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

@media (min-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 82px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  border-color: var(--border-hover);
}

.stat-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.stat-icon {
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-card--accent .stat-icon { color: var(--accent); }
.stat-card--danger .stat-icon { color: var(--danger-text); }
.stat-card--purple .stat-icon { color: var(--purple-text); }
.stat-card--cyan .stat-icon { color: var(--cyan-text); }
.stat-card--warning .stat-icon { color: var(--warning-text); }

/* Message Card (Архив и Главная) */
.msg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
  overflow-wrap: anywhere;
}

.msg-card:hover {
  border-color: var(--border-hover);
}

.msg-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.msg-meta {
  flex: 1;
  min-width: 0;
}

.msg-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.msg-chat-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.msg-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.kind--saved {
  background: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.kind--edited {
  background: var(--purple-subtle);
  color: var(--purple-text);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.kind--deleted {
  background: var(--danger-subtle);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.msg-submeta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.msg-dot {
  opacity: 0.6;
}

.star-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.star-btn:hover {
  color: var(--warning-text);
}

.star-btn.is-starred {
  color: var(--warning);
}

.star-btn.star-pop {
  animation: starPop 0.32s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes starPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.38); }
  100% { transform: scale(1); }
}

.msg-bubble {
  background: rgba(255, 255, 255, 0.038);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px 14px 14px 4px;
  padding: 13px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

body.light .msg-bubble {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.msg-text {
  font-family: var(--font-msg);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}

/* Media Attachments */
.msg-media-photo {
  margin: 10px 0 12px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.photo-container {
  position: relative;
  cursor: pointer;
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.photo-container:hover {
  transform: scale(1.008);
  box-shadow: var(--shadow-md);
}

.chat-photo-img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md);
}

.photo-overlay {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.2s ease;
}

.photo-zoom-icon {
  display: grid;
  place-items: center;
}

/* Audio & Voice Player */
.msg-audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 10px 0 12px;
  transition: border-color 0.15s ease;
}

body.light .msg-audio-player {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.audio-play-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #ffffff;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 10px var(--accent-glow);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.audio-play-btn:hover {
  transform: scale(1.06);
}

.audio-play-btn.is-playing {
  background: var(--purple);
  box-shadow: 0 2px 10px var(--purple-subtle);
}

.audio-play-btn.sm {
  width: 30px;
  height: 30px;
}

.audio-player-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.audio-waveform-track {
  cursor: pointer;
  padding: 4px 0;
  touch-action: manipulation;
}

.audio-waveform-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 26px;
}

.wf-bar {
  flex: 1;
  min-width: 2px;
  max-width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

body.light .wf-bar {
  background: rgba(15, 23, 42, 0.2);
}

.wf-bar.is-played {
  background: var(--accent);
  transform: scaleY(1.08);
}

body.light .wf-bar.is-played {
  background: var(--accent);
}

.audio-info-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.audio-timer {
  font-weight: 600;
  color: var(--text-primary);
}

.audio-divider {
  opacity: 0.5;
}

.audio-duration {
  color: var(--text-secondary);
}

.audio-kind-pill {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-text);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

/* Video Notes (Кружочки) */
.msg-video-note-wrap {
  margin: 10px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.video-note-circle {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  border: 3px solid rgba(139, 92, 246, 0.4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.chat-video-note {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-note-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--purple-text);
  background: var(--purple-subtle);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.video-note-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple);
  animation: pulse-dot 1.5s infinite;
}

/* Videos */
.msg-media-video {
  margin: 10px 0 12px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  max-height: 380px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.chat-video {
  width: 100%;
  max-height: 380px;
  display: block;
  border-radius: var(--radius-md);
}

/* Documents */
.msg-media-doc {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  margin: 10px 0 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

body.light .msg-media-doc {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.doc-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--purple-subtle);
  color: var(--purple-text);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.doc-icon-badge.sm {
  width: 26px;
  height: 26px;
}

.doc-info-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-size {
  font-size: 11px;
  color: var(--text-muted);
}

.doc-dl-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.doc-dl-btn:hover {
  background: var(--accent);
  color: #ffffff;
  transform: scale(1.05);
}

.doc-dl-btn.sm {
  width: 28px;
  height: 28px;
}

/* Chat Filter Carousel */
.chats-carousel-section {
  margin-bottom: 14px;
}

.carousel-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  padding: 0 2px;
}

.carousel-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.clear-chat-btn {
  background: transparent;
  border: none;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 6px;
}

.clear-chat-btn:hover {
  text-decoration: underline;
}

.carousel-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.carousel-nav-arrows {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.carousel-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.carousel-arrow-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.carousel-arrow-btn:active {
  transform: scale(0.92);
}

body.light .carousel-arrow-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
}

body.light .carousel-arrow-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.15);
}

.chats-chips-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.chats-chips-carousel.is-dragging {
  cursor: grabbing;
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .chats-chips-carousel::-webkit-scrollbar {
    height: 5px;
  }
  .chats-chips-carousel::-webkit-scrollbar-track {
    background: transparent;
  }
  .chats-chips-carousel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
  }
  .chats-chips-carousel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
  }
  body.light .chats-chips-carousel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
  }
}

@media (max-width: 480px) {
  .chats-chips-carousel::-webkit-scrollbar {
    display: none;
  }
}

.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.chat-chip:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.chat-chip.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.chat-chip-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.chat-chip-count {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* Lightbox Modal */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.lightbox-backdrop.is-active {
  display: flex;
  opacity: 1;
}

.lightbox-dialog {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-close-btn {
  position: absolute;
  top: -44px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.lightbox-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-body {
  max-width: 100%;
  max-height: calc(90vh - 50px);
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

.lightbox-img {
  max-width: 100%;
  max-height: calc(90vh - 50px);
  object-fit: contain;
  display: block;
}

.lightbox-caption {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Timeline Media Snippets */
.timeline-media-photo {
  margin: 6px 0 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  max-width: 240px;
}

.timeline-photo-img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm);
}

.timeline-media-audio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(59, 130, 246, 0.1);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  margin: 6px 0 8px;
}

.timeline-media-doc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  margin: 6px 0 8px;
}

.msg-media-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--purple-subtle);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--purple-text);
  font-weight: 600;
}

.msg-media-banner.compact {
  margin-top: 8px;
  margin-bottom: 0;
}

.media-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(139, 92, 246, 0.2);
  padding: 2px 5px;
  border-radius: 4px;
}

.msg-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Pill Buttons */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 36px;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.pill-btn:active {
  transform: scale(0.96);
}

.pill-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.pill-btn.primary {
  background: var(--tg-theme-button-color, var(--accent));
  color: var(--tg-theme-button-text-color, var(--accent-text));
  border: none;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.pill-btn.primary:hover {
  filter: brightness(1.08);
}

.pill-btn.secondary {
  background: var(--surface-elevated);
  border-color: var(--border);
  color: var(--text-primary);
}

.pill-btn.secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.pill-btn.danger {
  background: var(--danger-subtle);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger-text);
}

.pill-btn.danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

.pill-btn.large {
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
  min-height: 46px;
}

/* Archive Search & Filters */
.search-panel {
  margin-bottom: 16px;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 6px 4px 14px;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.search-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.search-icon {
  color: var(--text-muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  padding: 6px 0;
  min-width: 0;
}

.search-submit-btn {
  padding: 6px 14px;
  min-height: 32px;
  font-size: 12px;
}

.dates-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.date-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 130px;
}

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

.date-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 8px;
  outline: none;
  min-width: 0;
}

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

/* Filter Chips Carousel */
.filter-chips-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.filter-chips-carousel.is-dragging {
  cursor: grabbing;
  user-select: none;
}

@media (min-width: 540px) {
  .filter-chips-carousel {
    flex-wrap: wrap;
    overflow-x: visible;
    cursor: default;
  }
}

@media (hover: hover) and (pointer: fine) {
  .filter-chips-carousel::-webkit-scrollbar {
    height: 5px;
  }
  .filter-chips-carousel::-webkit-scrollbar-track {
    background: transparent;
  }
  .filter-chips-carousel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
  }
  .filter-chips-carousel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
  }
  body.light .filter-chips-carousel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
  }
}

@media (max-width: 480px) {
  .filter-chips-carousel::-webkit-scrollbar {
    display: none;
  }
}

.filter-chip {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 7px 15px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.filter-chip.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin: 18px 0;
}

.load-more-btn {
  padding: 10px 24px;
}

/* Settings Grouped Lists (Screenshot 1 & 2 Style) */
.settings-group {
  margin-bottom: 22px;
}

.group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 4px;
}

.grouped-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-inner-padded {
  padding: 16px;
}

.action-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 14px;
}

.action-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.icon--accent { background: var(--accent-subtle); color: var(--accent); }
.icon--purple { background: var(--purple-subtle); color: var(--purple-text); }
.icon--cyan { background: var(--cyan-subtle); color: var(--cyan-text); }

.action-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.action-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.action-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.privacy-status-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.privacy-level-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--card-inner);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.privacy-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.status-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.status-pill--muted { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.status-pill--cyan { background: var(--cyan-subtle); color: var(--cyan-text); }
.status-pill--purple { background: var(--purple-subtle); color: var(--purple-text); }
.status-pill--success { background: var(--success-subtle); color: var(--success-text); }
.status-pill--danger { background: var(--danger-subtle); color: var(--danger-text); }
.status-pill--accent { background: var(--accent-subtle); color: var(--accent); }

.form-field {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.styled-select {
  width: 100%;
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.styled-select:focus {
  border-color: var(--accent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.audit-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
  background: var(--card-inner);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.notice-bullet {
  color: var(--accent);
  font-weight: 800;
}

/* Modern iOS / Telegram Style Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--surface-active);
  border: 1px solid var(--border);
  transition: 0.2s ease;
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

input:checked + .slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

input:focus-visible + .slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Family (Семья) Screen */
.family-top-action {
  margin-bottom: 18px;
}

.invite-container {
  margin-bottom: 16px;
}

.invite-card {
  background: var(--surface);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.invite-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.invite-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.invite-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.invite-header small {
  font-size: 12px;
  color: var(--text-muted);
}

.copy-field {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.styled-input {
  flex: 1;
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  min-width: 0;
}

.invite-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.count-badge {
  font-size: 12px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.family-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.family-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.family-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.family-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.family-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.family-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.access-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.badge--muted { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.badge--cyan { background: var(--cyan-subtle); color: var(--cyan-text); }
.badge--purple { background: var(--purple-subtle); color: var(--purple-text); }

.family-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: var(--card-inner);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  margin-bottom: 12px;
}

.family-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.family-private-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-inner);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

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

/* History Comparison Modal («Было / Стало») */
.history-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.dialog-title-row h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.badge-pill {
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 6px;
  width: 2px;
  background: var(--border);
}

.timeline-step {
  position: relative;
}

.timeline-marker {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  z-index: 1;
}

.timeline-content {
  background: var(--card-inner);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
}

.diff-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diff-block {
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
}

.diff-before {
  background: var(--danger-subtle);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.diff-before .diff-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--danger-text);
  margin-bottom: 2px;
}

.diff-after {
  background: var(--success-subtle);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.diff-after .diff-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--success-text);
  margin-bottom: 2px;
}

.diff-text {
  font-family: var(--font-msg);
  font-size: 14.5px;
  font-weight: 450;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: -0.01em;
}

.timeline-bubble {
  font-family: var(--font-msg);
  font-size: 15px;
  font-weight: 450;
  line-height: 1.52;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Access Log Modal */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  max-height: 60vh;
  overflow-y: auto;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--card-inner);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.log-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.log-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.log-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.log-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.empty-log-text {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

/* Empty States */
.empty-view {
  text-align: center;
  padding: 36px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: 12px 0;
}

.empty-graphic {
  width: 140px;
  height: 110px;
  max-width: 100%;
  margin: 0 auto 16px;
  display: block;
}

.empty-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 360px;
  margin: 0 auto 16px;
}

/* Modal Dialog */
dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: 85dvh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text-primary);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  margin: auto;
}

dialog::backdrop {
  background: rgba(5, 11, 24, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-top-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.close-dialog-btn {
  background: var(--card-inner);
  border: 1px solid var(--border);
}

/* Floating Docked Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: max(10px, env(safe-area-inset-bottom, 10px));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 520px);
  height: var(--nav-height);
  background: rgba(18, 26, 44, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px 6px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

body.light .bottom-nav {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  padding: 6px 4px;
  gap: 3px;
  min-height: 48px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab:active {
  transform: scale(0.92);
}

.nav-tab-icon {
  display: grid;
  place-items: center;
  line-height: 1;
}

.nav-tab-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.nav-tab[aria-current="page"] {
  color: #fff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35) 0%, rgba(139, 92, 246, 0.35) 100%);
}

body.light .nav-tab[aria-current="page"] {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.12);
}

/* Toast Floating Notification */
#toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 24px + max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px)));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Skeleton Loading Shimmer */
.skeleton-card {
  height: 110px;
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-hover) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Animations */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

main {
  animation: fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Scrollbar Button Suppression */
.chats-chips-carousel::-webkit-scrollbar-button,
.filter-chips-carousel::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Card Selection Mode */
.msg-card.is-selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

.is-select-mode .msg-card {
  position: relative;
  padding-left: 48px;
  cursor: pointer;
}

.card-select-checkbox {
  position: absolute;
  top: 18px;
  left: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  z-index: 2;
  color: #fff;
}

.card-select-checkbox:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.card-select-checkbox.is-checked {
  background: var(--accent);
  border-color: var(--accent);
}

.card-select-checkbox .custom-check-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
}

/* Archive Actions Bar */
.archive-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 12px;
  padding: 0 2px;
}

.archive-bar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.select-toggle-btn {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Floating Multi-Select Action Bar */
.floating-selection-bar {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 560px;
  background: rgba(18, 24, 38, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 1000;
  animation: slideUpBar 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

body.light .floating-selection-bar {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

@keyframes slideUpBar {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.selection-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.selection-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Icon Buttons & Card Action More */
.pill-btn.icon-btn {
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Sheet Menu for Card Options */
.sheet-menu-container {
  padding: 4px 0 6px;
}

.sheet-header {
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sheet-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sheet-action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  color: var(--text-primary);
}

.sheet-action-item:hover {
  background: var(--surface-hover);
}

.sheet-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  flex-shrink: 0;
}

.sheet-action-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sheet-action-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.sheet-action-desc {
  font-size: 11.5px;
  color: var(--text-muted);
}

.sheet-action-item.danger-action-item .sheet-action-icon {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.sheet-action-item.danger-action-item .sheet-action-label {
  color: var(--danger);
}

[hidden] {
  display: none !important;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
