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

        :root {
            --bg: #0a0a0f;
            --surface: #12121a;
            --surface-2: #1a1a26;
            --border: #2a2a3a;
            --border-hover: #3a3a52;
            --accent: #6366f1;
            --accent-hover: #818cf8;
            --accent-glow: rgba(99, 102, 241, 0.15);
            --success: #22c55e;
            --success-glow: rgba(34, 197, 94, 0.15);
            --danger: #ef4444;
            --danger-glow: rgba(239, 68, 68, 0.15);
            --warning: #f59e0b;
            --text: #e4e4eb;
            --text-dim: #8888a0;
            --text-muted: #555566;
            --radius: 12px;
            --radius-sm: 8px;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
            background: var(--bg);
            color: var(--text);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 2rem 1rem;
            line-height: 1.6;
        }

        .container {
            width: 100%;
            max-width: 680px;
        }

        header {
            text-align: center;
            margin-bottom: 2.5rem;
        }

        .logo {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 56px;
            height: 56px;
            background: linear-gradient(135deg, var(--accent), #a78bfa);
            border-radius: 16px;
            margin-bottom: 1rem;
        }

        .logo svg { width: 28px; height: 28px; }

        h1 {
            font-size: 1.75rem;
            font-weight: 700;
            letter-spacing: -0.025em;
            margin-bottom: 0.35rem;
        }

        header p {
            color: var(--text-dim);
            font-size: 0.9rem;
        }

        .card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 1.5rem;
            margin-bottom: 1rem;
            transition: border-color 0.2s;
        }

        .card:hover { border-color: var(--border-hover); }

        .card-title {
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-dim);
            margin-bottom: 1rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .card-title .dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--accent);
        }

        .step-list {
            list-style: none;
            counter-reset: steps;
        }

        .step-list li {
            counter-increment: steps;
            position: relative;
            padding-left: 2.25rem;
            padding-bottom: 0.85rem;
            font-size: 0.88rem;
            color: var(--text);
        }

        .step-list li:last-child { padding-bottom: 0; }

        .step-list li::before {
            content: counter(steps);
            position: absolute;
            left: 0;
            top: 1px;
            width: 22px;
            height: 22px;
            background: var(--surface-2);
            border: 1px solid var(--border);
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.7rem;
            font-weight: 700;
            color: var(--accent);
        }

        .step-list li::after {
            content: '';
            position: absolute;
            left: 10px;
            top: 26px;
            bottom: 4px;
            width: 1px;
            background: var(--border);
        }

        .step-list li:last-child::after { display: none; }

        .step-list .highlight {
            color: var(--accent-hover);
            font-weight: 600;
        }

        .step-list .warn {
            color: var(--warning);
            font-weight: 600;
        }

        .callout {
            background: var(--danger-glow);
            border: 1px solid rgba(239, 68, 68, 0.25);
            border-radius: var(--radius-sm);
            padding: 0.75rem 1rem;
            margin-top: 1rem;
            font-size: 0.82rem;
            color: #fca5a5;
            display: flex;
            gap: 0.5rem;
            align-items: flex-start;
        }

        .callout svg { flex-shrink: 0; margin-top: 2px; }

        .file-drop {
            position: relative;
            border: 2px dashed var(--border);
            border-radius: var(--radius);
            padding: 2rem;
            text-align: center;
            cursor: pointer;
            transition: all 0.25s;
            background: var(--surface);
        }

        .file-drop:hover, .file-drop.drag-over {
            border-color: var(--accent);
            background: var(--accent-glow);
        }

        .file-drop.has-file {
            border-color: var(--success);
            background: var(--success-glow);
            border-style: solid;
        }

        .file-drop input {
            position: absolute;
            inset: 0;
            opacity: 0;
            cursor: pointer;
        }

        .file-drop-icon {
            width: 40px;
            height: 40px;
            margin: 0 auto 0.75rem;
            background: var(--surface-2);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--border);
        }

        .file-drop-text {
            font-size: 0.9rem;
            font-weight: 500;
            margin-bottom: 0.25rem;
        }

        .file-drop-hint {
            font-size: 0.78rem;
            color: var(--text-muted);
        }

        .file-info {
            display: none;
            align-items: center;
            gap: 0.75rem;
            justify-content: center;
        }

        .file-info .name {
            font-weight: 600;
            font-size: 0.88rem;
            color: var(--success);
        }

        .file-info .size {
            font-size: 0.78rem;
            color: var(--text-dim);
        }

        .file-info .remove-btn {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 4px;
            border-radius: 4px;
            transition: color 0.15s;
            display: flex;
        }

        .file-info .remove-btn:hover { color: var(--danger); }

        .flash-mode {
            display: none;
            align-items: center;
            gap: 0.5rem;
            margin-top: 0.75rem;
            padding: 0.6rem 0.85rem;
            border-radius: var(--radius-sm);
            font-size: 0.78rem;
        }

        .flash-mode.mode-update {
            display: flex;
            background: var(--accent-glow);
            border: 1px solid rgba(99, 102, 241, 0.25);
            color: var(--accent-hover);
        }

        .flash-mode.mode-full {
            display: flex;
            background: rgba(245, 158, 11, 0.1);
            border: 1px solid rgba(245, 158, 11, 0.25);
            color: #fbbf24;
        }

        .flash-mode .mode-label {
            font-weight: 700;
        }

        .controls {
            display: flex;
            gap: 0.75rem;
            margin-top: 1.25rem;
        }

        .btn {
            flex: 1;
            padding: 0.75rem 1.25rem;
            border-radius: var(--radius-sm);
            border: none;
            font-size: 0.88rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
        }

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

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

        .btn-primary:hover:not(:disabled) {
            background: var(--accent-hover);
            box-shadow: 0 0 20px var(--accent-glow);
        }

        .btn-outline {
            background: transparent;
            color: var(--text);
            border: 1px solid var(--border);
        }

        .btn-outline:hover:not(:disabled) {
            border-color: var(--border-hover);
            background: var(--surface-2);
        }

        .progress-section {
            display: none;
            margin-top: 1rem;
        }

        .progress-bar-track {
            width: 100%;
            height: 6px;
            background: var(--surface-2);
            border-radius: 3px;
            overflow: hidden;
            margin-bottom: 0.5rem;
        }

        .progress-bar-fill {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, var(--accent), #a78bfa);
            border-radius: 3px;
            transition: width 0.3s ease;
        }

        .progress-bar-fill.erase { background: linear-gradient(90deg, var(--danger), #f97316); }
        .progress-bar-fill.done { background: linear-gradient(90deg, var(--success), #4ade80); }

        .progress-text {
            font-size: 0.78rem;
            color: var(--text-dim);
            display: flex;
            justify-content: space-between;
        }

        .console-output {
            background: #08080d;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 1rem;
            margin-top: 1rem;
            font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
            font-size: 0.75rem;
            line-height: 1.7;
            max-height: 260px;
            overflow-y: auto;
            color: var(--text-dim);
            display: none;
            scroll-behavior: smooth;
        }

        .console-output .log-info { color: var(--text-dim); }
        .console-output .log-success { color: var(--success); }
        .console-output .log-error { color: var(--danger); }
        .console-output .log-warn { color: var(--warning); }

        .status-badge {
            display: none;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 0.85rem;
            border-radius: 20px;
            font-size: 0.78rem;
            font-weight: 600;
            margin-top: 1rem;
            justify-content: center;
        }

        .status-badge.connected {
            display: inline-flex;
            background: var(--success-glow);
            color: var(--success);
            border: 1px solid rgba(34, 197, 94, 0.25);
        }

        .status-badge.disconnected {
            display: inline-flex;
            background: var(--surface-2);
            color: var(--text-muted);
            border: 1px solid var(--border);
        }

        .status-badge.error {
            display: inline-flex;
            background: var(--danger-glow);
            color: var(--danger);
            border: 1px solid rgba(239, 68, 68, 0.25);
        }

        .status-badge .pulse {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: currentColor;
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.4; }
        }

        .chip-info {
            display: none;
            gap: 1rem;
            flex-wrap: wrap;
            margin-top: 0.75rem;
        }

        .chip-info .chip-tag {
            background: var(--surface-2);
            border: 1px solid var(--border);
            border-radius: 6px;
            padding: 0.35rem 0.65rem;
            font-size: 0.75rem;
            color: var(--text-dim);
        }

        .chip-info .chip-tag span { color: var(--text); font-weight: 600; }

        .browser-warning {
            display: none;
            background: rgba(245, 158, 11, 0.1);
            border: 1px solid rgba(245, 158, 11, 0.25);
            border-radius: var(--radius);
            padding: 1.25rem;
            text-align: center;
            margin-bottom: 1rem;
            color: #fbbf24;
            font-size: 0.88rem;
        }

        .browser-warning a { color: #fcd34d; }

        footer {
            margin-top: 2.5rem;
            text-align: center;
            color: var(--text-muted);
            font-size: 0.75rem;
        }

        .spinner {
            width: 16px;
            height: 16px;
            border: 2px solid transparent;
            border-top-color: currentColor;
            border-radius: 50%;
            animation: spin 0.6s linear infinite;
            display: none;
        }

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

        @media (max-width: 600px) {
            body { padding: 1rem 0.75rem; }
            h1 { font-size: 1.4rem; }
            .controls { flex-direction: column; }
        }
