:root {
  --bg: #0d1218; --panel: #161e28e8; --panel-border: #2a3848;
  --text: #dce6f2; --dim: #8296ac; --accent: #4cc2ff; --accent2: #ffb454;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--text); }
canvas { display: block; }

/* ---------- loading ---------- */
#loading { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #17222e 0%, #0a0e13 75%); transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.loader-card { text-align: center; }
.pulse-ring { width: 74px; height: 74px; margin: 0 auto 22px; border-radius: 50%;
  border: 3px solid #27455e; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-title { font-size: 22px; font-weight: 600; letter-spacing: 2px; }
.loader-sub { font-size: 12px; color: var(--dim); margin: 8px 0 18px; }
.bar { width: 320px; height: 4px; background: #22303f; border-radius: 2px; overflow: hidden; margin: 0 auto; }
#bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; }
#load-msg { font-size: 12px; color: var(--dim); margin-top: 10px; }

/* ---------- top bar ---------- */
#topbar { position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: linear-gradient(180deg, #10161ef2, #10161e00); }
.brand { font-size: 15px; font-weight: 600; letter-spacing: 1px; white-space: nowrap; }
.brand .logo { margin-right: 4px; }
.brand .dim { color: var(--dim); font-weight: 400; font-size: 12px; margin-left: 6px; }
.search-wrap { position: relative; flex: 0 1 380px; }
#search { width: 100%; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--panel-border);
  background: #0f151d; color: var(--text); font-size: 13px; outline: none; }
#search:focus { border-color: var(--accent); }
#search-results { position: absolute; top: 36px; left: 0; right: 0; max-height: 340px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; display: none; backdrop-filter: blur(8px); }
#search-results.show { display: block; }
.sr-item { padding: 7px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sr-item:hover { background: #1f2c3b; }
.sr-item .zh { font-size: 13px; }
.sr-item .en { font-size: 11px; color: var(--dim); }
.sr-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; }
.view-presets { margin-left: auto; display: flex; gap: 6px; }
.view-presets button { background: #1a2432; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.view-presets button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- left panel ---------- */
#left { position: fixed; top: 56px; left: 12px; bottom: 46px; width: 252px; z-index: 15;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 12px 14px; overflow-y: auto; backdrop-filter: blur(10px); }
#left::-webkit-scrollbar { width: 6px; } #left::-webkit-scrollbar-thumb { background: #2c3d50; border-radius: 3px; }
.panel-title { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 1.5px; margin: 14px 0 7px; }
.panel-title:first-child { margin-top: 0; }
.panel-title .val { color: var(--accent); float: right; }
.sys-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-radius: 6px; cursor: pointer; user-select: none; }
.scene-row { display: flex; flex-wrap: wrap; gap: 5px; }
.scene-row button { background: #1a2432; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.scene-row button.active { background: #23405a; border-color: var(--accent); color: var(--accent); }
.sys-row:hover { background: #1c2836; }
.sys-row .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sys-row .nm { font-size: 13px; flex: 1; }
.sys-row .ct { font-size: 11px; color: var(--dim); }
.sys-row.off .nm, .sys-row.off .ct { color: #4d5c6e; }
.sys-row.loading .ct { color: var(--accent2); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 22px; }
.mode-row { display: flex; gap: 6px; }
.mode-btn, .clip-btn { flex: 1; background: #1a2432; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 6px; padding: 5px 0; font-size: 12px; cursor: pointer; }
.mode-btn.active, .clip-btn.active { background: #23405a; border-color: var(--accent); color: var(--accent); }
.clip-row { display: flex; gap: 5px; margin-bottom: 4px; }
#clip-flip, #clip-off { flex: 1; }
#clip-off.active { border-color: var(--accent2); color: var(--accent2); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; cursor: pointer; }
.check input { accent-color: var(--accent); }
.slider-row { font-size: 12px; color: var(--dim); margin: 6px 0; }
.slider-row .val { color: var(--accent); }
.wide-btn { width: 100%; margin-top: 8px; background: #1a2432; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 8px 0; font-size: 13px; cursor: pointer; }
.wide-btn:hover { border-color: var(--accent); color: var(--accent); }
kbd { background: #22303f; border: 1px solid #34455a; border-bottom-width: 2px; border-radius: 4px;
  padding: 0 5px; font-size: 11px; font-family: inherit; color: var(--accent); }

/* ---------- right panel ---------- */
#right { position: fixed; top: 56px; right: 12px; width: 300px; max-height: calc(100vh - 120px); z-index: 15;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 16px; overflow-y: auto; backdrop-filter: blur(10px); }
#info-empty { text-align: center; padding: 30px 0; color: var(--dim); font-size: 14px; line-height: 1.9; }
#info-empty span { font-size: 12px; }
#info-zh { font-size: 20px; font-weight: 600; line-height: 1.4; }
#info-latin { font-style: italic; color: var(--accent); font-size: 13px; margin-top: 2px; }
#info-en { color: var(--dim); font-size: 13px; margin-top: 2px; }
#info-system { margin-top: 10px; }
#info-system .badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; color: #0d1218; font-weight: 600; }
#info-desc { margin-top: 12px; font-size: 13px; line-height: 1.8; color: #c3d2e4;
  border-top: 1px solid var(--panel-border); padding-top: 10px; }
#info-meta { margin-top: 8px; font-size: 11px; color: #5b7188; }
#info-meta .auto-tag { color: #7a8ea3; }

/* ---------- footer hints ---------- */
#hints { position: fixed; left: 0; right: 0; bottom: 0; height: 34px; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 14px; font-size: 11px; color: var(--dim);
  background: linear-gradient(0deg, #10161ef2, #10161e00); white-space: nowrap; overflow-x: auto; }
#hints::-webkit-scrollbar { display: none; }

/* ---------- tooltip / hud / divider ---------- */
#tooltip { position: fixed; z-index: 30; pointer-events: none; display: none;
  background: #10161ef5; border: 1px solid var(--panel-border); border-radius: 7px;
  padding: 5px 10px; font-size: 12px; max-width: 280px; }
#tooltip .en { color: var(--dim); font-size: 11px; }
#hud { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 18;
  font-size: 12px; color: var(--accent); background: #10161ecc; border: 1px solid var(--panel-border);
  padding: 4px 14px; border-radius: 14px; opacity: 0; transition: opacity .3s; pointer-events: none; }
#hud.show { opacity: 1; }
#sbs-divider { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#sbs-divider span { position: absolute; bottom: 44px; font-size: 12px; color: #ffffff88; letter-spacing: 2px; }
#sbs-divider .eye-l { left: 12%; } #sbs-divider .eye-r { right: 12%; }
#sbs-divider::after { content: ''; position: absolute; left: 50%; top: 46px; bottom: 34px; width: 1px;
  background: linear-gradient(180deg, transparent, #ffffff22 20%, #ffffff22 80%, transparent); }

.hidden-ui #left, .hidden-ui #right, .hidden-ui #topbar, .hidden-ui #hints, .hidden-ui #sbs-divider { display: none; }

#crosshair { position: fixed; left: 50%; top: 50%; width: 14px; height: 14px; z-index: 40;
  transform: translate(-50%, -50%); pointer-events: none; }
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: #ffffffcc; }
#crosshair::before { left: 6px; top: 0; width: 2px; height: 14px; }
#crosshair::after { left: 0; top: 6px; width: 14px; height: 2px; }

/* ---------- touch ---------- */
html, body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
canvas { touch-action: none; }
#menu-btn { display: none; background: #1a2432; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 8px; width: 38px; height: 34px; font-size: 17px; cursor: pointer; }

#multipick-bar { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--accent);
  border-radius: 12px; padding: 8px 12px; backdrop-filter: blur(8px); font-size: 14px; }
#multipick-bar button { background: #23405a; color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; }
#multipick-bar #multipick-done { border-color: var(--accent); color: var(--accent); }

#touch-fps-ui { position: fixed; inset: 0; z-index: 22; pointer-events: none; }
#joystick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom));
  width: 108px; height: 108px; border-radius: 50%; border: 2px solid #ffffff44; background: #ffffff10;
  pointer-events: auto; touch-action: none; }
#stick { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; border-radius: 50%;
  background: #ffffff66; transform: translate(-50%, -50%); }
#touch-look-hint { position: absolute; right: 18px; top: 64px; color: #ffffff77; font-size: 12px; }
#touch-fps-ui .touch-col { position: absolute; right: max(16px, env(safe-area-inset-right));
  bottom: max(26px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
#touch-fps-ui .touch-col button { width: 74px; height: 48px; border-radius: 12px;
  background: #1a2432dd; color: var(--text); border: 1px solid var(--panel-border); font-size: 14px; }
#btn-fps-exit { border-color: var(--accent2) !important; color: var(--accent2) !important; }

/* ---------- 小屏响应式 ---------- */
@media (max-width: 900px) {
  #menu-btn { display: block; }
  #left { transform: translateX(-108%); transition: transform .25s; width: min(78vw, 280px);
    top: 52px; z-index: 30; box-shadow: 0 8px 30px #000a; }
  #left.open { transform: translateX(0); }
  #right { top: auto; right: 0; left: 0; bottom: 0; width: auto; max-height: 38vh;
    border-radius: 14px 14px 0 0; transform: translateY(105%); transition: transform .25s; }
  #right.show { transform: translateY(0); }
  #hints { display: none; }
  .view-presets { gap: 4px; } .view-presets button { padding: 4px 7px; font-size: 11px; }
  .search-wrap { flex: 1 1 auto; min-width: 0; }
  .brand .dim { display: none; }
}
