  :root {
    --bg: #f6f1e7;
    --paper: #fbf8f1;
    --ink: #2b2620;
    --ink-soft: #6b6256;
    --rule: #e2d9c8;
    --accent: #8a4b2a;
    --accent-soft: #f0dcc9;
    --hl: #f7e3a4;
    --shadow: 0 8px 30px rgba(60, 40, 20, .12);
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  }
  :root[data-theme="dark"] {
    --bg: #17140f; --paper: #1e1a14; --ink: #e8dfcf; --ink-soft: #a09685;
    --rule: #342d22; --accent: #e0a070; --accent-soft: #3a2a1d; --hl: #5a4a1e;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #17140f; --paper: #1e1a14; --ink: #e8dfcf; --ink-soft: #a09685;
      --rule: #342d22; --accent: #e0a070; --accent-soft: #3a2a1d; --hl: #5a4a1e;
      --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    }
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; }
  body {
    background: var(--bg); color: var(--ink);
    font-family: var(--serif); line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  button { font: inherit; color: inherit; cursor: pointer; }

  /* ---------- nav ---------- */
  .top { position: sticky; top: 0; z-index: 20; }
  .nav { background: var(--bg); border-bottom: 1px solid var(--rule); }
  .nav-in {
    max-width: 1180px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; gap: 12px;
    font-family: var(--sans); font-size: 14px;
  }
  .brand { font-family: var(--serif); font-style: italic; color: var(--ink-soft); }
  a.brand { text-decoration: none; }
  a.brand:hover { color: var(--accent); }
  .where { flex: 1; text-align: center; font-weight: 600; letter-spacing: .01em; }
  a.where { color: var(--ink); text-decoration: none; }
  a.where:hover { color: var(--accent); }
  .where small { color: var(--ink-soft); font-weight: 400; margin-left: 6px; }
  .chip {
    border: 1px solid var(--rule); background: transparent;
    padding: 6px 12px; border-radius: 999px; font-size: 13px; font-family: var(--sans);
  }
  a.chip { color: inherit; text-decoration: none; }
  .chip:hover { border-color: var(--accent); color: var(--accent); }
  .icon-btn { border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; font-size: 16px; }
  .icon-btn:hover { background: var(--accent-soft); }

  /* ---------- focus: compact, always visible ---------- */
  .focus {
    position: relative;
    background: var(--paper);
    border-bottom: 2px solid var(--accent-soft);
  }
  .focus-head {
    max-width: 1180px; margin: 0 auto; padding: 9px 16px;
    display: flex; align-items: center; justify-content: center; gap: 14px;
    width: 100%; border: 0; background: none; text-align: center; cursor: pointer;
  }
  .focus-label {
    flex: none; font-family: var(--sans); font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
    color: var(--paper); background: var(--accent); border-radius: 4px; padding: 3px 7px 3px 9px;
  }
  .focus-title {
    margin: 0; font-weight: 400; font-style: italic; color: var(--accent);
    font-size: clamp(18px, 2.6vw, 24px); line-height: 1.25; text-wrap: balance;
  }
  .focus-caret { flex: none; color: var(--ink-soft); font-family: var(--sans); font-size: 12px; transition: transform .2s; }
  .focus.open .focus-caret { transform: rotate(180deg); }
  .focus-body {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: var(--shadow);
    max-height: 60vh; overflow-y: auto;
  }
  .focus.open .focus-body { display: block; }
  .focus-body-in { max-width: 60ch; margin: 0 auto; padding: 14px 16px 18px; color: var(--ink-soft); font-size: 17px; }
  .focus-body p { margin: 0 0 10px; }
  .focus-actions { display: flex; gap: 8px; align-items: center; font-family: var(--sans); }
  .focus-edit input, .focus-edit textarea {
    width: 100%; font: inherit; color: var(--ink); background: var(--bg);
    border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px;
  }
  @media (max-width: 599px) {
    .focus-head { gap: 10px; padding: 8px 12px; }
  }

  /* ---------- layout ---------- */
  .layout {
    max-width: 1180px; margin: 0 auto;
    display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px;
    padding: 28px 16px 120px;
  }
  @media (max-width: 899px) { .layout { grid-template-columns: 1fr; padding-bottom: 150px; } }

  /* ---------- lectio ---------- */
  .lectio {
    max-width: 34em; margin: 0 auto; width: 100%; text-align: left;
    display: flex; flex-direction: column; gap: 26px; padding: 8px 0 20px;
    touch-action: pan-y;
  }
  .near {
    font-size: 17px; color: var(--ink-soft); opacity: .5; cursor: pointer; line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    text-wrap: pretty;
  }
  .near:hover { opacity: .9; }
  .now, .near { white-space: pre-line; }
  .near.edge { font-style: italic; opacity: .55; }
  .strip.scrolling { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 6px; }
  .strip.scrolling .tick { flex: none; }
  .near b { font-family: var(--sans); font-size: 11px; color: var(--accent); font-weight: 600; margin-right: 4px; }
  .now { font-size: clamp(22px, 3.6vw, 32px); line-height: 1.5; text-wrap: pretty; hyphens: auto; }
  .now.mid { font-size: clamp(20px, 3vw, 27px); line-height: 1.55; }
  .now.long { font-size: clamp(18px, 2.5vw, 22px); line-height: 1.7; }
  .now .ref {
    display: block; font-family: var(--sans); font-size: 12px; letter-spacing: .14em;
    text-transform: uppercase; color: var(--accent); margin-bottom: 14px;
  }
  .steps { display: flex; justify-content: flex-start; gap: 12px; }

  .strip { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 6px; margin-top: 18px; }
  .tick {
    position: relative; width: 30px; height: 30px; border-radius: 50%;
    border: 1px solid var(--rule); background: transparent;
    font-family: var(--sans); font-size: 12px; color: var(--ink-soft); padding: 0;
  }
  .tick:hover { border-color: var(--accent); color: var(--accent); }
  .tick.has::after {
    content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px;
    border-radius: 50%; background: var(--accent);
  }
  .tick.current { background: var(--accent); border-color: var(--accent); color: var(--paper); }
  .tick.current.has::after { background: var(--paper); }

  /* ---------- notes panel ---------- */
  .panel {
    align-self: start; position: sticky; top: 124px;
    background: var(--paper); border: 1px solid var(--rule); border-radius: 14px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; max-height: calc(100vh - 144px);
  }
  .panel-handle { display: none; }
  .panel-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--rule); font-family: var(--sans); }
  .panel-head .ref { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
  .panel-head .pfocus { font-family: var(--serif); font-style: italic; color: var(--accent); font-size: 15px; margin-top: 4px; }
  .notes { overflow-y: auto; padding: 6px 16px; flex: 1; min-height: 40px; }
  .empty { color: var(--ink-soft); font-style: italic; padding: 14px 0; font-size: 16px; }
  .note { padding: 12px 0; border-bottom: 1px solid var(--rule); font-size: 16.5px; line-height: 1.55; }
  .note:last-child { border-bottom: 0; }
  .note-meta { display: flex; justify-content: space-between; font-family: var(--sans); font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
  .note-meta button { border: 0; background: none; color: var(--ink-soft); padding: 0 2px; font-size: 12px; }
  .note-meta button:hover { color: var(--accent); }
  .note p { margin: 0 0 .5em; } .note p:last-child { margin: 0; }
  .note blockquote, .editor blockquote { margin: .4em 0; padding-left: 12px; border-left: 3px solid var(--accent-soft); color: var(--ink-soft); }
  .note ul, .note ol, .editor ul, .editor ol { margin: .3em 0; padding-left: 1.3em; }

  .composer { border-top: 1px solid var(--rule); padding: 10px 12px 12px; font-family: var(--sans); }
  .toolbar { display: none; gap: 4px; margin-bottom: 6px; }
  .composer.expanded .toolbar { display: flex; }
  .toolbar button { border: 1px solid var(--rule); background: transparent; border-radius: 6px; padding: 3px 9px; font-size: 13px; }
  .toolbar button:hover { border-color: var(--accent); color: var(--accent); }
  .editor {
    font-family: var(--serif); font-size: 16.5px; line-height: 1.5;
    min-height: 44px; max-height: 120px; overflow-y: auto;
    background: var(--bg); border: 1px solid var(--rule); border-radius: 10px;
    padding: 9px 11px; outline: none;
  }
  .composer.expanded .editor { min-height: 180px; max-height: 40vh; }
  .editor:focus { border-color: var(--accent); }
  .editor:empty::before { content: attr(data-placeholder); color: var(--ink-soft); opacity: .8; font-style: italic; pointer-events: none; }
  .composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
  .primary { background: var(--accent); color: var(--paper); border: 0; border-radius: 999px; padding: 7px 16px; font-family: var(--sans); font-size: 14px; }
  .primary:hover { filter: brightness(1.08); }

  /* mobile bottom sheet */
  @media (max-width: 899px) {
    .panel {
      position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30;
      border-radius: 16px 16px 0 0; border-bottom: 0;
      max-height: 82vh; height: 82vh;
      transform: translateY(calc(100% - 66px - env(safe-area-inset-bottom)));
      transition: transform .28s cubic-bezier(.2,.8,.2,1);
      padding-bottom: env(safe-area-inset-bottom);
    }
    .panel.open { transform: none; }
    .panel-handle {
      display: flex; align-items: center; gap: 10px; position: relative;
      height: 66px; padding: 0 16px; flex: none; cursor: pointer;
      font-family: var(--sans); font-size: 14px; border: 0; background: none; width: 100%; text-align: left;
    }
    .panel-handle::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--rule); }
    .panel-handle .ref { font-weight: 600; }
    .panel-handle .count { color: var(--ink-soft); flex: 1; }
    .panel-handle .go { color: var(--accent); }
    .panel-head { padding-top: 4px; }
    .panel-head .ref { display: none; }
  }

  /* ---------- all-notes view ---------- */
  .overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; display: none; }
  .overlay.show { display: block; }
  .overlay-in { max-width: 44em; margin: 0 auto; padding: 22px 16px 80px; }
  .overlay-bar { display: flex; justify-content: space-between; align-items: center; font-family: var(--sans); font-size: 14px; margin-bottom: 18px; }
  .overlay h2 { font-size: clamp(26px, 4.5vw, 38px); font-style: italic; margin: 6px 0 4px; font-weight: 400; line-height: 1.2; color: var(--accent); }
  .overlay .sub { color: var(--ink-soft); font-family: var(--sans); font-size: 13px; margin-bottom: 28px; }
  .fv-item { margin: 0 0 28px; }
  .fv-ref { font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); background: none; border: 0; padding: 0; }
  .fv-ref:hover { text-decoration: underline; }
  .fv-quote { font-style: italic; color: var(--ink-soft); margin: 4px 0 10px; font-size: 16px; }
  .fv-note { padding-left: 14px; border-left: 3px solid var(--accent-soft); margin-bottom: 8px; font-size: 17px; }
  .toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-family: var(--sans); font-size: 13px; z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none; }
  .toast.show { opacity: 1; }

