/* ============================================
   AI Pulse — Apple-style design
   ============================================ */

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

:root {
  /* Light theme — Apple vibe */
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --bg-sidebar: rgba(255, 255, 255, 0.72);
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 0, 0, 0.08);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --grad-1: #667eea;
  --grad-2: #764ba2;
  --grad-3: #f093fb;
  --grad-4: #4facfe;
  --success: #34c759;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --sidebar-w: 260px;
  --transition: 240ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #1c1c1e;
  --bg-sidebar: rgba(28, 28, 30, 0.78);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;
  --accent: #0a84ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a { color: inherit; text-decoration: none; }
input { font-family: inherit; }

/* ============== Layout ============== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  width: 100vw;
}

/* ============== Sidebar ============== */
.sidebar {
  background: var(--bg-sidebar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.logo-beta {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-transform: lowercase;
  margin-top: 1px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { background: var(--bg-active); transform: scale(0.96); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.nav-section { margin-bottom: 18px; }

.nav-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: 6px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--bg-active); color: var(--accent); }
.nav-item svg { color: inherit; flex-shrink: 0; }

/* Отключённый раздел — серый, без hover-эффекта, не реагирует на клик */
.nav-item.disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.8);
}
.nav-item.disabled:hover { background: transparent; }
.nav-item.disabled .nav-icon { filter: grayscale(1); }
.nav-item.disabled .nav-count { display: none; }

/* Расширенный nav с иконкой + подзаголовком (для разделов) */
.nav-item .nav-icon {
  font-size: 18px;
  line-height: 1;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item .nav-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.nav-item .nav-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}
.nav-item .nav-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item.active .nav-sub { color: var(--accent); opacity: 0.7; }
.nav-item .nav-count {
  font-size: 10.5px;
  color: var(--text-tertiary);
  background: var(--bg-active);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item.active .nav-count {
  background: var(--accent);
  color: white;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.source-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.source-item:hover { background: var(--bg-hover); color: var(--text); }
.source-item .src-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad-1);
}
.source-item .src-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-active);
  padding: 1px 7px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  transition: var(--transition);
}
.user-card:hover { background: var(--bg-hover); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2));
  color: white; font-weight: 600;
  display: grid; place-items: center;
  font-size: 13px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-status { font-size: 11px; color: var(--text-tertiary); }

/* ============== Main ============== */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  height: 56px;
  flex-shrink: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  width: 360px;
  max-width: 50%;
  transition: var(--transition);
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}
.search-box svg { color: var(--text-tertiary); flex-shrink: 0; }
.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}
.search-box input::placeholder { color: var(--text-tertiary); }
.kbd {
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-active);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.btn-ghost {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-secondary);
  transition: var(--transition);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }

/* ============== Content ============== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 60px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* ============== Hero ============== */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 36px 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: white;
  overflow: hidden;
  margin-bottom: 36px;
  box-shadow: var(--shadow-md);
  transition: background 600ms ease;
}

