/* =========================================================================
   e-Bible — "illuminated manuscript meets modern editorial"
   ========================================================================= */

/* ----- Theme tokens ----------------------------------------------------- */
:root {
    /* Brand palette — matched to the HKBP logo: violet→blue, teal, coral / light */
    --paper:        #f1f3fb;
    --paper-2:      #e7e9f6;
    --surface:      #fafbff;
    --surface-rise: #ffffff;
    --ink:          #1b1e2e;
    --ink-soft:     #484c66;
    --ink-faint:    #868aa6;
    --line:         #e3e5f1;
    --line-strong:  #ccd0e4;

    --garnet:       #5b3df0;   /* primary (violet-blue) */
    --garnet-soft:  #7659f6;
    --gold:         #0e9c8e;   /* accent (teal) */
    --gold-soft:    #14b8a6;

    --grad-from:    #7c3aed;   /* logo gradient endpoints */
    --grad-to:      #2563eb;
    --spark:        #fb7185;   /* coral spark */

    --mark-bg:      #e6ddfc;
    --mark-ink:     #3a1c8c;

    --shadow-sm:    0 1px 2px rgba(30, 30, 70, .08);
    --shadow-md:    0 12px 30px -12px rgba(40, 35, 95, .26);
    --shadow-lg:    0 30px 70px -28px rgba(28, 26, 80, .45);

    --radius:       14px;
    --radius-sm:    9px;
    --radius-lg:    22px;

    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --font-read:    "Spectral", Georgia, "Times New Roman", serif;

    --sidebar-w:    288px;
    --reader-max:   46rem;
    --ease:         cubic-bezier(.22, .61, .36, 1);
}

[data-theme="dark"] {
    --paper:        #0e1020;
    --paper-2:      #14182f;
    --surface:      #161a2d;
    --surface-rise: #1e2238;
    --ink:          #e8eaf6;
    --ink-soft:     #b2b6d0;
    --ink-faint:    #7c8099;
    --line:         #262b45;
    --line-strong:  #353b5a;

    --garnet:       #9d8bff;   /* primary, lightened for dark */
    --garnet-soft:  #b6a8ff;
    --gold:         #2dd4bf;   /* teal */
    --gold-soft:    #5ee0d0;

    --grad-from:    #a78bfa;
    --grad-to:      #60a5fa;
    --spark:        #fb7185;

    --mark-bg:      #46357f;
    --mark-ink:     #ece6ff;

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, .45);
    --shadow-md:    0 14px 34px -14px rgba(0, 0, 0, .72);
    --shadow-lg:    0 36px 80px -30px rgba(0, 0, 0, .85);
}

* { box-sizing: border-box; }

/* The [hidden] attribute must always win, even over our display:flex layouts. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    background:
        radial-gradient(120% 90% at 100% 0%, var(--paper-2) 0%, var(--paper) 55%),
        var(--paper);
    color: var(--ink);
    font-family: var(--font-read);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color .5s var(--ease), color .35s var(--ease);
}

/* Subtle paper grain over the whole canvas */
.grain {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: .5;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
}
[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .06; }

::selection { background: var(--mark-bg); color: var(--mark-ink); }

:focus-visible {
    outline: 2.5px solid var(--garnet);
    outline-offset: 2px;
    border-radius: 4px;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ----- Top bar ---------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px clamp(14px, 3vw, 28px);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    flex: 0 1 auto;
    min-width: 0;
    text-decoration: none;
    color: var(--ink);
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    border-radius: 11px;
    overflow: hidden;
    background: #14122b; /* the logo is designed on a dark tile */
    box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255,255,255,.06);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.32rem;
    letter-spacing: -.01em;
}
.brand-sub {
    font-size: .64rem;
    letter-spacing: .34em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-top: 3px;
}