/* ---------- sign in ---------- */
.signin { max-width: 340px; margin: 18vh auto 0; padding: 0 20px; text-align: center; }
.signin .brand { font-size: 28px; font-weight: 400; margin: 0 0 24px; }
.signin-form { display: flex; flex-direction: column; gap: 10px; }
.signin-form input[type="email"], .signin-form input[type="password"], .signin-form input[type="text"], .signin-form textarea {
  font: inherit; font-family: var(--sans); font-size: 15px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 10px; padding: 11px 12px; outline: none;
}
.signin-form input:focus, .signin-form textarea:focus { border-color: var(--accent); }
.signin-form .primary { padding: 11px 16px; margin-top: 4px; }
.signin-alert, .signin-notice { font-family: var(--sans); font-size: 14px; margin: 0 0 14px; }
.signin-alert { color: #b3402a; }
.signin-notice { color: var(--ink-soft); }

.signout { margin: 0; }
.signin-form + .signin-notice { margin-top: 6px; }

/* ---------- foci pages ---------- */
a:not(.chip):not(.where):not(.brand):not(.tick):not(.work-link) { color: var(--accent); }
.inline-form { display: inline; margin: 0; }
.page { max-width: 40em; margin: 0 auto; padding: 22px 16px 80px; }
.page-bar { display: flex; justify-content: space-between; font-family: var(--sans); margin-bottom: 18px; }
.page-title { font-size: clamp(26px, 4.5vw, 36px); font-weight: 400; margin: 6px 0 20px; }
.page-sub { font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 26px 0 10px; }
.page-empty { color: var(--ink-soft); font-style: italic; }
.focus-row { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.focus-row-title { font-size: 20px; font-style: italic; }
.focus-row-desc { color: var(--ink-soft); font-size: 16px; margin-top: 4px; }
.focus-row-meta { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------- notes ---------- */
.notes-unit:not(:has(.note))::before {
  content: "Nothing here yet. What does this passage say to your question?";
  display: block; color: var(--ink-soft); font-style: italic; padding: 14px 0; font-size: 16px;
}
.note-meta form { display: inline; }

/* Lexxy, themed to the paper palette (it follows light/dark through our variables). */
lexxy-editor, .lexxy-content {
  --lexxy-color-ink: var(--ink);
  --lexxy-color-text: var(--ink);
  --lexxy-color-ink-medium: var(--ink-soft);
  --lexxy-color-text-subtle: var(--ink-soft);
  --lexxy-color-ink-lighter: var(--rule);
  --lexxy-color-ink-lightest: var(--accent-soft);
  --lexxy-color-canvas: var(--bg);
  --lexxy-color-accent-dark: var(--accent);
  --lexxy-color-link: var(--accent);
  --lexxy-color-selected: var(--accent-soft);
  --lexxy-color-selected-hover: var(--accent-soft);
  --lexxy-color-code-bg: var(--accent-soft);
  font-family: var(--serif);
}
.composer lexxy-editor { --lexxy-editor-rows: 2lh; font-size: 16.5px; border-radius: 10px; }
.composer lexxy-toolbar { display: none; }
.composer.expanded lexxy-editor { --lexxy-editor-rows: 9lh; }
.composer.expanded lexxy-toolbar { display: flex; }
.note .lexxy-content { font-size: inherit; line-height: inherit; }
.note .lexxy-content > :first-child { margin-top: 0; }
.note .lexxy-content > :last-child { margin-bottom: 0; }

/* ---------- all-notes page ---------- */
.all-notes-title { font-style: italic; color: var(--accent); line-height: 1.2; margin-bottom: 4px; }
.all-notes-sub { color: var(--ink-soft); font-family: var(--sans); font-size: 13px; margin: 0 0 28px; }
a.fv-ref { text-decoration: none; }
a.fv-ref:hover { text-decoration: underline; }
.fv-note .lexxy-content > :first-child { margin-top: 0; }
.fv-note .lexxy-content > :last-child { margin-bottom: 0; }
.fv-quote.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fv-more { border: 0; background: none; padding: 0 0 10px; color: var(--accent); font-family: var(--sans); font-size: 12px; cursor: pointer; }
.fv-more:hover { text-decoration: underline; }
.page-bar-actions { display: flex; gap: 8px; }
.fv-quote { white-space: pre-line; }

/* ---------- library pages ---------- */
.works { display: flex; flex-direction: column; }
.work-link { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.work-link:hover .work-link-title { color: var(--accent); }
.work-link-title { font-size: 20px; }
.work-link-meta { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); }
.chapters { margin-top: 8px; }
a.tick { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink-soft); }
.section-list { list-style: none; margin: 0; padding: 0; columns: 2 18em; column-gap: 32px; }
.section-list li { padding: 6px 0; break-inside: avoid; display: flex; align-items: center; gap: 8px; }
.section-list a { color: var(--ink); text-decoration: none; }
.section-list a:hover { color: var(--accent); }
.noted-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
