/* Hide icon buttons until font is loaded (JS adds .icons-ready) */
.lang-wrapper,
.help-toggle,
.settings-wrapper,
.theme-toggle,
.share-toggle,
.feature-close {
    opacity: 0;
    transition: opacity 0.15s;
}
.icons-ready .lang-wrapper,
.icons-ready .help-toggle,
.icons-ready .settings-wrapper,
.icons-ready .theme-toggle,
.icons-ready .share-toggle,
.icons-ready .feature-close {
    opacity: 1;
}

/* === CSS Variables (Light Theme) === */
:root {
    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Type scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Radius scale */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Color palette — Olive & Stone (Mediterranean/Levantine) */
    --bg-page: #f7f6f1;
    --bg-card: #ffffff;
    --bg-header: #3d4a3c;
    --bg-panel-header: #edece6;
    --bg-th: #f3f2ec;
    --bg-input: #ffffff;
    --bg-ref: #e8e7df;
    --bg-ref-hover: #dddccf;
    --bg-autocomplete: #ffffff;
    --bg-ac-hover: #edece6;
    --bg-modal: #ffffff;
    --bg-tt-cell: rgba(255, 255, 255, 0.6);
    --bg-tt-table: rgba(80, 90, 60, 0.04);
    --bg-stat: #ffffff;
    --bg-highlight: #f5f0d8;
    --text-primary: #1c1e1a;
    --text-secondary: #555a50;
    --text-muted: #7a7e74;
    --text-gloss: #484c44;
    --text-translit: #555a50;
    --accent: #6b7a5e;
    --accent-dark: #3d4a3c;
    --accent-gold: #a89048;
    --bg-feature-tabs: #3d4a3c;
    --border: #dddcd4;
    --border-light: #eae9e2;
    --border-input: #c4c3ba;
    --shadow: rgba(0,0,0,0.06);
    --shadow-modal: rgba(0, 0, 0, 0.2);
    --overlay: rgba(0, 0, 0, 0.5);
    --error-bg: #fde8e8;
    --error-text: #c53030;
    --highlight-border: #a89048;
    --syriac-font: 'Noto Sans Syriac', 'Estrangelo Edessa', serif;
}

/* === Syriac Script Variants === */
[data-syriac-font="eastern"] {
    --syriac-font: 'Noto Sans Syriac Eastern', 'Estrangelo Edessa', serif;
}
[data-syriac-font="western"] {
    --syriac-font: 'Noto Sans Syriac Western', 'Estrangelo Edessa', serif;
}

/* === Dark Theme === */
[data-theme="dark"] {
    --bg-page: #12140f;
    --bg-card: #1a1d18;
    --bg-header: #242820;
    --bg-panel-header: #222620;
    --bg-th: #1e2218;
    --bg-input: #1a1d18;
    --bg-ref: #262a20;
    --bg-ref-hover: #323828;
    --bg-autocomplete: #1a1d18;
    --bg-ac-hover: #262a20;
    --bg-modal: #1a1d18;
    --bg-tt-cell: rgba(30, 35, 25, 0.6);
    --bg-tt-table: rgba(90, 110, 60, 0.10);
    --bg-stat: #1a1d18;
    --bg-highlight: #323610;
    --text-primary: #e2e4dc;
    --text-secondary: #a0a498;
    --text-muted: #727668;
    --text-gloss: #b0b4a8;
    --text-translit: #a0a498;
    --accent: #9aac84;
    --accent-dark: #b8cca0;
    --accent-gold: #c4a84c;
    --bg-feature-tabs: #2a3228;
    --border: #323630;
    --border-light: #262a22;
    --border-input: #444840;
    --shadow: rgba(0,0,0,0.3);
    --shadow-modal: rgba(0, 0, 0, 0.6);
    --overlay: rgba(0, 0, 0, 0.7);
    --error-bg: #3a1818;
    --error-text: #f08080;
    --highlight-border: #a89048;
    --viz-outlier-text: #D4A832;
    --viz-bridge-text: #D4A832;
}

/* === Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.65;
    font-size: var(--text-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 999;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
}
.skip-link:focus {
    top: 0.5rem;
}

/* === Header === */
header {
    text-align: center;
    padding: var(--space-lg) 0 var(--space-md);
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--space-xl);
}

.nav-logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    margin-right: auto;
}

.nav-logo img {
    height: 38px;
    width: auto;
}

header h1 {
    font-size: var(--text-3xl);
    color: var(--accent-dark);
    margin-bottom: var(--space-xs);
    font-weight: 700;
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-secondary);
    font-size: var(--text-lg);
}

/* Sticky header */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--bg-page);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: var(--space-sm) clamp(1rem, 3vw, 2rem);
    gap: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Settings button + dropdown */
.settings-wrapper {
    position: relative;
}

.settings-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px var(--shadow), 0 1px 3px rgba(0,0,0,0.04);
    padding: var(--space-sm) var(--space-md);
    min-width: 190px;
    z-index: 300;
}

.settings-dropdown.open {
    display: block;
}

.settings-label {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding: 0 6px;
}

.settings-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    color: var(--text-primary);
    text-align: left;
}

.settings-option:hover {
    background: var(--bg-ref);
}

.settings-option.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* Tooltips */
.stat-item[data-tooltip] {
    position: relative;
    cursor: help;
}

.stat-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-dark);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.78em;
    font-weight: normal;
    font-style: normal;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 50;
}

.stat-item[data-tooltip]:hover::after {
    opacity: 1;
}

