:root {
  --bg: #0a0e17;
  --bg-soft: #111726;
  --surface: #151c2e;
  --surface-2: #1b2438;
  --border: #243049;
  --border-soft: #1d2740;
  --text: #e6ecf7;
  --text-dim: #8b97b3;
  --text-faint: #5c6885;
  --accent: #4f8cff;
  --accent-cyan: #2dd4bf;
  --accent-green: #34d399;
  --accent-amber: #fbbf24;
  --accent-red: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  position: relative;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(79, 140, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 140, 255, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
  z-index: 0;
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  top: -260px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(circle, rgba(79, 140, 255, 0.16), transparent 65%);
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}

.site-header,
.shell {
  position: relative;
  z-index: 1;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 20px clamp(20px, 5vw, 56px);
  border-bottom: 1px solid var(--border-soft);
  background: rgba(10, 14, 23, 0.7);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: var(--accent);
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.2), rgba(45, 212, 191, 0.12));
  border: 1px solid rgba(79, 140, 255, 0.35);
  box-shadow: 0 0 22px rgba(79, 140, 255, 0.25);
}

.brand-mark svg {
  width: 26px;
  height: 26px;
}

.brand-text h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #fff, #9ec1ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.header-tz {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  font-family: var(--mono);
  color: var(--text-faint);
}

/* Shell */
.shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 32px clamp(20px, 5vw, 56px) 64px;
}

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(160deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(79, 140, 255, 0.45);
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--accent);
  background: rgba(79, 140, 255, 0.12);
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.accent-cyan { color: var(--accent-cyan); background: rgba(45, 212, 191, 0.12); }
.stat-icon.accent-green { color: var(--accent-green); background: rgba(52, 211, 153, 0.12); }
.stat-icon.accent-amber { color: var(--accent-amber); background: rgba(251, 191, 36, 0.12); }

.stat-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.5px;
}

.stat-value.small {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 280px;
  padding: 6px 6px 6px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  flex-shrink: 0;
}

#keyword {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  font-family: var(--font);
}

#keyword::placeholder { color: var(--text-faint); }

.source-filter {
  min-width: 190px;
  height: 44px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 600 13px var(--font);
}

.btn-primary {
  padding: 9px 20px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #6f9fff);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.97); }

.result-count {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.view-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: -4px 0 22px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(21, 28, 46, 0.72);
}

.view-tab {
  min-width: 84px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font: 650 13px var(--font);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.view-tab:hover {
  color: var(--text);
}

.view-tab.active {
  color: var(--text);
  background: rgba(79, 140, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.25);
}

/* Feed */
.feed-scroll {
  padding: 0 0 32px;
}

.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 28px 0 12px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(21, 28, 46, 0.72);
}

.page-btn {
  min-width: 88px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: 600 13px var(--font);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.page-btn:hover:not(:disabled) {
  border-color: rgba(79, 140, 255, 0.5);
  background: rgba(79, 140, 255, 0.12);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.page-info {
  min-width: 110px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 13px;
}

.group-section {
  grid-column: 1 / -1;
  padding: 12px 12px 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(21, 28, 46, 0.35);
}

.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 6px 14px;
}

.group-title {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: var(--text);
}

.group-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}

.feed.loading {
  opacity: 0.5;
  pointer-events: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(165deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  color: inherit;
  text-decoration: none;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-cyan));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(79, 140, 255, 0.5);
  box-shadow: var(--shadow);
}

.card:hover::before,
.card:focus-visible::before { opacity: 1; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
}

.card-date { color: var(--accent-cyan); }
.card-id { color: var(--text-faint); }

.source-pill {
  color: var(--accent);
  background: rgba(79, 140, 255, 0.1);
  border: 1px solid rgba(79, 140, 255, 0.18);
  border-radius: 999px;
  padding: 2px 8px;
}

.card-cover {
  width: 100%;
  height: clamp(150px, 18vw, 220px);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(135deg, rgba(79, 140, 255, 0.08), transparent),
    var(--bg-soft);
}

.card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.card-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 650;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-summary {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  padding: 3px 10px;
  font-size: 11.5px;
  border-radius: 999px;
  color: #9ec1ff;
  background: rgba(79, 140, 255, 0.1);
  border: 1px solid rgba(79, 140, 255, 0.25);
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid var(--border-soft);
}

.card-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.card-action svg {
  width: 15px;
  height: 15px;
  transition: transform 0.2s ease;
}

.card:hover .card-action svg { transform: translateX(3px); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--text-faint);
}

.empty-state svg { width: 48px; height: 48px; opacity: 0.5; }
.empty-state p { margin: 0; font-size: 15px; }

/* Article page */
.brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.article-shell {
  padding-top: 20px;
}

.article-back {
  margin-bottom: 18px;
}

.article-back a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.article-back a:hover {
  color: var(--accent);
}

