/* ============================================================
   智慧校园 · 设计令牌
   ============================================================ */
:root {
  --bg-0: #03070e;
  --bg-1: #061120;
  --panel: rgba(8, 22, 42, 0.72);
  --panel-solid: rgba(7, 18, 34, 0.94);
  --panel-soft: rgba(12, 30, 54, 0.5);
  --line: rgba(64, 224, 255, 0.16);
  --line-strong: rgba(64, 224, 255, 0.42);
  --cyan: #39e6ff;
  --cyan-dim: #1b8ea8;
  --blue: #2e86ff;
  --violet: #7c6cff;
  --green: #22d3a7;
  --amber: #ffb020;
  --red: #ff4d6a;
  --text: #dcf1ff;
  --text-soft: #9dbfd6;
  --muted: #6c8ba3;
  --mono: "Bahnschrift", "DIN Alternate", "SF Mono", "Consolas", monospace;
  --sans: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --shadow-panel: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(64, 224, 255, 0.06);
  --glow-cyan: 0 0 12px rgba(57, 230, 255, 0.45);
  --ui-scale: 1;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { user-select: none; }

#app { position: fixed; inset: 0; overflow: hidden; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  font-size: calc(13px * var(--ui-scale));
}

.css2d-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 6;
}

/* 滚动条 */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(57, 230, 255, 0.22); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(57, 230, 255, 0.45); }

/* 文本工具类 */
.t-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.t-cyan { color: var(--cyan); }
.t-green { color: var(--green); }
.t-amber { color: var(--amber); }
.t-red { color: var(--red); }
.t-muted { color: var(--muted); }
.t-soft { color: var(--text-soft); }
.t-xs { font-size: 11px; }
.t-sm { font-size: 12px; }
.t-lg { font-size: 16px; }
.t-num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ============================================================
   启动遮罩
   ============================================================ */
.loader {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 520px at 50% 42%, rgba(16, 74, 122, 0.35), transparent 70%),
    linear-gradient(180deg, #04080f 0%, #061120 55%, #03070e 100%);
  transition: opacity 0.9s var(--ease), visibility 0.9s;
}

.loader.is-done { opacity: 0; visibility: hidden; }

.loader__inner {
  position: relative;
  width: min(560px, 84vw);
  text-align: center;
  padding-bottom: 6vh;
}

.loader__mark { margin-bottom: 22px; filter: drop-shadow(0 0 22px rgba(57, 230, 255, 0.45)); animation: markFloat 4s ease-in-out infinite; }
@keyframes markFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.loader__title {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: #eafaff;
  text-shadow: 0 0 26px rgba(57, 230, 255, 0.35);
}

.loader__sub {
  margin: 10px 0 34px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.32em;
  color: rgba(140, 190, 215, 0.65);
}

.loader__bar {
  position: relative;
  height: 2px;
  background: rgba(57, 230, 255, 0.12);
  overflow: hidden;
}

.loader__bar i {
  position: absolute;
  inset: 0 100% 0 0;
  background: linear-gradient(90deg, rgba(57, 230, 255, 0.2), #39e6ff 60%, #a9f7ff);
  box-shadow: 0 0 14px rgba(57, 230, 255, 0.8);
  transition: right 0.45s var(--ease);
}

.loader__status {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(150, 195, 220, 0.8);
}

.loader__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(57, 230, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 230, 255, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at 50% 46%, #000 8%, transparent 68%);
  pointer-events: none;
  z-index: -1;
}

/* ============================================================
   提示气泡 / Toast
   ============================================================ */
.tooltip {
  position: fixed;
  z-index: 60;
  min-width: 132px;
  max-width: 260px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  background: rgba(4, 14, 26, 0.92);
  border: 1px solid rgba(57, 230, 255, 0.35);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55), inset 0 0 18px rgba(57, 230, 255, 0.06);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity 0.16s linear;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.tooltip.is-on { opacity: 1; }
.tooltip b { color: var(--cyan); font-weight: 600; }
.tooltip .tip-row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-soft); }
.tooltip .tip-row em { font-style: normal; color: var(--text); font-family: var(--mono); }

.toasts {
  position: fixed;
  right: 22px;
  bottom: 120px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  padding: 10px 14px;
  border-left: 2px solid var(--cyan);
  background: linear-gradient(90deg, rgba(8, 30, 52, 0.95), rgba(6, 18, 34, 0.72));
  border-radius: 3px;
  font-size: 12.5px;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.34s var(--ease) both;
}

.toast.is-warn { border-left-color: var(--amber); }
.toast.is-crit { border-left-color: var(--red); }
.toast.is-out { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(26px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* 加载中断提示 */
.loader.has-error .loader__bar i {
  background: linear-gradient(90deg, rgba(255, 90, 110, 0.3), #ff5a6e);
  box-shadow: 0 0 14px rgba(255, 90, 110, 0.7);
}
.loader.has-error #loaderPct { display: none; }
.loader.has-error .loader__mark { animation: none; filter: drop-shadow(0 0 22px rgba(255, 90, 110, 0.4)); }

.loader__status em {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 10.5px;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: #ff9aa7;
  max-width: 46em;
}
.loader.has-error .loader__status {
  display: block;
  text-align: left;
  font-family: var(--sans);
  font-size: 12px;
  color: #dceef8;
}
.loader__retry {
  display: block;
  margin: 20px auto 0;
  padding: 8px 22px;
  border-radius: 3px;
  border: 1px solid rgba(57, 230, 255, 0.4);
  background: rgba(57, 230, 255, 0.1);
  color: #bff6ff;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.loader__retry:hover { background: rgba(57, 230, 255, 0.2); border-color: #39e6ff; color: #fff; }
