:root {
  --bg: #0c0d0f;
  --panel: #111214;
  --panel-2: #15171a;
  --text: #f5f6f7;
  --text-dim: #9aa3b2;
  --accent: #c7d2fe;
  --accent-2: #e0e7ff;
  --border: #2a2a2a;
  --line: #1e1e1e;
  --btn-bg: #e5e7eb;
  --btn-bg-hover: #f3f4f6;
  --btn-text: #111214;
  --btn-border: #2a2a2a;
  --danger: #ef4444;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { scrollbar-gutter: stable both-edges; overflow-y: scroll; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Lilex', monospace, 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }

.wrap { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); }
.topbar { padding: 0.5rem 1.5rem; }
.topbar-content {
  display: flex; align-items: center; gap: 0.75rem;
  max-width: 1100px; margin: 0 auto;
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--accent); }
.brand:hover { color: var(--accent-2); text-decoration: none; }

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

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1rem; border-radius: 0.3rem;
  border: 2px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-text);
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  font-family: inherit;
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-text); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

/* States */
.rss-loading,
.rss-auth-wall,
.rss-empty {
  text-align: center; padding: 3rem 1rem; color: var(--text-dim);
}
.rss-auth-wall p, .rss-empty p { margin: 0.5rem 0 1rem; }
.rss-empty svg { display: block; margin: 0 auto 0.5rem; }

/* RSS Header */
.rss-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem;
}
.rss-title { margin: 0; font-size: 1.5rem; font-weight: 800; }
.rss-header-actions { display: flex; gap: 0.5rem; }

/* Two-panel layout */
.rss-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  min-height: 0;
}

/* Feed sidebar */
.feed-sidebar {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}
.feed-list {
  list-style: none; margin: 0; padding: 0;
}
.feed-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background 0.12s;
  background: var(--panel);
}
.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--panel-2); }
.feed-item--active {
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
}
.feed-item-title {
  flex: 1; min-width: 0;
  font-size: 0.88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.feed-item-count {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.4rem; height: 1.4rem;
  padding: 0 0.35rem; border-radius: 0.7rem;
  background: var(--accent); color: #0c0d0f;
  font-size: 0.7rem; font-weight: 800;
}
.feed-item-count:empty { display: none; }
.feed-item-remove {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 0.85rem; padding: 0.1rem 0.25rem;
  border-radius: 0.2rem; opacity: 0; transition: opacity 0.1s;
  line-height: 1;
}
.feed-item:hover .feed-item-remove { opacity: 0.6; }
.feed-item-remove:hover { opacity: 1; color: var(--danger); background: rgba(239,68,68,0.1); }

/* Article list area */
.rss-main { min-width: 0; }

.rss-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  margin-bottom: 1rem;
}

/* Filter chips */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.filter-chip {
  padding: 0.25rem 0.65rem; border-radius: 1rem;
  border: 1px solid var(--border);
  background: none; color: var(--text-dim);
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
.filter-chip:hover { background: var(--panel); color: var(--text); }
.filter-chip--active {
  background: var(--accent); color: #0c0d0f;
  border-color: var(--accent);
}

/* Search */
.rss-search { flex: 1; min-width: 140px; }
.rss-search-input {
  width: 100%; padding: 0.35rem 0.65rem;
  border: 1px solid var(--border); border-radius: 0.3rem;
  background: var(--panel); color: var(--text);
  font-size: 0.85rem; font-family: inherit;
  outline: none;
}
.rss-search-input:focus { border-color: var(--accent); }
.rss-search-input::placeholder { color: var(--text-dim); }

/* Article list */
.article-list {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--border); border-radius: 0.4rem; overflow: hidden;
}
.article-item {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.8rem 1rem; border-bottom: 1px solid var(--line);
  background: var(--panel); cursor: pointer;
  transition: background 0.12s;
}
.article-item:last-child { border-bottom: none; }
.article-item:hover { background: var(--panel-2); }
.article-item--unread { border-left: 3px solid var(--accent); }
.article-item--unread .article-item-title { font-weight: 700; }