.hero--ai {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.hero--freeai {
  background: linear-gradient(135deg, #134e5e 0%, #71b280 100%);
}

.hero--design {
  background: linear-gradient(135deg, #2d1b69 0%, #5b2c87 50%, #8e44ad 100%);
}

.hero--aivideo {
  background: linear-gradient(135deg, #1a0b2e 0%, #5b2c87 35%, #ff5e5e 75%, #ff9a00 100%);
}

.hero--oilgas {
  background: linear-gradient(135deg, #0a1a2a 0%, #1f3a5f 35%, #5c7c00 70%, #c9a227 100%);
}

.hero--ru {
  background: linear-gradient(135deg, #0a1929 0%, #0d2b4f 35%, #1e4d8c 70%, #2e6fb5 100%);
}

.hero--world {
  background: linear-gradient(135deg, #0a0a1a 0%, #1a1f3a 35%, #2e3a5f 70%, #4a5c8c 100%);
}

.hero--fashion {
  background: linear-gradient(135deg, #2a0a1a 0%, #8e1f5a 35%, #c2185b 70%, #d4af37 100%);
}

.hero--interior {
  background: linear-gradient(135deg, #2c2416 0%, #6b4f2a 35%, #a67c52 70%, #d4b896 100%);
}

.hero-content { position: relative; z-index: 2; max-width: 60%; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 16px;
}

.pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(52, 199, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}

.hero h1 {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 12px;
}

.grad-text {
  background: linear-gradient(90deg, #f093fb, #4facfe, #43e97b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 200% 200%;
  animation: gradMove 6s ease infinite;
}
@keyframes gradMove {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero p {
  font-size: 16px;
  line-height: 1.5;
  opacity: 0.85;
  margin-bottom: 24px;
  font-weight: 400;
}

.hero-stats { display: flex; gap: 36px; }
.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.04em; }

/* Hero orbs */
.hero-visual { position: absolute; right: -20px; top: 0; bottom: 0; width: 50%; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.6;
  animation: float 12s ease-in-out infinite;
}
.orb-1 { width: 200px; height: 200px; background: #667eea; top: 20%; right: 30%; }
.orb-2 { width: 150px; height: 150px; background: #f093fb; bottom: 10%; right: 10%; animation-delay: -4s; }
.orb-3 { width: 180px; height: 180px; background: #4facfe; top: 50%; right: 50%; animation-delay: -8s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.05); }
  66% { transform: translate(-15px, 15px) scale(0.95); }
}

/* ============== Loading ============== */
.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state h3 { font-size: 16px; margin-bottom: 4px; color: var(--text); }
.loading-state p { font-size: 13px; }

/* ============== Articles grid ============== */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.article-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Картинка превью (опционально) */
.article-image {
  margin: -20px -20px 14px;
  height: 160px;
  background: linear-gradient(135deg, var(--bg-active), var(--bg-hover));
  overflow: hidden;
  position: relative;
}
.article-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.04));
  pointer-events: none;
}
.article-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}
.article-card:hover .article-image img { transform: scale(1.04); }
.article-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, linear-gradient(90deg, var(--grad-1), var(--grad-2)));
  opacity: 0;
  transition: opacity var(--transition);
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.article-card:hover::before { opacity: 1; }

.article-source {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--bg-active);
  border-radius: 6px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.01em;
}
.source-badge .src-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--src-color, var(--grad-1));
}
.article-date { color: var(--text-tertiary); font-size: 11.5px; }

.article-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.article-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-active);
  color: var(--text-secondary);
  font-weight: 500;
}

.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
}
.read-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 500;
  transition: gap var(--transition);
}
.article-card:hover .read-more { gap: 8px; }

.translated-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--success);
  font-weight: 500;
}
.translated-badge svg { width: 12px; height: 12px; }

/* ============== Empty state ============== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }

/* ============== Modal ============== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 240ms ease;
}
.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.modal {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 320ms cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.modal-body {
  overflow-y: auto;
  padding: 32px 40px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.modal-body h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 14px;
  color: var(--text);
}

.modal-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.modal-info .dot { color: var(--text-tertiary); }

.modal-summary {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
  border-left: 3px solid var(--grad-1);
  padding: 16px 18px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 24px;
  font-weight: 500;
}

.modal-content {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
}
.modal-content p { margin-bottom: 16px; }
.modal-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 28px 0 12px;
  letter-spacing: -0.01em;
}
.modal-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 20px 0 8px;
}
.modal-content ul, .modal-content ol { padding-left: 24px; margin-bottom: 16px; }
.modal-content li { margin-bottom: 6px; }
.modal-content code {
  font-family: "SF Mono", Menlo, monospace;
  background: var(--bg-active);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.modal-content blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  padding: 10px 16px;
  background: var(--bg-active);
  color: var(--accent);
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  transition: var(--transition);
}
.modal-link:hover { background: var(--accent); color: white; }

.modal-original {
  font-size: 13px;
  color: var(--text-tertiary);
  font-style: italic;
  margin: -8px 0 16px;
  padding: 8px 12px;
  background: var(--bg-active);
  border-radius: 8px;
  border-left: 2px solid var(--border-strong);
}

.modal-loader {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.modal-loader .spinner {
  margin: 0 auto 12px;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.modal-loader p { font-size: 13px; }

.modal-date {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: 4px;
}

.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.error-state code {
  font-family: "SF Mono", Menlo, monospace;
  background: var(--bg-active);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.muted { color: var(--text-tertiary); font-style: italic; }
.error { color: #ff453a; }

/* ============== Add source button ============== */
.add-source-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 16px);
  margin: 8px 8px 0;
  padding: 8px 12px;
  background: var(--bg-active);
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  transition: var(--transition);
  border: 1px dashed transparent;
}
.add-source-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent);
}
.add-source-btn svg { flex-shrink: 0; }

