/* Verse resource: original-language analysis and passage dictionary. */
#scripture-viewer .scripture-original-dictionary {
    --od-bg: #ffffff;
    --od-bg-muted: #fafaf9;
    --od-bg-soft: #f5f5f4;
    --od-fg: #1c1917;
    --od-fg-muted: #57534e;
    --od-border: #d6d3d1;
    --od-border-soft: #e7e5e4;
    --od-accent: #92400e;
    --od-accent-bg: #fef3c7;
    --od-accent-border: #f59e0b;
    --od-focus: #2563eb;
    --od-primary-bg: #dcfce7;
    --od-primary-fg: #166534;
    --od-primary-border: #86efac;
    --od-supporting-bg: #fef3c7;
    --od-supporting-fg: #92400e;
    --od-supporting-border: #fcd34d;
    --od-unaligned-bg: #f5f5f4;
    --od-unaligned-fg: #57534e;
    --od-unaligned-border: #a8a29e;
    box-sizing: border-box;
    min-width: 0;
    color: var(--od-fg);
    background: var(--od-bg);
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

#scripture-viewer .scripture-original-dictionary *,
#scripture-viewer .scripture-original-dictionary *::before,
#scripture-viewer .scripture-original-dictionary *::after {
    box-sizing: border-box;
}

#scripture-viewer .scripture-original-dictionary [hidden] {
    display: none !important;
}

#scripture-viewer .scripture-original-dictionary__control-group button,
#scripture-viewer .scripture-original-dictionary__retry,
#scripture-viewer .scripture-original-dictionary__layer-open,
#scripture-viewer .scripture-original-dictionary__layer-close,
#scripture-viewer .scripture-original-dictionary__word-button,
#scripture-viewer .scripture-original-dictionary__examples,
#scripture-viewer .scripture-original-dictionary__term-link {
    min-height: 2.75rem;
    min-width: 2.75rem;
    border-radius: 0.5rem;
    font: inherit;
}

#scripture-viewer .scripture-original-dictionary__status {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.75rem 1rem 0;
    border: 1px solid var(--od-border-soft);
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    color: var(--od-fg-muted);
    background: var(--od-bg-muted);
    font-size: 0.875rem;
    line-height: 1.45;
}

#scripture-viewer .scripture-original-dictionary__status[data-state="error"] {
    border-color: #fca5a5;
    color: #991b1b;
    background: #fef2f2;
}

#scripture-viewer .scripture-original-dictionary__spinner {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    border: 2px solid var(--od-border);
    border-top-color: var(--od-accent);
    border-radius: 9999px;
    animation: scripture-original-dictionary-spin 0.8s linear infinite;
    will-change: transform;
}

@keyframes scripture-original-dictionary-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#scripture-viewer .scripture-original-dictionary__retry {
    margin-left: auto;
    border: 1px solid var(--od-accent-border);
    padding: 0.45rem 0.85rem;
    color: var(--od-accent);
    background: var(--od-accent-bg);
    font-weight: 800;
    cursor: pointer;
}

#scripture-viewer .scripture-original-dictionary__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--od-border-soft);
    background: var(--od-bg);
}

#scripture-viewer .scripture-original-dictionary__control-group {
    display: inline-flex;
    max-width: 100%;
    gap: 0.2rem;
    border: 0;
    border-radius: 0.65rem;
    padding: 0.2rem;
    background: var(--od-bg-soft);
}

#scripture-viewer .scripture-original-dictionary__control-group button {
    border: 0;
    padding: 0.45rem 0.75rem;
    color: var(--od-fg-muted);
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 800;
    cursor: pointer;
}

#scripture-viewer .scripture-original-dictionary__control-group button[aria-pressed="true"] {
    color: #ffffff;
    background: #292524;
}

#scripture-viewer .scripture-original-dictionary__layer-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin-inline-start: auto;
    border: 1px solid var(--od-accent-border);
    padding: 0.45rem 0.8rem;
    color: var(--od-accent);
    background: var(--od-accent-bg);
    font-size: 0.8125rem;
    font-weight: 850;
    white-space: nowrap;
    cursor: pointer;
}

#scripture-viewer .scripture-original-dictionary__layer-open:hover {
    border-color: var(--od-accent);
    filter: brightness(0.98);
}

#scripture-viewer .scripture-original-dictionary__table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    border-right: 1px solid var(--od-border-soft);
}

#scripture-viewer .scripture-original-dictionary__table {
    width: 100%;
    min-width: 58rem;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
}

#scripture-viewer .scripture-original-dictionary__table th,
#scripture-viewer .scripture-original-dictionary__table td {
    border-bottom: 1px solid var(--od-border-soft);
    padding: 0.65rem 0.7rem;
    text-align: left;
    vertical-align: top;
}

#scripture-viewer .scripture-original-dictionary__table th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--od-fg);
    background: var(--od-bg-soft);
    font-weight: 900;
    white-space: nowrap;
}

#scripture-viewer .scripture-original-dictionary__table-row:hover td {
    background: var(--od-bg-muted);
}

#scripture-viewer .scripture-original-dictionary__translation-cell {
    min-width: 9rem;
    font-weight: 750;
}

#scripture-viewer .scripture-original-dictionary__translation-cell small {
    display: block;
    margin-top: 0.25rem;
    color: var(--od-fg-muted);
    font-size: 0.72rem;
    font-weight: 500;
}

#scripture-viewer .scripture-original-dictionary__word-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--od-border);
    padding: 0.4rem 0.7rem;
    color: var(--od-fg);
    background: var(--od-bg);
    font-weight: 850;
    line-height: 1.25;
    cursor: pointer;
}

#scripture-viewer .scripture-original-dictionary__word-button[dir="rtl"] {
    font-family: "Noto Sans Hebrew", "Ezra SIL", serif;
    font-size: 1.05rem;
}

#scripture-viewer .scripture-original-dictionary__word-button[lang="grc"] {
    font-family: "Noto Serif", Georgia, serif;
    font-size: 1rem;
}

#scripture-viewer .scripture-original-dictionary__word-button:hover,
#scripture-viewer .scripture-original-dictionary__word-button.is-selected {
    border-color: var(--od-accent-border);
    color: var(--od-accent);
    background: var(--od-accent-bg);
}

#scripture-viewer .scripture-original-dictionary__role {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    border: 1px solid;
    border-radius: 9999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.6875rem;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
}

#scripture-viewer .scripture-original-dictionary__role--primary {
    border-color: var(--od-primary-border);
    color: var(--od-primary-fg);
    background: var(--od-primary-bg);
}

#scripture-viewer .scripture-original-dictionary__role--supporting {
    border-color: var(--od-supporting-border);
    color: var(--od-supporting-fg);
    background: var(--od-supporting-bg);
}

#scripture-viewer .scripture-original-dictionary__role--unaligned {
    border-color: var(--od-unaligned-border);
    color: var(--od-unaligned-fg);
    background: var(--od-unaligned-bg);
}

#scripture-viewer .scripture-original-dictionary__compact-list,
#scripture-viewer .scripture-original-dictionary__word-columns ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#scripture-viewer .scripture-original-dictionary__compact-list {
    display: grid;
    gap: 0.65rem;
    padding: 0.85rem;
}

#scripture-viewer .scripture-original-dictionary__compact-item,
#scripture-viewer .scripture-original-dictionary__word-card,
#scripture-viewer .scripture-original-dictionary__term-card {
    min-width: 0;
    border: 1px solid var(--od-border-soft);
    border-radius: 0.8rem;
    padding: 0.8rem;
    background: var(--od-bg);
    box-shadow: 0 1px 2px rgb(28 25 23 / 0.04);
}

#scripture-viewer .scripture-original-dictionary__compact-primary,
#scripture-viewer .scripture-original-dictionary__compact-secondary,
#scripture-viewer .scripture-original-dictionary__word-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

#scripture-viewer .scripture-original-dictionary__compact-secondary {
    margin-top: 0.5rem;
    color: var(--od-fg-muted);
    font-size: 0.75rem;
}

#scripture-viewer .scripture-original-dictionary__translation {
    flex: 1 1 8rem;
    color: var(--od-fg);
    font-weight: 800;
    overflow-wrap: anywhere;
}

#scripture-viewer .scripture-original-dictionary__strong,
#scripture-viewer .scripture-original-dictionary__count {
    color: var(--od-fg-muted);
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

#scripture-viewer .scripture-original-dictionary__compact-gloss,
#scripture-viewer .scripture-original-dictionary__word-meta,
#scripture-viewer .scripture-original-dictionary__word-gloss,
#scripture-viewer .scripture-original-dictionary__variants {
    margin: 0.5rem 0 0;
    color: var(--od-fg-muted);
    font-size: 0.8125rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

#scripture-viewer .scripture-original-dictionary__layer {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 1rem;
}

#scripture-viewer .scripture-original-dictionary__layer-backdrop {
    position: absolute;
    inset: 0;
    background: rgb(15 23 42 / 0.58);
    backdrop-filter: blur(2px);
}

