* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: #090d16;
    color: #e2e8f0;
    font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
    overflow: hidden;
}

.studio-shell {
    display: grid;
    grid-template-columns: 1fr 440px;
    height: 100vh;
    width: 100vw;
}

/* ============ 左侧实时预览 ============ */
.preview-pane {
    display: flex;
    flex-direction: column;
    background: #05070e;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 0;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(14, 20, 35, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #ffe08a, #d4962e);
    display: grid; place-items: center; font-size: 18px;
}
.brand-title { font-size: 14px; font-weight: 600; color: #fff; }
.brand-sub { font-size: 11px; color: #94a3b8; }

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

.viewport-switch {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px;
    border-radius: 8px;
}

.vp-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.vp-btn.active { background: #f2c76f; color: #0e0a04; font-weight: 600; }

.ghost-btn {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-size: 12px;
    padding: 6px 11px;
    border-radius: 8px;
    cursor: pointer;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(242, 199, 111, 0.6); }

.preview-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #111827 0%, #05070e 100%);
    overflow: hidden;
}
.preview-stage iframe { width: 100%; height: 100%; border: none; transition: all 0.25s ease; }
.preview-stage.mobile-mode { padding: 16px; }
.preview-stage.mobile-mode iframe {
    width: 390px;
    height: min(800px, 100%);
    border-radius: 28px;
    border: 6px solid #1e293b;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.78);
}

/* ============ 右侧定制表单 ============ */
.editor-pane {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #0e1422;
}

.code-banner {
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(242, 199, 111, 0.14), rgba(15, 23, 42, 0.95));
    border-bottom: 1px solid rgba(242, 199, 111, 0.28);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.code-row {
    display: flex;
    gap: 8px;
}

.code-row input {
    flex: 1;
    background: rgba(5, 8, 16, 0.85);
    border: 1px solid rgba(242, 199, 111, 0.42);
    border-radius: 8px;
    padding: 8px 10px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    outline: none;
}

.code-row button {
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: #f2c76f;
    color: #140d04;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.code-status {
    font-size: 11px;
    color: #cbd5e1;
}
.code-status.ok { color: #6ee7b7; }
.code-status.warn { color: #fcd34d; }
.code-status.err { color: #fca5a5; }

.editor-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 13px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: #f8fafc; }

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(242, 199, 111, 0.16);
    color: #f3d58d;
    border: 1px solid rgba(242, 199, 111, 0.35);
}

.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }

.theme-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    cursor: pointer;
    text-align: left;
}
.theme-card:hover { background: rgba(255, 255, 255, 0.07); }
.theme-card.active {
    background: rgba(242, 199, 111, 0.15);
    border-color: #f2c76f;
}
.theme-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.theme-card-name { font-size: 12px; font-weight: 600; }
.theme-card-tag { font-size: 10px; color: #94a3b8; }
.theme-dots { display: flex; gap: 3px; }
.theme-dots span { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35); }

.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chip {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    font-size: 11px;
    padding: 4px 9px;
    border-radius: 999px;
    cursor: pointer;
}
.preset-chip:hover,
.preset-chip.active { border-color: #f2c76f; color: #fff; background: rgba(242, 199, 111, 0.2); }

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mini-rand-btn {
    border: 1px solid rgba(242, 199, 111, 0.42);
    background: rgba(242, 199, 111, 0.12);
    color: #ffe394;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.18s;
}
.mini-rand-btn:hover {
    background: #f2c76f;
    color: #140c03;
    font-weight: 600;
}

.field-row { display: flex; flex-direction: column; gap: 5px; }
.field-row label { font-size: 11px; color: #94a3b8; }
.field-row input[type="text"],
.field-row input[type="datetime-local"],
.field-row textarea {
    width: 100%;
    background: rgba(5, 8, 16, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 8px 10px;
    color: #fff;
    font-size: 12px;
    font-family: inherit;
    outline: none;
}
.field-row input:focus, .field-row textarea:focus { border-color: #f2c76f; }

.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 6px; }
.seg-btn {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    font-size: 11px;
    padding: 7px 6px;
    border-radius: 8px;
    cursor: pointer;
}
.seg-btn.active { background: #f2c76f; border-color: #f2c76f; color: #0b0f19; font-weight: 600; }

.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.toggle-item {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 9px; border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px; cursor: pointer;
}
.toggle-item input { accent-color: #f2c76f; }

/* 照片上传 */
.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 14px 10px;
    border: 1.5px dashed rgba(242, 199, 111, 0.45);
    border-radius: 10px; background: rgba(242, 199, 111, 0.04);
    cursor: pointer; text-align: center;
}
.dropzone:hover, .dropzone.dragover { background: rgba(242, 199, 111, 0.12); border-color: #f2c76f; }
.dropzone input { display: none; }
.dropzone-title { font-size: 12px; font-weight: 600; color: #f3d58d; }
.dropzone-hint { font-size: 11px; color: #94a3b8; }

.photo-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.thumb-item { position: relative; aspect-ratio: 1; border-radius: 7px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.15); }
.thumb-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del {
    position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
    border-radius: 50%; border: none; background: rgba(0, 0, 0, 0.72);
    color: #fff; font-size: 11px; cursor: pointer; display: grid; place-items: center;
}

/* 语音录制区 */
.voice-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.voice-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.voice-btn {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(242, 199, 111, 0.45);
    background: rgba(242, 199, 111, 0.1);
    color: #f3d58d;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
}
.voice-btn.recording {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
    font-weight: 600;
}
.voice-preview {
    display: flex; align-items: center; gap: 8px;
}
.voice-preview audio { flex: 1; height: 32px; }

.file-pick-btn {
    display: block; padding: 9px 12px; border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.04);
    text-align: center; font-size: 12px; color: #cbd5e1; cursor: pointer;
}
.file-pick-btn input { display: none; }

/* 热门 BGM 歌单与试听区 */
.bgm-segmented { grid-template-columns: repeat(3, 1fr); }
.bgm-sub-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.bgm-sub-box[hidden] { display: none; }
.bgm-sub-tip { font-size: 11px; color: #94a3b8; line-height: 1.5; }
.bgm-audition-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bgm-audition-row .voice-btn { padding: 6px 10px; font-size: 11px; }
.bgm-now-playing { font-size: 11px; color: #f3d58d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.bgm-select-row { display: flex; gap: 8px; align-items: center; }
.bgm-select {
    flex: 1;
    min-width: 0;
    background: rgba(5, 8, 16, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 7px 8px;
    color: #fff;
    font-size: 12px;
    outline: none;
}
.bgm-select:focus { border-color: #f2c76f; }
.bgm-select-row .voice-btn { padding: 7px 12px; font-size: 12px; flex-shrink: 0; }

.danger-link { background: none; border: none; color: #f87171; font-size: 11px; cursor: pointer; padding: 0; }

/* 底部提交栏 */
.submit-bar {
    padding: 13px 16px;
    background: #0a0f1c;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.primary-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ffe394 0%, #d4962e 100%);
    color: #140c03;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(242, 199, 111, 0.35);
}
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.submit-tip { font-size: 11px; color: #94a3b8; text-align: center; }

/* 生成成功弹窗 */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(4, 6, 14, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop[hidden] { display: none; }

.modal-card {
    width: 100%;
    max-width: 440px;
    background: #111827;
    border: 1px solid rgba(242, 199, 111, 0.5);
    border-radius: 18px;
    padding: 26px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.8);
}
.modal-card h3 { margin: 0; font-size: 19px; color: #ffe394; }
.modal-desc { margin: 0; font-size: 12px; color: #cbd5e1; line-height: 1.6; }
.gift-link-box {
    background: rgba(5, 8, 16, 0.9);
    border: 1px solid rgba(242, 199, 111, 0.35);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    color: #ffe394;
    word-break: break-all;
    user-select: all;
}
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.modal-actions a, .modal-actions button {
    padding: 10px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
}
.btn-copy-link { background: #f2c76f; color: #140c03; }
.btn-open-gift { background: rgba(255, 255, 255, 0.12); color: #fff; }
.btn-close-modal { background: transparent; border: none; color: #94a3b8; font-size: 12px; cursor: pointer; }

@media (max-width: 960px) {
    html, body { overflow: auto; }
    .studio-shell { grid-template-columns: 1fr; height: auto; }
    .preview-pane { height: 56vh; }
    .editor-pane { height: auto; }
}
