/* =============================================================
   TOKENS — Design system variables
   ============================================================= */
:root {
  /* Colors — warm stone palette */
  --c-bg:             #fafaf8;
  --c-surface:        #ffffff;
  --c-surface-subtle: #f5f5f4;
  --c-border:         #e7e5e4;
  --c-border-strong:  #d6d3d1;
  --c-text:           #1c1917;
  --c-text-secondary: #57534e;
  --c-text-muted:     #78716c;
  --c-accent:         #c2410c;
  --c-accent-hover:   #9a3412;
  --c-accent-subtle:  #fff7ed;
  --c-unread:         #c2410c;
  --c-success-bg:     #f0fdf4;
  --c-success-text:   #15803d;
  --c-success-border: #bbf7d0;

  /* Spacing */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font:      system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --lh-tight:   1.3;
  --lh-snug:    1.45;
  --lh-normal:  1.6;
  --lh-relaxed: 1.75;

  /* UI */
  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .06);
  --shadow:    0 1px 3px rgb(0 0 0 / .10), 0 1px 2px rgb(0 0 0 / .06);
  --transition: 150ms ease;

  /* Layout */
  --sidebar-w:  220px;
  --nav-h:      48px;
  --reading-max: 680px;
}

/* Dark mode — applied via data attribute or system preference */
html[data-theme="dark"] {
  --c-bg:             #1c1917;
  --c-surface:        #292524;
  --c-surface-subtle: #1c1917;
  --c-border:         #44403c;
  --c-border-strong:  #57534e;
  --c-text:           #f5f5f4;
  --c-text-secondary: #a8a29e;
  --c-text-muted:     #78716c;
  --c-accent:         #ea580c;
  --c-accent-hover:   #f97316;
  --c-accent-subtle:  #431407;
  --c-unread:         #ea580c;
  --c-success-bg:     #052e16;
  --c-success-text:   #4ade80;
  --c-success-border: #166534;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .2);
  --shadow:    0 1px 3px rgb(0 0 0 / .3), 0 1px 2px rgb(0 0 0 / .2);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --c-bg:             #1c1917;
    --c-surface:        #292524;
    --c-surface-subtle: #1c1917;
    --c-border:         #44403c;
    --c-border-strong:  #57534e;
    --c-text:           #f5f5f4;
    --c-text-secondary: #a8a29e;
    --c-text-muted:     #78716c;
    --c-accent:         #ea580c;
    --c-accent-hover:   #f97316;
    --c-accent-subtle:  #431407;
    --c-unread:         #ea580c;
    --c-success-bg:     #052e16;
    --c-success-text:   #4ade80;
    --c-success-border: #166534;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .2);
    --shadow:    0 1px 3px rgb(0 0 0 / .3), 0 1px 2px rgb(0 0 0 / .2);
    color-scheme: dark;
  }
}


/* =============================================================
   BASE — Reset + global typography
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-3);
  line-height: var(--lh-tight);
  font-weight: 600;
  color: var(--c-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--c-accent);
  text-decoration: none;
}
a:hover {
  color: var(--c-accent-hover);
  text-decoration: underline;
}

ul, ol { margin: 0; padding-left: var(--sp-6); }
li { margin-bottom: var(--sp-1); }

hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: var(--sp-6) 0;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}


/* =============================================================
   FORMS — Inputs & buttons
   ============================================================= */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"] {
  display: block;
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input[type="text"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgb(194 65 12 / .12);
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text-secondary);
  margin-bottom: var(--sp-1);
}

button,
.btn,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: #fff;
  background: var(--c-accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), box-shadow var(--transition);
}
button:hover,
.btn:hover,
input[type="submit"]:hover {
  background: var(--c-accent-hover);
  color: #fff;
  text-decoration: none;
}
button:focus-visible,
.btn:focus-visible,
input[type="submit"]:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.btn-ghost,
button.btn-ghost {
  color: var(--c-text-secondary);
  background: transparent;
  border-color: var(--c-border-strong);
}
.btn-ghost:hover,
button.btn-ghost:hover {
  background: var(--c-surface-subtle);
  color: var(--c-text);
}

.btn-sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
}

.field { display: flex; flex-direction: column; }


