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

:root {
  --sidebar-w:  240px;
  --bg:         #fafaf9;
  --bg2:        #ffffff;
  --border:     #e5e3dc;
  --text:       #1a1a18;
  --text2:      #6b6b66;
  --accent:     #534AB7;
  --accent-bg:  #f0eefd;
  --unread-bg:  #ffffff;
  --read-bg:    #f5f4f1;
  --star:       #e8a020;
  --danger:     #cc3a2e;
  --radius:     8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #18181a;
    --bg2:       #222224;
    --border:    #333336;
    --text:      #e8e8e4;
    --text2:     #8c8c88;
    --accent-bg: #2a2660;
    --unread-bg: #222224;
    --read-bg:   #1e1e20;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

/* ---- Layout ---- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  max-width: 860px;
  padding: 28px 32px;
}

/* ---- Sidebar ---- */
.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.app-logo {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.sidebar-nav { flex: 1; padding: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover  { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text2);
  padding: 12px 10px 4px;
}

.feed-favicon  { border-radius: 3px; flex-shrink: 0; }
.feed-title    { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.unread-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---- Sección feeds con botones ---- */
.nav-section-feeds {
  display: flex;
  align-items: center;
  padding: 12px 10px 4px;
  gap: 2px;
}

/* ---- Botones icono sidebar ---- */
.sidebar-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 16px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 0;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.sidebar-icon-btn:hover { background: var(--border); color: var(--text); }

/* ---- Dropdown del sidebar ---- */
.sidebar-dropdown {
  position: absolute;
  right: 0;
  top: 28px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 180px;
  z-index: 50;
  overflow: hidden;
}

.sidebar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
  white-space: nowrap;
}
.sidebar-dropdown-item:hover { background: var(--bg); }

/* ---- Carpetas sidebar ---- */
.sidebar-folder { margin-bottom: 1px; }

.sidebar-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}
.sidebar-folder-header:hover { background: var(--bg); color: var(--text); }

.folder-arrow {
  font-size: 9px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.sidebar-folder-feeds {
  display: none;
  overflow: hidden;
}
.sidebar-folder-feeds.open { display: block; }

/* ---- Buttons ---- */
.btn, .btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  text-decoration: none;
  transition: border-color .12s, background .12s;
}
.btn:hover, .btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #3C3489; border-color: #3C3489; }

.btn.danger, .btn-sm.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn.danger:hover, .btn-sm.danger:hover { background: #fdf0ef; }

/* ---- Content header ---- */
.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.content-header h1 { font-size: 20px; font-weight: 600; }
.header-actions    { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Article list ---- */
.articles-container { display: flex; flex-direction: column; gap: 1px; }

.articles-container.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.article-card {
  background: var(--unread-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  transition: background 0.15s;
  cursor: pointer;
}

.article-card:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.article-card:last-child  { border-radius: 0 0 var(--radius) var(--radius); }
.article-card + .article-card { border-top: none; }

.articles-container.cards .article-card,
.articles-container.cards .article-card:first-child,
.articles-container.cards .article-card:last-child,
.articles-container.cards .article-card + .article-card {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
}

.article-card.read    { background: var(--read-bg); }
.article-card:hover   { border-color: #b0adcc; }

.article-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
}

.article-date::before { content: '·'; margin-right: 4px; }

.article-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 6px;
}
.article-title a {
  color: var(--text);
  text-decoration: none;
}
.article-title a:hover { color: var(--accent); }

.article-summary {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 10px;
  line-height: 1.5;
}

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

.star-btn, .read-btn {
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.1s;
}
.star-btn:hover, .read-btn:hover { background: var(--border); color: var(--text); }
.star-btn.starred { color: var(--star); }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-state p { margin-bottom: 16px; }

/* ---- Forms ---- */
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 12px;
}

input, select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.12s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #fdf0ef;
  border-radius: var(--radius);
  border: 1px solid #f5c4b3;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert.success { background: #eaf5ee; color: #0f6e56; border: 1px solid #9fe1cb; }
.alert.danger  { background: #fdf0ef; color: #993c1d; border: 1px solid #f5c4b3; }

/* ---- Auth pages ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-wrap h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-wrap h2 { font-size: 15px; font-weight: 400; color: var(--text2); margin-bottom: 20px; }

.auth-links { margin-top: 16px; font-size: 13px; color: var(--text2); }
.auth-links a { color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ---- Installer ---- */
.install-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.install-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 500px;
}

.install-header { margin-bottom: 28px; text-align: center; }
.install-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 16px; }

.steps-indicator { display: flex; gap: 8px; justify-content: center; }

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}
.step-dot.active { border-color: var(--accent); color: var(--accent); }
.step-dot.done   { background: var(--accent); border-color: var(--accent); color: #fff; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.check-row.ok   span { color: #1d9e75; font-weight: 700; }
.check-row.fail span { color: var(--danger); font-weight: 700; }

/* ---- Settings ---- */
.settings-section { margin-bottom: 36px; }
.settings-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ---- Carpetas en manage ---- */
.folder-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.folder-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.folder-icon { font-size: 14px; }
.folder-feeds { padding: 0 14px; }

/* ---- Panel lateral de artículo ---- */
.article-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.article-panel.open {
  transform: translateX(0);
}

.article-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.article-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.article-panel-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.panel-feed-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.panel-date {
  font-size: 12px;
  color: var(--text2);
}

.article-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.panel-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  transition: border-color .12s, background .12s;
  white-space: nowrap;
}
.panel-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.panel-btn-close {
  font-size: 14px;
  padding: 5px 8px;
}
.panel-btn-close:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.article-panel-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.article-panel-summary {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
  flex: 1;
  margin-bottom: 24px;
}

.article-panel-footer {
  flex-shrink: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.panel-visit-btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 14px;
}

.article-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
}
.article-panel-overlay.open { display: block; }

body.panel-open { overflow: hidden; }

/* ---- Responsive ---- */
@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .articles-container.cards { grid-template-columns: 1fr; }
  .content-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .article-panel { width: 100vw; border-left: none; }
}