/* === Tokens: Light theme === */
:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;

  /* Status colors */
  --reliable: #16a34a;
  --reliable-bg: #f0fdf4;
  --reliable-border: #bbf7d0;
  --false: #dc2626;
  --false-bg: #fef2f2;
  --false-border: #fecaca;
  --disputed: #ca8b04;
  --disputed-bg: #fefce8;
  --disputed-border: #fef08a;
  --water: #2563eb;
  --water-bg: #eff6ff;
  --water-border: #bfdbfe;
  --opinion: #6b7280;
  --opinion-bg: #f9fafb;
  --opinion-border: #e5e7eb;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --max-width: 860px;
  --header-height: 60px;
}

/* === Tokens: Dark theme === */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: #1e3a5f;

  --reliable-bg: #052e16;
  --reliable-border: #166534;
  --false-bg: #450a0a;
  --false-border: #991b1b;
  --disputed-bg: #422006;
  --disputed-border: #a16207;
  --water-bg: #172554;
  --water-border: #1e40af;
  --opinion-bg: #1f2937;
  --opinion-border: #374151;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* === Header === */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 24px;
}
.logo {
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; opacity: 0.85; }
.logo-img {
  display: block;
  height: 24px;
  width: auto;
}
[data-theme="dark"] .logo-dark { display: block; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; }
[data-theme="light"] .logo-light { display: block; }
.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
}
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.nav-link:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }
.nav-link.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--border-light); }
[data-theme="dark"] .theme-icon-light { display: inline; }
[data-theme="dark"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: inline; }

/* === Burger === */
.burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 200;
}
.burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0; }
.burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* === Main === */
.main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* === Footer === */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* === Container === */
.container { max-width: var(--max-width); margin: 0 auto; }

h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 8px; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 16px; }

/* === Hero === */
.hero { text-align: center; margin-bottom: 32px; }
.hero h1 { font-size: 2rem; margin-bottom: 12px; }
.hero-subtitle { color: var(--text-secondary); font-size: 1.05rem; max-width: 600px; margin: 0 auto; line-height: 1.7; }

/* === Mode switch === */
.mode-switch {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
}
.mode-btn {
  padding: 8px 24px;
  border: none;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font);
}
.mode-btn.active { background: var(--accent); color: white; }
.mode-btn:not(.active):hover { background: var(--border-light); }

/* === Form === */
.check-form { margin-bottom: 40px; }
.field { margin-bottom: 16px; }
.field.hidden { display: none; }
.field textarea,
.field input[type="url"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--bg-card);
  color: var(--text);
  resize: vertical;
  transition: border-color 0.15s;
}
.field textarea:focus,
.field input[type="url"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.field input[type="url"] { padding: 12px 16px; }
.form-actions { display: flex; align-items: center; gap: 16px; }
.btn-primary {
  padding: 12px 32px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 8px 18px; font-size: 0.85rem; }

/* === Filter bar === */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.filter-search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-search-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}
.filter-search-input:focus { outline: none; border-color: var(--accent); }
.filter-search-input::placeholder { color: var(--text-muted); }
.filter-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-item label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.filter-item select,
.filter-item input[type="search"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-width: 140px;
}
.filter-item select:focus,
.filter-item input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}
.filter-reset {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.filter-reset:hover { color: var(--text); text-decoration: none; }

/* === Tag badges === */
.feed-card-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
}
.tag-badge:hover { background: var(--accent); color: white; text-decoration: none; }

/* === Source filter link === */
.source-filter-link {
  color: var(--text-muted);
  font-weight: 500;
}
.source-filter-link:hover { color: var(--accent); text-decoration: none; }
.form-hint { color: var(--text-muted); font-size: 0.85rem; }
.form-error { color: var(--false); font-size: 0.85rem; }

