/* Study layout prototype (study.html). Bible Bubble palette; sans throughout
   (Fredoka for the brand and titles, Nunito for everything read). Desktop: studies | chat | Bible. Tablet: chat | Bible with
   the studies as a drawer. Phone: chat, with the Bible as a bottom sheet. */

:root {
  --bg: #f7faff;
  --surface: #ffffff;
  --surface-2: #eef4ff;
  --line: rgba(31, 79, 224, 0.14);
  --line-strong: rgba(31, 79, 224, 0.28);
  --text: #13205a;
  --text-dim: #4b5886;
  --text-faint: #7d88ad;
  --accent: #1f4fe0;
  --accent-deep: #173cb0;
  --on-accent: #fff;
  --fill: var(--accent); /* one blue: borders and dots take the button colour */
  --user-bubble: #dce9ff;
  /* Warm amber: the verse being checked (cited, commented on, selected)
     and the pill that opened it. Blue is for what can be pressed. Kept
     more orange than --hl-yellow so it never reads as the reader's own
     highlight. */
  --mark: rgba(255, 176, 46, 0.2);
  --mark-strong: rgba(255, 176, 46, 0.38);
  --mark-edge: #f59a0b;
  --mark-pill: #ffe3ad;
  --mark-ink: #6b3d00;
  --selected: rgba(31, 79, 224, 0.1);
  --hl-yellow: #fff1a8;
  --hl-green: #cdf2d4;
  --hl-blue: #d6e6ff;
  --hl-pink: #ffd9ea;
  --shadow: 0 10px 30px rgba(19, 32, 90, 0.1);
  --radius: 16px;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1430;
    --surface: #151d40;
    --surface-2: #1b2550;
    --line: rgba(150, 175, 255, 0.14);
    --line-strong: rgba(150, 175, 255, 0.28);
    --text: #e8edff;
    --text-dim: #aab4dc;
    --text-faint: #7f8ab4;
    --accent: #8fb3ff;
    --accent-deep: #b6cdff;
    --on-accent: #0e1430;
    --user-bubble: #23336e;
    --mark: rgba(226, 178, 86, 0.2);
    --mark-strong: rgba(226, 178, 86, 0.36);
    --mark-edge: #d9a84a;
    --mark-pill: #6a4f1c;
    --mark-ink: #ffeec4;
    --selected: rgba(143, 179, 255, 0.14);
    --hl-yellow: rgba(255, 220, 90, 0.28);
    --hl-green: rgba(90, 210, 130, 0.25);
    --hl-blue: rgba(110, 160, 255, 0.28);
    --hl-pink: rgba(255, 120, 180, 0.25);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) minmax(380px, 44%);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "side chat reader";
}
.top { grid-area: top; }
.sidebar { grid-area: side; }
.chat { grid-area: chat; }
.reader { grid-area: reader; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font: 600 18px var(--display); white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.preview-pill { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); background: var(--surface-2); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text-dim); flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
#menu-btn { display: none; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: transparent; border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 700; color: var(--text-dim); }
.segmented button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(19, 32, 90, 0.12); }
.ghost-btn { display: none; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 13.5px; color: var(--text); }
.ghost-btn svg { width: 17px; height: 17px; }
.primary-btn { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 7px 15px; font-weight: 700; font-size: 13.5px; text-decoration: none; white-space: nowrap; }
.primary-btn:hover { background: var(--accent-deep); }