.lang-toggle, .theme-toggle, .help-toggle, .settings-toggle, .share-toggle {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 7px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.lang-toggle:hover, .theme-toggle:hover, .help-toggle:hover, .settings-toggle:hover, .share-toggle:hover {
    background: var(--bg-ref);
    color: var(--accent);
    border-color: var(--accent);
}

.lang-toggle .material-symbols-outlined,
.theme-toggle .material-symbols-outlined,
.help-toggle .material-symbols-outlined,
.settings-toggle .material-symbols-outlined,
.share-toggle .material-symbols-outlined {
    font-size: 22px;
}

.lang-wrapper {
    position: relative;
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px var(--shadow), 0 1px 3px rgba(0,0,0,0.04);
    padding: 6px;
    min-width: 60px;
    z-index: 300;
}

.lang-dropdown.open {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lang-option {
    display: block;
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85em;
    font-weight: 600;
    text-align: center;
    transition: background 0.15s;
}

.lang-option:hover {
    background: var(--bg-hover, #f0f0f0);
}

.lang-option.active {
    background: var(--accent);
    color: #fff;
}


/* === Root of the Day === */
.rotd-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--accent-gold, #b8860b);
}
[dir="rtl"] .rotd-card {
    border-left: none;
    border-right: 3px solid var(--accent-gold, #b8860b);
}
.rotd-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-gold, #b8860b);
    font-weight: 600;
}
.rotd-icon { font-size: 18px !important; }
.rotd-root {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.rotd-syriac {
    font-family: var(--syriac-font, 'Noto Sans Syriac'), serif;
    font-size: 1.6rem;
    color: var(--text-primary);
}
.rotd-key {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.rotd-gloss {
    font-size: 0.95rem;
    color: var(--text-secondary);
}
.rotd-sabor, .rotd-lost {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    line-height: 1.5;
}
.rotd-cognates {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.6rem 0;
}
.rotd-cognate {
    font-size: 0.85rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--bg-page);
}
.rotd-cognate.heb { border-left: 2px solid #4a90d9; }
.rotd-cognate.arb { border-left: 2px solid #d94a4a; }
[dir="rtl"] .rotd-cognate.heb { border-left: none; border-right: 2px solid #4a90d9; }
[dir="rtl"] .rotd-cognate.arb { border-left: none; border-right: 2px solid #d94a4a; }
.rotd-cognate small {
    color: var(--text-secondary);
    margin-left: 0.3rem;
}
.rotd-cta {
    display: inline-block;
    margin-top: 0.3rem;
    font-size: 0.85rem;
    color: var(--accent-gold, #b8860b);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
}
.rotd-cta:hover { opacity: 0.7; }
.rotd-readmore {
    color: var(--accent-gold, #b8860b);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.85rem;
}
.rotd-readmore:hover { opacity: 0.7; }

/* === Search form === */
.search-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-xl);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px var(--shadow);
    margin-bottom: var(--space-2xl);
}
.search-section-hero {
    padding: 0;
    overflow: hidden;
}
.search-section-hero .search-tabs {
    background: var(--bg-feature-tabs);
    padding: 0 var(--space-md);
    margin-bottom: 0;
}
.search-section-hero .search-panel {
    padding: var(--space-lg) var(--space-xl);
}
.search-section-hero .home-cta-row {
    padding: 0 var(--space-xl) var(--space-lg);
}

.search-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.search-tabs::-webkit-scrollbar { display: none; }

.search-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.search-tab:hover {
    color: var(--accent);
}

.search-tab.active {
    color: var(--accent-dark);
    border-bottom-color: var(--accent);
}

/* Hero search section overrides */
.search-section-hero .search-tabs {
    border-bottom: none;
}
.search-section-hero .search-tab {
    color: rgba(255,255,255,0.6);
}
.search-section-hero .search-tab:hover {
    color: rgba(255,255,255,0.9);
}
.search-section-hero .search-tab.active {
    color: #ffffff;
    border-bottom-color: var(--accent-gold);
}

.search-panel {
    /* panels are toggled via JS display */
}

/* === Home CTA buttons === */
.home-cta-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.home-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border: 2px solid var(--accent);
    border-radius: 24px;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.95em;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.home-cta-btn:hover {
    background: var(--accent);
    color: #fff;
}

.home-cta-btn .material-symbols-outlined {
    font-size: 18px;
}

/* === Feature showcase === */
.feature-showcase {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px var(--shadow);
    margin-bottom: var(--space-2xl);
    overflow: hidden;
}

.feature-tabs {
    display: flex;
    gap: 0;
    background: var(--bg-feature-tabs);
    border-bottom: none;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 var(--space-md);
}
.feature-tabs::-webkit-scrollbar { display: none; }

.feature-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    background: none;
    border: none;
    flex-shrink: 0;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.92em;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    transition: color 0.15s, border-color 0.15s;
}

.feature-tab:hover {
    color: rgba(255,255,255,0.9);
}

.feature-tab.active {
    color: #ffffff;
    border-bottom-color: var(--accent-gold);
}

.feature-tab .material-symbols-outlined {
    font-size: 18px;
}

.feature-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: color 0.15s;
}

.feature-close:hover {
    color: #ffffff;
}

.feature-panel {
    padding: 16px var(--space-xl) var(--space-lg);
    font-size: 0.93em;
    line-height: 1.65;
    color: var(--text-secondary);
}

.feature-cta {
    display: inline-block;
    margin-top: 8px;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s;
}

.feature-cta:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

.feature-reopen-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--text-muted);
    font-size: 0.85em;
    text-decoration: none;
    transition: color 0.15s;
}

.feature-reopen-link:hover {
    color: var(--accent);
}

/* Viz view tabs (Grafo / Ficha) */
.viz-view-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0;
}
.viz-view-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: -2px;
}
.viz-view-tab:hover {
    color: var(--text-primary);
    background: var(--bg-ref);
}
.viz-view-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}
.viz-view-tab .material-symbols-outlined {
    font-size: 20px;
}

/* Root Card (Ficha) */
.root-ficha {
    padding: 24px 20px;
}
.ficha-section {
    margin-bottom: 28px;
}
.ficha-section:last-child {
    margin-bottom: 0;
}
.cite-highlight {
    background: rgba(107, 122, 94, 0.2);
    color: var(--accent-dark);
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 700;
}
[data-theme="dark"] .cite-highlight {
    background: rgba(154, 172, 132, 0.2);
    color: var(--accent-gold);
}
.ficha-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 12px 0;
}
.ficha-section-title .material-symbols-outlined {
    font-size: 20px;
    color: var(--accent);
}
.ficha-root-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}
.ficha-root-syriac {
    font-family: var(--syriac-font);
    font-size: 2em;
    font-weight: 600;
    color: var(--accent);
}
.ficha-root-translit {
    font-size: 1.1em;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.05em;
}
.ficha-semantic-text {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    font-style: italic;
}
.ficha-citation-original {
    font-family: var(--syriac-font);
    font-size: 1.45em;
    line-height: 1.8;
    direction: rtl;
    text-align: right;
    color: var(--text-primary);
    padding: 10px 16px 0;
    border-left: 3px solid var(--accent);
    background: var(--bg-ref);
    border-radius: 0 8px 0 0;
}
.ficha-citation-translit {
    font-size: 1.05em;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 4px 16px;
    border-left: 3px solid var(--accent);
    background: var(--bg-ref);
    font-style: italic;
}
.ficha-citation {
    margin: 0 0 8px 0;
    padding: 8px 16px 12px;
    border-left: 3px solid var(--accent);
    background: var(--bg-ref);
    border-radius: 0 0 8px 0;
    font-size: 0.95em;
    line-height: 1.6;
    color: var(--text-primary);
    font-style: italic;
}
.ficha-citation-note {
    font-size: 0.85em;
    font-style: italic;
    color: var(--accent);
    margin-top: 6px;
    padding: 6px 10px;
    border-left: 3px solid var(--accent);
    background: rgba(107, 122, 94, 0.06);
    border-radius: 0 4px 4px 0;
}
[data-theme="dark"] .ficha-citation-note {
    background: rgba(154, 172, 132, 0.1);
}
.ficha-citation-ref {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85em;
    color: var(--text-secondary);
}
.ficha-read-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.ficha-read-link:hover {
    text-decoration: underline;
}
.ficha-sisters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.ficha-sister {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    min-width: 100px;
}
.ficha-sister:hover {
    border-color: var(--accent);
    background: var(--bg-ref);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.ficha-sister-root {
    font-weight: 600;
    font-size: 1em;
}
.ficha-sister-gloss {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-top: 2px;
}
.ficha-sister-shared {
    font-size: 0.7em;
    color: var(--accent);
    font-weight: 600;
    margin-top: 4px;
}
.ficha-sisters-empty {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}
/* Translation degradation — ¿Qué se perdió? */
.ficha-degradation-chain {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0 16px;
}
.deg-step-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 120px;
    max-width: 220px;
}
.deg-step {
    border-radius: 10px;
    padding: 12px 14px;
    text-align: center;
    width: 100%;
}
.deg-word {
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 2px;
}
.deg-translit {
    font-size: 0.9em;
    opacity: 0.85;
    font-style: italic;
    margin-bottom: 6px;
}
.deg-range {
    font-size: 0.78em;
    line-height: 1.4;
    opacity: 0.9;
}
.deg-aramaic {
    background: #3d4a3c;
    color: #fff;
}
.deg-aramaic .deg-word {
    font-family: var(--syriac-font);
}
.deg-greek {
    background: #5c6b52;
    color: #fff;
}
.deg-modern {
    background: var(--bg-highlight);
    color: var(--text-primary);
    border: 2px solid var(--border);
}
.deg-label {
    font-size: 0.72em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
    font-weight: 600;
}
.deg-arrow-wrap {
    display: flex;
    align-items: center;
    padding-top: 20px;
}
.deg-arrow {
    font-size: 1.5em;
    color: var(--text-secondary);
    font-weight: 300;
}
.ficha-degradation-lost {
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.6;
    padding: 12px 16px;
    border-left: 3px solid var(--accent-gold);
    background: var(--bg-highlight);
    border-radius: 0 8px 8px 0;
    font-size: 0.92em;
}