.article-page {
  background: linear-gradient(165deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.article-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.article-title {
  margin: 0 0 12px;
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.4;
}

.article-cover {
  margin: 0;
  padding: 20px 28px 0;
}

.article-cover img {
  display: block;
  width: 100%;
  max-height: min(68vh, 760px);
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: rgba(10, 14, 23, 0.45);
}

.article-body {
  padding: 24px 28px 36px;
}

/* Detail dialog */
.detail-dialog {
  width: min(880px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.detail-dialog::backdrop {
  background: rgba(5, 8, 14, 0.72);
  backdrop-filter: blur(6px);
}

.detail-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.detail-heading h2 {
  margin: 0 0 10px;
  font-size: 21px;
  line-height: 1.4;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.detail-meta-item { font-family: var(--mono); }

.detail-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover { color: var(--accent-red); border-color: var(--accent-red); }
.icon-btn svg { width: 20px; height: 20px; }

.detail-content {
  padding: 22px 24px;
  overflow: auto;
  font-size: 15px;
  line-height: 1.8;
  color: #d3dbec;
}

.detail-content :where(p, span, section, div, li, strong, em, td, th, .meta-row, .data-meta) {
  color: #d3dbec !important;
  background: transparent !important;
}

.detail-content .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(27, 36, 56, 0.55) !important;
}

.detail-content .meta-row p {
  margin: 0;
}

.detail-content .data-meta {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(27, 36, 56, 0.55) !important;
}

.detail-loading {
  padding: 40px 0;
  text-align: center;
  color: var(--text-faint);
}

.detail-content h2,
.detail-content h3,
.detail-content h4 {
  color: #fff;
  margin: 22px 0 10px;
  line-height: 1.4;
}

.detail-content h2 { font-size: 19px; }
.detail-content h3 { font-size: 17px; }
.detail-content h4 { font-size: 15.5px; }
.detail-content p { margin: 12px 0; }

.detail-content a {
  color: var(--accent-cyan);
  text-decoration: none;
  border-bottom: 1px dashed rgba(45, 212, 191, 0.4);
}

.detail-content a:hover { border-bottom-style: solid; }

.detail-content img {
  display: block;
  max-width: 100%;
  max-height: min(68vh, 760px);
  height: auto;
  margin: 16px auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  object-fit: contain;
}

.detail-content code {
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 13px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--accent-cyan);
}

.detail-content table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 13.5px;
  overflow: hidden;
  border-radius: 8px;
}

.detail-content th,
.detail-content td {
  padding: 9px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.detail-content th {
  background: var(--surface-2);
  color: #fff;
  font-weight: 600;
}

.detail-content tr:nth-child(even) td { background: rgba(27, 36, 56, 0.4); }

.detail-content ul,
.detail-content ol { padding-left: 22px; margin: 12px 0; }
.detail-content li { margin: 6px 0; }

/* Scrollbars */
body::-webkit-scrollbar,
.detail-content::-webkit-scrollbar { width: 10px; }
body::-webkit-scrollbar-track,
.detail-content::-webkit-scrollbar-track { background: transparent; }
body::-webkit-scrollbar-thumb,
.detail-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
  border: 2px solid var(--surface);
}

@media (max-width: 760px) {
  .shell {
    padding: 20px 16px 48px;
  }
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card {
    gap: 10px;
    min-width: 0;
    padding: 12px;
  }
  .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .stat-icon svg {
    width: 19px;
    height: 19px;
  }
  .stat-label {
    font-size: 11.5px;
  }
  .stat-value {
    font-size: 20px;
  }
  .stat-value.small {
    font-size: 12.5px;
  }
  .toolbar {
    gap: 10px;
    margin-bottom: 14px;
  }
  .search-box {
    min-width: 0;
  }
  .result-count {
    width: 100%;
    padding: 0 2px;
    line-height: 1.2;
  }
  .feed-scroll {
    padding-bottom: 16px;
  }
  .view-tabs {
    margin-bottom: 14px;
  }
  .feed { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
  .card-cover { height: clamp(140px, 48vw, 210px); }
  .article-header { padding: 20px 16px 16px; }
  .article-cover { padding: 16px 16px 0; }
  .article-body { padding: 18px 16px 28px; }
  .detail-dialog {
    width: min(100%, calc(100% - 16px));
    max-height: calc(100vh - 16px);
  }
  .detail-panel { max-height: calc(100vh - 16px); }
  .detail-content {
    padding: 18px 16px;
    font-size: 14.5px;
  }
  .detail-content img { max-height: 56vh; }
}

@media (max-width: 560px) {
  .stat-value { font-size: 22px; }
  .feed { grid-template-columns: 1fr; }
  .group-grid { grid-template-columns: 1fr; }
  .detail-header { flex-direction: row; }
}

@media (max-width: 420px) {
  .site-header { padding: 16px; }
  .brand-mark {
    width: 40px;
    height: 40px;
  }
  .brand-text h1 { font-size: 19px; }
  .header-meta { font-size: 12px; }
  .search-box {
    min-width: 0;
    width: 100%;
  }
  .view-tabs {
    display: flex;
    width: 100%;
  }
  .view-tab {
    flex: 1;
    min-width: 0;
  }
  .card-cover { height: clamp(120px, 54vw, 180px); }
  .card-title { font-size: 15.5px; }
  .detail-header { padding: 18px 16px 14px; }
  .detail-heading h2 { font-size: 18px; }
  .icon-btn {
    width: 34px;
    height: 34px;
  }
}
