:root {
  --rp-bg: #f7f8fb;
  --rp-surface: #ffffff;
  --rp-text: #1d2433;
  --rp-muted: #5b6478;
  --rp-border: #e6e8ef;
  --rp-accent: #4f46e5;
  --rp-accent-hover: #4338ca;
  --rp-danger: #dc2626;
  --rp-radius: 14px;
  --rp-radius-sm: 10px;
  --rp-shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --rp-shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
  --rp-shadow-lg: 0 24px 60px rgba(17, 24, 39, 0.18);
  --rp-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --rp-bg: #0f1115;
    --rp-surface: #181b22;
    --rp-text: #e7e9ef;
    --rp-muted: #9aa3b2;
    --rp-border: #262a33;
    --rp-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

body.rp-body {
  background: var(--rp-bg);
  color: var(--rp-text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}

h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.01em;
  font-weight: 600;
}

.rp-navbar {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rp-border);
  z-index: 1020;
}

@media (prefers-color-scheme: dark) {
  .rp-navbar {
    background: rgba(24, 27, 34, 0.82);
  }
  .navbar-toggler-icon {
    filter: invert(1);
  }
}

.rp-search-form #rp-search {
  width: 16rem;
  transition: width 0.2s var(--rp-ease);
}
.rp-search-form #rp-search:focus {
  width: 22rem;
}

.feed-group-header {
  border-bottom: 1px solid var(--rp-border);
  background: var(--rp-bg);
  z-index: 1010;
}

.day-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--rp-muted);
  border-bottom: 1px solid var(--rp-border);
  padding-bottom: 0.35rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 56px;
  background: var(--rp-bg);
  z-index: 1005;
}

.rss-card {
  position: relative;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  box-shadow: var(--rp-shadow-sm);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s var(--rp-ease), box-shadow 0.2s var(--rp-ease), border-color 0.2s var(--rp-ease);
}

.rss-card:hover,
.rss-card:focus-within {
  transform: translateY(-3px);
  box-shadow: var(--rp-shadow-md);
  border-color: transparent;
}

.rss-card:focus-visible {
  outline: 3px solid var(--rp-accent);
  outline-offset: 2px;
}

.rss-card-image {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1a1d24, #0b0c10);
  overflow: hidden;
}

.rss-card-image > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--rp-ease);
}

.rss-card:hover .rss-card-image > img {
  transform: scale(1.04);
}

.rss-card-image--fallback {
  display: grid;
  place-items: center;
}

.rss-card-image--fallback::after {
  /* Subtle radial highlight to give the gradient more depth. */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.22),
    rgba(255, 255, 255, 0) 55%
  );
  pointer-events: none;
}

.rss-card-favicon-badge {
  position: relative;
  z-index: 1;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25),
              inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: transform 0.5s var(--rp-ease);
}

.rss-card-favicon-badge > img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}

.rss-card:hover .rss-card-favicon-badge {
  transform: scale(1.06);
}

.rss-card-publication--overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.7rem 0.95rem 1.4rem;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  background: linear-gradient(
    to bottom,
    rgba(8, 10, 14, 0.72) 0%,
    rgba(8, 10, 14, 0.32) 55%,
    rgba(8, 10, 14, 0) 100%
  );
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Make room for the star button (top-left) when it's present. */
.rss-card:has(.rss-star-btn) .rss-card-publication--overlay {
  padding-left: 3.1rem;
}

