* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-light: #8b5cf6;
    --primary-dark: #4f46e5;
    --secondary-color: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --background: #ffffff;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.title-icon {
    font-size: 2rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

.settings-panel {
    background: var(--surface);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.api-settings h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.api-config-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group input,
.input-group select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: var(--transition);
    background: white;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.input-group small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.region-selection {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.region-selection label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.region-selection select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: white;
    transition: var(--transition);
}

.region-selection select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgb(99 102 241 / 0.1);
}

.help-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.help-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.help-content {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: var(--shadow);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.help-content h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.help-content ol {
    margin-left: 1rem;
    margin-bottom: 1rem;
}

.help-content li {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.help-content li strong {
    color: var(--text-primary);
    font-weight: 600;
}

.help-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.help-content a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.pricing-info {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    border-left: 4px solid var(--primary-color);
}

.pricing-info strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
}

.api-status {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-indicator {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.status-indicator.configured {
    background: #d1fae5;
    color: #065f46;
    border-color: #a7f3d0;
}

.status-indicator.error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 0;
    min-height: 600px;
}

.editor-section {
    padding: 2rem;
    border-right: 1px solid var(--border);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.editor-header h2 {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    height: calc(100vh - 300px);
    min-height: 800px;
}

.editor-wrapper,
.preview-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: white;
}

#markdown-editor {
    width: 100%;
    height: 100%;
    border: none;
    padding: 1rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    background: #fafafa;
}

.markdown-preview {
    height: 100%;
    padding: 1rem;
    overflow-y: auto;
    background: white;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.markdown-preview h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.markdown-preview h2 {
    font-size: 1.5rem;
}

.markdown-preview h3 {
    font-size: 1.3rem;
}

.markdown-preview p {
    margin-bottom: 1rem;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.markdown-preview blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
}

.markdown-preview pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1rem 0;
}

.markdown-preview code {
    background: var(--surface);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.85rem;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
}

.tools-section {
    padding: 2rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tool-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.tool-card h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.voice-settings {
    margin-bottom: 1rem;
}

.voice-settings .input-group {
    margin-bottom: 0.75rem;
}

.voice-settings input[type="range"] {
    width: 100%;
}

#rate-value {
    font-weight: 500;
    color: var(--primary-color);
}

.platform-selection {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.platform-selection label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.platform-selection label:hover {
    background: var(--surface);
}

.platform-selection input[type="checkbox"] {
    accent-color: var(--primary-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    min-height: 44px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1rem;
}

.result-area {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.result-area audio {
    width: 100%;
    margin-bottom: 1rem;
}

.audio-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.audio-controls .btn {
    margin: 0;
}

.script-display {
    margin-top: 1rem;
}

.script-display h4 {
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.script-content {
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 1rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.script-item {
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    background: white;
    border-left: 3px solid var(--primary-color);
    transition: var(--transition);
}

.script-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateX(2px);
}

.script-timestamp {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.script-text {
    color: var(--text-primary);
    line-height: 1.5;
}

#generated-titles {
    margin-bottom: 1rem;
}

.platform-titles {
    margin-bottom: 1.5rem;
}

.platform-titles h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.title-section {
    margin-bottom: 1rem;
}

.title-item {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.title-text {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
}

.tags-section {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.tags-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.tags {
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.btn-copy {
    background: var(--surface);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-copy:hover {
    background: var(--primary-color);
    color: white;
}

/* Toast 动画 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.progress-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    z-index: 1000;
    min-width: 300px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    width: 0%;
    transition: width 0.3s ease;
    animation: progress-animation 2s infinite;
}

@keyframes progress-animation {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#progress-text {
    color: var(--text-secondary);
    font-weight: 500;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .editor-section {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .api-config-section {
        grid-template-columns: 1fr;
    }

    .api-status {
        flex-direction: column;
        align-items: stretch;
    }

    .status-item {
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header {
        padding: 1.5rem;
    }

    .title {
        font-size: 2rem;
    }

    .editor-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 500px;
    }

    .editor-wrapper,
    .preview-wrapper {
        height: 400px;
    }

    .script-content {
        max-height: 200px;
    }

    .editor-section,
    .tools-section {
        padding: 1.5rem;
    }

    .audio-controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .audio-controls .btn {
        width: 100%;
    }
}