/* 控制面板样式 — Apple Light Theme */
.controls {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* 登录同步按钮 — 固定圆形图标，仅颜色区分状态 */
.auth-entrance-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 50%;
    color: rgba(29, 29, 31, 0.5);
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    box-sizing: border-box;
}

.auth-entrance-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(29, 29, 31, 0.8);
}

.auth-entrance-btn:active {
    /* 无动画，保持固定尺寸 */
}

.auth-entrance-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* 已登录：绿色 */
.auth-entrance-btn.logged-in {
    border-color: rgba(52, 199, 89, 0.4);
    color: rgba(52, 199, 89, 0.85);
}

.auth-entrance-btn.logged-in:hover {
    background: rgba(52, 199, 89, 0.1);
    border-color: rgba(52, 199, 89, 0.5);
    color: #34c759;
}

/* 插件库按钮及其后面的按钮靠右 */
#pluginLibraryBtn {
    margin-left: auto;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: rgba(29, 29, 31, 0.85);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    padding: 0;
}

.control-btn svg {
    display: block;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.85);
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.control-btn:active {
    transform: scale(0.95);
}

#settingsToggle.active {
    background: rgba(0, 0, 0, 0.08);
    transform: rotate(90deg);
}

#settingsToggle:hover {
    transform: rotate(45deg) scale(1.05);
}

#settingsToggle.active:hover {
    transform: rotate(90deg) scale(1.05);
}

/* ============================
   底部工具栏
   ============================ */
.bottom-toolbar {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 8px) + 4px);
    left: 0;
    right: 0;
    max-width: 100vw;
    z-index: 1500;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    padding: 14px 20px 0 20px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    scroll-behavior: smooth;
}
.bottom-toolbar::-webkit-scrollbar {
    display: none; /* Chrome/Safari: hide scrollbar */
}
.bottom-toolbar::after {
    content: '';
    flex: 0 0 4px; /* right padding for scroll end */
}

/* ========== 滑动边缘提示 ========== */
.toolbar-edge {
    position: fixed;
    z-index: 1501;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.25s ease;
}
/* 默认微微上浮，出现时滑入 */
.toolbar-edge.left {
    left: 8px;
    transform: translateX(-6px) translateY(2px);
}
.toolbar-edge.left.visible {
    transform: translateX(0) translateY(0);
}
.toolbar-edge.right {
    right: 8px;
    transform: translateX(6px) translateY(2px);
}
.toolbar-edge.right.visible {
    transform: translateX(0) translateY(0);
}

/* 小型半透明确认圆 + 箭头 */
.toolbar-edge::before {
    content: '';
    position: absolute;
    bottom: 100%;
    margin-bottom: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(29, 29, 31, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.toolbar-edge::after {
    content: '';
    position: absolute;
    bottom: calc(100% - 4px);
    width: 7px;
    height: 7px;
    border-color: rgba(255, 255, 255, 0.85);
    border-style: solid;
    border-width: 0;
}
.toolbar-edge.left::after {
    left: 50%;
    margin-left: -5px;
    border-left-width: 2px;
    border-bottom-width: 2px;
    transform: rotate(45deg) translateY(-1px);
}
.toolbar-edge.right::after {
    right: 50%;
    margin-right: -5px;
    border-right-width: 2px;
    border-top-width: 2px;
    transform: rotate(45deg) translateY(-1px);
}
.toolbar-edge.visible {
    opacity: 1;
}

.bottom-tool-btn {
    width: 56px;
    min-width: 56px;
    height: 56px;
    flex-shrink: 0;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 0;
}

.bottom-tool-btn:hover {
    transform: scale(1.08);
}

.bottom-tool-btn:active {
    transform: scale(0.95);
    transition: all 0.1s ease;
}

.tool-btn-icon {
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.5px;
    line-height: 1;
    color: currentColor;
}

/* 设置面板 */
.settings-panel {
    position: absolute;
    top: 35px;
    right: 0;
    width: 240px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.settings-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 音乐面板 */
.music-panel {
    position: absolute;
    top: 35px;
    right: 40px;
    width: 280px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    max-height: 400px;
}

.music-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.music-panel-content {
    padding: 8px 0;
}

.music-current-track {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
}

#musicPanelTrackName {
    font-size: 13px;
    color: rgba(134, 134, 139, 0.9);
    font-weight: 500;
}

/* 音乐控制按钮区域 */
.music-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.music-control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: rgba(29, 29, 31, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.music-control-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.1);
}

.music-control-btn:active {
    transform: scale(0.95);
}

.music-control-btn svg {
    display: block;
}

#musicPlayPauseBtn.playing .play-icon {
    display: none;
}

