: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); }

/* 一级导航（顶部横向） */
:root { --nav-h: 50px; }
#nav {
  position: fixed; left: 0; right: 0; top: 0; height: var(--nav-h); background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px; padding: 0 16px; z-index: 20;
}
.brand { display: flex; gap: 8px; align-items: center; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand b { font-size: 14px; } .brand small { font-size: 12px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); flex: none; position: relative; }
.logo::after { content: ""; position: absolute; left: 6px; top: 7px; border: 7px solid transparent; border-bottom: 11px solid #fff; border-top: 0; }
.nav-links { display: flex; gap: 4px; height: 100%; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-links a { display: flex; align-items: center; padding: 0 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.on { color: var(--accent); border-bottom-color: var(--accent); }
.navfoot { font-size: 11px; color: var(--muted); flex: none; }
#app { margin-top: var(--nav-h); height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h)); 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); }
.tag.d { color: #ffc36b; border-color: rgba(255,195,107,.45); background: rgba(255,170,60,.08); white-space: nowrap; }
.tag.o { font-size: 10px; opacity: .8; white-space: nowrap; }
.item.derived .t div::before { content: "✦ "; color: #ffc36b; }
.overlay .desc { margin: 0 0 8px; line-height: 1.55; color: var(--text); max-width: 320px; }
.overlay.closed .desc { display: none; }
.cmp-lbl { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(17,19,23,.82); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12px; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
.cmp-sel { max-width: 220px; }
.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 { min-width: 0; overflow: hidden; }
.stage canvas.gl { display: block; touch-action: none; position: absolute; left: 0; top: 0; }
.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%); }


/* 三栏页面（角色 / 场景素材）：横屏 左类目+列表 | 中 3D 视图 | 右 信息+操作 */
.tri { display: grid; grid-template-columns: 250px minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); height: 100%; }
.tri.ppage { grid-template-columns: 330px minmax(0, 1fr) 280px; }
.tri .col { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tri .c-left { border-right: 1px solid var(--line); }
.tri .c-right { border-left: 1px solid var(--line); overflow: auto; padding: 12px; gap: 12px; }
.tri .c-center { position: relative; min-width: 0; min-height: 0; display: flex; }
.tri .c-center .stage { flex: 1; }
.col-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.col-title { font-size: 12px; color: var(--muted); letter-spacing: .05em; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cat { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 10px; text-align: left; }
.cat small { color: inherit; opacity: .7; font-size: 11px; }
.cat.on { background: var(--accent-d); border-color: rgba(79,156,249,.55); color: var(--accent); }
.tri .list { overflow: auto; flex: 1; min-height: 0; }
.tri .card { padding: 12px; }
.info-card h2 { font-size: 16px; margin-bottom: 8px; }
.info-card .desc { margin: 0 0 8px; line-height: 1.55; font-size: 13px; }
.info-card .kv { font-size: 12.5px; }
.ops-card { display: flex; flex-direction: column; gap: 10px; }
.ops-card .clips { max-height: 240px; min-height: 80px; }
.ctl-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ctl-row label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.tl-sub { text-align: right; margin-top: -6px; color: var(--muted); }
a.btn { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; color: var(--text); white-space: nowrap; }
a.btn:hover { text-decoration: none; border-color: #3a414d; }
.evts { line-height: 1.4; }
.evts:empty { display: none; }
.cmp-sel { max-width: 100%; }
.ptabs { display: none; }
.tri .tiles { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 12px; margin: 6px 0; }
.sel-kv { font-size: 12px; margin: 4px 0; }
.kv.tree { font-size: 12.5px; }
.kv.tree dt.full { display: none; } .kv.tree dd.full { grid-column: 1 / -1; }
.kv.tree details { margin: 2px 0; } .kv.tree details > summary { cursor: pointer; color: var(--muted); }
.kv.tree details > .kv { padding-left: 14px; border-left: 1px solid var(--line); margin: 4px 0 4px 4px; }
.cfg-tree { max-height: 72vh; overflow: auto; }

/* 手机横屏（矮屏）：三栏收紧 */
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  :root { --nav-h: 40px; }
  #nav { gap: 8px; padding: 0 8px; }
  .brand small, .navfoot { display: none; }
  .nav-links a { padding: 0 10px; font-size: 13px; }
  .tri { grid-template-columns: 190px minmax(0, 1fr) 240px; }
  .tri.ppage { grid-template-columns: 230px minmax(0, 1fr) 220px; }
  .col-head { padding: 6px; gap: 5px; }
  .col-title { display: none; }
  .cats { gap: 4px; }
  .cat { padding: 3px 6px; font-size: 12px; }
  .tri .c-right { padding: 6px; gap: 6px; }
  .tri .card { padding: 8px; }
  .info-card h2 { font-size: 14px; margin-bottom: 4px; }
  .info-card .desc { display: none; }
  .info-card .kv, .ctl-row label { font-size: 11.5px; }
  .item { padding: 5px 8px; }
  .item .t small { display: none; }
  .tri .item .tag { display: none; }
  .ops-card { gap: 6px; } .ops-card .clips { max-height: 120px; }
  button, a.btn { padding: 3px 8px; font-size: 12px; }
  input[type=search] { padding: 4px 6px; }
  .tri .tiles { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 5px; padding: 5px; }
  .tile div { font-size: 11px; padding: 3px 5px; } .tile small { display: none; }
  .split.maps { grid-template-columns: 220px 1fr; }
  .panel { width: 200px; max-height: 70dvh; font-size: 12px; padding: 7px; }
  .panel.collapsed > :not(h3) { display: none; }
  .panel.collapsed h3 { margin: 0; }
  .overlay { font-size: 11px; padding: 6px 9px; max-width: 45%; }
  .overlay h2 { font-size: 13px; margin: 0; }
  .overlay dl { display: none !important; } .overlay.open dl { display: grid !important; margin-top: 6px; }
}

/* 手机（竖屏 / 窄屏） */
@media (max-width: 860px) and (max-aspect-ratio: 1/1) {
  :root { --nav-h: 46px; }
  #nav { gap: 6px; padding: 0 8px; }
  .brand b, .brand small, .navfoot { display: none; }
  .nav-links { justify-content: space-between; }
  .nav-links a { padding: 0 9px; font-size: 14px; }
  .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; }
  .side { border-right: 0; border-top: 1px solid var(--line); }
  .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 .desc { display: none; } .overlay.open .desc { display: block; }
  .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; }
  .panel.collapsed h3 { margin: 0; }
  .panel.collapsed { width: auto; min-width: 96px; }
  .cfg { grid-template-columns: 1fr; }
  .cfg .col { max-height: 30vh; }
  .mobile-only { display: inherit !important; }
  .split.maps .main { height: 60dvh; }
}
/* 竖屏三栏页：视图在上，页签切换 列表 / 信息 / 动作 */
@media (max-aspect-ratio: 1/1) {
  .tri, .tri.ppage { grid-template-columns: 1fr; grid-template-rows: 46% auto minmax(0, 1fr); }
  .tri .c-center { grid-row: 1; }
  .tri .ptabs { grid-row: 2; display: flex; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel); }
  .ptabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 9px 0; color: var(--muted); border-bottom: 2px solid transparent; }
  .ptabs button.on { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }
  .tri .c-left, .tri .c-right { grid-row: 3; border: 0; }
  .tri .cats { grid-template-columns: repeat(3, 1fr); }
  .tri[data-ptab=list] .c-right { display: none; }
  .tri[data-ptab=info] .c-left, .tri[data-ptab=ops] .c-left { display: none; }
  .tri[data-ptab=info] .ops-card, .tri[data-ptab=ops] .info-card { display: none; }
  .ops-card .clips { max-height: 30dvh; }
}
/* v4 视角预设 */
.view-row { gap: 6px; }
.view-row .view-btn { padding: 4px 10px; font-size: 12.5px; }

/* v5 游戏试玩入口 */
.nav-links a.nav-play { color: #ffd166; }
.play-cta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; padding: 14px 18px; border: 1px solid rgba(255, 209, 102, .35);
  background: linear-gradient(90deg, rgba(255, 209, 102, .12), rgba(79, 156, 249, .08)); text-decoration: none; }
.play-cta b { font-size: 17px; color: #ffd166; }
.play-cta span { color: var(--muted); font-size: 13.5px; }
.play-cta:hover { text-decoration: none; border-color: rgba(255, 209, 102, .7); }
