@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Spectral:wght@600&display=swap');

:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #151515;
  --bg-tertiary: #1d1d1d;
  --bg-hover: #252525;
  --border: #282828;
  --text-primary: #e5e5e5;
  --text-secondary: #9a9a9a;
  --text-tertiary: #6b6b6b;
  --text-read: #4a4a4a;
  --accent: #9d7ce8;
  --accent-hover: #b599f0;
  --accent-soft: rgba(157, 124, 232, 0.12);
  --success: #66d9a8;
  --error: #ff8787;
  --warning: #ffd166;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-display: 'Spectral', Georgia, serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 32px;
  margin-bottom: 8px;
  text-align: center;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font-body);
}

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

.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s;
}

.btn-primary { width: 100%; background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-secondary); }

.error-msg {
  padding: 12px 16px;
  background: rgba(255, 135, 135, 0.1);
  border: 1px solid rgba(255, 135, 135, 0.3);
  color: var(--error);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 20px;
}

/* App Layout */
.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* Header */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-btn {
  width: 42px; height: 42px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}

.header-title { flex: 1; min-width: 0; }

.header-title h1 {
  font-size: 18px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 42px; height: 42px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

.icon-btn:active { background: var(--bg-hover); }

/* Sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 998;
}

.sidebar-overlay.active { display: block; }

.sidebar {
  position: fixed;
  left: -100%; top: 0; bottom: 0;
  width: 285px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 999;
  transition: left 0.3s ease;
  display: flex; flex-direction: column;
}

.sidebar.open { left: 0; }

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 16px;
}

.btn-add {
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.feed-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.section-header {
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feed-item {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
}

.feed-item:active { background: var(--bg-hover); }
.feed-item.active { background: var(--accent-soft); }
.feed-item.active .feed-name { color: var(--accent); font-weight: 500; }

.feed-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; overflow: hidden;
}

.feed-icon img {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 6px;
}

.feed-content { flex: 1; min-width: 0; }

.feed-name {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-status {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.feed-status.error { color: var(--error); }

.feed-count {
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.feed-count.has-unread {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.feed-delete {
  background: var(--error);
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  display: none;
}

.feed-item:hover .feed-delete { display: block; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* Pull to Refresh */
#pull-indicator {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--accent);
  opacity: 0;
  transition: height 0.1s ease;
  font-weight: 500;
}

/* Controls */
.controls {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.search {
  flex: 1;
  min-width: 150px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
}

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

.select {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
}

.filter-btn {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
}

.filter-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.mark-all-btn {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
}

.mark-all-btn:active { background: var(--bg-hover); }

/* Skeleton Loading */
.skeleton {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}

.skeleton-line {
  height: 14px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  margin-bottom: 10px;
  animation: shimmer 1.5s infinite;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.full { width: 100%; }
.skeleton-line.title { height: 20px; width: 85%; margin-bottom: 12px; }
.skeleton-thumb { height: 160px; background: var(--bg-tertiary); border-radius: 10px; margin-bottom: 14px; animation: shimmer 1.5s infinite; }

@keyframes shimmer {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

/* Articles */
.articles { padding: 16px; }

.article {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  transition: opacity 0.3s;
}

.article.read { opacity: 0.45; }
.article.read:hover { opacity: 0.7; }

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

.article-source {
  color: var(--accent);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.source-icon {
  width: 14px; height: 14px;
  border-radius: 3px;
}

.article-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 10px;
  cursor: pointer;
  color: var(--text-primary);
}

.article.read .article-title { color: var(--text-read); }

.article-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-thumb-wrap {
  width: 100%;
  height: 180px;
  overflow: hidden;
  border-radius: 10px;
  margin-bottom: 14px;
}

.article-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.article-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 7px 13px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 5px;
  cursor: pointer;
  font-family: var(--font-body);
}

.action-btn:active { background: var(--bg-hover); }
.action-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Pagination */
.pagination {
  padding: 20px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.page-btn {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-body);
}

.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-info { color: var(--text-secondary); font-size: 14px; }

/* Modal */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}

.modal-header h3 { font-size: 20px; font-weight: 600; }

.modal-close {
  width: 32px; height: 32px;
  background: none; border: none;
  font-size: 28px; color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
}

.modal-body { padding: 24px; }

.modal-footer {
  display: flex; gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Empty State */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty h3 { font-size: 20px; margin-bottom: 8px; color: var(--text-primary); }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px; left: 20px; right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 2000;
  animation: slideUp 0.3s ease;
  font-size: 14px;
}

.toast.success { border-color: var(--success); background: rgba(102,217,168,0.1); }
.toast.error { border-color: var(--error); background: rgba(255,135,135,0.1); }

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

/* PWA Install */
.install-prompt {
  position: fixed;
  bottom: 20px; left: 20px; right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  padding: 16px;
  border-radius: 12px;
  display: flex; align-items: center; gap: 12px;
  z-index: 1001;
}

.install-prompt p { flex: 1; font-size: 14px; }
.install-prompt button {
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
}
.install-prompt .close { background: transparent; color: var(--text-secondary); padding: 4px; }

/* Desktop */
@media (min-width: 768px) {
  .app { flex-direction: row; }
  .menu-btn { display: none; }
  .sidebar { position: static; width: 300px; left: 0; }
  .sidebar-overlay { display: none !important; }
  .header { padding: 16px 24px; }
  .controls { padding: 12px 24px; }
  .articles { padding: 20px 24px; }
  .article { padding: 22px; }
  .article-thumb-wrap { height: 220px; }
  .feed-delete { display: none; }
  .feed-item:hover .feed-delete { display: block; }
}

/* Category Filters */
.category-filters {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.category-filters:empty { display: none; }
.category-filters::-webkit-scrollbar { display: none; }

.category-filters .filter-btn {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 13px;
  padding: 7px 14px;
}

@media (min-width: 768px) {
  .category-filters { padding: 8px 24px; }
}
