:root {
  --bg: #0b0d10;
  --panel: #101317;
  --panel2: #151a20;
  --line: #232a33;
  --line2: #39414c;
  --txt: #e8eaed;
  --dim: #8b93a1;
  --dim2: #626b78;
  --acc: #46d06a;
  --acc2: #8ce8a8;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--txt); font-family: var(--sans); font-size: 13px; }

#app { display: flex; height: 100%; }

/* ---------- sidebar ---------- */
#panel {
  width: 342px; min-width: 342px; height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  z-index: 10;
}
#panel::-webkit-scrollbar { width: 4px; }
#panel::-webkit-scrollbar-thumb { background: #2a3240; border-radius: 2px; }

#brand { padding: 20px 20px 14px; }
#brand h1 {
  font-size: 30px; font-weight: 800; letter-spacing: 0.06em; line-height: 1.1;
  color: var(--acc);
}
#brand h1 .tm { font-size: 12px; font-style: normal; vertical-align: super; color: var(--acc2); }
#brand h1 em {
  display: inline-block; margin-left: 8px; font-style: normal; font-weight: 300;
  font-size: 15px; letter-spacing: 0.34em; color: var(--txt); vertical-align: 4px;
}
#brand .sub { margin-top: 7px; color: var(--dim); font-size: 11.5px; letter-spacing: 0.05em; font-family: var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
.chips span {
  font-family: var(--mono); font-size: 10.5px; color: #c7cdd6;
  border: 1px solid var(--line2); background: var(--panel2);
  padding: 3px 7px; border-radius: 3px; white-space: nowrap;
}
.tape {
  height: 7px; margin: 2px 0 4px;
  background: repeating-linear-gradient(-45deg, var(--acc) 0 11px, transparent 11px 24px);
  opacity: 0.9;
}

section { padding: 15px 20px 17px; border-bottom: 1px solid var(--line); }
section h2 {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.22em; color: var(--txt);
  margin-bottom: 13px; display: flex; align-items: baseline; gap: 8px;
}
section h2 i { color: var(--acc); font-style: normal; letter-spacing: 0.1em; font-size: 11px; }
section h2 b { margin-left: auto; color: var(--dim); font-family: var(--mono); font-weight: 400; font-size: 11px; }

.row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
.row .lbl { color: var(--dim); font-size: 12px; margin-right: auto; }

