/* Adds progress semantics without changing the existing button system. */
a.autofill.button-style.sage-progress-complete {
    position: relative;
    padding-left: 34px !important;
}

a.autofill.button-style.sage-progress-complete::before {
    content: "✓";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 800;
}

.sage-learning-card {
    border: 1px solid #dfe8e5;
    border-radius: 16px;
    padding: 18px;
    margin: 14px 0;
    background: #fff;
}
.sage-learning-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.sage-learning-progress {
    height: 10px;
    border-radius: 999px;
    background: #edf2f1;
    overflow: hidden;
    margin: 12px 0 8px;
}
.sage-learning-progress > span {
    display: block;
    height: 100%;
    width: 0;
    background: #009898;
    border-radius: inherit;
}
.sage-learning-modules {
    margin-top: 14px;
}
.sage-learning-module {
    border-top: 1px solid #edf0ef;
    padding: 10px 0;
}
.sage-learning-module summary {
    cursor: pointer;
    font-weight: 700;
}
.sage-learning-items {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}
.sage-learning-items li {
    padding: 4px 0;
}
.sage-learning-items .done::before { content: "✓ "; font-weight: 800; }
.sage-learning-items .pending::before { content: "○ "; opacity: .55; }

/* -------------------------------------------------------------------------
   Stage 9 · compact in-conversation course continuity
   ------------------------------------------------------------------------- */
.earth-course-context,
.earth-course-bridge {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #d7dfdc;
}

.earth-course-context-stage9 {
    --course-accent: #009898;
}

.earth-course-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    color: #24302b;
}
.earth-course-progress-head strong:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.earth-course-progress-bar {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8efed;
}
.earth-course-progress-bar > span {
    display: block;
    height: 100%;
    background: var(--course-accent, #009898);
    border-radius: inherit;
}

/* Stage 9 refinement: Prev / Continue / Next stays outside and before context. */
.earth-course-nav-row {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 14px 0 9px;
}
.earth-course-nav-slot { min-width: 0; display:flex; align-items:center; }
.earth-course-nav-left { justify-content:flex-start; }
.earth-course-nav-right { justify-content:flex-end; }
.earth-course-nav-label {
    color: #63716e;
    font-size: .76em;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
    text-align: center;
}
.earth-course-nav-button,
.earth-course-next .earth-course-next-button,
.earth-course-next .earth-course-prev {
    margin: 0 !important;
    min-height: 36px !important;
    height: 36px !important;
    padding: 0 12px !important;
    border-radius: 999px !important;
    white-space: nowrap !important;
    font-size: .84em !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.earth-course-nav-button.sage-progress-complete {
    padding-left: 12px !important;
}
.earth-course-nav-button.sage-progress-complete::before {
    position: static !important;
    display: inline-block;
    transform: none !important;
    margin-right: 6px;
    line-height: 1;
}

.earth-course-finished {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 11px;
    border-radius: 999px;
    background: #edf7f4;
    color: #007777;
    font-size: .82em;
    font-weight: 700;
}

/* Whole compact course strip is the disclosure trigger. */
.earth-course-context-stage9 {
    --course-accent: #009898;
}
.earth-course-context-toggle {
    appearance: none;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.earth-course-context-toggle:focus-visible {
    outline: 2px solid #0b8e89;
    outline-offset: 5px;
    border-radius: 8px;
}
.earth-course-compact-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 8px;
    min-width: 0;
}
.earth-course-compact-meta {
    flex: 1 1 auto;
    min-width: 0;
    color: #667773;
    font-size: .86em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.earth-course-context-chevron {
    flex: 0 0 auto;
    color: #087b77;
    font-size: .82em;
    font-weight: 800;
    transition: transform .2s ease;
}
.earth-course-context-stage9.is-expanded .earth-course-context-chevron {
    transform: rotate(180deg);
}
.earth-course-details-inline {
    position: static;
    width: auto;
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    overflow: hidden;
    padding: 0;
    margin-top: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: max-height .22s ease, opacity .18s ease, transform .18s ease, margin-top .18s ease;
}
.earth-course-context-stage9.is-expanded .earth-course-details-inline {
    margin-top: 10px;
}
.earth-course-detail-line {
    color: #5e6f6b;
    font-size: .86em;
    line-height: 1.45;
}
.earth-course-detail-line + .earth-course-detail-line { margin-top: 5px; }

.earth-course-mini-label {
    margin-bottom: 6px;
    font-size: .74em;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: #73817e;
}
.earth-course-breadcrumb-row {
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid #e7ecea;
}
.earth-course-breadcrumbs,
.earth-course-explore-buttons {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.earth-course-breadcrumbs .button-style.earth-breadcrumb {
    margin: 0 !important;
    max-width: 100%;
    min-height: 32px !important;
    padding: 5px 8px !important;
    font-size: .82em !important;
    overflow: hidden;
    text-overflow: ellipsis;
}
.earth-breadcrumb-sep { color: #9aa6a2; font-weight: 700; }
.earth-breadcrumb-current {
    flex: 1 1 100%;
    color: #52615d;
    font-size: .84em;
    font-weight: 600;
    margin-top: 3px;
}

.earth-course-progress-meta,
.earth-course-module-progress {
    margin-top: 5px;
    color: #667773;
    font-size: .86em;
}
.earth-course-explore {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(0,152,152,.045);
}
.earth-course-bridge {
    padding: 10px 12px;
    border: 1px solid #dce8e5;
    border-radius: 12px;
    background: #fff;
}
.earth-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(220px,1fr));
    gap: 8px;
}
.earth-module-grid .button-style {
    margin: 0 !important;
    text-align: left;
    white-space: normal !important;
}

@media (max-width: 720px) {
    .earth-course-progress-head strong:first-child { white-space: normal; }
    .earth-course-compact-meta { white-space: normal; }
    .earth-course-nav-row { gap: 7px; }
    .earth-course-nav-label { font-size: .7em; }
    .earth-course-nav-button,
    .earth-course-next .earth-course-next-button,
    .earth-course-next .earth-course-prev {
        min-height: 34px !important;
        height: 34px !important;
        padding: 0 10px !important;
    }
    .earth-module-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .earth-course-nav-row { grid-template-columns: 1fr auto 1fr; }
    .earth-course-nav-button,
    .earth-course-next .earth-course-next-button,
    .earth-course-next .earth-course-prev {
        padding: 0 8px !important;
        font-size: .79em !important;
    }
    .earth-course-nav-label { font-size: .66em; }
}

/* Recipe responses: subtle semantic distinction from normal SAGE knowledge. */
#conversation li.bot.bot-recipe {
    background: #FFFBEE !important;
}

@media (max-width: 640px) {
    .earth-course-next-buttons,
    .earth-course-explore-buttons,
    .earth-course-breadcrumbs {
        gap: 6px;
    }
    .earth-course-breadcrumb-current {
        flex-basis: 100%;
    }
    .earth-module-grid {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------------------------------------------
   My SAGE · Made it modal — presentation-only repair.
   Existing script.js remains the sole owner of modal behaviour.
   ------------------------------------------------------------------------- */
#sage-recipe-made-modal .sage-quest-modal-card {
    width: min(620px, calc(100vw - 32px));
    max-width: 620px;
    padding: 26px;
    border-radius: 20px;
    box-sizing: border-box;
}

#sage-recipe-made-modal .sage-quest-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    width: 100%;
    margin: 15px 0 0;
    box-sizing: border-box;
    color: #202322;
    font-weight: 500;
    line-height: 1.35;
}

#sage-recipe-made-modal .sage-quest-field textarea,
#sage-recipe-made-modal .sage-quest-field input {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 11px 12px !important;
    border: 1px solid #cfd8d4 !important;
    border-radius: 11px !important;
    background: #fff !important;
    color: #202322 !important;
    font: inherit !important;
    font-weight: 400 !important;
    line-height: 1.45 !important;
    outline: none;
}

#sage-recipe-made-modal .sage-quest-field textarea {
    min-height: 112px;
    resize: vertical;
}

