/* --- CSS Variables (Dark Mode) --- */
html {
    height: 100%;
    margin: 0;
    padding: 0;/* [新增] 确保根元素能占据整个视口高度 */
}
body, #viewer-container {
    -webkit-user-select: none; /* Safari, Chrome */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* Internet Explorer/Edge */
    user-select: none;         /* 标准语法 */
    -webkit-touch-callout: none;

    /* 禁用iOS上点击链接或可点击元素时出现的半透明灰色背景 */
    -webkit-tap-highlight-color: transparent;
}
:root {
    --bg-color: #1e1e1e;
    --text-color: #e0e0e0;
    --primary-color: #5cadff; /* A slightly lighter blue */
    --container-bg: #2a2a2a;
    --button-bg: #383838;
    --button-hover-bg: #484848;
    --overlay-button-bg: rgba(40, 40, 40, 0.7);
    --overlay-button-hover-bg: rgba(60, 60, 60, 0.8);
    --panel-bg: rgba(45, 45, 45, 0.9);
    --border-color: rgba(255, 255, 255, 0.15);
    --slider-track-bg: #555;
    --slider-thumb-bg: var(--primary-color);
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    box-sizing: border-box;
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden; /* Prevent horizontal scroll */
}

h1 {
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
}

#viewer-container {
    width: 95vw;
    max-width: 1900px;
    height: calc(100vh - 80px);/* Limit max width on desktop */
    min-height: 400px;
    position: relative; /* Needed for absolute positioning of children */
    flex-grow: 1;
    touch-action: none; /* Prevent default touch actions like page scroll on viewer */
    border-radius: 8px;
    overflow: hidden; /* Clip canvas and absolutely positioned elements like panels */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    background-color: #111; /* Fallback background if renderer alpha fails or is not set */
}

/* Fullscreen styles */
#viewer-container:fullscreen {
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
}
/* Safari/older webkit fullscreen styles */
#viewer-container:-webkit-full-screen {
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
}

canvas {
    display: block; /* Remove potential bottom space */
    width: 100%;
    height: 100%;
    cursor: grab; /* Default cursor for orbit controls */
}
canvas:active { cursor: grabbing; } /* Cursor while dragging */
canvas.pointer-locked { cursor: crosshair; } /* Cursor for first-person mode */

/* Loading Indicator */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75); /* Dark semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100; /* Ensure it's on top during load */
    color: white;
    font-size: 1.2em;
    /* Fade out effect, delayed to avoid flashing */
    transition: opacity 0.5s ease-out 0.2s;
    pointer-events: auto; /* Block interaction with viewer while loading */
}
#loading-indicator {
    padding: 15px 25px;
    background-color: rgba(50, 50, 50, 0.9);
    border-radius: 8px;
    text-align: center;
}
/* Class added by JS to hide the loading overlay */
#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none; /* Allow interaction with viewer once hidden */
}