/* =============================================================
   NAV
   ============================================================= */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--nav-h);
  padding: 0 var(--sp-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--c-text);
  text-decoration: none;
  margin-right: auto;
}
.nav-brand:hover { text-decoration: none; color: var(--c-text); }

nav a:not(.nav-brand) {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text-secondary);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
nav a:not(.nav-brand):hover {
  color: var(--c-text);
  background: var(--c-surface-subtle);
  text-decoration: none;
}

/* Sign-out button styled as a nav link */
nav form { display: inline; }
#sign-out-button {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text-muted);
  background: none;
  border: none;
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
#sign-out-button:hover {
  color: var(--c-text);
  background: var(--c-surface-subtle);
}

/* Notification toggle in nav */
.nav-notifications {
  display: flex;
  align-items: center;
}
.notification-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text-secondary);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.notification-toggle:hover {
  color: var(--c-text);
  background: var(--c-surface-subtle);
}
.notification-toggle input[type="checkbox"] {
  accent-color: var(--c-accent);
}

/* Hamburger button — hidden on desktop */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.hamburger:hover {
  background: var(--c-surface-subtle);
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--c-text);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Nav links wrapper — inline on desktop */
.nav-links {
  display: contents;
}

/* Mobile styles */
@media (max-width: 640px) {
  nav {
    flex-wrap: wrap;
  }

  .hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    padding-bottom: var(--sp-3);
    gap: var(--sp-1);
    background: var(--c-surface);
  }

  .nav-links--open {
    display: flex;
  }

  .nav-links a,
  .nav-links .notification-toggle,
  .nav-links #sign-out-button {
    width: 100%;
    text-align: left;
    padding: var(--sp-2) var(--sp-3);
  }

  .nav-links .nav-notifications {
    width: 100%;
  }

  .nav-links form {
    width: 100%;
  }
}

/* Theme toggle button — styled as a nav link */
.theme-toggle {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text-secondary);
  background: none;
  border: none;
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.theme-toggle:hover {
  color: var(--c-text);
  background: var(--c-surface-subtle);
}


/* =============================================================
   LAYOUT — Sidebar + main grid
   ============================================================= */
#layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100vh - var(--nav-h));
  transition: grid-template-columns 0.2s ease;
}

/* Collapsed */
#layout.sidebar-collapsed {
  grid-template-columns: 1fr;
}

#sidebar {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  padding-bottom: var(--sp-6);
  transition: padding var(--transition), border-color var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--sp-3) var(--sp-3) 0;
}

#sidebar h3 {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-text-muted);
  padding: var(--sp-4) var(--sp-4) var(--sp-1);
  margin: 0;
  white-space: nowrap;
}
#sidebar ul { list-style: none; padding: 0; margin: 0; }
#sidebar li a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}
#sidebar li a:hover {
  background: var(--c-surface-subtle);
  color: var(--c-text);
  text-decoration: none;
}
.feed-link-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.feed-updated-at {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  flex-shrink: 0;
}
#sidebar .see-more-link {
  color: var(--c-text-muted);
  font-style: italic;
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-4) 0;
  border-top: 1px solid var(--c-border);
  margin-top: var(--sp-4);
}
.sidebar-footer a {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
}

/* Toggle button shared styles */
.sidebar-collapse-btn,
.sidebar-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: var(--text-sm);
  line-height: 1;
  color: var(--c-text-muted);
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition), color var(--transition);
}
.sidebar-collapse-btn:hover,
.sidebar-expand-btn:hover {
  background: var(--c-surface-subtle);
  color: var(--c-text);
}

/* Expand button — always visible when rendered (React controls mount/unmount) */

/* Main article list */
#article-list { overflow-y: auto; }

.article-list-header {
  display: flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 40px;
}

.show-read-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  cursor: pointer;
  margin-left: auto;
  user-select: none;
}

.show-read-toggle input[type="checkbox"] {
  cursor: pointer;
}

.sort-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  user-select: none;
  margin-left: var(--sp-2);
}

.sort-toggle-btn:hover {
  color: var(--c-text);
  border-color: var(--c-text-muted);
}


/* =============================================================
   VIEW MODE TOGGLE
   ============================================================= */
.view-mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-mode-btn {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--c-text-muted);
  background: var(--c-surface);
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.view-mode-btn:hover {
  background: var(--c-surface-subtle);
  color: var(--c-text);
}
.view-mode-btn.active {
  background: var(--c-accent);
  color: #fff;
}
.view-mode-btn.active:hover {
  background: var(--c-accent-hover);
}
.view-mode-btn + .view-mode-btn {
  border-left: 1px solid var(--c-border-strong);
}


