/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== CSS VARIABLES ===== */
:root {
    /* Colors - Modern Design System */
    --color-primary: #000000;
    --color-primary-light: #1a1a1a;
    --color-secondary: #ffffff;
    --color-accent: #6366f1;
    --color-accent-hover: #4f46e5;
    --color-accent-light: rgba(99, 102, 241, 0.1);
    
    --color-text-primary: #000000;
    --color-text-secondary: #6b7280;
    --color-text-tertiary: #9ca3af;
    --color-text-inverse: #ffffff;
    
    --color-bg-primary: #ffffff;
    --color-bg-secondary: #f9fafb;
    --color-bg-tertiary: #f3f4f6;
    
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    --color-border-focus: #6366f1;
    
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    
    /* Typography - SF Pro Display + Noto Sans SC */
    --font-family-primary: 'SF Pro Display', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-family-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    
    /* Font Sizes - Perfect Scale */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */
    --text-4xl: 2.25rem;   /* 36px */
    --text-5xl: 3rem;      /* 48px */
    --text-6xl: 3.75rem;   /* 60px */
    
    /* Font Weights */
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-extrabold: 800;
    
    /* Spacing - 8pt Grid System */
    --space-1: 0.125rem;   /* 2px */
    --space-2: 0.25rem;    /* 4px */
    --space-3: 0.375rem;   /* 6px */
    --space-4: 0.5rem;     /* 8px */
    --space-6: 0.75rem;    /* 12px */
    --space-8: 1rem;       /* 16px */
    --space-10: 1.25rem;   /* 20px */
    --space-12: 1.5rem;    /* 24px */
    --space-16: 2rem;      /* 32px */
    --space-20: 2.5rem;    /* 40px */
    --space-24: 3rem;      /* 48px */
    --space-32: 4rem;      /* 64px */
    --space-40: 5rem;      /* 80px */
    --space-48: 6rem;      /* 96px */
    --space-64: 8rem;      /* 128px */
    
    /* Border Radius */
    --radius-sm: 0.25rem;  /* 4px */
    --radius-md: 0.5rem;   /* 8px */
    --radius-lg: 0.75rem;  /* 12px */
    --radius-xl: 1rem;     /* 16px */
    --radius-2xl: 1.5rem;  /* 24px */
    --radius-full: 9999px;
    
    /* Shadows - Layered Design */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Transitions - Smooth & Natural */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-Index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal: 1040;
    --z-popover: 1050;
    --z-tooltip: 1060;
    --z-toast: 1070;
}

/* ===== BASE STYLES ===== */
html {
    font-size: 16px;
    line-height: 1.5;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family-primary);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: 1.6;
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ===== BACKGROUND ELEMENTS ===== */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.02;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.1) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: -2;
}

.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ===== APP LAYOUT ===== */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 896px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    position: relative;
}

/* ===== HERO SECTION ===== */
.hero {
    padding: var(--space-32) 0 var(--space-24);
    text-align: center;
    position: relative;
}

.hero-content {
    max-width: 640px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-6);
    transition: var(--transition-base);
}

.hero-badge:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.badge-icon {
    font-size: var(--text-base);
}

.hero-title {
    font-size: clamp(var(--text-4xl), 8vw, var(--text-6xl));
    font-weight: var(--font-extrabold);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-6);
}

.title-line {
    display: block;
}

.title-highlight {
    background: linear-gradient(135deg, var(--color-accent) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: var(--text-lg);
    font-weight: var(--font-normal);
    color: var(--color-text-secondary);
    line-height: 1.6;
    max-width: 480px;
    margin: 0 auto;
}

/* ===== MAIN CONTENT ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-24);
    padding-bottom: var(--space-32);
}

/* ===== PANELS ===== */
.creation-panel,
.story-panel {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2xl);
    padding: var(--space-24);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.creation-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
    opacity: 0.5;
}

.panel-header {
    margin-bottom: var(--space-20);
}

.story-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-16);
}

.header-left {
    flex: 1;
}

.panel-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}

.panel-subtitle {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* ===== FORM STYLES ===== */
.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-20);
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}

.label-text {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.label-required {
    color: var(--color-error);
    font-size: var(--text-xs);
    margin-left: var(--space-1);
}

.label-optional {
    font-size: var(--text-xs);
    font-weight: var(--font-normal);
    color: var(--color-text-tertiary);
    background: var(--color-bg-tertiary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

/* ===== OPTION GRID ===== */
.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-3);
}

.option-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4) var(--space-6);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-secondary);
    text-align: center;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
    position: relative;
    min-height: 44px;
}

.option-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: var(--color-accent);
    opacity: 0;
    transition: var(--transition-fast);
}

