.tour-spotlight-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10650;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tour-spotlight-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
}

/* SVG punch-through container */
.tour-spotlight-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10651 !important;
}

.tour-spotlight-dark-rect {
    fill: rgba(24, 32, 26, 0.32);
    pointer-events: auto;
}

.tour-spotlight-border {
    fill: none;
    stroke: var(--cta, #33513F);
    stroke-width: 1.5;
    stroke-dasharray: none;
    pointer-events: none;
    transition: all 0.2s ease;
}

/* Coach card */
.tour-card {
    position: absolute;
    z-index: 10660 !important;
    pointer-events: auto !important;
    background: var(--bg-surface, #FFFFFF);
    border-radius: 20px;
    padding: 18px 20px 16px;
    width: 320px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border, #E4E0D4);
    box-sizing: border-box;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    animation: tourCardFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tour-card button,
.tour-card a {
    pointer-events: auto !important;
}

@keyframes tourCardFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tour-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.tour-header-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tour-progress-badge {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cta, #33513F);
    background: var(--accent-light, #E8EFE9);
    padding: 3px 8px;
    border-radius: 6px;
}

.tour-substep-badge {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-secondary, #8A8570);
    background: var(--bg-surface-light, #F5F3EC);
    border: 1px solid var(--border, #E4E0D4);
    padding: 2px 7px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

.tour-skip-btn {
    border: none;
    background: none;
    color: var(--text-secondary, #8A8570);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 6px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    transition: color 0.15s ease;
}

.tour-skip-btn:hover {
    color: var(--text-primary, #1A1C19);
}

.tour-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #1A1C19);
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.tour-card-body {
    font-size: 13px;
    color: var(--text-secondary, #6E6855);
    line-height: 1.45;
    margin: 0 0 16px 0;
}

.tour-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tour-discover-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--cta, #33513F);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 0;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tour-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tour-btn-prev {
    background: transparent;
    border: 1px solid var(--border, #E4E0D4);
    color: var(--text-secondary, #8A8570);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.tour-btn-prev:hover {
    background: var(--line, #EFEAD8);
}

.tour-btn-next {
    background: var(--cta, #33513F);
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(51, 81, 63, 0.25);
}

.tour-btn-next:hover {
    background: #253C2E;
}

/* ── INTERACTIVE TRY-IN-PLACE PUNCH-THROUGH ────────────────────────────── */

/* Elevates highlighted target above the tour overlay (10600) so user can tap/click it directly */
.tour-highlighted-target {
    /* The SVG hole permits interaction without changing target geometry. */
    pointer-events: auto !important;
    outline: none !important;
    transition: transform 0.2s ease !important;
}

.tour-elevated-ancestor,
.tab-bar:has(.tour-highlighted-target) {
    z-index: 10605 !important;
}

/* When a modal is open during tour (e.g. habit create modal), elevate tour card above the modal */
.tour-spotlight-overlay.modal-mode {
    z-index: 10700;
}

.tour-spotlight-overlay.modal-mode .tour-spotlight-svg {
    display: none;
}

.tour-spotlight-overlay.modal-mode .tour-card {
    z-index: 10710;
    top: calc(14px + env(safe-area-inset-top, 0px)) !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    border: 2px solid var(--cta, #33513F);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

/* Micro celebration badge */
.tour-success-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #DCFCE7;
    color: #166534;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    animation: tourCardFadeIn 0.3s ease;
}


/* A quiet coach with explicit, freely selectable sections. */
.tour-card { background: var(--paper, #F5F3EC); box-shadow: 0 12px 36px rgba(20,30,22,.16); }
.tour-section-label { display: block; font-size: 11px; color: var(--text-secondary); margin: 10px 0 5px; }
#tour-section-select { width: 100%; min-width: 0; min-height: 40px; border: 1px solid var(--border, #DED9C9); border-radius: 10px; padding: 8px; margin-bottom: 12px; background: var(--bg-surface, #fff); color: var(--text-primary); font: inherit; font-size: 12px; }
.tour-card-footer { flex-wrap: wrap; }
.tour-actions-right { margin-left: auto; }
.tour-spotlight-overlay.form-guidance .tour-card, .tour-spotlight-overlay.form-guidance .tour-spotlight-svg { display: none; }
.tour-form-guide { border: 1px solid var(--border, #DED9C9); border-radius: 14px; padding: 14px; background: var(--paper, #F5F3EC); color: var(--text-primary); scroll-margin-top: 12px; }
.tour-form-heading, .tour-form-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tour-form-heading span { font-size: 11px; color: var(--text-secondary); }
.tour-form-guide h3 { font-size: 16px; margin: 8px 0; }
.tour-form-guide p { font-size: 13px; line-height: 1.5; margin: 6px 0; }
.tour-form-guide button { min-height: 44px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--cta, #33513F); cursor: pointer; font: inherit; font-size: 12px; }
.tour-form-guide [data-guide=next] { margin-left: auto; background: var(--cta, #33513F); color: #fff; }
.tour-form-guide [hidden] { display: none; }
#tour-form-summary { font-weight: 600; overflow-wrap: anywhere; }
#tour-form-error { color: #a23c31; }
.tour-form-field { outline: 1px solid var(--cta, #33513F); outline-offset: 5px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { .tour-card, .tour-spotlight-overlay, .tour-spotlight-border { animation: none; transition: none; } }

.tour-card { transition: opacity .2s ease; overflow-y: auto; }

.tour-spotlight-overlay.dialog-paused .tour-card, .tour-spotlight-overlay.dialog-paused .tour-spotlight-svg { display: none; }

/* Reserve reading space above the insight sheet while its guide is visible. */
body:has(#tour-spotlight-overlay.active[data-step="smart_insights"]) .rhythm-evidence-sheet { max-height: 42dvh; }

/* Status messages must not block the guided controls. */
body:has(#tour-spotlight-overlay.active) .toast { pointer-events: none; }

.single-task #tour-section-select, .single-task #tour-progress-badge, .single-task #tour-btn-prev { display:none !important; }
