:root {
  --bg: #0b1119;
  --panel: #111a26;
  --panel2: #16212f;
  --line: #22303f;
  --text: #dbe6f2;
  --muted: #7d8fa5;
  --accent: #e23c3c;
  --accent2: #2f7ae5;
  --ok: #1f8a4c;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
button:hover { background: #1e2c3e; border-color: #33465c; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #c93030; }
button.danger { color: #ff8b8b; border-color: #4a2626; }
button.danger:hover { background: #2a1414; }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #0d1620;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); }
input[type="color"] { width: 38px; height: 28px; padding: 2px; cursor: pointer; }
input[type="range"] { padding: 0; height: 22px; accent-color: var(--accent); background: none; border: none; }

.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.login-mask {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #16283c 0%, #060a10 70%);
}
.login-card {
  width: 320px; padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.login-logo { font-size: 19px; font-weight: 700; letter-spacing: 3px; text-align: center; }
.login-sub { color: var(--muted); font-size: 11px; letter-spacing: 1.4px; text-align: center; margin: 6px 0 22px; text-transform: uppercase; }
.login-card label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.login-card label input { margin-top: 5px; }
.login-card button { width: 100%; margin-top: 6px; padding: 9px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; letter-spacing: 2px; }
.login-msg { min-height: 18px; margin-top: 10px; color: #ff8b8b; font-size: 12px; text-align: center; }

/* ---------------- 地图占位 ---------------- */
.map-placeholder {
  position: absolute; inset: 0; z-index: 5;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px; text-align: center;
  background: radial-gradient(circle at 50% 40%, #101d2b 0%, #070c12 75%);
}
.map-placeholder .ph-title { font-size: 17px; letter-spacing: 2px; color: #ffb35c; }
.map-placeholder .ph-msg { color: #ff8b8b; font-size: 12px; }
.map-placeholder .ph-tip { max-width: 460px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.map-placeholder code { background: #0d1620; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: #8fc4ff; }

/* ---------------- 布局 ---------------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 296px; flex: 0 0 296px;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.stage { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0a1420; }
.inspector {
  width: 292px; flex: 0 0 292px;
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
  min-height: 0; overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 700; letter-spacing: 1px; border-bottom: 1px solid var(--line); }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.userbox { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--muted); }
.userinfo { flex: 1; min-width: 0; }
.uname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urole { font-size: 11px; color: var(--muted); }
.icon-btn { padding: 4px 8px; font-size: 12px; background: transparent; }

.section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.section.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.section-title { display: flex; align-items: center; justify-content: space-between; font-size: 11px; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; }
.count { color: var(--muted); font-size: 11px; }
.mini-btn { padding: 1px 7px; font-size: 11px; background: transparent; border-color: var(--line); }

.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tools button { padding: 7px 2px; font-size: 12px; }

.select { width: 100%; }

/* ---------------- 目录树 ---------------- */
.tree { flex: 1; overflow-y: auto; margin: -2px -6px 0; }
.tree-group { font-size: 11px; color: var(--muted); padding: 6px 8px 2px; }
.tree-node {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: var(--radius); cursor: pointer;
  white-space: nowrap; overflow: hidden;
}
.tree-node:hover { background: var(--panel2); }
.tree-node.active { background: #23202a; color: #ffb4b4; }
.tree-node .caret { width: 12px; text-align: center; color: var(--muted); font-size: 10px; }
.tree-node .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tree-node .num { color: var(--muted); font-size: 11px; }
.tree-node .ops { display: none; gap: 4px; }
.tree-node:hover .ops { display: flex; }
.tree-node .ops button { padding: 0 4px; font-size: 11px; background: transparent; border: none; color: var(--muted); }
.tree-node .ops button:hover { color: var(--accent); }

.list { flex: 1; overflow-y: auto; margin: 0 -6px; }
.list-item {
  display: flex; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: var(--radius); cursor: pointer;
}
.list-item:hover { background: var(--panel2); }
.list-item.active { background: #23202a; }
.list-item .swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); font-size: 12px; padding: 10px 8px; }

/* ---------------- 地图浮层 ---------------- */
.drawbar {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; z-index: 20;
  background: rgba(13, 22, 32, .94); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  white-space: nowrap;
}
.drawbar .spacer { width: 10px; }
#drawHint { color: #ffd0a0; }

/* 保存/操作提示：顶部居中弹出 */
.toast {
  position: fixed; top: 22px; left: 50%;
  transform: translateX(-50%) translateY(-18px) scale(.96);
  z-index: 10000; opacity: 0; pointer-events: none;
  padding: 12px 30px;
  font-size: 15px; font-weight: 700; letter-spacing: 1px;
  color: #fff; white-space: nowrap;
  background: linear-gradient(180deg, #23a55a, #17803f);
  border: 1px solid #35c273; border-radius: 10px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06) inset;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.toast.err {
  background: linear-gradient(180deg, #cf3b3b, #9c2323);
  border-color: #e26060;
}
.toast.warn {
  background: linear-gradient(180deg, #d08a12, #a3660a);
  border-color: #eaa540;
}

.statusbar {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  z-index: 20;
  padding: 4px 14px; font-size: 11px; color: #9fb0c6;
  background: rgba(8, 14, 22, .78);
  border: 1px solid var(--line);
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------------- 属性面板 ---------------- */
.insp-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.insp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 16px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; letter-spacing: .5px; }
.field > span b { color: var(--text); font-weight: 600; }
.field > input, .field > select, .field > textarea { margin-top: 0; }
.field input[type="range"] + span { margin-top: 2px; }

.color-row { display: flex; gap: 8px; align-items: center; }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.swatches i { width: 16px; height: 16px; border-radius: 3px; cursor: pointer; border: 1px solid rgba(255,255,255,.15); }
.swatches i:hover { transform: scale(1.15); }

.seg { display: flex; gap: 0; }
.seg button { flex: 1; border-radius: 0; border-right: none; }
.seg button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.seg button:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-right: 1px solid var(--line); }
.seg button.active { background: var(--accent2); border-color: var(--accent2); color: #fff; }

.symbol-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.symbol-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #0d1620; border: 1px solid var(--line); border-radius: 5px; padding: 3px; cursor: pointer; }
.symbol-grid img:hover { border-color: #3b5573; }
.symbol-grid img.on { border-color: var(--accent); background: #241a1a; }

/* 保存 / 删除固定在面板底部，不随表单滚动 */
.insp-actions {
  display: flex; gap: 8px; flex: 0 0 auto;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.insp-actions button { flex: 1; padding: 8px; }
.insp-hint { flex: 0 0 auto; margin: 0; padding: 8px 14px 0; }
.inspector input:disabled,
.inspector select:disabled,
.inspector textarea:disabled,
.inspector button:disabled { opacity: .45; cursor: not-allowed; }
.hint { margin-top: 10px; font-size: 11px; color: #d8a34a; line-height: 1.4; }

/* ---------------- 抽屉 ---------------- */
.drawer-mask { position: fixed; inset: 0; z-index: 9000; background: rgba(4, 8, 13, .6); display: flex; justify-content: flex-end; }
.drawer { width: 420px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px; }
.sym-group { margin-bottom: 18px; }
.sym-group h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 1px; }
.sym-items { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sym-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; background: #0d1620; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.sym-item:hover { border-color: #3b5573; }
.sym-item img { width: 38px; height: 38px; }
.sym-item span { font-size: 11px; color: var(--muted); text-align: center; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #253345; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1180px) {
  .sidebar { width: 248px; flex-basis: 248px; }
  .inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: -10px 0 30px rgba(0,0,0,.5); }
}