/* Compact degradation in word modal */
.modal-degradation {
    margin: 10px 0 14px;
    padding: 10px 14px;
    background: var(--bg-highlight, #f5f0e8);
    border-radius: var(--radius-md);
    border-left: 3px solid #483D8B;
}
.modal-deg-chain {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.modal-deg-step {
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 500;
}
.modal-deg-aramaic {
    background: #3d4a3c;
    color: #fff;
}
.modal-deg-aramaic .syriac,
.modal-deg-aramaic {
    font-family: var(--syriac-font);
}
.modal-deg-greek {
    background: #5c6b52;
    color: #fff;
}
.modal-deg-modern {
    background: var(--border);
    color: var(--text-primary);
}
.modal-deg-arrow {
    color: var(--text-secondary);
    font-size: 1.1em;
}
.modal-deg-range {
    font-size: 0.82em;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 4px;
}
.modal-deg-lost {
    font-size: 0.85em;
    color: var(--text-primary);
    line-height: 1.5;
}
.modal-deg-more {
    font-size: 0.9em;
    color: var(--accent);
    text-decoration: none;
    font-style: italic;
}
.modal-deg-more:hover {
    text-decoration: underline;
}

/* Dark mode overrides for degradation */
[data-theme="dark"] .deg-aramaic {
    background: #4a5a46;
}
[data-theme="dark"] .deg-greek {
    background: #5a4fb0;
}
[data-theme="dark"] .deg-modern {
    background: var(--bg-highlight, #4a3a10);
    color: var(--text-primary, #e8dcc8);
}
[data-theme="dark"] .ficha-degradation-lost {
    background: var(--bg-highlight);
    color: var(--text-primary);
    border-left-color: var(--accent-gold);
}
[data-theme="dark"] .modal-degradation {
    background: var(--bg-highlight);
    border-left-color: var(--accent-gold);
}
[data-theme="dark"] .modal-deg-modern {
    background: var(--border);
    color: var(--text-primary);
}

.ficha-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ficha-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}
.ficha-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ficha-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.ficha-table tr:last-child td {
    border-bottom: none;
}
.ficha-word {
    display: block;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 2px;
}
.ficha-word-syriac { font-family: var(--syriac-font); }
.ficha-word-hebrew { font-family: 'Noto Sans Hebrew', serif; }
.ficha-word-arabic { font-family: 'Noto Sans Arabic', serif; direction: rtl; }
.ficha-translit {
    display: block;
    font-size: 0.85em;
    color: var(--text-secondary);
}
.ficha-meaning {
    display: block;
    font-size: 0.82em;
    color: var(--text-primary);
    margin-top: 2px;
}

.search-section label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.search-row .autocomplete-wrapper {
    flex: 1;
}
.search-row input[type="text"] {
    padding: 12px 16px;
    font-size: 1.1em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    flex: 1;
}
.search-row input[type="text"]:focus {
    border-color: var(--accent);
    outline: none;
}

.search-row button {
    padding: 12px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
}

.search-row button:hover {
    background: var(--accent-dark);
}
[data-theme="dark"] .search-row button {
    background: var(--bg-feature-tabs);
}
[data-theme="dark"] .search-row button:hover {
    background: #364230;
}

.search-help {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.translit-toggle {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    margin-left: 6px;
    font-size: 0.95em;
}

.translit-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
    margin-top: 10px;
    padding: 12px;
    background: var(--bg-tt-table);
    border-radius: var(--radius-md);
    border: 1px solid rgba(139, 69, 19, 0.15);
}

.tt-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    border-radius: 4px;
    background: var(--bg-tt-cell);
}

.tt-syriac {
    font-family: var(--syriac-font);
    font-size: 1.3em;
    direction: rtl;
}

.tt-latin {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--accent);
    margin-top: 2px;
}

.translit-cell {
    line-height: 1.4;
}

.translit-academic {
    font-style: italic;
}

.translit-simple {
    font-size: 0.85em;
    color: var(--text-translit);
}

.gloss-cell {
    font-size: 0.9em;
    color: var(--text-gloss);
    font-style: italic;
    max-width: 200px;
}

.stem-badge {
    display: inline-block;
    font-size: 0.75em;
    font-style: normal;
    background: var(--bg-ref);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    vertical-align: middle;
    white-space: nowrap;
}

/* === Error message === */
.error {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid var(--error-text);
}

/* === Results === */
.results-section {
    margin-bottom: 30px;
    scroll-margin-top: 70px;
}

.root-header {
    background: var(--bg-header);
    color: #fff;
    padding: 15px 20px 12px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.root-header-top {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}

.root-header .root-syriac {
    font-size: 2.2em;
    direction: rtl;
    font-family: var(--syriac-font);
}

.root-header .root-latin {
    font-size: 1.4em;
    font-family: monospace;
    letter-spacing: 2px;
    text-transform: uppercase;
}

td .root-latin {
    font-family: monospace;
    font-size: 0.85em;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-left: 6px;
}

.root-meaning {
    font-size: 1.15em;
    opacity: 0.9;
    font-style: italic;
    margin-bottom: 12px;
}

.root-header-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-btn {
    display: inline-block;
    padding: 6px 14px;
    background: var(--accent-gold, #8b4513);
    color: #fff;
    border: 1px solid var(--accent-gold, #8b4513);
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85em;
    transition: background 0.15s, opacity 0.15s;
}

.nav-btn:hover {
    opacity: 0.85;
}

/* === Section panels === */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    margin-bottom: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.panel:not(:first-child) {
    border-radius: var(--radius-lg);
}

.panel-header {
    background: var(--bg-panel-header);
    padding: var(--space-md) var(--space-lg);
    font-weight: 600;
    font-size: var(--text-lg);
    color: var(--accent-dark);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel:not(:first-child) .panel-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel-body {
    padding: var(--space-md) var(--space-lg);
    overflow-x: auto;
}

/* === Tables === */
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    background: var(--bg-th);
    font-weight: 600;
    color: var(--accent-dark);
}

/* === Script text styling === */
.syriac {
    direction: rtl;
    font-family: var(--syriac-font);
    font-size: 1.3em;
    unicode-bidi: bidi-override;
}

.hebrew {
    direction: rtl;
    font-family: 'Noto Sans Hebrew', 'David', 'Times New Roman', serif;
    font-size: 1.2em;
    unicode-bidi: bidi-override;
}

.arabic {
    direction: rtl;
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Times New Roman', serif;
    font-size: 1.2em;
    unicode-bidi: bidi-override;
}

.translit {
    font-family: monospace;
    color: var(--text-translit);
    font-size: 0.95em;
}

.refs {
    font-size: 0.85em;
    color: var(--text-gloss);
    max-height: 100px;
    overflow-y: auto;
}

.ref-link {
    display: inline-block;
    background: var(--bg-ref);
    padding: 2px 6px;
    border-radius: 3px;
    margin: 2px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.15s;
}

.ref-link:hover {
    background: var(--bg-ref-hover);
    color: var(--accent-dark);
}

/* Export button */
.export-btn {
    float: right;
    background: var(--bg-ref);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 0.8em;
    color: var(--text-body);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s;
}

.export-btn:hover {
    background: var(--accent);
    color: #fff;
}

.export-btn .material-symbols-outlined {
    font-size: 16px;
}

/* Book filter */
.book-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px;
}

.book-filter-label {
    font-size: 0.85em;
    color: var(--text-muted);
    white-space: nowrap;
}

.book-filter select {
    flex: 1;
    max-width: 300px;
    padding: 4px 8px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-body);
    font-size: 0.9em;
}

.ref-link.ref-expanded {
    background: var(--accent);
    color: #fff;
}

.ref-more {
    display: inline-block;
    padding: 2px 6px;
    margin: 2px;
    font-size: 0.9em;
    color: var(--text-muted);
}

/* KWIC Concordance */
.kwic-line {
    display: block;
    margin: 6px 0;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    direction: rtl;
    text-align: right;
    line-height: 1.8;
    position: relative;
}

.kwic-before, .kwic-after {
    color: var(--text-muted);
    font-size: 1.1em;
}

.kwic-word {
    color: var(--accent-dark);
    font-weight: 700;
    font-size: 1.15em;
    background: rgba(107, 122, 94, 0.12);
    padding: 2px 4px;
    border-radius: 3px;
}

.kwic-translation {
    display: block;
    direction: ltr;
    text-align: left;
    font-style: italic;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kwic-actions {
    display: flex;
    gap: 10px;
    direction: ltr;
    margin-top: 4px;
}

.kwic-action {
    font-size: 0.8em;
    color: var(--accent);
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 3px;
    background: var(--bg-ref);
    cursor: pointer;
}

.kwic-action:hover {
    background: var(--accent);
    color: #fff;
}

.count-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.85em;
}

.no-results {
    color: var(--text-secondary);
    font-style: italic;
    padding: 10px 0;
}

/* === Stats bar === */
.stats-bar {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.stat-item {
    background: var(--bg-stat);
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 1px 4px var(--shadow);
    text-align: center;
}

.stat-item .stat-value {
    font-size: 1.4em;
    font-weight: bold;
    color: var(--accent);
}

.stat-item .stat-label {
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* === Verse Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-modal);
    border-radius: var(--radius-lg);
    padding: 0 var(--space-2xl) var(--space-2xl);
    max-width: 720px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 40px var(--shadow-modal), 0 2px 8px rgba(0,0,0,0.06);
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-sticky-header {
    position: sticky;
    top: 0;
    background: var(--bg-modal);
    z-index: 15;
    padding-top: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: 0 4px 8px -4px rgba(0,0,0,0.1);
}
.modal-sticky-header::before {
    content: '';
    display: block;
    position: absolute;
    top: -200px;
    left: -3rem;
    right: -3rem;
    height: 200px;
    background: var(--bg-modal);
}

.modal-close {
    position: absolute;
    top: var(--space-lg);
    right: 0;
    background: none;
    border: none;
    font-size: 1.8em;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    z-index: 20;
    padding: 0 2px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-copy {
    position: absolute;
    top: calc(var(--space-lg) + 2px);
    right: 32px;
    background: none;
    border: none;
    font-size: 1.2em;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    z-index: 20;
}
.modal-copy:hover {
    color: var(--accent);
}

/* Share modal */
.share-modal-content {
    max-width: 400px;
    text-align: center;
    padding: 30px 35px 25px;
}

.share-modal-title {
    font-size: 1.2em;
    color: var(--accent-dark);
    margin-bottom: 20px;
}

.share-qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.share-qr-wrap canvas,
.share-qr-wrap img {
    border-radius: var(--radius-md);
    border: 3px solid var(--border);
    padding: 8px;
    background: #fff;
}

.share-qr-hint {
    margin-top: 10px;
    font-size: 0.85em;
    color: var(--text-muted);
    font-style: italic;
}

.share-url-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.share-url-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.85em;
    font-family: monospace;
}

.share-copy-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.share-copy-btn:hover {
    background: var(--accent-dark);
}

.share-copy-btn .material-symbols-outlined {
    font-size: 20px;
}

.modal-ref {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--accent-dark);
    margin: 0;
    padding: 0 60px var(--space-sm) 0;
    border-bottom: 2px solid var(--bg-panel-header);
}

.modal-ref-syriac {
    font-family: var(--syriac-font);
    font-size: 1.5em;
    vertical-align: middle;
    direction: rtl;
    unicode-bidi: isolate;
}

.modal-syriac {
    direction: rtl;
    font-family: var(--syriac-font);
    font-size: 1.6em;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: right;
    unicode-bidi: bidi-override;
}

.modal-translit {
    font-family: monospace;
    font-size: 1.05em;
    color: var(--text-translit);
    line-height: 1.6;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.modal-translation {
    font-size: 0.95em;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--border-light);
    font-style: italic;
}

.modal-translation:empty {
    display: none;
}

.modal-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-style: italic;
}

/* Highlighted word in modal */
.modal-syriac .hl,
.modal-translit .hl {
    background: var(--bg-highlight);
    color: var(--accent);
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
    border-bottom: 2px solid var(--highlight-border);
}

/* === Modal navigation arrows === */
.modal-nav-arrow {
    display: block;
    margin: 0 auto;
    background: none;
    border: none;
    font-size: 1.4em;
    cursor: pointer;
    color: var(--accent);
    padding: 6px 24px;
    transition: color 0.15s, opacity 0.15s;
}
.modal-nav-arrow:hover:not(:disabled) {
    color: var(--text-primary);
}
.modal-nav-arrow:disabled {
    opacity: 0.25;
    cursor: default;
}

/* Verse blocks inside modal */
.verse-block {
    margin: 10px 0;
}
.verse-separator {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

/* === Autocomplete === */
.autocomplete-wrapper {
    position: relative;
    flex: 1;
}

.autocomplete-wrapper input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.2em;
    border: 2px solid var(--border-input);
    border-radius: 6px;
    font-family: monospace;
    letter-spacing: 2px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.autocomplete-wrapper input[type="text"]:focus {
    border-color: var(--accent);
    outline: none;
}

/* Cognate word search input */
.cognate-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.1em;
    border: 2px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.cognate-input:focus {
    border-color: var(--accent);
    outline: none;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-autocomplete);
    border: 1px solid var(--border-input);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.autocomplete-list:empty {
    display: none;
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:hover {
    background: var(--bg-ac-hover);
}

.ac-syriac {
    direction: rtl;
    font-family: var(--syriac-font);
    font-size: 1.3em;
}

.ac-translit {
    font-family: monospace;
    color: var(--accent-dark);
    font-weight: bold;
    letter-spacing: 1px;
}

.ac-count {
    color: var(--text-muted);
    font-size: 0.85em;
    margin-left: auto;
}

/* === Disambiguation list === */
.disambiguation {
    margin-top: 15px;
}

.disambiguation-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-ref);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
}

.disambiguation-item:hover {
    background: var(--bg-ref-hover);
}

.disambiguation-item .syriac {
    font-size: 1.5em;
}

/* === Browse filters === */
.browse-filters {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.browse-filter {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color, rgba(128,128,128,0.2));
    transition: all 0.15s;
}
.browse-filter:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}
.browse-filter.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.browse-context {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.browse-context .syriac {
    font-family: var(--syriac-font, 'Noto Sans Syriac'), serif;
    font-size: 0.95rem;
}
.browse-ref {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    margin-left: 0.3rem;
}
.browse-ref:hover { text-decoration: underline; }

/* === Browse pagination === */
.browse-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.browse-page-info {
    color: var(--text-secondary);
    font-size: 0.95em;
}

.browse-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.95em;
}

