/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    overflow: hidden; /* 隐藏默认滚动，使用自定义滚动 */
}

/* 整页滚动容器 */
.full-page-scroll {
    height: 100vh;
    width: 100vw;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* 隐藏滚动条但保持功能 */
.full-page-scroll::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.full-page-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* 滚动页面 */
.scroll-page {
    height: 100vh;
    width: 100vw;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    overflow: hidden;
}

/* 入口欢迎页样式 */
#intro-page {
    display: flex;
    align-items: center;
    justify-content: center;
    /* 背景图平铺 */
    /* 背景图片在 backgrounds 文件夹，确保带有扩展名 */
    background: url('backgrounds/v2-76a38f748fd8b54bccac73afe92d7c28_1440w.jpeg') center center / cover repeat;
    color: #fff;
    position: relative;
}

/* 主应用页面 */
#app-page {
    display: flex;
    flex-direction: column;
    /* 从左上到右下的平滑过渡渐变色 */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    height: 100%;
    overflow: hidden;
}

/* 应用容器在页面中的样式 */
#app-page #app {
    flex: 1;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* 半透明黑色浮层 */
#intro-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 1;
}

#intro-page .intro-content {
    position: relative;
    z-index: 2;
}

#intro-page .intro-content h1 {
    font-size: 3rem;
    text-align: center;
    padding: 20px;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

/* title parts (no animation) */
.title-part {
    display: inline-block;
    opacity: 1;
    transform: none;
}

/* subtitle style (static) */
.subtitle {
    margin-top: 10px;
    font-size: 1rem;
    background: linear-gradient(90deg, #9ad4d6, #58a0a4, #ddc3c7, #d1a9a9);
    -webkit-background-clip: text;
    color: transparent;
    opacity: 1;
    text-align: center;
}

/* 滑动指引 */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    color: #fff;
    font-size: 14px;
    opacity: 0.8;
}

.scroll-indicator .arrow {
    display: block;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid #fff;
    margin-bottom: 6px;
    animation: arrow-bounce 1.5s infinite;
}

@keyframes arrow-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) rotate(45deg) translateY(0); }
    40% { transform: translateX(-50%) rotate(45deg) translateY(8px); }
    60% { transform: translateX(-50%) rotate(45deg) translateY(4px); }
}

/* 应用容器 */
#app {
    position: relative;
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* 侧边面板 */
.side-panel {
    width: 220px;
    min-width: 220px;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.3s ease;
}

.side-panel.folded {
    width: 0;
    min-width: 0;
    overflow: visible; /* 保持折叠按钮可见 */
    z-index: 100; /* 折叠时面板层级提升，确保按钮浮在预览区之上 */
}

.side-panel.folded .panel-content {
    overflow: hidden;
    visibility: hidden;
    width: 0;
    min-width: 0;
    padding: 0;
    opacity: 0;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
}

.panel-content::-webkit-scrollbar {
    width: 4px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* 折叠按钮：固定在面板边缘，垂直居中，折叠时仍可见，置于最上层 */
.fold-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 40px;
    background: #2d2d44;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 300ms ease;
    z-index: 1000;
}

.fold-btn:hover {
    background: #3d3d5c;
}

/* 左侧折叠按钮：相对 #app 定位，展开时在左面板右缘，折叠时在左边缘 */
#fold-left {
    left: 220px;
    border-radius: 4px 0 0 4px;
    border-right: none;
}

#app.left-panel-folded #fold-left {
    left: 0;
    border-radius: 0 4px 4px 0;
    border-left: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* 右侧折叠按钮：相对 #app 定位，展开时在右面板左缘，折叠时在右边缘 */
#fold-right {
    right: 220px;
    border-radius: 0 4px 4px 0;
    border-left: none;
}

#app.right-panel-folded #fold-right {
    right: 0;
    border-radius: 4px 0 0 4px;
    border-right: none;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* 区块标题 */
.section {
    margin-bottom: 16px;
}

.section-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* 子区块 */
.subsection {
    margin-bottom: 12px;
}

.subsection-label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-bottom: 8px;
}