/* === Legend === */
.status-legend {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.legend-grid { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.legend-item.reliable .legend-dot { background: var(--reliable); }
.legend-item.false .legend-dot { background: var(--false); }
.legend-item.disputed .legend-dot { background: var(--disputed); }
.legend-item.water .legend-dot { background: var(--water); }
.legend-item.opinion .legend-dot { background: var(--opinion); }

/* === Result page === */
.back-link { display: inline-block; margin-bottom: 24px; color: var(--text-secondary); font-size: 0.9rem; }
.result-header { margin-bottom: 32px; }
.result-header h1 { margin-bottom: 8px; }
.source-link { font-size: 0.9rem; }
.reliability { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.reliability-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  background: color-mix(in srgb, var(--reliable) var(--score), var(--false));
  color: white;
}
.reliability-date { color: var(--text-muted); font-size: 0.85rem; }

/* === Sentences === */
.sentences { display: flex; flex-direction: column; gap: 4px; }

.sentence {
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.sentence-text { font-size: 1rem; line-height: 1.6; margin-bottom: 8px; }
.sentence-meta { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.sentence-status { font-weight: 500; }
.sentence-source { font-size: 0.85rem; }

.sentence-reliable { background: var(--reliable-bg); border-color: var(--reliable-border); }
.sentence-reliable .sentence-status { color: var(--reliable); }
.sentence-false { background: var(--false-bg); border-color: var(--false-border); }
.sentence-false .sentence-status { color: var(--false); }
.sentence-disputed { background: var(--disputed-bg); border-color: var(--disputed-border); }
.sentence-disputed .sentence-status { color: var(--disputed); }
.sentence-water { background: var(--water-bg); border-color: var(--water-border); }
.sentence-water .sentence-status { color: var(--water); }
.sentence-opinion { background: var(--opinion-bg); border-color: var(--opinion-border); }
.sentence-opinion .sentence-status { color: var(--opinion); }

/* === Related facts from other news === */
.related-section {
  margin-top: 28px;
}
.related-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.related-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.related-facts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.related-fact {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.related-fact-text {
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 6px;
}
.related-fact-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
}
.related-fact-status {
  font-weight: 500;
}
.related-fact-news-link {
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}
.related-fact-news-link:hover {
  text-decoration: underline;
}

.related-fact-reliable { background: var(--reliable-bg); border-color: var(--reliable-border); }
.related-fact-reliable .related-fact-status { color: var(--reliable); }
.related-fact-false { background: var(--false-bg); border-color: var(--false-border); }
.related-fact-false .related-fact-status { color: var(--false); }
.related-fact-disputed { background: var(--disputed-bg); border-color: var(--disputed-border); }
.related-fact-disputed .related-fact-status { color: var(--disputed); }
.related-fact-water { background: var(--water-bg); border-color: var(--water-border); }
.related-fact-water .related-fact-status { color: var(--water); }
.related-fact-opinion { background: var(--opinion-bg); border-color: var(--opinion-border); }
.related-fact-opinion .related-fact-status { color: var(--opinion); }

/* === Share === */
.share {
  margin-top: 32px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}
.share-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
}

/* === Recent checks on main === */
.recent-checks { margin-top: 40px; }
.recent-checks h2 { margin-bottom: 16px; }
.feed-card-sm .feed-card-score {
  width: 40px; height: 40px;
  font-size: 0.78rem;
}
.feed-card-sm .feed-card-content h2 { font-size: 0.9rem; }

/* === Feed === */
.feed-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
.feed-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: box-shadow 0.15s;
  color: var(--text);
}
.feed-card:hover { box-shadow: var(--shadow-lg); text-decoration: none; }
.feed-card-score {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--reliable) var(--score), var(--false));
  color: white;
}
.feed-card-content { flex: 1; min-width: 0; }
.feed-card-content h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === Feed card with facts === */
.feed-card-full {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: box-shadow 0.15s;
}
.feed-card-full:hover { box-shadow: var(--shadow-lg); }
.feed-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.feed-card-title-block { flex: 1; min-width: 0; }
.feed-card-title-block h2 { font-size: 1.1rem; margin-bottom: 4px; }
.feed-card-title-block h2 a { color: var(--text); }
.feed-card-title-block h2 a:hover { color: var(--accent); text-decoration: none; }

.feed-facts { display: flex; flex-direction: column; gap: 8px; }
.feed-fact {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
}
.feed-fact-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px;
}
.feed-fact-text { flex: 1; min-width: 0; }
.feed-fact-comment { color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0; max-width: 200px; }

.feed-fact-reliable { background: var(--reliable-bg); }
.feed-fact-reliable .feed-fact-dot { background: var(--reliable); }
.feed-fact-false { background: var(--false-bg); }
.feed-fact-false .feed-fact-dot { background: var(--false); }
.feed-fact-disputed { background: var(--disputed-bg); }
.feed-fact-disputed .feed-fact-dot { background: var(--disputed); }
.feed-fact-water { background: var(--water-bg); }
.feed-fact-water .feed-fact-dot { background: var(--water); }
.feed-fact-opinion { background: var(--opinion-bg); }
.feed-fact-opinion .feed-fact-dot { background: var(--opinion); }

/* === Show more toggle === */
.feed-facts-extra { flex-direction: column; }
.feed-show-more {
  display: block;
  width: 100%;
  padding: 8px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font);
  margin-top: 4px;
}
.feed-show-more:hover { color: var(--accent); border-color: var(--accent); }

.empty { text-align: center; color: var(--text-secondary); padding: 48px 0; }

/* === Pagination === */
.pagination { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.page-btn {
  min-width: 40px; height: 40px;
  padding: 0 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: background 0.1s;
}
.page-btn:hover { background: var(--border-light); text-decoration: none; }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-ellipsis {
  min-width: 40px; height: 40px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.load-more {
  display: none;
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font);
}
.load-more:hover { background: var(--accent-light); }

/* === Sources === */
.section-desc { color: var(--text-secondary); margin-bottom: 24px; }
.sources-table { display: flex; flex-direction: column; gap: 8px; }
.source-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.source-name { flex: 1; font-weight: 500; }
.source-score { font-weight: 700; font-size: 1.1rem; }
.source-count { color: var(--text-muted); font-size: 0.85rem; }

.source-reliable .source-score { color: var(--reliable); }
.source-false .source-score { color: var(--false); }
.source-gray .source-score { color: var(--text-muted); }

/* === About === */
.about-section { margin-bottom: 32px; }
.about-section h2 { font-size: 1.15rem; margin-bottom: 8px; }
.about-section p { color: var(--text-secondary); line-height: 1.7; }

/* === Responsive === */
@media (max-width: 768px) {
  .header-inner { gap: 12px; }
  .burger { display: flex; margin-left: auto; }
  .nav {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-card);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 150;
    padding: 24px;
  }
  .nav.open { display: flex; }
  .nav-link { padding: 12px 24px; font-size: 1.1rem; }
  .hero h1 { font-size: 1.5rem; }
  .hero-subtitle { font-size: 0.95rem; }
  .main { padding: 24px 16px 48px; }
  .footer-inner { flex-direction: column; gap: 4px; }
  .pagination { display: none; }
  .load-more { display: block; }
  .reliability { flex-direction: column; align-items: flex-start; gap: 4px; }
  .source-row { flex-wrap: wrap; gap: 8px; }
  .source-count { width: 100%; }
  .feed-fact { flex-wrap: wrap; }
  .feed-fact-comment { max-width: 100%; width: 100%; }
  .feed-card-header { flex-direction: column; gap: 12px; align-items: center; text-align: center; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-item select { min-width: 0; width: 100%; }
}
