:root {
  --bg-color: #121210;
  --surface-color: #1c1c18;
  --surface-hover: #262620;
  --border-color: #2e2e28;
  --text-primary: #e3e3dc;
  --text-secondary: #a1a196;
  --accent-color: #d4af37; /* Cozy Gold */
  --accent-hover: #bfa030;

  --sidebar-width: 260px;
  --feed-width: 400px;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  margin: 0;
  padding: 0;
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#root {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Layout structure */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Scrollbars custom styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Sidebar styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--surface-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
  flex-shrink: 0;
  height: 100%;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  text-decoration: none;
  color: var(--accent-color);
  font-size: 20px;
  font-weight: 600;
  transition: transform 0.2s ease;
}
.logo-container:hover {
  transform: scale(1.02);
}
.logo-icon {
  font-size: 24px;
}

.menu-section {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 24px;
}

.menu-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 600;
  position: sticky;
  top: 0;
  background-color: var(--surface-color);
  z-index: 5;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-item {
  margin-bottom: 6px;
}

.menu-item-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  transition: all 0.2s ease;
  cursor: pointer;
}

.menu-link:hover {
  background-color: var(--surface-hover);
}

.menu-link.active {
  background-color: var(--surface-hover);
  border-left: 3px solid var(--accent-color);
  padding-left: 9px;
  font-weight: 500;
}

.menu-link-text {
  margin-right: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: var(--border-color);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}
.menu-link.active .badge {
  background-color: var(--accent-color);
  color: var(--bg-color);
  font-weight: 600;
}

/* Sidebar Footer / Action buttons */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background-color: var(--surface-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}
.btn-action:hover {
  background-color: var(--border-color);
  border-color: var(--text-secondary);
}
.btn-action-primary {
  background-color: var(--accent-color);
  color: var(--bg-color);
  border-color: var(--accent-color);
}
.btn-action-primary:hover {
  background-color: var(--accent-hover);
  color: var(--bg-color);
  transform: translateY(-1px);
}

/* Main Content Feed */
.feed-container {
  width: var(--feed-width);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  height: 100%;
}

.feed-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: rgba(18, 18, 16, 0.9);
  backdrop-filter: blur(10px);
}

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

.feed-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

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

.feed-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.toggle-read-container {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  user-select: none;
}
.toggle-read-container:hover {
  color: var(--text-primary);
}

.feed-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.post-card-container {
  position: relative;
  margin-bottom: 16px;
  opacity: 1;
  transition: all 0.3s ease;
}

.post-card-container.read-fade {
  opacity: 0.45;
}

.post-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: block;
  text-decoration: none;
  color: inherit;
}

.post-card.active {
  border-color: var(--accent-color);
  background-color: var(--surface-hover);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
}

.post-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

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

