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

:root {
  --bg: #111111;
  --surface: #1e1e1e;
  --text: #ffffff;
  --muted: #333333;
  --muted-text: #888888;
  --accent: #4a9eff;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --text: #111111;
    --muted: #dddddd;
    --muted-text: #666666;
    --accent: #0066cc;
  }
}

html { height: 100%; }

body {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

/* ── Header ── */
header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--muted);
}

.app-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

h1 { font-size: 20px; font-weight: 700; }

/* ── Filter bar ── */
#filter-bar {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--muted);
  background: var(--bg);
}

#filter-bar::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid var(--muted);
  background: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Pull-to-refresh indicator ── */
#pull-indicator {
  flex-shrink: 0;
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: height 0.15s ease;
}

.pull-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Offline notice ── */
#offline-notice {
  flex-shrink: 0;
  padding: 6px 16px;
  background: var(--surface);
  color: var(--muted-text);
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid var(--muted);
}

#offline-notice[hidden] { display: none; }

/* ── Main scroll area ── */
main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#article-list {
  list-style: none;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Article card ── */
.article-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--muted);
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.article-card:active { background: var(--surface); }

.article-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.article-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.article-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-meta {
  font-size: 12px;
  color: var(--muted-text);
}

.article-snippet {
  font-size: 13px;
  color: var(--muted-text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Read state ── */
.is-read .article-title {
  color: var(--muted-text);
}

/* ── Save button ── */
.save-btn {
  display: block;
  width: 100%;
  padding: 2px 16px 4px;
  text-align: left;
  background: none;
  border: none;
  color: var(--muted-text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.save-btn[data-saved="true"] {
  color: var(--accent);
}

/* ── Block button ── */
.block-btn {
  display: block;
  width: 100%;
  padding: 4px 16px 8px;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--muted);
  color: var(--muted-text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

/* ── Skeleton loading ── */
.skeleton-item { padding: 12px 16px; }

.skeleton-card {
  height: 72px;
  background: var(--surface);
  border-radius: 10px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Error / empty state ── */
.feed-message {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted-text);
  font-size: 15px;
}

.feed-message button {
  display: block;
  margin: 16px auto 0;
  padding: 9px 22px;
  border-radius: 8px;
  border: 1px solid var(--muted);
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

/* ── Nudge bar ── */
#nudge-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  gap: 8px;
  z-index: 100;
}

#nudge-bar[hidden] { display: none; }

#nudge-dismiss {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px;
}

/* ── Settings button ── */
#settings-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* ── Settings panel ── */
#settings-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}

#settings-panel[hidden] { display: none; }

.settings-header {
  display: flex;
  align-items: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--muted);
}

.settings-title {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

#settings-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.settings-section {
  padding: 20px 16px 8px;
}

.settings-section h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-text);
  margin-bottom: 12px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--muted);
}

.item-row-name {
  flex: 1;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-row-badge {
  font-size: 11px;
  color: var(--muted-text);
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 99px;
  flex-shrink: 0;
}

.item-row-delete {
  background: none;
  border: none;
  color: var(--muted-text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.add-form {
  margin-top: 16px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-form input {
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 9px 12px;
}

.add-form input::placeholder {
  color: var(--muted-text);
}

.add-form button[type="submit"] {
  padding: 9px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.settings-empty {
  color: var(--muted-text);
  font-size: 13px;
  padding: 8px 0;
}
