:root {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1e293b;
  --topbar-bg: rgba(15, 23, 42, 0.94);
  --border: #263244;
  --text: #e2e8f0;
  --text-body: #cbd5e1;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --cheap-bg: rgba(16, 185, 129, 0.14);
  --cheap-fg: #34d399;
  --peak-bg: rgba(245, 158, 11, 0.16);
  --peak-fg: #fbbf24;
  --reader-font-size: 16px;
}

body[data-theme="paper"] {
  --bg: #f4efe6;
  --surface: #fbf8f1;
  --surface-2: #efe7d6;
  --topbar-bg: rgba(244, 239, 230, 0.95);
  --border: #ddd3c0;
  --text: #221c15;
  --text-body: #3d342a;
  --muted: #6e6253;
  --primary: #9a3412;
  --primary-hover: #7c2d12;
  --cheap-bg: rgba(22, 163, 74, 0.12);
  --cheap-fg: #15803d;
  --peak-bg: rgba(217, 119, 6, 0.14);
  --peak-fg: #b45309;
}

body[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --topbar-bg: rgba(255, 255, 255, 0.95);
  --border: #e2e8f0;
  --text: #0f172a;
  --text-body: #334155;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --cheap-bg: rgba(16, 185, 129, 0.12);
  --cheap-fg: #059669;
  --peak-bg: rgba(245, 158, 11, 0.15);
  --peak-fg: #d97706;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.full-width { width: 100%; }

/* Login */
.login-body {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
}
.login-logo { font-size: 2.5rem; text-align: center; }
.login-card h1 { text-align: center; margin: 0.4rem 0 0.2rem; font-size: 1.4rem; }
.login-card p { text-align: center; margin-bottom: 1.5rem; }
.login-card label { display: block; margin-top: 0.8rem; margin-bottom: 0.3rem; font-size: 0.88rem; color: var(--muted); }
.login-card input {
  width: 100%; padding: 0.65rem 0.8rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.login-card button { margin-top: 1.2rem; }
.error-msg { margin-top: 0.8rem; color: #f87171; font-size: 0.88rem; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0.75rem 1rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; }
.refresh-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }

.switcher-group {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; gap: 2px;
}
.sw-btn, .theme-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 0.3rem 0.55rem; border-radius: 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.sw-btn.active, .theme-btn.active {
  background: var(--primary); color: #fff;
}
.btn-sm { padding: 0.28rem 0.55rem; font-size: 0.8rem; }
.font-controls { display: inline-flex; align-items: center; gap: 0.3rem; }

.tariff-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.38rem 0.7rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
}
.tariff-badge .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tariff-cheap { background: var(--cheap-bg); color: var(--cheap-fg); border: 1px solid rgba(52, 211, 153, 0.3); }
.tariff-cheap .dot { background: var(--cheap-fg); }
.tariff-peak { background: var(--peak-bg); color: var(--peak-fg); border: 1px solid rgba(251, 191, 36, 0.3); }
.tariff-peak .dot { background: var(--peak-fg); }

.cost-badge {
  padding: 0.38rem 0.65rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}

/* Tabs */
.tabs {
  max-width: 1180px; margin: 0 auto; padding: 0 1rem;
  display: flex; gap: 0.25rem; overflow-x: auto;
}
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 0.65rem 0.95rem; cursor: pointer; font-size: 0.9rem; font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Buttons & Inputs */
.btn {
  padding: 0.48rem 0.85rem; border-radius: 8px; border: 1px solid transparent;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-dismiss {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 0.35rem 0.7rem; font-size: 0.8rem;
}
.btn-dismiss:hover { color: #fca5a5; border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.btn-danger-sm {
  background: rgba(239, 68, 68, 0.14); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.35rem 0.65rem; font-size: 0.8rem;
}

input, select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.9rem;
}

/* Main */
.container { max-width: 1180px; margin: 1.25rem auto; padding: 0 1rem 3rem; }

.alert-banner {
  background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fde68a; padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.9rem;
}
.toast {
  position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 100;
  background: var(--surface-2); border: 1px solid var(--primary); color: var(--text);
  padding: 0.7rem 1rem; border-radius: 10px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* Feed */
.feed-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 1rem;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 0.38rem 0.75rem; border-radius: 999px; font-size: 0.83rem; cursor: pointer;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.search-wrap input { min-width: 220px; }

.articles-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1rem;
}
.article-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.1rem; display: flex; flex-direction: column; justify-content: space-between; gap: 0.75rem;
}
.article-card.prio-very_high { border-left: 4px solid #ef4444; }
.article-card.prio-high { border-left: 4px solid #3b82f6; }
.article-card.prio-medium { border-left: 4px solid #64748b; }
.article-card.prio-low { border-left: 4px solid #334155; opacity: 0.9; }
.article-card.is-read { opacity: 0.68; }

.article-meta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem;
  font-size: 0.78rem; color: var(--muted);
}
.badge {
  padding: 0.18rem 0.5rem; border-radius: 6px; font-weight: 600; font-size: 0.74rem;
  background: var(--surface-2); color: var(--text);
}
.badge-very_high { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.badge-high { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.badge-medium { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }
.badge-low { background: rgba(71, 85, 105, 0.25); color: #94a3b8; }

.article-title {
  margin: 0.35rem 0; font-size: 1.03rem; font-weight: 700; line-height: 1.38;
}
.article-title a, .article-title-btn {
  color: var(--text); text-decoration: none; background: none; border: none;
  padding: 0; font: inherit; text-align: left; cursor: pointer;
}
.article-title a:hover, .article-title-btn:hover { color: #93c5fd; text-decoration: underline; }
.article-thumb {
  width: 100%; height: 175px; object-fit: cover; border-radius: 8px;
  margin-bottom: 0.55rem; background: var(--surface-2); display: block; cursor: pointer;
}

/* Reader Modal */
.reader-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.reader-backdrop {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.8); backdrop-filter: blur(4px);
}
.reader-dialog {
  position: relative; z-index: 201; width: 100%; max-width: 780px; max-height: 90vh;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
}
.reader-topbar {
  padding: 0.8rem 1.2rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.reader-scroll {
  padding: 1.25rem 1.4rem; overflow-y: auto; flex: 1;
}
.reader-cover {
  width: 100%; max-height: 360px; object-fit: cover; border-radius: 10px; margin-bottom: 1rem;
}
.reader-title {
  margin: 0 0 1rem; font-size: 1.45rem; line-height: 1.32;
}
.reader-summary-box {
  background: rgba(59, 130, 246, 0.12); border-left: 3px solid var(--primary);
  padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1.2rem;
  font-size: 0.95rem; color: var(--text);
}
.reader-body p {
  margin: 0 0 1rem; font-size: var(--reader-font-size); line-height: 1.72; color: var(--text-body);
}

/* 1. GAZETE (EDITORIAL) DÜZENİ */
.editorial-wrap { display: flex; flex-direction: column; gap: 1.5rem; }
.editorial-hero {
  display: grid; grid-template-columns: 1.55fr 1fr; gap: 1rem;
  border-bottom: 2px solid var(--border); padding-bottom: 1.25rem;
}
.editorial-lead {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.15rem; display: flex; flex-direction: column; justify-content: space-between; gap: 0.8rem;
}
.editorial-lead .article-thumb { height: 280px; }
.editorial-lead .article-title { font-family: Georgia, "Times New Roman", serif; font-size: 1.55rem; line-height: 1.25; }
.editorial-side-stack { display: flex; flex-direction: column; gap: 0.85rem; }
.editorial-columns { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.editorial-main-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.editorial-briefs {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem;
}
.editorial-briefs h3 { margin: 0 0 0.75rem; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.brief-item {
  padding: 0.65rem 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.3rem;
}
.brief-item:last-child { border-bottom: none; }

/* 2. LİSTE / İSTİHBARAT + SPLIT VIEW */
.feed-stage { display: block; }
.feed-stage.split-open { display: grid; grid-template-columns: 1fr 1.05fr; gap: 1rem; align-items: start; }
.terminal-list { display: flex; flex-direction: column; gap: 0.5rem; }
.terminal-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.7rem 0.85rem; display: grid; grid-template-columns: 76px 1fr auto; gap: 0.85rem; align-items: center;
}
.terminal-row.no-thumb { grid-template-columns: 1fr auto; }
.terminal-row.active-row { border-color: var(--primary); }
.terminal-thumb {
  width: 76px; height: 58px; object-fit: cover; border-radius: 7px; cursor: pointer; background: var(--surface-2);
}
.terminal-main { min-width: 0; }
.terminal-main .article-title { margin: 0.15rem 0; font-size: 0.96rem; }
.terminal-main .article-summary {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.84rem;
}
.split-reader {
  position: sticky; top: 112px; height: calc(100vh - 130px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden;
}
.split-reader-bar {
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.split-reader-scroll { padding: 1.1rem 1.25rem; overflow-y: auto; flex: 1; }

/* 3. BENTO DÜZENİ */
.bento-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  grid-auto-flow: dense; gap: 1rem;
}
.bento-wide { grid-column: span 2; }
.bento-wide .article-thumb { height: 240px; }

@media (max-width: 960px) {
  .editorial-hero, .editorial-columns, .feed-stage.split-open { grid-template-columns: 1fr; }
  .bento-wide { grid-column: span 1; }
  .split-reader { display: none !important; }
}
.reader-footer {
  padding: 0.8rem 1.2rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.article-summary { margin: 0; font-size: 0.9rem; color: var(--text-body); line-height: 1.5; }

.article-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding-top: 0.5rem; border-top: 1px solid rgba(38, 50, 68, 0.6);
  font-size: 0.8rem; color: var(--muted);
}

/* Panels & Forms */
.panel-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.panel-card h2 { margin-top: 0; font-size: 1.1rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.stack-form { display: flex; flex-direction: column; gap: 0.6rem; max-width: 480px; }
.stack-form label { font-size: 0.88rem; color: var(--muted); margin-top: 0.3rem; }
.checkbox-label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.88rem; cursor: pointer; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.list-stack { display: flex; flex-direction: column; gap: 0.6rem; }
.row-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.85rem 1rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.row-info { display: flex; flex-direction: column; gap: 0.2rem; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

@media (max-width: 640px) {
  .articles-grid { grid-template-columns: 1fr; }
  .search-wrap, .search-wrap input { width: 100%; }
}
