/* The collection screen: one collection on a page of its own. Uses only theme variables. */
body.coll-open { overflow: hidden; }
.coll-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.coll-screen[hidden] { display: none; }
.coll-screen > * { width: 100%; max-width: 920px; margin-left: auto; margin-right: auto; box-sizing: border-box; }

.coll-head { flex: none; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 14px; padding-bottom: 0; }
.coll-back { min-height: 44px; }
.coll-title { margin: 0; font-size: clamp(1.25rem, 4vw, 1.7rem); line-height: 1.2; overflow-wrap: anywhere; }
.coll-chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.coll-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--control); border: 1px solid var(--border); font-size: 0.85rem; color: var(--muted); }
.coll-chip .coll-icon { width: 15px; height: 15px; }
.coll-about { grid-column: 1 / -1; margin: 0; color: var(--muted); line-height: 1.5; }
.coll-about strong { color: var(--text); }

.coll-tabs { flex: none; position: sticky; top: calc(-1 * max(16px, env(safe-area-inset-top))); padding-top: max(16px, env(safe-area-inset-top)); z-index: 3; display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--bg); scrollbar-width: thin; }
.coll-tab { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; min-height: 44px; padding: 8px 14px; border: 0; border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.coll-tab:hover { background: var(--control); color: var(--text); }
.coll-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent-2); font-weight: 600; }

