/* CHIKARA Scripture - Style 1 Gold (Standards 2.4). Light is the default; dark and sepia are remembered choices via data-theme. */
@font-face { font-family: 'Cormorant Garamond'; src: url('fonts/cormorant-garamond-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cormorant Garamond'; src: url('fonts/cormorant-garamond-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url('fonts/plus-jakarta-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url('fonts/plus-jakarta-sans-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }

:root {
  --f-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --f-body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --halo-size: 70px; --petal-size: 56px; --radius-inner: 112px; --read-size: 1.15rem;
  --splash-bg: #09443B;
  --r: 14px;
}
/* Bridge from the CHIKARA Theme Kit (chikara-theme.css, canonical) to this app's names. The kit sets --text --muted --surface --surface-2
   --surface-3 --line --hair --gold --gold-band --teal --state-text and the plaster background; nothing below redefines a kit colour. */
:root { --primary: #C9973A; --on-primary: #1A140C; }
html[data-theme] { --ink: var(--text); --alt: var(--surface-3); --bg: var(--surface); --primary-ink: var(--gold); --teal-ink: var(--state-text); --edge: var(--muted); }
html[data-family="dark"] { color-scheme: dark; --danger-ink: #F29184; --hl1: #5A4A18; --hl2: #1F4E45; --hl3: #6A2E28; --hl4: #2B3C66; --woj: #3DDC97; }
html[data-family="light"] { color-scheme: light; --danger-ink: #8F2E24; --hl1: #F3E0A0; --hl2: #BFE3D6; --hl3: #F6D3CC; --hl4: #D1DCF0; --woj: #08603F; }
html[data-theme="mustard"] { --woj: #053D28; --danger-ink: #5C130C; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); font: 400 15px/1.5 var(--f-body); min-height: 100dvh; }
.mono { font-family: var(--f-mono); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--primary-ink); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--f-display); font-weight: 600; margin: 0; }

/* Buttons: one style family */
.btn { min-height: 44px; min-width: 44px; padding: 8px 14px; border: 1px solid var(--edge); border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 600; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 8px; }
.btn.primary { background: var(--gold-band); background-size: 100% 150%; background-position: top; border-color: var(--primary); color: var(--on-primary); }
.btn[aria-pressed="true"] { background: var(--alt); border-color: var(--primary-ink); color: var(--primary-ink); }

/* Island reference layout (Standards C.2) */
:root { --safe-top: env(safe-area-inset-top, 0px); --island-h: 40px; --island-gap: 8px; --island-top: max(10px, var(--safe-top)); --island-strip: calc(var(--island-top) + var(--island-h) + var(--island-gap)); --island-bg: #1A1208; --island-ink: #FBF5EA; --island-ok: #4ADE80; --island-warn: #FBBF24; --island-off: #F87171; }
html.has-island body { padding-top: var(--island-strip); }
html.has-island::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: var(--island-strip); background: var(--plaster-base); z-index: 199; pointer-events: none; }
.topbar { position: sticky; top: 0; padding-top: var(--safe-top); z-index: 80; background: var(--ck-bar); }
html.has-island .topbar { top: var(--island-strip); padding-top: 0; }
.island { box-sizing: border-box; position: fixed; top: var(--island-top); left: 50%; transform: translateX(-50%); z-index: 200; width: max-content; max-width: min(440px, calc(100vw - 2rem)); min-height: var(--island-h); background: var(--island-bg); color: var(--island-ink); border: 0; border-radius: 999px; box-shadow: 0 8px 32px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.14), inset 0 1px 0 rgba(255,255,255,.08); transition: border-radius .35s cubic-bezier(.175,.885,.32,1.275), padding .35s ease; }
.island[hidden] { display: none; }
.island.expanded { border-radius: 22px; }
.island-toggle { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--island-h); padding: 8px 18px; background: none; border: 0; color: inherit; font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.3; text-align: left; cursor: pointer; }
.island-toggle::after { content: ''; position: absolute; inset: -2px 0; }
.island-toggle[aria-disabled="true"] { cursor: default; }
.island-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 999px; }
.island-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.island.expanded .island-text { white-space: normal; }
.island-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; animation: island-pulse 2s ease-in-out infinite; }
.island-dot[data-state="ok"] { background: var(--island-ok); box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.island-dot[data-state="warn"] { background: var(--island-warn); box-shadow: 0 0 0 3px rgba(251,191,36,.25); }
.island-dot[data-state="off"] { background: var(--island-off); box-shadow: 0 0 0 3px rgba(248,113,113,.25); animation: none; }
.island-detail { padding: 0 18px 12px 37px; font-size: 12px; font-weight: 500; color: #C3BCB2; }
@keyframes island-pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.15); opacity: .85; } }
html.has-island .modal { max-height: calc(100dvh - var(--island-strip) - 16px); }

/* Header */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-left: 14px; padding-right: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 8px 4px 0; background: none; border: 0; text-align: left; }
.crest { width: 40px; height: 40px; border-radius: 50%; display: block; }
.wordmark { font-family: var(--f-display); font-weight: 600; font-size: 1.35rem; letter-spacing: .01em; }
.badges { display: flex; gap: 6px; }
.badge { padding: 5px 10px; border-radius: 999px; background: var(--alt); color: var(--ink); font-size: .75rem; font-weight: 700; }
.badge.mono { color: var(--teal-ink); }