.article-item-title {
  margin: 0; font-size: 0.95rem; color: var(--text); line-height: 1.35;
}
.article-item-title a { color: inherit; }
.article-item-title a:hover { color: var(--accent-2); }
.article-item-meta {
  display: flex; gap: 0.6rem; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--text-dim);
}
.article-item-feed {
  display: inline-block; padding: 0.02rem 0.35rem;
  border-radius: 0.2rem; background: var(--panel-2); border: 1px solid var(--border);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.article-item-summary {
  margin: 0.15rem 0 0; font-size: 0.84rem; color: var(--text-dim);
  line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.rss-load-more { text-align: center; padding: 1rem 0 0; }

/* Article reader */
.rss-back-btn { margin-bottom: 1rem; }
.article-reader {}
.article-reader-title {
  margin: 0 0 0.5rem; font-size: 1.4rem; font-weight: 800; line-height: 1.3;
}
.article-reader-meta {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  font-size: 0.85rem; color: var(--text-dim); margin-bottom: 1.25rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--line);
}
.article-reader-content {
  font-size: 0.95rem; line-height: 1.7; color: var(--text);
  max-width: 700px;
}
.article-reader-content p { margin: 0.8rem 0; }
.article-reader-content img { max-width: 100%; height: auto; border-radius: 0.3rem; }
.article-reader-content a { color: var(--accent); }
.article-reader-link {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 1.25rem; padding: 0.5rem 0;
  font-size: 0.9rem; color: var(--accent);
}

/* Dialogs */
.rss-dialog {
  border: 1px solid var(--border); border-radius: 0.5rem;
  background: var(--panel); color: var(--text);
  padding: 1.5rem; max-width: 440px; width: 90vw;
}
.rss-dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog-title { margin: 0 0 1rem; font-size: 1.15rem; font-weight: 800; }
.dialog-subtitle { margin: 1.25rem 0 0.5rem; font-size: 0.95rem; font-weight: 700; }
.dialog-hint { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--text-dim); }
.dialog-label { display: block; margin: 0.75rem 0 0.3rem; font-size: 0.85rem; font-weight: 600; }
.dialog-input {
  width: 100%; padding: 0.5rem 0.65rem;
  border: 1px solid var(--border); border-radius: 0.3rem;
  background: var(--bg); color: var(--text);
  font-size: 0.9rem; font-family: inherit;
}
.dialog-input:focus { outline: none; border-color: var(--accent); }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.dialog-actions--loose { margin-top: 1.5rem; }
.dialog-status { margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-dim); min-height: 1.2rem; }

/* Feed Store */
.store-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1rem;
}
.store-title { margin: 0; font-size: 1.2rem; font-weight: 800; }
.store-toolbar { margin-bottom: 1rem; }
.store-toolbar-row {
  display: flex; gap: 0.5rem; margin-top: 0.6rem;
}
.store-sort {
  padding: 0.35rem 0.5rem; border: 1px solid var(--border);
  border-radius: 0.3rem; background: var(--panel); color: var(--text);
  font-size: 0.82rem; font-family: inherit; cursor: pointer;
  flex-shrink: 0;
}
.store-sort:focus { outline: none; border-color: var(--accent); }
.store-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.store-card {
  display: flex; flex-direction: column;
  padding: 0.9rem 1rem; border-radius: 0.4rem;
  border: 1px solid var(--border); background: var(--panel);
  transition: background 0.12s, border-color 0.12s;
}
.store-card:hover { background: var(--panel-2); }
.store-card--subscribed { border-color: var(--accent); }
.store-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.35rem;
}
.store-card-title {
  margin: 0; font-size: 0.95rem; font-weight: 700;
  line-height: 1.3; flex: 1; min-width: 0;
}
.store-card-cat {
  flex-shrink: 0; padding: 0.05rem 0.4rem; border-radius: 0.2rem;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-dim);
}
.store-card-desc {
  margin: 0; font-size: 0.84rem; color: var(--text-dim);
  line-height: 1.4; flex: 1;
}
.store-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-top: 0.6rem; padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}
.store-card-subs {
  font-size: 0.78rem; color: var(--text-dim);
  transition: color 0.15s;
}
.store-card-subs--error { color: var(--danger); font-weight: 600; }
.store-card--error { border-color: var(--danger); }
.store-card-btn {
  padding: 0.25rem 0.6rem; border-radius: 0.25rem;
  border: 1px solid var(--accent); background: none;
  color: var(--accent); font-size: 0.78rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
.store-card-btn:hover {
  background: var(--accent); color: #0c0d0f;
}
.store-card-btn--subscribed {
  background: var(--accent); color: #0c0d0f;
  border-color: var(--accent);
}
.store-card-btn--subscribed:hover {
  background: none; color: var(--accent);
}
.store-empty { text-align: center; padding: 2rem 1rem; color: var(--text-dim); }

/* Discover list in Add Feed dialog */
.discover-list {
  list-style: none; margin: 0.5rem 0; padding: 0;
  border: 1px solid var(--border); border-radius: 0.3rem; overflow: hidden;
}
.discover-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.discover-item:last-child { border-bottom: none; }
.discover-item-info { flex: 1; min-width: 0; }
.discover-item-title {
  font-size: 0.88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.discover-item-url {
  font-size: 0.75rem; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Footer */
.footer {
  border-top: 1px solid var(--line);
  padding: 1rem 1.5rem; color: var(--text-dim); font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
  .rss-layout {
    grid-template-columns: 1fr;
  }
  .feed-sidebar {
    max-height: none;
    border: none; border-bottom: 1px solid var(--line);
    border-radius: 0;
  }
  .feed-list {
    display: flex; overflow-x: auto; gap: 0;
    -webkit-overflow-scrolling: touch;
  }
  .feed-item {
    flex-shrink: 0; border-bottom: none;
    border-right: 1px solid var(--line);
    padding: 0.45rem 0.75rem;
  }
  .feed-item:last-child { border-right: none; }
  .feed-item--active {
    border-left: none;
    border-bottom: 2px solid var(--accent);
  }
  .feed-item-remove { display: none; }
  .rss-toolbar { gap: 0.4rem; }
  .rss-search { min-width: 100%; order: 10; }
  .store-grid { grid-template-columns: 1fr; }
  .store-toolbar-row { flex-wrap: wrap; }
}