/* =============================================================
   SWIPEABLE CARD VIEW
   ============================================================= */
.card-stack-container {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-2) var(--sp-6) var(--sp-6);
  min-height: calc(100vh - var(--nav-h) - 60px);
}

.card-stack-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--c-text-muted);
  font-size: var(--text-lg);
}

.article-card {
  position: relative;
  width: min(500px, calc(100% - var(--sp-8)));
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  touch-action: pan-y;
  user-select: none;
}

.article-card-next {
  position: absolute;
  transform: scale(0.95) translateY(8px);
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
}

.article-card-current {
  position: relative;
  z-index: 1;
  cursor: grab;
}
.article-card-current:active {
  cursor: grabbing;
}

/* Swipe indicators */
.swipe-indicator {
  position: absolute;
  top: var(--sp-6);
  z-index: 10;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
}

.swipe-indicator-favorite {
  right: var(--sp-4);
  color: var(--c-success-text);
  border: 3px solid var(--c-success-text);
  background: var(--c-success-bg);
}

.swipe-indicator-next {
  left: var(--sp-4);
  color: var(--c-accent);
  border: 3px solid var(--c-accent);
  background: var(--c-accent-subtle);
}

/* Card content sections */
.card-content-header {
  padding: var(--sp-5) var(--sp-6) var(--sp-3);
  flex-shrink: 0;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-2);
}

.card-feed-name {
  font-weight: 600;
  color: var(--c-text-secondary);
}

.card-title {
  font-size: var(--text-xl);
  line-height: var(--lh-snug);
  margin-bottom: var(--sp-3);
}

.card-image {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: var(--sp-2);
}

.card-content-body {
  padding: 0 var(--sp-6) var(--sp-4);
}

.card-article-content {
  font-size: var(--text-sm);
  line-height: var(--lh-relaxed);
  color: var(--c-text-secondary);
}
.card-article-content p { margin-bottom: var(--sp-4); }
.card-article-content p:last-child { margin-bottom: 0; }
.card-article-content img,
.card-article-content video,
.card-article-content iframe {
  max-width: 100%;
  height: auto;
}

/* Card footer */
.card-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-subtle);
}

.card-hint {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}

.card-counter {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-text-muted);
  font-variant-numeric: tabular-nums;
}


/* =============================================================
   ARTICLES INDEX — Dense list
   ============================================================= */
.article-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5) var(--sp-3) var(--sp-6);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  position: relative;
  transition: background var(--transition);
}
.article-row:hover { background: var(--c-surface-subtle); }

/* Unread dot */
.article-row.unread::before {
  content: "";
  position: absolute;
  left: var(--sp-2);
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-unread);
}

.article-row .article-title-link {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-row .article-title-link:hover {
  color: var(--c-accent);
  text-decoration: none;
}
.article-row.read .article-title-link {
  color: var(--c-text-muted);
  font-weight: 400;
}

.feed-name,
.pub-date {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.pub-date {
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
}
a.feed-name {
  text-decoration: none;
  color: var(--c-text-muted);
}
a.feed-name:hover {
  color: var(--c-accent);
  text-decoration: underline;
}

/* Expanded article row */
.article-row-expanded {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5) var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  position: relative;
  transition: background var(--transition);
}
.article-row-expanded:hover { background: var(--c-surface-subtle); }

.article-row-expanded.unread::before {
  content: "";
  position: absolute;
  left: var(--sp-2);
  top: var(--sp-5);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-unread);
}

.article-expanded-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.article-expanded-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

.article-expanded-header .article-title-link {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.article-expanded-header .article-title-link:hover {
  color: var(--c-accent);
  text-decoration: none;
}
.article-row-expanded.read .article-title-link {
  color: var(--c-text-muted);
  font-weight: 400;
}

.article-expanded-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}

.article-author {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  font-style: italic;
}

