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

:root {
    --bg-primary: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --text-primary: #e8e8f0;
    --text-secondary: #9090a8;
    --text-muted: #606078;
    --accent: #6c5ce7;
    --accent-hover: #7c6cf7;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --success: #00d68f;
    --error: #ff6b6b;
    --border: #2a2a45;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== Container ===== */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

/* ===== Header ===== */
header {
    text-align: center;
    margin-bottom: 32px;
}

header h1 {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe, #6c5ce7);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== Card ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    transition: all var(--transition);
}

/* ===== Input Card ===== */
.input-card {
    position: relative;
    overflow: visible;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    transition: border-color var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 12px 16px;
    font-family: inherit;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-wrapper button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.input-wrapper button:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.input-wrapper button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 14px;
}

/* ===== Platform Detect ===== */
.platform-detect {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 13px;
}

.detect-label {
    color: var(--text-muted);
}

.detect-value {
    color: var(--accent);
    font-weight: 600;
}

.detect-value.waiting {
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== Supported Platforms ===== */
.supported-platforms {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.platform-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.platform-tag.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(108, 92, 231, 0.1);
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 40px 24px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 20px;
}

.loading-steps {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 14px;
    background: var(--bg-card-hover);
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.step.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.1);
}

.step.done {
    color: var(--success);
    border-color: var(--success);
    background: rgba(0, 214, 143, 0.1);
}

/* ===== Error Card ===== */
.error-card {
    display: flex;
    align-items: center;
    gap: 12px;
    border-color: rgba(255, 107, 107, 0.3);
    background: rgba(255, 107, 107, 0.05);
}

.error-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.error-card p {
    color: var(--error);
    font-size: 14px;
}

/* ===== Result Card ===== */
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.result-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.result-platform {
    padding: 4px 12px;
    background: var(--accent-glow);
    color: var(--accent);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.video-preview {
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    margin-bottom: 16px;
    max-height: 360px;
}

.video-preview video {
    width: 100%;
    display: block;
    max-height: 360px;
}

.video-info {
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-muted);
    width: 90px;
    flex-shrink: 0;
}

.info-value {
    color: var(--text-primary);
    word-break: break-all;
}

.info-value.url-text {
    color: var(--accent);
    font-size: 12px;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.btn-primary, .btn-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ===== History Card ===== */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.history-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-text:hover {
    color: var(--error);
    background: rgba(255, 107, 107, 0.1);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px 0;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-card-hover);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.history-item:hover {
    border-color: var(--accent);
}

.history-item-platform {
    padding: 2px 8px;
    background: var(--accent-glow);
    color: var(--accent);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.history-item-title {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 12px;
}

/* ===== Utility ===== */
.hidden {
    display: none !important;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    z-index: 1000;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .container {
        padding: 20px 16px 60px;
    }

    header h1 {
        font-size: 28px;
    }

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

    .input-wrapper button {
        width: 100%;
        justify-content: center;
    }

    .result-actions {
        flex-direction: column;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .loading-steps {
        flex-direction: column;
        align-items: center;
    }
}