.option-item:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.option-item.selected {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-inverse);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.option-item:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* ===== TEXTAREA ===== */
.textarea {
    padding: var(--space-4);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text-primary);
    resize: vertical;
    transition: var(--transition-fast);
    min-height: 120px;
}

.textarea:focus {
    outline: none;
    background: var(--color-bg-primary);
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-accent-light);
}

.textarea::placeholder {
    color: var(--color-text-tertiary);
}

/* ===== FORM ACTIONS ===== */
.form-actions {
    display: flex;
    justify-content: center;
    padding-top: var(--space-8);
}

/* ===== GENERATE BUTTON ===== */
.generate-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4) var(--space-8);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border: none;
    border-radius: var(--radius-xl);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: var(--transition-base);
    overflow: hidden;
    min-height: 56px;
    min-width: 160px;
}

.generate-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--color-accent), #8b5cf6);
    opacity: 0;
    transition: var(--transition-base);
}

.generate-button:hover::before {
    opacity: 1;
}

.generate-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.generate-button:active {
    transform: translateY(-1px);
}

.generate-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.generate-button.loading .button-icon {
    animation: loading-spin 1s linear infinite;
}

@keyframes loading-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.button-content {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    position: relative;
    z-index: 1;
}

.button-icon {
    font-size: var(--text-lg);
    transition: var(--transition-fast);
}

.generate-button:hover .button-icon {
    transform: scale(1.1);
}

.button-glow {
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--color-accent), #8b5cf6);
    border-radius: var(--radius-xl);
    opacity: 0;
    filter: blur(8px);
    transition: var(--transition-base);
    z-index: -1;
}

.generate-button:hover .button-glow {
    opacity: 0.3;
}

/* ===== STORY ACTIONS ===== */
.story-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.action-btn:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-inverse);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn.secondary {
    background: var(--color-bg-tertiary);
}

.action-btn.secondary:hover {
    background: var(--color-text-secondary);
}

/* Tooltip */
.action-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-2) var(--space-3);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
    z-index: var(--z-tooltip);
}

.action-btn:hover::after {
    opacity: 1;
}

/* ===== STORY CONTENT ===== */
.story-container {
    position: relative;
}

.story-content {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    font-size: var(--text-base);
    line-height: 1.8;
    color: var(--color-text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 200px;
    max-height: none;
    font-family: var(--font-family-primary);
    transition: var(--transition-base);
    
    /* 自适应高度 - 内容越长，容器自动扩展 */
    resize: none;
    overflow: visible;
    
    /* 性能优化 */
    contain: layout style;
    will-change: scroll-position;
}

.story-content:not(:empty) {
    min-height: auto;
    border-color: var(--color-border);
    background: var(--color-bg-primary);
    box-shadow: var(--shadow-sm);
    
    /* 内容较长时的样式优化 */
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* 长内容时的渐变遮罩效果 */
.story-content:not(:empty)::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(transparent, var(--color-bg-primary));
    pointer-events: none;
    opacity: 0;
    transition: var(--transition-base);
}

.story-content:not(:empty):hover::after {
    opacity: 1;
}

/* ===== LOADING ANIMATION ===== */
.story-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-24) var(--space-8);
    text-align: center;
}

.loading-animation {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
    animation: loading-pulse 1.4s ease-in-out infinite both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.loading-message {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    font-weight: var(--font-medium);
}

/* ===== TYPEWRITER EFFECT ===== */
.typewriter {
    position: relative;
}

.cursor {
    display: inline-block;
    background: var(--color-accent);
    width: 2px;
    height: 1.2em;
    animation: cursor-blink 1s infinite;
    margin-left: 1px;
    vertical-align: baseline;
    /* 性能优化 */
    will-change: opacity;
    transform: translateZ(0); /* 启用硬件加速 */
    backface-visibility: hidden;
}

@keyframes cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 网络质量差时的优化 */
.typewriter.reduced-motion .cursor {
    animation: none;
    opacity: 1;
}



/* ===== MARKDOWN STYLES ===== */
.story-content h1,
.story-content h2,
.story-content h3,
.story-content h4,
.story-content h5,
.story-content h6 {
    margin: var(--space-6) 0 var(--space-4);
    font-weight: var(--font-bold);
    line-height: 1.3;
    color: var(--color-text-primary);
}

.story-content h1 { font-size: var(--text-2xl); }
.story-content h2 { font-size: var(--text-xl); }
.story-content h3 { font-size: var(--text-lg); }
.story-content h4 { font-size: var(--text-base); }
.story-content h5 { font-size: var(--text-sm); }
.story-content h6 { font-size: var(--text-xs); }

.story-content p {
    margin: var(--space-4) 0;
    line-height: 1.8;
}

.story-content p:first-child {
    margin-top: 0;
}

.story-content p:last-child {
    margin-bottom: 0;
}

.story-content strong,
.story-content b {
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
}

.story-content em,
.story-content i {
    font-style: italic;
    color: var(--color-text-secondary);
}

.story-content u {
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-underline-offset: 2px;
}

.story-content ul,
.story-content ol {
    margin: var(--space-4) 0;
    padding-left: var(--space-6);
}

.story-content li {
    margin: var(--space-2) 0;
    line-height: 1.6;
}

.story-content blockquote {
    margin: var(--space-6) 0;
    padding: var(--space-4) var(--space-6);
    border-left: 4px solid var(--color-accent);
    background: var(--color-bg-secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--color-text-secondary);
}

.story-content hr {
    margin: var(--space-8) 0;
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

/* 段落间距优化 */
.story-content p + p {
    margin-top: var(--space-6);
}

.story-content br + br {
    display: block;
    margin: var(--space-2) 0;
    content: "";
}

/* ===== ERROR STYLES ===== */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-24) var(--space-8);
    text-align: center;
    min-height: 200px;
}