/* ---------- sidebar ---------- */
.sidebar { overflow-y: auto; padding: 16px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.new-study { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 12px; padding: 10px; font-weight: 700; }
.new-study:hover { border-color: var(--fill); background: var(--surface-2); }
.new-study svg { width: 18px; height: 18px; }
.side-section { margin-top: 22px; }
.side-section h2 { margin: 0 0 8px 6px; font: 600 12px var(--body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-list button { width: 100%; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; }
.side-list button:hover { background: var(--surface-2); }
.side-list button.on { background: var(--surface-2); font-weight: 700; }
.side-list .study-row { flex-direction: column; align-items: stretch; gap: 2px; }
.study-title { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; font-size: 14px; line-height: 1.3; }
.study-sub { font-size: 11.5px; font-weight: 600; color: var(--text-faint); }
.hl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.hl-ref { font-weight: 700; font-size: 13px; flex-shrink: 0; }
.hl-text { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.side-empty { margin: 0 6px; font-size: 13px; color: var(--text-faint); }
.side-note { margin: 26px 6px 0; font-size: 11.5px; color: var(--text-faint); }
.side-note a { color: inherit; }
/* Deleting what is saved: one study (the row's own button) or everything. */
.study-item { position: relative; }
.side-list .study-row { padding-right: 38px; }
.side-list .study-del { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 8px; color: var(--text-faint); opacity: 0; }
.side-list .study-del svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.study-item:hover .study-del, .study-del:focus-visible { opacity: 1; }
.side-list .study-del:hover { background: var(--surface); color: #c0365a; }
@media (hover: none) { .side-list .study-del { opacity: 1; } }
.side-clear { display: block; margin-top: 6px; padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; }
.side-clear:hover { color: #c0365a; }
.side-account { margin: 14px 6px 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-faint); overflow-wrap: anywhere; }
.side-account a { color: var(--text-dim); font-weight: 700; white-space: nowrap; }
/* Share links (study.js "share links"). */
.link-icon { width: 13px; height: 13px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.study-shared { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; color: var(--accent); font-weight: 800; }
.share-sub { display: inline-flex; align-items: center; gap: 4px; }
.msg-actions .share-btn { display: inline-flex; align-items: center; gap: 4px; }
.shared-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 10px; padding: 8px 12px; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 12px; font-size: 13px; line-height: 1.4; color: var(--text-dim); }
.shared-bar .link-icon { color: var(--accent); }
.shared-bar span { flex: 1; min-width: 180px; }
.shared-bar strong { color: var(--accent); }
.shared-bar button { border: 0; background: transparent; font: 700 12.5px var(--body); color: var(--accent); padding: 3px 6px; border-radius: 6px; }
.shared-bar button:hover { background: var(--surface); }
.shared-bar button[data-act="delete"] { color: #c0365a; }
.shared-banner { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.45; color: var(--text-dim); text-align: left; }
.shared-banner .link-icon { margin-top: 3px; color: var(--accent); }
.shared-banner strong { color: var(--text); }
.welcome .shared-banner { max-width: 520px; margin: 0 auto 18px; justify-content: center; }
.share-dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-family: var(--body); }
.share-dialog::backdrop { background: rgba(10, 18, 50, 0.45); }
.share-dialog h2 { margin: 0 0 12px; font: 600 20px var(--display); }
.share-q { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--user-bubble); font-size: 14px; line-height: 1.4; max-height: 6.5em; overflow: auto; overflow-wrap: anywhere; }
.share-warn { display: flex; gap: 8px; margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
.share-warn .link-icon { margin-top: 4px; color: var(--accent); }
.share-warn.alert { padding: 10px 12px; border-radius: 10px; background: var(--mark); border: 1px solid var(--mark-edge); }
.share-fine { margin: 0 0 16px; font-size: 13px; line-height: 1.45; color: var(--text-dim); }
.share-error { margin: -6px 0 12px; font-size: 13px; color: #c0365a; }
.share-error[hidden] { display: none; }
.share-url { display: flex; gap: 8px; margin-bottom: 14px; }
.share-url input { flex: 1; min-width: 0; border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 10px; font: 600 13.5px var(--body); color: var(--text); background: var(--bg); }
.share-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.share-dialog button { border-radius: 999px; padding: 8px 16px; font: 700 13.5px var(--body); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.share-dialog button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.share-dialog button.danger { margin-right: auto; color: #c0365a; }
.share-dialog button:disabled { opacity: 0.6; }

/* The account's plan and what is left of its questions today (study.js showPlan). */
.side-plan { display: block; margin-top: 4px; }
.side-plan[hidden] { display: none; }
.side-plan b { color: var(--text-dim); }
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 40, 0.35); z-index: 30; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 28px 24px 12px; }
.welcome { max-width: 560px; margin: 8vh auto 0; text-align: center; }
.welcome h1 { font: 600 30px/1.2 var(--display); margin: 0 0 10px; }
.welcome p { color: var(--text-dim); margin: 0 0 22px; }
.starters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.starter { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.4; color: var(--text); }
.starter:hover { border-color: var(--fill); box-shadow: var(--shadow); }
.open-bible-link { margin-top: 18px; border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 14px; }
.messages { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.msg-user { align-self: flex-end; max-width: 85%; background: var(--user-bubble); border-radius: 18px 18px 6px 18px; padding: 10px 15px; white-space: pre-wrap; }
.msg-user .about { display: block; font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 2px; }
.msg-ai { display: flex; gap: 12px; align-items: flex-start; }
.msg-ai .avatar { width: 30px; height: 30px; flex-shrink: 0; margin-top: 2px; }
.msg-ai .body { flex: 1; min-width: 0; font-size: 15.5px; line-height: 1.7; }
.msg-ai .body p { margin: 0 0 12px; }
.msg-ai .body p:last-child { margin-bottom: 0; }
.msg-ai .body ul { margin: 0 0 12px; padding-left: 20px; }
.msg-ai .body li { margin-bottom: 4px; }
.msg-ai .body .h { font: 800 16px var(--body); margin: 14px 0 6px; }
.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--text-faint); font-size: 14px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--fill); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.cite {
  display: inline-flex; align-items: center; border: 0; margin: 0 1px; padding: 0 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--accent);
  font: 700 12.5px/1.75 var(--body); vertical-align: 1px; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.cite:hover { background: var(--user-bubble); color: var(--accent-deep); }
.cite.on { background: var(--mark-pill); color: var(--mark-ink); }
/* A passage the answer has already cited: a text link, not a second pill. */
.cite.quiet { display: inline; margin: 0; padding: 0; border-radius: 3px; background: none; font: inherit; color: inherit; vertical-align: baseline; text-decoration: underline dotted var(--text-faint); text-underline-offset: 3px; cursor: pointer; }
.cite.quiet:hover { background: none; color: var(--accent); text-decoration-color: currentColor; }
.cite.quiet.on { background: var(--mark); color: inherit; text-decoration: underline solid var(--mark-edge); }
.msg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; }
.msg-actions button { border: 0; background: transparent; color: var(--text-faint); border-radius: 8px; padding: 4px 8px; font-size: 12.5px; font-weight: 700; }
.msg-actions button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.msg-actions .rate-btn { display: inline-flex; padding: 6px 7px; }
.rate-btn svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.rate-btn:disabled { cursor: default; opacity: 0.45; }
.rate-btn.chosen { opacity: 1; color: var(--accent); background: var(--surface-2); }
/* "Ask again" (study.js addRetry): next to the thumbs, or under an error. */
.retry-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 0; background: transparent; color: var(--text-faint); border-radius: 8px; padding: 6px 7px; cursor: pointer; }
.retry-btn:hover { background: var(--surface-2); color: var(--text); }
.retry-btn svg { width: 15px; height: 15px; fill: currentColor; }
.msg-error + .retry-btn { margin-top: 4px; color: var(--accent); }
.rate-note { font-size: 11.5px; color: var(--text-faint); margin-left: 4px; line-height: 1.4; }
.msg-error { color: #c0365a; }
.msg-error a { color: inherit; font-weight: 700; }

/* ---------- composer ---------- */
.composer { padding: 10px 24px 14px; max-width: 768px; width: 100%; margin: 0 auto; }
.context-chip { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px 4px; background: var(--surface-2); color: var(--accent); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; font-weight: 700; }
.context-chip button { border: 0; background: transparent; color: inherit; font-size: 17px; line-height: 1; padding: 0 4px; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 22px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); }
.composer-row:focus-within { border-color: var(--fill); }
#input { flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: 15.5px/1.5 var(--body); padding: 8px 0; max-height: 180px; }
#input::placeholder { color: var(--text-faint); }
#send { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
#send:hover:not(:disabled) { background: var(--accent-deep); }
#send:disabled { background: var(--surface-2); color: var(--text-faint); cursor: default; }
.composer-note { margin: 8px 0 0; text-align: center; font-size: 11.5px; color: var(--text-faint); }
.composer-note a { color: inherit; }
.free-note { display: block; margin-top: 2px; }
.free-note a { font-weight: 700; }

/* ---------- reader ---------- */
.reader { position: relative; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.reader-handle { display: none; }
.reader-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.passage-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; border-radius: 10px; padding: 4px 8px; font: 800 18px var(--body); color: var(--text); }
.passage-btn:hover { background: var(--surface-2); }
.passage-btn svg { width: 18px; height: 18px; color: var(--text-faint); }
.reader-translation { margin-left: auto; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.06em; color: var(--text-dim); }
.reader-translation:hover { border-color: var(--fill); color: var(--text); }
/* The header's translation switch already says it where there is room. */
@media (min-width: 761px) { .reader-translation { display: none; } .reader-close { margin-left: auto; } }
.reader-close { display: none; }
.reader-body { flex: 1 1 50%; min-height: 0; overflow-y: auto; padding: 22px 30px 120px; font: 17px/1.8 var(--body); }
.reader-body h3 { font: 600 26px var(--display); margin: 0 0 14px; }
.verse { border-radius: 4px; padding: 2px 1px; cursor: pointer; transition: background 0.12s ease; -webkit-tap-highlight-color: transparent; }
.verse sup { font: 700 11px var(--body); color: var(--text-faint); margin-right: 3px; vertical-align: 5px; }
.verse:hover { background: var(--selected); }
.verse.hl-yellow { background: var(--hl-yellow); }
.verse.hl-green { background: var(--hl-green); }
.verse.hl-blue { background: var(--hl-blue); }
.verse.hl-pink { background: var(--hl-pink); }
.verse.cited, .verse.comm-on { background: var(--mark); box-shadow: inset 0 -2px 0 var(--mark-edge); }
.verse.sel { background: var(--mark-strong); box-shadow: inset 0 -2px 0 var(--mark-edge); }
.reader-loading { color: var(--text-faint); font: 15px var(--body); }
.reader-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; font: 14px var(--body); }
.reader-foot button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 700; color: var(--text-dim); }
.reader-foot button:hover { border-color: var(--fill); color: var(--text); }

.verse-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 24px);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px;
  padding: 8px 8px 8px 14px; box-shadow: var(--shadow); white-space: nowrap; z-index: 5;
}
.verse-bar-ref { font-weight: 800; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.bar-btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13px; }
.bar-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bar-btn.primary:hover { background: var(--accent-deep); }
.swatches { display: inline-flex; gap: 5px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); padding: 0; }
.swatch[data-color="yellow"] { background: var(--hl-yellow); }
.swatch[data-color="green"] { background: var(--hl-green); }
.swatch[data-color="blue"] { background: var(--hl-blue); }
.swatch[data-color="pink"] { background: var(--hl-pink); }
.swatch.clear { background: linear-gradient(135deg, transparent 45%, #c0365a 45% 55%, transparent 55%), var(--surface); }

.picker { position: absolute; inset: 0; background: var(--surface); display: flex; flex-direction: column; z-index: 6; }
.picker-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); font: 800 16px var(--body); }
.picker-head span { flex: 1; }
.picker-body { overflow-y: auto; padding: 14px 16px 24px; }
.picker-body h4 { margin: 8px 0 8px; font: 700 12px var(--body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin-bottom: 14px; }
.book-grid button, .ch-grid button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 6px; font-size: 13.5px; font-weight: 600; text-align: center; }
.book-grid button:hover, .ch-grid button:hover { border-color: var(--fill); background: var(--surface-2); }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.ch-grid button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* The commentary button sits in the text, right after the cited verse. */
.comm-pill { display: inline-flex; align-items: center; gap: 5px; margin: 0 2px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 0 10px 0 8px; font: 700 12.5px/20px var(--body); color: var(--accent); vertical-align: -1.5px; white-space: nowrap; }
.comm-pill:hover { border-color: var(--fill); background: var(--surface-2); }
.comm-pill.on { border-color: var(--mark-edge); background: var(--mark-pill); color: var(--mark-ink); }
.comm-pill svg { width: 14px; height: 14px; }
/* Commentary takes the bottom half of the reader, under the passage; both
   halves scroll on their own. The size button (or opening a comment's full
   text) gives it most of the height, leaving the verse on show above. */
