* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 主背景色：深沉的海军蓝黑 */
    --bg-primary: #121420;
    --bg-secondary: #1a1d2e;
    --bg-tertiary: #24283b;
    /* 卡片色：明显亮出的中灰色 */
    --bg-card: #50505e;

    /* 渐变色：金黄色系 */
    --gradient-primary: linear-gradient(135deg, #FFB75E 0%, #ED8F03 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-accent: linear-gradient(135deg, #F5A623 0%, #F76B1C 100%);
    --gradient-warm: linear-gradient(135deg, #fa709a 0%, #fee140 100%);

    /* 文字颜色 */
    --text-primary: #e4e7f1;
    --text-secondary: #a0a8c1;
    --text-muted: #6b7280;

    /* 强调色统一为金色系 */
    --accent-purple: #F5A623;
    --accent-pink: #f5576c;
    --accent-blue: #F5A623;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;

    /* 边框带有微弱的金色发光感 */
    --border-color: rgba(245, 166, 35, 0.15);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* 过渡 */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 背景动画效果 */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.05) 0%, transparent 70%);
    animation: rotate 30s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* 头部样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding: 1.5rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 3rem;
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.3));
}

.logo-text h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.logo-text p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* 主内容区 - 上下布局 */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.main-content.vertical-layout {
    display: flex;
    flex-direction: column;
}

/* 区块样式 */
.input-section,
.output-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.input-section.compact {
    min-height: auto;
}

.output-section {
    min-height: 300px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-clear,
.btn-copy {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.25rem;
}

.btn-clear:hover,
.btn-copy:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.2);
}

/* 文本输入区 */
.script-textarea {
    width: 100%;
    background: #191B28;
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* 极弱的边框或去掉 */
    border-radius: var(--radius-md);
    padding: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.8;
    resize: none;
    font-family: inherit;
    transition: var(--transition);
    margin-bottom: 1rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.script-textarea:focus {
    outline: none;
    border-color: rgba(245, 166, 35, 0.5);
    /* 聚焦时亮起金边 */
    background: #1d202f;
    box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.1),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 固定高度输入框（约5行） */
.compact-textarea {
    height: 150px;
    min-height: 150px;
    max-height: 150px;
    flex: none;
}

.script-textarea:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.script-textarea::placeholder {
    color: var(--text-muted);
}

/* 按钮区 */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.6);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 4px 16px rgba(79, 172, 254, 0.4);
}

.btn-secondary:hover {
    box-shadow: 0 6px 24px rgba(79, 172, 254, 0.6);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1.25rem;
}

.btn-text {
    position: relative;
    z-index: 1;
}

/* 提示信息 */
.info-tips {
    background: var(--bg-tertiary);
    border-left: 4px solid var(--accent-purple);
    border-radius: var(--radius-sm);
    padding: 1rem 1.5rem;
}

.info-tips p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.info-tips ul {
    list-style: none;
    padding: 0;
}

.info-tips li {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.info-tips li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent-purple);
    font-weight: bold;
}

/* 输出区域 */
.output-area {
    flex: 1;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    overflow-y: auto;
    min-height: 400px;
}

/* 占位符样式 */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 8px rgba(102, 126, 234, 0.3));
}

.placeholder h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.placeholder p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.feature-icon {
    color: var(--accent-green);
    font-weight: bold;
}

/* Markdown 渲染样式 */
.markdown-content {
    color: var(--text-primary);
    line-height: 1.8;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin: 1.5rem 0 1rem;
    color: var(--text-primary);
}

.markdown-content h1 {
    font-size: 1.75rem;
    border-bottom: 2px solid var(--accent-purple);
    padding-bottom: 0.5rem;
}

.markdown-content h2 {
    font-size: 1.5rem;
    color: var(--accent-purple);
}

.markdown-content h3 {
    font-size: 1.25rem;
}

.markdown-content p {
    margin: 1rem 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.markdown-content li {
    margin: 0.5rem 0;
}

.markdown-content code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--accent-pink);
}

.markdown-content pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1rem 0;
}