.topbar-actions { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px 9px 13px;
    min-width: 210px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface-rise);
    color: var(--ink-faint);
    font-family: var(--font-read);
    font-size: .92rem;
    box-shadow: var(--shadow-sm);
    transition: border-color .25s, transform .25s var(--ease), color .25s;
}
.search-trigger:hover { border-color: var(--gold); color: var(--ink-soft); transform: translateY(-1px); }
.search-trigger svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger kbd {
    font-family: var(--font-read);
    font-size: .72rem;
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    background: var(--paper-2);
    color: var(--ink-faint);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 42px; height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface-rise);
    color: var(--ink-soft);
    box-shadow: var(--shadow-sm);
    transition: transform .25s var(--ease), border-color .25s, color .25s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--gold); color: var(--garnet); }
.icon-btn:active { transform: translateY(0) scale(.96); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }

/* "Kitab" Spotlight trigger */
.kitab-trigger {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface-rise);
    color: var(--ink-soft);
    font-family: var(--font-read);
    font-size: .92rem;
    box-shadow: var(--shadow-sm);
    transition: border-color .25s, transform .25s var(--ease), color .25s;
}
.kitab-trigger:hover { border-color: var(--gold); color: var(--garnet); transform: translateY(-1px); }
.kitab-trigger svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.kitab-trigger kbd {
    font-family: var(--font-read);
    font-size: .72rem;
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    background: var(--paper-2);
    color: var(--ink-faint);
}

/* Theme toggle sun/moon crossfade */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle svg { position: absolute; transition: transform .5s var(--ease), opacity .35s var(--ease); }
.theme-toggle .i-moon { opacity: 0; transform: translateY(120%) rotate(-40deg); }
[data-theme="dark"] .theme-toggle .i-sun  { opacity: 0; transform: translateY(-120%) rotate(40deg); }
[data-theme="dark"] .theme-toggle .i-moon { opacity: 1; transform: translateY(0) rotate(0); }

/* ----- Layout (single column; books open via the Spotlight palette) ----- */
.layout {
    position: relative;
    z-index: 1;
}

/* ----- Book Spotlight palette ------------------------------------------ */
.palette {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(12px, 9vh, 110px) 16px 16px;
    background: color-mix(in srgb, var(--paper) 55%, rgba(20, 12, 4, .55));
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: fade .2s var(--ease) both;
}
.palette-panel {
    width: min(560px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: rise .3s var(--ease) both;
}
.palette-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 13px;
    border-bottom: 1px solid var(--line);
}
.palette-icon { width: 20px; height: 20px; fill: none; stroke: var(--ink-faint); stroke-width: 1.7; stroke-linejoin: round; flex: none; }
#bookFilter {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.22rem;
}
#bookFilter:focus { outline: none; }
#bookFilter::placeholder { color: var(--ink-faint); font-weight: 400; }
.palette-close { width: 36px; height: 36px; }

.palette-list { overflow-y: auto; padding: 8px; scrollbar-width: thin; overscroll-behavior: contain; }
.book-nav-loading { padding: 28px 12px; color: var(--ink-faint); font-style: italic; text-align: center; }

.testament-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 10px 7px;
    font-size: .64rem;
    letter-spacing: .26em;
    text-transform: uppercase;
    color: var(--gold);
    font-weight: 600;
}
.testament-label::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.testament-label:first-child { margin-top: 4px; }

.book-link {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-soft);
    font-family: var(--font-read);
    font-size: 1.02rem;
    transition: background-color .15s, color .15s;
}
.book-link .bk-no {
    font-size: .72rem;
    color: var(--ink-faint);
    min-width: 20px;
    font-variant-numeric: tabular-nums;
}
.book-link .bk-name { flex: 1; }
.book-link .bk-hint {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .8rem;
    color: var(--gold);
    padding: 2px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--gold) 14%, transparent);
}
/* Keyboard / pointer highlight (Spotlight selection) */
.book-link.hl { background: color-mix(in srgb, var(--garnet) 13%, transparent); color: var(--ink); }
.book-link.active { color: var(--garnet); font-weight: 600; }
.book-link.active .bk-no { color: var(--garnet-soft); }
.book-link.active.hl { background: color-mix(in srgb, var(--garnet) 18%, transparent); }

/* ----- Reader ----------------------------------------------------------- */
.reader {
    min-height: calc(100dvh - 67px);
    padding: clamp(22px, 4vw, 60px) clamp(18px, 5vw, 64px) 120px;
}

