:root {
  --bg: #fff;
  --bg-alt: #f5f6f8;
  --bg-sidebar: #2b2f36;
  --sidebar-fg: #c7ccd4;
  --sidebar-fg-dim: #868d99;
  --accent: #3d7eff;
  --border: #e3e6ea;
  --text: #1d2126;
  --text-dim: #6b7280;
  --unread-dot: #3d7eff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; }

/* Login */
.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg-alt);
}
.login-card {
  display: flex; flex-direction: column; gap: 10px;
  background: #fff; padding: 32px; border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.12); width: 300px;
}
.login-card h1 { margin: 0 0 8px; text-align: center; }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}
.login-card button {
  padding: 10px; border: 0; border-radius: 8px; background: var(--accent);
  color: #fff; font-weight: 600; font-size: 15px;
}
.error { color: #d23; font-size: 13px; min-height: 16px; margin: 0; text-align: center; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 360px 1fr; height: 100vh; }

/* Sidebar */
.sidebar { background: var(--bg-sidebar); color: var(--sidebar-fg); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-actions button {
  background: transparent; border: 0; color: var(--sidebar-fg-dim); font-size: 16px; padding: 2px 5px;
}
.sidebar-actions button:hover { color: #fff; }
.nav-list { overflow-y: auto; padding: 8px 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; font-size: 14px; color: var(--sidebar-fg); user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.05); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .count { font-size: 12px; color: var(--sidebar-fg-dim); }
.nav-item.active .count { color: #e8eefc; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.feed { padding-left: 22px; }
.favicon { width: 16px; height: 16px; flex: none; border-radius: 3px; object-fit: contain; }
span.favicon { background: transparent; }
.feed-actions { display: none; gap: 2px; margin-left: auto; }
.nav-item.feed:hover .feed-actions { display: flex; }
.nav-item.feed:hover .count { display: none; }
.feed-actions button {
  background: transparent; border: 0; color: var(--sidebar-fg-dim);
  font-size: 12px; padding: 0 4px; line-height: 1;
}
.feed-actions button:hover { color: #fff; }
.nav-item.active .feed-actions button { color: #e8eefc; }
.nav-group { padding: 12px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--sidebar-fg-dim); }

/* Entry list */
.list-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; background: var(--bg-alt); }
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fff;
}
.list-head #list-title { font-weight: 600; }
.list-head-actions { display: flex; gap: 6px; }
.list-head button { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12px; color: var(--text-dim); }
.list-head button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.empty-list { padding: 32px 16px; color: var(--text-dim); text-align: center; font-size: 14px; }
.entry-list { overflow-y: auto; flex: 1; }
.entry {
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; background: #fff;
}
.entry:hover { background: #fafbfc; }
.entry.selected { background: #eaf1ff; }
.entry .e-top { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); margin-bottom: 3px; }
.entry .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unread-dot); flex: none; }
.entry.read .dot { background: transparent; }
.entry.read .e-title { font-weight: 400; color: var(--text-dim); }
.entry .e-feed { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .e-star { margin-left: auto; color: #f0a500; }
.entry .e-title { font-weight: 600; font-size: 14px; line-height: 1.3; margin-bottom: 3px; }
.entry .e-snip { font-size: 13px; color: var(--text-dim); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Reader */
.reader { overflow-y: auto; padding: 0; }
.reader-empty { display: grid; place-items: center; height: 100%; color: var(--text-dim); }
.reader-content { max-width: 680px; margin: 0 auto; padding: 40px 32px 80px; }
.reader-content h1.r-title { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
.reader-content h1.r-title a { color: var(--text); text-decoration: none; }
.reader-content .r-meta { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; display: flex; gap: 12px; align-items: center; }
.reader-content .r-meta button { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 12px; }
.reader-body { font-size: 17px; line-height: 1.7; color: #2a2f36; word-wrap: break-word; }
.reader-body img { max-width: 100%; height: auto; border-radius: 6px; }
.reader-body a { color: var(--accent); }
.reader-body pre { background: var(--bg-alt); padding: 12px; border-radius: 8px; overflow-x: auto; }
.reader-body blockquote { border-left: 3px solid var(--border); margin: 0; padding-left: 16px; color: var(--text-dim); }

/* Mobile: one pane at a time, navigated via data-pane on <body>. */
.mobile-only { display: none; }
.reader-bar { padding: 8px 12px; border-bottom: 1px solid var(--border); background: #fff; position: sticky; top: 0; z-index: 2; }
.back-btn { background: transparent; border: 0; color: var(--accent); font-size: 16px; font-weight: 600; padding: 4px 6px; }

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 100vh; }
  .sidebar, .list-pane, .reader { grid-column: 1; grid-row: 1; border-right: 0; }
  .sidebar, .list-pane, .reader { display: none; }
  body[data-pane="nav"] .sidebar { display: flex; }
  body[data-pane="list"] .list-pane { display: flex; }
  body[data-pane="reader"] .reader { display: block; }
  .mobile-only { display: inline-flex; }

  /* roomier tap targets + edge-to-edge reading */
  .nav-item { padding: 11px 16px; }
  .nav-item.feed { padding-left: 18px; }
  .feed-actions { display: flex; } /* always visible on touch (no hover) */
  .nav-item.feed .count { display: inline; }
  .entry { padding: 14px 16px; }
  .reader-content { padding: 20px 18px 80px; }
  .reader-content h1.r-title { font-size: 22px; }
  .reader-body { font-size: 18px; }
  /* respect the notch */
  .sidebar-head, .list-head, .reader-bar { padding-top: max(14px, env(safe-area-inset-top)); }
}
