/* =============================================
   CSS Custom Properties – Light / Dark Theme
   ============================================= */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --border: #e5e5e5;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --sidebar-width: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-card: #1e1e1e;
  --text-primary: #f0f0f0;
  --text-secondary: #999999;
  --border: #2a2a2a;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.6);
  --accent-light: #1e3a8a22;
}

/* =============================================
   Reset & Base
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  font-family: var(--font);
  border: none;
  outline: none;
}

input, select, textarea {
  font-family: var(--font);
}

/* =============================================
   Layout – Sidebar + Main
   ============================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 16px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: background var(--transition), border-color var(--transition);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.sidebar-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  font-size: 18px;
  text-decoration: none;
}

.sidebar-btn:hover,
.sidebar-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.lang-btn {
  flex-direction: column;
  gap: 2px;
  height: auto;
  padding: 6px 4px;
}

.lang-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1;
}

/* Main content area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  max-width: 1376px;
}

/* =============================================
   Topbar / Page Header
   ============================================= */
.page-header {
  margin-bottom: 24px;
}

.greeting {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.greeting-sub {
  font-size: 14px;
  color: var(--text-secondary);
}

/* =============================================
   Filter Chips
   ============================================= */
.filter-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Bias-Bar Toggle Button */
.bias-bar-toggle-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0.45;
}

.bias-bar-toggle-btn:hover {
  opacity: 0.9;
}

.bias-bar-toggle-btn.active {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-card);
}

/* Hide all bias bars when toggle is off */
.bias-bars-hidden .bias-bar {
  display: none;
}

/* Refresh Button */
.refresh-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  opacity: 0.45;
  pointer-events: none;
  position: relative;
}

.refresh-btn:not(:disabled) {
  opacity: 1;
  pointer-events: auto;
  border-color: var(--accent);
  color: var(--accent);
}

.refresh-btn:not(:disabled):hover {
  background: var(--accent);
  color: #fff;
}

.refresh-icon {
  display: inline-block;
  font-size: 16px;
  line-height: 1;
  transition: transform 0.3s ease;
}

.refresh-btn.spinning .refresh-icon {
  animation: spin-once 0.6s ease-in-out;
}

@keyframes spin-once {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.refresh-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.refresh-btn:not(:disabled):hover .refresh-badge {
  background: #fff;
  color: var(--accent);
}

.chip {
  padding: 6px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* =============================================
   News Grid
   ============================================= */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 1024px) {
  .news-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* =============================================
   Article Card
   ============================================= */
.article-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: inherit;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}

.card-image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-secondary);
  position: relative;
}

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

.article-card:hover .card-image img {
  transform: scale(1.03);
}

.card-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 32px;
}

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