/* Menu */
.menu { position: fixed; z-index: 150; left: 10px; top: calc(var(--safe-top) + 64px); width: min(360px, calc(100vw - 20px)); max-height: calc(100dvh - 90px); overflow: auto; background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; }
html.has-island .menu { top: calc(var(--island-strip) + 64px); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; flex-wrap: wrap; }
.menu-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.menu-item { width: 100%; min-height: 44px; text-align: left; background: none; border: 0; padding: 8px 8px; border-radius: 10px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.menu-item:hover { background: var(--alt); }
.menu-jumps, .stepper { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
kbd { font-family: var(--f-mono); font-size: .75rem; color: var(--muted); border: 1px solid var(--edge); border-radius: 6px; padding: 1px 6px; }

/* Layout */
.app { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(var(--halo-size) + 60px + env(safe-area-inset-bottom, 0px)); }
.card, .panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); min-width: 0; position: relative; overflow: hidden; }
.accent-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary), var(--teal)); }
.refbtn { max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-display); font-size: 1.15rem; }
.row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.field { min-height: 44px; min-width: 0; width: 100%; border: 1px solid var(--edge); border-radius: 10px; padding: 8px 10px; background: var(--surface); color: var(--ink); }
textarea.field { min-height: 110px; resize: vertical; }
.lbl, .small { font-size: .8rem; color: var(--muted); }
.empty { color: var(--muted); font-size: .9rem; margin: 0; }
.footer { color: var(--muted); font-size: .8rem; text-align: center; margin: 18px 0 0; }
.setup { padding: 22px 18px 18px; }
.setup h2 { font-size: 1.7rem; margin-bottom: 6px; }
.progress { height: 8px; border-radius: 8px; background: var(--alt); overflow: hidden; margin: 12px 0 6px; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--teal)); }
.notice { border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 10px; padding: 10px 12px; font-size: .88rem; background: var(--surface); margin: 10px 0; }

