.templates-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 160;
    display: none;
    align-items: center;
    justify-content: center;
}

.templates-overlay.open {
    display: flex;
    animation: fadeIn 0.15s ease;
}

.templates-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.2s ease;
}

.templates-header {
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-shrink: 0;
}

.templates-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 7px;
}

.templates-title svg {
    width: 17px;
    height: 17px;
    stroke-width: 1.8;
}

.templates-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    display: block;
    margin-top: 2px;
}

.templates-grid {
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
}

.template-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.template-card:hover {
    border-color: var(--accent-purple);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124, 108, 255, 0.1);
}

.template-card.selected {
    border-color: var(--accent-purple);
    background: rgba(124, 108, 255, 0.08);
    box-shadow: 0 0 0 1px var(--accent-purple), 0 4px 16px rgba(124, 108, 255, 0.15);
}

.template-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.15s;
    color: transparent;
}

.template-check.checked {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
    color: #fff;
    box-shadow: 0 0 8px var(--accent-purple-glow);
}

.template-emoji {
    font-size: 22px;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-active);
    border-radius: var(--radius-sm);
}

.template-emoji svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent-purple);
    stroke-width: 1.8;
}

.template-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.template-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.template-desc {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.template-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--accent-purple);
    font-family: var(--mono);
    margin-top: 4px;
}

.templates-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-radius: 0 0 14px 14px;
}

.templates-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.templates-note {
    font-size: 11px;
    color: var(--text-tertiary);
    font-style: italic;
}

.templates-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.templates-detail {
    font-size: 11px;
    color: var(--accent-purple);
    font-family: var(--mono);
}

.templates-apply-btn {
    flex-shrink: 0;
    min-width: 140px;
    justify-content: center;
}

.templates-apply-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}


/* ─── WELCOME SCREEN ─── */
.welcome-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-base);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.welcome-overlay.open {
    display: flex;
    animation: welcomeFadeIn 0.5s ease;
}

.welcome-overlay.closing {
    animation: welcomeFadeOut 0.4s ease forwards;
}

@keyframes welcomeFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes welcomeFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.welcome-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 380px;
    width: 100%;
    padding: 48px 36px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5), 0 0 80px var(--accent-purple-glow);
    animation: cardFloat 0.6s ease;
}

@keyframes cardFloat {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.welcome-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.welcome-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-purple), #5b4de0);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 0 30px var(--accent-purple-glow);
}

.welcome-logo-name {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.welcome-heading {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    text-align: center;
}

.welcome-sub {
    font-size: 13.5px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.6;
    margin-top: -8px;
}

.welcome-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.welcome-input {
    text-align: center;
    font-size: 15px !important;
    padding: 12px 16px !important;
}

.welcome-btn {
    width: 100%;
    padding: 12px 20px !important;
    font-size: 14px !important;
    justify-content: center;
    margin-top: 4px;
}

.welcome-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--mono);
}

