:root {
  --bg: #0b1020;
  --bg2: #0f1830;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(120, 180, 255, 0.16);
  --text: #e8eefc;
  --muted: #93a4c4;
  --accent: #36e0ff;
  --accent2: #4f8cff;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  /* 分类色 */
  --c-shi: #36e0ff;   /* 市政道路 */
  --c-shui: #4f8cff;  /* 水利堤坝 */
  --c-neng: #ff9f43;  /* 能源矿业 */
  --c-chan: #2ed573;  /* 产品技术 */
  --c-guo: #b368ff;   /* 国际前沿 */
  --c-xue: #ff6fb5;   /* 学术标准 */
  --c-shi2: #ffd93d;  /* 市场政策 */
}
[data-theme="light"] {
  --bg: #eef2fb;
  --bg2: #ffffff;
  --card: #ffffff;
  --card-border: rgba(40, 90, 180, 0.14);
  --text: #16203a;
  --muted: #5b6b8c;
  --shadow: 0 8px 24px rgba(40, 90, 180, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 80% -10%, rgba(54, 224, 255, 0.10), transparent 60%),
              radial-gradient(900px 500px at 0% 0%, rgba(79, 140, 255, 0.10), transparent 55%),
              linear-gradient(180deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: 90px;
  transition: background .3s, color .3s;
}
.bg-glow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; backdrop-filter: blur(12px);
  background: rgba(10, 16, 32, 0.55);
  border-bottom: 1px solid var(--card-border);
}
[data-theme="light"] .topbar { background: rgba(255,255,255,0.7); }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; color: #04121f; font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 18px rgba(54, 224, 255, 0.5);
}
.brand-text h1 { font-size: 17px; margin: 0; letter-spacing: .5px; }
.brand-text p { font-size: 12px; margin: 2px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--card-border);
  background: var(--card); color: var(--text); font-size: 18px; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

/* 标签 */
.tabs { display: flex; gap: 8px; padding: 12px 16px 4px; position: relative; z-index: 1; }
.tab {
  flex: 1; padding: 9px 0; border-radius: 10px; border: 1px solid var(--card-border);
  background: var(--card); color: var(--muted); font-size: 14px; cursor: pointer; transition: .2s;
}
.tab.active { color: #04121f; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; font-weight: 700; }

main { padding: 8px 16px; position: relative; z-index: 1; }
.tab-pane { display: none; animation: fade .35s ease; }
.tab-pane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 统计 */
.stats { display: flex; gap: 10px; margin: 8px 0; }
.stat {
  flex: 1; padding: 12px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--card-border); text-align: center;
}
.stat b { display: block; font-size: 22px; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { font-size: 11px; color: var(--muted); }

/* 趋势 */
.trend-card { padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--card-border); margin: 10px 0; }
.trend-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.trend-total { color: var(--accent); font-weight: 700; }

/* 控件 */
.controls { margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--card-border); background: var(--card); color: var(--muted); transition: .2s;
}
.chip.active { color: #04121f; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; font-weight: 700; }
.row2 { display: flex; gap: 8px; }
.select, .search {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--card-border);
  background: var(--card); color: var(--text); font-size: 14px; outline: none;
}
.select { flex: 0 0 38%; }
.search { flex: 1; }

/* 列表/卡片 */
.list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.card {
  position: relative; padding: 14px 14px 12px; border-radius: 16px; background: var(--card);
  border: 1px solid var(--card-border); box-shadow: var(--shadow); cursor: pointer;
  animation: fade .35s ease; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cat, var(--accent)); }
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; color: #04121f; font-weight: 700; background: var(--cat, var(--accent)); }
.imp { font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--card-border); color: var(--muted); }
.imp.高 { color: #ff6b6b; border-color: rgba(255,107,107,.4); }
.imp.中 { color: var(--accent); border-color: rgba(54,224,255,.4); }
.imp.低 { color: var(--muted); }
.date { margin-left: auto; font-size: 11px; color: var(--muted); }
.card h3 { font-size: 15.5px; margin: 2px 0 6px; line-height: 1.45; }
.card p { font-size: 13px; color: var(--muted); margin: 0 0 8px; line-height: 1.6; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.kw { padding: 2px 7px; border-radius: 6px; background: rgba(120,180,255,.10); color: var(--accent); }
.params { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--accent2); }
.ai-note { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(54,224,255,.07); border-left: 3px solid var(--accent); font-size: 12.5px; color: var(--text); }
.ai-note b { color: var(--accent); }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.mini-btn { font-size: 12px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--card-border); background: transparent; color: var(--muted); cursor: pointer; }
.mini-btn:active { transform: scale(.95); }
.mini-btn.on { color: #ffd93d; border-color: rgba(255,217,61,.5); }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }

/* 底栏 */
.footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); gap: 10px;
  background: rgba(10, 16, 32, 0.7); backdrop-filter: blur(12px); border-top: 1px solid var(--card-border);
}
[data-theme="light"] .footer { background: rgba(255,255,255,0.8); }
#updatedAt { font-size: 11.5px; color: var(--muted); }
.ai-fab {
  padding: 10px 16px; border-radius: 999px; border: none; color: #04121f; font-weight: 700; font-size: 13px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 0 18px rgba(54,224,255,.45);
}
.ai-fab:active { transform: scale(.96); }

/* 弹层 */
.modal, .sheet { position: fixed; inset: 0; z-index: 50; display: grid; }
.modal { place-items: center; background: rgba(2, 6, 16, 0.7); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; width: min(560px, 92vw); max-height: 84vh; overflow: auto;
  background: var(--bg2); border: 1px solid var(--card-border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
}
.modal-close, .sheet-head button { position: absolute; top: 12px; right: 14px; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--card-border); background: var(--card); color: var(--text); font-size: 18px; cursor: pointer; }
#detailBody h2 { font-size: 18px; margin: 0 0 10px; line-height: 1.4; }
#detailBody .meta { margin: 10px 0; }
#detailBody .ai-note { margin-top: 14px; }
#detailBody a { color: var(--accent); }

/* AI 面板 */
.sheet { align-items: end; background: rgba(2,6,16,.5); }
.sheet-head {
  position: relative; padding: 14px 16px; font-size: 14px; font-weight: 700;
  background: var(--bg2); border-bottom: 1px solid var(--card-border); border-radius: 18px 18px 0 0;
  display: flex; align-items: center;
}
.sheet-body { background: var(--bg2); padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; max-height: 80vh; overflow: auto; }
.ai-config { display: flex; flex-direction: column; gap: 8px; }
.ai-config label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.ai-config input, .ai-config select { padding: 9px 10px; border-radius: 9px; border: 1px solid var(--card-border); background: var(--card); color: var(--text); font-size: 13px; }
.ai-context { font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--card-border); border-radius: 9px; padding: 8px 10px; }
.ai-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.ai-actions button { flex: 1; min-width: 80px; padding: 9px 6px; border-radius: 9px; border: 1px solid var(--card-border); background: var(--card); color: var(--text); font-size: 12.5px; cursor: pointer; }
.ai-actions button:active { transform: scale(.96); }
#aiInput { min-height: 64px; padding: 10px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--card); color: var(--text); font-size: 13px; resize: vertical; font-family: inherit; }
.ai-output { min-height: 90px; padding: 12px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--card); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.ai-output.loading::after { content: "▋"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 380px) {
  .brand-text h1 { font-size: 15px; }
  .stat b { font-size: 19px; }
}
