:root {
  --bg: #06090e;
  --panel: rgba(13, 19, 27, 0.82);
  --line: rgba(140, 180, 210, 0.13);
  --txt: #d8e4f0;
  --muted: #7d92a8;
  --amber: #ffb02e;
  --cyan: #38d6e6;
  --red: #ff5b3a;
  --blue: #4a9dff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden; background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 40%, rgba(3, 6, 10, 0.34) 78%, rgba(3, 6, 10, 0.7) 100%);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 74px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  width: 4px; height: 34px; border-radius: 2px;
  background: linear-gradient(180deg, var(--amber), rgba(255, 176, 46, 0.15));
  box-shadow: 0 0 16px rgba(255, 176, 46, 0.5);
}
.brand h1 { font-size: 15.5px; font-weight: 600; letter-spacing: 0.04em; }
.brand p { font-size: 10px; color: var(--muted); letter-spacing: 0.16em; margin-top: 3px; text-transform: uppercase; }
.top-actions { display: flex; gap: 8px; pointer-events: auto; }
.ghost {
  background: rgba(13, 19, 27, 0.7); border: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  backdrop-filter: blur(10px); transition: 0.18s; font-family: inherit;
}
.ghost:hover { color: var(--txt); border-color: rgba(160, 200, 230, 0.32); }
.ghost.on { color: var(--amber); border-color: rgba(255, 176, 46, 0.4); background: rgba(255, 176, 46, 0.08); }

/* ---------- 面板 ---------- */
.panel {
  position: fixed; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.panel.left { left: 18px; top: 84px; width: 262px; padding: 13px 13px 11px; }
.panel.right {
  right: 18px; top: 84px; width: 300px; padding: 13px;
  max-height: calc(100vh - 250px); overflow-y: auto; overflow-x: hidden;
}
.panel.right::-webkit-scrollbar { width: 4px; }
.panel.right::-webkit-scrollbar-thumb { background: rgba(140, 180, 210, 0.22); border-radius: 2px; }

.sec-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 4px 0 9px; padding-bottom: 6px; border-bottom: 1px solid rgba(140, 180, 210, 0.09);
}
.sec-title span { font-size: 11px; letter-spacing: 0.12em; color: #a9bed2; }
.sec-title em { font-style: normal; font-size: 9.5px; color: var(--muted); opacity: 0.8; }

/* ---------- 部件按钮 ---------- */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.chip {
  display: flex; align-items: center; gap: 7px; padding: 7px 8px;
  background: rgba(255, 255, 255, 0.028); border: 1px solid var(--line);
  border-radius: 8px; color: var(--txt); font-size: 12px; cursor: pointer;
  transition: 0.18s; font-family: inherit; text-align: left;
}
.chip i {
  width: 7px; height: 7px; border-radius: 2px; flex: none;
  background: var(--c); box-shadow: 0 0 8px var(--c); opacity: 0.85;
}
.chip:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(160, 200, 230, 0.3); }
.chip.active {
  border-color: var(--c); background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 1px var(--c) inset, 0 0 16px -6px var(--c);
}

/* ---------- 铲斗装法 ---------- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 9px; border-radius: 8px; cursor: pointer; font-family: inherit;
  background: rgba(255, 255, 255, 0.028); border: 1px solid var(--line); color: var(--txt);
}
.mode b { font-size: 13px; font-weight: 650; letter-spacing: 0.04em; }
.mode small { font-size: 10px; color: var(--muted); }
.mode.on {
  border-color: rgba(255, 176, 46, 0.7);
  background: rgba(255, 176, 46, 0.1);
  box-shadow: 0 0 0 1px rgba(255, 176, 46, 0.35) inset;
}
.mode.on small { color: #e7c48a; }
.mode-note {
  margin: 8px 0 14px; font-size: 11px; line-height: 1.55; color: #9db2c6;
}

/* ---------- 滑杆 ---------- */
.slider { margin: 0 0 11px; }
.sl-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.sl-top span { font-size: 11px; color: #9db2c6; }
.sl-top .val { font-family: var(--mono); font-size: 11px; color: var(--amber); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--amber) 0 var(--p), rgba(255, 255, 255, 0.09) var(--p) 100%);
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: #0b1017; border: 2px solid var(--amber);
  box-shadow: 0 0 10px rgba(255, 176, 46, 0.55); cursor: grab;
}
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.1); }