/* sliders */
.slider-row output { font-family: var(--mono); font-size: 12px; color: var(--acc2); width: 44px; text-align: right; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 22px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: #2a3038; border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; margin-top: -6px;
  background: var(--acc); border: 2px solid #ffd9cf22; border-radius: 3px;
  box-shadow: 0 0 0 3px rgba(70, 208, 106, 0.15);
}
input[type="range"]::-moz-range-track { height: 3px; background: #2a3038; }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; background: var(--acc); border: none; border-radius: 3px; }

/* buttons */
button {
  font-family: var(--sans); font-size: 12px; color: var(--txt);
  background: transparent; border: 1px solid var(--line2); border-radius: 4px;
  padding: 8px 12px; cursor: pointer; letter-spacing: 0.04em;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
button:hover { background: #1a2027; border-color: #4a5462; }
button.primary { border-color: var(--acc); color: var(--acc2); font-weight: 600; }
button.primary:hover { background: var(--acc); color: #0b0d10; }
.btns button { flex: 1; }

/* segmented */
.seg button { flex: initial; padding: 5px 9px; font-family: var(--mono); font-size: 11px; border-radius: 3px; }
.seg button.on { background: var(--acc); border-color: var(--acc); color: #0b0d10; font-weight: 700; }

/* toggles */
label.toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; cursor: pointer; user-select: none; color: #c9cfd8; font-size: 12.5px;
}
label.toggle input { display: none; }
label.toggle i {
  width: 34px; height: 18px; border-radius: 10px; background: #2a3038;
  position: relative; transition: background 0.18s; flex: none;
}
label.toggle i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 8px; background: #8b93a1; transition: left 0.18s, background 0.18s;
}
label.toggle input:checked + i { background: var(--acc); }
label.toggle input:checked + i::after { left: 18px; background: #fff; }

.nowBuilding {
  margin-top: 9px; font-family: var(--mono); font-size: 11px; color: var(--dim);
  border-left: 2px solid var(--acc); padding: 3px 0 3px 9px; min-height: 16px;
}
.nowBuilding b { color: var(--acc2); font-weight: 600; }

/* run mode */
button.power { width: 100%; padding: 11px; font-size: 13.5px; font-weight: 700; border-color: var(--acc); color: var(--acc2); }
button.power:hover { background: var(--acc); color: #0b0d10; }
button.power.on { background: var(--acc); color: #0b0d10; }
#runPanel { margin-top: 12px; }
#runPanel.hidden { display: none; }
.temp output { font-family: var(--mono); font-size: 15px; color: var(--txt); min-width: 62px; text-align: center; }
.temp button { width: 34px; padding: 6px 0; font-size: 15px; font-family: var(--mono); }
.runStat { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 10px; line-height: 1.7; }
.runStat b { color: #8ce8a8; font-weight: 500; }
.runStat.heat b { color: #c9b2ff; }

/* part list */
#partList { list-style: none; margin: 0 -8px; }
#partList li {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: baseline; gap: 8px;
  padding: 6.5px 10px; border-radius: 4px; cursor: pointer; border-left: 2px solid transparent;
}
#partList li:hover { background: #1a2027; }
#partList li.active { background: #0f1a13; border-left-color: var(--acc); }
#partList li i { font-family: var(--mono); font-style: normal; font-size: 10.5px; color: var(--acc); }
#partList li .n { font-size: 12.5px; color: #d7dce3; }
#partList li em { font-style: normal; font-family: var(--mono); font-size: 9.5px; color: var(--dim2); letter-spacing: 0.03em; text-align: right; }
#partList li.phase-head {
  display: block; cursor: default; margin-top: 7px; padding: 4px 10px 2px;
  font-size: 10px; letter-spacing: 0.25em; color: var(--dim2); border-left: none;
}
#partList li.phase-head:hover { background: transparent; }

footer { padding: 16px 20px 26px; color: var(--dim2); font-size: 10.5px; line-height: 1.9; font-family: var(--mono); }

/* ---------- stage ---------- */
#stage { position: relative; flex: 1; min-width: 0; }
#stage canvas { display: block; position: absolute; inset: 0; }

#leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#tags { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }

.tag {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  background: rgba(12, 14, 17, 0.92); border: 1px solid #57606d; border-radius: 3px;
  padding: 4px 8px 5px; white-space: nowrap; will-change: transform;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.tag b { display: block; font-size: 12px; font-weight: 600; color: #f2f4f7; letter-spacing: 0.03em; }
.tag i { display: block; font-style: normal; font-family: var(--mono); font-size: 9px; color: #97a0ae; letter-spacing: 0.06em; margin-top: 1px; }
.tag.hot { border-color: var(--acc); box-shadow: 0 0 0 1px rgba(70, 208, 106, 0.35), 0 2px 14px rgba(70, 208, 106, 0.25); }
.tag.hot b { color: #d8f5e0; }
.tag.unit { border-color: var(--acc); background: rgba(9, 18, 12, 0.94); padding: 6px 11px; }
.tag.unit b { font-size: 13.5px; color: var(--acc2); letter-spacing: 0.12em; }

#phaseToast {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(12, 14, 17, 0.88); border: 1px solid var(--line2); border-radius: 4px;
  padding: 7px 16px; font-family: var(--mono); font-size: 12px; color: #cfd5de;
  opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 5; white-space: nowrap;
}
#phaseToast b { color: var(--acc2); font-weight: 600; }
#phaseToast.show { opacity: 1; }

#hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 11px; color: #77808d; letter-spacing: 0.08em;
  background: rgba(12, 14, 17, 0.6); padding: 5px 12px; border-radius: 3px;
  transition: opacity 1.2s; pointer-events: none; z-index: 5; white-space: nowrap;
}

/* dossier card */
#dossier {
  position: absolute; right: 16px; bottom: 16px; width: 330px; z-index: 6;
  background: rgba(13, 16, 20, 0.96); border: 1px solid var(--line2); border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s, transform 0.2s;
}
#dossier.hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }
#dossier header { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px 0; }
#dossier .num {
  font-family: var(--mono); font-size: 11px; color: var(--acc);
  border: 1px solid var(--acc); border-radius: 3px; padding: 2px 6px; margin-top: 2px;
}
#dossier .t b { display: block; font-size: 15.5px; font-weight: 700; }
#dossier .t i { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: 0.08em; }
#dossier #dClose {
  margin-left: auto; border: none; font-size: 17px; color: var(--dim); padding: 0 4px; line-height: 1;
}
#dossier #dClose:hover { color: var(--txt); background: none; }
#dossier p { padding: 10px 14px 4px; color: #c3cad4; font-size: 12.5px; line-height: 1.75; }
#dossier .chips { padding: 4px 14px 12px; margin-top: 2px; }
#dossier .dNav {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); padding: 8px 10px;
}
#dossier .dNav button { border: none; color: var(--dim); font-size: 11.5px; padding: 4px 8px; }
#dossier .dNav button:hover { color: var(--acc2); background: none; }
#dossier .dNav span { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); }

/* narrow screens */
@media (max-width: 860px) {
  #panel { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.25s; }
  #panel.open { transform: none; }
  #dossier { width: calc(100% - 32px); }
}