/* Welcome state */
.welcome {
    max-width: 38rem;
    margin: clamp(20px, 8vh, 90px) auto 0;
    text-align: center;
    animation: rise .8s var(--ease) both;
}
.welcome-kicker {
    font-size: .72rem;
    letter-spacing: .34em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 18px;
}
.welcome-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2.4rem, 6vw, 4rem);
    line-height: 1.02;
    letter-spacing: -.02em;
    margin: 0 0 22px;
    color: var(--grad-to); /* fallback */
    background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.welcome-lead { font-size: 1.12rem; color: var(--ink-soft); margin: 0 auto 34px; max-width: 32rem; }
.welcome-lead em { font-style: italic; color: var(--ink); }

.cta {
    padding: 14px 26px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
    color: #ffffff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-md);
    transition: transform .3s var(--ease), box-shadow .3s, filter .25s;
}
.cta:hover { transform: translateY(-2px); filter: brightness(1.08) saturate(1.05); box-shadow: var(--shadow-lg); }
.cta:active { transform: translateY(0); }

/* Chapter */
.chapter { max-width: var(--reader-max); margin: 0 auto; animation: rise .5s var(--ease) both; }

.chapter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 34px;
}
.crumb { font-size: .82rem; color: var(--ink-faint); letter-spacing: .04em; }
.crumb b { color: var(--ink-soft); font-weight: 600; }

