/* Notes panel: highlights, exports and spaced review (see highlights-ui.js). */
.round-btn { position: relative; }
.notes-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
}
.notes-badge[hidden] { display: none; }
.hl-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.hl-tab { flex: 1; }
.hl-tab[aria-selected="true"] { background: var(--control-hover); font-weight: 600; }
.hl-add, .hl-export { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hl-item { padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid #e8c547; border-radius: var(--r-md); }
.hl-item.hl-green { border-left-color: #4caf7d; }
.hl-item.hl-blue { border-left-color: var(--accent-2); }
.hl-item.hl-pink { border-left-color: #e86fa7; }
.hl-quote { margin: 0 0 8px; font-family: var(--reader-font, serif); line-height: 1.5; overflow-wrap: anywhere; }
.hl-status { margin: 0 0 8px; font-size: 0.82rem; color: var(--muted); }
.hl-note-label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 2px; }
.hl-note { width: 100%; box-sizing: border-box; resize: vertical; }
.hl-actions { display: flex; gap: 8px; margin-top: 8px; }
.hl-del { margin-left: auto; }
.rv-count { font-size: 1.1rem; margin: 4px 0 8px; }
.rv-source { text-align: center; }
.rv-sitting .panel { position: static; transform: none; width: auto; max-width: none; box-shadow: none; }
@media (max-width: 640px) {
  .hl-add button, .hl-export button, .hl-export select { flex: 1 1 auto; }
}
.hl-export select { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--control); color: var(--text); font: inherit; }

/* Annotating a section after its quiz */
.panel-annotate { width: 100%; max-width: none; }
.annot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.annot-count { color: var(--muted); font-size: 0.85rem; }
.annot-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 4px; }
.annot-colors { display: flex; gap: 8px; }
.annot-swatch { width: 32px; height: 32px; min-width: 32px; min-height: 32px; padding: 0; border-radius: 50%; border: 2px solid var(--border); background: #e8c547; }
.annot-swatch.hl-green { background: #4caf7d; }
.annot-swatch.hl-blue { background: var(--accent-2); }
.annot-swatch.hl-pink { background: #e86fa7; }
.annot-swatch[aria-checked="true"] { border-color: var(--text); box-shadow: none; outline: 2px solid var(--text); outline-offset: 2px; }
.annot-colors-small .annot-swatch { width: 22px; height: 22px; min-width: 22px; min-height: 22px; }
.annot-status { margin: 4px 0 10px; }
.annot-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.annot-text { white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-md); font-family: var(--reader-font, serif); font-size: 1.05rem; line-height: 1.7; user-select: text; }
.stage.overlay-wide .annot-text { max-height: 66vh; overflow-y: auto; } /* the text scrolls in its box so Done stays in view */
.annot-mark { color: inherit; background: #e8c54766; border-radius: var(--r-sm); cursor: pointer; }
.annot-mark.hl-green { background: #4caf7d66; }
.annot-mark.hl-blue { background: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.annot-mark.hl-pink { background: #e86fa766; }
.annot-mark-open { outline: 2px solid var(--accent); outline-offset: 1px; }
.annot-mark:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.annot-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.annot-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.annot-item { padding: 10px 12px; border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--r-md); }
.annot-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.annot-remove { min-width: 32px; min-height: 32px; padding: 0; border-radius: 50%; font-size: 1.2rem; line-height: 1; }
.annot-note { overflow: hidden; resize: none; }
.annot-foot { position: sticky; bottom: 0; padding-top: 10px; background: var(--card, var(--bg)); }
@media (max-width: 720px) {
  .annot-cols { grid-template-columns: 1fr; }
}

/* ---------- Notes: underline tabs, cards, empty state ---------- */
.hl-tabs { gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.hl-tab { flex: 0 0 auto; min-height: 44px; padding: 8px 16px; border: 0; border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); font: inherit; }
.hl-tab:hover { background: var(--control); color: var(--text); }
.hl-tab[aria-selected="true"] { background: transparent; color: var(--text); border-bottom-color: var(--accent-2); font-weight: 600; }
.hl-empty { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px dashed var(--border); border-radius: var(--r-md); }
.hl-empty span { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.rv-count { margin: 0 0 6px; font-size: 1.1rem; }
.rv-count .stat-num { font-size: 2.2rem; line-height: 1; margin-right: 6px; }
.hl-tags { margin-top: 6px; }
.hl-tag-input { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--control); color: inherit; font: inherit; font-size: 0.9rem; }

/* ---------- The "This text" page: a full window, one tab per kind of thing, Review set apart (principles 26, 44; decision 37) ---------- */
#notesPanel .sp-body { max-width: 1280px; }
.tt-title { min-width: 0; }
.tt-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tt-eyebrow { margin: 0 0 2px; font-size: 0.85rem; color: var(--muted); }
.tt-eyebrow[hidden] { display: none; }
#notesPanel .sp-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.tt-head-actions .round-btn.has-label { width: auto; padding: 0 14px 0 11px; gap: 7px; border-radius: 999px; }
.tt-head-actions .round-btn.has-label .rb-label { display: inline; }
.tt-head-actions .round-btn[hidden] { display: none; }

/* The list on the left. Review sits at its foot, in the accent colour: it is the one thing here you come back to. */
#notesPanel .sp-nav { width: 220px; }
.tt-nav .stab { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.tt-chip { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--control-hover); color: var(--text); font-size: 0.78rem; font-weight: 600; text-align: center; }
.tt-nav .tt-review { margin-top: auto; border: 2px solid var(--accent-2); color: var(--text); font-weight: 600; }
.tt-nav .tt-review:hover { background: var(--control); }
.tt-nav .tt-review[aria-selected="true"] { background: var(--accent-2); color: var(--bg); }
.tt-nav .tt-review .tt-chip { background: var(--accent); color: var(--bg); }

.tt-content { display: flex; flex-direction: column; gap: 16px; padding-top: 18px; }
.tt-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-sizing: border-box; }
.tt-card-head { display: flex; align-items: center; gap: 10px; }
.tt-card-title { margin: 0; font-size: 1rem; font-family: var(--font-display); }
.tt-pill { padding: 2px 10px; border-radius: 999px; background: var(--control); color: var(--muted); font-size: 0.76rem; }
.tt-hint { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

/* Overview and Sections: plain text read as it is, changed with a pencil. Only the takeaways and the sections are cards. */
.tt-flow { display: flex; flex-direction: column; gap: 30px; max-width: 1120px; }
.tt-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; align-items: start; }
.tt-block { display: flex; flex-direction: column; gap: 6px; }
.tt-block-head { display: flex; align-items: center; gap: 4px; }
.tt-block-title { margin: 0; font-size: 1.1rem; font-family: var(--font-display); }
.tt-text { margin: 0; font-size: 1.05rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.tt-empty { color: var(--muted); font-style: italic; }
.tt-edit { flex: 1 1 auto; min-width: 0; }
.tt-edit-actions { display: flex; gap: 8px; margin-top: 8px; }
.tt-edit-actions button { min-height: 40px; }
button.tt-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
button.tt-icon:hover { background: var(--control); color: var(--text); }
button.tt-icon[hidden] { display: none; }
.tt-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tt-takes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.tt-all-cols { grid-column: 1 / -1; }
.tt-take { flex-direction: row; align-items: flex-start; gap: 8px; padding: 12px 8px 12px 18px; }
.tt-take .tt-text { font-size: 1rem; }

.tt-area { display: block; width: 100%; box-sizing: border-box; min-height: 120px; resize: none; overflow: hidden; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--control); color: var(--text); font: inherit; font-size: 1rem; line-height: 1.65; }
.tt-area:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

/* Sections: one card each; number, counts, pencil and Annotate on one line, the note underneath. */
.tt-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.tt-section { gap: 6px; }
.tt-sec-head { display: flex; align-items: center; gap: 10px; }
.tt-num { margin: 0; font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.tt-sec-head .tt-push { margin-left: auto; }
button.tt-small { min-height: 36px; padding: 4px 14px; font-size: 0.88rem; }

/* Annotations: the annotating screen, one section at a time. The panel- classes it uses are styled for the reader's overlay only, so they are given here too. */
.tt-annot .panel-title { margin: 0; font-size: 1.05rem; font-family: var(--font-display); }
.tt-annot .panel-sub { margin: 0; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tt-annot .panel-muted { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.tt-annot .panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.tt-pick { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--control); color: var(--text); font: inherit; min-height: 44px; }

/* Review: its own tab and its own button in the reader. */
.tt-review-pane { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.tt-review-card { gap: 12px; }
.tt-review-card button.primary { align-self: flex-start; }

/* The reader's Review button: a pill with a word, so it reads as more than one of the round tools beside it. */
.review-btns button.review-open { position: relative; width: auto; padding: 0 18px 0 14px; gap: 8px; color: var(--text); border: 2px solid var(--accent-2); font-weight: 600; }
.review-btns button.review-open:hover { background: var(--control); }
.rv-badge { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 0.78rem; font-weight: 700; line-height: 1.3; text-align: center; }
.rv-badge[hidden] { display: none; }

@media (max-width: 860px) {
    }
@media (max-width: 640px) {
  #notesPanel .sp-nav { width: auto; }
  .tt-nav .stab { flex: none; }
  .tt-nav .tt-review { margin-top: 0; order: -1; } /* first in the row, so it is never scrolled out of sight */
}

/* A highlight's note: a small window over the text, opened by clicking the highlight. */
.annot-pop-back { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; background: color-mix(in srgb, var(--bg) 65%, transparent); }
.annot-pop { position: relative; width: min(900px, 100%); max-height: 90vh; overflow-y: auto; box-sizing: border-box; display: flex; flex-direction: column; gap: 14px; padding: 40px 20px 18px; border: 1px solid var(--border); border-left: 4px solid #e8c547; border-radius: var(--radius); background: var(--card); color: var(--text); text-align: left; }
.annot-pop.hl-green { border-left-color: #4caf7d; }
.annot-pop.hl-blue { border-left-color: var(--accent-2); }
.annot-pop.hl-pink { border-left-color: #e86fa7; }
.annot-pop-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.annot-pop-quotewrap { position: relative; display: flex; min-width: 0; }
.annot-pop-quote { flex: 1 1 auto; margin: 0; padding: 12px 48px 12px 16px; min-height: 200px; max-height: 46vh; overflow-y: auto; border-left: 3px solid var(--border); background: var(--bg); border-radius: var(--r-md); color: var(--text); font-family: var(--reader-font, serif); font-size: 1rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.annot-pop-quotewrap .ai-star { position: absolute; top: 10px; right: 12px; width: 26px; height: 26px; }
.annot-pop-note { display: block; width: 100%; box-sizing: border-box; min-height: 200px; max-height: 46vh; resize: none; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--control); color: var(--text); font: inherit; line-height: 1.6; }
.annot-pop-note:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.annot-pop .hl-tag-input { width: 100%; box-sizing: border-box; }
.annot-pop-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.annot-pop-foot .hl-tags { flex: 1 1 200px; min-width: 0; }
.annot-pop-foot > button { margin: 0; }
#notesPanel .annot-pop .annot-swatch, .annot-pop .annot-swatch { flex: none; box-sizing: border-box; width: 24px; height: 24px; min-width: 24px; min-height: 24px; padding: 0; aspect-ratio: 1 / 1; }

/* The annotating screen's top row: everything on one line, so the text gets the space. */
.annot-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 8px; }
.annot-head .panel-title { margin: 0; }
.annot-head .annot-count { color: var(--muted); font-size: 0.85rem; }
.annot-head .annot-status { color: var(--muted); font-size: 0.85rem; }
.annot-head .annot-go { margin-left: auto; }
.annot-head .annot-step { min-width: 44px; padding: 0 10px; font-size: 1.3rem; line-height: 1; }
.ai-star { width: 24px; height: 24px; fill: var(--accent-2); flex: none; }

/* Annotations on the page: the section's text in a card that fills the window, the controls in a little toolbar under it. Nothing overlaps. */
.tt-view-highlights { overflow: hidden; }
.tt-annot { position: relative; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.tt-annot .panel-annotate { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 0; border: 0; background: transparent; gap: 10px; }
.tt-annot .annot-cols { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 18px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.tt-annot .annot-text { flex: 1 1 auto; min-height: 0; padding: 0 0 110px; border: 0; overflow-y: auto; font-size: 1.1rem; line-height: 1.8; } /* the room under the last line is for the capsule */

/* The bar that offers a deleted annotation back. */
.annot-undo { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 500; display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 18px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); max-width: calc(100vw - 32px); }
.annot-undo button { min-height: 36px; padding: 4px 16px; border-radius: 999px; }

/* The capsule of controls, the same shape as the collection page's: it floats over the bottom of the text. */
.annot-bar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 5; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 24px); padding: 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); box-shadow: var(--shadow-md, var(--shadow-sm)); }
.annot-bar button, .annot-bar select { min-height: 48px; border-radius: 999px; font-weight: 600; margin: 0; }
.annot-bar button:not(.primary) { border: 0; background: var(--control); }
.annot-bar .annot-step { min-width: 48px; padding: 0 12px; font-size: 1.4rem; }
.annot-bar .annot-all-btn { display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; }
.annot-bar .annot-go { margin-left: 0; padding: 0 22px; }
.annot-bar .tt-pick { padding: 0 14px; border: 0; background: var(--control); }
.annot-flash { position: absolute; left: 50%; bottom: 86px; transform: translateX(-50%); z-index: 5; padding: 4px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 0.85rem; }
.annot-flash:empty { display: none; }

/* View All: every annotation of the text as a list of rows. */
.annot-all-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 110px; }
button.annot-all-row { display: flex; flex: none; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; min-height: 0; padding: 12px 14px; text-align: left; border: 1px solid var(--border); border-left: 4px solid #e8c547; border-radius: var(--r-md); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
button.annot-all-row.hl-green { border-left-color: #4caf7d; }
button.annot-all-row.hl-blue { border-left-color: var(--accent-2); }
button.annot-all-row.hl-pink { border-left-color: #e86fa7; }
button.annot-all-row:hover:not(:disabled) { background: var(--control); }
button.annot-all-row:disabled { opacity: 0.55; cursor: default; }
.annot-all-top { display: flex; align-items: center; gap: 8px; }
.annot-all-sec { color: var(--muted); font-size: 0.82rem; }
.annot-all-quote { font-family: var(--reader-font, serif); font-size: 1.02rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.annot-all-note { color: var(--muted); font-size: 0.9rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 900px) { .tt-takes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .tt-top { grid-template-columns: 1fr; gap: 24px; } }
@media (max-width: 560px) { .tt-takes { grid-template-columns: 1fr; } .annot-bar { border-radius: 28px; } }

/* The window's close: a bare × in its corner. */
.annot-pop button.annot-x, #notesPanel .annot-pop button.annot-x { position: absolute; top: 6px; right: 10px; min-width: 36px; min-height: 36px; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 1.7rem; line-height: 1; cursor: pointer; }
.annot-pop button.annot-x:hover { color: var(--text); background: none; }
@media (max-width: 640px) { .annot-pop-grid { grid-template-columns: 1fr; } .annot-pop-quote, .annot-pop-note { min-height: 120px; } }
