/* =====================================================================
   Discover Jesus Now - student site styles
   Colours, type and spacing are set once as variables below.
   ===================================================================== */

/* ---------------------------------------------------------------------
   Fonts - hosted on this site (assets/fonts/, SIL Open Font License).
   Browsers only download a file when the page uses it; the Thai files
   load only on pages with Thai text.
   --------------------------------------------------------------------- */
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(fonts/fraunces-latin-wght-normal.woff2) format("woff2-variations"), url(fonts/fraunces-latin-wght-normal.woff2) format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Fraunces"; font-style: italic; font-weight: 100 900; font-display: swap;
    src: url(fonts/fraunces-latin-wght-italic.woff2) format("woff2-variations"), url(fonts/fraunces-latin-wght-italic.woff2) format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(fonts/inter-latin-wght-normal.woff2) format("woff2-variations"), url(fonts/inter-latin-wght-normal.woff2) format("woff2");
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Noto Sans Thai"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(fonts/noto-sans-thai-thai-wght-normal.woff2) format("woff2-variations"), url(fonts/noto-sans-thai-thai-wght-normal.woff2) format("woff2");
    unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }
@font-face { font-family: "Noto Serif Thai"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url(fonts/noto-serif-thai-thai-wght-normal.woff2) format("woff2-variations"), url(fonts/noto-serif-thai-thai-wght-normal.woff2) format("woff2");
    unicode-range: U+02D7,U+0303,U+0331,U+0E01-0E5B,U+200C-200D,U+25CC; }

:root {
    /* Colours */
    --navy-950: #0f1a30;
    --navy-900: #1c2b4a;
    --navy-800: #24375d;
    --navy-700: #2f4a7a;
    --navy-100: #e6ecf6;
    --navy-50:  #f2f5fb;
    --gold-600: #b27a1f;
    --gold-500: #d19a3a;
    --gold-400: #e8b85c;
    --gold-100: #f8ecd4;
    --gold-50:  #fcf7ec;
    --sage-700: #3d6b4c;
    --sage-500: #5a8a69;
    --sage-100: #e3efe6;
    --sage-50:  #f2f8f3;
    --plum-500: #7b6aa8;
    --plum-100: #ebe6f5;
    --plum-50:  #f6f4fa;
    --rose-600: #b3261e;
    --rose-50:  #fdf0ef;
    --ink:      #1b2233;
    --ink-2:    #3c4557;
    --muted:    #667085;
    --line:     #e6e1d7;
    --line-2:   #efebe3;
    --paper:    #ffffff;
    --cream:    #faf8f4;

    /* Type */
    --font-sans:  "Inter", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-serif: "Fraunces", "Noto Serif Thai", Georgia, "Times New Roman", serif;

    /* Shape and depth */
    --radius-sm: 10px;
    --radius:    16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(15, 26, 48, .06), 0 1px 3px rgba(15, 26, 48, .05);
    --shadow:    0 4px 12px rgba(15, 26, 48, .07), 0 1px 3px rgba(15, 26, 48, .05);
    --shadow-lg: 0 18px 40px -12px rgba(15, 26, 48, .22);
    --ring:      0 0 0 3px rgba(209, 154, 58, .45);

    --header-h: 68px;
    --tabbar-h: 64px;
}

/* ---------------------------------------------------------------------
   Base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--cream);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: var(--navy-700); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--navy-900); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; color: var(--navy-950); margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 3rem); }
h2 { font-size: clamp(1.35rem, 1.15rem + .9vw, 1.75rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
small { font-size: .85rem; }
::selection { background: var(--gold-100); }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--navy-900); color: #fff; padding: .5rem 1rem; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }
.wrap-narrow { max-width: 780px; }
.site-main { flex: 1; padding-bottom: 3rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* ---------------------------------------------------------------------
   Header
   --------------------------------------------------------------------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid transparent;
    transition: box-shadow .2s, border-color .2s;
}
.site-header.is-scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 20px -14px rgba(15, 26, 48, .35); }
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: 1.5rem; }

.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--navy-950); margin-right: auto; min-width: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 4px 10px -4px rgba(28, 43, 74, .6); flex-shrink: 0; }
/* A logo uploaded on the admin Header page: as tall as chosen there, never squeezed */
.brand-logo { display: block; height: var(--logo-h, 38px); width: auto; max-width: 260px; object-fit: contain; flex-shrink: 0; }
.area-admin .brand-logo { max-width: 120px; }
/* A long site name is cut short with "..." rather than pushing the menu off the screen.
   On the admin side the name is simply kept short, since the admin menu is wide. */
