:root {
    --bg-deep: #050507;
    --glass-bg: rgba(20, 20, 25, 0.6);
    --glass-card: rgba(40, 40, 50, 0.45);
    --glass-card-hover: rgba(60, 60, 70, 0.55);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.15);
    --text-main: #ffffff;
    --text-sub: rgba(255, 255, 255, 0.55);
    --accent: #0A84FF; /* iOS Blue */
    --success: #30D158; /* iOS Green */
    --danger: #FF453A; /* iOS Red */
    --warning: #FFD60A; /* iOS Yellow */
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    background: var(--bg-deep);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', sans-serif;
    color: var(--text-main);
    touch-action: none;
    -webkit-font-smoothing: antialiased;
}
#app { position: relative; width: 100vw; height: 100vh; }
#canvas-wrap { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
#canvas-wrap canvas { display: block; width: 100% !important; height: 100% !important; }
/* ─── 悬浮按钮 (灵动岛风格) ─── */
#togglePanelBtn {
    position: absolute; bottom: 20px; right: 20px; z-index: 20;
    width: 48px; height: 48px; border-radius: 24px;
    background: rgba(30, 30, 35, 0.7);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), var(--glass-highlight);
    color: var(--text-main); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s;
    background: transparent;
}
#togglePanelBtn:hover { transform: scale(1.05); background: rgba(50, 50, 60, 0.8); }
#togglePanelBtn:active { transform: scale(0.95); }
#togglePanelBtn svg { width: 22px; height: 22px; position: absolute; transition: opacity 0.2s, transform 0.2s; }
#togglePanelBtn .icon-close { display: none; opacity: 0; transform: rotate(-90deg); }
#togglePanelBtn.is-open .icon-open { display: none; }
#togglePanelBtn.is-open .icon-close { display: block; opacity: 1; transform: rotate(0deg); }
#panel {
    position: absolute; top: 0; right: 0; height: 100%; width: 300px;
    background: var(--glass-bg);
    display: flex; flex-direction: column; overflow-y: auto;
    padding: 24px; gap: 20px;
    transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 10;
    background: transparent;
}
#panel.panel-hidden { transform: translateX(105%); visibility: hidden; pointer-events: none; }
#panel::-webkit-scrollbar { width: 6px; }
#panel::-webkit-scrollbar-track { background: transparent; }
#panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.card {
    background: var(--glass-card);
    border-radius: 20px; padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2), var(--glass-highlight);
    transition: background 0.2s;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 18px; padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 10px; letter-spacing: 0.5px; }
