/* ============================================================
   HUD 布局：顶栏 / 左栏 / 中区 / 右栏 / 底栏
   ============================================================ */
.hud-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: calc(338px * var(--ui-scale)) minmax(0, 1fr) calc(404px * var(--ui-scale));
  grid-template-rows: calc(64px * var(--ui-scale)) minmax(0, 1fr) calc(96px * var(--ui-scale));
  grid-template-areas:
    "top top top"
    "left stage right"
    "bottom bottom bottom";
  gap: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
  padding: 0 calc(16px * var(--ui-scale)) calc(14px * var(--ui-scale));
  pointer-events: none;
}

/* ---------- 顶栏 ---------- */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
  position: relative;
}

.topbar::before {
  content: "";
  position: absolute;
  left: -18px;
  right: -18px;
  top: -10px;
  height: calc(100% + 34px);
  background: linear-gradient(180deg, rgba(3, 12, 22, 0.62), rgba(3, 12, 22, 0.28) 62%, transparent);
  z-index: -1;
  pointer-events: none;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 1px;
  background: linear-gradient(90deg, rgba(57, 230, 255, 0.55), rgba(57, 230, 255, 0.12) 42%, rgba(57, 230, 255, 0) 78%);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand__mark {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(57, 230, 255, 0.4);
  background: radial-gradient(circle at 50% 30%, rgba(57, 230, 255, 0.24), transparent 70%);
  box-shadow: inset 0 0 14px rgba(57, 230, 255, 0.16);
  clip-path: polygon(50% 0, 100% 26%, 100% 74%, 50% 100%, 0 74%, 0 26%);
}

.brand__mark svg { filter: drop-shadow(0 0 6px rgba(57, 230, 255, 0.7)); }

.brand__txt { display: flex; flex-direction: column; gap: 2px; }

.brand__title {
  font-size: calc(18px * var(--ui-scale));
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #eafaff;
  text-shadow: 0 0 18px rgba(57, 230, 255, 0.4);
  white-space: nowrap;
}

.brand__sub {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: rgba(122, 168, 194, 0.7);
  white-space: nowrap;
}

.topbar__spacer { flex: 1; }

.topbar__stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 0 10px;
  flex: none;
  border-left: 1px solid rgba(57, 230, 255, 0.12);
}

.topbar__stat .k { font-size: 10.5px; color: var(--muted); letter-spacing: 0.06em; }
.topbar__stat .v { font-family: var(--mono); font-size: 16px; color: var(--cyan); letter-spacing: 0.02em; }
.topbar__stat .u { font-size: 10px; color: var(--muted); }

.topbar__clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  padding-left: 16px;
  border-left: 1px solid rgba(57, 230, 255, 0.12);
}

.topbar__clock .time { font-family: var(--mono); font-size: 20px; letter-spacing: 0.06em; color: #eafaff; }
.topbar__clock .date { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; color: var(--muted); }

.datasource {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid rgba(34, 211, 167, 0.35);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--green);
  background: rgba(34, 211, 167, 0.07);
}

.datasource i { width: 4px; height: 4px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); animation: blink 1.8s infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- 左右栏 ---------- */
.rail {
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--ui-scale));
  pointer-events: auto;
  min-height: 0;
  overflow: hidden auto;
  padding-right: 2px;
}

.rail--left { grid-area: left; }
.rail--right { grid-area: right; }

/* ---------- 中区 ---------- */
.stage {
  grid-area: stage;
  position: relative;
  pointer-events: none;
  min-width: 0;
}

.stage__top {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  padding-top: 4px;
}

.breadcrumb {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  background: rgba(6, 18, 34, 0.78);
  border: 1px solid rgba(57, 230, 255, 0.22);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  max-width: 100%;
}

.breadcrumb.hidden { display: none; }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 12.5px;
  color: var(--text-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}

.crumb:hover { color: var(--text); background: rgba(57, 230, 255, 0.1); }
.crumb.is-current { color: var(--cyan); background: rgba(57, 230, 255, 0.12); font-weight: 600; }
.crumb__sep { color: rgba(120, 168, 194, 0.4); font-size: 11px; }
.crumb__idx { font-family: var(--mono); font-size: 9px; opacity: 0.55; }

.crumb-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 6px;
  padding: 3px 9px;
  font-size: 11.5px;
  color: var(--text-soft);
  border: 1px solid rgba(57, 230, 255, 0.2);
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  transition: all 0.16s;
}

.crumb-back:hover { color: var(--cyan); border-color: rgba(57, 230, 255, 0.55); box-shadow: 0 0 12px rgba(57, 230, 255, 0.18); }

.stage__hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(140, 180, 205, 0.55);
  letter-spacing: 0.08em;
  text-align: center;
  line-height: 1.7;
  pointer-events: none;
  transition: opacity 0.3s;
}

.stage__hint kbd {
  display: inline-block;
  padding: 0 5px;
  margin: 0 2px;
  border: 1px solid rgba(120, 190, 215, 0.3);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(160, 205, 230, 0.8);
}

/* 场景内浮动指标 */
.floating-stats {
  position: absolute;
  left: calc(2px * var(--ui-scale));
  bottom: calc(30px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.retina { position: absolute; inset: 0; pointer-events: none; }
.retina::before, .retina::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border: 1px solid rgba(57, 230, 255, 0.25);
}
.retina::before { left: 4px; top: 44px; border-right: 0; border-bottom: 0; }
.retina::after { right: 4px; bottom: 4px; border-left: 0; border-top: 0; }

/* ---------- 底栏 ---------- */
.dock {
  grid-area: bottom;
  pointer-events: auto;
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 0;
}

/* ---------- 设备抽屉 ---------- */
.drawer {
  position: absolute;
  top: calc(76px * var(--ui-scale));
  right: calc(16px * var(--ui-scale));
  bottom: calc(112px * var(--ui-scale));
  width: calc(392px * var(--ui-scale));
  z-index: 30;
  pointer-events: auto;
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  transition: transform 0.42s var(--ease), opacity 0.3s var(--ease);
  display: flex;
  flex-direction: column;
}

.drawer.is-open { transform: none; opacity: 1; }

@media (max-width: 1800px) {
  .range-wrap { display: none; }
  .brand__title { font-size: calc(16px * var(--ui-scale)); letter-spacing: 0.06em; }
  .brand__sub { display: none; }
}

@media (max-width: 1560px) {
  .datasource { display: none; }
  .hud-grid { grid-template-columns: calc(272px * var(--ui-scale)) minmax(0, 1fr) calc(330px * var(--ui-scale)); }
}

@media (max-width: 1280px) {
  .hud-grid {
    grid-template-columns: calc(236px * var(--ui-scale)) minmax(0, 1fr) 0px;
    grid-template-areas: "top top top" "left stage right" "bottom bottom bottom";
  }
  .rail--right { display: none; }
  .brand__sub { display: none; }
  .topbar__stat:nth-of-type(2) { display: none; }
}

@media (max-width: 900px) {
  .hud-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: calc(56px * var(--ui-scale)) minmax(0, 1fr) calc(78px * var(--ui-scale));
    grid-template-areas: "top" "stage" "bottom";
    padding: 0 8px 8px;
  }
  .rail { display: none; }
  .drawer { left: 8px; right: 8px; width: auto; top: 64px; bottom: 90px; }
  .brand__title { font-size: 15px; letter-spacing: 0.06em; }
  .topbar__stat { display: none; }
}
