/* Berean — minimal, mobile-first styles. */
/* Theme: <html data-theme="system|light|dark"> comes from the user's display.theme preference.
   "system" (and signed-out pages) follow the device; light/dark override it. */
:root {
  --bg: #fafaf7; --fg: #1f2328; --muted: #5f6670; --accent: #2f5d8a;
  --card: #fff; --border: #d9dcd6; --error: #a1260d; --ok: #1d6b3a; --on-accent: #fff;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #16181b; --fg: #e6e6e3; --muted: #a2a8b0; --accent: #8ab4e0;
  --card: #1f2226; --border: #34383e; --error: #ff8a70; --ok: #7fd49c; --on-accent: #12161b;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b; --fg: #e6e6e3; --muted: #a2a8b0; --accent: #8ab4e0;
    --card: #1f2226; --border: #34383e; --error: #ff8a70; --ok: #7fd49c; --on-accent: #12161b;
    color-scheme: dark;
  }
}
/* Text size: <html data-font-scale="small|normal|large"> (display.font_scale). */
html { font-size: 17px; }
html[data-font-scale="small"] { font-size: 15px; }
html[data-font-scale="large"] { font-size: 20px; }
* { box-sizing: border-box; }
body { margin: 0; font: 1rem/1.5 system-ui, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
               padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
                   gap: .4rem .9rem; }
.who { color: var(--muted); }
main { padding: 1rem; max-width: 52rem; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem;
        margin: 0 0 1rem; }
.narrow { max-width: 26rem; margin: 1.5rem auto; }
h1 { font-size: 1.4rem; margin-top: 0; }
label { display: block; margin-bottom: .9rem; font-weight: 600; }
input, select { display: block; width: 100%; margin-top: .3rem; padding: .6rem; font: inherit;
        border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--fg); }