.article-preview {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  line-height: 1.5;
  margin: var(--sp-1) 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-thumbnail {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
  align-self: center;
}

/* Pagination (Pagy) */
.pagy-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-4);
}
.pagy-nav a,
.pagy-nav .current,
.pagy-nav .disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--sp-2);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}
.pagy-nav a {
  color: var(--c-text-secondary);
  border: 1px solid var(--c-border);
  transition: background var(--transition);
}
.pagy-nav a:hover {
  background: var(--c-surface-subtle);
  text-decoration: none;
}
.pagy-nav .current {
  background: var(--c-accent);
  color: #fff;
  font-weight: 600;
  border: 1px solid transparent;
}
.pagy-nav .disabled {
  color: var(--c-border-strong);
}


/* =============================================================
   ARTICLE SHOW — Reading view
   ============================================================= */
.article-show {
  position: relative;
  max-width: var(--reading-max);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6) var(--sp-12);
}

.swipe-zone {
  position: relative;
  touch-action: pan-y;
  user-select: none;
  cursor: grab;
  overflow: hidden;
}

.swipe-zone:active {
  cursor: grabbing;
}

.swipe-hint {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-4);
}

.swipe-hint-next {
  font-style: italic;
}

.back-link {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-5);
}
.back-link:hover { color: var(--c-accent); text-decoration: none; }

.article-show h1 {
  font-size: var(--text-2xl);
  line-height: var(--lh-snug);
  margin-bottom: var(--sp-3);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-4);
}
.article-meta a {
  color: var(--c-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article-meta a:hover { color: var(--c-accent); }

/* Read status action */
#article-read-status form { display: inline; }
#article-read-status { margin-bottom: var(--sp-5); }

#article-content {
  font-size: var(--text-base);
  line-height: var(--lh-relaxed);
  overflow-x: hidden;
}
#article-content img,
#article-content video,
#article-content iframe,
#article-content embed {
  max-width: 100%;
  height: auto;
}
#article-content p { margin-bottom: var(--sp-5); }
#article-content p:last-child { margin-bottom: 0; }

#article-content a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
#article-content a:hover { color: var(--c-accent-hover); }

#article-content strong, #article-content b { font-weight: 700; }
#article-content em, #article-content i { font-style: italic; }

#article-content h1, #article-content h2, #article-content h3,
#article-content h4, #article-content h5, #article-content h6 {
  font-weight: 700;
  line-height: var(--lh-tight);
  margin: var(--sp-6) 0 var(--sp-3);
}
#article-content h1 { font-size: var(--text-2xl); }
#article-content h2 { font-size: var(--text-xl); }
#article-content h3 { font-size: var(--text-lg); }

#article-content ul, #article-content ol {
  margin: 0 0 var(--sp-5) var(--sp-6);
  padding: 0;
}
#article-content ul { list-style: disc; }
#article-content ol { list-style: decimal; }
#article-content li { margin-bottom: var(--sp-2); }
#article-content li:last-child { margin-bottom: 0; }

#article-content blockquote {
  border-left: 3px solid var(--c-border-strong);
  margin: 0 0 var(--sp-5);
  padding: var(--sp-3) var(--sp-5);
  color: var(--c-text-secondary);
  background: var(--c-surface-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
#article-content blockquote p:last-child { margin-bottom: 0; }

#article-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--c-surface-subtle);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
}

#article-content pre {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4);
  background: var(--c-surface-subtle);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: var(--lh-normal);
}
#article-content pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: var(--text-sm);
}

#article-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--sp-5);
}
#article-content th, #article-content td {
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border);
  text-align: left;
}
#article-content th {
  background: var(--c-surface-subtle);
  font-weight: 600;
}

#article-content figure { margin: 0 0 var(--sp-5); }
#article-content figcaption {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-top: var(--sp-2);
}

#article-content hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: var(--sp-6) 0;
}


/* =============================================================
   SUMMARY TABS — Pure CSS radio-based tab system
   ============================================================= */
#summary-section {
  margin-top: var(--sp-8);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.summary-section-heading {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--c-text-muted);
  padding: var(--sp-3) var(--sp-5);
  margin: 0;
  background: var(--c-surface-subtle);
  border-bottom: 1px solid var(--c-border);
}

#summary-tabs {
  display: flex;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}

.tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  user-select: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.tab-btn:hover {
  color: var(--c-text);
  background: var(--c-surface-subtle);
}

