:root {
  --bg: #111317; --panel: #181b21; --panel2: #1e2229; --line: #2a2f38; --text: #e6e8ec; --muted: #8f97a4;
  --accent: #4f9cf9; --accent-d: rgba(79, 156, 249, .16); --nav-w: 200px; --r: 8px;
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input, textarea { font: inherit; color: var(--text); }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #3a414d; }
button.on, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .4; cursor: default; }
input[type=text], input[type=search], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
h1, h2, h3 { margin: 0 0 10px; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
small { color: var(--muted); }

/* 导航 */
#nav {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--nav-w); background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; z-index: 20;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand b { display: block; font-size: 14px; } .brand small { font-size: 12px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); flex: none; position: relative; }
.logo::after { content: ""; position: absolute; left: 8px; top: 9px; border: 7px solid transparent; border-bottom: 12px solid #fff; border-top: 0; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; color: var(--text); }
#nav a:hover { background: var(--panel2); text-decoration: none; }
#nav a.on { background: var(--accent-d); color: var(--accent); }
#nav a i { font-style: normal; width: 18px; text-align: center; opacity: .85; }
.navfoot { margin-top: auto; font-size: 11px; color: var(--muted); padding: 8px; }
#app { margin-left: var(--nav-w); height: 100vh; height: 100dvh; overflow: hidden; }
.page { height: 100%; }
.scroll { overflow: auto; height: 100%; }
.loading, .err { padding: 30px; color: var(--muted); }
.err { color: #f87171; }

/* 通用 */
.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.stat b { display: block; font-size: 24px; font-weight: 600; } .stat span { color: var(--muted); font-size: 12px; }
.links { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.links a.card { color: var(--text); display: block; }
.links a.card:hover { border-color: var(--accent); text-decoration: none; }
.links a.card b { display: block; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; }
tr:hover td { background: var(--panel2); }
.tbl { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); max-height: 70vh; background: var(--panel); }
.section { margin-top: 28px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.tag.a { color: var(--accent); border-color: rgba(79,156,249,.4); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dl a { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dl a:last-child { border: 0; }

/* 分栏（列表 + 3D 视图） */
.split { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
.side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side .head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.side .list { overflow: auto; flex: 1; min-height: 0; }
.item { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--text); }
.item:hover { background: var(--panel2); text-decoration: none; }
.item.on { background: var(--accent-d); box-shadow: inset 3px 0 0 var(--accent); }
.item .t { flex: 1; min-width: 0; } .item .t div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1; min-height: 0; background: #15171c; }
.stage canvas.gl { display: block; touch-action: none; }
.overlay { position: absolute; left: 12px; top: 12px; max-width: min(340px, 70%); background: rgba(17,19,23,.82); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 12px; font-size: 12px; backdrop-filter: blur(6px); pointer-events: auto; }
.overlay h2 { font-size: 15px; margin-bottom: 6px; cursor: pointer; }
.overlay h2::after { content: " ▾"; color: var(--muted); font-size: 11px; }
.overlay.closed dl { display: none; }
.overlay.closed h2 { margin: 0; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; text-align: center; padding: 20px; }
.spinner { position: absolute; right: 14px; top: 14px; font-size: 12px; color: var(--muted); }

/* 动画面板 */
.anim { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 12px; display: grid; grid-template-columns: 280px 1fr; gap: 12px; height: 210px; }
.clips { overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.clip { padding: 6px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; border-bottom: 1px solid var(--line); }
.clip:hover { background: var(--panel2); } .clip.on { background: var(--accent-d); color: var(--accent); }
.clip.off { opacity: .45; }
.ctrl { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ctrl .row label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.timeline { display: flex; align-items: center; gap: 8px; } .timeline input { flex: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* 素材网格 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; padding: 10px; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; overflow: hidden; color: var(--text); display: block; }
.tile:hover { border-color: #3d4552; text-decoration: none; }
.tile.on { border-color: var(--accent); }
.tile img { width: 100%; aspect-ratio: 1; display: block; background: #15171c; object-fit: contain; opacity: .25; }
.tile img.ok { opacity: 1; }
.tile div { padding: 5px 7px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile small { display: block; font-size: 11px; }
.split.props { grid-template-columns: minmax(300px, 42%) 1fr; }

/* 地图 */
.split.maps { grid-template-columns: 300px 1fr; }
.maps .side .list .grp { padding: 8px 12px 4px; color: var(--muted); font-size: 12px; }
.maps .room { padding: 6px 12px 6px 22px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; cursor: pointer; color: var(--text); }
.maps .room:hover { background: var(--panel2); text-decoration: none; }
.maps .room.on { color: var(--accent); background: var(--accent-d); }
.toolbar { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-height: calc(100% - 20px); overflow-y: auto; overscroll-behavior: contain; }
.toolbar .panel { flex: none; }
.panel { background: rgba(24,27,33,.92); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; font-size: 13px; width: 230px; backdrop-filter: blur(6px); overflow: auto; }
.panel h3 { margin: 0 0 8px; font-size: 12px; }
.panel label { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.panel .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: rgba(10,11,14,.92); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 12px; max-width: 260px; display: none; }
.tip b { color: var(--accent); }
.banner { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--accent); border-radius: var(--r); padding: 8px 12px; display: flex; gap: 8px; align-items: center; font-size: 13px; z-index: 6; }
.joy { position: absolute; left: 24px; bottom: 24px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); touch-action: none; display: none; z-index: 4; }
.joy i { position: absolute; left: 40px; top: 40px; width: 40px; height: 40px; border-radius: 50%; background: rgba(79,156,249,.7); }
.joy.show { display: block; }
.hint { position: absolute; left: 12px; bottom: 12px; font-size: 12px; color: var(--muted); background: rgba(17,19,23,.7); padding: 4px 8px; border-radius: 6px; }
textarea.json { width: 100%; height: 120px; resize: vertical; }
.mobile-only { display: none !important; }

/* 数据 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
pre.json { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow: auto; max-height: 70vh; font-size: 12px; margin: 0; }
.cfg { display: grid; grid-template-columns: 220px 260px 1fr; gap: 12px; }
.cfg .col { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); max-height: 72vh; overflow: auto; }
.cfg .col a { display: block; padding: 6px 10px; color: var(--text); font-size: 13px; border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg .col a.on { color: var(--accent); background: var(--accent-d); }

#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: var(--panel2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 6px; opacity: 0; transition: .2s; z-index: 50; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* 手机 */
@media (max-width: 860px) {
  :root { --nav-h: 56px; }
  #nav { top: auto; right: 0; width: auto; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); flex-direction: row; padding: 0 0 env(safe-area-inset-bottom);
    border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .brand, .navfoot { display: none; }
  #nav a { flex: 1; flex-direction: column; gap: 2px; padding: 7px 0; font-size: 11px; border-radius: 0; justify-content: center; }
  #nav a i { font-size: 17px; }
  #app { margin-left: 0; height: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom)); }
  .wrap { padding: 18px 14px 40px; }
  .split, .split.props, .split.maps { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .split .main { order: -1; height: 52dvh; }
  .split.chars .main { height: 74dvh; }
  .side { border-right: 0; border-top: 1px solid var(--line); }
  .anim { grid-template-columns: 1fr; height: auto; max-height: 32dvh; overflow: auto; gap: 8px; padding: 8px; flex: none; }
  .clips { max-height: 110px; }
  .overlay { font-size: 11px; padding: 6px 9px; max-width: 62%; left: 8px; top: 8px; }
  .overlay h2 { font-size: 13px; margin: 0; cursor: pointer; }
  .overlay dl { display: none !important; margin-top: 6px; }
  .overlay.open dl { display: grid !important; }
  .toolbar { top: 6px; right: 6px; }
  .panel { width: 190px; max-height: 45dvh; font-size: 12px; }
  .panel.collapsed > :not(h3) { display: none; }
  .cfg { grid-template-columns: 1fr; }
  .cfg .col { max-height: 30vh; }
  .mobile-only { display: inherit !important; }
  .split.maps .main { height: 60dvh; }
}
