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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #7d8590;
  --blue: #58a6ff;
  --accent: #1f6feb;
  --green: #3fb950;
  --yellow: #e3b341;
  --red: #f85149;
  --gold: #d4a843;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* TOPBAR */
#topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}
.logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo i { font-size: 18px; }
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
#status-text { font-size: 11px; color: var(--muted); }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--text); background: var(--surface2); }

/* LAYOUT */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR */
#sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px 0;
}
.nav-section {
  padding: 10px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  border-left: 3px solid transparent;
  font-size: 13px;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active, .nav-item.active-cat { color: var(--gold); border-left-color: var(--gold); background: rgba(212,168,67,0.08); }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

/* MAIN */
#main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.view { flex: 1; overflow-y: auto; padding: 20px; display: none; flex-direction: column; }
.view.active { display: flex; }

.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.search-box {
  flex: 1;
  max-width: 360px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.search-box:focus { border-color: var(--gold); }
.count-badge {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 12px;
}

/* ARTICLE CARDS */
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.article-card:hover { border-color: var(--gold); }
.article-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.article-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}
.cat-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  background: rgba(212,168,67,0.15);
  color: var(--gold);
  border: 1px solid rgba(212,168,67,0.3);
  flex-shrink: 0;
}
.article-summary {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 8px;
}
.article-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  align-items: center;
}
.article-source { font-weight: 600; color: var(--blue); }
.article-pending {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* DIGEST */
.digest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 720px;
}
.digest-date {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 16px;
}
.markdown h1, .markdown h2 { color: var(--text); font-weight: 600; margin: 16px 0 8px; }
.markdown h2 { font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 6px; color: var(--gold); }
.markdown h3 { font-size: 13px; color: var(--blue); margin: 12px 0 6px; }
.markdown p { color: var(--muted); line-height: 1.7; margin-bottom: 10px; font-size: 13px; }
.markdown strong { color: var(--text); font-weight: 600; }
.markdown ul, .markdown ol { color: var(--muted); padding-left: 20px; margin-bottom: 10px; }
.markdown li { line-height: 1.7; font-size: 13px; margin-bottom: 4px; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* BUTTONS */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: #388bfd; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* UTILS */
.loading { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