.browse-link:hover {
    text-decoration: underline;
    color: var(--accent-dark);
}

/* === Footer === */
footer {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
    border-top: 1px solid var(--border);
    margin-top: var(--space-3xl);
}

.footer-line {
    margin-bottom: 6px;
}

.footer-repo {
    margin-bottom: 6px;
}

.footer-repo a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.footer-repo a:hover {
    color: var(--accent-dark);
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.footer-sep {
    color: var(--border);
}

footer a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

footer a:hover {
    color: var(--accent-dark);
}

/* === Reader === */
.reader-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.reader-selects {
    display: flex;
    gap: 12px;
    align-items: center;
}

.reader-selects label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.reader-label {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reader-selects select {
    padding: 8px 12px;
    border: 2px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1em;
    cursor: pointer;
}

.reader-selects select:focus {
    border-color: var(--accent);
    outline: none;
}

.reader-arrows {
    display: flex;
    gap: 8px;
}

.reader-hint {
    font-size: 0.85em;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 20px;
}

.reader-body {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px 25px;
    box-shadow: 0 2px 8px var(--shadow);
}

.reader-verse {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.reader-verse:last-child {
    border-bottom: none;
}

.verse-num {
    position: absolute;
    right: -5px;
    top: 14px;
    font-size: 0.75em;
    font-weight: 700;
    color: var(--accent);
    min-width: 20px;
    text-align: right;
}


.verse-constellation-link {
    position: absolute;
    right: -5px;
    top: 32px;
    color: var(--accent-gold);
    opacity: 0.7;
    text-decoration: none;
    transition: opacity 0.2s;
}
.verse-constellation-link .material-symbols-outlined {
    font-size: 20px;
}
.verse-constellation-link:hover {
    opacity: 1;
}

/* === Bookmarks === */
.bm-verse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    margin-right: 4px;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
    position: relative;
    z-index: 2;
    min-width: 24px;
    min-height: 24px;
}
.bm-verse-btn .material-symbols-outlined { font-size: 18px; }
.bm-verse-btn:hover, .bm-verse-btn.bookmarked { color: var(--accent); }
.bm-verse-btn.bookmarked .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}

.bm-root-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.5);
    padding: 6px;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}
