/* VoiceLab 样式（三栏版） */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    height: 100vh;
    overflow: hidden;
}

/* ============ 整体布局：三栏（导航 | 工具 | 结果） ============ */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============ 第一栏：导航 ============ */
.sidebar {
    flex: none;
    width: 200px;
    background: #0b1120;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    padding: 18px 10px;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 8px 20px;
}

.brand-logo {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    color: #f1f5f9;
}

.sidebar-foot {
    margin-top: auto;
    padding: 14px 8px 2px;
    border-top: 1px solid #1e293b;
    color: #64748b;
    font-size: 12px;
}

/* 侧边栏导航 */
.tabs {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    text-align: left;
}

.tab:hover {
    background: #1e293b;
    color: #e2e8f0;
}

.tab.active {
    background: #6366f1;
    color: #fff;
}

.tab-icon {
    flex: none;
    width: 18px;
    height: 18px;
}

/* ============ 第二栏：工具面板 ============ */
.main {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 第二栏滚动区（隐藏滚动条，仅保留滚轮/触摸滚动） */
.main-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 32px 40px;
    scrollbar-width: none;
}

.main-scroll::-webkit-scrollbar {
    display: none;
}

.panel {
    display: none;
    max-width: 720px;
    margin: 0 auto;
}

.panel.active {
    display: block;
}

.panel h2 {
    margin-bottom: 8px;
    color: #f1f5f9;
    font-size: 20px;
}

.desc {
    color: #94a3b8;
    margin-bottom: 24px;
    font-size: 14px;
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #cbd5e1;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 14px;
    font-family: inherit;
}

.form-group input[type="file"] {
    padding: 10px;
    border: 1px dashed #334155;
    border-radius: 8px;
    width: 100%;
    color: #94a3b8;
}

.form-group textarea {
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #6366f1;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 150px;
    gap: 16px;
}

/* 标签行 + AI 小按钮 */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.label-row label {
    margin-bottom: 0;
}

/* AI 写剧本 */
.ai-box {
    padding: 18px;
    background: #0f172a;
    border: 1px dashed #475569;
    border-radius: 12px;
    margin-bottom: 24px;
}

.ai-box-title {
    color: #c7d2fe;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
}

.ai-box .form-row {
    grid-template-columns: 1fr 1fr;
}

.ai-box .form-group {
    margin-bottom: 14px;
}

/* 配音工坊：两列布局（左：AI 写剧本 + 剧本；右：其余功能） */
#studio {
    max-width: 1000px;
}

.studio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.studio-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.studio-col .ai-box,
.studio-col .form-group {
    margin-bottom: 0;
}

/* 角色音色下拉 */
.cast-voices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cast-empty {
    color: #64748b;
    font-size: 13px;
    padding: 6px 0;
}

.cast-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cast-name {
    flex: none;
    width: 64px;
    color: #94a3b8;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cast-row select {
    flex: 1;
    min-width: 0;
}

/* 在线录音 */
.recorder {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.record-status {
    color: #94a3b8;
    font-size: 13px;
}

#vc-preview {
    width: 100%;
    margin-top: 12px;
}

/* ============ 图标按钮体系 ============ */
.icon-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #334155;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.15s;
}

.icon-btn:hover {
    background: #475569;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.icon-btn.xs {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: transparent;
    color: #a5b4fc;
    border: 1px solid #4f46e5;
}

.icon-btn.xs:hover {
    background: #6366f1;
    color: #fff;
}

.icon-btn.xs svg {
    width: 14px;
    height: 14px;
}

.icon-btn.sm {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #334155;
}

.icon-btn.sm svg {
    width: 16px;
    height: 16px;
}

.icon-btn.primary {
    background: #6366f1;
    color: #fff;
    width: auto;
    min-width: 40px;
    height: 40px;
    padding: 0 16px;
    gap: 8px;
    font-size: 14px;
}

.icon-btn.primary:hover {
    background: #4f46e5;
}

.icon-btn.danger {
    background: #7f1d1d;
    color: #fecaca;
}

.icon-btn.danger:hover {
    background: #991b1b;
}

.icon-btn.play {
    background: #6366f1;
    color: #fff;
    border-radius: 50%;
}

.icon-btn.play:hover {
    background: #4f46e5;
}

.icon-btn.record {
    background: #dc2626;
    color: #fff;
}

.icon-btn.record:hover {
    background: #b91c1c;
}

.icon-btn.record.recording {
    background: #7f1d1d;
    animation: vl-pulse 1.2s ease-in-out infinite;
}

.icon-btn.block {
    width: 100%;
    height: 42px;
}

@keyframes vl-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* 忙碌态：隐藏图标，显示旋转 spinner */
.icon-btn.busy {
    pointer-events: none;
    opacity: 0.8;
}

.icon-btn.busy > svg {
    display: none;
}

.icon-btn.busy::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: vl-spin 0.8s linear infinite;
}

.icon-btn.primary.busy::after {
    border-color: rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
}

@keyframes vl-spin {
    to { transform: rotate(360deg); }
}

/* ============ 第三栏：生成结果列表 ============ */
.results {
    flex: none;
    width: 320px;
    background: #0b1120;
    border-left: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.results-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #1e293b;
}

.results-head h3 {
    font-size: 15px;
    color: #f1f5f9;
}

.results-count {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #6366f1;
    color: #fff;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.result-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.results-empty {
    color: #64748b;
    font-size: 13px;
    text-align: center;
    padding: 40px 12px;
}

.result-item {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 12px;
}

.result-item.playing {
    border-color: #6366f1;
}

.result-item-text {
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 10px;
}

.result-item-actions {
    display: flex;
    gap: 6px;
}