.card-topic {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-teaser {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.card-source {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bias-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Bias colours: blue = left/liberal, red = right/conservative */
.bias-dot.left          { background: #3b82f6; }
.bias-dot.center-left   { background: #818cf8; }
.bias-dot.center        { background: #6b7280; }
.bias-dot.center-right  { background: #f97316; }
.bias-dot.right         { background: #ef4444; }
.bias-dot.neutral       { background: #9ca3af; }
.bias-dot.unknown       { background: transparent; border: 1.5px dashed #9ca3af; }

/* =============================================
   Source Chips (unknown-bias sources)
   ============================================= */
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =============================================
   Bias Bar  (blue → red gradient with dots)
   ============================================= */
.bias-bar {
  padding: 6px 16px 10px;
}

.bias-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.bias-bar-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    #3b82f6 0%,
    #818cf8 30%,
    #6b7280 50%,
    #f97316 70%,
    #ef4444 100%
  );
}

.bias-bar-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  cursor: default;
  z-index: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  transition: transform 0.15s;
}

.bias-bar-dot:hover {
  transform: translate(-50%, -50%) scale(1.35);
  z-index: 2;
}

.bias-bar-dot.dot-left          { background: #3b82f6; }
.bias-bar-dot.dot-center-left   { background: #818cf8; }
.bias-bar-dot.dot-center        { background: #6b7280; }
.bias-bar-dot.dot-center-right  { background: #f97316; }
.bias-bar-dot.dot-right         { background: #ef4444; }

/* Unknown sources shown as small chips below the bar */
.bias-bar-unknown {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 7px;
}

/* Larger variant for story detail sidebar */
.bias-bar-full .bias-bar-track {
  height: 8px;
  border-radius: 4px;
}

.bias-bar-full .bias-bar-dot {
  width: 22px;
  height: 22px;
  font-size: 10px;
  border-width: 2.5px;
}

.source-count-badge {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Story-Detail: Quellen-Liste */
.story-sources-section {
  margin-bottom: 24px;
}

.story-sources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.story-source-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition), background var(--transition);
}

.story-source-card:hover {
  border-color: var(--accent);
  background: var(--bg-card);
}

.story-source-card .bias-dot {
  width: 10px;
  height: 10px;
}

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

.story-source-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-source-domain {
  font-size: 11px;
  color: var(--text-secondary);
}

.story-source-bias-label {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.story-source-arrow {
  font-size: 14px;
  color: var(--text-secondary);
  opacity: 0.5;
}


/* =============================================
   Load More / Pagination
   ============================================= */
.load-more-container {
  text-align: center;
  margin-top: 32px;
}

.btn-load-more {
  padding: 12px 32px;
  border-radius: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.btn-load-more:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =============================================
   Empty / Loading States
   ============================================= */
.state-container {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}

.state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.state-desc {
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* =============================================
   Article Detail Page
   ============================================= */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .article-layout {
    grid-template-columns: 1fr;
  }
}

.article-main {}

.article-hero {
  margin-bottom: 28px;
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  transition: color var(--transition);
}

.article-back:hover {
  color: var(--accent);
  text-decoration: none;
}

.article-topic-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.article-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 12px;
}

@media (max-width: 640px) {
  .article-title {
    font-size: 22px;
  }
}

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

.article-meta a {
  color: var(--accent);
}

/* Tab Navigation */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px 16px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
  transition: all var(--transition);
  position: relative;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

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

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Tab Content */
.tab-content {
  min-height: 200px;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-panel.active {
  display: block;
}

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

.view-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
}

.view-content p {
  margin-bottom: 12px;
}

.view-content ul, .view-content ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.view-content li {
  margin-bottom: 6px;
}

.view-content strong {
  color: var(--text-primary);
}

.view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 14px;
  gap: 12px;
}

.view-error {
  padding: 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

/* =============================================
   Article Sidebar (Right)
   ============================================= */
.article-sidebar {}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Overlapping image tiles */
.image-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.image-tile {
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 4/3;
  background: var(--bg-secondary);
}

.image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-tile:first-child {
  grid-column: 1 / -1;
  aspect-ratio: 16/9;
}

/* Source Card */
.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.source-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.source-name {
  font-weight: 700;
  font-size: 15px;
}

.source-domain {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* Bias Scale */
.bias-scale-wrapper {
  margin-bottom: 8px;
}

.bias-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.bias-scale-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    #3b82f6 0%,
    #818cf8 30%,
    #6b7280 50%,
    #f97316 70%,
    #ef4444 100%
  );
  margin-bottom: 4px;
}

.bias-scale-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.bias-label-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 4px;
}

.bias-disclaimer {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  font-style: italic;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* =============================================
   Auth Pages (Login / Register)
   ============================================= */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.auth-logo-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.auth-logo-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.auth-form-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
}

/* =============================================
   Form Elements
   ============================================= */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
  color: var(--text-secondary);
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Interest / Source Checkboxes */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-item {
  display: none;
}

.checkbox-label {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-label:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.checkbox-item:checked + .checkbox-label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* =============================================
   Buttons
   ============================================= */
.btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* =============================================
   Alert / Error Messages
   ============================================= */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.alert.visible {
  display: block;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

[data-theme="dark"] .alert-error {
  background: #2d1515;
  border-color: #7f1d1d;
  color: #fca5a5;
}

[data-theme="dark"] .alert-success {
  background: #14261c;
  border-color: #14532d;
  color: #86efac;
}

/* =============================================
   Auth footer link
   ============================================= */
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* =============================================
   Profile Page
   ============================================= */
.profile-layout {
  max-width: 640px;
}

.profile-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.profile-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.profile-display-name {
  font-size: 22px;
  font-weight: 800;
}

.profile-email {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

/* =============================================
   Source Picker
   ============================================= */

.source-picker-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.source-search-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

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

.source-filter-select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

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

.source-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.source-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  padding: 3px 8px 3px 6px;
  border-radius: 99px;
}

.source-chip-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 0 2px;
}

.source-chip-remove:hover {
  color: #fff;
}

.source-picker-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.source-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.source-picker-item:last-child {
  border-bottom: none;
}

.source-picker-item:hover {
  background: var(--bg);
}

.source-picker-item.selected {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.source-picker-checkbox {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.source-picker-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-picker-domain {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 100px;
}

.source-picker-country {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 80px;
}

.source-picker-bias {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 80px;
  text-align: right;
}

.source-no-results {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 12px 0;
  text-align: center;
}

/* =============================================
   Version Section
   ============================================= */

.version-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.version-badge {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: 0.04em;
}

.version-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.version-date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

.version-changelog {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.version-changelog-item {
  font-size: 13px;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
}

.version-changelog-item::before {
  content: "●";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 8px;
  top: 4px;
}

.setting-label {
  font-size: 14px;
  font-weight: 500;
}

/* =============================================
   Theme Toggle Button
   ============================================= */
.theme-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--border);
  transition: background var(--transition);
  cursor: pointer;
  border: none;
  outline: none;
}

.theme-toggle.active {
  background: var(--accent);
}

.theme-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.theme-toggle.active::after {
  transform: translateX(20px);
}

/* =============================================
   Toast Notification
   ============================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  color: var(--bg-primary);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 300px;
}

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

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-4px); }
}

/* =============================================
   Responsive – Mobile
   ============================================= */
@media (max-width: 640px) {
  .main-content {
    padding: 16px;
    margin-left: 0;
  }

  .sidebar {
    width: 100%;
    height: var(--sidebar-width);
    flex-direction: row;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 16px;
    justify-content: space-around;
  }

  .sidebar-nav {
    flex-direction: row;
  }

  .app-layout {
    flex-direction: column;
    padding-bottom: var(--sidebar-width);
  }

  .auth-card {
    padding: 28px 20px;
  }
}

/* =============================================
   Utility Classes
   ============================================= */
.hidden { display: none !important; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