/* Viewer Overlay Buttons (Settings, Fullscreen, Help) */
.viewer-overlay-buttons {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20; /* Above canvas, below panels */
    display: flex;
    gap: 8px;
    opacity: 0; /* Hidden by default on desktop */
    pointer-events: none; /* Non-interactive when hidden */
    transition: opacity 0.3s ease-in-out; /* Fade effect */
}
/* Class added by JS to show buttons */
.viewer-overlay-buttons.visible {
    opacity: 1;
    pointer-events: auto; /* Interactive when visible */
}
.overlay-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.3rem;
    line-height: 36px; /* Vertically center icon */
    text-align: center;
    cursor: pointer;
    background-color: var(--overlay-button-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 50%; /* Circular buttons */
    transition: background-color 0.2s ease, transform 0.1s ease;
    /* Frosted glass effect */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.overlay-btn:hover {
    background-color: var(--overlay-button-hover-bg);
    border-color: rgba(255, 255, 255, 0.4);
}
.overlay-btn:active {
    transform: scale(0.92); /* Click feedback */
}

/* Settings Panel */
#settings-panel {
    display: none; /* Visibility controlled by JS */
    position: absolute;
    top: 55px; /* Position below overlay buttons */
    left: 10px;
    z-index: 21; /* Above overlay buttons */
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    min-width: 200px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
/* Class added by JS to show the panel */
#settings-panel.active { display: block; }

/* Main view items in settings panel */
.settings-main-view > div {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Pushes arrow icon to the right */
    transition: background-color 0.15s ease;
}
.settings-main-view > div:last-child { margin-bottom: 0; }
.settings-main-view > div:hover { background-color: rgba(255, 255, 255, 0.1); }
.settings-main-view > div span { /* Text label */
    flex-grow: 1; /* Takes available space */
    margin-left: 8px;
}

/* Submenu base style */
.settings-submenu {
    display: none; /* Visibility controlled by JS */
    padding: 15px; /* Base padding for submenus */
}
.settings-submenu.active { display: block; } /* Show active submenu */

.settings-submenu h4 { /* Submenu titles */
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 1.1em;
    display: flex; /* To align back button and title */
    align-items: center;
    border-bottom: 1px solid var(--border-color); /* Separator line */
    padding-bottom: 8px;
}

/* Back button style within submenus */
.submenu-back-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2em;
    margin-right: 10px;
    cursor: pointer;
    padding: 0 5px; /* Clickable area */
    transition: color 0.15s ease;
}
.submenu-back-btn:hover { color: var(--primary-color); }

/* General style for options within settings */
.setting-option { margin-bottom: 10px; }
.setting-option label {
    display: block; /* Make label take full width */
    cursor: pointer;
    color: #ccc; /* Slightly dimmer text */
    font-size: 0.95em;
    display: flex;
    align-items: center; /* Align radio/checkbox with text */
    transition: color 0.15s ease;
}
.setting-option input[type="radio"],
.setting-option input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--primary-color); /* Color the check/radio */
    cursor: pointer;
    vertical-align: middle; /* Align better with text */
}
.setting-option label:hover { color: var(--text-color); } /* Feedback on hover */

/* Environment Map Buttons Container */
#panel-env-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 15px;
}
#panel-env-controls button {
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    background-color: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}
#panel-env-controls button:hover { background-color: var(--button-hover-bg); }
/* Style for the currently selected environment map button */
#panel-env-controls button.active {
    background-color: var(--primary-color);
    color: #fff; /* White text on primary color */
    font-weight: 500;
}

/* Light Rotation Slider Container */
#light-rotation-slider-container {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color); /* Visual separator */
}
#light-rotation-slider-container h5 { /* Heading for the slider */
    margin-top: 0;
    margin-bottom: 10px;
    color: #ccc;
    font-weight: 500;
    font-size: 1em;
    text-align: left; /* Align with other labels */
}
#light-rotation-slider {
    width: 100%;
    cursor: pointer;
    accent-color: var(--primary-color);
    margin-top: 5px;
    height: 5px; /* Thinner track */
}

/* Small helper text below options */
.setting-option small,
#settings-scene small { /* Note: #settings-scene small is likely unused now */
    font-size: 0.8em;
    color: #aaa;
    display: block;
    margin-top: 4px;
}
/* Add left padding to small text under radio/checkbox to align */
.setting-option small { padding-left: 22px; }
/* No padding needed for scene small text (if it existed) */
#settings-scene small { padding-left: 0; }

/* General style for buttons inside panels (like save, clear) */
.panel-button-style {
    padding: 8px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    background-color: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: block; /* Make button take full width */
    width: 100%;
    text-align: center;
    margin-bottom: 5px; /* Space below button */
}
.panel-button-style:hover {
    background-color: var(--button-hover-bg);
}
.panel-button-style:active {
    transform: scale(0.98); /* Click feedback */
}
.panel-button-style:disabled {
     opacity: 0.5;
     cursor: not-allowed;
}


