/* 页面基础样式（变量、控件、侧栏、画面里的卡片）：从 index.html 拆出来（UI 改造第 ① 步，样式不变） */
/* 布局：左侧测绘记录本式控制面板，右侧整屏 3D 场景；手机端面板收为底部抽屉 */
:root {
  --paper: #f3f1ec;
  --paper-2: #e8e5dd;
  --ink: #1f2326;
  --muted: #646a6e;
  --line: #cfcac0;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --grid: #e4c9c3;
  --ok: #2f7d4f;
  --warn: #b7791f;
  --bad: #b3261e;
  --dead: #3b3f42;
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d2023; --paper-2: #262a2e; --ink: #e9e6df; --muted: #9aa0a4; --line: #3a3f44;
    --accent: #e0574c; --accent-ink: #1a0d0b; --grid: #3d2c2a; --ok: #5cbf86; --warn: #e2a94a; --bad: #ef6b60; --dead: #c9ccce;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1d2023; --paper-2: #262a2e; --ink: #e9e6df; --muted: #9aa0a4; --line: #3a3f44;
  --accent: #e0574c; --accent-ink: #1a0d0b; --grid: #3d2c2a; --ok: #5cbf86; --warn: #e2a94a; --bad: #ef6b60; --dead: #c9ccce;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); overflow: hidden; }
#app { display: grid; grid-template-columns: 360px 1fr; height: 100%; }
#panel { overflow-y: auto; padding: 20px 20px 28px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 22px; background: var(--paper); }
#stage { position: relative; min-width: 0; background: #b9c4cc; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

h1 { font-family: var(--font-display); font-weight: 900; font-size: 26px; margin: 0; letter-spacing: 0.02em; text-wrap: balance; }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; line-height: 1.55; }
/* 界面语言切换（i18n.js） */
#panel header { position: relative; }
#langSw { position: absolute; right: 0; top: 2px; display: flex; gap: 2px; }
#langSw button { padding: 2px 7px; font: 600 11px/1.4 var(--font-data); border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 3px; cursor: pointer; }
#langSw button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
section { display: flex; flex-direction: column; gap: 10px; }
.label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.label span { font-family: var(--font-data); letter-spacing: 0; text-transform: none; font-weight: 400; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#shareBox { margin-top: 6px; } #shareUrl { width: 100%; box-sizing: border-box; font: 11px/1.4 ui-monospace, monospace; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line, #ccc); background: transparent; color: inherit; }
button:disabled { opacity: 0.45; cursor: default; }
select, button { font: inherit; font-size: 14px; color: var(--ink); }
select { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); background: var(--paper-2); border-radius: 6px; }
button { border: 1px solid var(--line); background: var(--paper-2); padding: 8px 12px; border-radius: 6px; cursor: pointer; }
button:hover { border-color: var(--ink); }
button:focus-visible, select:focus-visible, input:focus-visible, li:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; flex: 1; padding: 11px 14px; font-size: 15px; }
button.primary.stop { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.seed { font-family: var(--font-data); font-size: 12px; color: var(--muted); }

.mag { display: flex; align-items: flex-end; gap: 14px; }
.mag-num { font-family: var(--font-data); font-weight: 600; font-size: 56px; line-height: 0.9; font-variant-numeric: tabular-nums; color: var(--accent); }
.mag-meta { display: flex; flex-direction: column; gap: 2px; padding-bottom: 4px; min-width: 0; }
.mag-meta b { font-size: 15px; }
.mag-meta small { color: var(--muted); font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font-family: var(--font-data); font-size: 12px; padding: 4px 9px; }
.chips button.on { border-color: var(--accent); color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.facts div { background: var(--paper); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts small { font-size: 11px; color: var(--muted); }
.facts b { font-family: var(--font-data); font-size: 16px; font-variant-numeric: tabular-nums; }
.desc { font-size: 13px; line-height: 1.6; margin: 0; }
.desc em { font-style: normal; font-weight: 700; color: var(--accent); }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg button.on { outline: 2px solid currentColor; outline-offset: -2px; }
.seg button { font-size: 13px; padding: 7px 6px; }
#seis { width: 100%; height: 120px; border-radius: 6px; border: 1px solid var(--line); display: block; }
#blist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#blist li { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; padding: 7px 10px; border-top: 1px solid var(--line); cursor: pointer; font-size: 13px; }
#blist li:first-child { border-top: 0; }
#blist li:hover { background: var(--paper-2); }
#blist .lot { font-family: var(--font-data); font-size: 12px; color: var(--muted); }
#blist .bn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.s-ok { color: var(--ok); } .s-crack { color: var(--warn); } .s-part { color: var(--bad); }
.s-down { color: var(--paper); background: var(--dead); border-color: var(--dead); }
#log { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.55; max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
#log li { display: grid; grid-template-columns: 46px 1fr; gap: 6px; }
#log li.bad span { color: var(--bad); }
#log li.warn span { color: var(--warn); }
#log li.quake span { font-weight: 700; }
#log time { font-family: var(--font-data); color: var(--muted); font-variant-numeric: tabular-nums; }
#log .empty { display: block; color: var(--muted); }
.credit { font-size: 11px; color: var(--muted); line-height: 1.6; margin: 0; }

#hud { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; align-items: stretch; pointer-events: none; flex-wrap: wrap; justify-content: flex-end; }
.hud-card { background: rgba(20, 24, 27, 0.62); color: #eef0ee; border-radius: 8px; padding: 7px 11px; display: flex; flex-direction: column; justify-content: center; gap: 1px; backdrop-filter: blur(8px); }
.hud-card small { font-size: 11px; color: #b8c0c4; }
.hud-card b { font-family: var(--font-data); font-size: 17px; font-variant-numeric: tabular-nums; }
.hud-int b { font-family: var(--font-display); font-size: 28px; color: #ff8a7a; line-height: 1; }
#state { font-size: 13px; font-weight: 700; }
#busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20, 24, 27, 0.55); color: #f3f1ec; font-size: 14px; z-index: 5; }
.hint { position: absolute; left: 14px; bottom: 12px; font-size: 12px; color: #eef0ee; background: rgba(20,24,27,0.5); padding: 4px 8px; border-radius: 4px; pointer-events: none; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 52% 48%; }
  #stage { grid-row: 1; }
  #panel { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); padding: 14px 16px 24px; gap: 18px; }
  .mag-num { font-size: 44px; }
  #hud { top: 8px; right: 8px; gap: 6px; }
  .hud-card { padding: 5px 8px; }
  .hud-card b { font-size: 14px; }
  .hud-int b { font-size: 22px; }
  .hint { display: none; }
}
/* 演示模式的开始倒计时（不是预警，不放声音） */
#countdown { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(10, 12, 14, 0.35); color: #fff; pointer-events: none; }
#countdown[hidden] { display: none; }
#countdown .cd-txt { font: 600 20px/1.3 var(--font-body); letter-spacing: .08em; }
#countdown .cd-num { font: 700 72px/1 var(--font-data); }
#countdown button { pointer-events: auto; padding: 6px 18px; }
.note { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
/* 震级相近的真实地震 */
#nearQ { margin-top: 10px; }
#nearQ ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#nearQ li { background: var(--paper-2); border-radius: 6px; padding: 6px 8px; font-size: 12.5px; line-height: 1.45; }
#nearQ .nq-h { display: flex; gap: 8px; align-items: baseline; }
#nearQ .nq-h span { font-family: var(--font-data); color: var(--muted); font-size: 12px; }
#nearQ .nq-go { margin-left: auto; padding: 1px 8px; font-size: 12px; }
#nearQ .nq-d { color: var(--accent); }
#nearQ .nq-n { color: var(--muted); }
#nearQ a { font-size: 11px; color: var(--muted); }
/* 抗震规范对比表 */
#codeCmpBtn { margin-top: 8px; width: 100%; }
#codeCmpOut { margin-top: 8px; font-size: 12.5px; }
#codeCmpOut[hidden] { display: none; }
#codeCmpOut table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#codeCmpOut th, #codeCmpOut td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--line); }
#codeCmpOut th:first-child, #codeCmpOut td:first-child { text-align: left; color: var(--muted); }
#codeCmpOut th { font-weight: 600; font-size: 12px; } #codeCmpOut th small { display: block; font-weight: 400; color: var(--muted); }
#codeCmpOut .cur { background: var(--paper-2); }
#codeCmpOut td small { color: var(--muted); }
#codeCmpOut p { margin: 6px 0 0; line-height: 1.5; }
/* 历史地震回放：真实 / 模拟对照 */
#histDesc { margin-top: 8px; }
#histCmp { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; line-height: 1.5; }
#histCmp[hidden] { display: none; }
#histCmp > div { background: var(--paper-2); border-radius: 6px; padding: 6px 8px; }
#histCmp small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
#histCmp ul { margin: 0; padding-left: 18px; color: var(--muted); }
/* 对话气泡（行人视角） */
#bubbles { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.bubble { position: absolute; left: 0; top: 0; max-width: 220px; padding: 4px 9px; border-radius: 10px; background: rgba(255,255,255,.92); color: #1d1d1f;
  font: 600 14px/1.35 var(--font-body); white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: rgba(255,255,255,.92); }
.bubble.quakeStrong, .bubble.wave, .bubble.collapse, .bubble.tsunami { background: rgba(255,236,232,.95); color: #8e1b12; }
.bubble.hurt, .bubble.trapped, .bubble.child { background: rgba(255,246,222,.95); }
.bubble.rescue { background: rgba(232,244,255,.95); color: #0d3c6e; }
/* 室内视角：所在的楼倒塌时画面变黑 */
#indoorFade { position: absolute; inset: 0; z-index: 8; background: #000; opacity: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
#indoorFade[hidden] { display: none; }
#indoorFade p { color: #ddd; font: 600 18px/1.4 var(--font-body); letter-spacing: .1em; }
#binfo .bi-in { margin: 8px 0 2px; width: 100%; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.3); }
/* 点楼看原因：右侧卡片 */
#binfo { position: absolute; right: 14px; top: 84px; z-index: 6; width: 340px; max-height: min(calc(100% - 180px), calc(100vh - 190px)); overflow-y: auto; padding: 12px 14px 10px;
  background: rgba(20, 24, 27, 0.82); color: #eef0ee; border-radius: 10px; backdrop-filter: blur(8px); font-size: 12.5px; line-height: 1.5; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
#binfo[hidden] { display: none; }
#binfo h3 { margin: 0 22px 8px 0; font-size: 15px; }
#binfo .bi-st { font-size: 12px; font-weight: 400; padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,.14); margin-left: 4px; }
#binfo h4 { margin: 10px 0 4px; font-size: 12px; color: #b8c0c4; letter-spacing: .06em; }
#binfo dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
#binfo dt { color: #b8c0c4; white-space: nowrap; } #binfo dd { margin: 0; }
#binfo ul, #binfo ol { margin: 0; padding-left: 18px; } #binfo li { margin: 2px 0; } #binfo p { margin: 0; }
#binfo .bi-close { position: absolute; right: 8px; top: 6px; padding: 0 8px; background: transparent; border: 0; color: #eef0ee; font-size: 18px; }
#binfo .bi-note { display: block; margin-top: 10px; color: #8d969b; font-size: 11px; }
@media (max-width: 760px) { #binfo { left: 8px; right: 8px; width: auto; top: auto; bottom: 90px; max-height: 45%; } }
/* 灾情统计：地震开始后出现在画面右下角 */
#dstats { position: absolute; right: 14px; bottom: 14px; z-index: 5; display: grid; grid-template-columns: repeat(6, auto); gap: 4px 14px;
  background: rgba(20, 24, 27, 0.62); color: #eef0ee; border-radius: 8px; padding: 8px 12px; backdrop-filter: blur(8px); pointer-events: none; font-size: 12px; }
#dstats span { color: #b8c0c4; }
#dstats b { font-family: var(--font-data); font-size: 14px; font-variant-numeric: tabular-nums; margin-left: 4px; color: #fff; }
#dstats b.bad { color: #ff8a80; }
@media (max-width: 760px) { #dstats { grid-template-columns: repeat(2, auto); right: 8px; bottom: 8px; } }
/* 地震预警：中央横幅（倒数）+ 手机通知卡片 + 电视底部滚动字幕 */
#eew { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6; padding: 10px 18px; border-radius: 8px;
  display: flex; align-items: center; gap: 14px; background: #c62118; color: #fff; font: 600 15px/1.35 var(--font-body);
  box-shadow: 0 6px 24px rgba(0,0,0,.35); animation: eewPulse 0.9s ease-in-out infinite alternate; pointer-events: none; white-space: nowrap; }
#eew[hidden], #eewPhone[hidden] { display: none; }
#eew small { font-weight: 400; opacity: .9; }
#eew .eew-n { font: 700 40px/1 var(--font-data); min-width: 1.4em; text-align: center; }
@keyframes eewPulse { from { opacity: 1; } to { opacity: .78; } }
#eewPhone { position: absolute; left: 14px; top: 14px; z-index: 6; width: 270px; padding: 10px 12px; border-radius: 14px;
  background: rgba(245, 245, 247, 0.94); color: #1d1d1f; box-shadow: 0 8px 28px rgba(0,0,0,.3); font: 13px/1.45 var(--font-body); pointer-events: none; }
#eewPhone b { color: #c62118; } #eewPhone span { float: right; color: #888; font-size: 11px; }
#eewPhone p { margin: 4px 0 0; } #eewPhone em { font-style: normal; font-weight: 700; color: #c62118; }
#eewPhone p.weak { color: #8a5a00; font-size: 12px; }
/* 无人机图传画面的叠加参数（drone.js） */
#droneHud { position: absolute; inset: 0; z-index: 3; pointer-events: none; color: #fff; font: 600 12px/1.3 var(--font-data); text-shadow: 0 1px 2px rgba(0,0,0,.8); }
#droneHud[hidden] { display: none; }
.dr-top { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; padding: 4px 12px; border-radius: 4px; background: rgba(0,0,0,.32); white-space: nowrap; }
.dr-top .low { color: #ff6b5e; } .dr-mode { color: #8fe3a0; }
.dr-bars { display: inline-flex; gap: 1px; align-items: flex-end; height: 11px; margin-left: 3px; vertical-align: -1px; }
.dr-bars b { width: 3px; background: rgba(255,255,255,.3); } .dr-bars b.on { background: #fff; }
.dr-bot { position: absolute; left: 50%; top: 112px; transform: translateX(-50%); display: flex; gap: 16px; padding: 4px 12px; border-radius: 4px; background: rgba(0,0,0,.32); white-space: nowrap; }
.dr-cross { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; }
.dr-cross::before, .dr-cross::after { content: ''; position: absolute; background: rgba(255,255,255,.75); }
.dr-cross::before { left: 0; right: 0; top: 12px; height: 1.5px; } .dr-cross::after { top: 0; bottom: 0; left: 12px; width: 1.5px; }
.dr-frame { position: absolute; inset: 18% 22%; border: 1px solid rgba(255,255,255,.18); }
.dr-warn { position: absolute; left: 50%; top: 140px; transform: translateX(-50%); padding: 3px 10px; border-radius: 4px; background: rgba(160,40,20,.75); white-space: nowrap; font-weight: 600; }
@media (max-width: 760px) { .dr-top, .dr-bot { gap: 8px; font-size: 10px; } }
/* 电视新闻（虚构的「QL 新闻 24」，见 news.js）：左下角 16:9 小电视 */
#news { position: absolute; left: 14px; bottom: 40px; z-index: 6; width: 320px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden;
  box-shadow: 0 8px 26px rgba(0,0,0,.4); border: 2px solid #15181b; background: #0d2a52; color: #fff; font-family: var(--font-body); }
#news[hidden] { display: none; }
.nw-scr { position: absolute; inset: 0; }
.nw-scr.red { background: radial-gradient(circle at 50% 40%, #d4261b, #8f130c); }
.nw-bg { position: absolute; inset: 0; width: 100%; height: 100%; } .nw-scr.red .nw-bg { display: none; }
.nw-bug { position: absolute; left: 8px; top: 7px; padding: 2px 6px; border: 1.5px solid rgba(255,255,255,.85); border-radius: 3px; font: 800 11px/1.2 var(--font-body); letter-spacing: .5px; background: rgba(0,0,0,.18); }
.nw-live { position: absolute; right: 26px; top: 8px; font: 600 10px/1.2 var(--font-data); font-style: normal; opacity: .9; }
.nw-live::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: #ff4b3e; vertical-align: 1px; }
.nw-off { position: absolute; left: 8px; top: 28px; padding: 1px 5px; border-radius: 3px; background: rgba(0,0,0,.55); color: #ffd36b; font: 600 10px/1.4 var(--font-body); font-style: normal; }
.nw-off[hidden] { display: none; } .nw-scr.red .nw-off { display: none; }
.nw-body { position: absolute; left: 12px; right: 12px; top: 26%; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.nw-scr:not(.red) .nw-body { right: 44%; top: 30%; }
.nw-h { display: block; font: 800 17px/1.25 var(--font-body); }
.nw-body p { margin: 3px 0 0; font-size: 11px; line-height: 1.35; opacity: .95; }
.nw-n { font: 800 34px/1 var(--font-data); margin-top: 2px; } .nw-n.sm { font-size: 22px; }
.nw-scr.red .nw-body { text-align: center; top: 15%; }
.nw-strap { position: absolute; left: 0; right: 0; bottom: 20px; display: flex; height: 22px; font: 700 12px/22px var(--font-body); white-space: nowrap; overflow: hidden; }
.nw-strap b { flex: none; padding: 0 8px; background: #d4261b; letter-spacing: 1px; }
.nw-scr.red .nw-strap b { background: #ffd200; color: #8f130c; }
.nw-strap span { flex: 1; padding: 0 8px; background: rgba(255,255,255,.94); color: #10203a; overflow: hidden; text-overflow: ellipsis; }
.nw-tk { position: absolute; left: 0; right: 0; bottom: 0; height: 20px; overflow: hidden; background: #0a1a33; font: 500 11px/20px var(--font-body); white-space: nowrap; }
.nw-tk span { display: inline-block; padding-left: 100%; animation: nwTicker 20s linear infinite; }
@keyframes nwTicker { to { transform: translateX(-100%); } }
.nw-x { position: absolute; right: 4px; top: 4px; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.4); color: #fff; font: 13px/18px sans-serif; cursor: pointer; }
@media (max-width: 760px) { #news { width: 230px; left: 8px; bottom: 8px; } .nw-h { font-size: 14px; } .nw-n { font-size: 26px; } }
  /* 浏览器要求用户操作后才能放声音：第一次点击页面前的提示 */
  #soundHint { position: absolute; left: 12px; top: 12px; z-index: 30; padding: 6px 12px; border-radius: 16px; background: rgba(20, 24, 28, 0.78); color: #f2efe6;
    font: 500 13px 'Noto Sans SC', sans-serif; cursor: pointer; animation: hintPulse 2.4s ease-in-out infinite; }
  #soundHint.gone { display: none; }
  /* 预警盲区示意：震中、盲区圈、本地位置 */
  .eew-note { display: flex; gap: 10px; align-items: center; margin: 6px 0 2px; font-size: 12px; line-height: 1.5; color: #4a4a48; }
  .eew-note svg { flex: none; }
  .eew-note b { color: #1e1e1c; }
  .eew-note .late { color: #b3261e; }
  @keyframes hintPulse { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }
