.bible-chapter-heading { position: relative; }
.bible-chapter-heading:has(> .verse-selection-heading-button:not([hidden])) { padding-inline: 44px; }
.verse-selection-heading-button {
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; padding: 6px;
    border: 1px solid #cbd0d5; border-radius: 7px;
    color: #626970; background: transparent; cursor: pointer;
}
.verse-selection-heading-button[hidden] { display: none !important; }
.verse-selection-heading-button svg {
    width: 24px; height: 24px; fill: none; stroke: currentColor;
    stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.verse-selection-heading-button:hover {
    background: #62697012;
    border-color: #9299a0;
}
.verse-selection-heading-button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.verse-selection-heading-button[aria-pressed="true"] { color: #fff; background: #848c94; border-color: #848c94; }
.dark-theme .verse-selection-heading-button { color: #c5c9ce; border-color: #646b72; }
.dark-theme .verse-selection-heading-button:hover { background: #c5c9ce1a; border-color: #9ca3aa; }
.dark-theme .verse-selection-heading-button[aria-pressed="true"] { color: #292d32; background: #c5c9ce; border-color: #c5c9ce; }
.verse-selection-bar {
    --selection-accent: #343a40;
    --selection-paper: #f3f4f5;
    --selection-ink: #343a40;
    --selection-muted: #565e66;
    --selection-border: #b4bbc2;
    --selection-hover: #343a4012;
    --selection-menu-paper: #fff;
    --selection-menu-ink: #343a40;
    --selection-menu-hover: #62697012;
    font: 13px/1.4 system-ui, sans-serif;
    color: var(--selection-ink);
    position: fixed;
    z-index: 1030;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 16px);
    display: grid;
    grid-template-columns: minmax(0, 150px) auto 32px;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--selection-border);
    border-radius: 12px;
    background: var(--selection-paper);
    box-shadow: 0 10px 32px #20252b26, 0 0 0 3px #ffffffcc;
}
.dark-theme .verse-selection-bar {
    --selection-accent: #f2f3f5;
    --selection-paper: #444a50;
    --selection-ink: #f2f3f5;
    --selection-muted: #d0d4d8;
    --selection-border: #737b83;
    --selection-hover: #ffffff14;
    --selection-menu-paper: #30353a;
    --selection-menu-ink: #f2f3f5;
    --selection-menu-hover: #ffffff14;
    box-shadow: 0 10px 32px #00000059, 0 0 0 2px #c5c9ce1a;
}
.verse-selection-bar[hidden] { display: none !important; }
.verse-selection-bar.is-anchored {
    top: var(--verse-bar-top, 8px); bottom: auto;
    left: var(--verse-bar-left, 8px); transform: none;
    max-width: var(--verse-bar-width, calc(100% - 16px));
}
.verse-selection-bar.is-anchored .verse-selection-summary strong { overflow: hidden; text-overflow: ellipsis; }
.verse-selection-summary { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-left: 4px; }
.verse-selection-summary strong { font-size: 13px; font-weight: 600; white-space: nowrap; }
.verse-selection-reference { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--selection-muted); }
.verse-selection-actions { display: flex; gap: 4px; }
.verse-selection-share-menu { display: flex; align-items: center; }
.verse-selection-share-menu .dropdown-menu { max-width: calc(100vw - 24px); background: var(--selection-menu-paper); color: var(--selection-menu-ink); }
.verse-selection-share-menu .dropdown-item { color: var(--selection-menu-ink); }
.verse-selection-share-menu .dropdown-item:hover, .verse-selection-share-menu .dropdown-item:focus { background: var(--selection-menu-hover); }
.verse-selection-bar button {
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    padding: 6px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--selection-ink);
    cursor: pointer;
    touch-action: manipulation;
}
.verse-selection-bar button:hover:not(:disabled) { background: var(--selection-hover); }
.verse-selection-bar button:focus-visible, .verse-select-checkbox:focus-visible {
    outline: 2px solid var(--selection-accent, #626970); outline-offset: 2px;
}
.verse-selection-bar button svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.verse-selection-bar button:disabled { opacity: .45; cursor: default; }
.verse-selection-bar .verse-selection-share { color: var(--selection-accent); }
.verse-selection-bar .verse-selection-close { padding: 0; width: 100%; line-height: 1; color: var(--selection-muted); }
.verse-selection-bar .verse-selection-close svg { display: block; width: 18px; height: 18px; flex-basis: 18px; }
.verse-selection-status { grid-column: 1 / -1; font-size: 12px; }
.verse-selection-status:empty { display: none; }
.verse-selection-status.is-sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap; border: 0;
}
.verse-select-checkbox {
    position: absolute; left: 0; top: 0; display: none; align-items: center; justify-content: center;
    width: 32px; height: 24px; padding: 2px 6px; border: 0; border-radius: 5px;
    background: transparent; color: #848c94; cursor: pointer; user-select: none;
}
.verse-select-checkbox svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.verse-select-checkbox path { opacity: 0; }
body.verse-selection-mode:not(.verse-touch-selection) .verse-selection-enabled { position: relative; padding-left: 32px; }
body.verse-selection-mode:not(.verse-touch-selection) .verse-select-checkbox { display: inline-flex; }
body.verse-selection-mode:not(.verse-touch-selection) .verse-selection-enabled > .verse-body { cursor: pointer; }
/* Editions with initials/mappings already have an absolute number gutter. Extend it
   at chapter level so decorative initials keep their existing text wrapping. */
body.verse-selection-mode:not(.verse-touch-selection) .ostrog-chapter { padding-left: 58px; }
body.verse-selection-mode:not(.verse-touch-selection) .bible-mapped-chapter { padding-left: calc(var(--bible-number-width, 22px) + 38px); }
body.verse-selection-mode:not(.verse-touch-selection) :is(.ostrog-chapter, .bible-mapped-chapter) .verse-selection-enabled { padding-left: 0; }
body.verse-selection-mode:not(.verse-touch-selection) .ostrog-chapter .verse-select-checkbox { left: -58px; }
body.verse-selection-mode:not(.verse-touch-selection) .bible-mapped-chapter .verse-select-checkbox { left: calc(-1 * (var(--bible-number-width, 22px) + 38px)); }
.verse-select-checkbox:hover { background: #62697012; }
.verse-select-checkbox[aria-checked="true"] rect { fill: currentColor; }
.verse-select-checkbox[aria-checked="true"] path { opacity: 1; stroke: #fff; }
.dark-theme .verse-select-checkbox { color: #c5c9ce; }
.dark-theme .verse-select-checkbox:hover { background: #c5c9ce1a; }
.dark-theme .verse-select-checkbox:focus-visible { outline-color: #c5c9ce; }
.dark-theme .verse-select-checkbox[aria-checked="true"] path { stroke: #292d32; }
.verse-number[data-verse-selectable]:not(.relations) { cursor: default; }
.verse-number[data-verse-selectable].relations {
    cursor: help; text-decoration-line: underline; text-decoration-style: dotted;
    text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.bible-verse.is-verse-selected {
    border-radius: 4px;
    background-color: color-mix(in srgb, var(--bible-selection-color, red) 7.5%, transparent);
    box-shadow: inset -3px 0 0 var(--bible-selection-color, red);
}
.dark-theme .bible-verse.is-verse-selected { background-color: #f0a49a19; box-shadow: inset -3px 0 0 #f0a49a; }
/* The first touch hold selects a verse; selected verses allow native word selection. */
.verse-touch-selection:not(.verse-native-selection) .bible-verse:has(> [data-verse-selectable]):not(.is-verse-selected) > .verse-body,
.verse-touch-selection .is-holding-verse > .verse-body {
    -webkit-user-select: none; user-select: none;
}
.verse-touch-selection .is-holding-verse > .verse-body { -webkit-touch-callout: none; }
.verse-touch-selection .is-verse-selected:not(.is-holding-verse) > .verse-body,
.verse-touch-selection.verse-native-selection .bible-verse:has(> [data-verse-selectable]) > .verse-body {
    -webkit-user-select: text; user-select: text;
}
@media (max-width: 540px) {
    .verse-selection-bar { width: calc(100% - 16px); grid-template-columns: minmax(0, 1fr) auto 28px; gap: 3px; padding: 5px; }
    .verse-selection-reference, .verse-selection-bar button svg { display: none; }
    .verse-selection-bar button { padding: 6px; font-size: 12px; }
    .verse-selection-summary strong { font-size: 12px; }
}
@media print {
    .verse-selection-heading-button { display: none !important; }
    .bible-chapter-heading:has(> .verse-selection-heading-button) { padding-inline: 0; }
    .verse-selection-bar, body.verse-selection-mode .verse-select-checkbox { display: none !important; }
    body.verse-selection-mode .verse-selection-enabled { padding-left: 0 !important; }
    body.verse-selection-mode .ostrog-chapter { padding-left: 26px !important; }
    body.verse-selection-mode .bible-mapped-chapter { padding-left: calc(var(--bible-number-width, 22px) + 6px) !important; }
    .bible-verse.is-verse-selected { background: none !important; box-shadow: none !important; }
}