/* 图片网格 */
.image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.image-grid-item {
    aspect-ratio: 16/10;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.image-grid-item:hover {
    border-color: #667eea;
    transform: scale(1.02);
}

.image-grid-item.selected {
    border-color: #10b981;
}

.image-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 文件输入 */
.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-btn {
    padding: 6px 12px;
    background: #3d3d5c;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-btn:hover {
    background: #4d4d6c;
}

.file-name {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 切换开关 */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.toggle-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3d3d5c;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #8b5cf6;
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* 滑块 */
.slider-row {
    margin-bottom: 12px;
}

.slider-label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin-bottom: 8px;
}

.slider {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #3d3d5c;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.4);
    font-size: 10px;
    margin-top: 4px;
}

/* 按钮 */
.btn {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.btn:last-child {
    margin-bottom: 0;
}

.btn-primary {
    background: #8b5cf6;
    color: #fff;
}

.btn-primary:hover {
    background: #7c3aed;
}

.btn-success {
    background: #10b981;
    color: #fff;
}

.btn-success:hover {
    background: #059669;
}

.btn-secondary {
    background: #374151;
    color: #fff;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-warning {
    background: #d97706;
    color: #fff;
}

.btn-warning:hover {
    background: #b45309;
}

.btn-orange {
    background: #ea580c;
    color: #fff;
}

.btn-orange:hover {
    background: #c2410c;
}

.btn-gray {
    background: #4b5563;
    color: #fff;
}

.btn-gray:hover {
    background: #6b7280;
}

/* 新增信息按钮样式 */
.btn-info {
    background: #3b82f6;
    color: #fff;
}

.btn-info:hover {
    background: #2563eb;
}

/* 按钮组 */
.button-group .btn {
    margin-bottom: 8px;
}

/* 导航按钮 */
.nav-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.nav-buttons .btn {
    margin-bottom: 0;
}

/* 暂存场景预览模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: #1a1a2e;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    color: #fff;
    position: relative;
}

.snapshot-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.snapshot-item {
    background: #2d2d44;
    border-radius: 4px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.snapshot-thumb {
    width: 100%;
    height: 72px;
    object-fit: cover;
    background: #000;
    border-radius: 2px;
    margin-bottom: 6px;
}

.snapshot-info {
    font-size: 12px;
    margin-bottom: 6px;
}

.snapshot-restore-btn {
    font-size: 11px;
    padding: 4px 8px;
}

.modal-close {
    margin-top: 12px;
    width: auto;
}

/* 撤回按钮 */
.undo-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.undo-buttons .btn {
    margin-bottom: 0;
}

/* 中间预览区域 */
.preview-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

.preview-wrapper {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    aspect-ratio: 16/9;
}

/* 预览容器 */
.preview-container {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* 图片关联样式 - 已移至HTML内联样式 */

.preview-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

.character-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.character-sprite {
    position: absolute;
    bottom: 0;
    height: 85%;
    pointer-events: auto;
    transition: all 0.3s ease;
    max-width: 40%;
}

.character-sprite img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

/* 单个角色居中 */
.character-sprite.single {
    left: 50%;
    transform: translateX(-50%);
}

/* 第一个角色（两个角色时）- 位于左侧偏右位置 */
.character-sprite.first {
    left: 25%;
    transform: translateX(-50%);
}

/* 第二个角色 - 位于右侧 */
.character-sprite.second {
    left: 75%;
    transform: translateX(-50%);
}

/* 指挥官对话框 */
.commander-dialog {
    position: absolute;
    top: 50%;
    right: 2rem;
    width: 20rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transform: translateY(-50%);
}

.commander-text {
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    color: #000;
    font-size: 0.875rem;
    padding: 0.5rem;
    resize: none;
    outline: none;
    font-family: monospace;
    letter-spacing: 0.05em;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 对话区域 - 位于背景图内部底部 */
.dialog-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6), transparent);
    z-index: 50;
}

.character-name {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid white;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 0.25rem;
    outline: none;
    resize: none;
}

.character-name:focus {
    outline: none;
}

.character-name::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* 导出时用于替代 input 的 div，避免 html2canvas 裁切角色名 */
.character-name-export {
    display: block;
    white-space: nowrap;
    overflow: visible;
}

.dialog-input-wrapper {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px;
}

.dialog-input {
    width: 100%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.90);
    font-size: 20px;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: inherit;
}