.result-item-actions .icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.result-item-actions .icon-btn svg {
    width: 15px;
    height: 15px;
}

.result-item-actions .icon-btn.playing {
    background: #6366f1;
    color: #fff;
}

.result-item-actions .icon-btn.danger {
    background: transparent;
    border: 1px solid #7f1d1d;
    color: #fca5a5;
}

.result-item-actions .icon-btn.danger:hover {
    background: #7f1d1d;
    color: #fecaca;
}

/* ============ 底部播放器（固定在第二栏底部） ============ */
.player {
    flex: none;
    width: 100%;
    height: 72px;
    background: #0b1120;
    border-top: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    z-index: 500;
    transition: height .25s ease, padding .25s ease, border-color .25s ease;
}

/* 向下收起控件栏 */
.player.collapsed {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
    overflow: hidden;
}

/* 收起后右下角留下的向上箭头 */
.player-restore {
    position: absolute;
    right: 20px;
    bottom: 12px;
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.player.collapsed ~ .player-restore {
    opacity: 1;
    visibility: visible;
}

#player-toggle {
    width: 44px;
    height: 44px;
}

.player-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.player-title {
    font-size: 13px;
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-line {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-time {
    flex: none;
    font-size: 11px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    width: 36px;
}

.player-time:last-child {
    text-align: right;
}

.player-seek {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #334155;
    border-radius: 999px;
    outline: none;
    cursor: pointer;
}

.player-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.player-seek::-moz-range-thumb {
    display: none;
}

.player-volume {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
}

.player-vol-icon {
    width: 18px;
    height: 18px;
    color: #94a3b8;
    cursor: pointer;
}

/* 悬停音量图标时向上弹出的竖向滑块 */
.player-vol-pop {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    padding: 12px 6px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    z-index: 600;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility .15s ease;
}

/* 透明桥接区：鼠标从图标移到弹出层途中保持 hover */
.player-vol-pop::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -8px;
    height: 8px;
}

.player-volume:hover .player-vol-pop {
    opacity: 1;
    visibility: visible;
}

.player-vol-pop input[type="range"] {
    writing-mode: vertical-lr;
    direction: rtl;
    -webkit-appearance: none;
    appearance: none;
    width: 6px;
    height: 84px;
    background: #334155;
    border-radius: 999px;
    outline: none;
    cursor: pointer;
}

.player-vol-pop input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #94a3b8;
    cursor: pointer;
}

.player-vol-pop input[type="range"]::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: none;
    border-radius: 50%;
    background: #94a3b8;
    cursor: pointer;
}

/* ============ 历史记录 ============ */
.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.history-empty {
    color: #94a3b8;
    font-size: 14px;
    padding: 20px 0;
}

.history-item {
    padding: 16px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.history-badge {
    flex: none;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 999px;
    background: #6366f1;
    color: #fff;
}

.history-title {
    color: #f1f5f9;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-sub {
    color: #94a3b8;
    font-size: 12px;
    margin-bottom: 10px;
}

.history-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-actions .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    text-decoration: none;
}

.history-actions .icon-btn svg {
    width: 16px;
    height: 16px;
}

.history-actions .icon-btn.danger {
    background: transparent;
    border: 1px solid #7f1d1d;
    color: #fca5a5;
}

.history-actions .icon-btn.danger:hover {
    background: #7f1d1d;
    color: #fecaca;
}

/* ============ 全局提示 ============ */
.toast {
    position: fixed;
    left: 50%;
    bottom: 92px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: #334155;
    color: #e2e8f0;
    padding: 12px 22px;
    border-radius: 10px;
    border: 1px solid #475569;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: 14px;
    z-index: 900;
}

.toast.hidden {
    display: none;
}

.spinner {
    flex: none;
    width: 14px;
    height: 14px;
    border: 2px solid #64748b;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: vl-spin 0.8s linear infinite;
}

.hidden {
    display: none;
}

/* ============ 登录遮罩 ============ */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-overlay.hidden {
    display: none;
}

.login-box {
    width: 320px;
    max-width: 90vw;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 28px;
}

.login-box h3 {
    color: #f1f5f9;
    margin-bottom: 6px;
}

.login-box .desc {
    margin-bottom: 18px;
}

.login-box input {
    width: 100%;
    padding: 12px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 14px;
    margin-bottom: 14px;
}

.login-box input:focus {
    outline: none;
    border-color: #6366f1;
}

.login-error {
    color: #fca5a5;
    font-size: 13px;
    margin-bottom: 12px;
}

.login-error.hidden {
    display: none;
}

/* ============ 响应式 ============ */
@media (max-width: 1100px) {
    .results {
        width: 260px;
    }
}

@media (max-width: 900px) {
    body {
        overflow: auto;
        height: auto;
    }

    .app {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        position: static;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 10px 12px;
        overflow-x: auto;
    }

    .brand {
        flex: none;
        padding: 0;
    }

    .brand-name {
        display: none;
    }

    .tabs {
        flex-direction: row;
        gap: 6px;
    }

    .tab {
        width: auto;
        white-space: nowrap;
        padding: 8px 12px;
    }

    .sidebar-foot {
        display: none;
    }

    .main {
        overflow: visible;
    }

    .main-scroll {
        padding: 16px;
        overflow: visible;
    }

    .panel {
        max-width: none;
    }

    #studio {
        max-width: none;
    }

    .studio-grid {
        grid-template-columns: 1fr;
    }

    .results {
        width: 100%;
        border-left: none;
        border-top: 1px solid #1e293b;
        max-height: 320px;
    }

    .player {
        padding: 0 12px;
        gap: 10px;
    }

    .player-vol-pop input[type="range"] {
        height: 64px;
    }
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}