.coll-body { padding-top: 18px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.coll-block { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.coll-h { margin: 0; font-size: 1.1rem; }
.coll-note, .coll-sub { margin: 0; color: var(--muted); line-height: 1.5; font-size: 0.92rem; }
.coll-empty { margin: 0; padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }

.coll-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.coll-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.coll-item-info { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.coll-item-info strong { overflow-wrap: anywhere; }
.coll-item-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.coll-meter { height: 6px; border-radius: 3px; background: var(--control); overflow: hidden; }
.coll-meter i { display: block; height: 100%; background: var(--accent-2); }
.coll-add select, .coll-search { width: 100%; max-width: 420px; min-height: 44px; box-sizing: border-box; }

.coll-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.coll-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.coll-stat strong { font-size: 1.5rem; line-height: 1.1; }
.coll-stat span { font-size: 0.82rem; color: var(--muted); }

.coll-glossary { margin: 0; display: grid; gap: 4px 0; }
.coll-glossary dt { margin-top: 12px; font-weight: 650; }
.coll-glossary dd { margin: 0; color: var(--muted); line-height: 1.5; }

.coll-notes { width: 100%; box-sizing: border-box; resize: none; overflow: hidden; field-sizing: content; }
.coll-mark { padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--accent-2); border-radius: 10px; background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.coll-quote { margin: 0; font-family: var(--reader-font, serif); line-height: 1.5; overflow-wrap: anywhere; }
.coll-notetext { margin: 0; line-height: 1.5; }
.coll-passage { margin: 8px 0 4px; padding: 12px 14px; border-left: 4px solid var(--accent-2); background: var(--control); border-radius: 8px; font-family: var(--reader-font, serif); line-height: 1.6; overflow-wrap: anywhere; }

.coll-form { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }
.coll-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.coll-danger { margin-left: auto; color: var(--accent); border-color: var(--accent); background: transparent; }

/* A test, practice or card run draws the shared panels right in the page. */
.overlay.coll-run { position: static; inset: auto; z-index: auto; background: transparent; padding: 0; min-height: 320px; overflow: visible; }
.overlay.coll-run .panel { animation: none; }

@media (max-width: 560px) {
  .coll-head { grid-template-columns: 1fr; }
  .coll-danger { margin-left: 0; }
  .coll-item-actions button { flex: 1 1 auto; min-height: 44px; }
}

/* ---------- Symbols, buttons and choices ---------- */
.coll-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.coll-screen button.coll-ibtn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 44px; padding: 8px; }
.coll-screen button.coll-ibtn.has-text { padding: 8px 14px; }
.coll-screen button.coll-ibtn.primary { padding: 8px 14px; }
.coll-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.coll-bar .coll-search { flex: 1 1 220px; max-width: none; }
.coll-bar .coll-sort { flex: 0 1 220px; min-height: 44px; box-sizing: border-box; }
.coll-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--control); align-self: flex-start; }
.coll-screen button.coll-seg-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.coll-screen button.coll-seg-btn[aria-checked="true"] { background: var(--card); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent-2); }
.coll-label { display: flex; align-items: center; gap: 7px; margin: 0; font-weight: 600; }
.coll-label small { font-weight: 400; margin-left: auto; }
.coll-checks { display: flex; flex-direction: column; gap: 8px; }
.coll-check { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.coll-check input { width: 20px; height: 20px; min-height: 0; padding: 0; }
.coll-saved { min-height: 1.2em; font-size: 0.82rem; color: var(--accent-2); }
.coll-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.coll-range input[type="range"] { flex: 1 1 160px; min-height: 32px; }

/* ---------- Glossary ---------- */
.gloss { display: flex; flex-direction: column; gap: 8px; }
.gloss-letter { margin: 14px 0 2px; font-size: 1.1rem; color: var(--accent-2); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.gloss-entry { padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--accent-2); border-radius: 10px; background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.gloss-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gloss-term { margin: 0; font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.gloss-tools { display: flex; gap: 4px; }
.gloss-def { margin: 0; line-height: 1.55; overflow-wrap: anywhere; }
.gloss-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--control); color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.gloss-note .coll-icon { margin-top: 2px; color: var(--accent-2); }
.coll-edit-card { display: flex; flex-direction: column; gap: 8px; }
.coll-edit-card input { width: 100%; box-sizing: border-box; }

/* ---------- Notes ---------- */
.notes-text { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.notes-text-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notes-text-head h4 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.notes-field { display: flex; flex-direction: column; gap: 6px; }
.coll-mark-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- Appearance ---------- */
.look-grid { display: grid; gap: 10px; }
.look-themes { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.look-fonts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.coll-screen button.look-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 84px; padding: 10px 8px; border-radius: 12px; background: var(--card); border: 2px solid var(--border); }
.coll-screen button.look-choice[aria-checked="true"] { border-color: var(--accent-2); }
.look-font { font-size: 2rem; line-height: 1; color: var(--text); }
.look-name { font-size: 0.82rem; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.look-choice[aria-checked="true"] .look-name { color: var(--text); font-weight: 600; }
.look-same { font-size: 1.8rem; line-height: 1; color: var(--muted); }
.look-themes .swatch-art { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 56px; border-radius: 8px; background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.look-themes .swatch-art i { font: 600 1.25rem/1 Georgia, serif; font-style: normal; }
.look-themes .swatch-art u { position: absolute; right: 7px; bottom: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); }

/* ---------- Settings ---------- */
.coll-langs { display: flex; flex-direction: column; gap: 8px; }
.coll-lang { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.coll-lang-name { flex: 1 1 120px; }
.coll-lang input { width: 90px; }

/* ---------- Moving a text: the collections as books, in a small window ---------- */
.move-dialog { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.move-card { width: 100%; max-width: 760px; max-height: 90vh; overflow-y: auto; box-sizing: border-box; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.move-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }

/* ---------- Notes: cards side by side, one text at a time ---------- */
.notes-top { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.note-card, .set-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.note-card textarea { width: 100%; box-sizing: border-box; resize: none; overflow: hidden; }
.notes-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.coll-screen button.notes-chip { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border-radius: 999px; background: var(--control); }
.coll-screen button.notes-chip[aria-selected="true"] { background: var(--card); border-color: var(--accent-2); font-weight: 600; }
.notes-panel { display: flex; flex-direction: column; gap: 12px; }
.notes-text-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notes-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.note-card.wide { grid-column: 1 / -1; }
.notes-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.notes-section { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.coll-mark { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--accent-2); border-radius: 10px; background: var(--bg); }
.coll-mark-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.coll-mark-side textarea { width: 100%; }

/* ---------- Settings: cards in a grid ---------- */
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.set-card.set-card-wide { grid-column: 1 / -1; } /* the "Tailor the questions" card spans the grid */
.set-card .coll-h { display: flex; align-items: center; gap: 8px; }
.look-views { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.look-choice .coll-icon { width: 28px; height: 28px; color: var(--text); }
.set-save { position: sticky; bottom: 0; z-index: 3; display: flex; padding: 10px 0; background: var(--bg); }

/* ---------- Small extras ---------- */
.coll-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-2); color: var(--bg); font-size: 0.72rem; font-weight: 700; }
.coll-undo { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); max-width: calc(100vw - 32px); }
.coll-screen button.coll-top { position: fixed; right: 20px; bottom: 20px; left: auto; width: auto; max-width: none; margin: 0; z-index: 80; min-width: 48px; min-height: 48px; border-radius: 50%; background: var(--card); border: 1px solid var(--border); }
.coll-screen button.coll-top[hidden] { display: none; }

@media (max-width: 700px) {
  .notes-top, .notes-grid, .coll-mark { grid-template-columns: 1fr; }
  .coll-undo { bottom: 80px; }
}

/* The export window */
.exp-card { max-width: 560px; }
.exp-form { display: flex; flex-direction: column; gap: 12px; }
.exp-field { display: flex; flex-direction: column; gap: 4px; }
.exp-label { font-size: 0.85rem; color: var(--muted); }
.exp-field select { width: 100%; min-height: 44px; box-sizing: border-box; }
.exp-options { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; }
.exp-check { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.exp-summary { margin: 12px 0 0; font-weight: 600; }
.exp-help { margin: 4px 0 8px; }
.exp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gloss-type { margin-right: auto; margin-left: 8px; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 0.8rem; }
.coll-tags { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--control); color: inherit; font: inherit; font-size: 0.9rem; }

/* Segmented control, Readwise-style (docs/design-research.md): a quiet pill track, the picked segment a lifted pill. */
.coll-seg { gap: 2px; padding: 3px; border-color: transparent; border-radius: 22px; }
.coll-screen button.coll-seg-btn { border-radius: 20px; padding: 6px 16px; }
.coll-screen button.coll-seg-btn[aria-checked="true"] { box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--accent-2); }

/* Quizlet-style set page (docs/design-research.md): the three practice modes are three equal boxes, and a text row starts with an icon tile. */
.coll-seg.coll-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 0; border: 0; border-radius: 0; background: transparent; align-self: stretch; }
.coll-screen .coll-modes button.coll-seg-btn { flex-direction: column; justify-content: center; gap: 6px; min-height: 64px; padding: 10px 12px; border: 2px solid transparent; border-radius: 16px; background: var(--control); color: var(--text); font-weight: 600; }
.coll-screen .coll-modes button.coll-seg-btn:hover { background: var(--control-hover); }
.coll-screen .coll-modes button.coll-seg-btn[aria-checked="true"] { background: var(--card); border-color: var(--accent-2); box-shadow: var(--shadow-sm); }
.coll-item-tile { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--accent-2) 14%, var(--card)); color: var(--accent-2); }
.coll-item-tile .coll-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.coll-item-info strong { font-size: 1.02rem; }

/* Labels and callouts (design audit) */
.coll-mark, .coll-passage, .gloss-entry { border: 1px solid color-mix(in srgb, var(--accent-2) 40%, var(--border)); border-radius: 14px; background: color-mix(in srgb, var(--accent-2) 7%, var(--card)); }

/* Opening a tab (or the page) lifts its content in, one block after another; the header and the tab row stay put. Off with "Screen animations" and for reduced motion (styles.css). */
@keyframes coll-rise { from { opacity: 0; transform: translateY(22px) scale(0.985); } to { opacity: 1; transform: none; } }
.coll-body.enter > * { animation: coll-rise 0.55s var(--ease-out) both; }
.coll-body.enter > *:nth-child(2) { animation-delay: 0.07s; }
.coll-body.enter > *:nth-child(3) { animation-delay: 0.14s; }
.coll-body.enter > *:nth-child(4) { animation-delay: 0.21s; }
.coll-body.enter > *:nth-child(5) { animation-delay: 0.28s; }
.coll-body.enter > *:nth-child(n+6) { animation-delay: 0.35s; }
.coll-body.enter .set-grid > .set-card:nth-child(2), .coll-body.enter .coll-list > li:nth-child(2) { animation: coll-rise 0.55s var(--ease-out) 0.12s both; }
.coll-body.enter .set-grid > .set-card:nth-child(3), .coll-body.enter .coll-list > li:nth-child(3) { animation: coll-rise 0.55s var(--ease-out) 0.2s both; }
.coll-body.enter .set-grid > .set-card:nth-child(n+4), .coll-body.enter .coll-list > li:nth-child(n+4) { animation: coll-rise 0.55s var(--ease-out) 0.28s both; }
