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

:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-card: #1c2128;
  --bg-card-hover: #22272e;
  --bg-input: #0d1117;
  --text: #f0f6fc;
  --text-secondary: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-subtle: rgba(56, 189, 248, 0.12);
  --border: #30363d;
  --border-muted: #21262d;
  --border-focus: #38bdf8;
  --unread-dot: #38bdf8;
  --star: #facc15;
  --bookmark: #f43f5e;
  --success: #22c55e;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, Cambria, serif;
  --font-mono: 'JetBrains Mono', monospace;
  --reader-font-size: 1.15rem;
  --reader-line-height: 1.75;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* --- App Header --- */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(22, 27, 34, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#brand-container {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#heading {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  background: linear-gradient(135deg, #fff 40%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.date-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* --- Search Bar --- */
.search-container {
  position: relative;
  flex: 1;
  max-width: 380px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 36px 6px 34px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-ui);
  transition: all 0.2s ease;
}

#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background: #090d13;
}

.search-shortcut {
  position: absolute;
  right: 12px;
  background: var(--border-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  pointer-events: none;
}

.clear-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
}
.clear-btn:hover { color: var(--text); }

/* --- View Filters --- */
.view-filters {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

.filter-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

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

.filter-tab.active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.count-badge {
  background: var(--border);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
}

.filter-tab.active .count-badge {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* --- Header Actions --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.action-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--bg-card-hover);
}

.action-btn.icon-only {
  padding: 6px 8px;
}

.kbd-hint {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
}

.spinning {
  animation: spin 0.8s linear infinite;
}

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

/* --- Category Nav Bar --- */
#categories-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-muted);
  padding: 8px 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
#categories-bar::-webkit-scrollbar { display: none; }

.category-tabs {
  display: flex;
  gap: 6px;
  min-width: max-content;
}

.cat-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.cat-chip:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.cat-chip.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

.cat-badge {
  background: rgba(255,255,255,0.08);
  font-size: 0.68rem;
  padding: 0 5px;
  border-radius: 8px;
  color: var(--text-muted);
}
.cat-chip.active .cat-badge {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
}

/* --- Filter Banner --- */
.filter-banner {
  background: #111d2e;
  border-bottom: 1px solid #1e3a5f;
  padding: 8px 20px;
  font-size: 0.82rem;
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-banner button {
  background: transparent;
  border: 1px solid #2563eb;
  color: #bfdbfe;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}
.filter-banner button:hover { background: #1d4ed8; color: #fff; }

/* --- Articles Container --- */
#news-view {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.articles-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Article Card --- */
.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 18px;
  position: relative;
}

.article-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.article-card.read {
  opacity: 0.75;
}
.article-card.read .article-title {
  color: var(--text-secondary);
}

.card-unread-indicator {
  position: absolute;
  top: 18px;
  left: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--unread-dot);
  display: none;
}
.article-card:not(.read) .card-unread-indicator {
  display: block;
}

.card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.card-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.75rem;
}

.source-badge {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.source-badge:hover { text-decoration: underline; }

.category-tag {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
}

.time-badge {
  color: var(--text-muted);
}

.author-badge {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.article-title {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  margin-bottom: 6px;
  word-break: break-word;
}

.article-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

/* Bottom Card Toolbar */
.card-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 4px;
}

.card-tool-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
  text-decoration: none;
}

.card-tool-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.card-tool-btn.active-star {
  color: var(--star);
}
.card-tool-btn.active-star svg {
  fill: var(--star);
}

.card-tool-btn.active-save {
  color: var(--bookmark);
}
.card-tool-btn.active-save svg {
  fill: var(--bookmark);
}

.card-tool-btn.active-read {
  color: var(--success);
}

.card-thumbnail {
  width: 140px;
  height: 94px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Loading & Empty State */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  margin-bottom: 16px;
  color: var(--text-muted);
}
.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p {
  margin-bottom: 20px;
}

/* --- Modals Shared --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-backdrop.hidden {
  display: none;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.close-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* --- Reader View Modal --- */
.reader-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.reader-toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(22, 27, 34, 0.95);
  flex-shrink: 0;
}

.reader-meta-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
}

.reader-source-badge {
  color: var(--accent);
  font-weight: 600;
}

.reader-author {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.reader-tool-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  transition: all 0.15s ease;
}
.reader-tool-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text);
  border-color: var(--text-muted);
}
.reader-tool-btn.active-star { color: var(--star); }
.reader-tool-btn.active-star svg { fill: var(--star); }
.reader-tool-btn.active-save { color: var(--bookmark); }
.reader-tool-btn.active-save svg { fill: var(--bookmark); }

.reader-article {
  padding: 32px 40px;
  overflow-y: auto;
  flex: 1;
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
}