/* Help Panel */
#help-panel {
    display: none; /* Visibility controlled by JS */
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%); /* Center the panel */
    z-index: 25; /* High z-index to be on top */
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px 25px;
    width: 85vw; /* Relative width, good for different screens */
    max-width: 550px; /* Max width */
    max-height: 75vh; /* Max height to prevent overflow */
    overflow-y: auto; /* Allow scrolling if content is too tall */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
#help-panel.active { display: block; } /* Show panel */

#help-panel h2 { /* Main title */
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-weight: 500;
    text-align: center;
    font-size: 1.3em;
}
#help-panel h3 { /* Section titles */
    margin-top: 20px;
    margin-bottom: 10px;
    color: #ccc;
    font-weight: 500;
    font-size: 1.1em;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 5px;
}
#help-panel .info-text { /* Container for instruction list */
    margin-top: 0;
    color: #bbb;
    font-size: 0.95em;
    line-height: 1.6; /* Improve readability */
}
#help-panel .info-text ul { /* Instruction list */
    padding-left: 20px; /* Indent list items */
    margin-top: 10px;
    list-style: none; /* Remove default bullet points */
}
#help-panel .info-text li { /* Individual instructions */
    margin-bottom: 8px;
    position: relative; /* For custom bullet positioning */
    padding-left: 15px; /* Space for custom bullet */
}
/* Custom bullet point */
#help-panel .info-text li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}
/* Highlight keys/actions within instructions */
#help-panel .info-text b {
    color: var(--text-color); /* Make highlighted text brighter */
    font-weight: 600;
}
/* Close button for panels */
.close-panel-btn {
    position: absolute;
    top: 8px; right: 10px;
    background: none; border: none;
    color: #aaa;
    font-size: 1.8rem;
    line-height: 1; /* Prevent extra vertical space */
    cursor: pointer;
    padding: 0 5px; /* Increase clickable area */
    transition: color 0.15s ease;
}
.close-panel-btn:hover { color: var(--text-color); }

/* Speed Indicator (First-Person Mode) */
#speed-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%); /* Center horizontally */
    z-index: 25; /* On top */
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.9em;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s ease-out;
    pointer-events: none; /* Don't block clicks */
}
#speed-indicator.visible { opacity: 1; } /* Show indicator */

/* Description Area Below Viewer */
.description-area {
    margin-top: 0px; /* Space below viewer */
    padding: 15px 20px;
    width: 90vw; /* Responsive width */
    max-width: 800px; /* Limit width on large screens */
    background-color: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    text-align: center;
}
.description-area h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-weight: 500;
}
.description-area p {
    color: #bbb;
    font-size: 0.95em;
    line-height: 1.6;
    margin-bottom: 0; /* Remove default paragraph bottom margin */
}


/* 标注和调试面板样式 */

/* 调试控制面板 (Admin Only) */
.debug-panel {
    position: absolute;
    top: 60px; /* Position below overlay buttons */
    right: 10px; /* Position on the right */
    left: auto;  /* Clear left positioning */
    z-index: 22; /* Above settings panel */
    background-color: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px; /* Padding inside the panel */
    width: 240px; /* Fixed width */
    max-height: calc(80vh - 80px); /* Limit height relative to viewport */
    overflow-y: auto; /* Add scrollbar if content overflows */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    display: none; /* Hidden by default, controlled by JS */
}

/* Buttons at the top of Debug Panel (Add, Delete, Toggle Vis) */
.debug-controls-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 12px; /* Space below buttons */
}
.debug-controls-buttons button {
    flex: 1; /* Distribute space */
    min-width: 70px; /* Minimum width */
    padding: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    background-color: var(--button-bg);
    border: none;
    border-radius: 4px;
    color: var(--text-color);
    transition: background-color 0.2s ease;
}
.debug-controls-buttons button:hover {
    background-color: var(--button-hover-bg);
}
.debug-controls-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* Style for active toggle button (e.g., Visibility On) */
.toggle-button.active {
    background-color: #0a5; /* Greenish active color */
    color: white;
}