.bm-root-btn .material-symbols-outlined { font-size: 28px; }
.bm-root-btn:hover { color: #fff; }

/* Proximity search results */
.proximity-result {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}
.proximity-result:last-child { border-bottom: none; }
.proximity-ref { font-weight: 600; margin-bottom: 4px; }
.proximity-ref a { color: var(--accent); text-decoration: none; }
.proximity-ref a:hover { text-decoration: underline; }
.proximity-syriac { font-size: 1.15em; direction: rtl; text-align: right; margin: 6px 0; line-height: 1.8; }
.proximity-translit { font-family: monospace; font-size: 0.85em; color: var(--text-muted); margin: 2px 0; }
.proximity-translation { font-style: italic; color: var(--text-muted); font-size: 0.9em; }
.prox-roots-header { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; flex-wrap: wrap; }
.prox-root-card { display: flex; align-items: baseline; gap: 8px; padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 8px; }
.prox-root-syriac { font-size: 1.4em; padding: 2px 6px; border-radius: 4px; }
.prox-root-translit { font-family: monospace; font-size: 1.1em; font-weight: 600; letter-spacing: 1px; }
.prox-root-gloss { font-style: italic; color: var(--text-muted); }
.prox-plus { font-size: 1.3em; font-weight: 700; color: var(--text-muted); }
.prox-hl1 { background: rgba(107, 122, 94, 0.25); border-radius: 3px; padding: 1px 3px; }
.prox-hl2 { background: rgba(180, 140, 50, 0.3); border-radius: 3px; padding: 1px 3px; }

/* Cookie consent banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-header);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 9999;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
    font-size: 0.9em;
}
.cookie-text { flex: 1; line-height: 1.4; }
.cookie-link { color: var(--accent-gold, #d4a843); margin-left: 6px; }
.cookie-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
}
.cookie-accept { background: var(--accent); color: #fff; }
.cookie-accept:hover { background: var(--accent-dark); }
.cookie-reject { background: transparent; color: rgba(255,255,255,0.7); border: 1px solid rgba(255,255,255,0.3); }
.cookie-reject:hover { color: #fff; border-color: #fff; }
@media (max-width: 600px) {
    .cookie-banner { flex-direction: column; text-align: center; padding: 12px 16px; }
    .cookie-buttons { width: 100%; justify-content: center; }
}

.bookmarks-toggle { color: var(--text-body); text-decoration: none; display: flex; align-items: center; }
.bookmarks-toggle .material-symbols-outlined { font-size: 22px; }

.bookmarks-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.bookmarks-tabs { display: flex; gap: 4px; }
.bm-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.15s;
}
.bm-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.bm-tab .material-symbols-outlined { font-size: 18px; }
.bm-count {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.8em;
}
.bm-tab.active .bm-count { background: rgba(255,255,255,0.2); }
.bookmarks-actions { display: flex; gap: 4px; }
.bm-action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}
.bm-action-btn:hover { color: var(--accent); border-color: var(--accent); }

.bookmarks-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.bm-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
}
.bm-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.bm-ref {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}
.bm-ref:hover { text-decoration: underline; }
.bm-gloss { color: var(--text-muted); font-style: italic; }
.bm-date { color: var(--text-muted); font-size: 0.8em; margin-left: auto; }
.bm-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px;
}
.bm-remove:hover { color: #c00; }
.bm-remove .material-symbols-outlined { font-size: 16px; }
.bm-syriac {
    font-size: 1.2em;
    margin: 6px 0;
    direction: rtl;
}
.bm-translation {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9em;
    margin: 4px 0;
}
.bm-note {
    background: rgba(107,122,94,0.08);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85em;
    margin: 6px 0;
    color: var(--text-body);
}
.bm-note-input input {
    width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85em;
    background: var(--bg-main);
    color: var(--text-body);
    margin-top: 4px;
}

.reader-line {
    margin-right: 32px;
    line-height: 1.8;
}

.reader-syriac {
    direction: rtl;
    font-family: var(--syriac-font);
    font-size: 1.4em;
    text-align: right;
    margin-right: 32px;
    unicode-bidi: bidi-override;
}

.reader-translit {
    font-family: monospace;
    font-size: 1.1em;
    color: var(--text-translit);
    line-height: 1.6;
}

.reader-translit.hebrew,
.reader-translit.arabic {
    font-family: inherit;
    font-size: 1.15em;
}

.reader-translation {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.5;
    margin-top: 2px;
}

.rtl-text {
    direction: rtl;
    text-align: right;
    font-style: normal;
    font-size: 1.15em;
}

/* Clickable words in reader */
.rw {
    display: inline;
    margin: 0 1px;
}

.rw.clickable {
    cursor: pointer;
    border-bottom: 2px solid var(--accent);
    transition: background 0.15s;
}

.rw.clickable:hover {
    background: var(--bg-highlight);
    border-radius: 3px;
}

/* === Audio Player === */
.audio-chapter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    margin: 8px 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-sizing: border-box;
}