/* Reader */
.reader { padding: 18px 16px 16px; }
.reader-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.reader-head h2 { font-size: clamp(1.4rem, 5vw, 2rem); text-align: center; flex: 1; }
.chapter-sub { text-align: center; font-style: italic; color: var(--muted); margin: 0 0 8px; font-family: var(--f-display); font-size: 1.1rem; }
.verses { font-family: var(--f-display); font-size: var(--read-size); line-height: 1.7; }
.sec { font-family: var(--f-body); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary-ink); margin: 18px 0 4px; }
.v { display: block; padding: 3px 6px; margin: 0 -6px; border-radius: 8px; position: relative; scroll-margin-top: calc(var(--island-strip, 0px) + 80px); }
.v.para { margin-top: 12px; }
.v i { font-style: italic; }
.vn { display: inline-block; min-width: 44px; min-height: 44px; margin: -14px 0 -14px -10px; padding: 0 4px; vertical-align: baseline; background: none; border: 0; font-family: var(--f-body); font-size: .7em; font-weight: 700; color: var(--primary-ink); position: relative; top: .1em; }
.vn::after { content: ''; }
.v.hl1 { background: var(--hl1); } .v.hl2 { background: var(--hl2); } .v.hl3 { background: var(--hl3); } .v.hl4 { background: var(--hl4); }
.v.bm::before { content: ''; position: absolute; left: -4px; top: 6px; width: 4px; height: 22px; border-radius: 2px; background: var(--primary); }
.v.target { outline: 3px solid var(--primary-ink); outline-offset: 1px; }
.v.gap { color: var(--muted); font-style: italic; font-family: var(--f-body); font-size: .85rem; }
.v.dmg .dmgflag { font-family: var(--f-body); font-size: .72rem; color: var(--danger-ink); margin-left: 6px; font-style: normal; font-weight: 700; }
.vnote { font-family: var(--f-body); font-size: .85rem; border-left: 3px solid var(--teal); padding: 2px 8px; margin: 3px 0 3px 4px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.reader-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Pickers and results */
.book-group { font-family: var(--f-body); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.grid.nums { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.grid .btn { padding: 6px 4px; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.sw { min-width: 44px; min-height: 44px; border-radius: 12px; border: 2px solid var(--edge); }
.sw.s1 { background: var(--hl1); } .sw.s2 { background: var(--hl2); } .sw.s3 { background: var(--hl3); } .sw.s4 { background: var(--hl4); }
.sw[aria-pressed="true"] { border-color: var(--primary-ink); outline: 2px solid var(--primary-ink); outline-offset: 1px; }
.result { display: block; width: 100%; text-align: left; min-height: 44px; padding: 8px 10px; background: none; border: 1px solid transparent; border-bottom-color: var(--line); border-radius: 10px; }
.result:hover, .result:focus-visible { background: var(--alt); }
.result .rref { font-family: var(--f-body); font-weight: 700; font-size: .85rem; color: var(--primary-ink); display: block; }
.result .rtxt { font-family: var(--f-display); font-size: 1.05rem; line-height: 1.4; }
.result mark { background: var(--hl1); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.palette-list { display: grid; gap: 2px; margin-top: 8px; max-height: 55dvh; overflow: auto; }

/* Halo (Standards 5): four layers, upward petals, size tokens */
.halo { position: fixed; left: 50%; right: auto; top: auto; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: var(--halo-size); height: var(--halo-size); z-index: 120; border-radius: 50%; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; animation: breathe 3.6s ease-in-out infinite; }
.halo.dragging { cursor: grabbing; animation: none; }
.halo.open { animation: none; }
.halo-ring { position: absolute; inset: -2px; border-radius: 50%; background: conic-gradient(from 0deg, var(--primary), var(--teal), var(--primary), #E8C76F, var(--teal), var(--primary)); animation: spin 3.4s linear infinite; }
.halo.open .halo-ring { animation-duration: .7s; }
.halo-core { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); border-radius: 50%; object-fit: cover; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%,100% { filter: drop-shadow(0 4px 6px rgba(0,0,0,.28)) drop-shadow(0 0 4px rgba(201,151,58,.35)); } 50% { filter: drop-shadow(0 4px 6px rgba(0,0,0,.28)) drop-shadow(0 0 12px rgba(201,151,58,.7)); } }
.halo-backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(15,16,16,.35); }
.halo-petals { position: fixed; inset: 0; z-index: 130; pointer-events: none; }
.petal { position: absolute; width: var(--petal-size); height: var(--petal-size); margin: calc(var(--petal-size) / -2) 0 0 calc(var(--petal-size) / -2); border-radius: 50%; border: 1px solid var(--edge); background: var(--surface); color: var(--primary-ink); display: grid; place-items: center; padding: 0; pointer-events: none; opacity: 0; transform: translate(var(--from-x, 0), var(--from-y, 0)) scale(.5); transition: transform .38s cubic-bezier(0.34, 1.56, 0.64, 1), opacity .25s ease; }
.petal.out { opacity: 1; transform: translate(0, 0) scale(1); }
.petal.live { pointer-events: auto; }
.petal svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.petal[aria-current="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.petal-label { position: absolute; top: 100%; margin-top: 3px; left: 50%; transform: translateX(-50%); font-size: .7rem; font-weight: 700; background: #1A1208; color: #FBF5EA; padding: 2px 7px; border-radius: 8px; white-space: nowrap; }
.petal.col .petal-label { top: 50%; left: 100%; margin: 0 0 0 6px; transform: translateY(-50%); }

/* Modals, tour, update bar */
.modal-wrap { position: fixed; inset: 0; z-index: 300; background: rgba(15,16,16,.55); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); border-radius: 20px 20px 0 0; border: 1px solid var(--edge); padding: 18px; width: min(100%, 680px); max-height: 85dvh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.modal-head h2 { font-size: 1.6rem; }
.modal-body p { margin: 6px 0; }
.modal-body ul { padding-left: 20px; }
.modal-body li { margin: 4px 0; }
.about-lines p { margin: 2px 0; }
.palette-list { display: grid; gap: 4px; margin-top: 8px; max-height: 50dvh; overflow: auto; }
.palette-list button { text-align: left; min-height: 44px; padding: 8px 10px; background: none; border: 1px solid transparent; border-radius: 10px; }
.palette-list button:hover, .palette-list button:focus-visible { background: var(--alt); }
.tour { position: fixed; inset: 0; z-index: 400; background: rgba(15,16,16,.6); display: flex; align-items: center; justify-content: center; padding: 16px; pointer-events: auto; }
.tour-card { background: var(--surface); border: 1px solid var(--edge); border-radius: 18px; padding: 18px; max-width: 420px; width: 100%; }
.tour-card h2 { font-size: 1.6rem; margin: 4px 0; }
.tour-step { color: var(--muted); font-size: .75rem; margin: 0; }
.tour-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.tour-target { outline: 4px solid var(--primary); outline-offset: 4px; border-radius: 14px; position: relative; z-index: 401; }
.update-bar { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 350; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--edge); border-radius: 14px; padding: 8px 12px; box-shadow: var(--shadow); }
.update-bar span { flex: 1; font-weight: 600; }

/* Splash (Standards 17.1): plate colour = manifest colour; no credit line */
.splash { position: fixed; inset: 0; z-index: 1000; background: var(--splash-bg); color: #F2EDE2; display: grid; place-items: center; transition: opacity .6s ease; }
.splash.done { opacity: 0; pointer-events: none; }
.splash-inner { width: min(90vw, 420px); text-align: center; }
@media (min-width: 480px) { .splash-inner { width: min(90vw, 520px); } }

.splash-logo { width: 100%; height: auto; display: block; opacity: 0; transform: scale(.85); animation: logo-in 1.8s ease forwards; }
.splash-title, .splash-tag, .splash-bar, .splash-status { opacity: 0; animation: fade-in .5s ease forwards; }
.splash-title { font-size: 2rem; margin-top: 6px; animation-delay: 1.3s; }
.splash-tag { margin: 4px 0 14px; color: #D9D2C3; animation-delay: 1.55s; }
.splash-bar { height: 6px; border-radius: 6px; background: rgba(255,255,255,.18); overflow: hidden; animation-delay: 1.7s; }
.splash-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #C9973A, #E8C76F); }
.splash-status { font-family: var(--f-mono); font-size: .8rem; color: #D9D2C3; margin: 8px 0 0; min-height: 1.4em; animation-delay: 1.7s; }
.splash-skip { position: absolute; top: calc(14px + var(--safe-top)); right: 14px; min-height: 44px; min-width: 64px; padding: 8px 16px; border-radius: 999px; border: 1px solid rgba(255,255,255,.5); background: rgba(0,0,0,.25); color: #F2EDE2; font-weight: 700; }
@keyframes logo-in { to { opacity: 1; transform: scale(1); } }
@keyframes fade-in { to { opacity: 1; } }

@media (max-width: 760px) { .wordmark { font-size: 1.15rem; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .splash-logo, .splash-title, .splash-tag, .splash-bar, .splash-status { opacity: 1; transform: none; }
  .splash { transition: opacity .6s ease !important; }
}

/* Words of Jesus: emerald letters (data-woj="off" turns them off) */
.woj { color: var(--woj); }
html[data-woj="off"] .woj { color: inherit; }
.picker { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.picker .btn { padding: 6px 10px; }
.book-group:first-child { margin-top: 0; }