.card-title svg { width: 18px; height: 18px; color: var(--accent); filter: drop-shadow(0 0 4px rgba(10,132,255,0.5)); }
.card-actions { display: flex; gap: 12px; }
.card-sub { font-size: 12px; color: var(--text-sub); font-weight: 500; cursor: pointer; transition: color 0.2s; }
.card-sub:hover { color: var(--accent); }
.global-btns { display: flex; gap: 12px; margin-bottom: 20px; }
.gbtn {
    flex: 1; padding: 12px 0; border-radius: 12px; font-size: 13px; font-weight: 600;
    cursor: pointer; background: rgba(255,255,255,0.06); color: #fff;
    border: 1px solid rgba(255,255,255,0.08); transition: all 0.2s;
}
.gbtn:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.gbtn.on { background: rgba(48, 209, 88, 0.15); border-color: rgba(48, 209, 88, 0.3); color: var(--success); box-shadow: 0 0 12px rgba(48,209,88,0.1); }
.gbtn.off { background: rgba(255, 69, 58, 0.15); border-color: rgba(255, 69, 58, 0.3); color: var(--danger); }
.gbtn:active { transform: scale(0.97); }
.switch-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; font-size: 13px; font-weight: 600; color: var(--text-main);
}
.sr { margin-bottom: 18px; }
.sr:last-child { margin-bottom: 0; }
.sr-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-sub); margin-bottom: 10px; font-weight: 500; }
.sr-label span { color: var(--text-main); font-variant-numeric: tabular-nums; font-weight: 600; }
input[type=range] {
    width: 100%; height: 6px; appearance: none; -webkit-appearance: none;
    background: rgba(255,255,255,0.1); border-radius: 3px; outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
    appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
    background: #fff; cursor: pointer; border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3), 0 0 0 2px rgba(255,255,255,0.1);
    transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.2); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; cursor: pointer; border: none; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.quick-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.qp-btn {
    padding: 12px 0; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; color: var(--text-main); font-size: 14px; font-weight: 700; cursor: pointer;
    transition: all 0.2s; backdrop-filter: blur(4px);
}
.qp-btn:hover { background: rgba(10,132,255,0.15); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 10px rgba(10,132,255,0.1); }
.light-item {
    background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px; margin-bottom: 12px; overflow: hidden; transition: all 0.3s;
}
.light-item:hover { background: rgba(255,255,255,0.05); }
.light-item.highlight {
    background: rgba(10, 132, 255, 0.08); border-color: rgba(10, 132, 255, 0.3);
    box-shadow: 0 0 20px rgba(10,132,255,0.15);
}
.light-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; cursor: pointer; }
.light-name { font-size: 14px; color: var(--text-main); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.light-sub { font-size: 11px; color: var(--text-sub); margin-top: 3px; font-weight: 500; }
.light-body { padding: 0 16px; border-top: 1px solid rgba(255,255,255,0.04); display: none; }
.light-body.open { display: block; padding-bottom: 16px; padding-top: 12px; }
.light-sub-item { border-bottom: 1px solid rgba(255,255,255,0.04); padding: 12px 0; }
.light-sub-item:last-child { border-bottom: none; }
.light-sub-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.light-sub-header.highlight { background: rgba(10,132,255,0.1); margin: 0 -16px; padding: 12px 16px; }
.light-sub-header .light-name { font-size: 13px; }
.light-sub-header img { width: 24px; height: 24px; border-radius: 6px; background: rgba(255,255,255,0.05); padding: 2px; }
.light-body-inner { display: block; padding-top: 14px; }
.toggle {
    width: 44px; height: 26px; border-radius: 13px; cursor: pointer; flex-shrink: 0;
    position: relative; transition: background 0.3s ease; background: rgba(120,120,128,0.32);
}
.toggle.on { background: var(--success); box-shadow: 0 0 10px rgba(48,209,88,0.3); }
.toggle::after {
    content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%;
    top: 2px; left: 2px; background: #fff; transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.toggle.on::after { transform: translateX(18px); }
.scene-btns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.scene-btn {
    position: relative; padding: 12px 0; border-radius: 12px; font-size: 13px; font-weight: 600;
    cursor: pointer; background: rgba(255,255,255,0.06); color: #fff; border: 1px solid rgba(255,255,255,0.08);
    transition: all 0.2s; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scene-btn:hover { background: rgba(255,255,255,0.1); }
.scene-btn.active { background: rgba(10,132,255,0.15); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 12px rgba(10,132,255,0.15); }
.scene-btn .icon-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; line-height: 22px; text-align: center;
    border-radius: 50%; background: rgba(0,0,0,0.3); font-size: 11px;
    display: none; cursor: pointer; z-index: 2;
}
.scene-btn .edit-icon { left: 6px; color: var(--accent); }
.scene-btn .del-icon { right: 6px; color: var(--danger); }
.scene-btn:hover .edit-icon, .scene-btn:hover .del-icon { display: block; }
.scene-btn:hover { padding-left: 34px; padding-right: 34px; }
.modal { position: absolute; inset: 0; background: rgba(0,0,0,0.6); z-index: 50; display: none; align-items: center; justify-content: center; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.modal.open { display: flex; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
    width: 90%; max-width: 420px; max-height: 80vh; background: rgba(30,30,35,0.85);
    backdrop-filter: blur(40px) saturate(180%); -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 24px; overflow: hidden;
    display: flex; flex-direction: column; box-shadow: 0 25px 60px rgba(0,0,0,0.6);
    animation: scaleIn 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}
#confirmModal .modal-panel { max-width: 320px; }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-header .close { cursor: pointer; color: var(--text-sub); font-size: 20px; opacity: 0.8; transition: opacity 0.2s; }
.modal-header .close:hover { opacity: 1; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; overflow: auto; scrollbar-width: none; }
.modal-body::-webkit-scrollbar { display: none; }
.modal-footer { padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; gap: 12px; }
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input {
    width: 100%; padding: 12px 14px; border-radius: 10px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-main); font-size: 14px; outline: none; transition: all 0.2s;
}
.form-input:focus { border-color: var(--accent); background: rgba(255,255,255,0.08); box-shadow: 0 0 0 3px rgba(10,132,255,0.2); }
.scene-light-group { margin-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 12px; }
.scene-light-group-title { margin: 12px 0 10px; font-weight: 700; font-size: 14px; color: var(--text-main); }
.scene-light-item { background: rgba(255,255,255,0.04); border-radius: 12px; padding: 12px; margin-bottom: 8px; border: 1px solid rgba(255,255,255,0.05); }
.scene-light-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.scene-light-item-header span { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.scene-light-item-header img { width: 24px; height: 24px; border-radius: 6px; background: rgba(255,255,255,0.05); padding: 2px; }
.scene-light-item-params { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.param-input-group label { font-size: 10px; color: var(--text-sub); text-transform: uppercase; }
.param-input-group input {
    width: 100%; padding: 8px; border-radius: 8px; background: rgba(255,255,255,0.08);
    border: 1px solid transparent; color: #fff; font-size: 13px; outline: none; margin-top: 4px;
}
.param-input-group input:focus { border-color: var(--accent); }
#statusbar { position: absolute; bottom: 12px; left: 12px; font-size: 11px; color: rgba(255,255,255,0.3); pointer-events: none; z-index: 10; }
#stats { position: absolute; top: 12px; left: 12px; font-size: 11px; color: rgba(255,255,255,0.3); pointer-events: none; line-height: 1.5; z-index: 10; }
#uploadBtn, #modelBtn { position: absolute; top: 80px; right: 20px; z-index: 20; padding: 8px 14px; background: rgba(30,30,35,0.7); backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: 16px; color: var(--text-main); font-size: 12px; cursor: pointer; display: none; font-weight: 500; }
#modelBtn { right: 120px; }
#fileInput, #modelFileInput, #sceneFileInput { display: none; }
#loading-overlay { position: absolute; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; background: #000000; transition: opacity 0.6s ease, visibility 0.6s ease; }
#loading-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-rings { position: relative; width: 100px; height: 100px; }
.loader-rings span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; animation: spin-ring 1.8s cubic-bezier(0.5,0,0.5,1) infinite; }
.loader-rings span:nth-child(1) { border-top-color: var(--accent); box-shadow: 0 0 15px rgba(10,132,255,0.5); animation-delay: 0s; }
.loader-rings span:nth-child(2) { inset: 12px; border-top-color: rgba(10,132,255,0.4); border-right-color: rgba(10,132,255,0.1); animation-delay: -0.3s; animation-duration: 1.4s; }
.loader-rings span:nth-child(3) { inset: 24px; border-top-color: rgba(10,132,255,0.2); animation-delay: -0.6s; animation-duration: 1.0s; }
.loader-rings::after { content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #fff; top: 50%; left: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 20px 5px rgba(255,255,255,0.8); animation: pulse-dot 1.8s ease-in-out infinite; }
@keyframes spin-ring { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0%,100% { opacity:1; box-shadow:0 0 20px 5px rgba(255,255,255,0.8); } 50% { opacity:0.3; box-shadow:0 0 8px 2px rgba(10,132,255,0.3); } }
.loader-text { text-align: center; }
.loader-title { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: 2px; margin-bottom: 10px; text-transform: uppercase; }
.loader-sub { font-size: 12px; color: rgba(255,255,255,0.5); display: flex; align-items: center; gap: 6px; justify-content: center; font-weight: 500; }
.dots span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 0 2px; animation: dot-bounce 1.2s ease-in-out infinite; }
.dots span:nth-child(2){animation-delay:0.2s} .dots span:nth-child(3){animation-delay:0.4s}
@keyframes dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:0.4} 40%{transform:translateY(-6px);opacity:1} }
@media (max-width: 768px) {
    #panel { width: 100%; height: 65vh; border-left: none; border-top: 0px solid var(--glass-border); padding: 16px; gap: 14px; bottom: 0; top: auto; }
    #panel.panel-hidden { transform: translateY(100%); visibility: hidden; }
    .card { padding: 16px; border-radius: 16px; }
}
#fps-display { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; pointer-events: none; z-index: 100; font-family: -apple-system, BlinkMacSystemFont, 'SF Mono', monospace; letter-spacing: 1px; transition: color 0.5s; background: rgba(0,0,0,0.65); padding: 5px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
@media (max-width: 768px) { #fps-display { left: 50%; transform: translateX(-50%); top: auto; bottom: 80px; } }