.source-tag {
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Source tag specific colors are set dynamically via inline styles */

.post-title {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
}

.post-summary {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Reader Pane (Right Side) */
.reader-pane {
  flex: 1;
  background-color: var(--surface-color);
  padding: 40px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.reader-placeholder {
  margin: auto;
  text-align: center;
  color: var(--text-secondary);
}

.reader-placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--accent-color);
  opacity: 0.5;
}

.reader-content {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: none;
}

.reader-header {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.reader-title {
  font-size: 28px;
  margin-top: 0;
  margin-bottom: 16px;
  line-height: 1.35;
  color: var(--text-primary);
}

.reader-link {
  color: var(--accent-color);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}
.reader-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.reader-body {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 17px;
  line-height: 1.85;
  color: #d1d1ca;
}

.reader-body a {
  color: #58a6ff;
  text-decoration: underline;
  transition: color 0.15s ease;
}

.reader-body a:hover {
  color: #79c0ff;
}

.reader-body h1,
.reader-body h2,
.reader-body h3 {
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  margin-top: 36px;
  margin-bottom: 16px;
  line-height: 1.4;
}

.reader-body p {
  margin-bottom: 24px;
}

.reader-body * {
  max-width: 100% !important;
  box-sizing: border-box;
}

.reader-body img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 6px;
  margin: 24px auto;
  display: block;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.reader-body .cozy-picture {
  margin: 24px auto;
  text-align: center;
  max-width: 100%;
}

.reader-body .cozy-caption {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: -10px;
  margin-bottom: 24px;
  line-height: 1.6;
  text-align: center;
  font-style: italic;
}

.reader-body .cozy-gallery-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 24px 0;
  max-width: 100%;
}

.reader-body code {
  font-family: 'Courier New', Courier, monospace;
  background-color: var(--bg-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}

.reader-body pre {
  background-color: var(--bg-color);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  margin: 24px 0;
}

.reader-body pre code {
  padding: 0;
  background: none;
}

/* Modal dialog for GitHub Actions Sync info */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.modal-overlay.active {
  display: flex;
  opacity: 1;
}
.modal-content {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  position: relative;
}
.modal-title {
  font-size: 20px;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 16px;
  color: var(--accent-color);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}
.modal-close:hover {
  color: var(--text-primary);
}
.modal-body p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.code-block-local {
  background: var(--bg-color);
  padding: 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 13px;
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  word-break: break-all;
}

.reader-back-btn {
  display: none;
  align-items: center;
  gap: 8px;
  background-color: var(--surface-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 24px;
  width: fit-content;
  transition: all 0.2s ease;
}
.reader-back-btn:hover {
  background-color: var(--border-color);
  border-color: var(--text-secondary);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 24px;
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}
.sidebar-close-btn:hover {
  color: var(--text-primary);
}

.menu-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.menu-toggle-btn:hover {
  background-color: var(--border-color);
  border-color: var(--text-secondary);
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Responsive design for tablets / mobiles */
@media (max-width: 992px) {
  body {
    flex-direction: row;
  }
  .app-container {
    flex-direction: row;
  }

  .menu-toggle-btn {
    display: flex;
  }

  /* Make sidebar a sliding drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 1000;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar-close-btn {
    display: block;
  }

  .reader-back-btn {
    display: inline-flex;
  }

  /* Single-pane mobile layout switching */
  .app-container.has-active-post .sidebar {
    display: none;
  }
  .app-container.has-active-post .feed-container {
    display: none;
  }
  .app-container.has-active-post .reader-pane {
    width: 100%;
    height: 100%;
    display: flex;
    padding: 20px;
  }

  .app-container:not(.has-active-post) .reader-pane {
    display: none;
  }
  .app-container:not(.has-active-post) .feed-container {
    width: 100%;
    height: 100%;
    flex: 1;
    border-right: none;
    border-bottom: none;
  }
}

.btn-add-source-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.7;
  transition: all 0.15s ease;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-add-source-icon:hover {
  opacity: 1;
  color: var(--accent-color);
  background-color: var(--surface-hover);
}

.dropdown-empty-message {
  padding: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* Welcome Onboarding panel */
.welcome-container {
  max-width: 480px;
  margin: 40px auto;
  padding: 32px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.4s ease-out;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.welcome-title {
  font-size: 20px;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--accent-color);
}

.welcome-subtitle {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.welcome-tip {
  font-size: 12px;
  color: var(--text-secondary);
  background-color: var(--bg-color);
  padding: 10px 14px;
  border-radius: 6px;
  border-left: 3px solid var(--accent-color);
  text-align: left;
  line-height: 1.5;
}

/* Source Selector Modal Specific Styles */
.source-selector-modal {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.source-modal-header {
  display: flex;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 20px;
  color: var(--text-secondary);
  align-items: center;
}

.source-modal-header .divider {
  opacity: 0.3;
}

.btn-link-action {
  background: none;
  border: none;
  color: var(--accent-color);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.btn-link-action:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.source-modal-body {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 24px;
  padding-right: 4px;
}

.source-groups-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.source-group-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.source-group-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.source-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 8px;
}

.source-modal-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background-color: var(--surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.source-modal-item:hover {
  border-color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.source-modal-item.selected {
  border-color: var(--accent-color);
  background-color: rgba(212, 175, 55, 0.08);
}

.source-modal-item-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.source-modal-footer .btn-action {
  width: auto;
  min-width: 100px;
}

.source-modal-search-container {
  margin-bottom: 16px;
  width: 100%;
}

.source-modal-search {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.source-modal-search:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.15);
}

.filter-dropdown-container {
  display: flex;
  align-items: center;
}

.filter-select {
  background-color: var(--surface-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-select:hover {
  border-color: var(--accent-color);
}

.filter-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.15);
}

/* Reader navigation buttons (Left/Right margins) */
.reader-pane {
  position: relative;
}

.reader-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
  opacity: 0.15;
  user-select: none;
}

.reader-nav-btn:hover {
  opacity: 1;
  color: var(--accent-color);
  background: none;
}

.reader-nav-btn.nav-prev {
  /* Aligns with the left gutter of reader content on desktop */
  left: calc(var(--sidebar-width) + var(--feed-width) + 8px);
}

.reader-nav-btn.nav-next {
  /* Aligns with the right gutter of reader content on desktop */
  right: 8px;
}

@media (max-width: 1200px) {
  .reader-nav-btn.nav-prev {
    left: calc(var(--sidebar-width) + 8px);
  }
}

@media (max-width: 992px) {
  .reader-nav-btn {
    width: 36px;
    height: 36px;
    font-size: 32px;
    opacity: 0.2;
  }
  .reader-nav-btn.nav-prev {
    left: 4px;
  }
  .reader-nav-btn.nav-next {
    right: 4px;
  }
  .reader-content {
    padding: 0;
  }
}
