:root {
  --bg: #0b1020;
  --panel: #121a30;
  --panel-2: #1a2440;
  --border: #26324f;
  --text: #e6ebf5;
  --muted: #8d9ab5;
  --accent: #ff7a45;
  --blue: #40a9ff;
  --green: #52c41a;
  --yellow: #faad14;
  --red: #ff4d4f;
  --topbar-h: 56px;
  --footer-h: 32px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}
a { color: var(--blue); }
button { font: inherit; color: inherit; }
h2, h3, h4 { margin: 0.6em 0 0.4em; }
h3 { font-size: 15px; color: #c9d3ea; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading { color: var(--muted); padding: 12px 0; }
.loading::before { content: "⏳ "; }
.error { color: #ffb3b3; background: #3a1620; border: 1px solid #5c2230; padding: 8px 10px; border-radius: 6px; margin: 8px 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* 顶栏 */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab {
  background: none; border: 0; padding: 8px 14px; border-radius: 6px; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

main { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; overflow: auto; }
.view.active { display: block; }

/* 地图视图 */
#view-map.active { display: flex; overflow: hidden; }
#map { flex: 1; height: 100%; background: #0a0f1c; }

/* 3D 地球视图 */
#view-globe.active { display: block; position: relative; }
#globe { position: absolute; inset: 0; }
.globe-hint {
  position: absolute; top: 10px; left: 10px; max-width: calc(100% - 180px);
  background: rgba(18, 26, 48, 0.85); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 12px; font-size: 12px; color: var(--muted); z-index: 2; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .globe-hint { display: none; } /* 窄屏下与底图切换器会重叠，隐藏提示保留切换器 */
}
.globe-layer-switcher {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; font-size: 13px;
}
.globe-info {
  position: absolute; bottom: 16px; left: 16px; z-index: 2; width: 320px; max-height: 50%;
  overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.globe-info-close { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; font-size: 16px; }
/* 未使用 Cesium Ion，隐藏其默认 Logo 与出处面板，改用页脚统一署名 */
#globe .cesium-viewer-bottom { display: none; }

.sidebar {
  width: 400px;
  max-width: 45vw;
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 12px 16px 24px;
}
.sidebar-search input[type="search"], .list-header input[type="search"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.check { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }

.site-list, .mini-list, .popup-list { list-style: none; margin: 0; padding: 0; }
.site-item, .mini-launch {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--border); padding: 8px 4px; cursor: pointer;
}
.site-item:hover, .mini-launch:hover { background: var(--panel-2); }
.site-name { flex: 1; }
.site-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.site-meta b { color: var(--accent); }
.mini-launch { align-items: flex-start; gap: 10px; }
.mini-date {
  display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; min-width: 44px;
  font-weight: 600; color: var(--accent); font-size: 13px; line-height: 1.3; padding-top: 1px;
}
.mini-date-time { color: var(--muted); font-weight: 400; font-size: 11px; }
.mini-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-title { font-weight: 600; }
.mini-sub, .mini-time { font-size: 12px; color: var(--muted); }
.mini-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.mini-cd { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cd { color: var(--accent); font-variant-numeric: tabular-nums; margin-left: 6px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-up { background: var(--accent); }
.dot-active { background: var(--blue); }
.dot-inactive { background: #8c8c8c; }

.btn-link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 4px 0; }
.btn { background: var(--accent); border: 0; color: #fff; padding: 8px 14px; border-radius: 6px; cursor: pointer; }

.site-head img { width: 100%; max-height: 160px; object-fit: cover; border-radius: 8px; margin-top: 8px; }
.site-head h2 { font-size: 18px; }
.site-head details { margin-top: 8px; color: #c2cbe0; }
.site-head summary { cursor: pointer; color: var(--blue); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stats div { background: var(--panel-2); border-radius: 8px; padding: 8px; text-align: center; }
.stats b { display: block; font-size: 18px; }
.stats span { font-size: 12px; color: var(--muted); }

.subtabs { display: flex; gap: 4px; margin: 16px 0 4px; border-bottom: 1px solid var(--border); }
.subtab { background: none; border: 0; padding: 6px 12px; cursor: pointer; color: var(--muted); }
.subtab.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

/* 天气 */
.weather-box { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.now { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.now-icon { font-size: 36px; }
.now-temp { font-size: 20px; font-weight: 600; }
.now-temp span { font-size: 14px; font-weight: 400; color: #c9d3ea; margin-left: 6px; }
.daily { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 6px 0; }
.day { text-align: center; font-size: 11px; background: var(--bg); border-radius: 6px; padding: 6px 2px; }
.day-name { color: var(--muted); }
.day-icon { font-size: 20px; }
.day-temp { font-weight: 600; }
.day-extra { color: var(--muted); }

.assess { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 8px; margin-bottom: 10px; }
.assess-score { font-size: 28px; font-weight: 700; min-width: 52px; text-align: center; }
.assess-level { font-weight: 700; font-size: 16px; }
.lvl-go { background: rgba(82, 196, 26, 0.15); border: 1px solid rgba(82, 196, 26, 0.5); }
.lvl-go .assess-score { color: var(--green); }
.lvl-caution { background: rgba(250, 173, 20, 0.15); border: 1px solid rgba(250, 173, 20, 0.5); }
.lvl-caution .assess-score { color: var(--yellow); }
.lvl-nogo { background: rgba(255, 77, 79, 0.15); border: 1px solid rgba(255, 77, 79, 0.5); }
.lvl-nogo .assess-score { color: var(--red); }
.hourly { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.hourly th, .hourly td { padding: 4px; text-align: center; border-bottom: 1px solid var(--border); }
.hourly th { color: var(--muted); font-weight: 400; }
.hourly tr.hl { background: rgba(255, 122, 69, 0.18); font-weight: 600; }

/* 地图控件 */
.legend { background: rgba(18, 26, 48, 0.9); color: var(--text); padding: 8px 10px; border-radius: 6px; font-size: 12px; line-height: 1.8; }
.legend .dot { margin-right: 6px; vertical-align: -1px; }
.pad-icon { font-size: 18px; text-align: center; line-height: 22px; filter: drop-shadow(0 0 3px #000); }
.leaflet-popup-content { font-size: 13px; }
.popup-list li { padding: 4px 0; border-bottom: 1px solid #eee; }
.popup-list .muted { color: #888; }
.leaflet-tooltip { font-size: 12px; }

/* 列表视图 */
.list-header { display: flex; align-items: center; gap: 16px; padding: 12px 20px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
.list-header h2 { white-space: nowrap; }
.list-header input, #news-form { max-width: 420px; flex: 1; }
#news-form { display: flex; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; padding: 0 20px 24px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: transform 0.15s, border-color 0.15s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-img { height: 150px; background: var(--panel-2) center/cover no-repeat; }
.card-body { padding: 10px 14px 14px; }
.card-body h3 { margin: 6px 0 4px; font-size: 16px; color: var(--text); }
.card-sub { color: var(--muted); font-size: 13px; }
.card-time { margin: 4px 0; font-size: 13px; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid; }
.st-go { color: var(--green); border-color: var(--green); }
.st-success { color: var(--green); border-color: var(--green); background: rgba(82, 196, 26, 0.1); }
.st-tbd, .st-tbc { color: var(--muted); border-color: var(--muted); }
.st-hold, .st-partial { color: var(--yellow); border-color: var(--yellow); }
.st-failure { color: var(--red); border-color: var(--red); }
.st-flight, .st-live { color: var(--blue); border-color: var(--blue); }

/* 新闻 */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding: 0 20px 24px; }
.news-grid.compact { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); padding: 0; gap: 10px; }
.news { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; color: var(--text); text-decoration: none; }
.news:hover { border-color: var(--blue); }
.news img { width: 100%; height: 160px; object-fit: cover; }
.compact .news img { height: 100px; }
.news-body { padding: 10px 12px; }
.news h4 { margin: 4px 0; font-size: 15px; }
.news p { margin: 0; color: #b7c1d8; font-size: 13px; }
.compact .news p { display: none; }

/* 弹窗 */
dialog {
  width: min(820px, 94vw); max-height: 90vh; padding: 0; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); color: var(--text); overflow: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-close { position: sticky; top: 8px; float: right; margin: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.6); font-size: 20px; cursor: pointer; z-index: 2; }
.dlg-hero { height: 240px; background: center/cover no-repeat; }
.dlg-content { padding: 16px 24px 24px; }
.dlg-time { color: #c9d3ea; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.desc { color: #c2cbe0; }

/* 用块级 + text-align 居中而不是 flex 居中：内容超宽时从左侧开始显示、右侧省略，保证最前面的备案号始终可见 */
.footer { height: var(--footer-h); line-height: calc(var(--footer-h) - 1px); flex-shrink: 0; text-align: center; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: var(--panel); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 800px) {
  .brand small { display: none; }
  #view-map.active { flex-direction: column; }
  #map { height: 50%; flex: none; }
  .sidebar { width: 100%; max-width: none; height: 50%; border-left: 0; border-top: 1px solid var(--border); }
  .list-header { flex-wrap: wrap; }
  .footer { font-size: 10px; }
}