.markdown-content blockquote {
    border-left: 4px solid var(--accent-purple);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-content strong {
    color: var(--accent-purple);
    font-weight: 600;
}

/* 加载动画覆盖层 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 26, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
}

.loading-content {
    text-align: center;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 500;
}

/* 滚动条样式 */
.output-area::-webkit-scrollbar,
.script-textarea::-webkit-scrollbar {
    width: 8px;
}

.output-area::-webkit-scrollbar-track,
.script-textarea::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.output-area::-webkit-scrollbar-thumb,
.script-textarea::-webkit-scrollbar-thumb {
    background: var(--accent-purple);
    border-radius: 4px;
}

.output-area::-webkit-scrollbar-thumb:hover,
.script-textarea::-webkit-scrollbar-thumb:hover {
    background: var(--accent-pink);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .input-section,
    .output-section {
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .logo-text h1 {
        font-size: 1.5rem;
    }

    .action-buttons {
        flex-direction: column;
    }
}

/* 字数限制控件 */
.word-limit-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.word-limit-section label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.word-limit-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-limit {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.btn-limit:hover {
    border-color: var(--accent-purple);
    background: var(--accent-purple);
    color: white;
}

.word-limit-section input[type="number"] {
    width: 80px;
    height: 36px;
    text-align: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.word-limit-section input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.word-limit-unit {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 全宽按钮 */
.btn-full {
    width: 100%;
}

/* 新剧本展示区 */
.new-script-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 2px solid var(--accent-green);
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.new-script-section .section-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.new-script-section h3 {
    font-size: 1.1rem;
    color: var(--accent-green);
}

.btn-copy-new {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--gradient-accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-copy-new:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.new-script-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.script-text {
    color: var(--text-primary);
    line-height: 1.9;
    font-size: 1rem;
    white-space: pre-wrap;
}

/* 隐藏 number input 的箭头 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* 结果区域通用样式 */
.result-section {
    margin-top: 1rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    animation: slideIn 0.4s ease-out;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.result-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-purple);
    margin: 0;
}

.result-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.result-content.no-scroll {
    max-height: none;
    overflow: visible;
}

.script-text-area {
    line-height: 1.9;
}

/* 操作按钮组 */
.action-buttons-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.btn-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--gradient-accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.btn-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Markdown 表格样式 */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.markdown-content th {
    background: var(--bg-tertiary);
    color: var(--accent-purple);
    font-weight: 600;
}

.markdown-content tr:nth-child(even) {
    background: rgba(102, 126, 234, 0.05);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }

    .header {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .logo-icon {
        font-size: 2rem;
    }

    .logo-text h1 {
        font-size: 1.25rem;
    }

    .logo-text p {
        font-size: 0.75rem;
    }

    .input-section,
    .output-section {
        padding: 1rem;
    }

    .section-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .section-header h2 {
        font-size: 1rem;
    }

    .compact-textarea {
        height: 120px;
        min-height: 120px;
        max-height: 120px;
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .word-limit-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .btn {
        padding: 0.875rem 1rem;
    }

    .result-section {
        padding: 1rem;
    }

    .result-content {
        padding: 0.75rem;
        max-height: 280px;
    }

    .placeholder-icon {
        font-size: 2.5rem;
    }

    .placeholder h3 {
        font-size: 1.1rem;
    }

    .placeholder p {
        font-size: 0.875rem;
    }
}

/* 小屏手机适配 */
@media (max-width: 480px) {
    .header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .word-limit-controls {
        width: 100%;
        justify-content: center;
    }

    .btn-copy-new {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* 导出模式样式（图片/PDF导出时使用白色背景） */
.export-mode {
    background: #ffffff !important;
    color: #1a1a1a !important;
}

.export-mode .header {
    background: #f8f9fa !important;
    border-color: #dee2e6 !important;
}

.export-mode .logo-text h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.export-mode .logo-text p {
    color: #666 !important;
}

.export-mode .input-section,
.export-mode .output-section,
.export-mode .result-section {
    background: #f8f9fa !important;
    border-color: #dee2e6 !important;
}

.export-mode .result-content {
    background: #ffffff !important;
    border: 1px solid #dee2e6 !important;
}

.export-mode .markdown-content,
.export-mode .script-text,
.export-mode .result-header h3,
.export-mode .section-header h2 {
    color: #1a1a1a !important;
}

.export-mode .markdown-content h1,
.export-mode .markdown-content h2,
.export-mode .markdown-content h3 {
    color: #333 !important;
}

.export-mode .markdown-content th {
    background: #e9ecef !important;
    color: #333 !important;
}

.export-mode .markdown-content td {
    border-color: #dee2e6 !important;
    color: #1a1a1a !important;
}

.export-mode .action-buttons-group {
    display: none !important;
}

.export-mode .script-textarea {
    background: #fff !important;
    color: #1a1a1a !important;
    border-color: #dee2e6 !important;
}

.export-mode .status-indicator {
    background: #e9ecef !important;
    border-color: #dee2e6 !important;
}

.export-mode .status-text {
    color: #333 !important;
}

/* 原始剧本字数显示 */
.input-word-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: -5px 0 15px 5px;
    opacity: 0.8;
}