:root {
  --bg: #F8FAFC;
  --panel: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --weak: #94A3B8;
  --line: #E2E8F0;
  --card-line: #E5E7EB;
  --chip: #F1F5F9;
  --accent: #3B3FC4;
  --accent-hover: #3336A8;
  --accent-soft: #EEF2FF;
  --accent-border: #6366F1;
  --accent-text: #3730A3;
  --ok: #22C55E;
  --warning: #F59E0B;
  --error: #EF4444;
  --unknown: #CBD5E1;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { border: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(20px, calc((100vw - 1180px) / 2 + 20px));
  background: rgba(248, 250, 252, 0.86);
  border-bottom: 1px solid rgba(226, 232, 240, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  font-size: 17px;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 6px;
}

.nav a {
  height: 34px;
  min-width: 56px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.nav a[aria-current="page"],
.nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.hero {
  display: grid;
  gap: 20px;
}

.hero-copy { display: grid; gap: 6px; }

.eyebrow {
  display: none;
}

.hero h1 {
  margin: 0;
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  color: var(--text);
}

.hero p {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--muted);
}

.hero-search {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}

.hero-search span {
  color: var(--weak);
  font-size: 14px;
  font-weight: 600;
}

.hero-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 15px;
}

.discover-form {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: -6px;
}

.status-pill {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #FFFFFF;
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.status-dot,
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--unknown);
}

.status-dot.ok, .health-dot.ok { background: var(--ok); }
.status-dot.warning, .health-dot.warning { background: var(--warning); }
.status-dot.error, .health-dot.error { background: var(--error); }

.category-rail {
  margin-top: 0;
}

.chip-row,
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 0 6px;
  margin-bottom: 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chip-row::-webkit-scrollbar,
.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #FFFFFF;
  color: #475569;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.chip.active,
.filter-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text);
}

.filter-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 0;
}

.desktop-filter {
  min-width: 0;
}

.section-label {
  display: none;
}

.filter-chip,
.ghost-button {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  color: #475569;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.ghost-button {
  flex: 0 0 auto;
}

.mobile-filter-button {
  display: none;
}

.summary-row {
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.feed-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}

.feed-card {
  min-height: 220px;
  min-width: 0;
  padding: 18px;
  background: #FFFFFF;
  border: 1px solid var(--card-line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.feed-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.feed-identity {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.favicon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: #EEF2FF;
  color: var(--accent);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 700;
}

.favicon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-title {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 17px;
  line-height: 24px;
  font-weight: 700;
}

.domain {
  color: var(--weak);
  font-size: 13px;
  line-height: 18px;
}

.short-url {
  max-width: 230px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-badge {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  font-size: 0;
}

.description {
  margin: 14px 0 0;
  color: #475569;
  font-size: 14px;
  line-height: 21px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.meta-chip {
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--chip);
  color: #475569;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tag {
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #F8FAFC;
  color: #64748B;
  border: 1px solid var(--line);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.card-actions,
.detail-actions {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.secondary-button,
.copy-button,
.primary-button {
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-button,
.copy-button {
  width: 88px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  color: #334155;
}

.primary-button {
  flex: 1;
  min-width: 0;
  background: var(--accent);
  color: #FFFFFF;
}

.card-actions .copy-button + .primary-button {
  grid-column: 1 / -1;
}

.primary-button:hover { background: var(--accent-hover); }
.primary-button:disabled { opacity: 0.7; cursor: wait; }
.primary-button.done { background: var(--ok); }
.primary-button.exists { background: #64748B; }
.primary-button.failed { background: var(--error); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  max-height: 80vh;
  border-radius: 20px;
  background: #FFFFFF;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
  padding: 0;
  overflow: hidden;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #FFFFFF;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button:hover { background: var(--chip); }

.modal-panel > .icon-button {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 1;
}

.preview-header {
  height: 68px;
  padding: 0 70px 0 22px;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.preview-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 24px;
}

.preview-header .muted {
  margin-top: 2px;
  font-size: 13px;
}

.preview-list {
  max-height: calc(80vh - 138px);
  overflow-y: auto;
  padding: 18px 22px;
}

.preview-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--chip);
}

.preview-item:first-child { padding-top: 0; }

.preview-item h4 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 22px;
  font-weight: 600;
}

.preview-item .muted {
  display: block;
  margin-top: 4px;
  color: var(--weak);
  font-size: 12px;
}

.preview-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.modal-actions {
  height: 70px;
  padding: 14px 22px;
  border-top: 1px solid #E5E7EB;
  background: #FFFFFF;
  display: flex;
}

.skeleton { display: grid; gap: 12px; }
.skeleton-line {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #EEF2F7, #F8FAFC, #EEF2F7);
  background-size: 220% 100%;
  animation: shimmer 1.1s infinite linear;
}
.skeleton-line.short { width: 48%; }
@keyframes shimmer { to { background-position: -220% 0; } }

.filter-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: end;
  background: rgba(15, 23, 42, 0.35);
}

.filter-sheet-panel {
  max-height: 76vh;
  overflow: auto;
  padding: 18px;
  border-radius: 22px 22px 0 0;
  background: #FFFFFF;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-close { position: static; }

.detail-shell {
  max-width: 820px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--muted);
}

.detail-layout {
  display: grid;
  gap: 16px;
}

.detail-main,
.detail-preview {
  padding: 18px;
  background: #FFFFFF;
  border: 1px solid var(--card-line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.detail-hero-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.detail-main h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 36px;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.detail-row {
  padding: 12px;
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  word-break: break-all;
}

.detail-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--weak);
  font-size: 12px;
  font-weight: 600;
}

.detail-row code,
.detail-row a {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.discover-results {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.discover-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.discover-group-head h2 {
  margin: 0;
  font-size: 18px;
}

.discover-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.discover-item {
  padding: 18px;
  background: #FFFFFF;
  border: 1px dashed var(--line);
  border-radius: 18px;
}

.muted { color: var(--muted); }

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #FFFFFF;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 12px;
  background: #0F172A;
  color: #FFFFFF;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

@media (min-width: 640px) {
  .feed-grid,
  .discover-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .chip-row { flex-wrap: wrap; }
  .feed-grid,
  .discover-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (max-width: 639px) {
  .topbar {
    padding: 12px 14px;
  }

  .shell {
    padding: 16px 14px 32px;
  }

  .hero h1 {
    font-size: 26px;
    line-height: 34px;
  }

  .hero-search {
    min-height: 50px;
  }

  .chip-row {
    flex-wrap: nowrap;
  }

  .desktop-filter {
    display: none;
  }

  .mobile-filter-button {
    display: inline-flex;
    align-items: center;
  }

  .filter-panel {
    justify-content: flex-start;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .modal-panel {
    width: 100%;
    height: 80vh;
    max-height: 80vh;
    border-radius: 22px 22px 0 0;
  }

  .preview-list {
    max-height: calc(80vh - 138px);
  }

  .card-actions,
  .detail-actions {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
  }
}
