* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, "Microsoft Yahei", sans-serif;
    -webkit-tap-highlight-color: transparent;
}
body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #111317;
    color: #d1d5db;
    position: relative;
}

.viewer-wrap {
    width: 100%;
    height: 100%;
}
#canvas-container {
    width: 100%;
    height: 100%;
}
#canvas-container canvas {
    display: block;
    user-select: none;
    touch-action: none;
}
.empty-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #64748b;
    font-size: 16px;
    pointer-events: none;
    text-align: center;
    padding: 0 20px;
}

/* 侧边栏：桌面维持320px，仅移动端缩小 */
.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: min(320px, 85vw);
    height: 100%;
    background: #181b22;
    padding: clamp(16px,3vw,24px) clamp(14px,2.5vw,18px);
    display: flex;
    flex-direction: column;
    gap: clamp(14px,2.5vw,18px);
    overflow-y: auto;
    transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
    z-index: 10;
    box-shadow: 4px 0 12px rgba(0,0,0,0.25);
}
/* 平板/手机 768px以下启用窄侧边栏 */
@media (max-width: 768px) {
    .sidebar {
        width: min(260px, 72vw);
    }
}
/* 超小手机 */
@media (max-width: 420px) {
    .sidebar {
        width: min(220px, 72vw);
    }
}

.sidebar.hide {
    transform: translateX(-100%);
}
.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: #333842;
    border-radius: 99px;
}

/* 侧边栏推拉按钮 */
.sidebar-toggle {
    position: absolute;
    top: 50%;
    left: min(320px,85vw);
    transform: translateY(-50%);
    width: 18px;
    height: 44px;
    border-radius: 0 5px 5px 0;
    background: #272c36;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #adb5bd;
    font-size: 11px;
    transition: all 0.32s cubic-bezier(0.4,0,0.2,1);
    z-index: 11;
    user-select: none;
}
@media (max-width: 768px) {
    .sidebar-toggle {
        left: min(260px,72vw);
    }
}
@media (max-width: 420px) {
    .sidebar-toggle {
        left: min(220px,72vw);
    }
}
.sidebar.hide ~ .sidebar-toggle {
    left: 0;
}
.sidebar-toggle:active {
    background: #3b82f6;
    color: #fff;
}

.title {
    font-size: clamp(17px,4vw,19px);
    font-weight: 600;
    color: #f1f5f9;
}

.upload-area {
    border: 1px dashed #373c47;
    border-radius: 12px;
    padding: clamp(20px,4vw,28px) 14px;
    text-align: center;
    cursor: pointer;
    transition: 0.24s;
    background: #1c2028;
}
.upload-area:active {
    border-color: #3b82f6;
    background: #1f242d;
}
.upload-area .main-text {
    font-size: clamp(13px,3vw,14px);
    color: #f1f5f9;
    margin-bottom: 4px;
}
.upload-area .sub-text {
    font-size: 11px;
    color: #8892a0;
    margin-bottom: 8px;
}
.upload-area .file-name-text {
    font-size: 12px;
    color: #94a3b8;
    word-break: break-all;
}
#file {
    display: none;
}

.setting-card {
    background: #1c2028;
    border-radius: 12px;
    padding: clamp(12px,2.5vw,16px);
}
.setting-title {
    font-size: 14px;
    color: #e2e8f0;
    margin-bottom: 14px;
    font-weight: 500;
}
.setting-row {
    margin-bottom: 14px;
}
.setting-row:last-child {
    margin-bottom: 0;
}
.setting-label-line {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #adb5bd;
    margin-bottom: 6px;
}
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 99px;
    background: #2d333f;
    outline: none;
    -webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}
.btn-reset {
    width: 100%;
    padding: 9px;
    border-radius: 8px;
    border: none;
    background: #2563eb;
    color: white;
    cursor: pointer;
    font-size:14px;
    margin-top:8px;
}
.btn-reset:active {
    background:#1d4ed8;
}
.switch-row {
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin:12px 0;
}
.switch-label{
    font-size:13px;
    color:#adb5bd;
}
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2d333f;
    transition: .3s;
    border-radius: 20px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #3b82f6;
}
input:checked + .slider:before {
    transform: translateX(20px);
}
.info-panel{
    background:#272c36;
    border-radius:8px;
    padding:10px;
    font-size:12px;
    color:#cbd5e1;
    white-space: pre-line;
}
.tip-text {
    font-size: 12px;
    line-height: 1.65;
    color: #94a3b8;
}
.warn-text {
    margin-top: 8px;
    font-size: 11px;
    color: #fbbf24;
}