/* 小剧场页面容器 */
.page#theater-page {
    position: fixed;
    inset: 0;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
    z-index: 10000;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

.page#theater-page.is-active {
    opacity: 1;
    pointer-events: auto;
}

/* 小剧场页面头部 */
.theater-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.theater-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.theater-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theater-character-filter {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.theater-character-filter:focus {
    outline: none;
    border-color: #666666;
}

.theater-create-btn {
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.theater-create-btn:hover {
    background: #333333;
    transform: scale(1.05);
}

.theater-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state p {
    margin: 8px 0;
}

.empty-hint {
    font-size: 14px;
    opacity: 0.7;
}

/* 剧场列表 */
.theater-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.theater-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.theater-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.theater-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.theater-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.theater-card-info {
    flex: 1;
}

.theater-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.theater-card-character {
    font-size: 14px;
    color: var(--text-secondary);
}

.theater-card-mode {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.theater-card-mode.story {
    background: #f5f5f5;
    color: #333333;
}


.theater-card-content {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.theater-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* 创建弹窗 */
.theater-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.theater-modal.active {
    display: flex;
}

.theater-modal-content {
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.theater-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.theater-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.theater-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theater-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.theater-form-group {
    margin-bottom: 20px;
}

.theater-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}


.theater-select,
.theater-input,
.theater-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: all 0.2s;
}

.theater-select:focus,
.theater-input:focus,
.theater-textarea:focus {
    outline: none;
    border-color: #666666;
}

.theater-textarea {
    resize: vertical;
    font-family: inherit;
}

.theater-hint {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.theater-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theater-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.theater-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1a1a1a;
    cursor: pointer;
}

.theater-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1a1a1a;
    cursor: pointer;
    border: none;
}

.theater-slider-value {
    font-weight: 600;
    color: #1a1a1a;
    min-width: 50px;
    text-align: right;
}

.theater-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theater-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.theater-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.theater-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.theater-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.theater-btn-cancel {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.theater-btn-cancel:hover {
    background: var(--hover-bg);
}

.theater-btn-primary {
    background: #1a1a1a;
    color: white;
}

.theater-btn-primary:hover {
    background: #333333;
}

.theater-btn-primary:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* 详情页 */
.theater-detail-page {
    position: fixed;
    inset: 0;
    background: #ffffff;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.theater-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.theater-detail-title-area {
    flex: 1;
}

.theater-detail-title-area h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.theater-detail-mode {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.theater-settings-btn {
    background: #f5f5f5;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.theater-settings-btn:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

/* 故事内容 */
.theater-story-content {
    display: block;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.theater-story-info {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    flex-shrink: 0;
}

.theater-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.theater-info-label {
    font-size: 12px;
    color: var(--text-tertiary);
}

.theater-info-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.theater-story-text {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    line-height: 1.6;
    font-size: 15px;
    color: var(--text-primary);
    white-space: pre-wrap;
    font-family: KaiTi, '楷体', serif;
}

/* 对话高亮样式 */
.theater-dialogue {
    font-style: italic;
    font-weight: 600;
}

.theater-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.theater-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: #1a1a1a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 章节导航 */
.chapter-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.chapter-nav-btn {
    background: #f5f5f5;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
}

.chapter-nav-btn:hover:not(:disabled) {
    background: #e0e0e0;
    transform: scale(1.05);
}

.chapter-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chapter-regenerate-btn {
    background: #ffffff;
    border-color: var(--border-color);
    color: #1a1a1a;
}

.chapter-regenerate-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.chapter-indicator {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 120px;
    text-align: center;
}

/* 继续创作按钮 */
.theater-actions {
    display: flex;
    justify-content: center;
    padding: 24px 16px;
    margin-top: 20px;
}

.theater-continue-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.theater-continue-btn:hover {
    background: #333333;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.theater-continue-btn:active {
    transform: translateY(0);
}

.theater-continue-btn svg {
    flex-shrink: 0;
}

/* 继续创作弹窗中的滑块 */
#continueWordCount::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1a1a1a;
    cursor: pointer;
}

#continueWordCount::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1a1a1a;
    cursor: pointer;
    border: none;
}

/* 返回按钮 */
#theater-page .back-btn {
    background: white;
    border: 1px solid #e0e0e0;
    color: #1a1a1a;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 8px;
    width: 36px;
    height: 36px;
}

#theater-page .back-btn:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

/* 空状态提示文字 */
#theater-page .empty-hint {
    color: #1a1a1a;
    font-weight: 500;
}

/* 继续创作弹窗 - 需要比详情页更高的层级 */
#continueStoryModal {
    z-index: 3000;
}

/* 番外设置弹窗 */
#theaterSettingsModal {
    z-index: 3000;
}

.theater-settings-modal {
    max-width: 500px;
}

.theater-settings-readonly {
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.theater-settings-readonly p {
    margin: 0;
}

.theater-settings-empty {
    color: var(--text-tertiary);
    font-style: italic;
}

/* 颜色选择器 */
.theater-color-picker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theater-color-picker input[type="color"] {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
}

.theater-color-reset {
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.theater-color-reset:hover {
    background: var(--hover-bg);
}

/* 图片选择器 */
.theater-image-picker {
    display: flex;
    gap: 8px;
}

.theater-btn-secondary {
    padding: 8px 16px;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.theater-btn-secondary:hover {
    background: var(--hover-bg);
}

.theater-image-preview {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.theater-image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

/* 危险操作区域 */
.theater-danger-zone {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 2px solid #fee;
}

.theater-danger-zone label {
    color: #d32f2f;
}

.theater-btn-danger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #fff;
    color: #d32f2f;
    border: 2px solid #d32f2f;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.theater-btn-danger:hover {
    background: #d32f2f;
    color: white;
}

.theater-btn-danger svg {
    flex-shrink: 0;
}

/* 删除确认弹窗 */
#deleteConfirmModal {
    z-index: 4000;
}

.theater-confirm-modal {
    max-width: 400px;
}

.theater-confirm-message {
    font-size: 15px;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.theater-confirm-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* 字体导入 */
.theater-font-import {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.theater-font-import .theater-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.theater-custom-font-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-top: 8px;
}

.theater-font-name {
    font-size: 13px;
    color: var(--text-secondary);
}

.theater-btn-icon-small {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.theater-btn-icon-small:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 字体预设 */
.theater-font-preset-actions {
    margin-bottom: 12px;
}

.theater-font-preset-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.theater-font-preset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    transition: all 0.2s;
}

.theater-font-preset-item:hover {
    background: var(--bg-hover);
}

.theater-font-preset-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.theater-font-preset-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.theater-font-preset-details {
    font-size: 12px;
    color: var(--text-secondary);
}

.theater-font-preset-actions {
    display: flex;
    gap: 4px;
}

/* 响应式 */
@media (max-width: 768px) {
    .theater-list {
        grid-template-columns: 1fr;
    }

    .theater-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .theater-story-info {
        flex-direction: column;
        gap: 12px;
    }

    .theater-font-import {
        flex-direction: column;
    }

    .theater-font-preset-list {
        max-height: 200px;
    }
}