#scripture-viewer .scripture-original-dictionary__layer-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(42rem, calc(100vw - 2rem));
    max-height: min(78vh, 48rem);
    overflow: hidden;
    border: 1px solid var(--od-border);
    border-radius: 1rem;
    color: var(--od-fg);
    background: var(--od-bg);
    box-shadow: 0 24px 70px rgb(15 23 42 / 0.35);
}

#scripture-viewer .scripture-original-dictionary__layer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--od-border-soft);
    padding: 1rem 1rem 0.9rem;
    background: var(--od-bg);
}

#scripture-viewer .scripture-original-dictionary__layer-header h3 {
    margin: 0;
    color: var(--od-fg);
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.4;
}

#scripture-viewer .scripture-original-dictionary__layer-header .scripture-original-dictionary__summary {
    margin: 0.3rem 0 0;
}

#scripture-viewer .scripture-original-dictionary__layer-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--od-border);
    padding: 0;
    color: var(--od-fg-muted);
    background: var(--od-bg);
    cursor: pointer;
}

#scripture-viewer .scripture-original-dictionary__layer-close:hover {
    border-color: var(--od-accent-border);
    color: var(--od-accent);
    background: var(--od-accent-bg);
}

#scripture-viewer .scripture-original-dictionary__dictionary {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem;
}

#scripture-viewer .scripture-original-dictionary__summary {
    margin: 0 0 0.85rem;
    color: var(--od-fg-muted);
    font-size: 0.875rem;
    font-weight: 700;
}

#scripture-viewer .scripture-original-dictionary__word-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

#scripture-viewer .scripture-original-dictionary__word-columns > section {
    min-width: 0;
}

#scripture-viewer .scripture-original-dictionary__word-columns :is(h3, h4) {
    margin: 0 0 0.65rem;
    color: var(--od-fg);
    font-size: 0.95rem;
    font-weight: 900;
}

#scripture-viewer .scripture-original-dictionary__word-columns ul {
    display: grid;
    gap: 0.65rem;
}

#scripture-viewer .scripture-original-dictionary__word-header .scripture-original-dictionary__count {
    margin-left: auto;
}

#scripture-viewer .scripture-original-dictionary__examples,
#scripture-viewer .scripture-original-dictionary__term-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--od-border);
    padding: 0.4rem 0.7rem;
    color: var(--od-accent);
    background: var(--od-bg);
    font-size: 0.78rem;
    font-weight: 850;
    text-decoration: none;
    cursor: pointer;
}

#scripture-viewer .scripture-original-dictionary__term-link {
    justify-content: flex-start;
    font-size: 0.9rem;
}

#scripture-viewer .scripture-original-dictionary__examples:hover,
#scripture-viewer .scripture-original-dictionary__term-link:hover {
    border-color: var(--od-accent-border);
    background: var(--od-accent-bg);
    text-decoration: underline;
}

#scripture-viewer .scripture-original-dictionary__empty {
    color: var(--od-fg-muted);
    font-size: 0.875rem;
}

#scripture-viewer .scripture-original-dictionary :is(button, a):focus-visible {
    outline: 3px solid var(--od-focus);
    outline-offset: 2px;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary {
    --od-bg: #111827;
    --od-bg-muted: #182231;
    --od-bg-soft: #1f2937;
    --od-fg: #f8fafc;
    --od-fg-muted: #cbd5e1;
    --od-border: #475569;
    --od-border-soft: #334155;
    --od-accent: #fde68a;
    --od-accent-bg: #422f12;
    --od-accent-border: #f59e0b;
    --od-focus: #7dd3fc;
    --od-primary-bg: #123d2b;
    --od-primary-fg: #bbf7d0;
    --od-primary-border: #22c55e;
    --od-supporting-bg: #422f12;
    --od-supporting-fg: #fde68a;
    --od-supporting-border: #f59e0b;
    --od-unaligned-bg: #293548;
    --od-unaligned-fg: #e2e8f0;
    --od-unaligned-border: #64748b;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary__control-group button[aria-pressed="true"] {
    color: #fde68a;
    background: #2a2416;
    box-shadow: inset 0 0 0 1px #92400e;
}

/*
 * The resource sheet is a dark reading surface, so selected controls should
 * remain within that luminance range. A warm keyline and text carry the
 * selected state without the glare of a near-white tile.
 */
#scripture-viewer[data-scripture-theme="dark"] .scripture-verse-resources-sheet {
    border-color: #334155;
    background: #101827;
    color: #f8fafc;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-verse-resource-tab[aria-selected="true"],
