.sal-chat { max-width: 54rem; }
.sal-chat h2 { margin-bottom: .5rem; }
.sal-notice, .sal-status { color: var(--muted); }
.sal-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.sal-actions .primary-link { margin: 0; }
.sal-chat button { font: inherit; cursor: pointer; }
.sal-chat button:not(.primary-link) { background: var(--card); color: var(--accent); padding: .45rem .65rem; border: 1px solid var(--line); border-radius: .35rem; }
.sal-chat button:disabled { opacity: .55; cursor: default; }
.sal-chat button:focus-visible, .sal-chat textarea:focus-visible, .sal-history summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sal-messages { max-block-size: 42rem; overflow-y: auto; }
.sal-message { background: var(--card); border-left: 2px solid var(--accent); padding: .85rem 1.05rem; margin-block: .75rem; }
.sal-user { background: var(--paper); border-color: var(--line); }
.sal-message p { margin: .25rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sal-starters { display: flex; flex-wrap: wrap; gap: .5rem; padding: .4rem 0 .8rem; border: 0; margin: .8rem 0; }
.sal-starters legend, .sal-composer label { font-weight: 650; }
.sal-starters button { text-align: left; }
.sal-composer textarea { display: block; width: 100%; border: 1px solid var(--line); border-radius: .4rem; padding: .65rem; margin-block: .3rem .8rem; resize: vertical; font: inherit; }
.sal-history li { margin-bottom: .5rem; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.sal-history summary, .sal-resources summary { color: var(--accent); cursor: pointer; font-weight: 650; }
.sal-chapter { background: var(--card); }
.sal-chapter .reading-excerpt { display: block; padding-block: clamp(1.5rem, 4vw, 3.25rem); }
.sal-chapter .reading-excerpt h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); margin: .35rem 0 1.6rem; }
.sal-excerpt-nav, .sal-chapter > p { width: min(100% - 2.5rem, 42rem); margin: 0 auto; padding-bottom: 1.5rem; }
.sal-excerpt-nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.sal-excerpt-nav a { flex: 1 1 14rem; border-top: 1px solid var(--line); padding-top: .8rem; font-weight: 650; }
.sal-excerpt-nav small { display: block; color: var(--muted); }
body:has(.reading-excerpt:target) #main > :not(.reading) { display: none; }

.page-heading.sal-guide-heading {
    grid-template-columns: minmax(0, 1fr) minmax(10rem, .4fr);
}
.page-heading.sal-guide-heading .page-heading-image { max-width: 20rem; }
@media (max-width: 680px) {
    .page-heading.sal-guide-heading { grid-template-columns: minmax(0, 1fr) 36%; align-items: center; }
}