.primary {
  width: 100%; margin-top: 6px; padding: 9px; border-radius: 9px; cursor: pointer;
  border: 1px solid rgba(255, 176, 46, 0.5);
  background: linear-gradient(180deg, rgba(255, 176, 46, 0.22), rgba(255, 176, 46, 0.08));
  color: #ffd18a; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  font-family: inherit; transition: 0.18s;
}
.primary:hover { background: linear-gradient(180deg, rgba(255, 176, 46, 0.32), rgba(255, 176, 46, 0.14)); }
.primary.playing { color: #ffb02e; border-color: var(--amber); box-shadow: 0 0 20px -4px rgba(255, 176, 46, 0.6); }
.hint { font-size: 9.5px; color: var(--muted); text-align: center; margin-top: 8px; letter-spacing: 0.03em; }

/* ---------- 右栏 ---------- */
.chain { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 11px; }
.chain span {
  font-size: 9.5px; color: #9db2c6; padding: 3px 6px; border-radius: 5px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03);
}
.chain .hl { color: var(--amber); border-color: rgba(255, 176, 46, 0.35); background: rgba(255, 176, 46, 0.07); }
.chain i { font-style: normal; font-size: 9px; color: var(--muted); opacity: 0.55; }

.info-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.swatch { width: 7px; height: 7px; border-radius: 2px; flex: none; align-self: center; box-shadow: 0 0 10px currentColor; }
.info-head h3 { font-size: 15px; font-weight: 600; letter-spacing: 0.03em; }
.info-head .en { font-size: 8.5px; color: var(--muted); letter-spacing: 0.14em; }
.tag { font-size: 10.5px; color: var(--muted); padding-bottom: 8px; margin-bottom: 9px; border-bottom: 1px dashed var(--line); }
.rows .row { display: flex; gap: 8px; margin-bottom: 7px; }
.rows .row span {
  flex: 0 0 24px; font-size: 9.5px; color: var(--amber); opacity: 0.85; padding-top: 2px; letter-spacing: 0.05em;
}
.rows .row p { font-size: 11.5px; line-height: 1.62; color: #b3c4d4; }
.formula {
  margin-top: 9px; padding: 6px 8px; border-radius: 6px;
  font-family: var(--mono); font-size: 10px; color: var(--cyan); letter-spacing: 0.02em;
  background: rgba(56, 214, 230, 0.06); border: 1px solid rgba(56, 214, 230, 0.16);
}
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.m { background: rgba(255, 255, 255, 0.026); border: 1px solid rgba(140, 180, 210, 0.08); border-radius: 7px; padding: 5px 7px; }
.m span { display: block; font-size: 9px; color: var(--muted); margin-bottom: 1px; }
.m b { font-family: var(--mono); font-size: 11.5px; font-weight: 500; color: #e6f0fa; }

/* ---------- 多路阀 ---------- */
.panel.valve {
  left: 50%; transform: translateX(-50%); bottom: 14px;
  width: min(560px, calc(100vw - 620px)); min-width: 380px;
  padding: 8px 12px 6px;
}
.valve-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.valve-head .vt { font-size: 10.5px; letter-spacing: 0.12em; color: #a9bed2; }
.legend { display: flex; align-items: center; gap: 5px; font-size: 9px; color: var(--muted); }
.legend i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; margin-left: 6px; }
.lg-p { background: var(--red); }
.lg-t { background: var(--blue); }
.lg-i { background: var(--amber); }
.lg-b { background: var(--cyan); height: 5px !important; border-radius: 2px !important; }
.valve-svg { width: 100%; height: auto; display: block; }

.line { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.line.p { stroke: var(--red); }
.line.t { stroke: var(--blue); }
.line.dim { opacity: 0.22; }
.line.on {
  opacity: 1; stroke-width: 2.1; stroke-dasharray: 7 5;
  animation: flow 0.6s linear infinite;
}
.line.t.on { animation-direction: reverse; }
@keyframes flow { to { stroke-dashoffset: -12; } }

.spool { fill: rgba(255, 255, 255, 0.04); stroke: rgba(140, 180, 210, 0.22); stroke-width: 1; transition: 0.2s; }
.spool.on { fill: rgba(255, 176, 46, 0.14); stroke: var(--amber); }
.spool-txt { fill: #c0d1e1; font-size: 10.5px; font-family: inherit; }
.act { fill: rgba(255, 255, 255, 0.022); stroke: rgba(140, 180, 210, 0.14); stroke-width: 1; transition: 0.2s; }
.act.on { fill: rgba(56, 214, 230, 0.09); stroke: rgba(56, 214, 230, 0.55); }
.act-txt { fill: #93a8bc; font-size: 9.5px; font-family: inherit; }
.bar-bg { fill: rgba(255, 255, 255, 0.06); }
.bar { fill: rgba(56, 214, 230, 0.35); transition: width 0.12s linear; }
.bar.on { fill: var(--cyan); }
.bypass { stroke: var(--amber); stroke-width: 1.3; stroke-dasharray: 5 5; opacity: 0.7; animation: flow 1.6s linear infinite; }
.bypass-txt { fill: var(--amber); font-size: 9px; opacity: 0.72; font-family: inherit; }
.sym-line { fill: none; stroke: #8299ae; stroke-width: 1.2; }
.sym-line.thin { stroke-width: 0.9; }
.sym-fill { fill: #8299ae; }
.sym-txt { fill: var(--muted); font-size: 8.5px; font-family: inherit; }
.rail-txt { fill: #6f8599; font-size: 8.5px; letter-spacing: 0.08em; font-family: inherit; }

/* ---------- 3D 标注 ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px;
  transition: opacity 0.25s; will-change: transform;
}
.lbl i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); flex: none;
  box-shadow: 0 0 0 3px rgba(56, 214, 230, 0.16), 0 0 12px rgba(56, 214, 230, 0.7);
}
.lbl span {
  font-size: 10px; color: #d3e4f2; white-space: nowrap; padding: 2px 6px; border-radius: 5px;
  background: rgba(6, 10, 16, 0.72); border: 1px solid rgba(140, 180, 210, 0.18);
  letter-spacing: 0.05em; backdrop-filter: blur(4px);
}

/* ---------- 加载 ---------- */
#loader {
  position: fixed; inset: 0; background: #06090e; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; z-index: 50;
  transition: opacity 0.5s; font-size: 11px; color: var(--muted); letter-spacing: 0.14em;
}
#loader.hide { opacity: 0; pointer-events: none; }
.spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255, 176, 46, 0.15); border-top-color: var(--amber);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 自适应 ---------- */
@media (max-width: 1240px) {
  .panel.left { width: 236px; }
  .panel.right { width: 268px; }
  .panel.valve { width: calc(100vw - 560px); }
}
@media (max-width: 1040px) {
  .panel.valve { display: none; }
  .panel.right { max-height: calc(100vh - 120px); }
}
@media (max-height: 760px) {
  .panel.right { max-height: calc(100vh - 200px); }
  .brand p { display: none; }
}