#scripture-viewer[data-scripture-theme="dark"] .scripture-ow-view-mode[aria-selected="true"] {
    color: #fde68a;
    background: #2a2416;
    box-shadow: inset 0 0 0 1px #92400e;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-verse-resource-tab[aria-selected="false"],
#scripture-viewer[data-scripture-theme="dark"] .scripture-ow-view-mode[aria-selected="false"] {
    color: #cbd5e1;
    background: transparent;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-verse-resource-tab[aria-selected="false"]:hover,
#scripture-viewer[data-scripture-theme="dark"] .scripture-ow-view-mode[aria-selected="false"]:hover {
    color: #f8fafc;
    background: #273449;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-cards {
    border-bottom-color: #334155;
    background: #0f172a;
    scrollbar-color: #64748b #1e293b;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-cards::-webkit-scrollbar {
    height: 0.55rem;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-cards::-webkit-scrollbar-track {
    background: #1e293b;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-cards::-webkit-scrollbar-thumb {
    border: 2px solid #1e293b;
    border-radius: 9999px;
    background: #64748b;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-card {
    border-color: #475569;
    background: #1e293b;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-card:hover {
    border-color: #64748b;
    background: #273449;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-card.is-active {
    border-color: #f59e0b;
    background: #2a2416;
    box-shadow: 0 0 0 1px rgb(245 158 11 / 0.18);
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-card.is-active .ow-ko,
#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-card.is-active .ow-surface {
    color: #fff7ed;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-card.is-active .ow-reading {
    color: #cbd5e1;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary .scripture-ow-card.is-active .ow-helper {
    color: #fbbf24;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary [data-ow-detail] .divide-stone-100 > :not([hidden]) ~ :not([hidden]) {
    border-color: #334155 !important;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary [data-ow-detail] .text-stone-400 {
    color: #94a3b8 !important;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary [data-ow-detail] [data-open-original-search] {
    border-color: #b45309 !important;
    color: #fde68a !important;
    background: #2a2416 !important;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary [data-ow-detail] [data-open-original-search] .text-amber-700 {
    color: #fbbf24 !important;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary [data-ow-detail] [data-open-original-search]:hover {
    border-color: #f59e0b !important;
    background: #3a2b17 !important;
}

#scripture-viewer[data-scripture-theme="dark"] .scripture-original-dictionary__status[data-state="error"] {
    border-color: #ef4444;
    color: #fecaca;
    background: #3f171b;
}

@media (min-width: 1024px) {
    #scripture-viewer .scripture-verse-resources-sheet[data-active-resource-tab="original"][data-original-dictionary-density="table"]:not([data-original-dictionary-layer="open"])[open] {
        width: min(92vw, 78rem);
    }

    #scripture-viewer .scripture-original-dictionary__compact-list {
        display: none !important;
    }

    #scripture-viewer .scripture-original-dictionary__word-columns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1023.98px) {
    #scripture-viewer .scripture-original-dictionary__table-wrap {
        display: none !important;
    }

    #scripture-viewer .scripture-original-dictionary__compact-list:not([hidden]) {
        display: grid;
    }

    #scripture-viewer .scripture-original-dictionary__controls {
        align-items: stretch;
    }

    #scripture-viewer .scripture-original-dictionary__control-group {
        flex: 1 1 auto;
    }

    #scripture-viewer .scripture-original-dictionary__control-group button {
        flex: 1 1 auto;
    }

    #scripture-viewer .scripture-original-dictionary__layer-open {
        flex: 1 1 100%;
        margin-inline-start: 0;
    }
}

@media (max-width: 479.98px) {
    #scripture-viewer .scripture-original-dictionary__controls {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    #scripture-viewer .scripture-original-dictionary__layer {
        place-items: end center;
        padding: 0.75rem;
    }

    #scripture-viewer .scripture-original-dictionary__layer-dialog {
        width: calc(100vw - 1.5rem);
        max-height: min(84vh, 48rem);
        border-radius: 1rem;
    }

    #scripture-viewer .scripture-original-dictionary__dictionary {
        padding: 0.75rem;
    }

    #scripture-viewer .scripture-original-dictionary__status {
        margin-left: 0.75rem;
        margin-right: 0.75rem;
    }

    #scripture-viewer .scripture-original-dictionary__compact-list {
        padding: 0.75rem;
    }

    #scripture-viewer .scripture-original-dictionary__word-header .scripture-original-dictionary__count {
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    #scripture-viewer .scripture-original-dictionary__spinner {
        animation-duration: 1.8s;
    }
}