#musicPlayPauseBtn.playing .pause-icon {
    display: block !important;
}

#musicPlayPauseBtn:not(.playing) .play-icon {
    display: block;
}

#musicPlayPauseBtn:not(.playing) .pause-icon {
    display: none !important;
}

.music-panel-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
}

.music-panel-list::-webkit-scrollbar {
    width: 6px;
}

.music-panel-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 3px;
}

.music-panel-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.music-panel-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.music-panel-track {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.music-panel-track:hover {
    background: rgba(0, 0, 0, 0.04);
}

.music-panel-track.active {
    background: rgba(0, 113, 227, 0.08);
    border-left: 3px solid #0071e3;
}

.music-panel-track .track-icon {
    font-size: 14px;
    color: rgba(134, 134, 139, 0.8);
}

.music-panel-track.active .track-icon {
    color: #0071e3;
}

.music-panel-track .track-name {
    font-size: 13px;
    color: rgba(29, 29, 31, 0.85);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-header {
    padding: 18px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-close-btn {
    background: none;
    border: none;
    color: rgba(134, 134, 139, 0.8);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: 12px;
}

.panel-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(29, 29, 31, 0.9);
}

.panel-close-btn:active {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(0.95);
}

.panel-content {
    padding: 8px 0;
}

.setting-item {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.setting-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.setting-item:active {
    background: rgba(0, 0, 0, 0.06);
}

.setting-icon {
    font-size: 18px;
    margin-right: 12px;
    width: 20px;
    height: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(134, 134, 139, 0.9);
}

.setting-text {
    flex: 1;
    font-size: 14px;
    color: rgba(29, 29, 31, 0.85);
    font-weight: 400;
}

.setting-status {
    font-size: 12px;
    color: rgba(134, 134, 139, 0.8);
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.setting-status.active {
    color: #34c759;
    background: rgba(52, 199, 89, 0.12);
}

/* 颜色选择器面板 */
.color-panel {
    position: absolute;
    top: 35px;
    right: 250px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.color-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.color-option {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin: 5px;
    cursor: pointer;
    display: inline-block;
    border: 3px solid rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
    transform: scale(1.15);
    border-color: rgba(0, 0, 0, 0.2);
}

.color-option:active {
    transform: scale(1.05);
}

/* 文件输入隐藏 */
#imageInput {
    display: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .controls {
        top: 15px;
        right: 20px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .settings-panel {
        width: 200px;
    }
    
    .music-panel {
        width: 240px;
    }
    
    .color-panel {
        right: 210px;
        padding: 15px;
    }
    
    .color-option {
        width: 38px;
        height: 38px;
    }
}

/* 平板纵屏优化 (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .controls {
        top: 18px;
        right: 20px;
        gap: 8px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .controls {
        top: 15px;
        right: 15px;
        gap: 8px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .auth-entrance-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    .auth-entrance-icon {
        width: 14px;
        height: 14px;
    }
    
    .settings-panel {
        width: 180px;
        right: 0px;
    }
    
    .music-panel {
        width: 200px;
        right: 50px;
    }
    
    .color-panel {
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(-10px) scale(0.95);
    }
    
    .color-panel.active {
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* 手机横屏模式 - 控制按钮优化 */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    .controls {
        top: 8px;
        right: 15px;
        gap: 8px;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
    }
    
    .control-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .auth-entrance-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .auth-entrance-icon {
        width: 14px;
        height: 14px;
    }
    
    .settings-panel {
        width: 200px;
        top: 30px;
    }
    
    .music-panel {
        width: 220px;
        top: 30px;
        right: 35px;
        max-height: 300px;
    }
    
    .panel-header {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .music-current-track {
        padding: 10px 16px;
    }
    
    #musicPanelTrackName {
        font-size: 12px;
    }
    
    .music-controls {
        padding: 10px 16px;
        gap: 6px;
    }
    
    .music-control-btn {
        width: 32px;
        height: 32px;
    }
    
    .music-control-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .music-panel-list {
        max-height: 200px;
    }
    
    .music-panel-track {
        padding: 8px 10px;
    }
    
    .music-panel-track .track-name {
        font-size: 12px;
    }
    
    .setting-item {
        padding: 10px 16px;
    }
    
    .setting-icon {
        width: 18px;
        height: 18px;
        margin-right: 10px;
    }
    
    .setting-text {
        font-size: 13px;
    }
    
    .color-panel {
        top: 30px;
        right: 210px;
        padding: 12px;
    }
    
    .color-option {
        width: 35px;
        height: 35px;
        margin: 4px;
    }
}

/* 更小的横屏设备 */
@media (max-width: 700px) and (max-height: 400px) and (orientation: landscape) {
    .controls {
        top: 6px;
        right: 12px;
        gap: 6px;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
    }
    
    .control-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .auth-entrance-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    
    .auth-entrance-icon {
        width: 12px;
        height: 12px;
    }
    
    .settings-panel {
        width: 180px;
        top: 28px;
    }
    
    .music-panel {
        width: 200px;
        top: 28px;
        right: 32px;
        max-height: 250px;
    }
    
    .panel-header {
        padding: 10px 14px;
        font-size: 12px;
    }
    
    .music-current-track {
        padding: 8px 14px;
    }
    
    #musicPanelTrackName {
        font-size: 11px;
    }
    
    .music-controls {
        padding: 8px 14px;
        gap: 5px;
    }
    
    .music-control-btn {
        width: 28px;
        height: 28px;
    }
    
    .music-control-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .music-panel-list {
        max-height: 150px;
    }
    
    .music-panel-track {
        padding: 6px 8px;
        margin-bottom: 3px;
    }
    
    .music-panel-track .track-icon {
        font-size: 12px;
    }
    
    .music-panel-track .track-name {
        font-size: 11px;
    }
    
    .setting-item {
        padding: 8px 14px;
    }
    
    .setting-icon {
        width: 16px;
        height: 16px;
        margin-right: 8px;
    }
    
    .setting-icon svg {
        width: 16px;
        height: 16px;
    }
    
    .setting-text {
        font-size: 12px;
    }
    
    .color-panel {
        top: 28px;
        right: 190px;
        padding: 10px;
    }
    
    .color-option {
        width: 30px;
        height: 30px;
        margin: 3px;
    }
}

/* 底部工具栏响应式 */
@media (max-width: 480px) {
    .bottom-toolbar {
        bottom: calc(env(safe-area-inset-bottom, 6px) + 4px);
        gap: 8px;
        padding: 12px 14px 0 14px;
    }

    .bottom-tool-btn {
        width: 48px;
        min-width: 48px;
        height: 48px;
    }

    .tool-btn-icon {
        font-size: 18px;
    }

    .tool-btn-label {
        font-size: 9px;
    }
}

@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    .bottom-toolbar {
        bottom: calc(env(safe-area-inset-bottom, 2px) + 2px);
        gap: 6px;
        padding: 10px 12px 0 12px;
    }

    .bottom-tool-btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
    }

    .tool-btn-icon {
        font-size: 16px;
    }

    .tool-btn-label {
        font-size: 8px;
    }
}