/* ============== Add modal ============== */
.add-modal {
  max-width: 560px;
}
.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-title-row h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: grid; place-items: center;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.modal-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: var(--bg-active);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.section-picker {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.section-opt {
  padding: 10px 8px;
  background: var(--bg-active);
  color: var(--text);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  transition: var(--transition);
  border: 1.5px solid transparent;
}
.section-opt:hover { background: var(--bg-hover); }
.section-opt.active {
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent);
  border-color: var(--accent);
}

.input-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.input-row input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-active);
  border: 1.5px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.input-row input:focus {
  background: var(--bg-elev);
  border-color: var(--accent);
}
.input-row input::placeholder { color: var(--text-tertiary); }

.input-row .btn-ghost {
  width: 40px;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  background: var(--bg-elev);
}
.input-row .btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rss-status {
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}
.rss-status.ok { color: var(--success); }
.rss-status.err { color: #ff453a; }
.rss-status.loading { color: var(--text-tertiary); }

.form-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--bg-active);
  border-radius: 10px;
  margin-bottom: 16px;
  animation: slideDown 280ms ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.form-row .form-group { margin-bottom: 0; }
.form-row input {
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.form-row input:focus { border-color: var(--accent); }

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent, #667eea);
}

.checkbox-label:hover { color: var(--text-primary); }
.color-opt {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}
.color-opt:hover { transform: scale(1.1); }
.color-opt.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg-elev) inset;
}

.rss-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-active);
  padding: 4px;
  border-radius: 10px;
}
.rss-tab {
  padding: 9px 8px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.rss-tab:hover { color: var(--text); }
.rss-tab.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.discover-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.discover-results:empty { display: none; }
.discover-card {
  padding: 12px 14px;
  background: var(--bg-active);
  border-radius: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.discover-card:hover {
  background: var(--bg-elev);
  border-color: var(--border-strong);
}
.discover-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.discover-card-title .src-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.discover-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}
.discover-card-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  align-items: center;
}
.discover-card-meta .badge {
  padding: 2px 6px;
  background: rgba(52, 199, 89, 0.15);
  color: var(--success);
  border-radius: 4px;
  font-weight: 600;
}
.discover-card-meta .badge.path {
  background: rgba(0, 113, 227, 0.12);
  color: var(--accent);
}
.discover-card-url {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: ui-monospace, SFMono-Regular, monospace;
  word-break: break-all;
}
.discover-card-samples {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.discover-empty {
  padding: 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-tertiary);
  background: var(--bg-active);
  border-radius: 10px;
}

.rss-preview {
  background: var(--bg-active);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: none;
}
.rss-preview.show { display: block; }
.rss-preview-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.rss-preview-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.rss-preview-samples {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-tertiary);
}
.rss-preview-samples li {
  padding-left: 12px;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rss-preview-samples li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: bold;
}