.sal-guide-widget {
    --accent: #792f42;
    --card: #fffcf7;
    --ink: #2b2024;
    --line: #ddd0c4;
    --muted: #64565b;
    --paper: #faf7f0;
    position: fixed;
    inset-inline-end: max(.75rem, env(safe-area-inset-right));
    inset-block-end: max(.75rem, env(safe-area-inset-bottom));
    z-index: 1000;
    font: 1rem/1.45 system-ui, sans-serif;
    text-align: start;
    color: var(--ink);
}
.sal-guide-widget, .sal-guide-widget * { box-sizing: border-box; }
.sal-guide-trigger {
    display: flex;
    gap: .5rem;
    align-items: center;
    min-block-size: 2.75rem;
    padding: .45rem .85rem;
    list-style: none;
    color: #fff;
    background: var(--accent);
    border: 1px solid #fff3;
    border-radius: 1.5rem;
    box-shadow: 0 .2rem .7rem #301c2842;
    font-weight: 700;
    cursor: pointer;
}
.sal-guide-trigger::-webkit-details-marker { display: none; }
.sal-guide-trigger::before {
    content: '?';
    display: grid;
    place-items: center;
    inline-size: 1.3rem;
    block-size: 1.3rem;
    border: 1px solid currentColor;
    border-radius: 50%;
}
.sal-guide-widget[open] > .sal-guide-trigger::before { content: '×'; }
.sal-guide-panel {
    position: absolute;
    inset-inline-end: 0;
    inset-block-end: calc(100% + .65rem);
    width: min(25rem, calc(100vw - 1.75rem));
    max-height: calc(100vh - 5rem);
    max-block-size: min(37rem, calc(100dvh - 5rem));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: .6rem;
    box-shadow: 0 .4rem 1.6rem #301c2845;
}
.sal-guide-panel h2 { margin: .1rem 0 .5rem; font: 1.45rem/1.2 Georgia, serif; color: var(--ink); }
.sal-guide-panel p { margin: .4rem 0 .65rem; }
.sal-guide-panel a { color: var(--accent); text-decoration: underline; text-underline-offset: .18em; }
.sal-guide-panel .sal-notice, .sal-guide-panel .sal-status { font-size: .9rem; }
.sal-guide-panel .sal-starters { display: flex; flex-wrap: wrap; min-inline-size: 0; margin: .65rem 0; }
.sal-guide-panel .sal-starters button { font-size: .9rem; min-height: 2rem; }
.sal-guide-panel .sal-messages { max-block-size: 14rem; }
.sal-guide-panel textarea { min-block-size: 4rem; color: var(--ink); background: #fff; }
.sal-guide-panel button.primary-link {
    padding: .45rem .85rem;
    min-block-size: 2.5rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
}
.sal-guide-widget :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media print { .sal-guide-widget { display: none; } }

.sal-guide-widget:not([open]) > .sal-guide-panel { display: none; }

.sal-guide-widget {
    --guide-bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
    --guide-side: max(16px, calc(env(safe-area-inset-right) + 12px));
    --guide-height: 50px;
    inset-inline-end: var(--guide-side);
    inset-block-end: var(--guide-bottom);
}
.sal-guide-widget > .sal-guide-trigger {
    min-block-size: var(--guide-height);
    padding: .55rem 1rem;
    gap: .65rem;
    font-size: 1rem;
    line-height: 1.3;
    color: #fff;
    background: #792f42;
    border: 2px solid #fff;
    border-radius: 2rem;
    box-shadow: 0 3px 14px #2a17284d;
}
.sal-guide-trigger::before {
    content: '';
    inline-size: 1.55rem;
    block-size: 1.2rem;
    flex: none;
    border: 2px solid currentColor;
    border-radius: .45rem .45rem .45rem .1rem;
    background: radial-gradient(circle at 30% 50%,currentColor 1px,transparent 1.5px),
        radial-gradient(circle at 50% 50%,currentColor 1px,transparent 1.5px),
        radial-gradient(circle at 70% 50%,currentColor 1px,transparent 1.5px);
}
.sal-guide-widget[open] > .sal-guide-trigger::before {
    content: '×';
    background: none;
    border: 0;
    line-height: 1;
}
.sal-guide-widget > .sal-guide-trigger:hover { background: #622135; }
.sal-guide-widget > .sal-guide-trigger:focus-visible { outline: 3px solid #542035; outline-offset: 2px; }
.sal-guide-widget > .sal-guide-panel {
    width: min(25rem, calc(100vw - var(--guide-side) - max(1rem, env(safe-area-inset-left))));
    max-height: calc(100vh - var(--guide-bottom) - 100% - 1.5rem);
    max-block-size: min(37rem, calc(100dvh - var(--guide-bottom) - 100% - 1.5rem - env(safe-area-inset-top)));
}
@media (min-width: 800px) {
    .sal-guide-widget {
        --guide-height: 58px;
        --guide-side: max(28px, calc(env(safe-area-inset-right) + 16px));
        --guide-bottom: max(40px, calc(env(safe-area-inset-bottom) + 16px));
    }
    .sal-guide-widget > .sal-guide-trigger { font-size: 1.125rem; padding-inline: 1.25rem; }
}

.sal-guide-short-label { display: none; }
@media (min-width: 800px) {
    .sal-guide-widget { --guide-side: max(8px, env(safe-area-inset-right)); }
    .sal-guide-widget > .sal-guide-trigger {
        inline-size: 4.5rem;
        padding: .3rem .15rem;
        flex-direction: column;
        justify-content: center;
        gap: .15rem;
        border-radius: .9rem;
        font-size: .9375rem;
    }
    .sal-guide-trigger .sal-guide-short-label { display: inline; }
    .sal-guide-trigger .sal-guide-long-label { display: none; }
    /* Keep a clear lane on laptops where the normal page margin is too narrow. */
    body:has(.sal-guide-widget) {
        padding-inline-end: max(0px, min(calc(5.75rem - 3.5vw), calc(11.5rem + var(--shell-width, 75rem) - 100%)));
    }
}