.rss-card-title {
  margin: 0 0 0.5rem;
  color: var(--rp-text);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rss-card .card-body {
  padding: 0.9rem 0.95rem 0.6rem;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.rss-card .card-text {
  color: var(--rp-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rss-card .card-footer {
  background: transparent;
  border-top: 1px solid var(--rp-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding: 0.55rem 0.95rem 0.7rem;
  color: var(--rp-muted);
  font-size: 0.8rem;
}

.rss-zoom-btn {
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

.rss-card[data-has-audio="true"]::before {
  content: "♪";
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 1;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.85rem;
  pointer-events: none;
}

.rss-star-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s var(--rp-ease), background 0.15s var(--rp-ease);
}

.rss-star-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.rss-star-btn[data-starred="1"] {
  color: #facc15;
}

.rss-star-btn.pop {
  animation: star-pop 0.3s var(--rp-ease);
}

@keyframes star-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.modal.fade .modal-dialog {
  transform: scale(0.94) translateY(12px);
  opacity: 0;
  transition: transform 0.28s var(--rp-ease), opacity 0.22s var(--rp-ease);
}

.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.lightbox .modal-content {
  border: none;
  border-radius: var(--rp-radius);
  box-shadow: var(--rp-shadow-lg);
  overflow: hidden;
  background: var(--rp-surface);
}

.lightbox .modal-body {
  padding: 0;
}

.lightbox .lb-hero img {
  max-height: 42vh;
  object-fit: cover;
}

.lightbox .lb-title {
  font-size: 1.35rem;
  font-weight: 600;
}

.lightbox .lb-meta {
  color: var(--rp-muted);
  font-size: 0.85rem;
}

.lightbox .lb-description {
  line-height: 1.65;
}

.lightbox .lb-description img {
  max-width: 100%;
  height: auto;
  border-radius: var(--rp-radius-sm);
  margin: 0.5rem 0;
}

#lb-audio {
  accent-color: var(--rp-accent);
}

.rp-lb-close {
  z-index: 2;
}

.rp-group-card {
  border-radius: var(--rp-radius);
  border: 1px solid var(--rp-border);
  border-left: 3px solid var(--rp-accent);
  box-shadow: var(--rp-shadow-sm);
}

.drag-handle {
  cursor: grab;
  color: var(--rp-muted);
  padding: 0.25rem;
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-handle:hover {
  color: var(--rp-accent);
}

.feed-list.drop-target {
  outline: 2px dashed var(--rp-accent);
  outline-offset: 4px;
}

.rp-icon-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  line-height: 1;
}

.rp-icon-btn.spinning {
  animation: rp-spin 0.8s linear infinite;
}

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

.rp-auth-card {
  border-radius: var(--rp-radius);
}

.rp-snippet mark {
  background: rgba(79, 70, 229, 0.2);
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}

.rp-star-thumb {
  width: 48px;
  height: 48px;
}

.rp-star-note:empty:before {
  content: attr(data-placeholder);
  color: var(--rp-muted);
}

/* -------- Compact view: feeds-as-cards with item lists -------- */

.rp-compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 350px);
  gap: 1rem;
  justify-content: start;
}

.rss-feed-compact {
  --feed-accent: linear-gradient(135deg, #4f46e5, #9333ea);
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 350px;
  height: 100%;
  background: var(--rp-surface);
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  box-shadow: var(--rp-shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s var(--rp-ease), transform 0.2s var(--rp-ease);
}

.rss-feed-compact::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--feed-accent);
  opacity: 0.9;
}

.rss-feed-compact:hover {
  box-shadow: var(--rp-shadow-md);
  transform: translateY(-1px);
}

.rss-feed-compact-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--rp-border);
}

.rss-feed-compact-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--feed-accent);
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.rss-feed-compact-icon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

.rss-feed-compact-icon.is-empty {
  /* No favicon available; the gradient stands in by itself. */
}

.rss-feed-compact-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--rp-text);
}

.rss-feed-compact-count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.rss-feed-compact-count-total {
  opacity: 0.55;
}

.rss-feed-compact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.rss-feed-compact-empty {
  padding: 0.75rem 0.9rem;
}

/* -------- Item row used inside compact feed cards -------- */

.rp-item-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid var(--rp-border);
  cursor: pointer;
  transition: background-color 0.15s var(--rp-ease);
  min-width: 0;
}

.rp-item-row:first-child {
  border-top: 0;
}

.rp-item-row:hover {
  background: color-mix(in srgb, var(--rp-accent) 6%, transparent);
}

.rp-item-row:focus-visible {
  outline: 2px solid var(--rp-accent);
  outline-offset: -2px;
}

.rp-item-row > :not(.rss-star-btn):not(.rp-item-row-preview) {
  pointer-events: none;
}

.rss-star-btn--sm {
  position: relative;
  top: auto;
  left: auto;
  z-index: 2;
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  font-size: 0.85rem;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: var(--rp-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rss-star-btn--sm[data-starred="1"] {
  color: #f59e0b;
}

.rp-item-row-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--rp-text);
}

.rp-item-row-date {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--rp-muted) 55%, transparent);
}

.rp-item-row-preview {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.05rem 0.35rem;
  font-size: 0.75rem;
  text-decoration: none;
  color: var(--rp-muted);
  background: var(--rp-surface);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.15s var(--rp-ease);
}

.rp-item-row:hover .rp-item-row-preview,
.rp-item-row:focus-within .rp-item-row-preview {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