/* Annotation Edit Panel within Debug Panel */
.annotation-edit-panel {
    margin-bottom: 15px; /* Space below edit section */
    padding: 10px;
    background-color: rgba(60, 60, 60, 0.5); /* Slightly different background */
    border-radius: 5px;
    display: none; /* Shown only when an annotation is selected */
    border: 1px solid rgba(255, 255, 255, 0.1); /* Optional subtle border */
}
.annotation-edit-panel input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    margin-bottom: 10px;
    background-color: #333;
    border: 1px solid #555;
    color: white;
    border-radius: 3px;
    box-sizing: border-box; /* Include padding in width */
    font-size: 0.9em;
}
.annotation-edit-panel input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Position Controls (X, Y, Z inputs) */
.position-controls {
    margin-top: 10px;
}
.position-controls h4 { /* "Position (Point)" heading */
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #ccc;
}
.position-input { /* Container for Label + Input */
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}
.position-input label { /* X:, Y:, Z: labels */
    width: 20px; /* Fixed width for alignment */
    display: inline-block;
    margin-right: 5px;
    color: #bbb;
    font-size: 0.9em;
    text-align: right;
}
.position-input input[type="number"] { /* Number inputs */
    flex-grow: 1; /* Take remaining space */
    max-width: 100px; /* Limit width */
    background-color: #333;
    border: 1px solid #555;
    color: white;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    appearance: textfield; /* Remove spinners */
    -moz-appearance: textfield;
}
.position-input input::-webkit-outer-spin-button,
.position-input input::-webkit-inner-spin-button {
  -webkit-appearance: none; /* Remove spinners for Webkit */
  margin: 0;
}
#apply-position { /* Apply Position Button */
    width: 100%;
    margin-top: 10px;
    background-color: var(--button-bg);
    border: none;
    border-radius: 3px;
    color: var(--text-color);
    padding: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
}
#apply-position:hover {
    background-color: var(--button-hover-bg);
}
#apply-position:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Slider Control Container (for Scale, Rotation, Ground Offset) */
.slider-control {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1); /* Dashed separator */
}
/* Remove border/padding for the first slider in a group */
.slider-control:first-of-type {
     margin-top: 10px;
     border-top: none;
     padding-top: 0;
}
/* Slider heading or label */
.slider-control h4,
.slider-control label {
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #ccc;
    display: block; /* Ensure it's on its own line */
}
/* Container for the range input and value display */
.slider-container {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between slider and value */
}
.slider-container input[type="range"] {
    flex-grow: 1; /* Slider takes available space */
    cursor: pointer;
    accent-color: var(--primary-color); /* Color the track/thumb */
    height: 5px; /* Thinner slider track */
    background: var(--slider-track-bg); /* Custom track background */
    border-radius: 3px;
    appearance: none; /* Override default look */
    -webkit-appearance: none;
}
/* Custom thumb style */
.slider-container input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--slider-thumb-bg);
    border-radius: 50%;
    cursor: pointer;
}
.slider-container input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--slider-thumb-bg);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}
.slider-container input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* Value display next to slider */
.slider-container span {
    font-size: 0.85em;
    color: #aaa;
    min-width: 35px; /* Ensure space for values like "360°" */
    text-align: right;
    white-space: nowrap;
}