.audio-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.audio-btn:hover {
    background: var(--accent-dark);
}

.audio-btn .material-symbols-outlined {
    font-size: 20px;
}

.audio-verse-play {
    width: 22px;
    height: 22px;
    padding: 0;
    margin-right: 4px;
    vertical-align: middle;
    display: inline-flex;
}

.audio-verse-play .material-symbols-outlined {
    font-size: 13px;
}

.audio-progress-wrap {
    flex: 1;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.audio-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width 0.15s linear;
    pointer-events: none;
}

.audio-time {
    font-size: 0.8em;
    color: var(--text-muted);
    font-family: monospace;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
}

.audio-speed {
    font-size: 0.8em;
    padding: 2px 4px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-body);
    cursor: pointer;
}

.reader-verse.verse-playing {
    background: rgba(107, 122, 94, 0.08);
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    transition: background 0.3s ease, border-left 0.3s ease;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .sticky-header {
        justify-content: center;
        padding: 8px 12px;
    }

    .stat-item[data-tooltip]::after {
        white-space: normal;
        max-width: 200px;
        text-align: center;
    }

    header {
        padding: 15px 0;
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 1.3em;
    }

    header p {
        font-size: 0.95em;
    }

    .search-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
    }
    .search-tab {
        padding: 8px 14px;
        font-size: 0.85em;
    }

    .feature-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
    }
    .feature-tab {
        padding: 10px 8px;
        font-size: 0.8em;
        gap: 3px;
    }
    .feature-tab .material-symbols-outlined {
        display: none;
    }

    .search-section {
        padding: 15px;
    }

    .search-row {
        flex-direction: column;
    }

    .search-row button {
        width: 100%;
        padding: 12px;
    }

    .stats-bar {
        gap: 10px;
    }

    .stat-item {
        padding: 8px 14px;
        flex: 1;
        min-width: 80px;
    }

    .stat-item .stat-value {
        font-size: 1.2em;
    }

    .root-header {
        padding: 12px 15px 10px;
    }

    .root-header .root-syriac {
        font-size: 1.6em;
    }

    .root-header .root-latin {
        font-size: 1.1em;
    }

    .root-header-nav {
        flex-wrap: wrap;
    }

    .panel-body {
        padding: 10px 12px;
        overflow-x: auto;
    }

    /* Card layout for Peshitta occurrences table on mobile */
    .peshitta-table thead {
        display: none;
    }

    .peshitta-table,
    .peshitta-table tbody,
    .peshitta-table tr,
    .peshitta-table td {
        display: block;
        width: 100%;
    }

    .peshitta-table tr {
        border-bottom: 1px solid var(--border);
        padding: 10px 0;
    }

    .peshitta-table tr:last-child {
        border-bottom: none;
    }

    .peshitta-table td {
        padding: 2px 0;
        text-align: left;
        border: none;
    }

    .peshitta-table td.syriac {
        font-size: 1.4em;
        display: inline;
        margin-right: 10px;
    }

    .peshitta-table td.translit-cell {
        display: inline;
        font-size: 0.9em;
    }

    .peshitta-table td.gloss-cell {
        display: block;
        color: var(--text-secondary);
        font-style: italic;
        padding: 2px 0;
    }

    .peshitta-table td.refs {
        display: block;
        padding-top: 4px;
    }

    /* Other tables keep horizontal scroll */
    table:not(.peshitta-table) {
        min-width: 300px;
    }

    th, td {
        padding: 8px 6px;
        font-size: 0.9em;
    }

    .syriac {
        font-size: 1.1em;
    }

    .modal-content {
        padding: 20px 15px;
        width: 95%;
        max-height: 85vh;
    }

    .modal-syriac {
        font-size: 1.3em;
    }

    .modal-translit {
        font-size: 0.9em;
    }

    .translit-table {
        grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    }

    .footer-links {
        flex-direction: column;
        gap: 4px;
    }

    .footer-sep {
        display: none;
    }

    .reader-nav {
        flex-direction: column;
        align-items: stretch;
    }

    .reader-selects {
        flex-direction: column;
    }

    .reader-body {
        padding: 15px 12px;
    }

    .reader-syriac {
        font-size: 1.2em;
    }

    .reader-translit {
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.1em;
    }

    .stat-item .stat-value {
        font-size: 1em;
    }

    .stat-item .stat-label {
        font-size: 0.75em;
    }

    table {
        min-width: 350px;
    }

    .root-header .root-syriac {
        font-size: 1.4em;
    }
}