.dialog-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .side-panel {
        width: 200px;
        min-width: 200px;
    }
    
    #fold-left { left: 200px; }
    #app.left-panel-folded #fold-left { left: 0; }
    #fold-right { right: 200px; }
    #app.right-panel-folded #fold-right { right: 0; }
}

@media (max-width: 900px) {
    .side-panel {
        width: 180px;
        min-width: 180px;
    }
    
    #fold-left { left: 180px; }
    #app.left-panel-folded #fold-left { left: 0; }
    #fold-right { right: 180px; }
    #app.right-panel-folded #fold-right { right: 0; }
    
    .preview-wrapper {
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }
    
    .side-panel {
        width: 100%;
        height: 200px;
        min-height: 200px;
    }
    
    .side-panel.folded {
        height: 0;
        min-height: 0;
    }
    
    .fold-btn {
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 20px;
    }
    
    #fold-left {
        right: auto;
        bottom: -20px;
        border-radius: 0 0 4px 4px;
    }
    
    #fold-right {
        left: 50%;
        top: -20px;
        border-radius: 4px 4px 0 0;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* 打字机效果 */
.typing-cursor::after {
    content: '|';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}
/* 文本格式化信息样式 */
.format-info {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #fff;
    margin-top: 6px;
}

.format-info span {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* 顶部声明栏样式 */
.top-disclaimer-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(90deg, #991b1b, #7f1d1d); /* 深红色警告背景 */
    color: #fff;
    text-align: center;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 9999; /* 确保在最顶层 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* 可选：鼠标悬停时稍微变亮 */
.top-disclaimer-banner:hover {
    background: linear-gradient(90deg, #b91c1c, #991b1b);
}
/* ģ̬�򣺱��泡��Ԥ�� */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    position: relative;
    background: #1a1a2e;
    padding: 20px;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    color: #fff;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

#saved-scenes-modal .modal-footer {
    position: sticky;
    bottom: 0;
    background: #1a1a2e;
    padding-top: 15px;
    padding-bottom: 5px;
}

.close {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.scene-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-start;
}

.scene-list img.scene-thumb {
    width: 150px;
    height: auto;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
}

.scene-list img.scene-thumb:hover {
    border-color: #10b981;
}

/* 导出进度弹窗 */
.export-progress-content {
    min-width: 400px;
}

.export-progress-content h3 {
    margin: 0 0 15px 0;
    text-align: center;
}

.progress-container {
    margin-bottom: 12px;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: #2d2d44;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    border-radius: 12px;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: #a0a0b0;
}

.export-all-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #3d3d5c;
}

.export-tip {
    font-size: 12px;
    color: #8080a0;
    text-align: center;
    margin: 8px 0;
}

.cancel-btn {
    width: 100%;
    padding: 10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.cancel-btn:hover {
    background: #dc2626;
}

/* 更多设置面板 */
.more-settings-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.more-settings-content.expanded {
    max-height: 1000px;
    overflow-y: auto;
}

#more-settings-arrow {
    display: inline-block;
    margin-left: 8px;
    transition: transform 0.3s ease;
}

#more-settings-arrow.rotated {
    transform: rotate(180deg);
}

/* 紧凑版输入框 */
.color-input-compact {
    width: 100%;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #2d2d44;
    color: #fff;
    font-size: 13px;
    box-sizing: border-box;
}

.format-btn {
    padding: 6px 12px;
    margin: 2px;
    min-width: 32px;
    height: 32px;
}

.format-btn.active {
    background: #4CAF50 !important;
    color: white !important;
    font-weight: bold;
}

/* 导出弹窗关闭按钮样式 */
.modal-close-cross {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #fff;
    opacity: 0.7;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 100;
    line-height: 1;
}

.modal-close-cross:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-close-cross:active {
    transform: scale(0.95);
}