/* Save/Cancel buttons in Annotation Edit Panel */
.annotation-edit-buttons {
    display: flex;
    justify-content: space-between; /* Space out buttons */
    margin-top: 15px;
    gap: 10px; /* Add gap between buttons */
}
.annotation-edit-buttons button {
    flex: 1; /* Make buttons share width */
    padding: 6px 10px;
    cursor: pointer;
    background-color: var(--button-bg);
    border: none;
    border-radius: 3px;
    color: var(--text-color);
    transition: background-color 0.2s ease;
    font-size: 0.9rem;
}
.annotation-edit-buttons button:hover {
    background-color: var(--button-hover-bg);
}
.annotation-edit-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Annotation List Container */
#annotation-list-container {
    margin-top: 15px;
    max-height: 180px; /* Limit height */
    overflow-y: auto; /* Add scroll if needed */
    border-top: 1px solid var(--border-color); /* Separator line */
    padding-top: 10px;
}
#annotation-list-container h4 { /* "Annotation List" heading */
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #ccc;
    padding-bottom: 5px;
}
#annotation-list { /* The actual list */
    display: flex;
    flex-direction: column;
    gap: 5px; /* Space between list items */
}
.annotation-list-item { /* Individual item in the list */
    padding: 6px 8px;
    background-color: rgba(60, 60, 60, 0.5);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Show "..." for overflow */
    transition: background-color 0.2s ease;
}
.annotation-list-item:hover {
    background-color: rgba(80, 80, 80, 0.7);
}
/* Style for the selected item in the list */
.annotation-list-item.selected {
    background-color: rgba(92, 173, 255, 0.4); /* Primary color with transparency */
    font-weight: bold;
    color: #fff; /* White text when selected */
}
/* Message shown when the list is empty */
.empty-list-message {
    color: #999;
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    padding: 10px 0;
}

/* Container for Moved Scene Controls (Ground Offset, Save Settings) */
.moved-scene-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color); /* Separator */
}
.moved-scene-controls h4 { /* "Scene Settings" heading */
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: #ccc;
}
/* Reuse .slider-control for Ground Offset */
.moved-scene-controls .slider-control {
    border-top: none; /* No extra border needed */
    margin-top: 0;
    padding-top: 0;
    margin-bottom: 10px; /* Space below slider */
}
/* Use panel-button-style for Save Settings button */
.moved-scene-controls button.panel-button-style {
    margin-top: 5px; /* Space above button */
}
.moved-scene-controls small { /* Helper text below save button */
    font-size: 0.8em;
    color: #aaa;
    display: block;
    margin-top: 4px;
}

/* Temporary Message inside Panels */
.temp-message {
    padding: 5px 8px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 0.85em;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}