.user-sources-list {
  margin-bottom: 16px;
}
.user-sources-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.user-source-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-active);
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}
.user-source-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.user-source-name { flex: 1; }
.user-source-remove {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-tertiary);
  transition: var(--transition);
}
.user-source-remove:hover { background: #ff453a; color: white; }

.user-sources-empty {
  color: var(--text-secondary, #999);
  font-size: 13px;
  text-align: center;
  padding: 16px 8px;
  line-height: 1.5;
}

.bundle-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
  margin-top: 12px;
  border-top: 1px dashed var(--border);
}
.bundle-bar-label {
  font-size: 12px;
  color: var(--text-secondary, #999);
  margin-right: 4px;
}
.bundle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-active, rgba(0,0,0,0.04));
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.bundle-btn:hover { background: var(--bg-hover, rgba(0,0,0,0.08)); }
.bundle-btn:active { transform: scale(0.97); }
.bundle-btn svg { opacity: 0.7; }

.bundle-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.bundle-toast.show { opacity: 1; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ============================================
   Splash (full-screen first-load) + overlay (subsequent loads)
   ============================================ */
.splash {
  display: none; /* показывается через .show */
  position: fixed;
  inset: 0;
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 600px at 20% -10%, rgba(102,126,234,0.18), transparent 60%),
    radial-gradient(800px 600px at 100% 100%, rgba(118,75,162,0.18), transparent 60%),
    var(--bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: splashIn 0.35s ease;
}
.splash.hide { animation: splashOut 0.45s ease forwards; pointer-events: none; }
.splash.show { display: flex !important; }
@keyframes splashIn { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }
@keyframes splashOut { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }

/* Пока splash на экране — прячем всё остальное, чтобы "Ничего не нашлось" не моргало */
body.preload .app > *:not(.splash) { visibility: hidden; }

.splash-card {
  width: min(100%, 520px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 20px);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  text-align: center;
}
.splash-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}
.splash-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.splash-status {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  min-height: 20px;
}
.splash-progress {
  width: 100%;
  height: 6px;
  background: var(--bg-active);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 24px;
}
.splash-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--grad-1), var(--grad-2), var(--grad-3));
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer { from { background-position: 0% 0; } to { background-position: 200% 0; } }

.splash-tips {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  margin-bottom: 20px;
}
.splash-tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg-active);
  border-radius: var(--radius-sm, 10px);
  opacity: 0;
  transform: translateY(8px);
  animation: tipIn 0.4s ease forwards;
}
.splash-tip:nth-child(1) { animation-delay: 0.1s; }
.splash-tip:nth-child(2) { animation-delay: 0.25s; }
.splash-tip:nth-child(3) { animation-delay: 0.4s; }
@keyframes tipIn { to { opacity: 1; transform: none; } }
.splash-tip-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.25);
  position: relative;
  overflow: hidden;
}
.splash-tip-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 60%);
  pointer-events: none;
}
.splash-tip-icon svg { position: relative; z-index: 1; }
.splash-tip-icon--blue {
  background: linear-gradient(135deg, #4facfe 0%, #00c6ff 100%);
}
.splash-tip-icon--purple {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.splash-tip-icon--green {
  background: linear-gradient(135deg, #34c759 0%, #1f8a3e 100%);
}
.splash-tip-text { font-size: 13px; color: var(--text); line-height: 1.4; }
.splash-tip-text b { font-weight: 600; }
.splash-footer {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Маленький полупрозрачный оверлей при обновлении раздела — отключён, использовался только первые итерации */
.refreshing-overlay { display: none !important; }

/* Шеринг-бар в модалке статьи — в стиле iOS Share Sheet */
.share-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 18px 0 22px;
  padding: 18px 14px 14px;
  background: linear-gradient(180deg, var(--bg-active, rgba(0,0,0,0.03)), transparent);
  border-radius: var(--radius-lg, 20px);
  border: 1px solid var(--border);
}
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 72px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.share-btn:hover { transform: translateY(-2px); }
.share-btn:active { transform: translateY(0) scale(0.96); }

.share-btn-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  color: white;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.25);
  position: relative;
  overflow: hidden;
}
.share-btn-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 60%);
  pointer-events: none;
}
.share-btn-icon svg { position: relative; z-index: 1; }

