:root {
  --bg: #f5f7fb;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-soft: #6b7280;
  --brand: #2563eb;
  --brand-light: #dbeafe;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

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

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.topbar a, .topbar a:hover { color: #fff; text-decoration: none; }
.topbar nav { display: flex; gap: 16px; font-size: 14px; font-weight: 500; }
.topbar nav a { opacity: .9; }
.topbar nav a:hover { opacity: 1; }

.notice {
  background: #fef3c7;
  color: #78350f;
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid #fde68a;
}

/* ---------- status panel ---------- */
.status-panel {
  background: #0b1220;
  color: #d1d5db;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  border-radius: var(--radius);
  margin: 12px 0 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.status-panel header {
  background: #111827;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #f3f4f6;
  letter-spacing: .02em;
}
.status-panel header .right { display: flex; gap: 8px; }
.status-panel button {
  background: #1f2937;
  color: #f3f4f6;
  border: 1px solid #374151;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.status-panel button:hover { background: #374151; }
.status-panel button.primary { background: var(--brand); border-color: var(--brand); }
.status-panel button.danger { background: #7f1d1d; border-color: #991b1b; }

.status-body { padding: 12px; display: grid; gap: 8px; }
.status-body .row { display: flex; flex-wrap: wrap; gap: 14px; }
.status-body .row > div {
  background: #111827;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #1f2937;
  min-width: 0;
  word-break: break-all;
}
.status-body .row > div b { color: #f3f4f6; }
.status-body .label { color: #9ca3af; }
.status-body .ok { color: #4ade80; }
.status-body .bad { color: #f87171; }
.status-body .warn { color: #fbbf24; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.dot.green { background: #22c55e; }
.dot.red { background: #ef4444; }
.dot.yellow { background: #f59e0b; }
.dot.gray { background: #6b7280; }

.status-section { border-top: 1px dashed #374151; padding-top: 8px; }
.status-section h4 { margin: 0 0 6px; color: #f3f4f6; font-size: 12.5px; }
.status-section ul { margin: 0; padding-left: 18px; }
.status-section li { margin: 1px 0; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls label { color: #9ca3af; font-size: 12px; }
.controls input[type=range] { vertical-align: middle; }
.controls .val { color: #f3f4f6; font-weight: 600; min-width: 1.5em; display: inline-block; }

.fetch-log {
  max-height: 110px;
  overflow: auto;
  background: #0a0f1a;
  border-radius: 6px;
  padding: 6px 8px;
  border: 1px solid #1f2937;
  font-size: 11.5px;
}
.fetch-log .line { white-space: nowrap; }
.fetch-log .from-cache { color: #60a5fa; }
.fetch-log .from-network { color: #4ade80; }
.fetch-log .from-fail { color: #f87171; }
.fetch-log .from-forced { color: #fbbf24; }

/* ---------- article list ---------- */
.list-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.card .thumb {
  background: #e5e7eb;
  aspect-ratio: 16/9;
  position: relative;
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 24px;
  letter-spacing: .1em;
}
.card .body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-soft); }
.card .title { font-size: 16px; font-weight: 700; line-height: 1.35; color: var(--text); }
.card .summary { font-size: 13.5px; color: var(--text-soft); }

.badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.cat { background: var(--brand-light); color: #1e40af; }
.badge.cat.pol { background: #fee2e2; color: #991b1b; }
.badge.cat.fin { background: #fef3c7; color: #92400e; }
.badge.cat.spt { background: #dcfce7; color: #166534; }
.badge.cat.tec { background: #dbeafe; color: #1e40af; }
.badge.cat.lif { background: #ede9fe; color: #5b21b6; }
.badge.offline-ok { background: #dcfce7; color: #166534; }
.badge.offline-no { background: #f3f4f6; color: #4b5563; }
.badge.read { background: #e0e7ff; color: #3730a3; }
.badge.stale { background: #fef3c7; color: #92400e; }

/* ---------- article page ---------- */
.article {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 28px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}
.article h1 { font-size: 24px; margin: 8px 0 4px; line-height: 1.3; }
.article .meta { color: var(--text-soft); font-size: 13px; margin-bottom: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.article .hero { aspect-ratio: 16/8; overflow: hidden; border-radius: 8px; background: #e5e7eb; position: relative; margin-bottom: 14px; }
.article .hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.article .hero .fallback { position: absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#fff; font-weight:800; font-size:32px; letter-spacing:.1em; }
.article .body { font-size: 16.5px; line-height: 1.8; color: #1f2937; }
.article .footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.article .footer a { padding: 8px 14px; background: var(--brand-light); border-radius: 6px; color: #1e40af; font-weight: 600; }
.article .source-info {
  margin-top: 14px;
  padding: 10px 12px;
  background: #0b1220;
  color: #d1d5db;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  border-radius: 8px;
}

/* ---------- about ---------- */
.prose { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); }
.prose h2 { margin-top: 28px; font-size: 18px; }
.prose h2:first-child { margin-top: 0; }
.prose code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 13.5px; }
.prose ol, .prose ul { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose .note { background: #eff6ff; padding: 8px 12px; border-left: 3px solid var(--brand); border-radius: 6px; margin: 12px 0; }

@media (max-width: 480px) {
  .article h1 { font-size: 20px; }
  .status-body .row { gap: 8px; }
  .status-body .row > div { flex: 1 1 100%; }
}