.temp-message.visible { opacity: 1; }
.temp-message.error { background-color: #800; color: white; }
.temp-message.success { background-color: #050; color: white; }

/* == NEW START: 音频输入框样式 == */
.audio-input-control {
    margin-top: 10px;
}
.audio-input-control label {
    display: block;
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 5px;
}
.audio-input-control input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    background-color: #333;
    border: 1px solid #555;
    color: white;
    border-radius: 3px;
    box-sizing: border-box;
    font-size: 0.9em;
}
/* == NEW END == */

/* --- Media Queries --- */

/* Styles for smaller screens (Tablets/Mobile) */
@media (max-width: 768px) {
    body { padding: 10px; } /* Less padding on mobile */
    h1 { font-size: 1.5em; }
    #viewer-container {
        width: 100%; /* Full width */
        height: 65vh; /* Adjust height */
        min-height: 350px; /* Lower min height */
    }

    /* Force overlay buttons visible on mobile */
    .viewer-overlay-buttons {
        top: 5px; left: 5px; /* Closer to edge */
        opacity: 1 !important; /* Always visible */
        pointer-events: auto !important; /* Always interactive */
    }
    .overlay-btn {
        width: 32px; height: 32px; /* Slightly smaller buttons */
        font-size: 1.1rem; line-height: 32px;
    }

    /* Adjust Settings Panel for mobile */
    #settings-panel {
        top: 42px; /* Below smaller buttons */
        left: 5px;
        min-width: 180px; /* Adjust min width */
        padding: 8px; /* Slightly less padding */
        max-height: 70vh; /* Limit height */
        overflow-y: auto; /* Enable scroll */
    }
    .settings-main-view > div { padding: 6px 10px; font-size: 0.9em; }
    .settings-submenu { padding: 10px; }
    .settings-submenu h4 { font-size: 1em; margin-bottom: 10px;}
    .setting-option label { font-size: 0.9em; }
    .setting-option small { padding-left: 20px; }
    #panel-env-controls button { padding: 5px 8px; font-size: 0.8rem; }
    .panel-button-style { padding: 6px 12px; font-size: 0.85rem;}

    /* Adjust Help Panel for mobile */
    #help-panel {
        width: 90vw; /* Wider on mobile */
        padding: 15px;
        max-height: 80vh;
    }
    #help-panel h2 { font-size: 1.2em; }
    #help-panel h3 { font-size: 1em; }
    #help-panel .info-text { font-size: 0.9em; }

    /* Adjust Description Area for mobile */
    .description-area {
        width: 95%; /* Almost full width */
        padding: 10px 15px;
    }

    /* Adjust Debug Panel for mobile */
    .debug-panel {
        width: 200px; /* Adjust width */
        right: 5px;
        top: 55px; /* Adjust top position */
        padding: 8px 10px;
        max-height: calc(70vh - 70px); /* Adjust max height */
    }
    .debug-controls-buttons button {
        font-size: 0.8rem;
        padding: 5px;
        min-width: 65px; /* Adjust min width */
    }
    .annotation-edit-panel { padding: 8px; }
    .position-controls h4 { font-size: 0.85rem; }
    .position-input label { width: 18px; margin-right: 3px; }
    .position-input input { max-width: 80px; padding: 3px 4px; }
    #apply-position { font-size: 0.8rem; }
    .slider-control h4, .slider-control label { font-size: 0.85rem; }
    .slider-container input[type="range"] { height: 4px; }
    .slider-container input[type="range"]::-webkit-slider-thumb { width: 12px; height: 12px; }
    .slider-container input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; }
    .slider-container span { font-size: 0.8em; min-width: 30px; }
    .annotation-edit-buttons button { font-size: 0.85rem; }
    #annotation-list-container { max-height: 120px; /* Reduce max height */ }
    .annotation-list-item { font-size: 0.85rem; padding: 5px 6px;}
    .empty-list-message { font-size: 0.85rem; }
    .moved-scene-controls h4 { font-size: 0.9rem; }
    .moved-scene-controls button { font-size: 0.85rem; }
    .moved-scene-controls small { font-size: 0.75em; }

    /* Hide elements marked only for desktop */
    .desktop-only { display: none !important; }
    /* Show elements marked only for mobile */
    .mobile-only { display: inline !important; } /* Use list-item for li in help */
}

/* Ensure correct display for desktop/mobile specific help instructions */
@media (max-width: 768px) {
    #help-panel .info-text li.mobile-only { display: list-item !important; }
    #help-panel .info-text li.desktop-only { display: none !important; }
}
@media (min-width: 769px) {
     #help-panel .info-text li.desktop-only { display: list-item !important; }
     #help-panel .info-text li.mobile-only { display: none !important; }
}

.admin-only {
    display: none;
}

.debug-mode-only {
    display: none;
}

#task-hud {
    position: absolute;       /* 相对于 #viewer-container 定位 */
    bottom: 30px;             /* 距离父容器底部 20px */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;              /* 确保在 canvas 之上即可 */
    background-color: rgba(30, 30, 30, 0.85);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    /* --- 尺寸和布局 --- */
    width: 90%;
    max-width: 600px;
    padding: 12px 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;   /* 让文字和按钮垂直排列 */
    align-items: center;
    gap: 10px;                /* 文本和按钮之间的间距 */
    text-align: center;
}

#task-hud p {
    margin: 0;
    font-size: 0.95em;
    line-height: 1.4;
}

#task-hud button {
    padding: 8px 15px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    background-color: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 5px;
    white-space: nowrap;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#task-hud button:hover:not(:disabled) {
    background-color: var(--button-hover-bg);
}

#task-hud button:active:not(:disabled) {
    transform: scale(0.97);
}

#task-hud button:disabled {
    background-color: #444;
    color: #888;
    cursor: not-allowed;
    opacity: 0.7;
}
/* == NEW END == */