body:not(.area-admin) .main-nav { flex-shrink: 0; }
.area-admin .brand { flex-shrink: 0; }
.area-admin .brand-name { max-width: 200px; }
.brand-mark-sm { width: 28px; height: 28px; border-radius: 8px; box-shadow: none; }
.brand-name { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand-name strong { font-weight: 700; }

.main-nav { display: flex; gap: .25rem; }
.main-nav a {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .5rem .9rem; border-radius: 999px;
    color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem;
}
.main-nav a:hover { background: var(--navy-50); color: var(--navy-900); }
.main-nav a.is-active { background: var(--navy-900); color: #fff; }

.user-menu { position: relative; }
.user-menu > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
    padding: .25rem .5rem .25rem .25rem; border-radius: 999px; border: 1px solid var(--line);
    background: var(--paper); color: var(--ink-2); font-size: .9rem; font-weight: 500;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { border-color: #d6cfc2; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); color: #fff;
    font-size: .8rem; font-weight: 700; letter-spacing: .02em;
}
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px;
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: .4rem; z-index: 60;
    animation: pop .14s ease-out;
}
.menu-who { padding: .6rem .75rem .7rem; border-bottom: 1px solid var(--line-2); margin-bottom: .3rem; }
.menu-who strong { display: block; }
.menu-who small { color: var(--muted); word-break: break-all; }
.menu-panel a { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: .95rem; }
.menu-panel a:hover { background: var(--navy-50); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* Search: the round button in the header of every student page (search.php) */
.header-search {
    display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
    border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--ink-2);
}
.header-search:hover { border-color: #d6cfc2; color: var(--navy-900); }
.header-search.is-active { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.header-search .icon { width: 19px; height: 19px; }
.header-search + .settings-menu { margin-left: -.9rem; }      /* the two round buttons sit as a pair */

/* Settings (language) menu */
.settings-menu { position: relative; }
.settings-btn {
    display: inline-flex; align-items: center; gap: .4rem; height: 40px; padding: 0 .65rem;
    border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink-2); cursor: pointer;
}
.settings-btn:hover { border-color: #d6cfc2; color: var(--navy-900); }
.flag { width: 22px; height: 15px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(15, 26, 48, .12); flex: none; }
.settings-panel { min-width: 240px; }
.settings-label { padding: .2rem .75rem .35rem; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lang-options { display: grid; gap: .3rem; padding: 0 .1rem .2rem; }
.lang-options form { margin: 0; }
.lang-option {
    width: 100%; display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px;
    border: 1px solid transparent; background: transparent; font: 500 .95rem var(--font-sans); color: var(--ink); cursor: pointer; text-align: left;
}
.lang-option:hover { background: var(--navy-50); }
.lang-option .flag { width: 28px; height: 19px; }
.lang-option .icon { margin-left: auto; color: var(--gold-600); }
.lang-option.is-on { background: var(--gold-50); border-color: var(--gold-400); font-weight: 600; }
:lang(th) body, html[lang="th"] body { line-height: 1.75; }

/* ---------------------------------------------------------------------
   Footer and phone tab bar
   --------------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); background: var(--paper); padding: 2rem 0; color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem; }
.footer-brand { display: flex; align-items: center; gap: .5rem; font-family: var(--font-serif); color: var(--navy-900); font-weight: 600; }
.footer-verse { margin: 0; font-family: var(--font-serif); font-style: italic; color: var(--ink-2); }
.footer-verse span { font-style: normal; font-family: var(--font-sans); font-size: .8rem; color: var(--muted); margin-left: .35rem; }
.footer-links { margin: 0; }

.tab-bar { display: none; }

/* ---------------------------------------------------------------------
   Buttons, chips, progress, alerts, cards
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 44px; padding: .6rem 1.2rem; border-radius: 999px; border: 1px solid transparent;
    font: 600 .95rem/1.2 var(--font-sans); text-decoration: none; cursor: pointer;
    transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--navy-900); color: #fff; box-shadow: 0 6px 16px -8px rgba(28, 43, 74, .8); }
.btn-primary:hover { background: var(--navy-800); color: #fff; }
.btn-gold { background: linear-gradient(135deg, var(--gold-400), var(--gold-500)); color: var(--navy-950); box-shadow: 0 6px 16px -8px rgba(178, 122, 31, .9); }
.btn-gold:hover { color: var(--navy-950); filter: brightness(1.04); }
.btn-ghost { background: var(--paper); color: var(--navy-900); border-color: var(--line); }
.btn-ghost:hover { border-color: #cfc7b8; background: var(--navy-50); color: var(--navy-900); }
.btn-light { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .28); }
.btn-light:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.btn-sm { min-height: 36px; padding: .4rem .85rem; font-size: .88rem; }
.btn-icon { width: 44px; padding: 0; }
.btn-block { width: 100%; }

.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .65rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; line-height: 1.4; background: var(--navy-50); color: var(--navy-800); white-space: nowrap;
}
.chip .icon { width: 14px; height: 14px; }
.chip-gold    { background: var(--gold-100); color: #7a5312; }
.chip-sage    { background: var(--sage-100); color: var(--sage-700); }
.chip-rose    { background: var(--rose-50); color: var(--rose-600); }
.chip-muted   { background: #f0eee9; color: var(--muted); }
.chip-glass   { background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(6px); }

.progress { height: 8px; background: #ece7dd; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-500), var(--gold-400)); transition: width .6s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: .4rem; }

.alert { display: flex; gap: .65rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--radius-sm); border: 1px solid; margin: 1rem 0; font-size: .95rem; }
.alert .icon { margin-top: 2px; }
.alert-success { background: var(--sage-50); border-color: #c4dccb; color: var(--sage-700); }
.alert-error   { background: var(--rose-50); border-color: #f1c5c1; color: var(--rose-600); }
.alert-info    { background: var(--navy-50); border-color: #d3dcee; color: var(--navy-800); }
.flash-area { padding-top: 1rem; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: clamp(1.1rem, 3vw, 1.6rem); }

.eyebrow { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-600); margin-bottom: .5rem; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 3rem 0 1.25rem; }
.section-head h2 { margin: 0; }
.section-head p { margin: .25rem 0 0; color: var(--muted); }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .88rem; color: var(--muted); margin: 0 0 1rem; }
.breadcrumb a { color: inherit; text-decoration: none; }
.breadcrumb a:hover { color: var(--navy-900); text-decoration: underline; }
.breadcrumb .icon { width: 14px; height: 14px; opacity: .6; }
.on-dark .breadcrumb, .on-dark .breadcrumb a { color: rgba(255, 255, 255, .8); }

.admin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .6rem .9rem; border-radius: var(--radius-sm); background: var(--gold-50); border: 1px dashed #e2c78f; color: #6b4a12; font-size: .88rem; margin: 1rem 0; }
.admin-bar a { color: #6b4a12; font-weight: 600; }

/* ---------------------------------------------------------------------
   Student home
   --------------------------------------------------------------------- */
.hero {
    position: relative; overflow: hidden; color: #fff;
    background:
        radial-gradient(1200px 400px at 85% -10%, rgba(232, 184, 92, .28), transparent 60%),
        radial-gradient(800px 500px at -10% 110%, rgba(90, 138, 105, .25), transparent 60%),
        linear-gradient(135deg, var(--navy-950), var(--navy-800));
    padding: clamp(2.25rem, 6vw, 4.5rem) 0 clamp(4.5rem, 9vw, 6.5rem);
}
.hero::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M22 14v16M15 20.5h14' stroke='%23fff' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: center; }
.hero h1 { color: #fff; margin-bottom: .35em; }
.hero h1 em { font-style: italic; color: var(--gold-400); font-weight: 500; }
.hero-lead { font-size: clamp(1rem, .95rem + .3vw, 1.15rem); color: rgba(255, 255, 255, .82); max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

.votd {
    position: relative; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
    border-radius: var(--radius-lg); padding: clamp(1.25rem, 3vw, 1.75rem); backdrop-filter: blur(8px);
}
.votd .eyebrow { color: var(--gold-400); }
.votd blockquote { margin: 0; font-family: var(--font-serif); font-size: clamp(1.1rem, 1rem + .5vw, 1.35rem); line-height: 1.5; color: #fff; }
.votd .votd-ref { display: inline-flex; align-items: center; gap: .35rem; margin-top: 1rem; color: var(--gold-400); font-weight: 600; text-decoration: none; font-size: .92rem; }
.votd .votd-ref:hover { color: #fff; }
.votd .votd-note { margin: .9rem 0 0; font-size: .82rem; color: rgba(255,255,255,.75); }
.votd .votd-note a { color: var(--gold-400); }

.home-body { position: relative; margin-top: clamp(-3.5rem, -6vw, -2.5rem); z-index: 2; }

.stat-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 1rem; }
.continue-card { display: flex; gap: 1.1rem; align-items: center; padding: 1.1rem 1.25rem; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.continue-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: inherit; }
.continue-thumb { width: 64px; height: 64px; border-radius: 14px; flex: none; object-fit: cover; background: var(--navy-100); }
.continue-card .eyebrow { margin-bottom: .15rem; }
.continue-card > div { min-width: 0; }
.continue-thumb.placeholder-art { width: 64px; height: 64px; font-size: 1.4rem; }
.continue-card h3 { margin: 0 0 .15rem; font-size: 1.1rem; }
.continue-card p { margin: 0; color: var(--muted); font-size: .88rem; }
.continue-go { margin-left: auto; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-900); color: #fff; flex: none; }
.stat { padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: .9rem; }
.stat-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.stat-icon.gold { background: var(--gold-100); color: var(--gold-600); }
.stat-icon.sage { background: var(--sage-100); color: var(--sage-700); }
.stat-num { font-family: var(--font-serif); font-size: 1.7rem; font-weight: 600; line-height: 1; color: var(--navy-950); }
.stat-label { font-size: .85rem; color: var(--muted); }

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: clamp(1rem, 2.5vw, 1.5rem); }
.topic-card { display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: inherit; transition: transform .18s, box-shadow .18s; }
.topic-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); color: inherit; }
.topic-media { position: relative; aspect-ratio: 16 / 9; background: var(--navy-100); overflow: hidden; }
.topic-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.topic-card:hover .topic-media img { transform: scale(1.04); }
.topic-media .chip { position: absolute; left: .75rem; top: .75rem; background: rgba(15, 26, 48, .6); color: #fff; backdrop-filter: blur(6px); }
.topic-media .done-badge { position: absolute; right: .75rem; top: .75rem; background: var(--sage-500); color: #fff; }
.topic-body { padding: 1.1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.topic-body h3 { margin: 0; font-size: 1.25rem; }
.topic-body p { margin: 0; color: var(--muted); font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.topic-foot { margin-top: auto; padding-top: .75rem; }
.topic-cta { display: flex; align-items: center; justify-content: space-between; margin-top: .9rem; font-weight: 600; color: var(--navy-800); font-size: .92rem; }
.topic-cta .icon { transition: transform .18s; }
.topic-card:hover .topic-cta .icon { transform: translateX(4px); }

/* Placeholder picture for topics without a featured graphic */
.placeholder-art {
    width: 100%; height: 100%; display: grid; place-items: center; color: rgba(255, 255, 255, .9);
    font-family: var(--font-serif); font-size: 3rem; font-weight: 600;
    background:
        radial-gradient(circle at 80% 20%, rgba(232, 184, 92, .45), transparent 45%),
        linear-gradient(135deg, var(--navy-800), var(--navy-950));
}
.placeholder-art.v1 { background: radial-gradient(circle at 20% 20%, rgba(232, 184, 92, .45), transparent 45%), linear-gradient(135deg, #3d6b4c, #1f3d2c); }
.placeholder-art.v2 { background: radial-gradient(circle at 80% 80%, rgba(255, 255, 255, .25), transparent 45%), linear-gradient(135deg, #b27a1f, #6b4512); }
.placeholder-art.v3 { background: radial-gradient(circle at 30% 70%, rgba(232, 184, 92, .35), transparent 45%), linear-gradient(135deg, #5b3f7a, #2b1d40); }

.empty-state { text-align: center; padding: clamp(2rem, 6vw, 3.5rem) 1.5rem; }
.empty-state .icon-lg { color: var(--gold-500); margin: 0 auto .75rem; width: 44px; height: 44px; }
.empty-state h3 { margin-bottom: .35rem; }
.empty-state p { color: var(--muted); margin: 0 auto; max-width: 28rem; }

/* ---------------------------------------------------------------------
   Topic page
   --------------------------------------------------------------------- */
.topic-hero { position: relative; color: #fff; background: var(--navy-950); overflow: hidden; }
.topic-hero-bg { position: absolute; inset: 0; }
.topic-hero-bg img, .topic-hero-bg .placeholder-art { width: 100%; height: 100%; object-fit: cover; }
.topic-hero-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15, 26, 48, .35) 0%, rgba(15, 26, 48, .78) 60%, rgba(15, 26, 48, .95) 100%); }
.topic-hero-inner { position: relative; z-index: 1; padding-top: clamp(2rem, 6vw, 4rem); padding-bottom: clamp(2rem, 5vw, 3rem); min-height: clamp(260px, 38vw, 400px); display: flex; flex-direction: column; justify-content: flex-end; }
.topic-hero h1 { color: #fff; max-width: 46rem; }
.topic-hero .lead { color: rgba(255, 255, 255, .85); max-width: 42rem; font-size: 1.05rem; white-space: pre-line; }
.topic-hero .chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }

.topic-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(1.25rem, 3vw, 2rem); margin-top: clamp(1.5rem, 4vw, 2.5rem); align-items: start; }
.topic-side { position: sticky; top: calc(var(--header-h) + 16px); display: grid; gap: 1rem; }
.progress-ring { --p: 0; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
    background: conic-gradient(var(--gold-500) calc(var(--p) * 1%), #ece7dd 0); flex: none; }
.progress-ring > span { width: 76px; height: 76px; border-radius: 50%; background: var(--paper); display: grid; place-items: center;
    font-family: var(--font-serif); font-size: 1.35rem; font-weight: 600; color: var(--navy-950); }
.side-progress { display: flex; align-items: center; gap: 1rem; }
.side-progress p { margin: 0; color: var(--muted); font-size: .9rem; }
.side-progress strong { display: block; color: var(--ink); font-size: 1rem; }
.mode-note { display: flex; gap: .75rem; font-size: .9rem; color: var(--ink-2); }
.mode-note .icon { color: var(--gold-600); margin-top: 2px; }

.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.lesson-item { position: relative; }
.lesson-link { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.1rem; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
a.lesson-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d9d1c2; color: inherit; }
.lesson-num {
    width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
    font-weight: 700; font-size: .95rem; background: var(--navy-50); color: var(--navy-800); border: 2px solid var(--navy-100);
}
.lesson-item.is-done .lesson-num { background: var(--sage-500); border-color: var(--sage-500); color: #fff; }
.lesson-item.is-current .lesson-num { background: var(--gold-500); border-color: var(--gold-400); color: var(--navy-950); box-shadow: 0 0 0 5px var(--gold-100); }
.lesson-item.is-locked .lesson-link { background: #f7f5f1; box-shadow: none; }
.lesson-item.is-locked .lesson-num { background: #efece6; border-color: #e6e1d7; color: #a39d92; }
.lesson-item.is-locked .lesson-title { color: #8d877c; }
.lesson-text { min-width: 0; flex: 1; }
.lesson-title { display: block; font-weight: 600; color: var(--navy-950); line-height: 1.35; }
.lesson-sub { display: block; font-size: .83rem; color: var(--muted); margin-top: .15rem; }
.lesson-end { display: flex; align-items: center; gap: .5rem; flex: none; }
.lesson-end .icon { color: var(--muted); }
/* Step-by-Step: a line joining the numbered circles */
.lesson-list.is-steps .lesson-item:not(:last-child)::after {
    content: ""; position: absolute; left: calc(1.1rem + 20px); top: calc(50% + 21px); height: calc(100% - 42px + .75rem);
    width: 2px; background: var(--line); z-index: 0;
}
.lesson-list.is-steps .lesson-item.is-done:not(:last-child)::after { background: var(--sage-500); }

/* ---------------------------------------------------------------------
   Lesson page
   --------------------------------------------------------------------- */
.lesson-head { padding: clamp(1.75rem, 5vw, 3rem) 0 1rem; }
.lesson-head h1 { margin-bottom: .6rem; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; color: var(--muted); font-size: .9rem; }
.lesson-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: #cbc4b6; }
.step-track { display: flex; gap: 6px; margin-top: 1.25rem; }
.step-track span { flex: 1; height: 5px; border-radius: 99px; background: #e6e1d7; }
.step-track span.done { background: var(--sage-500); }
.step-track span.here { background: var(--gold-500); }

/* Read-aloud bar */
.tts {
    position: sticky; top: calc(var(--header-h) + 8px); z-index: 20;
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    padding: .5rem .6rem .5rem .85rem; margin: 1rem 0 1.75rem;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm);
}
.tts-label { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; font-size: .9rem; color: var(--navy-900); margin-right: auto; }
.tts-label .icon { color: var(--gold-600); }
.tts .btn { min-height: 38px; }
.tts .btn-icon { width: 38px; }
.popover { position: relative; }
.popover > summary { list-style: none; cursor: pointer; }
.popover > summary::-webkit-details-marker { display: none; }
.popover-panel {
    position: absolute; right: 0; top: calc(100% + 10px); width: min(320px, calc(100vw - 32px));
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 1rem; z-index: 40; animation: pop .14s ease-out;
}
.popover-panel label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin: .5rem 0 .3rem; }
.popover-panel label:first-child { margin-top: 0; }
.select, .popover-panel select {
    width: 100%; min-height: 42px; padding: .45rem 2.2rem .45rem .75rem; border-radius: 10px; border: 1px solid var(--line);
    background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right .6rem center / 16px;
    font: 500 .92rem var(--font-sans); color: var(--ink); appearance: none; -webkit-appearance: none;
}
.tts-tip { display: block; margin-top: .75rem; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.tts-label .short { display: none; }
.tts-note { flex-basis: 100%; font-size: .8rem; color: var(--muted); padding-left: .25rem; }
.tts-note:empty { display: none; }
.tts-speaking { background: linear-gradient(90deg, rgba(232, 184, 92, .22), rgba(232, 184, 92, .08)) !important; border-radius: 8px; box-shadow: 0 0 0 6px rgba(232, 184, 92, .12); transition: background .2s; }

/* The lesson's own recording: a player in the same bar as the Listen reader.
   When a lesson has both, one bar is shown at a time (see includes/lesson_audio.php). */
.tts[hidden], .audio-ui[hidden], .audio-bar audio[hidden], .listen-swap[hidden] { display: none; }
.audio-bar .tts-label { margin-right: .25rem; white-space: nowrap; }
.audio-bar audio { flex: 1 1 260px; min-width: 0; height: 40px; }
.audio-ui { display: flex; align-items: center; gap: .5rem; flex: 1 1 340px; min-width: 0; }
.audio-play { min-width: 5.9rem; }
.audio-play .when-paused, .audio-play .when-playing { display: inline-flex; }
.audio-play .when-playing, .audio-bar.is-playing .audio-play .when-paused { display: none; }
.audio-bar.is-playing .audio-play .when-playing { display: inline-flex; }
.audio-bar.is-loading .audio-play .icon { animation: audio-wait 1s ease-in-out infinite; }
@keyframes audio-wait { 50% { opacity: .35; } }
.audio-seek {
    --p: 0%;
    flex: 1 1 0; min-width: 56px; height: 28px; margin: 0 .2rem; padding: 0;
    appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; touch-action: none;
}
.audio-seek::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--gold-500) var(--p), var(--line) var(--p)); }
.audio-seek::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%;
    background: var(--navy-900); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(15, 26, 48, .4);
}
.audio-seek::-moz-range-track { height: 6px; border-radius: 99px; background: var(--line); }
.audio-seek::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--gold-500); }
.audio-seek::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--navy-900); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(15, 26, 48, .4); }
.audio-seek:focus-visible { outline: none; box-shadow: none; }
.audio-seek:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(209, 154, 58, .4); }
.audio-seek:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(209, 154, 58, .4); }
.audio-time { font-size: .84rem; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.audio-total { color: var(--muted); }
.audio-speed { min-width: 3.5rem; padding-left: .4rem; padding-right: .4rem; font-variant-numeric: tabular-nums; }
.audio-bar .tts-note { color: var(--rose-600); }

.reading { font-size: 1.075rem; line-height: 1.8; color: var(--ink); }
.reading > h2 { margin: 2.5rem 0 .9rem; display: flex; align-items: center; gap: .75rem; font-size: clamp(1.3rem, 1.15rem + .7vw, 1.6rem); }
.reading > h2::before { content: ""; width: 26px; height: 3px; border-radius: 3px; background: var(--gold-500); flex: none; }
.reading > h3 { margin: 1.9rem 0 .7rem; font-size: clamp(1.1rem, 1.03rem + .35vw, 1.28rem); color: var(--navy-900); }
.reading > p { margin: 0 0 1.15rem; }
.reading > p.intro { font-size: 1.15rem; color: var(--ink-2); }
/* Quotes and lists made in the lesson editor */
.reading > .lesson-quote {
    margin: 1.4rem 0 1.6rem; padding: .15rem 0 .15rem 1.15rem; border-left: 4px solid var(--gold-400);
    font-family: var(--font-serif); font-size: 1.1em; line-height: 1.65; color: var(--ink-2);
}
.reading > .lesson-quote + .lesson-quote { margin-top: -.9rem; }
.reading > .text-list { margin: 0 0 1.15rem; padding-left: 1.6rem; overflow: hidden; }
.reading > .text-list li { margin-bottom: .4rem; padding-left: .2rem; }
.reading > .text-list li::marker { color: var(--gold-600); font-weight: 600; }
.reading a:not(.bible-ref):not(.ref):not(.scripture-card) { text-underline-offset: 3px; overflow-wrap: anywhere; }
a.bible-ref { color: var(--navy-700); text-decoration: underline; text-decoration-color: rgba(47, 74, 122, .35); text-underline-offset: 3px; font-weight: 500; white-space: nowrap; }
a.bible-ref:hover { text-decoration-color: currentColor; }
/* Bible references in the lesson title and headings keep the heading's look; in a quoted verse they are gold on the dark card */
.lesson-head h1 a.bible-ref, .reading h2 a.bible-ref, .reading h3 a.bible-ref { color: inherit; font-weight: inherit; white-space: normal; text-decoration-thickness: 1.5px; text-underline-offset: .18em; }
.lesson-head h1 a.bible-ref:hover, .reading h2 a.bible-ref:hover, .reading h3 a.bible-ref:hover { color: var(--navy-700); }
.reading b a.bible-ref, .reading strong a.bible-ref { font-weight: inherit; }
.verse-card p a.bible-ref { color: var(--gold-400); font-weight: inherit; text-decoration-color: rgba(232, 184, 92, .5); }
.verse-card p a.bible-ref:hover { color: #fff; }

.scripture-card {
    display: flex; align-items: center; gap: 1rem; padding: 1rem 1.1rem; margin: 1rem 0 1.5rem;
    background: var(--sage-50); border: 1px solid #cfe1d4; border-radius: var(--radius); text-decoration: none; color: inherit;
    transition: transform .15s, box-shadow .15s;
}
.scripture-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.scripture-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--sage-500); color: #fff; flex: none; }
.scripture-card small { display: block; color: var(--sage-700); font-weight: 600; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.scripture-card strong { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 600; color: var(--navy-950); }
.scripture-card .version { color: var(--muted); font-size: .85rem; margin-left: .3rem; }
.scripture-card .go { margin-left: auto; color: var(--sage-700); display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; font-size: .88rem; white-space: nowrap; }

.verse-card {
    position: relative; margin: 1.25rem 0 1.75rem; padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 3vw, 2rem);
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); color: #fff; border-radius: var(--radius-lg);
    box-shadow: 0 16px 36px -18px rgba(28, 43, 74, .8); overflow: hidden;
}
.verse-card::before { content: "\201C"; position: absolute; right: 1rem; top: -1.5rem; font-family: var(--font-serif); font-size: 9rem; color: rgba(232, 184, 92, .18); line-height: 1; }
.verse-card p { position: relative; margin: 0; font-family: var(--font-serif); font-size: clamp(1.15rem, 1.05rem + .5vw, 1.4rem); line-height: 1.55; font-weight: 500; }
.verse-card p + p { margin-top: .75em; }                 /* a Bible section with several paragraphs */
.verse-card .ref { position: relative; display: inline-flex; align-items: center; gap: .35rem; margin-top: .9rem; color: var(--gold-400); font-weight: 600; font-size: .92rem; text-decoration: none; }
.verse-card .ref:hover { color: #fff; }
.verse-card .ref small { color: rgba(255, 255, 255, .6); font-weight: 500; }

/* Lesson pictures
   - beside the text: the paragraphs after it wrap around it
   - centered: in the middle on a line of its own, at a medium size
   - full width: as wide as the text (or as wide as the picture really is)
   - the reading column is a size container, so pictures stack above their
     paragraph whenever the column itself is narrow (not only on phones)
   - --img-w (set on each picture) is the picture's own width, so a small
     picture is never stretched larger than it really is */
.reading { container-type: inline-size; }
.reading::after { content: ""; display: table; clear: both; }
.reading > h2, .reading > h3, .reading > .verse-card, .reading > .scripture-card,
.reading > .question-card, .reading > .lesson-figure.is-wide, .reading > .lesson-figure.is-center, .reading > .lesson-video { clear: both; }

/* A video in a lesson (kept on YouTube or Vimeo): centered, in the usual player */
.lesson-video { margin: 1.75rem auto 1.9rem; max-width: 100%; }
.video-frame {
    position: relative; aspect-ratio: 16 / 9; width: 100%; overflow: hidden; border-radius: var(--radius-lg);
    background: var(--navy-950); box-shadow: 0 18px 34px -20px rgba(15, 26, 48, .55), 0 0 0 1px rgba(15, 26, 48, .06);
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-video figcaption { margin-top: .6rem; font-size: .85rem; line-height: 1.45; color: var(--muted); text-align: center; text-wrap: balance; }
.lesson-video .video-link { display: none; }        /* only on paper, where the video cannot play */
.lesson-figure { margin: 0 0 1.25rem; }
.lesson-figure img {
    display: block; width: 100%; height: auto; border-radius: var(--radius);
    background: var(--cream);
    box-shadow: 0 18px 34px -20px rgba(15, 26, 48, .55), 0 0 0 1px rgba(15, 26, 48, .06);
}
.lesson-figure.is-right { float: right; width: min(46%, var(--img-w, 360px)); margin: .45rem 0 1.1rem clamp(1.25rem, 3.5cqi, 2rem); }
.lesson-figure.is-left  { float: left;  width: min(46%, var(--img-w, 360px)); margin: .45rem clamp(1.25rem, 3.5cqi, 2rem) 1.1rem 0; }
.lesson-figure.is-center { width: min(58%, var(--img-w, 420px)); margin: 1.5rem auto 1.7rem; }
.lesson-figure.is-wide  { width: min(100%, var(--img-w, 100%)); margin: 1.75rem auto 1.9rem; }
.lesson-figure.is-wide img { border-radius: var(--radius-lg); }
.lesson-figure figcaption { margin-top: .6rem; font-size: .85rem; line-height: 1.45; color: var(--muted); text-align: center; text-wrap: balance; }
@container (max-width: 34rem) {
    .lesson-figure.is-right, .lesson-figure.is-left {
        float: none; width: min(100%, var(--img-w, 100%)); margin: .25rem auto 1.4rem;
    }
    .lesson-figure.is-center { width: min(80%, var(--img-w, 100%)); }
}

/* Small picture beside the lesson title */
.lesson-head.has-art { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem clamp(1rem, 4vw, 2.25rem); align-items: center; }
.lesson-art {
    margin: 0; width: min(clamp(76px, 17vw, 136px), var(--img-w, 136px)); padding: clamp(.45rem, 1.2vw, .7rem);
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); rotate: 2.5deg; transition: rotate .25s ease;
}
.lesson-art:hover { rotate: 0deg; }
.lesson-art img { display: block; width: 100%; height: auto; border-radius: 12px; }
.lesson-art figcaption { display: none; }

/* Tap to see a picture larger (only offered when the picture has more detail than shown) */
img.can-zoom { cursor: zoom-in; transition: transform .2s ease, box-shadow .2s ease; }
img.can-zoom:hover { transform: translateY(-2px); }
img.can-zoom:focus-visible { outline: none; box-shadow: var(--ring); }
.zoom-dialog { padding: 0; border: 0; background: transparent; overflow: visible; max-width: 96vw; max-height: 94vh; }
.zoom-dialog::backdrop { background: rgba(15, 26, 48, .78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.zoom-dialog[open] { animation: zoom-in .2s ease-out; }
.zoom-dialog img { display: block; max-width: min(96vw, 1400px); max-height: 86vh; width: auto; height: auto; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow-lg); }
.zoom-dialog p { margin: .75rem auto 0; max-width: 40rem; color: #fff; text-align: center; font-size: .92rem; }
.zoom-close {
    position: absolute; top: -.85rem; right: -.85rem; width: 42px; height: 42px; border-radius: 50%; border: 0;
    display: grid; place-items: center; background: var(--paper); color: var(--navy-900); box-shadow: var(--shadow); cursor: pointer;
}
.zoom-close:focus-visible { outline: none; box-shadow: var(--ring); }
@keyframes zoom-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* The copyright notice at the very bottom of a lesson, and the Bible translations' lines: small print */
.lesson-copyright { margin-top: 2.25rem; padding-top: .9rem; border-top: 1px solid var(--line); font-size: .8rem; line-height: 1.6; color: var(--muted); }
.lesson-copyright p { margin: 0; }
.lesson-copyright p + p { margin-top: .45rem; }
.lesson-copyright a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.lesson-copyright b { color: var(--ink-2); }

.questions-intro { margin: 2.5rem 0 1rem; }
.question-card { margin: 1rem 0 1.25rem; padding: clamp(1.1rem, 3vw, 1.4rem); border-left: 4px solid var(--gold-500); }
.question-top { display: flex; gap: .85rem; align-items: flex-start; }
.q-badge { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--gold-100); color: #7a5312; font-weight: 700; font-size: .9rem; margin-top: 2px; }
.q-text { font-weight: 500; color: var(--navy-950); line-height: 1.6; }
.answer-box {
    width: 100%; min-height: 120px; margin-top: .9rem; padding: .85rem 1rem; border-radius: 12px; border: 1px solid var(--line);
    background: #fdfcf9; font: 400 1rem/1.6 var(--font-sans); color: var(--ink); resize: vertical; transition: border-color .15s, box-shadow .15s, background .15s;
}
.answer-box:focus { outline: none; border-color: var(--gold-500); box-shadow: var(--ring); background: #fff; }
.answer-box::placeholder { color: #a6a093; }
.answer-foot { display: flex; justify-content: flex-end; min-height: 1.3rem; margin-top: .35rem; }
.save-state { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); }
.save-state.ok { color: var(--sage-700); }
.save-state.error { color: var(--rose-600); }
.answer-done { margin-top: .9rem; padding: .85rem 1rem; border-radius: 12px; background: var(--sage-50); border: 1px solid #d3e5d8; white-space: pre-wrap; }
/* A Yes or No question: two buttons to choose from instead of a box to type in
   (a question with a box as well has the box under them) */
.answer-choice { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .9rem; }
.answer-choice .yn-option { position: relative; display: inline-flex; margin: 0; }
.answer-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.answer-choice .yn-option span {
    display: inline-flex; align-items: center; justify-content: center; min-width: 6.5rem; min-height: 46px; padding: .5rem 1.4rem;
    border-radius: 999px; border: 1.5px solid var(--line); background: #fdfcf9; color: var(--navy-900);
    font: 600 1rem/1.3 var(--font-sans); transition: border-color .15s, box-shadow .15s, background .15s, color .15s;
}
.answer-choice input:hover + span { border-color: var(--gold-500); }
.answer-choice input:focus-visible + span { border-color: var(--gold-500); box-shadow: var(--ring); }
.answer-choice input:checked + span { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.answer-choice input:disabled { cursor: default; }
.answer-choice input:disabled + span { border-color: var(--line); color: var(--muted); }
.answer-choice .save-state { margin-left: auto; }
/* A multiple-choice question: one wide button for each choice, under each other, with its letter (ก ข ค / a b c) */
.answer-choice.is-list { flex-direction: column; align-items: stretch; gap: .5rem; }
.answer-choice .mc-option { position: relative; display: flex; margin: 0; }
.answer-choice .mc-option > span {
    flex: 1; display: flex; align-items: flex-start; gap: .75rem; min-height: 46px; padding: .6rem 1rem;
    border-radius: 12px; border: 1.5px solid var(--line); background: #fdfcf9; color: var(--ink);
    font: 400 1rem/1.55 var(--font-sans); text-align: left; transition: border-color .15s, box-shadow .15s, background .15s, color .15s;
}
.answer-choice .mc-letter {
    flex: none; width: 28px; height: 28px; margin-top: -1px; border-radius: 50%; display: grid; place-items: center;
    background: var(--gold-100); color: #7a5312; font-weight: 700; font-size: .9rem;
}
.answer-choice .mc-text { padding-top: .05rem; }
.answer-choice .mc-option input:checked + span .mc-letter { background: var(--gold-500); color: var(--navy-950); }
.answer-choice .mc-option input:checked + span a { color: #fff; }
.answer-choice.is-list .save-state { margin-left: 0; align-self: flex-end; }
/* After review: the student's choice was right, or which one was */
.answer-done.is-right { background: var(--sage-50); border-color: #b9d8c2; }
.answer-done.is-wrong { background: #fdf3f2; border-color: #f0cdc9; }
.answer-mark { display: flex; align-items: center; gap: .35rem; margin: .45rem 0 0; font-size: .92rem; font-weight: 600; }
.answer-mark.is-right { color: var(--sage-700); }
.answer-mark.is-wrong { color: var(--rose-600); }
.reviewer-note { display: flex; gap: .6rem; margin-top: .75rem; padding: .75rem .9rem; border-radius: 12px; background: var(--navy-50); color: var(--navy-800); font-size: .93rem; }
.reviewer-note .icon { margin-top: 2px; flex: none; }

.submit-card { margin: 2.5rem 0 1rem; padding: clamp(1.25rem, 3vw, 1.75rem); text-align: center; }
.submit-card h3 { margin-bottom: .35rem; }
.submit-card p { color: var(--muted); max-width: 32rem; margin: 0 auto 1.25rem; }
.submit-actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.submit-card.is-done { background: var(--sage-50); border-color: #cfe1d4; }
.submit-card.is-done .big-check { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto .9rem; background: var(--sage-500); color: #fff; box-shadow: 0 0 0 8px var(--sage-100); }
.submit-card.is-returned { background: var(--gold-50); border-color: #ecd6a8; }

/* Guest Mode: reading without logging in (includes/layout.php, lesson.php, topic.php) */
.header-login { white-space: nowrap; }
.guest-bar { background: var(--gold-50); border-bottom: 1px solid #ecd6a8; color: #5c4210; font-size: .9rem; }
.guest-bar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; padding-top: .55rem; padding-bottom: .55rem; }
.guest-text { flex: 1 1 18rem; min-width: 0; line-height: 1.45; }
.guest-actions { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.guest-actions .btn { min-height: 34px; padding: .3rem .85rem; font-size: .85rem; }
.guest-card p { margin: .7rem 0 1rem; color: var(--ink-2); font-size: .93rem; }
.submit-card.is-guest { background: var(--gold-50); border-color: #ecd6a8; }
.submit-card.is-guest .chip { margin-bottom: .75rem; }
.answer-guest {
    display: flex; gap: .5rem; align-items: flex-start; margin: .9rem 0 0; padding: .75rem .9rem;
    border: 1px dashed #dccfae; border-radius: 12px; background: #fdfcf9; color: var(--muted); font-size: .93rem;
}
.answer-guest .icon { flex: none; margin-top: 3px; }
.answer-guest a { font-weight: 600; }

/* Share a lesson: a button that opens a small menu (share_menu() in includes/layout.php) */
.share-menu { display: inline-block; }
.share-menu > summary { user-select: none; -webkit-user-select: none; }
.lesson-meta .meta-share { margin-left: auto; }
.share-panel { width: min(290px, calc(100vw - 32px)); padding: .6rem; text-align: left; color: var(--ink); font-size: .95rem; }
.share-head { display: block; padding: .35rem .5rem .5rem; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.share-item {
    display: flex; align-items: center; gap: .7rem; width: 100%; padding: .5rem; border: 0; border-radius: 10px;
    background: transparent; color: var(--ink); font: 500 .95rem var(--font-sans); text-decoration: none; text-align: left; cursor: pointer;
}
.share-item[hidden] { display: none; }
.share-item:hover { background: var(--navy-50); color: var(--ink); }
.share-item:focus-visible { outline: none; box-shadow: var(--ring); }
.share-dot { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 .85rem/1 var(--font-sans); }
.share-dot.share-plain { background: var(--navy-50); color: var(--navy-900); }
.share-copy { display: flex; gap: .4rem; margin-top: .5rem; padding: .6rem .3rem .2rem; border-top: 1px solid var(--line-2); }
.share-copy .input { min-width: 0; min-height: 36px; padding: .3rem .6rem; font-size: .82rem; }
.share-copy .btn { flex: none; min-height: 36px; white-space: nowrap; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .6rem 1rem; margin: 1.5rem 0 0; color: var(--ink-2); font-size: .95rem; text-align: center; }
@media (max-width: 760px) {
    /* On phones the share menu comes up from the bottom, so it never runs off the screen */
    .share-panel { position: fixed; left: 16px; right: 16px; top: auto; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); width: auto; z-index: 70; }
    .header-login { min-height: 36px; padding: .35rem .8rem; }
    .header-login .icon { display: none; }
    /* The Log in button is just above, in the header, so the Guest Mode line stays short */
    .guest-bar { font-size: .85rem; }
    .guest-actions { display: none; }
}
@media (max-width: 380px) {
    /* Very small phones: no room in the header, so the button goes in the Guest Mode line */
    .header-login { display: none; }
    .guest-actions { display: inline-flex; }
    .guest-actions .btn-ghost { display: none; }
}

.lesson-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 2rem 0 0; }
.pager-link { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.15rem; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; min-width: 0; }
a.pager-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.pager-link small { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.pager-link strong { color: var(--navy-950); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-link.next { text-align: right; align-items: flex-end; grid-column: 2; }
.pager-link.is-locked { background: #f7f5f1; color: var(--muted); box-shadow: none; }
.pager-link.is-locked strong { color: #8d877c; }

/* Friendly full-page messages (locked, not found) */
.message-page { text-align: center; padding: clamp(3rem, 10vw, 6rem) 0; }
.message-page .big-icon { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; margin: 0 auto 1.25rem; background: var(--gold-100); color: var(--gold-600); }
.message-page .big-icon .icon { width: 34px; height: 34px; }
.message-page p { color: var(--muted); max-width: 30rem; margin: 0 auto 1.5rem; }

/* ---------------------------------------------------------------------
   Resource Library: lesson PDFs as book covers
   --------------------------------------------------------------------- */
.library-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem 2rem; padding: clamp(1.75rem, 5vw, 3rem) 0 clamp(1.25rem, 3vw, 2rem); }
.library-head h1 { margin-bottom: .35rem; }
.library-sub { margin: 0; max-width: 36rem; color: var(--ink-2); }
.library-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.library-search {
    display: flex; align-items: center; gap: .5rem; min-height: 46px; padding: 0 .9rem; width: min(100%, 320px);
    background: var(--paper); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm);
    color: var(--muted); transition: border-color .15s, box-shadow .15s;
}
.library-search:focus-within { border-color: var(--gold-500); box-shadow: var(--ring); }
.library-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: 500 .95rem var(--font-sans); color: var(--ink); }
.lang-filter { display: inline-flex; padding: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm); }
.lang-filter label { position: relative; cursor: pointer; }
.lang-filter input { position: absolute; opacity: 0; pointer-events: none; }
.lang-filter span { display: block; padding: .45rem .95rem; border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--ink-2); transition: background .15s, color .15s; }
.lang-filter input:checked + span { background: var(--navy-900); color: #fff; }
.lang-filter input:focus-visible + span { box-shadow: var(--ring); }

.library-topic { margin: 0 0 clamp(2rem, 5vw, 3rem); }
.library-topic-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .9rem; padding-bottom: .75rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.library-topic-head h2 { margin: 0; font-size: clamp(1.25rem, 1.1rem + .6vw, 1.55rem); }
.library-topic-head h2 a { color: inherit; text-decoration: none; }
.library-topic-head h2 a:hover { color: var(--navy-700); }

.book-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 42vw), 1fr)); gap: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 2.5vw, 1.75rem); }
.book { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.book[hidden], .library-topic[hidden] { display: none; }

/* The cover: a book with a spine shadow on the left and a soft sheen */
.book-cover {
    position: relative; display: block; aspect-ratio: 3 / 4; border-radius: 4px 12px 12px 4px; overflow: hidden;
    background: var(--paper);
    box-shadow: 0 1px 2px rgba(15, 26, 48, .08), 0 14px 28px -14px rgba(15, 26, 48, .45);
    transition: transform .22s ease, box-shadow .22s ease;
}
.book-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.book-cover::before {
    content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: inherit;
    background: linear-gradient(90deg, rgba(0, 0, 0, .22) 0, rgba(0, 0, 0, .06) 4%, rgba(255, 255, 255, .18) 6%, rgba(255, 255, 255, 0) 12%),
                linear-gradient(135deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 45%);
}
/* No cover of its own: the PDF picture, centred on paper */
.book-cover.is-default { background: linear-gradient(160deg, #ffffff, #f3efe6); border: 1px solid var(--line); }
.book-cover.is-default img { object-fit: contain; padding: 22% 20%; }
a.book-cover:hover, a.book-cover:focus-visible { transform: translateY(-4px) rotate(-.6deg); box-shadow: 0 2px 4px rgba(15, 26, 48, .08), 0 22px 36px -16px rgba(15, 26, 48, .5); }
.book-get {
    position: absolute; right: .6rem; bottom: .6rem; z-index: 2; width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; background: var(--gold-500); color: #fff; box-shadow: 0 6px 14px -4px rgba(178, 122, 31, .6);
    opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .2s ease, transform .2s ease;
}
a.book-cover:hover .book-get, a.book-cover:focus-visible .book-get { opacity: 1; transform: none; }
@media (hover: none) { .book-get { opacity: 1; transform: none; width: 34px; height: 34px; } }
.book-lock { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: rgba(250, 248, 244, .55); color: var(--navy-800); }
.book-lock .icon { width: 30px; height: 30px; padding: 12px; box-sizing: content-box; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); }
.book.is-locked .book-cover img { filter: grayscale(1); opacity: .7; }

.book-info { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.book-title { font-family: var(--font-serif); font-weight: 600; font-size: 1.02rem; line-height: 1.35; color: var(--navy-950); text-decoration: none; overflow-wrap: anywhere; }
a.book-title:hover { color: var(--navy-700); text-decoration: underline; text-decoration-color: rgba(47, 74, 122, .35); text-underline-offset: 3px; }
.book.is-locked .book-title { color: #8d877c; }
.book-meta { display: flex; flex-wrap: wrap; align-items: center; font-size: .8rem; line-height: 1.5; color: var(--muted); }
.book-meta > span { white-space: nowrap; }
.book-meta > span + span::before { content: "·"; margin: 0 .35rem; color: #b9b2a5; }   /* dot between the parts */
.book-lang { align-self: flex-start; padding: .1rem .55rem; border-radius: 999px; background: var(--navy-50); color: var(--navy-800); font-size: .72rem; font-weight: 600; }
.book-meta-lock { flex-wrap: nowrap; align-items: flex-start; gap: .35rem; }
.book-meta-lock > span { white-space: normal; }
.book-meta-lock .icon { flex: none; margin-top: .15rem; }
.book-admin { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-top: .15rem; font-size: .8rem; }
.book-admin a { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; color: var(--plum-500); text-decoration: none; }
.book-admin a:hover { text-decoration: underline; }
.library-empty .big-icon { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; margin: 0 auto 1.25rem; background: var(--gold-100); color: var(--gold-600); }
.library-empty .big-icon .icon { width: 34px; height: 34px; }
.library-none { text-align: center; padding: 2rem 0; }

/* Book cover panel in the lesson editor */
/* Lesson editor: the Recording panel */
.audio-file-name { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .45rem; margin: 0 0 .55rem; font-size: .9rem; font-weight: 600; color: var(--navy-900); overflow-wrap: anywhere; }
.audio-file-name .icon { color: var(--gold-600); flex: none; }
.audio-file-name small { font-weight: 400; white-space: nowrap; }
.audio-check { display: block; width: 100%; height: 40px; }
.audio-check[hidden], .audio-ask[hidden], .audio-problem[hidden] { display: none; }
.audio-ask { margin-top: .85rem; padding: .85rem; border-radius: 12px; background: var(--gold-50); border: 1px solid var(--gold-100); }
.audio-question { margin: 0 0 .6rem; font-weight: 600; font-size: .95rem; line-height: 1.35; color: var(--navy-950); }
.audio-ask .choice { padding: .7rem .8rem; }
.audio-pick { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--line-2); }
.audio-pick > label { display: block; margin: 0 0 .4rem; font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.audio-pick .audio-check { margin-top: .6rem; }
.audio-problem { margin: .5rem 0 0; font-size: .85rem; line-height: 1.4; color: var(--rose-600); }
.cover-edit { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: .9rem; align-items: start; }
.cover-edit .book-cover { width: 96px; }
.cover-edit .book-cover.is-default img { padding: 20% 18%; }

/* ---------------------------------------------------------------------
   Search (search.php): the box, then what was found, the best first
   --------------------------------------------------------------------- */
.search-head { padding: clamp(1.75rem, 5vw, 3rem) 0 clamp(1rem, 3vw, 1.5rem); }
.search-head h1 { margin-bottom: 1.1rem; }
.search-form { display: flex; flex-wrap: wrap; gap: .6rem; }
.search-form .search-box { flex: 1 1 16rem; width: auto; min-height: 50px; }
.search-form .search-box input { font-size: 1.02rem; }
.search-hint { margin: .9rem 0 0; color: var(--muted); font-size: .92rem; }
.search-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.search-summary p { margin: 0; color: var(--ink-2); font-weight: 600; }
.search-filter { display: inline-flex; padding: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm); }
.search-filter a { padding: .4rem .85rem; border-radius: 999px; font-size: .86rem; font-weight: 600; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.search-filter a small { font-weight: 500; opacity: .7; margin-left: .15rem; }
.search-filter a:hover { color: var(--navy-900); }
.search-filter a.is-on { background: var(--navy-900); color: #fff; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-result { padding: 1.25rem 0; border-bottom: 1px solid var(--line-2); }
.search-kind { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-bottom: .45rem; }
.search-title { margin: 0; font-size: clamp(1.1rem, 1rem + .5vw, 1.3rem); line-height: 1.35; overflow-wrap: anywhere; }
.search-title a { color: var(--navy-950); text-decoration: none; }
.search-title a:hover { color: var(--navy-700); text-decoration: underline; text-decoration-color: rgba(47, 74, 122, .35); text-underline-offset: 3px; }
.search-result.is-locked .search-title { color: #8d877c; }
.search-excerpt { margin: .4rem 0 0; color: var(--ink-2); font-size: .95rem; line-height: 1.6; overflow-wrap: anywhere; }
.search-result mark { background: var(--gold-100); color: inherit; border-radius: 3px; }
.search-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; margin: .5rem 0 0; font-size: .85rem; color: var(--muted); }
.search-meta a { color: var(--navy-700); }
.search-download { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; text-decoration: none; }
.search-download:hover { text-decoration: underline; }
.search-locked { flex-basis: 100%; }
.search-more { margin: 1.25rem 0 0; color: var(--muted); font-size: .9rem; }
.page-search .empty-state { padding-top: clamp(1.5rem, 5vw, 2.5rem); }

/* ---------------------------------------------------------------------
   Bible reader
   --------------------------------------------------------------------- */
.bible-head { padding: clamp(1.5rem, 4vw, 2.5rem) 0 .5rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; justify-content: space-between; }
.bible-head h1 { margin: 0; }
.bible-head .chip { margin-left: .5rem; vertical-align: middle; }
.bible-picker { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.bible-picker .select { width: auto; min-width: 9rem; }
.bible-picker .select.chapter { min-width: 5.5rem; }
.chapter-text { font-family: var(--font-serif); font-size: clamp(1.1rem, 1.05rem + .25vw, 1.25rem); line-height: 1.95; color: #232a3a; padding: clamp(1.25rem, 4vw, 2.5rem); }
.chapter-text .verse { padding: .1rem .15rem; border-radius: 6px; transition: background .2s; }
.chapter-text .verse sup { font-family: var(--font-sans); font-size: .62em; font-weight: 700; color: var(--gold-600); margin-right: .2rem; cursor: pointer; padding: 0 .1rem; vertical-align: .55em; }
.chapter-text .verse sup:hover { color: var(--navy-900); }
.chapter-text .verse.hl { background: var(--gold-100); box-shadow: 0 0 0 3px var(--gold-100); }
.chapter-text .verse.start { box-shadow: 0 0 0 2px var(--gold-500); }
.chapter-text .verse.first sup { display: none; }
.chapter-text .drop { cursor: pointer; }
.chapter-text .drop { float: left; font-size: 3.6em; line-height: .8; font-weight: 600; color: var(--navy-900); margin: .1em .12em 0 0; }
.chapter-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; }
.copyright { font-size: .78rem; color: var(--muted); margin-top: 2rem; line-height: 1.5; }

/* ---------------------------------------------------------------------
   Tablets and phones
   --------------------------------------------------------------------- */
@media (max-width: 960px) {
    .hero-grid { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: 1fr 1fr; }
    .stat-row .continue-card { grid-column: 1 / -1; }
    .topic-layout { grid-template-columns: 1fr; }
    .topic-side { position: static; order: -1; }
}

@media (max-width: 760px) {
    :root { --header-h: 60px; }
    .main-nav, .user-name, .user-menu .icon-sm { display: none; }
    .settings-btn { height: 36px; padding: 0 .5rem; }
    .header-search { width: 36px; height: 36px; }
    .header-search + .settings-menu { margin-left: 0; }
    .header-inner { gap: .6rem; }
    .user-menu > summary { padding: 2px; border: 0; background: transparent; }
    .brand-name { font-size: 1.08rem; }
    .brand-mark { width: 34px; height: 34px; }
    .area-admin .brand { flex-shrink: 1; }
    .area-admin .brand-name { max-width: none; }
    .brand-logo, .area-admin .brand-logo { height: min(var(--logo-h, 38px), 40px); max-width: 170px; }

    body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
    .tab-bar {
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: rgba(255, 255, 255, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--line);
    }
    .tab-bar a {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        font-size: .7rem; font-weight: 600; color: var(--muted); text-decoration: none; -webkit-tap-highlight-color: transparent;
    }
    .tab-bar a .icon { width: 22px; height: 22px; }
    .tab-bar a.is-active { color: var(--navy-900); }
    .tab-bar a.is-active .icon { color: var(--gold-600); }

    .site-footer { padding: 1.5rem 0; }
    .footer-inner { flex-direction: column; align-items: flex-start; gap: .6rem; }

    .section-head { margin-top: 2.25rem; }
    .stat-row { gap: .75rem; }
    .stat { padding: .9rem 1rem; }
    .stat-num { font-size: 1.45rem; }
    .continue-thumb, .continue-thumb.placeholder-art { width: 52px; height: 52px; }

    .tts { border-radius: var(--radius); top: calc(var(--header-h) + 6px); }
    .tts { flex-wrap: nowrap; padding: .4rem .45rem .4rem .75rem; }
    .tts .btn-text { display: none; }
    .tts-label .long { display: none; }
    .tts-label .short { display: inline; }
    .tts-note { display: none; }
    .audio-bar { flex-wrap: wrap; }
    .audio-bar .tts-label { margin-right: 0; }
    .audio-bar .tts-note:not(:empty) { display: block; }
    .audio-ui { flex: 1 1 0; gap: .4rem; }
    .audio-play { min-width: 0; width: 38px; padding: 0; }
    .audio-total { display: none; }
    .audio-speed { min-width: 2.9rem; }
    .listen-swap { width: 38px; padding: 0; }
    .reading { font-size: 1.04rem; }
    .scripture-card .go span { display: none; }
    .lesson-pager { grid-template-columns: 1fr; }
    .pager-link.next { grid-column: auto; }
    .bible-picker { width: 100%; }
    .bible-picker .select { flex: 1; min-width: 0; }
    .chapter-text { padding: 1.25rem 1.1rem; }
}

@media (max-width: 420px) {
    .stat-label { font-size: .78rem; }
    .lesson-link { padding: .85rem .9rem; gap: .8rem; }
    .lesson-num { width: 36px; height: 36px; font-size: .85rem; }
    .lesson-list.is-steps .lesson-item:not(:last-child)::after { left: calc(.9rem + 17px); top: calc(50% + 18px); height: calc(100% - 36px + .75rem); }
    .lesson-end .chip-text { display: none; }
}

/* =====================================================================
   Admin area
   ===================================================================== */
.wrap-wide { max-width: 1280px; }
.area-admin { background: #f6f5f1; }
.admin-badge {
    margin-left: .4rem; padding: .15rem .5rem; border-radius: 6px; font-family: var(--font-sans);
    font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    background: var(--gold-100); color: #7a5312;
}
.area-admin .main-nav a { padding: .5rem .8rem; font-size: .92rem; }

.admin-main { padding-top: clamp(1.25rem, 3vw, 2rem); }
.admin-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; margin-bottom: 1.5rem; }
.admin-head h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); margin: 0; }
.admin-head .breadcrumb { margin-bottom: .5rem; }
.admin-sub { margin: .35rem 0 0; color: var(--muted); }
.admin-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.admin-grid > * { min-width: 0; }
.admin-side { display: grid; gap: 1rem; position: sticky; top: calc(var(--header-h) + 16px); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 1.25rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { font-size: 1.15rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.panel-head h2 .icon { color: var(--gold-600); }
.panel-body { padding: 1.25rem; }
.panel-foot { padding: .9rem 1.25rem; border-top: 1px solid var(--line-2); background: #fcfbf8; border-radius: 0 0 var(--radius) var(--radius); }

/* Dashboard */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { padding: 1.1rem 1.25rem; display: flex; gap: .9rem; align-items: center; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.stat-icon.navy { background: var(--navy-50); color: var(--navy-700); }
.stat-icon.rose { background: var(--rose-50); color: var(--rose-600); }
.kpi small { display: block; color: var(--muted); font-size: .8rem; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tool { display: flex; gap: 1rem; padding: 1.15rem 1.25rem; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tool:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d9d1c2; color: inherit; }
.tool .stat-icon { width: 44px; height: 44px; }
.tool h3 { font-size: 1.05rem; margin: 0 0 .2rem; }
.tool p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.tool .meta { display: inline-block; margin-top: .45rem; font-size: .8rem; font-weight: 600; color: var(--navy-700); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: .85rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--line-2); }
.activity li:last-child { border-bottom: 0; }
.activity .avatar { width: 36px; height: 36px; font-size: .75rem; flex: none; }
.activity .what { min-width: 0; flex: 1; font-size: .92rem; }
.activity .what strong { color: var(--navy-950); }
.activity .when { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .4rem; }
.field .help { display: block; font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.field .help[hidden] { display: none; }
.input, .textarea {
    width: 100%; min-height: 44px; padding: .6rem .8rem; border-radius: 10px; border: 1px solid var(--line);
    background: var(--paper); font: 400 .97rem/1.5 var(--font-sans); color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 7rem; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--gold-500); box-shadow: var(--ring); }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; }
.choice { position: relative; display: flex; gap: .75rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; }
.choice:hover { border-color: #d3cbbd; }
.field label.choice, .panel label.choice { display: flex; margin: 0; font-size: inherit; font-weight: inherit; color: inherit; }
.field label.check { display: inline-flex; font-weight: 500; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #c9c2b4; flex: none; margin-top: 2px; transition: border .15s; }
.choice strong { display: block; font-size: .95rem; color: var(--navy-950); }
.choice small { display: block; color: var(--muted); font-size: .82rem; line-height: 1.45; margin-top: .1rem; }
.choice:has(input:checked) { border-color: var(--gold-500); background: var(--gold-50); box-shadow: 0 0 0 1px var(--gold-500); }
.choice:has(input:checked) .dot { border: 6px solid var(--gold-500); }
.choice:has(input:focus-visible) { box-shadow: var(--ring); }
.check { display: inline-flex; align-items: center; gap: .5rem; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy-900); }
.file-drop { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 2px dashed #d8d0c1; border-radius: 12px; background: #fdfcf9; }
.file-drop .icon-lg { color: var(--gold-600); }
.file-drop > div { min-width: 0; flex: 1; }
.file-drop input[type=file] { font: inherit; font-size: .9rem; width: 100%; max-width: 100%; }
.image-preview { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); margin-bottom: .75rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.btn-danger { background: var(--paper); color: var(--rose-600); border-color: #efc9c5; }
.btn-danger:hover { background: var(--rose-50); color: var(--rose-600); border-color: #e3a9a3; }
.danger-zone { border-color: #f0d3d0; }
.danger-zone .panel-head h2 .icon { color: var(--rose-600); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .93rem; }
.table th { text-align: left; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .75rem 1rem; border-bottom: 1px solid var(--line); background: #fcfbf8; white-space: nowrap; }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfbf7; }
.table .cell-title { font-weight: 600; color: var(--navy-950); text-decoration: none; }
.table .cell-title:hover { text-decoration: underline; }
.table .cell-sub { display: block; font-size: .8rem; color: var(--muted); margin-top: .1rem; }
.table .cell-sub.warn-text { color: var(--rose-600); font-weight: 600; white-space: nowrap; }
.thumb { width: 72px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--navy-100); display: block; }
.thumb.placeholder-art { font-size: 1.1rem; }
/* A small book cover in a table (admin/books.php) */
.cover-thumb { display: block; width: 42px; aspect-ratio: 3 / 4; border-radius: 5px; overflow: hidden; background: #f3efe6; box-shadow: 0 0 0 1px rgba(15, 26, 48, .1); }
.cover-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-thumb.is-default img { object-fit: contain; padding: 18%; }
/* ---- Adding books to the Library (admin/books.php, run by assets/book_upload.js) ---- */
/* Where PDFs are chosen or dropped. "is-ready": a file is being dragged over the
   page; "is-over": it is over the panel and can be dropped. */
.drop-zone { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; padding: .85rem .9rem; border: 2px dashed #d8d1c3; border-radius: var(--radius-sm); background: var(--cream); transition: border-color .15s ease, background-color .15s ease; }
.drop-zone-hint { display: flex; align-items: center; gap: .45rem; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.drop-zone-hint .icon { color: var(--gold-600); flex: none; }
.drop-zone.is-ready { border-color: var(--gold-400); }
.drop-zone.is-over { border-color: var(--gold-600); background: var(--gold-50); }
.drop-zone:focus-within .drop-zone-pick { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.drop-zone-pick { cursor: pointer; }
@media (hover: none) {      /* phones and tablets: there is nothing to drag */
    .drop-zone { padding: 0; border: 0; background: none; }
    .drop-zone-hint { display: none; }
}
.field .help.upload-note { color: var(--rose-600); font-weight: 600; }
/* The books waiting to be added: a row for each. A row "is-ready", "is-sending",
   "is-done", "is-failed" (it can be tried again) or "is-refused" (it cannot). */
.book-queue { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.book-queue-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: .6rem; align-items: start; }
.book-queue-item button.cover-thumb { padding: 0; border: 0; cursor: pointer; font: inherit; }
.book-queue-item button.cover-thumb:hover:not(:disabled), .book-queue-item button.cover-thumb:focus-visible { box-shadow: 0 0 0 2px var(--gold-500); outline: none; }
.book-queue-item button.cover-thumb:disabled { cursor: default; }
.book-queue-main { min-width: 0; }
.book-queue-main .input { min-height: 38px; padding: .4rem .65rem; font-size: .9rem; }
.book-queue-note { display: block; margin-top: .25rem; font-size: .78rem; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.book-queue-item.is-done .book-queue-note { color: var(--sage-700); font-weight: 600; }
.book-queue-item.is-failed .book-queue-note, .book-queue-item.is-refused .book-queue-note { color: var(--rose-600); font-weight: 600; }
.book-queue-bar { display: block; height: 4px; margin-top: .3rem; border-radius: 2px; background: var(--line); overflow: hidden; }
.book-queue-bar[hidden] { display: none; }
.book-queue-bar > span { display: block; height: 100%; width: 0; background: var(--gold-500); transition: width .2s ease; }
.book-queue-remove { width: 32px; height: 32px; margin-top: 3px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.book-queue-remove:hover:not(:disabled) { color: var(--rose-600); border-color: var(--rose-600); }
.book-queue-remove:disabled { opacity: .4; cursor: default; }
/* The upload service did not answer the check made as the page opens */
.upload-check { margin-bottom: 1rem; padding: .8rem .9rem; border: 1px solid #f0c9c6; border-radius: var(--radius-sm); background: var(--rose-50); color: var(--rose-600); font-size: .88rem; }
.upload-check[hidden] { display: none; }
.upload-check p { margin: 0 0 .6rem; font-weight: 600; }
/* After a run in which some books were not added */
.upload-summary { margin: .6rem 0 0; font-size: .85rem; }
/* What the script did with the server, to copy and send when something goes wrong */
.upload-log { margin-top: .7rem; font-size: .8rem; color: var(--muted); }
.upload-log[hidden] { display: none; }
.upload-log summary { cursor: pointer; }
.upload-log pre { margin: .5rem 0; padding: .6rem .7rem; max-height: 14rem; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink-2); font-size: .72rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.order-btns { display: inline-flex; gap: .3rem; }
.order-btns form { display: inline; margin: 0; }
.order-btns .btn { min-height: 32px; width: 32px; padding: 0; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.num-col { width: 3rem; color: var(--muted); font-weight: 600; }

/* Lesson editor: a simple word processor (assets/lesson_editor.js).
   The lesson is one continuous page (.doc) made of text typed straight in
   (.doc-text) and cards for Bible verses, passages and pictures (.doc-card). */
.doc-toolbar {
    position: sticky; top: var(--header-h); z-index: 20;
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; padding: .5rem 1rem;
    background: rgba(252, 251, 248, .96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line-2);
}
.tb-group { display: inline-flex; align-items: center; gap: .15rem; padding-right: .6rem; border-right: 1px solid var(--line); }
.tb-group:last-child { border-right: 0; padding-right: 0; }
.doc-toolbar .tb-style { width: auto; min-height: 36px; padding-top: .3rem; padding-bottom: .3rem; font-size: .88rem; max-width: 11rem; }
.tb-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-width: 36px; height: 36px; padding: 0 .5rem;
    border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--navy-900);
    font: 600 .84rem/1 var(--font-sans); white-space: nowrap; cursor: pointer; transition: background .12s, border-color .12s;
}
.tb-btn:hover { background: var(--navy-50); border-color: var(--line); }
.tb-btn.is-on { background: var(--navy-100); border-color: #c5d1e6; }
.tb-btn[disabled] { opacity: .35; cursor: default; background: transparent; border-color: transparent; }
.tb-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.tb-btn > b, .tb-btn > i, .tb-btn > u { font-family: var(--font-serif); font-size: 1.08rem; }

.doc { position: relative; max-width: 46rem; margin: 0 auto; font-size: 1.05rem; line-height: 1.75; color: var(--ink); counter-reset: doc-q; }
.doc[lang="th"] { line-height: 1.95; }
.doc.is-empty::before { content: attr(data-placeholder); position: absolute; left: 0; top: 0; color: #9aa1ad; pointer-events: none; }
.doc-hint { max-width: 46rem; margin: 1.25rem auto 0; padding-top: .75rem; border-top: 1px dashed var(--line); font-size: .82rem; }
.doc-text { min-height: 1.75em; outline: none; cursor: text; overflow-wrap: anywhere; border-radius: 6px; }
.doc-text > p, .doc-text > ul, .doc-text > ol { margin: 0 0 .85rem; }
.doc-text > :last-child { margin-bottom: 0; }
.doc-text > h2 { margin: 1.5rem 0 .6rem; font-size: 1.45rem; }
.doc-text > h3 { margin: 1.2rem 0 .5rem; font-size: 1.15rem; color: var(--navy-900); }
.doc-text > h2:first-child, .doc-text > h3:first-child { margin-top: .25rem; }
.doc-text > h2 :is(b, i, u, strong, em), .doc-text > h3 :is(b, i, u, strong, em) { font-weight: inherit; font-style: inherit; text-decoration: none; }
.doc-text > blockquote {
    margin: 0 0 .85rem; padding: .15rem 0 .15rem 1rem; border-left: 4px solid var(--gold-400);
    font-family: var(--font-serif); font-size: 1.08em; color: var(--ink-2);
}
.doc-text > blockquote + blockquote { margin-top: -.85rem; padding-top: .5rem; }
.doc-text > ul, .doc-text > ol { padding-left: 1.6rem; }
.doc-text li { margin-bottom: .3rem; }
.doc-text li::marker { color: var(--gold-600); font-weight: 600; }
.doc-text a { color: var(--navy-700); text-decoration: underline; text-underline-offset: 3px; cursor: text; }
/* A question: students type their answer below it */
.doc-text > p.q {
    position: relative; min-height: 3rem; padding: .65rem .9rem .65rem 3.1rem; counter-increment: doc-q;
    background: var(--gold-50); border: 1px solid #eedfbd; border-left: 4px solid var(--gold-500); border-radius: 12px;
    font-weight: 500; color: var(--navy-950);
}
.doc-text > p.q::before {
    content: counter(doc-q); position: absolute; left: .75rem; top: .65rem; width: 28px; height: 28px; border-radius: 9px;
    display: grid; place-items: center; background: var(--gold-100); color: #7a5312; font: 700 .85rem/1 var(--font-sans);
}
/* A Yes or No question: the two choices students get are shown under it
   (the words come from the editor, in the lesson's language) */
.doc-text > p.q.yn::after {
    content: var(--yn-yes, "Yes") "   /   " var(--yn-no, "No"); display: block; width: fit-content; margin-top: .45rem; padding: .2rem .8rem;
    border-radius: 999px; border: 1.5px solid #e2cf9f; background: #fff; color: var(--navy-900);
    font: 600 .85rem/1.4 var(--font-sans); white-space: pre; pointer-events: none; user-select: none;
}

.doc-card {
    position: relative; margin: .9rem 0; padding: .5rem .9rem .8rem; background: var(--paper);
    border: 1px solid var(--line); border-left: 5px solid var(--sage-500); border-radius: 12px; box-shadow: var(--shadow-sm);
    font-size: .95rem; line-height: 1.5;
}
.doc-card.t-image { border-left-color: var(--plum-500); }
.doc-card.t-video { border-left-color: var(--navy-700); }
.doc-card.t-video .card-tag { color: var(--navy-700); }
.cv-video { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.cv-thumb {
    position: relative; flex: none; width: 132px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden;
    display: grid; place-items: center; background: var(--navy-900); color: #fff;
}
.cv-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cv-thumb .icon { position: relative; width: 28px; height: 28px; padding: 5px; border-radius: 50%; background: rgba(15, 26, 48, .65); fill: currentColor; }
.cv-video > div:last-child { min-width: 0; }
.cv-video strong { display: block; font-size: .9rem; color: var(--navy-950); }
.cv-video .muted { display: block; font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-status { display: block; margin-top: .35rem; font-size: .82rem; color: var(--sage-700); font-weight: 600; }
.video-status.is-bad { color: var(--rose-600); }
.video-preview { max-width: 420px; margin-top: .75rem; }
.video-preview .video-frame { border-radius: 12px; }
/* A question students answer by choosing (Yes or No, or multiple choice): numbered with the other questions */
.doc-card.t-question { border-left-color: var(--gold-500); background: var(--gold-50); counter-increment: doc-q; }
.doc-card.t-question .card-tag { color: #7a5312; }
.doc-card.t-question .card-tag::before { content: counter(doc-q) ". "; }
.cv-q-text { font-weight: 500; color: var(--navy-950); white-space: pre-line; }
.cv-choices { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; }
.cv-choices.is-yn { flex-direction: row; flex-wrap: wrap; gap: .4rem; }
.cv-choice { display: flex; align-items: flex-start; gap: .5rem; width: fit-content; max-width: 100%; padding: .2rem .7rem; border-radius: 10px; border: 1.5px solid #e2cf9f; background: #fff; color: var(--navy-900); }
.cv-choices.is-yn .cv-choice { border-radius: 999px; font-weight: 600; }
.cv-choice b { color: #7a5312; }
.cv-choice.is-right { border-color: var(--sage-500); background: var(--sage-50); }
.cv-choice.is-right .icon { flex: none; margin-top: .2rem; color: var(--sage-700); }
.cv-box { margin-top: .45rem; font-size: .85rem; color: var(--muted); }
.choice-rows { display: flex; flex-direction: column; gap: .35rem; }
.choice-rows .choice-row { display: flex; align-items: center; gap: .45rem; margin: 0; }
.choice-row .input { flex: 1; min-width: 0; }
.choice-row input[type=radio] { flex: none; width: 18px; height: 18px; accent-color: var(--sage-700); }
.choice-letter { flex: none; width: 1.6rem; text-align: center; color: #7a5312; }
.choice-row.is-yn, .choice-row.is-none { cursor: pointer; font-weight: 500; }
.choice-row .btn-icon { flex: none; }
.choice-add { padding-left: 2.2rem; }
.q-box { display: inline-flex; margin-top: .75rem; font-weight: 500; }
/* The lesson's copyright notice card: small print, like on the lesson page */
.doc-card.t-copyright { border-left-color: var(--muted); }
.doc-card.t-copyright .card-tag { color: var(--muted); }
.cv-copyright { font-size: .82rem; line-height: 1.6; color: var(--muted); }
.cv-copyright a { color: inherit; text-decoration: underline; }
.topic-copyright { padding: .5rem .7rem; border-radius: 8px; background: #faf8f3; }
/* A small box to type in with bold, italic, underline and links (assets/rich_text.js) */
.rich-text { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.rich-text:focus-within { border-color: var(--gold-500); box-shadow: var(--ring); }
.rich-bar { display: flex; gap: .15rem; padding: .25rem .35rem; border-bottom: 1px solid var(--line); background: #faf8f3; }
.rich-btn { min-width: 32px; height: 30px; padding: 0 .4rem; border: 0; border-radius: 6px; background: transparent; color: var(--navy-900); font: 600 .95rem/1 var(--font-serif, serif); cursor: pointer; display: inline-grid; place-items: center; }
.rich-btn:hover { background: var(--gold-100); }
.rich-box { min-height: 3.2rem; padding: .55rem .75rem; border: 0; box-shadow: none; outline: none; font-size: .88rem; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.rich-box.is-empty::before { content: attr(data-placeholder); color: #a6a093; pointer-events: none; }
.rich-box a { color: var(--navy-700); text-decoration: underline; }
.copyright-edit .help, #copyright .help { display: block; margin-top: .4rem; font-size: .85rem; color: var(--muted); }
/* Drag and drop in the lesson editor (with a mouse): the grip, the gold line where it will go */
.drag-grip { display: inline-grid; place-items: center; width: 22px; height: 26px; margin-right: .15rem; border: 0; border-radius: 6px; background: transparent; color: #a6a093; cursor: grab; touch-action: none; user-select: none; }
.drag-grip:hover { background: var(--gold-100); color: #7a5312; }
.head-grip { position: fixed; z-index: 40; padding: 0; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none !important; }
.is-dragged { opacity: .35; }
.drop-line { position: fixed; z-index: 60; height: 4px; border-radius: 4px; background: var(--gold-500); box-shadow: 0 0 0 3px rgba(209, 154, 58, .25); pointer-events: none; }
.drag-label { position: fixed; z-index: 61; max-width: 260px; padding: .25rem .6rem; border-radius: 8px; background: var(--navy-900); color: #fff; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; box-shadow: var(--shadow); }
.just-moved { animation: just-moved .9s ease-out; }
@keyframes just-moved { from { box-shadow: 0 0 0 4px rgba(209, 154, 58, .55); } to { box-shadow: 0 0 0 4px rgba(209, 154, 58, 0); } }
@media (hover: none), (pointer: coarse) { .drag-grip { display: none !important; } }
.doc-card.has-problem { border-color: #e3a9a3; border-left-color: var(--rose-600); box-shadow: 0 0 0 3px rgba(179, 38, 30, .12); }
.card-bar { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.card-bar .spacer { flex: 1; }
.card-bar .btn { min-height: 32px; padding: .25rem .65rem; font-size: .8rem; gap: .3rem; }
.card-bar .btn-icon { width: 32px; padding: 0; }
.card-tag { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sage-700); }
.doc-card.t-image .card-tag { color: #5a4a8a; }
.card-problem { margin: .45rem 0 0; color: var(--rose-600); font-size: .86rem; font-weight: 600; }
.card-view { margin-top: .35rem; border-radius: 8px; cursor: pointer; }
.card-view:focus-visible { outline: none; box-shadow: var(--ring); }
.cv-verse { font-family: var(--font-serif); font-size: 1.12rem; line-height: 1.55; color: var(--navy-950); }
.cv-verse.is-note, .bible-preview.is-note { font-family: var(--font-sans); font-size: .9rem; color: var(--muted); }
.cv-verse sup, .bible-preview sup { margin-right: .15rem; font-family: var(--font-sans); color: var(--muted); }
.cv-verse p, .bible-preview p { margin: 0; }                 /* a Bible section keeps its paragraphs */
.cv-verse p + p, .bible-preview p + p { margin-top: .55em; }
.doc-card.no-join { animation: no-join .3s 2; }               /* "Join above / below" found nothing to join */
@keyframes no-join { 50% { box-shadow: 0 0 0 3px rgba(179, 38, 30, .25); } }
.cv-ref { margin-top: .3rem; font-size: .88rem; font-weight: 600; color: var(--sage-700); }
.cv-ref span { font-weight: 500; color: var(--muted); }
.cv-passage small { display: block; font-size: .76rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sage-700); }
.cv-passage strong { font-family: var(--font-serif); font-size: 1.12rem; font-weight: 600; color: var(--navy-950); }
.cv-image { display: flex; align-items: center; gap: .9rem; }
.cv-pic { flex: none; display: grid; place-items: center; width: 132px; min-height: 64px; font-size: .82rem; text-align: center; }
.cv-pic img { display: block; max-width: 100%; max-height: 96px; border-radius: 6px; }
.cv-image strong { display: block; font-size: .9rem; color: var(--navy-950); }
.cv-image .muted { display: block; font-size: .86rem; }
.card-body .field { margin-top: .6rem; }
.card-body .textarea { min-height: 4rem; }
.use-row { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin: .65rem 0 .1rem; }
.verse-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0 .75rem; }
.verse-sides .is-off { opacity: .55; }
.bible-preview {
    min-height: 3.2rem; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: #faf8f3;
    font-family: var(--font-serif); line-height: 1.55;
}
.bible-preview small { display: block; margin-top: .35rem; font-family: var(--font-sans); color: var(--muted); }
.save-problem { color: var(--rose-600); font-size: .88rem; font-weight: 600; }

/* Picture cards in the lesson editor */
.doc-card.is-hidden { background: repeating-linear-gradient(135deg, #fbfaf7 0 12px, #f5f3ee 12px 24px); border-style: dashed; border-left-style: solid; }
.doc-card.is-hidden .img-thumb img, .doc-card.is-hidden .cv-pic img, .doc-card.is-hidden .cv-thumb img { opacity: .4; filter: grayscale(1); }
.hidden-chip { background: var(--plum-100); color: #4b3d7a; font-size: .75rem; }
.img-edit { display: grid; grid-template-columns: minmax(160px, 240px) minmax(0, 1fr); gap: 1rem 1.25rem; margin-top: .6rem; }
.img-thumb {
    display: grid; place-items: center; min-height: 130px; padding: .5rem; border: 1px solid var(--line); border-radius: 12px;
    background: #fff repeating-conic-gradient(#f1eee8 0 25%, #fff 0 50%) 0 0 / 16px 16px;   /* shows see-through parts */
}
.img-thumb img { display: block; max-width: 100%; max-height: 240px; border-radius: 6px; }
.img-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .6rem; }
.img-actions .btn { cursor: pointer; }
.img-status { font-size: .8rem; color: var(--muted); }
.img-controls .field:first-of-type { margin-top: .75rem; }
.img-show { font-weight: 600; }
.img-hint { margin: .5rem 0 0; font-size: .82rem; color: #6b4a12; background: var(--gold-50); border-radius: 8px; padding: .45rem .65rem; }
.place-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: .5rem; }
/* (.place-options .place-option is more specific than ".field label", so these win) */
.place-options .place-option {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: .4rem;
    padding: .6rem .5rem .65rem; margin: 0; position: relative;
    border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; text-align: center;
    font-size: .78rem; font-weight: 500; line-height: 1.3; color: var(--ink-2);
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.place-option svg { flex: none; width: 54px; height: 36px; fill: none; stroke: #c9c2b4; stroke-width: 2.2; stroke-linecap: round; }
.place-option svg .pic { fill: #d9d3c7; stroke: none; }
.place-option svg .title { stroke-width: 3.4; stroke: #b3ab9c; }
.place-option:hover { border-color: #cfc3e6; }
.place-option:has(input:checked) { border-color: var(--plum-500); background: var(--plum-50); box-shadow: 0 0 0 3px rgba(123, 106, 168, .15); color: #3f3368; }
.place-option:has(input:checked) svg .pic { fill: var(--plum-500); }
.place-option:has(input:focus-visible) { box-shadow: var(--ring); }
@media (max-width: 760px) { .img-edit { grid-template-columns: 1fr; } }
.ref-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: .6rem; align-items: end; }
.ref-row .check-link { white-space: nowrap; padding-bottom: .6rem; font-size: .88rem; font-weight: 600; }
.save-bar { position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; padding: .85rem 1rem; background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.dirty-note { color: #8a5a00; font-size: .88rem; font-weight: 600; }

/* "Please wait" screen while a page saves or a file is read (busyScreen in assets/app.js):
   a spinning ring and a line or two of text, over the dimmed page */
.busy-screen {
    position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 1.5rem;
    background: rgba(15, 26, 48, .45); backdrop-filter: blur(2px); cursor: progress; animation: busy-in .18s ease;
}
.busy-screen[hidden] { display: none; }
.busy-card {
    display: grid; justify-items: center; gap: .5rem; width: min(24rem, 100%); padding: 1.7rem 1.75rem 1.5rem;
    background: var(--paper); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); text-align: center;
}
.busy-card strong { font-size: 1.02rem; line-height: 1.45; color: var(--navy-950); }
.busy-note { font-size: .88rem; line-height: 1.45; color: var(--muted); }
.busy-ring {
    width: 46px; height: 46px; margin-bottom: .4rem; border-radius: 50%;
    border: 4px solid var(--gold-100); border-top-color: var(--gold-500); animation: busy-spin .85s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
@keyframes busy-in { from { opacity: 0; } }
pre.source { white-space: pre-wrap; background: #fbfaf6; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; font-size: .85rem; max-height: 420px; overflow: auto; }
details.panel > summary { cursor: pointer; padding: 1rem 1.25rem; font-weight: 600; list-style: none; display: flex; align-items: center; gap: .5rem; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .icon { color: var(--gold-600); }
details.panel[open] > summary { border-bottom: 1px solid var(--line-2); }
details.panel > .panel-body { padding-top: 1rem; }

.status-pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.published { background: var(--sage-100); color: var(--sage-700); }
.status-pill.draft { background: #f4ecdb; color: #8a5a00; }

/* Manage users */
.users-table .avatar { width: 38px; height: 38px; font-size: .8rem; }
.row-actions form { display: inline; margin: 0; }
.users-table .row-actions { flex-wrap: nowrap; }
.users-table .btn, .users-table td.muted { white-space: nowrap; }
.role-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: #faf8f4; margin: 0; }
.role-switch .seg { border: 0; background: transparent; font: 600 .8rem/1.2 var(--font-sans); padding: .4rem .8rem; border-radius: 999px; color: var(--muted); cursor: pointer; }
.role-switch .seg.is-on { background: var(--navy-900); color: #fff; }
.role-switch .seg:disabled { cursor: default; }
.role-switch .seg:not(.is-on):not(:disabled):hover { color: var(--navy-900); background: var(--navy-50); }

/* Translations page */
.tr-list { display: grid; }
.tr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--line-2); align-items: start; }
.tr-row:last-child { border-bottom: 0; }
.tr-row.is-missing { background: #fffaf0; }
.tr-en, .tr-th { display: flex; gap: .6rem; align-items: flex-start; min-width: 0; }
.tr-en > span:last-child { padding-top: .45rem; color: var(--ink); font-size: .95rem; overflow-wrap: anywhere; }
.tr-tag { flex: none; width: 34px; height: 24px; margin-top: .45rem; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--muted); background: #f0eee9; border-radius: 6px; }
.tr-tag .flag { width: 24px; height: 16px; }
.tr-th .tr-tag { background: transparent; }
.tr-th .textarea { min-height: 42px; padding: .5rem .7rem; font-size: .95rem; }
@media (max-width: 760px) {
    .tr-row { grid-template-columns: 1fr; gap: .4rem; padding: .85rem 1rem; }
}

/* Bible import */
.bible-import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1.5rem; align-items: start; }
.bible-import-grid .panel + .panel { margin-top: 0; }
@media (max-width: 760px) { .bible-import-grid { grid-template-columns: 1fr; } }
/* Bible reader: translation switch */
.tr-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--paper); }
.tr-switch a { padding: .35rem .8rem; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.tr-switch a.is-on { background: var(--navy-900); color: #fff; }
.tr-switch a:not(.is-on):hover { background: var(--navy-50); color: var(--navy-900); }
.chapter-text[lang="th"] { line-height: 2.05; }

/* The admin menu: on a laptop screen, Library, Bible and Translations show only their icons */
.area-admin .main-nav a { white-space: nowrap; }
@media (max-width: 1600px) {
    .area-admin .main-nav :is(.nav-library, .nav-bible, .nav-translations) span { display: none; }
    .area-admin .main-nav :is(.nav-library, .nav-bible, .nav-translations) { padding: .55rem; }
}
@media (max-width: 1100px) {
    .area-admin .main-nav a span { display: none; }
    .area-admin .main-nav a { padding: .55rem; }
}
@media (max-width: 960px) {
    .admin-grid { grid-template-columns: 1fr; }
    .admin-side { position: static; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .admin-badge { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .ref-row { grid-template-columns: 1fr 1fr; }
    .ref-row .check-link { grid-column: 1 / -1; padding: 0; }
    .kpi { padding: .9rem 1rem; }
    .panel-body { padding: 1rem; }
    .panel-head { padding: .9rem 1rem; }
    .save-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
    .admin-actions { width: 100%; }
    .admin-actions .btn { flex: 1; }

    /* Tables become stacked cards on phones */
    .table.stack thead { display: none; }
    .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
    .table.stack tr { padding: .75rem 1rem; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: auto 1fr auto; gap: .35rem .85rem; align-items: center; }
    .table.stack tr:last-child { border-bottom: 0; }
    .table.stack td { padding: 0; border: 0; }
    .table.stack td[data-label]:not(.keep-inline)::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
    .table.stack td.grow { grid-column: 2 / 3; }
    .table.stack td.full { grid-column: 1 / -1; }
    .table.stack td.hide-sm { display: none; }
    .users-table.stack td.role-cell { grid-column: 2 / -1; }
    .table.stack td.full .row-actions { justify-content: flex-start; flex-wrap: wrap; }
    .table.stack tbody tr:hover td { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
    .site-header, .tab-bar, .site-footer, .tts, .lesson-pager, .submit-actions,
    .guest-bar, .share-menu, .share-row, .answer-guest, .video-frame { display: none !important; }
    .lesson-video .video-link { display: block; text-align: center; font-size: .85rem; overflow-wrap: anywhere; }
    .lesson-figure img, .lesson-art { box-shadow: none; }
    body { background: #fff; }
}

/* ---------- Admin: Header page (site logo and name) ---------- */
.logo-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; margin-top: .5rem; }
.logo-slot { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; background: #fff; }
.logo-slot h3 { margin: 0 0 .75rem; font-size: 1rem; }
.logo-now { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; margin-bottom: .75rem; }
.logo-now-box { display: inline-flex; align-items: center; min-height: 60px; padding: .5rem .75rem; border: 1px dashed var(--line); border-radius: 10px; background: #fff; }
.logo-now-box img { display: block; width: auto; max-width: 220px; }
.logo-slot input[type=file] { max-width: 100%; }
.header-preview { display: flex; align-items: center; min-height: 60px; padding: .5rem .85rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.header-preview + .header-preview { margin-top: .6rem; }
.header-preview .brand { margin-right: 0; pointer-events: none; }
.preview-lang { display: block; margin: .9rem 0 .3rem; font-size: .85rem; font-weight: 600; color: var(--muted, #6b7280); }
.preview-lang:first-child { margin-top: 0; }


/* ---- Reviewing submitted lessons (admin/reviews.php, admin/review.php) ---- */
.nav-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: .3rem; border-radius: 999px; background: var(--rose-600); color: #fff; font: 700 .7rem/1 var(--font-sans); }
.tab-bar a { position: relative; }
.tab-bar .nav-count { position: absolute; top: 2px; left: 55%; margin: 0; }
.review-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.review-tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--navy-900); font-weight: 600; font-size: .9rem; text-decoration: none; }
.review-tabs a.is-on { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.review-tabs .tab-count { min-width: 1.4rem; padding: 0 .35rem; border-radius: 999px; background: rgba(15, 26, 48, .08); font-size: .78rem; text-align: center; }
.review-tabs a.is-on .tab-count { background: rgba(255, 255, 255, .2); }
.review-list { max-width: 52rem; }
.review-heading { margin: 1.6rem 0 .5rem; font-size: 1.15rem; color: var(--navy-950); }
.review-heading.is-sub { font-size: 1rem; color: var(--navy-800); }
.review-q { margin: .75rem 0; padding: 1rem 1.1rem; border-left: 4px solid var(--gold-500); }
.review-q .question-top { align-items: flex-start; }
.review-mark { margin-left: auto; flex: none; }
.review-answer { margin-top: .75rem; padding: .7rem .9rem; border-radius: 10px; background: var(--sage-50); border: 1px solid #d3e5d8; white-space: pre-wrap; }
.review-answer.is-empty { background: #faf8f3; border-color: var(--line); color: var(--muted); font-style: italic; }
.review-choices { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.review-choices.is-yn { flex-direction: row; flex-wrap: wrap; }
.review-choices li { display: flex; align-items: flex-start; flex-wrap: wrap; gap: .5rem; padding: .4rem .75rem; border-radius: 10px; border: 1.5px solid var(--line); background: #fdfcf9; color: var(--muted); }
.review-choices li b { color: #7a5312; }
.review-choices li.is-chosen { border-color: var(--navy-900); background: var(--navy-50); color: var(--navy-950); font-weight: 500; }
.review-choices li.is-right { border-color: var(--sage-500); }
.review-tag { font-style: normal; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; background: var(--navy-900); color: #fff; }
.review-tag.is-right { background: var(--sage-700); }
.review-note { margin-top: .75rem; }
.review-note label { font-size: .8rem; color: var(--muted); }
.review-note .textarea { min-height: 2.6rem; }
.review-finish { max-width: 52rem; margin-top: 1.5rem; }
.review-score { margin: 0 0 .9rem; font-weight: 600; color: var(--navy-900); }
.review-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
