/* Guide Trigger Button */
.guide-trigger-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card-subtle);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: 20px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.guide-btn:hover {
    border-color: var(--primary-color);
    background: var(--bg-card);
    transform: translateY(-1px);
}

/* Modal Backdrop - Uses inset: 0 and 100dvh for mobile address bar resilience */
.modal-backdrop {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

/* Modal Card Container */
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 620px;
    max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth momentum scroll on iOS */
    padding: 32px;
    position: relative;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    color: var(--text-main);
    box-sizing: border-box;
}

/* Close Button */
.modal-close {
    position: absolute;
    top: 18px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--primary-color);
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--text-main);
    padding-right: 30px;
    /* Leave space for close button */
}

.modal-subtitle {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Step List Styling */
.guide-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.guide-step {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px 18px;
    box-sizing: border-box;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 1rem;
    color: var(--text-main);
}

.step-number {
    width: 26px;
    height: 26px;
    background: var(--primary-color);
    color: #ffffff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.guide-step p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.6;
    word-break: break-word;
}

.guide-step code {
    background: var(--bg-body);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    word-break: break-all;
}

.step-sublist {
    margin: 8px 0 0 0;
    padding-left: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.65;
}

.step-sublist li {
    margin-bottom: 6px;
}

.code-callout {
    background: var(--bg-body);
    border-left: 3px solid var(--primary-color);
    padding: 8px 12px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--primary-color);
    margin: 10px 0;
    border-radius: 0 6px 6px 0;
    word-break: break-all;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.modal-action-btn {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

/* Mobile Specific Tweaks (Under 640px Viewports) */
@media (max-width: 640px) {
    .modal-backdrop {
        padding: 12px;
        align-items: flex-start;
        /* Align top on mobile so header is never clipped */
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .modal-card {
        padding: 20px 16px;
        max-height: calc(100dvh - 24px);
        /* Full visible screen height minus padding */
        border-radius: 12px;
    }

    .modal-title {
        font-size: 1.2rem;
    }

    .modal-close {
        top: 14px;
        right: 14px;
        font-size: 1.6rem;
    }

    .step-sublist {
        padding-left: 14px;
    }

    .modal-action-btn {
        width: 100%;
        /* Full width action button on phone screens */
    }
}