/* == NEW START: 相机路径记录工具样式 (Debug Panel) == */
.camera-path-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}
.camera-path-controls h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: #ccc;
}
.camera-path-buttons {
    display: flex;
    gap: 8px;
}
.camera-path-buttons button {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    background-color: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}
.camera-path-buttons button:hover {
    background-color: var(--button-hover-bg);
}
.position-sliders .slider-container label {
    width: 15px;
    font-weight: bold;
    color: #ccc;
}
.checkbox-control {
    display: flex;
    align-items: center;
    margin-top: 10px;
    padding: 5px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 4px;
}
.checkbox-control input[type="checkbox"] {
    margin: 0 8px 0 0;
    accent-color: var(--primary-color);
}
.checkbox-control label {
    font-size: 0.9em;
    color: #ccc;
    cursor: pointer;
}
/* style.css (在文件末尾添加) */

/* == NEW: 标注ID显示区域样式 == */
.annotation-id-display {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 4px 6px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-family: monospace; /* 使用等宽字体，更适合显示ID */
}

.annotation-id-display label {
    font-size: 0.85em;
    color: #aaa;
    margin-right: 5px;
    font-weight: bold;
}

.annotation-id-display span {
    font-size: 0.8em;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 如果ID太长，用省略号显示 */
    flex-grow: 1; /* 占据可用空间 */
}

.annotation-id-display button {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 1em;
    padding: 2px 4px;
    margin-left: 5px;
    transition: color 0.2s ease;
}

.annotation-id-display button:hover {
    color: var(--primary-color);
}
.slider-container.with-input .slider-input {
    width: 60px; /* 输入框宽度 */
    background-color: #333;
    border: 1px solid #555;
    color: white;
    padding: 3px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    text-align: center;
    -moz-appearance: textfield;
}
.slider-container.with-input .slider-input::-webkit-outer-spin-button,
.slider-container.with-input .slider-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.top-level-control {
    margin-bottom: 10px;
    padding: 8px;
    background-color: rgba(0,0,0,0.1);
}
@media screen and (max-height: 500px) and (orientation: landscape) {
    #task-hud {
        bottom: 40px !important;
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        max-width: 500px !important;
        gap: 6px !important;
    }
    
    #task-hud p {
        /* 减小行高,让文本更紧凑 */
        line-height: 1.3 !important;
        font-size: 0.85em !important;
        margin-bottom: 2px !important;
    }
    
    #task-hud button {
        /* 缩小按钮尺寸 */
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }
    
    /* 同时优化设置面板在横屏模式下的显示 */
    #settings-panel {
        max-height: 60vh !important;
        font-size: 0.85rem !important;
    }
    
    /* 优化帮助面板 */
    #help-panel {
        max-height: 70vh !important;
        font-size: 0.85rem !important;
    }
}

/* 针对极窄屏幕(高度<400px),进一步压缩 */
@media screen and (max-height: 400px) and (orientation: landscape) {
    #task-hud {
        bottom: 5px !important;
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        gap: 4px !important;
    }
    
    #task-hud p {
        line-height: 1.2 !important;
        font-size: 0.8em !important;
    }
    
    #task-hud button {
        padding: 4px 10px !important;
        font-size: 0.75rem !important;
    }
    
    /* 叠加按钮也需要缩小以避免遮挡 */
    .overlay-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 1rem !important;
        line-height: 28px !important;
    }
}

/* 针对超宽屏幕的横屏设备(如平板横屏),保持或恢复正常大小 */
@media screen and (min-width: 900px) and (orientation: landscape) {
    #task-hud {
        bottom: 40px; /* 恢复正常距离 */
        max-width: 600px;
    }
}
@media screen and (orientation: landscape) and (max-height: 600px) {

    /* --- 1. 视图全屏化 --- */
    h1,
    .description-area {
        display: none !important;
    }

    #viewer-container {
        width: 100vw;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    body {
        overflow: hidden !important;
        padding: 0;
    }

    #task-hud {
        bottom: 50px !important;
        width: 80% !important;
        max-width: 450px !important;
        padding: 8px 12px !important;
        gap: 6px !important;
    }

    #task-hud p {
        font-size: 0.8em !important;
        line-height: 1.3 !important;
    }
    
    #task-hud button {
        padding: 5px 10px !important;
        font-size: 0.8rem !important;
    }
}