/* Version switcher — the segmented control shown with a chapter */
.version-switch {
    display: inline-flex;
    padding: 4px;
    gap: 3px;
    background: var(--paper-2);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.vbtn {
    border: 0;
    background: transparent;
    padding: 7px 16px;
    border-radius: 999px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .86rem;
    letter-spacing: .02em;
    color: var(--ink-soft);
    transition: color .2s, background-color .25s var(--ease), box-shadow .25s;
    white-space: nowrap;
}
.vbtn:hover { color: var(--ink); }
.vbtn[aria-pressed="true"] {
    background: var(--surface-rise);
    color: var(--garnet);
    box-shadow: var(--shadow-sm);
}

.chapter-head { text-align: center; margin-bottom: 38px; }
.chapter-book {
    font-family: var(--font-display);
    font-weight: 600;
    font-style: italic;
    font-size: 1.35rem;
    color: var(--ink-soft);
    margin: 0 0 2px;
}
.chapter-no {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3.4rem, 11vw, 6rem);
    line-height: .9;
    letter-spacing: -.03em;
    margin: 0;
    color: var(--grad-to); /* fallback */
    background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.chapter-no::after {
    content: "";
    display: block;
    width: 54px; height: 3px;
    margin: 20px auto 0;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.chapter-lang {
    margin-top: 14px;
    font-size: .7rem;
    letter-spacing: .26em;
    text-transform: uppercase;
    color: var(--gold);
}

/* Verses */
.verses { font-size: 1.18rem; line-height: 1.85; }

.section-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-style: italic;
    font-size: 1.28rem;
    color: var(--garnet);
    margin: 34px 0 12px;
    line-height: 1.3;
}
.section-title:first-child { margin-top: 0; }

.verse {
    display: block;
    margin: 0;
    padding: 3px 6px;
    border-radius: 8px;
    scroll-margin-top: 90px;
    transition: background-color .25s;
}
.verse + .verse { margin-top: 2px; }
.vnum {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .72em;
    color: var(--garnet);
    vertical-align: .35em;
    margin-right: .35em;
    font-variant-numeric: tabular-nums;
    user-select: none;
}
.verse.flash { background: color-mix(in srgb, var(--spark) 22%, transparent); }

/* Per-verse share button — reveals on hover, faintly visible on touch */
.vshare {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em; height: 1.5em;
    margin-left: .25em;
    padding: 0;
    vertical-align: -.25em;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-faint);
    opacity: 0;
    transition: opacity .18s, color .18s, background-color .18s, transform .18s var(--ease);
}
.verse:hover .vshare { opacity: .5; }
.vshare:hover { opacity: 1; color: var(--garnet); background: color-mix(in srgb, var(--garnet) 12%, transparent); transform: translateY(-1px); }
.vshare svg { width: .8em; height: .8em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vshare.copied { color: var(--gold); opacity: 1; }
@media (hover: none) { .vshare { opacity: .4; } }

/* Drop cap on the first content verse of the chapter */
.verses > .verse.lead .vtext::first-letter {
    initial-letter: 3;
    -webkit-initial-letter: 3;
    font-family: var(--font-display);
    font-weight: 900;
    color: var(--garnet);
    margin-right: .08em;
    padding-right: .06em;
}

/* Staggered reveal */
.verses .verse, .verses .section-title { animation: verseIn .5s var(--ease) both; }

/* Centered chapter navigation (in the top bar) */
.chapter-nav {
    display: none;                 /* shown only when a chapter is open */
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0;
    justify-content: center;
}
.chapter-nav.active { display: flex; }

.pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink-faint);
    transition: color .2s, background-color .2s, transform .2s var(--ease);
}
.pager-btn:hover:not(:disabled) { color: var(--garnet); background: color-mix(in srgb, var(--garnet) 12%, transparent); }
.pager-btn:active:not(:disabled) { transform: scale(.92); }
.pager-btn:disabled { opacity: .28; cursor: not-allowed; }
.pager-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Horizontally scrollable chapter grid */
.chapter-grid {
    --chip-w: 40px;
    --chip-gap: 6px;
    --chip-pad: 4px;
    display: flex;
    flex-wrap: nowrap;
    gap: var(--chip-gap);
    overflow-x: auto;
    overflow-y: hidden;
    /* exactly five chips in view; the rest scroll into place */
    width: calc(var(--chip-w) * 5 + var(--chip-gap) * 4 + var(--chip-pad) * 2);
    max-width: 100%;
    padding: var(--chip-pad);
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;          /* the 5-chip window + fades are the affordance */
    /* fade the edges so it reads as scrollable */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 13px, #000 calc(100% - 13px), transparent);
            mask-image: linear-gradient(90deg, transparent, #000 13px, #000 calc(100% - 13px), transparent);
}
.chapter-grid::-webkit-scrollbar { height: 0; width: 0; }

.chip {
    flex: 0 0 var(--chip-w);
    width: var(--chip-w);
    scroll-snap-align: center;
    height: 34px;
    padding: 0 4px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-rise);
    color: var(--ink-soft);
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
    transition: background-color .18s, color .18s, border-color .18s, transform .18s var(--ease);
}
.chip:hover { border-color: var(--gold); color: var(--ink); transform: translateY(-1px); }
.chip.active {
    background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
    border-color: transparent;
    color: #ffffff;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* ----- Search overlay --------------------------------------------------- */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    justify-content: center;
    padding: clamp(16px, 8vh, 96px) 16px 16px;
    background: color-mix(in srgb, var(--paper) 55%, rgba(20,12,4,.55));
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: fade .25s var(--ease) both;
}
.search-panel {
    width: min(720px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: rise .35s var(--ease) both;
}
.search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px;
    border-bottom: 1px solid var(--line);
}
.search-icon { width: 21px; height: 21px; fill: none; stroke: var(--ink-faint); stroke-width: 1.8; stroke-linecap: round; flex: none; }
#searchInput {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 1.32rem;
    font-weight: 600;
}
#searchInput:focus { outline: none; }
#searchInput::placeholder { color: var(--ink-faint); font-weight: 400; }

.search-version { display: inline-flex; gap: 3px; padding: 3px; background: var(--paper-2); border-radius: 999px; }
.search-version .vbtn { padding: 5px 11px; font-size: .78rem; }

.search-close { width: 38px; height: 38px; }

.search-meta { padding: 10px 18px; font-size: .82rem; color: var(--ink-faint); border-bottom: 1px solid var(--line); min-height: 18px; }
.search-meta b { color: var(--garnet); font-weight: 600; }

