/* Highlights and comments: the side column of a note, the passage marks, the
   comment dialog (note pages and Reader) and the composer beside a selection. */

/* ---------------------------------------------------------------- columns */
.stream-article-reading { width: min(820px, 100%); margin-inline: auto; }
.stream-article.is-annotated { display: grid; grid-template-columns: minmax(0, 760px) minmax(230px, 310px); justify-content: center; column-gap: clamp(32px, 4vw, 56px); }
.stream-article.is-annotated > .stream-article-reading { grid-column: 1; width: 100%; min-width: 0; margin: 0; }
/* A wide table scrolls in place instead of running under the notes or off the screen. */
.stream-article-body table { display: block; max-width: 100%; overflow-x: auto; }
.note-annotation-rail { grid-column: 2; grid-row: 1; min-width: 0; color: #172333; font-family: var(--bn-sans, system-ui, sans-serif); }
.note-annotation-tabs { position: sticky; top: 0; z-index: 3; display: flex; gap: 2px; padding: 10px 0 0; border-bottom: 1px solid #d8dbd2; background: var(--bn-bg, #f4f3ec); }
.note-annotation-tabs button { flex: 1; padding: 8px 6px 9px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: #5b6874; font: 600 13px/1.3 inherit; cursor: pointer; }
.note-annotation-tabs button:hover { color: #172333; }
.note-annotation-tabs button[aria-selected="true"] { border-bottom-color: #172333; color: #172333; }
.note-annotation-tabs button:focus-visible { outline: 2px solid #2c79c7; outline-offset: -2px; }

/* ---------------------------------------------------------------- notes */
.note-annotation-list { position: relative; margin-top: 12px; }
.note-annotation-list.is-floating { margin-top: 0; }
.note-annotation-note { box-sizing: border-box; width: 100%; padding: 10px 12px; border: 1px solid #e0e1d9; border-left: 3px solid #d4b95e; border-radius: 6px; background: #fff; }
.note-annotation-list.is-floating .note-annotation-note { position: absolute; left: 0; transition: top .22s ease, border-color .15s ease, box-shadow .15s ease; }
.note-annotation-list:not(.is-floating) .note-annotation-note { margin-bottom: 10px; }
.note-annotation-note[data-highlight-id] { cursor: pointer; }
.note-annotation-note.is-focused { border-color: #172333; border-left-color: #d4a514; box-shadow: 0 4px 16px #1723331c; }
/* A short rule reaches back toward the passage the focused note belongs to. */
.note-annotation-list.is-floating .note-annotation-note.is-focused::before { content: ""; position: absolute; top: 12px; right: calc(100% + 4px); width: 22px; border-top: 1px dashed #8d9790; }
.note-annotation-note p { margin: 0; overflow-wrap: anywhere; }
.note-annotation-comment { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.note-annotation-note.is-highlights .note-annotation-comment { display: -webkit-box; overflow: hidden; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; }
.note-annotation-note.is-highlights.is-focused .note-annotation-comment { -webkit-line-clamp: 8; line-clamp: 8; }
.note-annotation-note .note-annotation-quote { display: -webkit-box; margin-bottom: 6px; overflow: hidden; color: #6a716d; font-size: 12px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; }
.note-annotation-note time, .note-annotation-count { display: inline-block; margin-top: 6px; color: #6a716d; font-size: 11.5px; line-height: 1.3; }
.note-annotation-note.is-discussion { border-left-color: #233d58; }
.note-annotation-empty { margin: 0; padding: 4px 0; color: #6a716d; font-size: 13px; line-height: 1.5; }
.note-annotation-add { display: block; width: 100%; margin-bottom: 12px; padding: 10px; border: 1px dashed #a9b2a6; border-radius: 6px; background: transparent; color: #233d58; font: 600 13px/1.3 inherit; cursor: pointer; }
.note-annotation-add:hover { border-style: solid; background: #fff; }
.note-annotation-rail.is-discussion .note-annotation-list { position: sticky; top: 56px; max-height: calc(100vh - 150px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }

/* ---------------------------------------------------------------- passages */
.reader-saved-highlight, .note-comment-mark, .stream-saved-highlight { padding: 0 .05em; border-radius: 2px; color: inherit; }
.reader-saved-highlight, .stream-saved-highlight { background: #ffe89a; }
.note-comment-mark { background: #e4eef8; box-shadow: inset 0 -2px #84b4e0; }
.stream-article-body mark[data-highlight-id] { cursor: pointer; transition: background-color .15s ease; }
.stream-article-body mark[data-highlight-id].is-focused { background: #ffd24d; box-shadow: 0 0 0 2px #ffd24d; }
.stream-article-body mark[data-highlight-id]:focus-visible { outline: 2px solid #2c79c7; outline-offset: 2px; }

/* ---------------------------------------------------------------- writing */
.note-selection-actions { position: absolute; z-index: 30; display: flex; gap: 6px; padding: 6px; border: 1px solid #d3d6cc; border-radius: 8px; background: #fff; box-shadow: 0 8px 24px #17233326; }
.note-selection-actions button, .note-dialog-actions button { min-height: 34px; padding: 0 14px; border: 1px solid #172333; border-radius: 6px; background: #172333; color: #fff; font: 600 13px/1 var(--bn-sans, system-ui, sans-serif); cursor: pointer; }
.note-selection-actions button.is-quiet, .note-dialog-actions button.is-quiet { border-color: #c5c9bf; background: #fff; color: #172333; }
.note-selection-actions button:focus-visible, .note-dialog-actions button:focus-visible { outline: 3px solid #2c79c7; outline-offset: 2px; }
.note-composer { position: absolute; z-index: 30; box-sizing: border-box; width: min(340px, calc(100vw - 16px)); padding: 12px; border: 1px solid #d3d6cc; border-radius: 10px; background: #fff; box-shadow: 0 14px 40px #17233333; }
.note-composer textarea, .note-dialog textarea, .reader-comment-dialog textarea { display: block; box-sizing: border-box; width: 100%; min-height: 76px; padding: 11px 12px; border: 1px solid #c5c9bf; border-radius: 8px; background: #fbfaf6; color: #172333; font: 15px/1.55 var(--bn-sans, system-ui, sans-serif); resize: vertical; }
.note-composer textarea:focus-visible, .note-dialog textarea:focus-visible, .reader-comment-dialog textarea:focus-visible { border-color: #172333; outline: 2px solid #172333; outline-offset: -1px; background: #fff; }
.note-dialog-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.note-dialog-actions small { margin-right: auto; color: #6a716d; font: 12px/1.4 var(--bn-sans, system-ui, sans-serif); }

/* The pop-up for a comment on a whole note, on note pages and in the Reader. */
.note-dialog, .reader-comment-dialog > div { box-sizing: border-box; width: min(520px, calc(100vw - 28px)); padding: 0 26px 22px; overflow: hidden; border: 0; border-top: 6px solid #233d58; border-radius: 12px; background: #fff; color: #172333; box-shadow: 0 28px 80px #0b121c59; }
.note-dialog::backdrop { background: rgba(14, 22, 32, .55); backdrop-filter: blur(2px); }
.note-dialog h2, .reader-comment-dialog h2 { margin: 22px 0 4px; color: #172333; font: 400 26px/1.25 Georgia, "Times New Roman", serif; letter-spacing: -.02em; }
.note-dialog-subject { margin: 0 0 16px; color: #5b6874; font: 14px/1.5 var(--bn-sans, system-ui, sans-serif); }
.note-dialog textarea, .reader-comment-dialog textarea { min-height: 140px; }
.reader-comment-dialog { position: fixed; z-index: 22; inset: 0; display: grid; place-items: center; padding: 14px; background: rgba(14, 22, 32, .55); }
.reader-comment-dialog label { display: block; margin: 0; }

/* ---------------------------------------------------------------- narrow */
@media (max-width: 979px) {
  .stream-article.is-annotated { grid-template-columns: minmax(0, 820px); }
  .stream-article.is-annotated > .note-annotation-rail { grid-column: 1; grid-row: 2; margin-top: 40px; }
  .note-annotation-tabs { position: static; }
  .note-annotation-rail.is-discussion .note-annotation-list { position: static; max-height: none; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { .note-annotation-list.is-floating .note-annotation-note { transition: none; } }