/* === Help page === */
.help-back-link {
    color: var(--accent);
    text-decoration: none;
}

.help-back-link:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

.help-content {
    max-width: 800px;
    margin: 0 auto;
}

.help-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
}

.help-section h2 {
    color: var(--accent);
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.3em;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 8px;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section ul li {
    padding: 8px 0;
    line-height: 1.6;
    border-bottom: 1px solid var(--border-light);
}

.help-section ul li:last-child {
    border-bottom: none;
}

.help-section ul li strong {
    color: var(--text-primary);
}

.help-capabilities ul li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
}

.help-capabilities ul li::before {
    content: "•";
    color: var(--accent);
    font-weight: bold;
    position: absolute;
    left: 4px;
}

.help-faq details {
    border-bottom: 1px solid var(--border-light);
    padding: 0;
}

.help-faq details:last-child {
    border-bottom: none;
}

.help-faq summary {
    cursor: pointer;
    padding: 12px 0;
    font-weight: bold;
    color: var(--text-primary);
    list-style: none;
}

.help-faq summary::-webkit-details-marker {
    display: none;
}

.help-faq summary::before {
    content: "▸ ";
    color: var(--accent);
}

.help-faq details[open] summary::before {
    content: "▾ ";
}

.help-faq .faq-answer {
    padding: 0 0 16px 16px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* === Root Visualizer === */
.viz-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.viz-svg-wrap {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    overflow: hidden;
}

.viz-svg-wrap svg {
    display: block;
    width: 100%;
    height: auto;
}

.viz-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1.1em;
}

.viz-error {
    text-align: center;
    padding: 40px 20px;
    color: #c0392b;
    font-size: 1.1em;
}

.viz-tooltip {
    display: none;
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 4px 16px var(--shadow);
    max-width: 280px;
    z-index: 100;
    pointer-events: none;
}

.viz-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
}