button { font: inherit; padding: .6rem 1.1rem; border: 0; border-radius: 6px;
         background: var(--accent); color: var(--on-accent); cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
form.inline { display: inline; margin: 0; }
.error { color: var(--error); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.hint { color: var(--muted); font-size: .9rem; }
h2 { font-size: 1.1rem; margin-top: 0; }
fieldset.card { min-width: 0; }
legend { font-weight: 700; padding: 0 .3rem; }
.field { margin-bottom: 1rem; }
.field > label { margin-bottom: 0; }
.field .hint, .field .error { margin: .25rem 0 0; }
label.check { display: flex; align-items: center; gap: .6rem; }
label.check input { width: auto; margin: 0; }
button.secondary { background: none; color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: var(--error); }
.list { list-style: none; padding: 0; margin: 0 0 1rem; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
           padding: .6rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 99px;
         border: 1px solid var(--border); color: var(--muted); }
.badge.off { color: var(--error); border-color: var(--error); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
             margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
button.small { padding: .3rem .65rem; font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Pop-up panels (HTML popover; no JavaScript). */
.panel[popover] { width: min(28rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
                  overflow: auto; padding: 1.2rem; border: 1px solid var(--border);
                  border-radius: 10px; background: var(--card); color: var(--fg);
                  box-shadow: 0 10px 40px rgb(0 0 0 / .35); text-align: left; font-weight: normal; }
.panel[popover]::backdrop { background: rgb(0 0 0 / .45); }

/* Tables: a real table on wide screens, stacked cards on phones. */
.table { width: 100%; border-collapse: collapse; background: var(--card);
         border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: .6rem .75rem; text-align: left; vertical-align: top;
                       border-bottom: 1px solid var(--border); }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.inactive td { color: var(--muted); }
.table .hint { margin: 0; }
.row-actions { display: flex; justify-content: flex-end; gap: .4rem; }
.row-actions > button, .row-actions > form { white-space: nowrap; }
.nowrap { white-space: nowrap; }
main:has(.table.users) { max-width: 64rem; }
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { border-bottom: 1px solid var(--border); padding: .4rem 0; }
  .table td { border: 0; padding: .2rem .75rem; }
  .table td[data-label] { display: flex; justify-content: space-between; gap: 1rem; }
  .table td[data-label]::before { content: attr(data-label); font-size: .8rem; color: var(--muted); }
  .table td[data-label="User"] { display: block; }
  .table td[data-label="User"]::before { content: none; }
  .table td[data-label] > * { text-align: right; }
  .table td[data-label="User"] > * { text-align: left; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; padding-top: .3rem; }
}

/* Capture form and capture lists (task 1.8). Phone first: one column, full-width controls. */
textarea { display: block; width: 100%; margin-top: .3rem; padding: .6rem; font: inherit;
           border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
           color: var(--fg); resize: vertical; min-height: 8rem; }
input, textarea { font-size: max(1rem, 16px); } /* 16px+ stops phones zooming into the box */
[aria-invalid="true"] { border-color: var(--error); }
.capture-form h1 { margin-bottom: .8rem; }
.field-row { display: flex; flex-direction: column; gap: 0 1rem; }
button.wide { width: 100%; padding: .8rem; font-weight: 600; }
@media (min-width: 640px) {
  .field-row { flex-direction: row; }
  .field-row > .field { flex: 1; }
  .field-row > .field-short { flex: 0 0 11rem; }
  button.wide { width: auto; padding: .6rem 1.6rem; }
}
.captures { list-style: none; padding: 0; margin: 0; }
.capture-item { padding: .8rem 0; border-bottom: 1px solid var(--border); }
.capture-item:last-child { border-bottom: 0; }
.capture-item p { margin: 0 0 .35rem; }
.capture-text { white-space: pre-line; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { font-size: .85rem; padding: .1rem .55rem; border-radius: 99px; border: 1px solid var(--border); }
.chip.ref { border-color: var(--accent); color: var(--accent); }
.chip.tag { background: var(--bg); color: var(--muted); }
.chip.tag::before { content: "#"; opacity: .6; }

/* Header account menu: a <details> drop-down (app.js closes it on an outside click / Esc). */
.user-menu { position: relative; }
.user-menu > summary { cursor: pointer; color: var(--accent); list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary::after { content: " ▾"; font-size: .8em; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20; min-width: 11rem;
                   display: flex; flex-direction: column; padding: .4rem 0; background: var(--card);
                   border: 1px solid var(--border); border-radius: 8px;
                   box-shadow: 0 8px 24px rgb(0 0 0 / .18); }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left;
                   padding: .5rem 1rem; text-decoration: none; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--bg); }
.user-menu .menu form { margin: 0; border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .3rem; }

/* Dashboard (home page): large buttons, one per part of Berean. */
.dashboard { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
             margin-bottom: 1rem; }
.dash-button { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem;
               padding: 1.4rem 1.3rem; min-height: 8rem; border-radius: 12px; text-decoration: none;
               background: var(--card); border: 1px solid var(--border); color: var(--fg);
               font-size: 1.35rem; font-weight: 700; }
.dash-button:hover, .dash-button:focus-visible { border-color: var(--accent); }
.dash-button .dash-icon { font-size: 1.8rem; line-height: 1; margin-bottom: .3rem; }
.dash-button .hint { font-weight: normal; font-size: .9rem; }

/* Bible reader (task 1.9). Phones: one column, a tapped verse opens underneath.
   Wide screens: full width, verses left, notes pane right (D-032, D-033). */
.go-form { display: flex; gap: .5rem; align-items: stretch; }
.go-form input { margin: 0; flex: 1; }
.go-top { padding: .8rem; }
.book-grid, .chapter-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.book-grid { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
.chapter-grid { grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr)); }
.book-grid a, .chapter-grid a { display: block; padding: .45rem .6rem; border: 1px solid var(--border);
                                border-radius: 6px; text-decoration: none; }
.chapter-grid a { text-align: center; }
.reader-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
              margin: 0 0 1rem; }
.reader-book { font-weight: 600; }
.reader { display: flex; flex-direction: column; }
.reader .side { order: -1; }           /* phones: "On this chapter" above the verses */
.side-hint, .pane { display: none; }   /* the pane is for wide screens only */
.chapter { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; line-height: 1.65; }
.chapter h1, .verse-panel, .excerpt { font-family: system-ui, sans-serif; }
.chapter .verse { display: block; padding: .15rem .35rem; margin: 0 -.35rem .1rem; border-radius: 6px;
         scroll-margin-top: 1rem; }
.verse:target, .verse.selected { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.verse-text { margin: 0; }
details.verse > summary { list-style: none; cursor: pointer; }
details.verse > summary::-webkit-details-marker { display: none; }
.vnum { color: var(--muted); font-size: .7em; font-family: system-ui, sans-serif; margin-right: .2rem; }
.note-mark { color: var(--ok); font-family: system-ui, sans-serif; font-size: .85em; white-space: nowrap; }
.omitted { color: var(--muted); font-style: italic; }
.verse-panel { margin: .3rem 0 .6rem; padding: .6rem .75rem; border-radius: 8px; font-size: .95rem;
               line-height: 1.5; background: var(--card); border: 1px solid var(--border); }
.panel-head { margin: 0 0 .4rem; }
.xrefs { margin-top: .5rem; }
.xrefs ul { list-style: none; padding: 0; margin: .2rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.excerpt { margin: 0 0 .5rem; padding: .5rem .75rem; border-radius: 8px; background: var(--bg);
           border: 1px solid var(--border); font-size: .95rem; line-height: 1.5; }
.excerpt.mine { border-left: 3px solid var(--ok); }
.excerpt.source { border-left: 3px solid var(--muted); }
.excerpt p { margin: 0 0 .25rem; }
.excerpt .hint { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .5rem; margin: 0; }
.excerpt-body { white-space: pre-line; overflow-wrap: anywhere; }
.on-chapter { margin: 0 0 1rem; padding: .8rem; border-radius: 10px;
              background: color-mix(in srgb, var(--ok) 10%, var(--card)); border: 1px solid var(--border); }
.on-chapter h2 { margin-bottom: .5rem; }
@media (min-width: 900px) {
  main:has(.reader) { max-width: none; }
  .reader { display: grid; grid-template-columns: minmax(0, 1fr) minmax(22rem, 32%); gap: 1.5rem;
            align-items: start; }
  .reader .side { order: 0; position: relative; align-self: stretch; }
  .js .side-hint { display: block; margin-top: 0; }
  .js .pane:not([hidden]) { display: block; position: absolute; left: 0; right: 0; }
  .js .pane .verse-panel { margin: 0; box-shadow: 0 6px 20px rgb(0 0 0 / .12); }
  .pane-close { position: absolute; right: .6rem; top: .35rem; font-size: 1.4rem; line-height: 1;
                text-decoration: none; z-index: 1; }
  /* With the script, wide screens never open a verse inline: its panel goes to the pane. */
  .js details.verse > .verse-panel { display: none; }
}
a.chip { text-decoration: none; }

/* Excerpt page (task 1.10) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden;
                   clip: rect(0 0 0 0); white-space: nowrap; }
.excerpt-page .excerpt { font-size: 1.05rem; padding: .75rem 1rem; }
.excerpt-page .meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.edit-text > summary, .danger-zone summary { cursor: pointer; color: var(--accent); margin: .5rem 0; }
.chip-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip.removable { display: inline-flex; align-items: center; gap: .3rem; padding-right: .2rem; }
.chip.removable a { text-decoration: none; }
.chip.removable form { display: inline; margin: 0; }
.chip-remove { background: none; color: var(--muted); padding: 0 .35rem; font-size: 1.1rem;
               line-height: 1; min-width: 1.8rem; min-height: 1.8rem; }
.chip-remove:hover, .chip-remove:focus-visible { color: var(--error); }
.add-form { display: flex; gap: .5rem; }
.add-form input { flex: 1; min-width: 0; }
.danger-zone summary { color: var(--error); }
.open-link { margin-left: auto; }
