/* Combined first-time onboarding + community modal. */
.cwm-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 9999);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vh, 36px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(5px) saturate(0.88);
    -webkit-backdrop-filter: blur(5px) saturate(0.88);
    animation: cwm-backdrop-in 180ms ease-out;
}

.page-content > .cwm-backdrop {
    inset: 0;
}

.cwm-modal {
    position: relative;
    width: min(100%, 900px);
    max-height: calc(100vh - clamp(32px, 8vh, 72px));
    max-height: calc(var(--app-dvh, 100dvh) - clamp(32px, 8dvh, 72px));
    padding: clamp(22px, 3vw, 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    border: 1px solid var(--border-subtle, rgba(15, 23, 42, 0.08));
    border-radius: 22px;
    background: var(--bg-surface, #fff);
    color: var(--text-primary, #1a1a18);
    box-shadow: 0 28px 80px rgba(3, 18, 16, 0.24), 0 6px 22px rgba(3, 18, 16, 0.10);
    animation: cwm-modal-in 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cwm-modal:focus {
    outline: none;
}

.cwm-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-tertiary, #73716b);
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease;
}

.cwm-close:hover {
    background: var(--bg-muted, #f1efe8);
    color: var(--text-primary, #1a1a18);
}

.cwm-modal :where(a, button):focus-visible {
    outline: 3px solid rgba(8, 80, 65, 0.32);
    outline-offset: 2px;
}

.cwm-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 14px;
    max-width: 680px;
    margin: 0 auto 24px;
    padding-right: 34px;
}

.cwm-header__icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #085041, #0f6e56);
    color: #fff;
    box-shadow: 0 10px 24px rgba(8, 80, 65, 0.20);
}

.cwm-eyebrow {
    margin: 1px 0 5px;
    color: var(--brand-primary, #085041);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.cwm-header h2 {
    margin: 0 0 7px;
    color: var(--text-primary, #1a1a18);
    font-size: clamp(20px, 2.5vw, 27px);
    font-weight: 700;
    line-height: 1.25;
}

.cwm-header p:last-child {
    margin: 0;
    color: var(--text-secondary, #5f5e5a);
    font-size: 13px;
    line-height: 1.55;
}

.cwm-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(285px, 0.85fr);
    align-items: start;
    gap: 20px;
}

.cwm-guide,
.cwm-community {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border-subtle, rgba(15, 23, 42, 0.08));
    border-radius: 16px;
    background: var(--bg-subtle, #fbfbf9);
}

.cwm-section-heading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    margin-bottom: 13px;
}

.cwm-step {
    min-width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--brand-primary-soft, #e1f5ee);
    color: var(--brand-primary, #085041);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.cwm-section-heading h3 {
    margin: 0 0 3px;
    color: var(--text-primary, #1a1a18);
    font-size: 15px;
    font-weight: 650;
    line-height: 1.35;
}

.cwm-section-heading p {
    margin: 0;
    color: var(--text-tertiary, #73716b);
    font-size: 11px;
    line-height: 1.45;
}

.cwm-guide-points {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
}

.cwm-guide-points span {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary, #5f5e5a);
    font-size: 10.5px;
    line-height: 1.35;
}

.cwm-guide-points svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    padding: 2px;
    border-radius: 999px;
    background: var(--brand-primary-soft, #e1f5ee);
    color: var(--brand-primary, #085041);
}

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

.cwm-item {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--border-subtle, rgba(15, 23, 42, 0.09));
    border-radius: 11px;
    background: var(--bg-surface, #fff);
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.cwm-item:hover {
    border-color: rgba(8, 80, 65, 0.24);
    background: var(--brand-primary-soft, #effaf6);
    color: inherit;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(8, 80, 65, 0.07);
}

.cwm-item-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 999px;
}

.cwm-item-body {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cwm-item-heading {
    display: flex;
    align-items: center;
    gap: 7px;
}

.cwm-item-heading strong {
    color: var(--text-primary, #1a1a18);
    font-size: 13px;
    font-weight: 600;
}

.cwm-platform {
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.035em;
}

.cwm-platform--fb {
    background: #e4ecf7;
    color: #1f4e96;
}

.cwm-platform--zalo {
    background: #ddf1fb;
    color: #0e5a88;
}

.cwm-item-meta {
    color: var(--text-tertiary, #73716b);
    font-size: 10px;
}

.cwm-item > svg {
    flex: 0 0 auto;
    color: var(--text-tertiary, #73716b);
    transition: transform 160ms ease;
}

.cwm-item:hover > svg {
    transform: translate(2px, -2px);
    color: var(--brand-primary, #085041);
}

.cwm-tip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    margin-top: 11px;
    padding: 9px 10px;
    border-radius: 9px;
    background: var(--brand-primary-soft, #e1f5ee);
    color: var(--text-secondary, #5f5e5a);
}

.cwm-tip svg {
    margin-top: 1px;
    color: var(--brand-primary, #085041);
}

.cwm-tip p {
    margin: 0;
    font-size: 10.5px;
    line-height: 1.45;
}

.cwm-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.cwm-primary,
.cwm-secondary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 11px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.cwm-primary {
    border: 1px solid #085041;
    background: #085041;
    color: #fff;
    box-shadow: 0 8px 20px rgba(8, 80, 65, 0.17);
}

.cwm-primary:hover {
    border-color: #0f6e56;
    background: #0f6e56;
    box-shadow: 0 10px 24px rgba(8, 80, 65, 0.22);
}

.cwm-secondary {
    border: 1px solid var(--border-default, rgba(15, 23, 42, 0.14));
    background: transparent;
    color: var(--text-secondary, #5f5e5a);
}

.cwm-secondary:hover {
    border-color: var(--text-tertiary, #73716b);
    background: var(--bg-muted, #f1efe8);
    color: var(--text-primary, #1a1a18);
}

@keyframes cwm-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cwm-modal-in {
    from { transform: translateY(10px) scale(0.975); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@media (max-width: 760px) {
    .cwm-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .cwm-modal {
        width: 100%;
        max-height: 94vh;
        max-height: min(94dvh, calc(100dvh - env(safe-area-inset-top)));
        padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
        border-width: 1px 0 0;
        border-radius: 20px 20px 0 0;
        scrollbar-gutter: auto;
    }

    .cwm-header {
        margin-bottom: 18px;
    }

    .cwm-grid {
        grid-template-columns: 1fr;
    }
}

/* Portrait tablets and compact laptop windows need a single readable column. */
@media (min-width: 761px) and (max-width: 900px) and (min-height: 681px) {
    .cwm-backdrop {
        padding: 18px;
    }

    .cwm-modal {
        width: min(100%, 720px);
        padding: 24px;
    }

    .cwm-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .cwm-close {
        top: 10px;
        right: 10px;
    }

    .cwm-header {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-right: 38px;
    }

    .cwm-header__icon {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .cwm-guide,
    .cwm-community {
        padding: 14px;
    }

    .cwm-guide-points {
        grid-template-columns: 1fr;
    }

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

    .cwm-primary,
    .cwm-secondary {
        width: 100%;
    }

    @keyframes cwm-modal-in {
        from { transform: translateY(22px); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }
}

/*
 * Phones in landscape and short laptop windows have enough width for two
 * panels but very little vertical room. Keep the primary actions visible and
 * compress non-interactive spacing without shrinking touch targets.
 */
@media (orientation: landscape) and (max-height: 680px) {
    .cwm-backdrop {
        align-items: center;
        padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    }

    .cwm-modal {
        width: min(100%, 960px);
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - max(16px, calc(env(safe-area-inset-top) + env(safe-area-inset-bottom))));
        padding: 14px 16px 0;
        border-width: 1px;
        border-radius: 16px;
        scrollbar-gutter: auto;
    }

    .cwm-close {
        top: 8px;
        right: 8px;
    }

    .cwm-header {
        gap: 10px;
        max-width: none;
        margin: 0 42px 12px 0;
        padding-right: 0;
    }

    .cwm-header__icon {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }

    .cwm-eyebrow {
        margin-bottom: 2px;
        font-size: 9px;
    }

    .cwm-header h2 {
        margin-bottom: 3px;
        font-size: 18px;
    }

    .cwm-header p:last-child {
        font-size: 11px;
        line-height: 1.4;
    }

    .cwm-grid {
        gap: 10px;
    }

    .cwm-guide,
    .cwm-community {
        padding: 11px;
        border-radius: 13px;
    }

    .cwm-section-heading {
        gap: 8px;
        margin-bottom: 8px;
    }

    .cwm-step {
        min-width: 28px;
        height: 28px;
    }

    .cwm-section-heading h3 {
        font-size: 13px;
    }

    .cwm-section-heading p {
        font-size: 10px;
    }

    .cwm-modal .guide-video-player--compact .guide-video-player__empty {
        min-height: 0;
        padding: 12px;
    }

    .cwm-guide-points {
        margin-top: 8px;
    }

    .cwm-item {
        min-height: 44px;
        padding: 6px 9px;
    }

    .cwm-list {
        gap: 5px;
    }

    .cwm-tip {
        margin-top: 7px;
        padding: 7px 8px;
    }

    .cwm-actions {
        position: sticky;
        z-index: 3;
        bottom: 0;
        margin: 10px -16px 0;
        padding: 9px 16px max(9px, env(safe-area-inset-bottom));
        border-top: 1px solid var(--border-subtle, rgba(15, 23, 42, 0.08));
        background: var(--bg-surface, #fff);
        box-shadow: 0 -10px 24px rgba(3, 18, 16, 0.06);
    }

    .cwm-primary,
    .cwm-secondary {
        min-height: 44px;
        padding-block: 8px;
    }
}

@media (orientation: landscape) and (min-width: 600px) and (max-height: 680px) {
    .cwm-grid {
        grid-template-columns: minmax(0, 1.08fr) minmax(270px, 0.92fr);
    }
}

@media (orientation: landscape) and (max-width: 599px) and (max-height: 680px) {
    .cwm-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cwm-backdrop,
    .cwm-modal {
        animation: none;
    }

    .cwm-item,
    .cwm-item > svg,
    .cwm-primary,
    .cwm-secondary {
        transition: none;
    }
}