.reader-article.font-serif {
  font-family: var(--font-serif);
}

.reader-title {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 24px;
  color: #fff;
  letter-spacing: -0.01em;
}

.reader-hero-container {
  margin-bottom: 24px;
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 420px;
}
.reader-hero-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reader-body {
  color: var(--text);
}

.reader-body p {
  margin-bottom: 1.25em;
}

.reader-body h1, .reader-body h2, .reader-body h3, .reader-body h4 {
  color: #fff;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  line-height: 1.3;
}

.reader-body a {
  color: var(--accent);
  text-decoration: underline;
}

.reader-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 1.5em 0;
  display: block;
}

.reader-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  color: var(--text-secondary);
  font-style: italic;
  margin: 1.5em 0;
}

.reader-body ul, .reader-body ol {
  padding-left: 24px;
  margin-bottom: 1.25em;
}

.reader-body pre, .reader-body code {
  font-family: var(--font-mono);
  background: var(--bg);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.9em;
}

.reader-body pre {
  padding: 14px;
  overflow-x: auto;
  margin-bottom: 1.25em;
}

.reader-link-box {
  margin-top: 36px;
  padding: 22px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.reader-summary-notice {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.reader-open-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 22px;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.reader-open-link-btn:hover {
  transform: translateY(-1px);
}

.reader-footer-nav {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.nav-arrow-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
}
.nav-arrow-btn:hover { background: var(--bg-card); color: var(--text); }

.progress-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* --- Feeds & Settings Dialog --- */
.settings-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.2rem; font-weight: 600; color: #fff; }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0 16px;
  gap: 6px;
}

.settings-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.settings-tab-btn:hover { color: var(--text); }
.settings-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Feeds List Tab */
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text);
  font-size: 0.85rem;
  flex: 1;
  max-width: 320px;
}

.badge-pill {
  background: var(--border-muted);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
}

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

.feed-row {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.feed-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.feed-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.feed-status-dot.ok { background: var(--success); }
.feed-status-dot.error { background: var(--danger); }

.feed-name-url {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.feed-title-txt {
  font-weight: 500;
  font-size: 0.9rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-url-txt {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.feed-cat-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font-ui);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.primary-btn {
  background: var(--accent);
  color: #0d1117;
  border: none;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.primary-btn:hover { background: var(--accent-hover); }

.secondary-btn {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}
.secondary-btn:hover { border-color: var(--text-muted); }

.danger-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
}
.danger-btn:hover { background: var(--danger); color: #fff; }

.test-result-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  margin-bottom: 16px;
}
.test-result-box.success { border-color: var(--success); color: #86efac; }
.test-result-box.error { border-color: var(--danger); color: #fca5a5; }

/* OPML Tab */
.opml-section {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.opml-section h3 {
  font-size: 1.05rem;
  color: #fff;
  margin-bottom: 6px;
}
.opml-section p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.import-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.or-divider {
  text-align: center;
  margin: 16px 0;
  position: relative;
}
.or-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-muted);
}
.or-divider span {
  position: relative;
  background: var(--bg-card);
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}
#opml-paste-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 10px;
  margin-bottom: 12px;
}

/* Categories Tab */
.category-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.category-add-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.85rem;
}
.categories-settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cat-setting-card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.cat-setting-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cat-keywords-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.keyword-tag {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.keyword-tag button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.keyword-tag button:hover { color: var(--danger); }

/* Logs Tab */
.logs-header {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.logs-terminal {
  background: #05070a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  height: 380px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #94a3b8;
}
.log-row {
  margin-bottom: 4px;
  word-break: break-all;
}
.log-row.error { color: #f87171; }
.log-row.warn { color: #facc15; }
.log-time { color: var(--text-muted); margin-right: 6px; }

/* Shortcuts Modal */
.shortcuts-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  padding: 20px 24px;
}
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  box-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

/* Responsiveness */
@media (max-width: 768px) {
  #app-header {
    flex-wrap: wrap;
    padding: 10px 14px;
  }
  .search-container {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
  .header-actions span { display: none; }
  .article-card {
    flex-direction: column-reverse;
  }
  .card-thumbnail {
    width: 100%;
    height: 180px;
  }
  .reader-article {
    padding: 20px 16px;
  }
  .shortcuts-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Comedy Hub: Video Clips, Memes, and Gags Layout
   ========================================================================== */

.comedy-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  animation: fadeIn 0.25s ease-out;
}

/* --- Hero Banner & Gag of the Day --- */
.comedy-hero {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.16) 0%, rgba(236, 72, 153, 0.12) 50%, rgba(30, 41, 59, 0.5) 100%);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.4), 0 0 24px -6px rgba(168, 85, 247, 0.15);
}

.comedy-hero::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.comedy-hero-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comedy-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #d8b4fe;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 9999px;
  width: fit-content;
}

.comedy-hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  margin: 0;
  background: linear-gradient(to right, #ffffff, #f472b6, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.comedy-hero-desc {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
}

/* Daily Gag Card */
.daily-gag-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 16px 20px;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gag-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gag-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gag-next-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-muted);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gag-next-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fbbf24;
  color: #fbbf24;
}

