:root {
    --primary: #1a56db;
    --primary-hover: #1e429f;
    --primary-light: rgba(26, 86, 219, 0.08);
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --radius: 12px;
    --radius-sm: 8px;
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.1);
    --font-stack: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --surface: #1e293b;
        --surface-2: #0f172a;
        --surface-3: #334155;
        --text: #f8fafc;
        --text-muted: #94a3b8;
        --border: #334155;
        --border-hover: #475569;
    }
}

:root[data-theme="dark"] {
    --surface: #1e293b;
    --surface-2: #0f172a;
    --surface-3: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-hover: #475569;
}

:root[data-theme="light"] {
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

body {
    font-family: var(--font-stack);
    background: var(--surface-2);
    color: var(--text);
    line-height: 1.5;
    padding: clamp(12px, 3vw, 24px) clamp(10px, 3vw, 16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

.onboard-wrapper {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 3vw, 20px);
    min-width: 0;
}

.onboard-top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}

.onboard-header {
    text-align: center;
    padding: 4px 0 8px;
}

.brand-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: clamp(0.72rem, 2.2vw, 0.82rem);
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 0.02em;
    max-width: 100%;
    text-align: center;
}

.onboard-header h1 {
    font-size: clamp(1.35rem, 4.5vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
    line-height: 1.25;
}

.onboard-header .subtitle {
    color: var(--text-muted);
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    max-width: 580px;
    margin: 0 auto;
    line-height: 1.45;
}

/* Stepper: Responsive & Adaptive */
.stepper-track {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.stepper-track::-webkit-scrollbar {
    display: none;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.step-item.active {
    color: var(--primary);
    font-weight: 700;
}

.step-item.completed {
    color: var(--success);
}

.step-item.completed .step-number {
    background: var(--success);
    color: #ffffff;
}

.step-number {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.step-item.active .step-number {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.step-text {
    font-size: 0.82rem;
    white-space: nowrap;
}

.step-line {
    flex: 1;
    min-width: 14px;
    height: 2px;
    background: var(--border);
}

.step-item.completed + .step-line {
    background: var(--success);
}

/* Card Form */
.onboard-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(18px, 4vw, 30px) clamp(14px, 3.5vw, 28px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    min-width: 0;
}

.step-section {
    display: none;
}

.step-section.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

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

.section-title {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.section-title h2 {
    font-size: clamp(1.1rem, 3.5vw, 1.25rem);
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
}

.section-title p {
    color: var(--text-muted);
    font-size: clamp(0.82rem, 2.3vw, 0.88rem);
    line-height: 1.45;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text);
}

.req {
    color: #ef4444;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-with-prefix {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    overflow: hidden;
    min-height: 44px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-with-prefix:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-with-prefix .prefix {
    padding: 0 12px;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    user-select: none;
}

.input-with-prefix input {
    border: none;
    border-radius: 0;
    background: transparent;
    flex: 1;
    min-width: 0;
    min-height: 42px;
}

.input-with-prefix input:focus {
    box-shadow: none;
}

.helper-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.helper-text code {
    background: var(--surface-3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    word-break: break-all;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border);
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
}

.color-code {
    font-family: monospace;
    font-size: 0.88rem;
    font-weight: 600;
}

/* Dropzone */
.logo-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: clamp(16px, 3vw, 24px);
    text-align: center;
    background: var(--surface-2);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-dropzone:hover,
.logo-dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone-icon {
    width: 34px;
    height: 34px;
    color: var(--primary);
    margin: 0 auto 6px;
}

.dropzone-content p {
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.dropzone-content span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dropzone-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.dropzone-preview img {
    max-height: 60px;
    max-width: 180px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    background: #ffffff;
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.preview-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-remove {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    padding: 6px 12px;
    min-height: 32px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

/* GPS Button */
.btn-gps {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(26, 86, 219, 0.25);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    text-align: center;
}

.btn-gps:hover {
    background: rgba(26, 86, 219, 0.14);
}

.btn-gps:active {
    transform: scale(0.99);
}

.gps-status-msg {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
    word-break: break-word;
}

/* Slider */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.radius-value {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    accent-color: var(--primary);
    cursor: pointer;
    min-height: 36px;
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
    flex-wrap: wrap;
    gap: 4px;
}

/* Step Actions */
.step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.step-actions.centered {
    justify-content: center;
    gap: 12px;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    min-height: 46px;
    padding: 11px 22px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

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

.btn-primary:active {
    transform: scale(0.99);
}

.btn-secondary {
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 46px;
    padding: 11px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-secondary:active {
    transform: scale(0.99);
}

/* Step 4 Success */
.success-banner {
    text-align: center;
    padding: 6px 0 20px;
}

.success-icon {
    margin-bottom: 10px;
}

.success-banner h2 {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--success);
}

.links-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    gap: 12px;
}

.link-info {
    overflow: hidden;
    min-width: 0;
    flex: 1;
}

.link-tag {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
    margin-bottom: 2px;
}

.link-url {
    font-family: monospace;
    font-size: 0.82rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
}

.link-buttons {
    display: grid;
    grid-template-columns: 105px 125px;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.btn-copy,
.btn-open {
    height: 38px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.15s ease;
    width: 100%;
}

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

.btn-copy:hover {
    background: var(--surface-3);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-open {
    background: var(--primary);
    color: #ffffff;
    border: 1px solid var(--primary);
}

.btn-open:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.slug-status,
.email-status {
    transition: all 0.2s ease;
}
.slug-status.available,
.email-status.valid {
    color: #10b981;
}
.slug-status.unavailable,
.email-status.invalid {
    color: #ef4444;
}
.slug-status.checking {
    color: #3b82f6;
}

/* Mobile & Tablet Breakpoints */
@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .stepper-track {
        padding: 8px 10px;
        gap: 4px;
    }

    .step-item {
        gap: 4px;
    }

    .step-text {
        font-size: 0.74rem;
        display: none; /* Hide labels, keep numbers on compact screens */
    }

    .step-item.active .step-text {
        display: inline; /* Show only active step label */
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .step-number {
        width: 26px;
        height: 26px;
        min-width: 26px;
        font-size: 0.78rem;
    }

    .step-line {
        min-width: 8px;
        margin: 0 4px;
    }

    .link-card {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .link-url {
        white-space: normal;
        word-break: break-all;
    }

    .link-buttons {
        width: 100%;
        grid-template-columns: 1fr 1fr;
    }

    .step-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .step-actions button,
    .step-actions a {
        width: 100%;
    }

    .step-actions.centered {
        flex-direction: column;
    }
}

@media (max-width: 380px) {
    body {
        padding: 8px 6px;
    }

    .onboard-card {
        padding: 14px 10px;
        border-radius: 10px;
    }

    .brand-pill {
        font-size: 0.68rem;
        padding: 4px 10px;
    }

    .onboard-header h1 {
        font-size: 1.25rem;
    }

    .input-with-prefix .prefix {
        padding: 0 8px;
        font-size: 0.8rem;
    }

    .link-buttons {
        grid-template-columns: 1fr;
    }
}
