/* CSS变量定义 */
:root {
  --font-scale: 1.0;
}

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

/* 全局样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    font-size: calc(16px * var(--font-scale));
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    text-decoration: none;
}

.chrome-link {
    background: linear-gradient(45deg, #4285f4, #34a853);
    color: white;
    text-decoration: none;
    padding: 0.5rem 2rem;
    border-radius: 50px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(66, 133, 244, 0.3);
    min-width: 250px;
    text-align: center;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.chrome-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(66, 133, 244, 0.4);
}

/* Header Settings Button */
.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.settings-btn {
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.2);
    color: #667eea;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

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

.settings-text {
    font-size: 0.9rem;
}

/* Main Content */
.main {
    padding: 2rem 0;
}

/* Introduction Section */
.intro-section {
    text-align: center;
    margin-bottom: 3rem;
}

.intro-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.intro-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.intro-description {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 2rem;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    white-space: pre-wrap;
}

.intro-features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.feature-icon {
    font-size: 1.2rem;
}

.feature-text {
    font-weight: 500;
    color: #667eea;
}

/* Input Section */
.input-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.input-container {
    margin-bottom: 2rem;
}

.input-label {
    display: block;
    font-size: 1.1rem;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.video-input {
    width: 100%;
    padding: 1rem 3rem 1rem 1rem;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.video-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.video-input.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.clear-btn {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #f5f5f5;
    color: #666;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    min-width: 140px;
    justify-content: center;
}

.action-btn:disabled {
    background: #e1e8ed;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
}

.action-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4);
}

.action-btn.loading {
    pointer-events: none;
}

.action-btn.loading .btn-text {
    display: none;
}

.action-btn.loading .btn-loading {
    display: inline-block !important;
}

.btn-loading {
    animation: spin 1s linear infinite;
}

/* Results Section */
.results-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f2f5;
}

.results-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #2c3e50;
}

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

.copy-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.copy-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.copy-btn.copied {
    background: #6c757d;
}

.close-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.results-content {
    max-height: 500px;
    overflow-y: auto;
    /* 防止滚动事件冒泡到父元素 */
    overscroll-behavior: contain;
    /* 防止滚动链接 */
    scroll-behavior: smooth;
    /* 确保滚动容器独立 */
    isolation: isolate;
}

.results-text {
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    /* 确保文本内容不会影响父容器的滚动 */
    overflow-wrap: break-word;
    /* 防止文本选择时的意外滚动 */
    user-select: text;
}

/* Loading Section */
.loading-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loading-text {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1.5rem;
}

.cancel-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* Error Section */
.error-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-text {
    font-size: 1.1rem;
    color: #dc3545;
    margin-bottom: 1.5rem;
}

.retry-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    margin-top: 2rem;
    padding: 2rem 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    color: #666;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.footer-links a:hover {
    color: #5a6fd8;
}

/* 动画 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Settings Section */
.settings-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e1e8ed;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.setting-text {
    font-size: 0.9rem;
    color: #666;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header .container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .chrome-link {
        min-width: 200px;
        padding: 0.75rem 2rem;
        font-size: 1rem;
    }
    
    .intro-title {
        font-size: 2rem;
    }
    
    .intro-content {
        padding: 2rem 1.5rem;
    }
    
    .intro-features {
        flex-direction: column;
        align-items: center;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .action-btn {
        min-width: 200px;
    }
    
    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        text-align: center;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .intro-title {
        font-size: 1.8rem;
    }
    
    .intro-description {
        font-size: 1rem;
    }
    
    .input-section,
    .results-section,
    .loading-section,
    .error-section {
        padding: 1.5rem 1rem;
    }
}

/* 优化滚动条 */
.results-content::-webkit-scrollbar {
    width: 6px;
}

.results-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.results-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.results-content::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

/* 打字机效果 */
.typewriter {
    overflow: hidden;
    border-right: 2px solid #667eea;
    animation: typing 0.05s steps(1) forwards, blink 1s infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%, 50% { border-color: #667eea; }
    51%, 100% { border-color: transparent; }
} 