.viz-link-icon {
    color: var(--accent);
    text-decoration: none;
    margin-left: 6px;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.viz-link-icon:hover {
    opacity: 1;
}

.viz-btn:hover {
    background: var(--accent-dark);
}
.viz-btn-primary {
    padding: 8px 20px;
    font-size: 1em;
    font-weight: 700;
    border-radius: var(--radius-md);
    background: #f0ece4;
    color: var(--accent-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.02em;
    transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.viz-btn-primary:hover {
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

[data-theme="dark"] .viz-btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .viz-btn-primary:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.viz-btn .material-symbols-outlined {
    font-size: 16px;
}
.viz-btn-primary .material-symbols-outlined {
    font-size: 18px;
}

/* Visualize button in word modal */
.modal-viz-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    margin: 8px 0 4px;
    box-shadow: 0 2px 6px rgba(139, 69, 19, 0.3);
    transition: background 0.15s, box-shadow 0.15s;
}
.modal-viz-btn:hover {
    background: var(--accent-dark);
    box-shadow: 0 3px 10px rgba(139, 69, 19, 0.4);
}
.modal-viz-btn .material-symbols-outlined {
    font-size: 18px;
}

.viz-controls {
    display: flex;
    gap: 18px;
    justify-content: center;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.viz-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.viz-check input[type="checkbox"] {
    display: none;
}

.viz-check-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.viz-check input[type="checkbox"]:checked + .viz-check-dot {
    border-color: transparent;
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3px currentColor;
}

.viz-check input[type="checkbox"]:not(:checked) + .viz-check-dot {
    opacity: 0.4;
}

.viz-outlier-key {
    display: inline-flex;
    align-items: center;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--text-muted, #999);
    font-size: 13px;
    color: var(--viz-outlier-text, #8B6914);
    gap: 2px;
}

.viz-bridge-key {
    display: inline-flex;
    align-items: center;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--text-muted, #999);
    font-size: 13px;
    color: var(--viz-bridge-text, #7A5C12);
    gap: 4px;
}

@keyframes bridge-dash-flow {
    to { stroke-dashoffset: -24; }
}

.bridge-link-animated {
    animation: bridge-dash-flow 1s linear infinite;
}

@keyframes bridge-pulse {
    0%, 100% { r: 0; opacity: 0.5; }
    50% { r: 8; opacity: 0; }
}

@keyframes bridge-glow {
    0%, 100% { stroke-opacity: 0.7; }
    50% { stroke-opacity: 1; }
}

.bridge-outlier-ring {
    animation: bridge-glow 2s ease-in-out infinite;
}

.bridge-outlier-pulse {
    animation: bridge-pulse 2s ease-in-out infinite;
}

/* Fullscreen button */
.viz-fullscreen-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--text-muted);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    transition: background 0.15s, color 0.15s;
}
.viz-fullscreen-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.viz-fullscreen-btn .material-symbols-outlined {
    font-size: 20px;
}

/* Fullscreen mode */
.viz-container.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: var(--bg-page, #fff);
    margin: 0;
    padding: 0;
    border-radius: 0;
    overflow: hidden;
}
.viz-container.is-fullscreen .viz-controls {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 10;
    background: var(--bg-card, rgba(255,255,255,0.92));
    backdrop-filter: blur(8px);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    padding: 10px 18px;
}
.viz-container.is-fullscreen .viz-svg-wrap {
    width: 100%;
    height: 100%;
}
.viz-container.is-fullscreen .viz-svg-wrap svg {
    width: 100% !important;
    height: 100% !important;
}

/* Native fullscreen API styles */
.viz-container:fullscreen,
.viz-container:-webkit-full-screen {
    background: var(--bg-page, #fff);
}
.viz-container:fullscreen .viz-controls,
.viz-container:-webkit-full-screen .viz-controls {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 10;
    background: var(--bg-card, rgba(255,255,255,0.92));
    backdrop-filter: blur(8px);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    padding: 10px 18px;
}

.viz-back {
    margin-top: 8px;
}

.viz-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.95em;
    padding: 6px 14px;
    border: 1px solid var(--accent);
    border-radius: 20px;
    transition: background 0.15s, color 0.15s;
}

.viz-back-link:hover {
    background: var(--accent);
    color: #fff;
}

@media (max-width: 768px) {
    .viz-controls {
        gap: 10px;
        padding: 10px 12px;
        flex-wrap: wrap;
    }
    .viz-check {
        font-size: 0.82em;
    }
}

/* === Text Search Results === */
.text-search-count {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.75rem 0 0.5rem;
}
.text-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}
.text-result-ref {
    display: inline-block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    background: rgba(184, 134, 11, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    border: 1px solid rgba(184, 134, 11, 0.2);
}
.text-result-ref:hover {
    background: var(--accent);
    color: #fff;
}
.text-result-translation {
    margin: 0.4rem 0 0.25rem;
    line-height: 1.6;
    font-size: 0.95rem;
}
[dir="rtl"] .text-result-translation {
    text-align: right;
}
[dir="rtl"] .text-result-translit {
    text-align: right;
}
.text-result-syriac {
    font-family: 'Noto Sans Syriac', 'Estrangelo Edessa', serif;
    direction: rtl;
    text-align: right;
    font-size: 1.3rem;
    color: var(--text-muted);
    margin: 0.4rem 0 0.1rem;
    line-height: 1.8;
}
.text-result-translit {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 0;
    letter-spacing: 0.02em;
}
.text-result-card mark {
    background: rgba(184, 134, 11, 0.25);
    color: inherit;
    padding: 0.1em 0.15em;
    border-radius: 2px;
}
.text-load-more {
    display: block;
    width: 100%;
    margin: 0.75rem 0;
    padding: 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent);
    font-size: 0.9rem;
    cursor: pointer;
}
.text-load-more:hover {
    background: var(--accent);
    color: var(--bg-page);
}

/* === Browse View Toggle === */
.browse-view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.browse-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.2s;
}
.browse-view-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.browse-view-btn.active {
    background: var(--accent);
    color: var(--bg-page);
    border-color: var(--accent);
}
.browse-view-btn .material-symbols-outlined {
    font-size: 18px;
}

/* === Semantic Fields Grid === */
.fields-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.field-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.field-card.field-open {
    border-color: var(--accent);
}
.field-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.field-header:hover {
    background: rgba(107, 122, 94, 0.08);
}
.field-icon {
    font-size: 22px;
    color: var(--accent);
}
.field-name {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
}
.field-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-page);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    min-width: 1.5rem;
    text-align: center;
}
.field-chevron {
    font-size: 22px;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.field-body {
    padding: 0 1rem 0.75rem;
}
.field-body table {
    min-width: auto;
}

/* === Sortable columns === */
.sortable-th {
    white-space: nowrap;
}
.sort-link {
    text-decoration: none;
    color: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.sort-link:hover {
    color: var(--accent);
}
.sort-link.sort-active {
    color: var(--accent);
    font-weight: 700;
}

/* === Meaning / Reverse Search Results === */
.meaning-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
}
.meaning-result-root {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.meaning-root-link {
    text-decoration: none;
    color: inherit;
    font-size: 1.1em;
    font-weight: 600;
}
.meaning-root-link:hover {
    color: var(--accent);
}
.meaning-root-link .syriac {
    font-size: 1.3em;
}
.meaning-gloss {
    color: var(--text-gloss);
    font-style: italic;
}
.meaning-result-sabor {
    margin-top: 0.35rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* === RTL Support (Hebrew / Arabic UI) === */
[dir="rtl"] {
    text-align: right;
}
[lang="ar"] body {
    font-size: 1.25em;
    line-height: 1.95;
}
[dir="rtl"] .sticky-header {
    direction: ltr;
    flex-direction: row-reverse;
}
[dir="rtl"] .nav-logo {
    margin-right: 0;
    margin-left: auto;
}
[dir="rtl"] .search-input-wrap {
    flex-direction: row-reverse;
}
[dir="rtl"] .search-input {
    text-align: right;
}
[dir="rtl"] .stats-grid {
    direction: rtl;
}
[dir="rtl"] .browse-table th,
[dir="rtl"] .browse-table td {
    text-align: right;
}
[dir="rtl"] .modal-close {
    right: auto;
    left: var(--space-sm);
}
[dir="rtl"] .lang-dropdown,
[dir="rtl"] .settings-dropdown {
    right: auto;
    left: 0;
}
[dir="rtl"] .feature-tab-icon {
    margin-right: 0;
    margin-left: var(--space-xs);
}
[dir="rtl"] .reader-line {
    margin-right: 0;
    margin-left: 32px;
}
[dir="rtl"] .verse-constellation-link {
    right: auto;
    left: -5px;
}
[dir="rtl"] .ficha-sister {
    direction: rtl;
}
[dir="rtl"] .pagination {
    direction: rtl;
}
[dir="rtl"] .methodology-content blockquote {
    border-left: none;
    border-right: 3px solid var(--accent, #6b7a5e);
    padding-left: 0;
    padding-right: 1em;
}
[dir="rtl"] .constellation-layout {
    flex-direction: row-reverse;
}
[dir="rtl"] .constellation-verse-num {
    margin-right: 0;
    margin-left: 4px;
}
[dir="rtl"] .feature-close {
    right: auto;
    left: 0.5rem;
}
[dir="rtl"] .root-header-nav {
    flex-direction: row-reverse;
}
[dir="rtl"] .autocomplete-list {
    text-align: right;
}
[dir="rtl"] ul,
[dir="rtl"] ol {
    padding-right: 1.5em;
    padding-left: 0;
}

/* === Guided Tour === */
.tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto;
}
.tour-overlay.active { opacity: 1; }

.tour-spotlight {
    position: absolute;
    z-index: 9999;
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    transition: all 0.35s ease;
    pointer-events: none;
}

.tour-tooltip {
    position: absolute;
    z-index: 10000;
    width: 340px;
    max-width: calc(100vw - 24px);
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, #e0ddd4);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: auto;
}
.tour-tooltip.active { opacity: 1; }
.tour-tooltip-center {
    text-align: center;
}

.tour-tooltip-title {
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--text-heading, #2c1810);
    margin-bottom: 8px;
}

.tour-tooltip-body {
    font-size: var(--text-sm);
    color: var(--text-secondary, #5a5247);
    line-height: 1.6;
    margin-bottom: 16px;
}
.tour-tooltip-body .tour-icon {
    font-size: 16px;
    vertical-align: -3px;
}

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

.tour-dots {
    display: flex;
    gap: 6px;
}
.tour-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border-light, #d0cdc4);
    transition: background 0.2s;
}
.tour-dot.active {
    background: var(--accent-olive, #6b7a5e);
}

.tour-buttons {
    display: flex;
    gap: 8px;
}
.tour-btn {
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}
.tour-btn-skip {
    background: transparent;
    color: var(--text-muted, #8c857a);
}
.tour-btn-skip:hover {
    background: var(--bg-panel-header, #edece6);
}
.tour-btn-next {
    background: var(--accent-olive, #6b7a5e);
    color: #fff;
}
.tour-btn-next:hover {
    background: var(--accent-dark, #4a5a3e);
}

/* Tour start button on homepage */
.tour-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-panel-header, #edece6);
    color: var(--text-secondary, #5a5247);
    border: 1px solid var(--border-light, #e0ddd4);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}
.tour-start-btn:hover {
    background: var(--accent-olive, #6b7a5e);
    color: #fff;
    border-color: var(--accent-olive, #6b7a5e);
}
.tour-start-btn .material-symbols-outlined {
    font-size: 18px;
}

@media (max-width: 600px) {
    .tour-tooltip {
        width: calc(100vw - 24px);
        left: 12px !important;
        right: 12px !important;
    }
    .audio-speed { display: none; }
    .audio-progress-wrap { height: 10px; }
    .audio-chapter-bar { padding: 8px 10px; gap: 8px; }
    .audio-time { font-size: 0.7em; min-width: 70px; }
}
