/* 悬浮 UI（UI改造方案.md）：画面铺满窗口，UI 浮在画面上。
   层级：0 画布 · 10 对话气泡 · 20 常驻 UI · 30 楼栋信息卡、设置抽屉 · 40 预警、新闻台、倒计时 · 50 室内黑屏 · 60 加载遮罩。
   UI 根容器不接收鼠标（拖滑杆时画面不跟着转，空白处照常拖视角），只有卡片本身接收。 */
:root { --z-bubble: 10; --z-ui: 20; --z-card: 30; --z-alert: 40; --z-fade: 50; --z-busy: 60; --gap: 14px; --ctl-w: 410px; --ctl-h: 210px; }

/* ---------- 画面铺满 ---------- */
body { margin: 0; }
#app { display: block; position: relative; height: 100%; }
#stage { position: absolute; inset: 0; }

/* ---------- 层级 ---------- */
#bubbles { z-index: var(--z-bubble); }
#hud, .hint, #dstats, #droneHud { z-index: var(--z-ui); }
#binfo, #drawer { z-index: var(--z-card); }
#eew, #eewPhone, #news, #countdown, #soundHint { z-index: var(--z-alert); }
#indoorFade { z-index: var(--z-fade); }
#busy { z-index: var(--z-busy); }

/* ---------- 悬浮卡片：深色半透明毛玻璃，里面的控件用深色配色 ---------- */
#ui { position: absolute; inset: 0; pointer-events: none; z-index: var(--z-ui); }
#ui > * { pointer-events: none; }
.ui-card { pointer-events: auto; background: rgba(20, 24, 27, 0.66); color: #eef0ee; border-radius: 10px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  --paper: rgba(20, 24, 27, 0); --paper-2: rgba(255, 255, 255, 0.08); --ink: #eef0ee; --muted: #aab2b6; --line: rgba(255, 255, 255, 0.16); --grid: rgba(255, 255, 255, 0.10); }
body.no-blur .ui-card, body.no-blur .hud-card, body.no-blur #binfo, body.no-blur #dstats { backdrop-filter: none; -webkit-backdrop-filter: none; background-color: rgba(20, 24, 27, 0.84); }
.ui-card button { border-color: var(--line); }
.ui-card select { background: rgba(255, 255, 255, 0.08); color: var(--ink); }
.ui-card select option { color: #1f2326; }

/* 上排：品牌 + ⚙ */
#uiTop { position: absolute; left: var(--gap); top: var(--gap); display: flex; gap: 8px; align-items: center; }
#brand { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; }
#brand h1 { font-size: 19px; color: #f3f1ec; }
#gear { width: 34px; height: 34px; padding: 0; font-size: 18px; line-height: 1; border-radius: 8px; background: rgba(255, 255, 255, 0.1); color: #f3f1ec; }

/* 左列：建筑、破坏记录（标题条一行，点开展开） */
#uiLeft { position: absolute; left: var(--gap); top: 64px; width: 300px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100% - var(--ctl-h) - var(--news-h, 0px) - 110px); }
.strip { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.strip-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; padding: 7px 12px; background: transparent; border: 0; color: #eef0ee; font-size: 13px; font-weight: 700; text-align: left; }
.strip-h > span:first-child::before { content: '▸'; display: inline-block; width: 1.1em; color: #aab2b6; font-weight: 400; }
.strip-h[aria-expanded="true"] > span:first-child::before { content: '▾'; }
.strip-h > span:first-child { flex: none; }
.strip-h > span:last-child { font: 400 12px/1.3 var(--font-data); color: #c9d0d3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-b { overflow-y: auto; padding: 0 10px 10px; min-height: 0; }
.strip-b.closed, #ctlMore.closed { display: none; }
#stripBuild { flex: 0 1 auto; } #stripLog { flex: 0 1 auto; }
#pBuild { max-height: 300px; } #pLog { max-height: 260px; }
#blist { border-color: var(--line); }
#blist li:hover { background: rgba(255, 255, 255, 0.07); }
.s-down { color: #fff; background: #50565a; border-color: #50565a; }
#log { max-height: none; }

/* 右列：记录仪（HUD 下面） */
#uiRight { position: absolute; right: var(--gap); top: 84px; width: 340px; display: flex; flex-direction: column; gap: 8px; }
#seis { height: 110px; border-color: var(--line); }
#pSeis { padding-top: 2px; }

/* 下排：主控制区（左下）+ 视角条（中下） */
#uiBottom { position: absolute; left: var(--gap); right: var(--gap); bottom: var(--gap); display: flex; align-items: flex-end; gap: 12px; }
#ctl { position: relative; width: var(--ctl-w); padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
#ctl .mag { gap: 12px; }
#ctl .mag-num { font-size: 44px; color: #ff8a7a; }
#ctl .mag-meta b { color: #f3f1ec; }
#ctl .mag-meta small { color: #aab2b6; }
#ctl input[type=range] { accent-color: #ff6b5e; }
.ctl-mag, .ctl-dist { display: flex; flex-direction: column; gap: 7px; }

#ctl .facts { background: var(--line); border-color: var(--line); }
#ctl .facts div { background: rgba(20, 24, 27, 0.55); padding: 5px 9px; }
#ctl .facts b { font-size: 15px; color: #fff; }
#ctl .more { position: absolute; right: 10px; top: 10px; padding: 1px 8px; font-size: 12px; background: transparent; color: #aab2b6; }
#ctl .more::after { content: ' ▾'; } #ctl .more[aria-expanded="true"]::after { content: ' ▴'; }
#ctlMore { max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
#ctlMore .desc em { color: #ff8a7a; }
#ctl .eew-note { color: #c9d0d3; } #ctl .eew-note b { color: #fff; } #ctl .eew-note .late { color: #ff8a7a; }
#ctl #nearQ li { background: rgba(255, 255, 255, 0.07); }
.ctl-act { display: flex; gap: 6px; flex-wrap: wrap; }
.ctl-act button { padding: 8px 11px; font-size: 13.5px; }
.ctl-act button.primary { flex: 1 1 140px; font-size: 15px; background: #c62118; border-color: #c62118; color: #fff; }
.ctl-act button.primary.stop { background: #eef0ee; color: #1f2326; border-color: #eef0ee; }
.ctl-act .quick { display: none; }
#viewBar { padding: 6px; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); }
#viewBar .seg { display: flex; gap: 4px; }
#viewBar .seg button { padding: 6px 12px; font-size: 13px; background: transparent; border-color: transparent; color: #dfe4e6; }
#viewBar .seg button:hover { border-color: var(--line); }
#viewBar .seg button.on { background: rgba(255, 255, 255, 0.16); color: #fff; outline: 0; }

/* 画面里原有的几块：给悬浮 UI 让位 */
#hud { top: var(--gap); right: var(--gap); }
.hint { left: auto; right: var(--gap); bottom: 78px; transition: opacity 0.6s; }
.hint.faded { opacity: 0; }
#dstats { right: var(--gap); bottom: var(--gap); }
#eewPhone { left: var(--gap); top: 64px; }
#soundHint { left: 50%; top: auto; bottom: 74px; transform: translateX(-50%); }
#news { left: var(--gap); bottom: calc(var(--ctl-h) + var(--gap) + 12px); }
#binfo { top: 84px; }

/* ---------- 设置抽屉（左侧滑出） ---------- */
#drawer { position: fixed; left: 0; top: 0; bottom: 0; width: 380px; max-width: 92vw; overflow-y: auto; padding: 16px 20px 28px; box-sizing: border-box;
  background: var(--paper); border-right: 1px solid var(--line); box-shadow: 6px 0 30px rgba(0, 0, 0, 0.25); display: flex; flex-direction: column; gap: 22px;
  transform: translateX(-104%); transition: transform 0.25s ease; visibility: hidden; }
body.drawer-open #drawer { transform: none; visibility: visible; }
#drawer header { display: flex; align-items: center; gap: 10px; }
#drawer h2 { margin: 0; font: 900 20px/1.2 var(--font-display); flex: 1; }
#drawer #langSw { position: static; }
#drawerClose { padding: 0 10px; font-size: 20px; line-height: 30px; background: transparent; border-color: transparent; }

/* H 键：隐藏全部 UI（预警照常显示） */
body.ui-hidden #ui, body.ui-hidden #hud, body.ui-hidden .hint, body.ui-hidden #dstats, body.ui-hidden #binfo { display: none; }

/* ---------- 按阶段变化（<body data-phase>，overlay-ui.js 设）---------- */
#ctlEdit { display: none; }
#ctl .ctl-act button, #ctl .mag-num { transition: font-size 0.2s; }
/* 倒计时 / 等待：主控制区缩成一个大大的“取消” */
body[data-phase="armed"] #ctl { width: 300px; }
body[data-phase="armed"] #ctl > :not(.ctl-act), body[data-phase="armed"] .ctl-act > :not(#go) { display: none; }
body[data-phase="armed"] #go { font-size: 18px; padding: 14px; }
/* 震动中：主控制区缩成一条“M7.0 · ■ 停止”，其余 UI 淡到一半，烈度和记录仪放大 */
body[data-phase="shaking"] #ctl { width: auto; flex-direction: row; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; }
body[data-phase="shaking"] #ctl > :not(.ctl-act):not(.ctl-mag), body[data-phase="shaking"] .ctl-act > :not(#go),
body[data-phase="shaking"] #mag, body[data-phase="shaking"] #presets, body[data-phase="shaking"] .mag-meta small { display: none; }
body[data-phase="shaking"] #ctl .mag-num { font-size: 30px; }
body[data-phase="shaking"] #go { flex: none; padding: 9px 18px; }
body[data-phase="shaking"] #go::before { content: '■ '; }
body[data-phase="shaking"] #uiLeft, body[data-phase="shaking"] #viewBar, body[data-phase="shaking"] .hint, body[data-phase="shaking"] #dstats, body[data-phase="shaking"] #uiTop { opacity: 0.5; transition: opacity 0.3s; }
body[data-phase="shaking"] #uiLeft:hover, body[data-phase="shaking"] #viewBar:hover, body[data-phase="shaking"] #uiTop:hover { opacity: 1; }
body[data-phase="shaking"] .hud-int b { font-size: 42px; }
body[data-phase="shaking"] #uiRight { width: 420px; }
body[data-phase="shaking"] #seis { height: 170px; }
/* 震后：操作栏（重放、跳到下一事件、复原……）；震级滑杆收起，点“调整”再展开 */
body[data-phase="after"]:not(.ctl-edit) #ctl .ctl-dist, body[data-phase="after"]:not(.ctl-edit) #mag, body[data-phase="after"]:not(.ctl-edit) #presets,
body[data-phase="after"]:not(.ctl-edit) #ctlMore, body[data-phase="after"] #ctl .more[data-toggle] { display: none; }
body[data-phase="after"] #ctlEdit { display: inline-block; }
body[data-phase="after"].ctl-edit #ctlEdit::after { content: ' ▴'; }
body[data-phase="after"]:not(.ctl-edit) #ctl .mag-num { font-size: 32px; }

/* ---------- 快捷按钮、操作提示（第 ④ 步） ---------- */
body[data-phase="after"] .ctl-act .quick { display: inline-block; }
.hint { pointer-events: auto; }
#ctl .ctl-act .quick { font-size: 12.5px; padding: 6px 9px; }
#drawer .label kbd, .hint kbd { font: 600 11px/1 var(--font-data); padding: 1px 4px; border: 1px solid currentColor; border-radius: 3px; opacity: .8; }

/* ---------- 手机 / 窄屏（第 ⑤ 步）：主控制区变成底部抽屉，设置改成全屏面板，HUD 只留状态和烈度 ---------- */
@media (max-width: 760px) {
  :root { --gap: 8px; }
  #app { display: block; } #stage { grid-row: auto; }
  #brand { padding: 4px 10px 4px 4px; gap: 8px; } #brand h1 { font-size: 15px; } #gear { width: 30px; height: 30px; font-size: 16px; }
  #hud { top: var(--gap); right: var(--gap); gap: 4px; }
  #hud .hud-card:not(.hud-int):not(:first-child) { display: none; }
  #uiLeft { top: 50px; width: min(320px, calc(100% - 172px)); max-height: calc(100% - var(--ctl-h) - var(--news-h, 0px) - 120px); }
  .strip-h { padding: 6px 10px; font-size: 12.5px; }
  #uiRight { display: none; }
  #uiBottom { left: 0; right: 0; bottom: 0; flex-direction: column; align-items: stretch; gap: 6px; }
  #viewBar { position: static; transform: none; margin: 0 var(--gap); overflow-x: auto; order: -1; }
  #viewBar .seg { flex-wrap: nowrap; } #viewBar .seg button { padding: 5px 9px; white-space: nowrap; }
  #ctl { width: auto; border-radius: 14px 14px 0 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); max-height: 58vh; overflow-y: auto; }
  #ctl .mag-num { font-size: 36px; }
  body[data-phase="armed"] #ctl { width: auto; }
  body[data-phase="shaking"] #ctl { width: auto; justify-content: space-between; }
  .hint { display: none; }
  #dstats { top: 54px; bottom: auto; right: var(--gap); }
  body[data-phase="idle"] #dstats { display: none; }
  #news { width: 230px; left: var(--gap); bottom: calc(var(--ctl-h) + 64px); }
  #binfo { bottom: calc(var(--ctl-h) + 64px); }
  #eewPhone { left: var(--gap); right: var(--gap); width: auto; top: 50px; }
  #soundHint { bottom: calc(var(--ctl-h) + 72px); }
  #drawer { width: 100vw; max-width: 100vw; border-right: 0; }
  /* 预警横幅压在品牌条下面，手机通知卡再往下；震动时右上的灾情统计先收起 */
  #eew { top: 50px; max-width: calc(100% - 16px); white-space: normal; }
  #eewPhone { top: 110px; }
  body[data-phase="shaking"] #dstats, body[data-phase="armed"] #dstats { display: none; }
}

/* 震级滑杆上 9.5~10 的假想区间（第 5 批第 5 条） */
.mag-scale { position: relative; height: 14px; margin-top: -6px; font: 10px/12px var(--font-data); color: #aab2b6; }
.mag-scale::before { content: ''; position: absolute; right: 0; top: 0; width: 7.1%; border-top: 2px dashed #ffb35c; }
.mag-scale span { position: absolute; right: 0; top: 2px; white-space: nowrap; }
body.mag-hypo #ctl .mag-num { color: #ffb35c; }
body.mag-hypo #ctl .mag-meta small { color: #ffcf96; }
body[data-phase="shaking"] .mag-scale, body[data-phase="armed"] .mag-scale, body[data-phase="after"]:not(.ctl-edit) .mag-scale { display: none; }
#resTxt { font: 10px/1.2 var(--font-data); color: #8d969b; }