div[class^="spinnerContainerPrimary"] {
    /* --- 1. 强制居中定位 --- */
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;

    /* --- 2. 使用 transform: scale() 来整体缩放 --- */
    transform: translate(-50%, -50%) scale(0.75) !important;

    /* --- 3. [新增] 修改背景色为半透明黑色 --- */
    background-color: rgba(0, 0, 0, 0.85) !important; /* <--- 在这里调整颜色和透明度 */

    /* --- 4. (可选) 微调样式 --- */
    border-radius: 12px !important;
}

#minimap {
    position: absolute;
    bottom: 40px; /* [修改] 距离底部10px */
    left: 50px;
    width: 290px;
    height: 200px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    /* overflow: hidden; */ /* 删除 */
    
    /* 用 clip-path 替代，避免黑色填充 */
    clip-path: inset(0 round 8px); /* 圆角裁剪，但不会创建黑色背景 */
    
    z-index: 100;
    pointer-events: none;
    background: transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
/* 玩家图标 */
#player-icon {
    position: absolute;
    width: 12px;
    height: 12px;
    background: rgba(255, 0, 0, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 101;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.8); /* 发光效果 */
    display: none;
}

/* === 手机端适配：尺寸缩小到1/2 === */
@media (max-width: 768px) {
    #minimap {
        width: 140px;  /* 从 120px 缩小到 60px (1/2) */
        height: 90px;
        top: 8px;
        right: 8px;
        left: auto;   /* [新增] 重置从PC端继承的left属性 */
        bottom: auto;
        border-width: 1px; /* 边框也相应变细 */
        border-radius: 6px;
    }
    
    #player-icon {
        width: 12px;  /* 从 8px 缩小 */
        height: 12px;
        border-width: 1px;
    }
}

/* 平板设备适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    #minimap {
        width: 140px;  /* 从 120px 缩小到 60px (1/2) */
        height: 90px;
        top: 8px;
        right: 8px;
        left: auto;   /* [新增] 重置从PC端继承的left属性 */
        bottom: auto;
        border-width: 1px; /* 边框也相应变细 */
        border-radius: 6px;
    }
    
    #player-icon {
        width: 12px;  /* 从 8px 缩小 */
        height: 12px;
        border-width: 1px;
    }
}

/* ========================================
   3D模型查看器样式 (Model Viewer Modal)
   添加到现有的 style.css 文件末尾
   ======================================== */

.model-viewer-modal {
    display: none; /* 默认隐藏 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.model-viewer-modal.active {
    opacity: 1;
}

.model-viewer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.model-viewer-panel {
    position: relative;
    width: 90vw;
    height: 90vh;
    max-width: 1400px;
    max-height: 900px;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
}

.model-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.model-viewer-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 1.2em;
    font-weight: 500;
}

.model-viewer-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.model-viewer-close-btn:hover {
    background: rgba(255, 70, 70, 0.8);
    transform: rotate(90deg);
}

.model-viewer-canvas-container {
    flex: 1;
    position: relative;
    background: #1a1a1a;
    overflow: hidden;
}

.model-viewer-canvas-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.model-viewer-footer {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .model-viewer-panel {
        width: 95vw;
        height: 85vh;
    }
    
    .model-viewer-header h3 {
        font-size: 1em;
    }
    
    .model-viewer-footer {
        font-size: 0.8em;
        padding: 8px 15px;
    }
}

/* 加载动画(可选) */
@keyframes modelViewerFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.model-viewer-modal.active .model-viewer-panel {
    animation: modelViewerFadeIn 0.3s ease-out;
}
