/* 视觉只做功能级；细节之后交给设计工具打磨。
   风险四色只用于表达风险，不拿来装饰。 */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --text: #15181d;
  --muted: #5d6673;
  --line: #d9dde3;
  --accent: #1f5fbf;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);

  --risk-0: #2e9e5b;   /* 绿 稳定 */
  --risk-1: #d9a90f;   /* 黄 观察 */
  --risk-2: #e6731b;   /* 橙 预警 */
  --risk-3: #d23f3f;   /* 红 临界 */

  --radius: 14px;
  --gutter: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #181c22; --surface-2: #222830; --text: #eef1f5;
    --muted: #9aa4b1; --line: #2c333c; --accent: #6ea3ff; --on-accent: #0b1220; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #181c22; --surface-2: #222830; --text: #eef1f5;
  --muted: #9aa4b1; --line: #2c333c; --accent: #6ea3ff; --on-accent: #0b1220; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; -webkit-text-size-adjust: 100%; line-height: 1.5; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- 顶栏与标签 ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter) 0;
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 8px; }
.top h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: .5px; }
.top .date { font-size: 13px; color: var(--muted); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; cursor: pointer; min-height: 32px;
}
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; border: 0; background: none; padding: 10px 12px 12px; font-size: 15px;
  color: var(--muted); border-bottom: 2.5px solid transparent; cursor: pointer; position: relative;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab .dot {
  position: absolute; top: 8px; right: 2px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--risk-3);
}

main { padding: 14px var(--gutter) calc(env(safe-area-inset-bottom) + 32px); max-width: 1100px; margin: 0 auto; }

/* ---------- 提醒横幅（触发式监控） ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  border: 1px solid var(--risk-3); border-left-width: 5px; border-radius: var(--radius);
  background: var(--surface); padding: 12px 14px; margin-bottom: 14px; cursor: pointer;
}
.alert.lvl-2 { border-color: var(--risk-2); }
.alert b { display: block; }
.alert span { font-size: 13px; color: var(--muted); }

.stale {
  border: 1px solid var(--risk-2); color: var(--text); background: var(--surface);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}

/* ---------- 新闻瓦片 ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  overflow: hidden; box-shadow: var(--shadow);
}
.card:focus-visible, .gauge-card:focus-visible, .alert:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.thumb {
  aspect-ratio: 16 / 9; width: 100%; object-fit: cover; display: block; background: var(--surface-2);
}
.thumb-fallback {
  aspect-ratio: 16 / 9; width: 100%; display: flex; align-items: flex-end; padding: 12px;
  background: linear-gradient(135deg, var(--surface-2), var(--line));
  color: var(--muted); font-weight: 600; font-size: 14px;
}
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.card h3 { font-size: 17px; line-height: 1.35; margin: 0; }
.card p { margin: 0; font-size: 14px; color: var(--muted); }
.meta { font-size: 12px; color: var(--muted); }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- 风险仪表盘 ---------- */
.gauges { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .gauges { grid-template-columns: repeat(2, 1fr); } }
.gauge-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 14px; text-align: left; cursor: pointer; box-shadow: var(--shadow);
  border-top: 5px solid var(--band);
}
.gauge-card h3 { margin: 0 0 4px; font-size: 16px; }
.gauge-row { display: flex; align-items: center; gap: 14px; }
.gauge-row svg { width: 132px; flex: none; }
.gauge-num { font-size: 28px; font-weight: 700; color: var(--band); line-height: 1.1; }
.gauge-band { font-size: 14px; font-weight: 600; }
.gauge-sub { font-size: 12px; color: var(--muted); }
.lights { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 10px; }
.light { width: 12px; height: 12px; border-radius: 50%; }
.lvl-0 { --band: var(--risk-0); } .lvl-1 { --band: var(--risk-1); }
.lvl-2 { --band: var(--risk-2); } .lvl-3 { --band: var(--risk-3); }
.light.lvl-0, .chip.lvl-0 { background: var(--risk-0); }
.light.lvl-1, .chip.lvl-1 { background: var(--risk-1); }
.light.lvl-2, .chip.lvl-2 { background: var(--risk-2); }
.light.lvl-3, .chip.lvl-3 { background: var(--risk-3); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 16px 0 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.quiet { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* ---------- 详情抽屉 ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); width: 100%; max-width: 720px; max-height: 92dvh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 0 0 calc(env(safe-area-inset-bottom) + 20px);
}
@media (min-width: 760px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head {
  position: sticky; top: 0; background: var(--surface); display: flex; justify-content: flex-end;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.sheet-content { padding: 16px var(--gutter) 0; }
.sheet h2 { margin: 0 0 6px; font-size: 21px; line-height: 1.35; }
.sheet .why {
  background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 12px 0; font-size: 15px;
}
.sheet ul { padding-left: 20px; margin: 8px 0; }
.sheet li { margin: 6px 0; }
.sheet .hero { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.btn-primary {
  display: block; text-align: center; text-decoration: none; margin-top: 18px; padding: 13px;
  border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.ind { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ind .chip { width: 14px; height: 14px; border-radius: 50%; flex: none; margin-top: 4px; }
.ind b { display: block; font-size: 15px; }
.ind span { font-size: 13px; color: var(--muted); }
.srcs { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- 登入 ---------- */
.login {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--gutter);
}
.login form {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login input {
  width: 100%; font-size: 17px; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
.login button[type="submit"] {
  width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 16px; cursor: pointer;
}
.login .err { color: var(--risk-3); font-size: 14px; min-height: 20px; margin-top: 8px; }
.login .lang { margin-top: 14px; }