.error-icon {
    font-size: var(--text-5xl);
    margin-bottom: var(--space-6);
    color: var(--color-error);
    animation: error-shake 0.5s ease-in-out;
}

@keyframes error-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.error-title {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-error);
    margin-bottom: var(--space-4);
}

.error-message {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-8);
    max-width: 400px;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    justify-content: center;
}

.error-btn {
    padding: var(--space-3) var(--space-6);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
    min-height: 40px;
}

.error-btn.primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-inverse);
}

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

.error-btn.primary:hover {
    background: var(--color-accent-hover);
}

/* ===== FOOTER ===== */
.footer {
    padding: var(--space-16) 0;
    text-align: center;
    border-top: 1px solid var(--color-border-light);
    margin-top: var(--space-24);
}

.footer p {
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .app {
        padding: 0 var(--space-4);
    }
    
    .hero {
        padding: var(--space-24) 0 var(--space-16);
    }
    
    .hero-title {
        font-size: clamp(var(--text-3xl), 10vw, var(--text-5xl));
    }
    
    .hero-subtitle {
        font-size: var(--text-base);
    }
    
    .creation-panel,
    .story-panel {
        padding: var(--space-16);
    }
    
    .panel-title {
        font-size: var(--text-xl);
    }
    
    .story-panel .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-4);
    }
    
    .story-actions {
        align-self: stretch;
        justify-content: center;
    }
    
    .option-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: var(--space-2);
    }
    
    .option-item {
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-xs);
        min-height: 40px;
    }
    
    .generate-button {
        min-width: 140px;
        min-height: 48px;
    }
    
    .story-content {
        padding: var(--space-6);
        font-size: var(--text-sm);
    }
}

@media (max-width: 480px) {
    .app {
        padding: 0 var(--space-3);
    }
    
    .hero {
        padding: var(--space-20) 0 var(--space-12);
    }
    
    .creation-panel,
    .story-panel {
        padding: var(--space-12);
        border-radius: var(--radius-xl);
    }
    
    .main {
        gap: var(--space-16);
    }
    
    .form {
        gap: var(--space-16);
    }
    
    .field-group {
        gap: var(--space-3);
    }
    
    .option-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
    
    .textarea {
        min-height: 100px;
        padding: var(--space-3);
    }
    
    .story-content {
        padding: var(--space-4);
    }
    
    .action-btn::after {
        display: none; /* Hide tooltips on mobile */
    }
}

/* ===== ANIMATIONS ===== */
.fade-in {
    animation: fade-in 0.4s ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slide-up 0.4s ease-out;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-tertiary);
}

/* ===== SELECTION ===== */
::selection {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

/* ===== FOCUS VISIBLE ===== */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* ===== NETWORK QUALITY OPTIMIZATIONS ===== */
/* 网络质量差时的优化 */
.network-poor .cursor,
.reduced-motion .cursor {
    animation: none !important;
    opacity: 1;
}

.network-poor .generate-button,
.reduced-motion .generate-button {
    transition: none !important;
}

.network-poor .option-item,
.reduced-motion .option-item {
    transition: none !important;
}

.network-poor .loading-dot,
.reduced-motion .loading-dot {
    animation-duration: 2s !important; /* 减慢动画 */
}

/* 网络质量中等时的优化 */
.network-medium .cursor {
    animation-duration: 1.5s; /* 稍微减慢光标闪烁 */
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 强制降级模式 */
.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

.reduced-motion .cursor {
    animation: none !important;
    opacity: 1 !important;
}