.comm-panel {
  position: relative; flex: 1 1 50%; min-height: 0;
  display: flex; flex-direction: column; background: var(--surface);
  border-top: 2px solid var(--line-strong);
}
.reader.comm-open .reader-body { padding-bottom: 28px; }
.reader.comm-tall .reader-body { flex: 0 0 24%; }
.reader.comm-tall .comm-panel { flex: 1 1 0; }
.comm-head, .comm-tabs, .reader-head { flex-shrink: 0; }
.comm-head { display: flex; align-items: center; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); font: 800 15px var(--body); }
.comm-head span { flex: 1; }
#comm-size svg { transition: transform 0.18s ease; }
#comm-size[aria-pressed="true"] svg { transform: rotate(180deg); }
.comm-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 20px 24px; }
.comm-tabs { display: flex; gap: 6px; padding: 10px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--line); }
.comm-tabs button { border: 0; background: transparent; border-bottom: 2px solid transparent; padding: 6px 10px 9px; font-weight: 700; font-size: 14px; color: var(--text-dim); white-space: nowrap; }
.comm-tabs button span { font-weight: 600; font-size: 12px; color: var(--text-faint); }
.comm-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.comm-tabs button:hover { color: var(--text); }
.comm-who { font-size: 12.5px; color: var(--text-dim); }
.comm-item + .comm-item { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.comm-ref { margin-top: 10px; font: 700 12.5px var(--body); color: var(--text-dim); }
.comm-item + .comm-item .comm-ref { margin-top: 0; }
.comm-who strong { color: var(--text); }
.comm-teaser { margin: 6px 0 10px; font-size: 14.5px; line-height: 1.55; }
/* The one-line teaser is ours, not the commentator's: say so. */
.comm-label { display: inline-block; margin-right: 7px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 5px; font: 800 10px/1.7 var(--body); letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); vertical-align: 1.5px; }
.comm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.comm-own, .comm-ask { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 5px 14px; font-weight: 700; font-size: 13px; color: var(--accent); }
.comm-own:hover { border-color: var(--fill); background: var(--surface-2); }
.comm-ask { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.comm-ask:hover { border-color: var(--accent-deep); background: var(--accent-deep); }
.comm-full { margin-top: 14px; font: 15px/1.7 var(--body); }
.comm-full p { margin: 0 0 10px; }
.comm-full .credit { font: italic 12px var(--body); color: var(--text-faint); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 700; z-index: 60; box-shadow: var(--shadow); }

/* ---------- tablet: studies become a drawer ---------- */
@media (max-width: 1180px) {
  .shell { grid-template-columns: minmax(0, 1fr) minmax(360px, 46%); grid-template-areas: "top top" "chat reader"; }
  #menu-btn { display: inline-flex; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 290px; z-index: 40; transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  .shell.side-open .sidebar { transform: none; }
}

/* ---------- phone: the Bible is a bottom sheet ---------- */
@media (max-width: 760px) {
  /* Split screen: the conversation on top, the Bible below (its passage and
     commentary a quarter of the screen each when commentary is open). */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top" "chat"; }
  .shell.reader-open { grid-template-rows: auto minmax(0, 1fr) 50dvh; grid-template-areas: "top" "chat" "reader"; }
  /* The taller commentary takes the room from the chat, not the passage. */
  .shell.reader-open:has(.reader.comm-tall) { grid-template-rows: auto minmax(0, 1fr) 76dvh; }
  .preview-pill, .segmented { display: none; }
  .ghost-btn { display: inline-flex; }
  .brand span { font-size: 16px; }
  .chat-scroll { padding: 18px 14px 8px; }
  .welcome { margin-top: 3vh; }
  .welcome h1 { font-size: 24px; }
  .starters { grid-template-columns: 1fr; }
  .composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .reader { display: none; border-left: 0; border-top: 2px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom); }
  .shell.reader-open .reader { display: flex; }
  .reader-head { padding: 4px 8px; }
  .reader.comm-open .reader-body { padding-bottom: 16px; }
  .passage-btn { font-size: 17px; }
  /* Phone: no title row; the tabs share a row with the close button. */
  .comm-head { position: absolute; top: 2px; right: 4px; padding: 0; border: 0; z-index: 1; }
  .comm-head span { display: none; }
  .comm-tabs { padding: 2px 84px 0 10px; }
  .comm-body { padding: 10px 14px 16px; }
  .reader-close { display: inline-flex; }
  .reader-body { padding: 12px 16px 90px; font-size: 16.5px; line-height: 1.75; }
  .reader-body h3 { font-size: 20px; margin-bottom: 8px; }
  .reader .segmented { display: inline-flex; }
  .verse-bar { flex-wrap: wrap; justify-content: center; white-space: normal; bottom: calc(14px + env(safe-area-inset-bottom)); }
}
