:root {
  --bg: #0b0e14;
  --bg2: #11151f;
  --panel: #151a27;
  --panel2: #1b2132;
  --border: #263047;
  --text: #dfe6f3;
  --muted: #8896ad;
  --accent: #00e5ff;
  --accent2: #ff0080;
  --accent3: #39ff14;
  --danger: #ff4d5e;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

body { display: flex; flex-direction: column; overflow: hidden; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #141a2a, #0f1420);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
  font-size: 18px;
}
.brand-name { letter-spacing: .5px; }

.tabs { display: flex; gap: 6px; margin-left: 8px; }
.tab {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.tab.active {
  color: #06121a;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 14px rgba(0,229,255,.4);
}
.top-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- 布局 ---------- */
.layout { flex: 1; display: flex; min-height: 0; }
.panel { display: none; flex: 1; min-width: 0; }
.panel.active { display: flex; }

/* ---------- 通用 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: .5px;
  text-transform: uppercase;
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
label input, label select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 13px;
}
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }
.grid-cols { display: flex; gap: 10px; }
.grid-cols label { flex: 1; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  background: var(--accent);
  color: #06121a;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(0,229,255,.35);
}
.btn.ghost { background: transparent; }
.btn.full { width: 100%; margin-top: 4px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
.hint code, label code, p code {
  background: var(--bg2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 300px;
  flex: none;
  overflow-y: auto;
  padding: 14px;
  border-right: 1px solid var(--border);
  background: var(--bg2);
}
.tool-row { display: flex; gap: 8px; }
.tool {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.tool.active { border-color: var(--accent); color: var(--accent); }
.tool.danger { color: var(--danger); }

.badge {
  background: var(--panel2);
  color: var(--accent3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  margin-left: 4px;
}
.arrow-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.arrow-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 4px;
  background: var(--bg2);
  border: 1px solid transparent;
  font-size: 12px;
}
.arrow-list li:hover { border-color: var(--border); }
.arrow-list li.sel { border-color: var(--accent); }
.arrow-list .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.arrow-list .meta { color: var(--muted); font-size: 11px; margin-left: auto; }
.arrow-list .del {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px;
}
.arrow-list .del:hover { color: var(--danger); }

.selected-info { font-size: 12px; }
.selected-info .kv { display: flex; justify-content: space-between; margin-bottom: 6px; }
.selected-info .kv b { font-weight: 600; color: var(--text); }
.dir-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.dir-btns button {
  padding: 6px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); cursor: pointer; font-size: 14px;
}
.dir-btns button.on { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 8px rgba(0,229,255,.3); }
.mini-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.mini-actions .btn { padding: 6px 10px; font-size: 12px; }

/* ---------- 舞台 ---------- */
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stage-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg2);
  flex: none;
}
.stage-info { font-size: 12px; color: var(--muted); }
.draw-hint { font-size: 12px; color: var(--accent3); }
.canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow: auto;
  background:
    radial-gradient(circle at 50% 0%, #121a2b 0%, #0a0d14 70%);
}
#board { background: #070a10; box-shadow: 0 0 40px rgba(0,180,255,.10); border-radius: 4px; }

/* ---------- 图片模式 ---------- */
#imagePanel { flex-direction: column; overflow-y: auto; min-height: 0; }
.image-grid { display: grid; grid-template-columns: 1fr 340px; gap: 14px; padding: 14px; flex: none; }
.image-grid > .card { margin-bottom: 0; }
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--accent); }
.dropzone .link { color: var(--accent); text-decoration: underline; }
.preview, .region-preview { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #000; }
#imgPreview { max-height: 380px; display: block; cursor: crosshair; }
#regionPreview { image-rendering: pixelated; cursor: crosshair; }
.region-row { display: flex; gap: 16px; align-items: flex-start; }
#plansCard, #regionCard { margin: 0 14px 14px; flex: none; }
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 2px;
}
.plan {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  transition: .15s;
}
.plan:hover { border-color: var(--accent); box-shadow: 0 0 14px rgba(0,229,255,.2); }
.plan canvas { width: 100%; border-radius: 6px; background: #070a10; display: block; }
.plan .plan-title { font-size: 12px; margin-top: 8px; font-weight: 600; }
.plan .plan-meta { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
  width: min(720px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h3 { margin: 0; color: var(--accent); }
.modal label { margin-top: 12px; }
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  resize: vertical;
}
.row { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
