/* ==========================================================================
   Reddit Archive Viewer - Modern CSS
   ========================================================================== */

:root {
  --reddit-orange: #ff4500;
  --reddit-orange-light: #ff5414;
  --reddit-blue: #7193ff;
  --reddit-downvote: #7193ff;
  --upvote-color: #ff4500;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Dark Theme (Default) */
[data-theme="dark"] {
  --bg-page: #030303;
  --bg-header: #1a1a1b;
  --bg-card: #1a1a1b;
  --bg-card-hover: #272729;
  --bg-sidebar: #1a1a1b;
  --bg-subtle: #272729;
  --bg-input: #272729;
  --bg-modal: #1a1a1b;
  --bg-modal-overlay: rgba(0, 0, 0, 0.82);
  --border-color: #343536;
  --border-light: #2d2d2e;
  --text-primary: #d7dadc;
  --text-secondary: #818384;
  --text-muted: #57595b;
  --text-link: #4fbcff;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --modal-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
  --badge-bg: #272729;
}

/* Light Theme */
[data-theme="light"] {
  --bg-page: #dae0e6;
  --bg-header: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f9fa;
  --bg-sidebar: #ffffff;
  --bg-subtle: #f6f7f8;
  --bg-input: #f6f7f8;
  --bg-modal: #ffffff;
  --bg-modal-overlay: rgba(0, 0, 0, 0.65);
  --border-color: #ccc;
  --border-light: #edeff1;
  --text-primary: #1c1c1c;
  --text-secondary: #787c7e;
  --text-muted: #878a8c;
  --text-link: #0079d3;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --modal-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  --badge-bg: #edeff1;
}

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

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

a {
  color: var(--text-link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Top Navigation Bar
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.2px;
}

.reddit-logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--reddit-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.reddit-logo-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.nav-brand-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.nav-brand-title .sub-name {
  color: var(--text-primary);
}

.nav-brand-title .archive-pill {
  font-size: 0.7rem;
  font-weight: 600;
  background-color: var(--reddit-orange);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Search Container */
.nav-search {
  flex: 1;
  max-width: 600px;
  position: relative;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrap svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 40px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  background-color: var(--bg-card);
  border-color: var(--text-link);
  box-shadow: 0 0 0 2px rgba(79, 188, 255, 0.2);
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
}
.search-clear-btn:hover {
  color: var(--text-primary);
}

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

.btn-nav-icon {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.btn-nav-icon:hover {
  background-color: var(--bg-subtle);
}

.btn-nav-text {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-nav-text.active {
  background-color: var(--reddit-orange);
  color: white;
  border-color: var(--reddit-orange);
}

/* ==========================================================================
   Subreddit Banner & Header
   ========================================================================== */
.sub-banner-container {
  width: 100%;
}

.sub-banner {
  height: 120px;
  background: linear-gradient(135deg, #102a43 0%, #1e3a5f 40%, #0b1f33 100%);
  position: relative;
  overflow: hidden;
}

.sub-banner-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.15;
  background-image: radial-gradient(#ffffff 1px, transparent 1px);
  background-size: 16px 16px;
}

.sub-header-bar {
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
}

.sub-header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: flex-end;
  position: relative;
  height: 60px;
}

.sub-avatar-wrap {
  position: absolute;
  top: -44px;
  left: 24px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 4px solid var(--bg-header);
  background: linear-gradient(135deg, #ff4500 0%, #e03d00 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.7rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.sub-info {
  margin-left: 104px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}

.sub-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sub-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.sub-id-pill {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.sub-stats-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sub-stat-item strong {
  color: var(--text-primary);
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-wrapper {
  max-width: 1200px;
  margin: 16px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .main-wrapper {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
}

/* ==========================================================================
   Filter & Sorting Bar
   ========================================================================== */
.controls-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.sort-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 8px;
}

.sort-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sort-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sort-tab svg {
  width: 16px;
  height: 16px;
}

.sort-tab:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.sort-tab.active {
  background-color: var(--bg-subtle);
  color: var(--reddit-orange);
}

.view-mode-toggle {
  display: flex;
  background-color: var(--bg-subtle);
  border-radius: 20px;
  padding: 2px;
  border: 1px solid var(--border-light);
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.view-btn.active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Secondary Filter Rows */
.filters-row {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  min-width: 48px;
}

.chips-container {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.filter-chip.active {
  background-color: var(--reddit-orange);
  color: #ffffff;
  border-color: var(--reddit-orange);
  font-weight: 600;
}

/* Active Filter Banner */
.active-filter-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.active-filter-alert .clear-btn {
  background: none;
  border: none;
  color: var(--reddit-orange);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
}

/* ==========================================================================
   Post Feed Cards (Card View)
   ========================================================================== */
.posts-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: border-color var(--transition-fast);
}

.post-card:hover {
  border-color: #818384;
}

/* Vote Column */
.vote-col {
  width: 44px;
  background-color: rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  flex-shrink: 0;
  user-select: none;
}

[data-theme="light"] .vote-col {
  background-color: #f8f9fa;
}

.vote-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.vote-btn svg {
  width: 18px;
  height: 18px;
}

.vote-btn.up:hover, .vote-btn.up.active {
  color: var(--reddit-orange);
  background-color: rgba(255, 69, 0, 0.1);
}

.vote-btn.down:hover, .vote-btn.down.active {
  color: var(--reddit-blue);
  background-color: rgba(113, 147, 255, 0.1);
}

.vote-score {
  font-size: 0.8rem;
  font-weight: 700;
  margin: 4px 0;
  color: var(--text-primary);
}

.vote-score.voted-up {
  color: var(--reddit-orange);
}
.vote-score.voted-down {
  color: var(--reddit-blue);
}

/* Post Main Content */
.post-main {
  flex: 1;
  padding: 10px 14px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.post-meta-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.post-sub-badge {
  font-weight: 700;
  color: var(--text-primary);
}

.post-author-link {
  color: var(--text-secondary);
  font-weight: 500;
}
.post-author-link:hover {
  text-decoration: underline;
  color: var(--reddit-orange);
}

.post-dot {
  opacity: 0.6;
}

.post-crosspost-tag {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Post Flair */
.post-flair {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-right: 6px;
  white-space: nowrap;
}

/* Dynamic Flair Styles */
.flair-news { background-color: #1e3a8a; color: #bfdbfe; }
.flair-pics-videos { background-color: #064e3b; color: #a7f3d0; }
.flair-discussion-opinions, .flair-discussion { background-color: #78350f; color: #fde68a; }
.flair-geopolitics { background-color: #134e4a; color: #99f6e4; }
.flair-media { background-color: #581c87; color: #e9d5ff; }
.flair-military-history { background-color: #713f12; color: #fef08a; }
.flair-article-analysis { background-color: #0f766e; color: #ccfbf1; }
.flair-osint { background-color: #881337; color: #fecdd3; }
.flair-aeroindia { background-color: #4c1d95; color: #ddd6fe; }
.flair-memes { background-color: #831843; color: #fbcfe8; }
.flair-default { background-color: var(--badge-bg); color: var(--text-secondary); border: 1px solid var(--border-color); }

[data-theme="light"] .flair-news { background-color: #dbeafe; color: #1e40af; }
[data-theme="light"] .flair-pics-videos { background-color: #d1fae5; color: #065f46; }
[data-theme="light"] .flair-discussion-opinions, [data-theme="light"] .flair-discussion { background-color: #fef3c7; color: #92400e; }
[data-theme="light"] .flair-geopolitics { background-color: #ccfbf1; color: #115e59; }
[data-theme="light"] .flair-media { background-color: #f3e8ff; color: #6b21a8; }
[data-theme="light"] .flair-military-history { background-color: #fef9c3; color: #854d0e; }
[data-theme="light"] .flair-article-analysis { background-color: #e0f2fe; color: #0369a1; }
[data-theme="light"] .flair-osint { background-color: #ffe4e6; color: #9f1239; }
[data-theme="light"] .flair-aeroindia { background-color: #ede9fe; color: #5b21b6; }
[data-theme="light"] .flair-memes { background-color: #fce7f3; color: #9d174d; }

/* Post Title */
.post-title-wrap {
  margin-bottom: 8px;
}

.post-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  display: inline;
  cursor: pointer;
}
.post-title:hover {
  color: var(--reddit-orange);
}

.post-domain-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}
.post-domain-tag:hover {
  text-decoration: underline;
  color: var(--text-secondary);
}

/* ==========================================================================
   Media Renderers
   ========================================================================== */
.post-media-box {
  margin: 8px 0 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  max-height: 520px;
}

[data-theme="light"] .post-media-box {
  background-color: #f8f9fa;
}

.post-img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
}

/* Gallery Component */
.gallery-viewer {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.gallery-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 250px;
  max-height: 520px;
  background-color: #000;
}

.gallery-img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  cursor: zoom-in;
}

.gallery-counter {
  position: absolute;
  top: 10px;
  right: 12px;
  background-color: rgba(0,0,0,0.65);
  color: white;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
}

.gallery-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0,0,0,0.6);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.gallery-nav-btn:hover {
  background-color: rgba(0,0,0,0.9);
}
.gallery-prev { left: 10px; }
.gallery-next { right: 10px; }

/* Video Player */
.post-video {
  max-width: 100%;
  max-height: 520px;
  background-color: black;
  border-radius: var(--radius-sm);
  outline: none;
}

/* Self Text Box */
.post-selftext-box {
  margin: 6px 0 10px 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-primary);
  position: relative;
}

.selftext-content {
  overflow: hidden;
  max-height: 240px;
  transition: max-height var(--transition-normal);
}

.selftext-content.expanded {
  max-height: none;
}

.selftext-fade-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(transparent, var(--bg-card));
  pointer-events: none;
}

.selftext-content.expanded + .selftext-fade-overlay {
  display: none;
}

.btn-expand-text {
  background: none;
  border: none;
  color: var(--reddit-orange);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.selftext-content p {
  margin-bottom: 8px;
}
.selftext-content blockquote {
  border-left: 3px solid var(--border-color);
  padding-left: 10px;
  margin: 6px 0;
  color: var(--text-secondary);
}
.selftext-content ul, .selftext-content ol {
  padding-left: 20px;
  margin: 6px 0;
}
.selftext-content code {
  background-color: var(--bg-subtle);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.85em;
  font-family: monospace;
}

/* External Link Card */
.external-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 6px 0 10px 0;
  text-decoration: none;
  transition: background-color var(--transition-fast);
}
.external-link-card:hover {
  background-color: var(--border-color);
  text-decoration: none;
}
.ext-link-info {
  display: flex;
  flex-direction: column;
}
.ext-link-url {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-link);
  word-break: break-all;
}
.ext-link-domain {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.ext-link-icon {
  color: var(--text-secondary);
  margin-left: 10px;
}

/* Post Action Bar (Footer) */
.post-action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.action-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  text-decoration: none;
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.action-btn.btn-saved {
  color: #f59e0b;
}

/* ==========================================================================
   Classic / Compact View
   ========================================================================== */
.posts-feed.classic-view .post-card {
  align-items: center;
  border-radius: 0;
  border-bottom: none;
}
.posts-feed.classic-view .post-card:first-child {
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}
.posts-feed.classic-view .post-card:last-child {
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  border-bottom: 1px solid var(--border-color);
}

.posts-feed.classic-view .vote-col {
  padding: 4px 2px;
  width: 38px;
}
.posts-feed.classic-view .vote-score {
  font-size: 0.75rem;
  margin: 1px 0;
}
.posts-feed.classic-view .post-main {
  padding: 8px 12px;
}
.posts-feed.classic-view .post-media-box,
.posts-feed.classic-view .post-selftext-box,
.posts-feed.classic-view .external-link-card {
  display: none;
}
.posts-feed.classic-view .post-title {
  font-size: 0.95rem;
}
.posts-feed.classic-view .post-action-bar {
  border-top: none;
  padding-top: 2px;
}

.classic-thumb {
  width: 58px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  margin-right: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.classic-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
}

/* ==========================================================================
   Pagination Bar
   ========================================================================== */
.pagination-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 16px 0 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  background-color: var(--border-color);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-jump-input {
  width: 52px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-input);
  color: var(--text-primary);
  text-align: center;
  font-size: 0.85rem;
}

/* ==========================================================================
   Sidebar Widgets
   ========================================================================== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-widget {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.widget-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #102a43 100%);
  color: white;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.widget-body {
  padding: 14px;
  font-size: 0.85rem;
}

.community-desc {
  margin-bottom: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.community-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 12px;
}

.stat-cell strong {
  display: block;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.stat-cell span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.widget-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.widget-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}

.widget-list-item a {
  color: var(--text-primary);
  font-weight: 500;
}
.widget-list-item a:hover {
  color: var(--reddit-orange);
}

.badge-count {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--bg-modal-overlay);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background-color: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--modal-shadow);
  position: relative;
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close-btn:hover {
  color: var(--text-primary);
}

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

/* Lightbox Modal */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.94);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.8);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.8;
}
.lightbox-close:hover {
  opacity: 1;
}

/* Toast Notification */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--modal-shadow);
  z-index: 3000;
  display: none;
  animation: fadeIn 0.2s ease;
}

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

/* Loading Spinner */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--reddit-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Comments Section & Threaded Comments
   ========================================================================== */
.comments-section {
  margin-top: 24px;
  border-top: 2px solid var(--border-light);
  padding-top: 20px;
}

.comments-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.comments-count-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.comments-sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.comments-sort-btn {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.comments-sort-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.comments-sort-btn.active {
  background-color: var(--reddit-orange);
  color: white;
  border-color: var(--reddit-orange);
}

.comments-tree {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Individual Comment Node */
.comment-node {
  position: relative;
  display: flex;
  flex-direction: column;
  font-size: 0.88rem;
  line-height: 1.5;
}

.comment-wrapper {
  position: relative;
  padding: 4px 0 6px 0;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.comment-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: monospace;
  font-size: 0.85rem;
  padding: 0 4px;
  font-weight: 700;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.comment-collapse-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.comment-author {
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}
.comment-author:hover {
  text-decoration: underline;
  color: var(--reddit-orange);
}

.comment-op-badge {
  background-color: #2563eb;
  color: white;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.comment-flair-badge {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 0.7rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-score {
  font-weight: 600;
  color: var(--text-primary);
}

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

.comment-body {
  color: var(--text-primary);
  margin-left: 18px;
  word-break: break-word;
}
.comment-body p {
  margin-bottom: 6px;
}
.comment-body p:last-child {
  margin-bottom: 0;
}
.comment-body blockquote {
  border-left: 3px solid var(--reddit-orange);
  padding-left: 8px;
  margin: 6px 0;
  color: var(--text-secondary);
  background: rgba(255, 69, 0, 0.05);
  border-radius: 0 4px 4px 0;
}
.comment-body code {
  background-color: var(--bg-subtle);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.85em;
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 18px;
  margin-top: 4px;
  font-size: 0.75rem;
}

.comment-action-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.comment-action-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* Thread guide line & Nested Replies */
.comment-replies {
  margin-left: 12px;
  padding-left: 14px;
  border-left: 2px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  position: relative;
  transition: border-color var(--transition-fast);
}

.comment-replies:hover {
  border-left-color: var(--text-muted);
}

/* Collapsed State */
.comment-node.collapsed > .comment-wrapper > .comment-body,
.comment-node.collapsed > .comment-wrapper > .comment-actions,
.comment-node.collapsed > .comment-replies {
  display: none !important;
}

.comment-node.collapsed > .comment-wrapper .comment-collapsed-notice {
  display: inline;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.75rem;
  margin-left: 4px;
}

.comment-collapsed-notice {
  display: none;
}

.no-comments-box {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   Site & Sidebar Footer
   ========================================================================== */
.site-footer {
  margin-top: 40px;
  padding: 24px 16px 36px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.footer-love {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.footer-heart {
  color: #ff4500;
  display: inline-block;
  animation: heartPulse 1.8s ease-in-out infinite;
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.footer-author-link {
  color: var(--text-link);
  font-weight: 700;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-author-link:hover {
  color: var(--reddit-orange);
  text-decoration: underline;
}

.footer-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-dot {
  font-size: 0.7rem;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}

.sidebar-footer a {
  color: var(--text-link);
  font-weight: 600;
}

.sidebar-footer a:hover {
  color: var(--reddit-orange);
  text-decoration: underline;
}

.sidebar-footer-copy {
  margin-top: 4px;
  font-size: 0.72rem;
}