/* Фирменные градиенты */
.share-btn--telegram .share-btn-icon {
  background: linear-gradient(135deg, #37BBFE 0%, #007DBB 100%);
}
.share-btn--email .share-btn-icon {
  background: linear-gradient(135deg, #FF8A65 0%, #FF5722 100%);
}
.share-btn--save .share-btn-icon {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.share-btn--copy .share-btn-icon {
  background: linear-gradient(135deg, #34c759 0%, #1f8a3e 100%);
  transition: background 0.2s, transform 0.2s;
}
.share-btn--copy.copied .share-btn-icon {
  background: linear-gradient(135deg, #34c759 0%, #28a745 100%);
  transform: scale(1.08);
}
.share-btn--copy.copied .share-btn-icon svg { opacity: 1; }

.share-btn-label {
  text-align: center;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

@media (max-width: 700px) {
  .share-bar { gap: 10px; padding: 14px 10px 10px; }
  .share-btn { width: 64px; }
  .share-btn-icon { width: 46px; height: 46px; border-radius: 14px; }
  .share-btn-icon svg { width: 20px; height: 20px; }
  .share-btn-label { font-size: 10px; }
}

@media (max-width: 700px) {
  .splash-card { padding: 24px 18px; }
  .splash-title { font-size: 24px; }
}
.btn-ghost-large {
  background: var(--bg-active);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-ghost-large:hover { background: var(--bg-hover); }
.btn-primary:disabled {
  background: var(--bg-active);
  color: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
}
.btn-primary:disabled:hover { background: var(--bg-active); transform: none; }

/* ============== Responsive ============== */

/* Десктоп: гамбургер и overlay скрыты */
.mobile-menu-btn { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .hero h1 { font-size: 32px; }
  .hero p { font-size: 14px; }
  .hero-stats { gap: 24px; }
  .stat-num { font-size: 22px; }
  .content { padding: 24px 24px 60px; }
  .hero { padding: 28px; }
  .search-box { width: 100%; max-width: 240px; }
}

@media (max-width: 700px) {
  .app { grid-template-columns: 1fr; }

  /* Шторка: сайдбар выезжает слева поверх контента */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    max-width: 84vw;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    display: flex;
  }
  .sidebar.open { transform: translateX(0); }

  /* Overlay (затемнение) */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 1000;
  }
  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  /* Гамбургер показываем */
  .mobile-menu-btn { display: inline-flex; }

  /* Topbar: гамбургер + поиск + actions — влезают */
  .topbar {
    gap: 8px;
    padding: 0 12px;
    height: 52px;
  }
  .search-box {
    width: auto;
    max-width: none;
    flex: 1;
    min-width: 0;
  }
  .search-box .kbd { display: none; }
  .search-box input { font-size: 13px; min-width: 0; }
  .search-box input::placeholder { color: transparent; }
  .search-box:focus-within input::placeholder { color: var(--text-tertiary); }

  /* Сетка контента */
  .articles-grid { grid-template-columns: 1fr; }
  .modal-body { padding: 24px 20px; }
  .modal-body h1 { font-size: 24px; }

  /* Hero чуть компактнее */
  .hero { padding: 20px; border-radius: var(--radius); }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 13px; }

  /* Topbar-actions кнопки чуть мельче */
  .topbar-actions .btn-ghost { padding: 6px 8px; }
}

/* ============================================
   Копирайт-футер под статьями
   ============================================ */
.content-footer {
  margin-top: 40px;
  padding: 24px 16px;
  text-align: center;
  border-top: 1px solid var(--border);
}
.content-footer-text {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-tertiary);
  font-weight: 400;
}
.content-footer-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  border-bottom: 1px dashed var(--text-tertiary);
  transition: var(--transition);
}
.content-footer-link:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ============================================
   Help modal (инструкция)
   ============================================ */
.help-modal .modal-body {
  max-width: 100%;
}
.help-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.help-section:last-child { border-bottom: none; }
.help-section h3 {
  margin: 0 0 8px 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}
.help-section p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.help-section p b { color: var(--text); font-weight: 600; }
.help-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--text-tertiary);
  transition: var(--transition);
}
.help-link:hover {
  border-bottom-color: var(--text);
}

.kbd-inline {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
  color: var(--text-tertiary);
  background: var(--bg-active);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  vertical-align: baseline;
  white-space: nowrap;
}