/* Active tab highlight per checked radio */
#summary-section:has(#tab-tldr:checked) [for="tab-tldr"],
#summary-section:has(#tab-bullets:checked) [for="tab-bullets"],
#summary-section:has(#tab-tweet_thread:checked) [for="tab-tweet_thread"],
#summary-section:has(#tab-podcast_script:checked) [for="tab-podcast_script"] {
  color: var(--c-accent);
  border-bottom-color: var(--c-accent);
}

/* All panels hidden */
.summary-panel { display: none; }

/* Show the active panel */
#summary-section:has(#tab-tldr:checked) #panel-tldr,
#summary-section:has(#tab-bullets:checked) #panel-bullets,
#summary-section:has(#tab-tweet_thread:checked) #panel-tweet_thread,
#summary-section:has(#tab-podcast_script:checked) #panel-podcast_script {
  display: block;
}

.summary-panel-inner {
  padding: var(--sp-5) var(--sp-6);
  background: var(--c-surface);
}

/* Summary content (from _summary.html.erb) */
.summary { }
.summary h3 { display: none; } /* Label shown by tab instead */
.summary-content {
  font-size: var(--text-sm);
  line-height: var(--lh-relaxed);
  color: var(--c-text);
  overflow-x: hidden;
}
.summary-content img,
.summary-content video,
.summary-content iframe,
.summary-content embed {
  max-width: 100%;
  height: auto;
}
.summary-content p:last-child { margin-bottom: 0; }

.summary-meta {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  margin-top: var(--sp-5);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--c-border);
}

/* Placeholder + generate form */
.summary-placeholder-box {
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
}
.summary-placeholder-box p {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-4);
}

/* Generating state */
.generating {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  padding: var(--sp-10) var(--sp-6);
  justify-content: center;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--c-border-strong);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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


/* =============================================================
   FEEDS PAGE
   ============================================================= */
.feeds-page {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6) var(--sp-12);
}
.feeds-page h1 { margin-bottom: var(--sp-6); }

.add-feed-form {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  padding: var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-8);
}
.add-feed-form .field { flex: 1; }
.add-feed-form label { margin-bottom: var(--sp-1); }
.add-feed-form input[type="url"] { width: 100%; }

.feeds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.feeds-table thead tr {
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-subtle);
}
.feeds-table th {
  padding: var(--sp-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-text-muted);
  text-align: left;
}
.feeds-table td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
  color: var(--c-text-secondary);
}
.feeds-table tr:last-child td { border-bottom: none; }
.feeds-table .feed-name-cell {
  font-weight: 500;
  color: var(--c-text);
}

.category-form {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.category-form input[type="text"] {
  width: auto;
  min-width: 110px;
  font-size: var(--text-xs);
  padding: var(--sp-1) var(--sp-2);
}

.actions-cell {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.actions-cell form { display: inline; }

/* =============================================================
   FEED SUBSCRIPTION SHOW
   ============================================================= */
.feed-subscription-page {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6) var(--sp-12);
}

.feed-subscription-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.feed-subscription-header h1 { margin-bottom: var(--sp-2); }

.feed-description {
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
}

.feed-site-url {
  font-size: var(--text-sm);
}

.feed-subscription-actions {
  flex-shrink: 0;
}

.feed-articles-list {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.feed-articles-list .article-row:last-child {
  border-bottom: none;
}

/* Sidebar feed name as link */
.feed-name-link {
  color: inherit;
}
.feed-name-link:hover {
  color: var(--c-accent);
  text-decoration: underline;
}

/* Feed name link in feeds table */
.feed-name-cell a {
  color: var(--c-text);
}
.feed-name-cell a:hover {
  color: var(--c-accent);
}

/* =============================================================
   FLASH MESSAGES
   ============================================================= */
.flash-container {
  padding: 0 var(--sp-6);
}
#notice {
  margin: var(--sp-3) 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  background: var(--c-success-bg);
  color: var(--c-success-text);
  border: 1px solid var(--c-success-border);
}
#alert {
  margin: var(--sp-3) 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  background: var(--c-accent-subtle);
  color: var(--c-accent);
  border: 1px solid var(--c-accent);
}

/* =============================================================
   FAVORITES PAGE
   ============================================================= */
.favorites-page {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--sp-6);
}
.favorites-page h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-6);
}
.favorites-page .empty-state {
  color: var(--c-text-muted);
  font-size: var(--text-sm);
  padding: var(--sp-8) 0;
}
