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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

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

.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.main-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    margin-bottom: 30px;
}

.input-section {
    margin-bottom: 30px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.url-input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s;
    resize: vertical;
    min-height: calc(1.5em * 3 + 30px);
    height: calc(1.5em * 3 + 30px);
    line-height: 1.5;
    font-family: inherit;
    overflow-y: auto;
    box-sizing: border-box;
}

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

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

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

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-small {
    padding: 10px 20px;
    font-size: 14px;
    white-space: nowrap;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-direction: column;
    align-items: stretch;
}

.button-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.button-group .btn {
    flex: 0 0 auto;
    min-width: 120px;
    white-space: nowrap;
}

.btn-paste {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

.btn-paste:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.btn-clear {
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%);
    color: white;
}

.btn-clear:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.3);
}

.platform-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.platform-tag {
    padding: 8px 16px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 14px;
    color: #666;
}

.platform-tag.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.loading.active {
    display: block;
}

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

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

.result-section {
    display: none;
    margin-top: 30px;
}

.result-section.active {
    display: block;
}

.video-preview {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.video-preview video {
    width: 100%;
    height: auto;
    display: block;
}

.download-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 20px auto;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s;
}

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

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.feature-card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.feature-card h3 {
    margin-bottom: 10px;
    color: #333;
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
    display: none;
    white-space: pre-wrap; /* 保留換行符 */
    word-wrap: break-word; /* 長單詞自動換行 */
    line-height: 1.6;
}

.error-message.active {
    display: block;
}

.success-message {
    background: #efe;
    color: #3c3;
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
    display: none;
}

.success-message.active {
    display: block;
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .input-group {
        flex-direction: column;
    }

    .main-card {
        padding: 20px;
    }

    .button-group {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
    }

    .button-group .btn {
        flex: 1;
        min-width: 100px;
    }

    .url-input {
        width: 100%;
    }
}

.video-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #e0e0e0;
}

.video-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.video-info-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
}

.btn-copy-info {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-copy-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

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

.video-info-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.info-item strong {
    color: #667eea;
    font-size: 14px;
}

.btn-copy-item {
    padding: 5px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-copy-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

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

.info-item span {
    color: #555;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

@media (max-width: 768px) {
    .video-info-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .info-item-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .btn-copy-item {
        flex: 1;
        min-width: 80px;
    }
}

.quality-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.quality-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.quality-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#qualitySelector {
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

#qualitySelector h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

#qualityButtons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