.gag-setup {
  font-size: 1rem;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.45;
  margin: 0;
}

.gag-reveal-wrap {
  min-height: 38px;
  display: flex;
  align-items: center;
}

.reveal-punchline-btn {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  border: none;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 9999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.reveal-punchline-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(236, 72, 153, 0.4);
}

.gag-punchline {
  font-size: 0.95rem;
  font-weight: 600;
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  border-left: 3px solid #34d399;
  padding: 8px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0;
  animation: fadeIn 0.25s ease-out;
}

/* --- Comedy Subnav Tabs --- */
.comedy-subnav {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-muted);
  padding-bottom: 12px;
  overflow-x: auto;
}

.comedy-subnav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.comedy-subnav-btn:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--bg-card);
}

.comedy-subnav-btn.active {
  background: linear-gradient(135deg, #9333ea, #c026d3);
  border-color: #a855f7;
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.35);
}

.comedy-count-badge {
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
}

/* --- Section Headings --- */
.comedy-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.comedy-section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.comedy-section-header .section-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- Video Clips Grid & Cards --- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.video-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.video-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  cursor: pointer;
  overflow: hidden;
}

.video-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.video-thumb-wrap:hover .video-thumb-img {
  transform: scale(1.03);
}

.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  background: rgba(220, 38, 38, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.video-thumb-wrap:hover .video-play-overlay {
  transform: translate(-50%, -50%) scale(1.1);
  background: #ef4444;
}

.video-play-overlay svg {
  margin-left: 3px;
}

.video-duration-pill {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.video-category-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(168, 85, 247, 0.85);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.video-player-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.video-player-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.video-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.video-show-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #c084fc;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.video-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
  margin: 0 0 6px 0;
}

.video-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0 0 12px 0;
  flex: 1;
}

.video-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-muted);
}

.video-play-btn {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #d8b4fe;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.video-play-btn:hover {
  background: rgba(168, 85, 247, 0.28);
  color: #fff;
}

.video-ext-link {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s ease;
}

.video-ext-link:hover {
  color: var(--accent);
}

/* --- Memes Grid & Cards --- */
.memes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.meme-card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.meme-card:hover {
  border-color: rgba(236, 72, 153, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.meme-img-wrap {
  position: relative;
  width: 100%;
  height: 240px;
  background: #0d1117;
  cursor: pointer;
  overflow: hidden;
}

.meme-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #090d16;
  transition: transform 0.3s ease;
}

.meme-img-wrap:hover .meme-img {
  transform: scale(1.02);
}

.meme-zoom-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.meme-img-wrap:hover .meme-zoom-badge {
  opacity: 1;
}

.meme-category-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f472b6;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.meme-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.meme-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
  margin: 0;
}

.meme-caption {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  flex: 1;
}

.meme-reactions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-muted);
}

.reaction-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.reaction-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.reaction-btn.reacted {
  background: rgba(236, 72, 153, 0.2);
  border-color: #ec4899;
  color: #f472b6;
}

/* --- Gags & Satire Section --- */
.gags-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.gag-card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}

.gag-card:hover {
  border-color: rgba(251, 191, 36, 0.35);
}

.gag-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gag-card-cat {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
}

.gag-card-rating {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.gag-card-setup {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
  margin: 0;
}

.gag-card-btn {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fbbf24;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-self: flex-start;
  transition: all 0.15s ease;
}

.gag-card-btn:hover {
  background: rgba(251, 191, 36, 0.22);
}

.gag-card-punchline {
  font-size: 0.9rem;
  font-weight: 600;
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
  border-left: 3px solid #34d399;
  padding: 6px 10px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0;
  animation: fadeIn 0.2s ease-out;
}

/* Satire Headlines List */
.satire-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.satire-card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.satire-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.satire-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
}

.satire-badge {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.satire-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
  margin: 0;
}

.satire-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Meme Lightbox Modal --- */
.meme-lightbox-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.meme-lightbox-img-wrap {
  width: 100%;
  max-height: 65vh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meme-lightbox-img-wrap img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
}

.meme-lightbox-info {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-card);
}

.meme-lightbox-info h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.meme-lightbox-info p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Responsiveness for Comedy Hub */
@media (max-width: 860px) {
  .comedy-hero {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px;
  }
}