.search-results { overflow-y: auto; padding: 8px; }
.result {
    display: block;
    width: 100%;
    text-align: left;
    padding: 13px 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    transition: background-color .16s, transform .16s var(--ease);
}
.result:hover { background: color-mix(in srgb, var(--gold) 13%, transparent); transform: translateX(2px); }
.result-ref {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .9rem;
    color: var(--garnet);
    margin-bottom: 3px;
}
.result-text { font-size: 1rem; line-height: 1.55; color: var(--ink-soft); }
.result-text mark { background: var(--mark-bg); color: var(--mark-ink); padding: 0 2px; border-radius: 3px; }

.search-empty, .search-hint { padding: 40px 18px; text-align: center; color: var(--ink-faint); font-style: italic; }
.search-more {
    display: block;
    width: calc(100% - 16px);
    margin: 8px;
    padding: 11px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-soft);
    font-family: var(--font-display);
    font-weight: 600;
}
.search-more:hover { border-color: var(--gold); color: var(--garnet); }

/* ----- Back-to-top button ---------------------------------------------- */
.to-top {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 70;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-rise) 86%, transparent);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    backdrop-filter: blur(10px) saturate(1.2);
    color: var(--garnet);
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(18px);
    transition: opacity .3s var(--ease), transform .3s var(--ease), color .2s, border-color .2s;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.to-top:hover { color: var(--garnet-soft); border-color: var(--gold); transform: translateX(-50%) translateY(-2px); }
.to-top:active { transform: translateX(-50%) translateY(0) scale(.93); }
.to-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ----- Toast ------------------------------------------------------------ */
.toast {
    position: fixed;
    left: 50%;
    bottom: 84px;                 /* sits above the back-to-top button */
    transform: translateX(-50%) translateY(20px);
    z-index: 80;
    padding: 11px 20px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font-size: .9rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: opacity .3s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----- Turnstile verification gate ------------------------------------- */
.gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(120% 90% at 100% 0%, var(--paper-2) 0%, var(--paper) 55%),
        var(--paper);
    transition: opacity .4s var(--ease);
}
.gate.hidden { opacity: 0; pointer-events: none; }
.gate-card {
    display: grid;
    justify-items: center;
    gap: 16px;
    text-align: center;
    animation: rise .5s var(--ease) both;
}
.gate-mark {
    width: 66px; height: 66px;
    border-radius: 18px;
    overflow: hidden;
    background: #14122b;
    box-shadow: var(--shadow-md);
}
.gate-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gate-card h1 {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.9rem;
    margin: 4px 0 0;
    color: var(--grad-to);
    background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.gate-card p { margin: 0; color: var(--ink-faint); font-size: .95rem; }
.gate-card .cf-turnstile { min-height: 65px; }

/* ----- Animations ------------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes verseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----- Responsive ------------------------------------------------------- */
@media (max-width: 880px) {
    .search-trigger { min-width: 0; }
    .search-trigger span, .search-trigger kbd { display: none; }
    .search-trigger { width: 42px; height: 42px; justify-content: center; padding: 0; border-radius: 12px; }

    /* Collapse the Kitab pill to an icon button too */
    .kitab-trigger span, .kitab-trigger kbd { display: none; }
    .kitab-trigger { width: 42px; height: 42px; justify-content: center; padding: 0; border-radius: 12px; }

    /* Chapter nav drops to its own centered row for easy thumb access */
    .topbar { flex-wrap: wrap; row-gap: 9px; }
    .chapter-nav { order: 5; flex-basis: 100%; gap: 6px; }
    .chapter-nav .pager-btn { width: 44px; height: 42px; }
}

@media (max-width: 560px) {
    body { font-size: 16px; }
    .verses { font-size: 1.08rem; }
    .brand-sub { display: none; }
    .chapter-bar { gap: 12px; }
    .version-switch { width: 100%; justify-content: center; }
    /* Larger touch targets for the 5-chip window on phones */
    .chapter-nav .chapter-grid { --chip-w: 46px; }
    .chapter-nav .chip { height: 40px; font-size: .98rem; }
}

/* ----- Motion / a11y preferences --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Scrollbars */
.palette-list::-webkit-scrollbar, .search-results::-webkit-scrollbar { width: 9px; }
.palette-list::-webkit-scrollbar-thumb, .search-results::-webkit-scrollbar-thumb {
    background: var(--line-strong); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box;
}