#sage-recipe-made-modal .sage-quest-field textarea:focus,
#sage-recipe-made-modal .sage-quest-field input:focus {
    border-color: #009898 !important;
    box-shadow: 0 0 0 3px rgba(0, 152, 152, .10) !important;
}

#sage-recipe-made-modal .sage-quest-modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}

#sage-recipe-made-modal .sage-quest-modal-actions button {
    min-height: 42px;
    padding: 9px 15px;
    border-radius: 11px;
    font: inherit;
    font-weight: 500 !important;
    cursor: pointer;
}

#sage-recipe-made-modal .sage-made-cancel {
    border: 1px solid #d5ddda !important;
    background: #fff !important;
    color: #34413e !important;
}

#sage-recipe-made-modal .sage-made-save {
    border: 1px solid #009898 !important;
    background: #009898 !important;
    color: #fff !important;
}

#sage-recipe-made-modal .sage-made-save:hover,
#sage-recipe-made-modal .sage-made-save:focus-visible {
    border-color: #007b7b !important;
    background: #007b7b !important;
}

#sage-recipe-made-modal .sage-made-save:disabled {
    opacity: .58;
    cursor: wait;
}

@media (max-width: 560px) {
    #sage-recipe-made-modal .sage-quest-modal-card {
        width: calc(100vw - 22px);
        padding: 20px 16px;
        border-radius: 18px;
    }

    #sage-recipe-made-modal .sage-quest-modal-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    #sage-recipe-made-modal .sage-quest-modal-actions button {
        width: 100%;
    }
}
