/* Shared semantic controls; compact application layout, separate reader typography. */
:root {
  color-scheme: light;
  --paper: #ffffff;
  --surface: #f6f7f9;
  --ink: #20262e;
  --muted: #59636e;
  --line: #d9dee4;
  --accent: #24705b;
  --button: #24705b;
  --light: #edf5f0;
  --sidebar-bg: #f5f8f6;
  --source-ink: #355f87;
  --source-soft: #edf3fa;
  --progress-ink: #8b601a;
  --progress-soft: #fcf4e4;
  --control-line: #b9c2cc;
  --sidebar-line: #dce5df;
  --sidebar-muted: #65746a;
  --sidebar-ink: #4e5c54;
  --sidebar-hover: #eaf0ec;
  --sidebar-active: #e2eee7;
  --sidebar-active-ink: #1e604a;
  --sidebar-active-count: #367056;
  --nav-symbol: #7a8d81;
  --nav-blue: #5080a5;
  --nav-amber: #a57a36;
  --nav-green: #368066;
  --nav-violet: #82709e;
  --sidebar-divider: #e0e7e2;
  --source-active: #e9f0f5;
  --draft-ink: #65557d;
  --account-ink: #69766d;
  --button-hover: #1c5948;
  --offline-ink: #745409;
  --offline-soft: #fff7df;
  --offline-line: #e3cf96;
  --message-line: #c5d5e5;
  --message-ink: #274d71;
  --message-soft: #f0f5fa;
  --error-ink: #913b30;
  --error-soft: #fdf3f1;
  --error-line: #e5c9c4;
  --row-line: #e5e9e6;
  --note-ink: #65705e;
  --tag-line: #dce7e0;
  --tag-soft: #f6f9f7;
  --tag-ink: #587462;
  --tag-hover-line: #91b6a1;
  --status-line: #d1ded6;
  --status-ink: #57846c;
  --status-hover: #e5f0e9;
  --status-hover-line: #94b5a2;
  --status-hover-ink: #246b4a;
  --selection-line: #9bb8a7;
  --note-line: #a7b5c4;
  --sidebar-width: 216px;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 4px;
}

:root[data-color-mode=dark] {
  color-scheme: dark;
  --paper: #1c2228;
  --surface: #252d35;
  --ink: #e0e6ec;
  --muted: #a6b2bd;
  --line: #414b55;
  --accent: #8ed1b0;
  --button: #2d755e;
  --light: #283e32;
  --sidebar-bg: #20262c;
  --source-ink: #a2c8eb;
  --source-soft: #283b4d;
  --progress-ink: #e1bf83;
  --progress-soft: #3d3422;
  --control-line: #56616c;
  --sidebar-line: #39434d;
  --sidebar-muted: #a6b2bd;
  --sidebar-ink: #c7d0d9;
  --sidebar-hover: #2a333c;
  --sidebar-active: #303c3a;
  --sidebar-active-ink: #a3dfbf;
  --sidebar-active-count: #a3dfbf;
  --nav-symbol: #a1adb8;
  --nav-blue: #91b9dc;
  --nav-amber: #d9b478;
  --nav-green: #8ac8a8;
  --nav-violet: #bba6d5;
  --sidebar-divider: #39434d;
  --source-active: #283b4d;
  --draft-ink: #c7b2e1;
  --account-ink: #a6b2bd;
  --button-hover: #286c56;
  --offline-ink: #edd095;
  --offline-soft: #3d3422;
  --offline-line: #79623b;
  --message-line: #425f7b;
  --message-ink: #b1d1ee;
  --message-soft: #243444;
  --error-ink: #f3afa5;
  --error-soft: #402b2b;
  --error-line: #7e504b;
  --row-line: #35413b;
  --note-ink: #b2bea8;
  --tag-line: #405449;
  --tag-soft: #25372d;
  --tag-ink: #adcbb8;
  --tag-hover-line: #80ad93;
  --status-line: #4b6556;
  --status-ink: #9dc9ae;
  --status-hover: #2b4638;
  --status-hover-line: #80ad93;
  --status-hover-ink: #b0dfbf;
  --selection-line: #658a74;
  --note-line: #6d839a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a, button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--control-line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.4;
}
input[type=checkbox] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
input[type=range] { padding: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
label { display: block; font-size: .875rem; font-weight: 500; }
label > input:not([type=checkbox]), label > select { display: block; margin-top: 5px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.75rem; line-height: 1.3; font-weight: 650; letter-spacing: -.025em; margin-bottom: 16px; }
h2 { font-size: 1.125rem; line-height: 1.4; font-weight: 650; margin-bottom: 16px; }
h3 { font-size: 1rem; line-height: 1.4; font-weight: 600; margin-bottom: 8px; }
p { margin-bottom: 16px; }
form { margin: 0; }
ul, ol { padding-left: 24px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
[hidden] { display: none !important; }

/* The application uses a persistent sidebar; reading stays full width. */
.site-header { border-bottom: 1px solid var(--line); }
.nav-inner { max-width: 1128px; min-height: 56px; margin: auto; padding: 0 28px; display: flex; align-items: center; gap: 24px; }
.wordmark { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-size: 1.125rem; font-weight: 750; letter-spacing: -.035em; text-decoration: none; }
.container { width: 100%; max-width: 1128px; padding: 0 28px; margin: auto; min-height: 70vh; }
.site-footer { max-width: 1064px; margin: 48px auto 0; border-top: 1px solid var(--line); padding: 16px 0 24px; display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; }
.site-footer a { color: var(--muted); }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 26px 0 20px; }
.page-heading h1 { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.page-heading > div { min-width: 0; }
.page-heading p { margin: 6px 0 0; font-size: .8125rem; }
.app-page { font-size: .9375rem; }
.app-page > .page-body { margin-left: var(--sidebar-width); min-height: 100dvh; display: flex; flex-direction: column; }
.app-page .container { max-width: 1280px; min-height: 0; flex: 1; }
.app-page .page-heading { padding: 22px 0 16px; }
.app-page .page-heading h1 { font-size: 1.375rem; }
.app-page .site-footer { max-width: none; margin: 28px 28px 0; padding: 12px 0 18px; }
.app-page .messages { width: 100%; max-width: 1280px; padding: 16px 28px 0; margin: 0 auto; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; flex-direction: column; width: var(--sidebar-width); height: 100dvh; padding: 18px 12px 10px; border-right: 1px solid var(--sidebar-line); background: var(--sidebar-bg); }
.sidebar-brand { display: flex; justify-content: space-between; align-items: center; padding: 0 8px; }
.sidebar-brand img { flex-shrink: 0; }
.sidebar .sidebar-add { margin: 20px 6px; min-height: 34px; justify-content: start; padding-left: 14px; font-size: .8125rem; }
.sidebar-add > span { margin-right: 2px; font-size: 1rem; font-weight: 400; }
.sidebar-scroll { min-height: 0; flex: 1; overflow-y: auto; }
.sidebar-label { margin: 0 10px 6px; color: var(--sidebar-muted); font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px 10px; border-radius: 4px; color: var(--sidebar-ink); text-decoration: none; font-size: .875rem; }
.sidebar-nav a > span:not(.nav-symbol):not(.count) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: var(--ink); }
.sidebar-nav a[aria-current] { background: var(--sidebar-active); color: var(--sidebar-active-ink); font-weight: 600; }
.sidebar-nav .count { margin-left: auto; color: var(--sidebar-muted); font-size: .6875rem; }
.sidebar-nav a[aria-current] .count { color: var(--sidebar-active-count); }
.nav-symbol { width: 17px; flex-shrink: 0; text-align: center; font-size: 1rem; line-height: 1; color: var(--nav-symbol); }
.unread-symbol { color: var(--nav-blue); }
.reading-symbol { color: var(--nav-amber); }
.read-symbol { color: var(--nav-green); }
.epub-symbol { color: var(--nav-violet); }
.sidebar-documents { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--sidebar-divider); }
.sidebar-draft { padding: 16px 10px; margin-top: 16px; border-top: 1px solid var(--sidebar-divider); }
.sidebar-draft .sidebar-label { margin: 0 0 8px; }
.sidebar-draft > a { display: block; font-size: .8125rem; color: var(--draft-ink); line-height: 1.5; overflow-wrap: anywhere; }
.sidebar-draft > span { display: block; margin-top: 4px; color: var(--muted); font-size: .6875rem; }
.sidebar-account { display: flex; align-items: center; gap: 8px; padding: 12px 8px 0; margin-top: 10px; border-top: 1px solid var(--sidebar-line); }
.account-profile { display: grid; min-width: 0; color: var(--sidebar-ink); text-decoration: none; border-radius: var(--radius); }
.account-profile:hover, .account-profile[aria-current] { color: var(--accent); }
.account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: inherit; font-size: .8125rem; font-weight: 600; }
.sidebar-account form { margin-left: auto; flex-shrink: 0; }
.sidebar-account .text-button { padding: 0; font-size: .75rem; color: var(--account-ink); }
.mobile-header, .sidebar .sidebar-close { display: none; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 35; border: 0; background: #14251bb3; padding: 0; }
.filter-chip { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; min-height: 32px; padding: 3px 8px; border-radius: 3px; background: var(--source-soft); color: var(--source-ink); font-size: .75rem; text-decoration: none; }
.filter-value { min-width: 0; overflow-wrap: anywhere; }
.filter-remove { flex-shrink: 0; font-size: 1rem; }
.filter-chip:hover { box-shadow: inset 0 0 0 1px var(--source-ink); }

/* Controls and shared states */
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--button);
  border-radius: var(--radius);
  background: var(--button);
  color: #fff;
  font-size: .875rem;
  font-weight: 550;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { background: var(--button-hover); color: #fff; text-decoration: none; }
.button.secondary { color: var(--ink); background: var(--paper); border-color: var(--control-line); }
.button.secondary:hover { background: var(--surface); }
.button.small { min-height: 34px; padding: 5px 11px; font-size: .8125rem; }
.text-button { border: 0; background: none; color: var(--accent); padding: 6px 0; font-size: .875rem; text-decoration: underline; text-underline-offset: 3px; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--control-line); background: var(--paper); border-radius: var(--radius); color: var(--ink); }
.icon-button:not(:disabled):hover { background: var(--surface); }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.count { font-size: .75rem; font-variant-numeric: tabular-nums; font-weight: 500; color: var(--muted); }
.badge, .offline-badge { display: inline-block; padding: 1px 7px; font-size: .75rem; line-height: 1.6; font-weight: 500; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: var(--surface); }
.offline-badge { color: var(--offline-ink); background: var(--offline-soft); border-color: var(--offline-line); }
.panel { border: 1px solid var(--line); padding: 24px; border-radius: var(--radius); }
.muted, .fine { color: var(--muted); }
.fine { font-size: .8125rem; line-height: 1.7; }
.break-word { overflow-wrap: anywhere; }
.messages { max-width: 1128px; margin: 20px auto 0; padding: 0 32px; }
.message { padding: 12px 14px; border: 1px solid var(--message-line); border-radius: var(--radius); color: var(--message-ink); background: var(--message-soft); font-size: .875rem; overflow-wrap: anywhere; }
.message.error { color: var(--error-ink); background: var(--error-soft); border-color: var(--error-line); }
.error, .errorlist { color: var(--error-ink); }
.errorlist { font-size: .875rem; padding-left: 20px; }
.empty-state { padding: 36px 24px; color: var(--muted); font-size: .875rem; border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state h2 { color: var(--ink); }
.empty-state p:last-child { margin-bottom: 0; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 24px; margin-top: 28px; font-size: .875rem; }

/* Library controls share a compact desktop scale and a clear surface. */
.library-workspace { --library-control-size: 36px; }
.library-workspace .library-control { min-height: var(--library-control-size); padding: 6px 10px; border-radius: 5px; font-size: .8125rem; line-height: 1.4; }
.library-workspace .library-control.quiet { border: 1px solid transparent; background: transparent; color: var(--ink); font-weight: 500; }
.library-workspace .library-control.quiet:hover { background: var(--paper); border-color: var(--line); }
.page-heading .page-eyebrow { margin: 0 0 5px; color: var(--muted); font-size: .6875rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
.library-status { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.library-status a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: .875rem; text-decoration: none; white-space: nowrap; }
.library-status a:hover { color: var(--accent); }
.library-status a[aria-current] { border-color: var(--accent); color: var(--accent); font-weight: 650; }
.library-status .count { min-width: 20px; padding: 0 5px; border-radius: 4px; background: var(--surface); font-size: .6875rem; text-align: center; }
.library-status a[aria-current] .count { background: var(--light); color: var(--accent); }
.library-scope { margin: 10px 0 18px; color: var(--muted); font-size: .75rem; }
.filters { position: relative; margin-bottom: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.search-row { display: flex; align-items: end; gap: 8px; margin-right: 104px; }
.filters label { min-width: 0; color: var(--muted); font-size: .75rem; font-weight: 500; }
.filters .search-label { flex: 1; }
.filters .source-label { flex: 0 1 190px; }
.filter-panel > summary { position: absolute; top: calc(1.2rem + 17px); right: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 96px; cursor: pointer; list-style: none; }
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary::after { content: '⌄'; }
.filter-panel[open] > summary::after { transform: rotate(180deg); }
.filter-panel[open] > summary.library-control { background: var(--paper); border-color: var(--line); }
.filter-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 3px; background: var(--source-soft); color: var(--source-ink); font-size: .6875rem; font-weight: 600; }
.filter-panel[open] { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.filter-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 12px; }
.filters .filter-checkbox { display: flex; align-items: center; gap: 8px; min-height: var(--library-control-size); font-weight: 400; }
.filter-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; }
.active-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.reset-filters { padding: 6px 0; font-size: .75rem; }
.list-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; min-height: 36px; padding: 0 0 12px; font-size: .75rem; color: var(--muted); }
.result-count { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; margin: 0; color: var(--ink); font-size: 1rem; line-height: 1.5; font-weight: 600; }
.result-label { color: var(--muted); font-size: .8125rem; font-weight: 400; }
.list-toolbar > div { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.sort-tools { display: flex; align-items: center; gap: 8px; }
.sort-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; font-weight: 400; white-space: nowrap; }
.sort-control > select { width: auto; max-width: 190px; margin: 0; }
.select-all, .excerpt-toggle { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: .75rem; color: var(--muted); }
.excerpt-toggle input { width: 15px; height: 15px; }
.article-list { border-top: 1px solid var(--control-line); }
.article-row { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; column-gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.article-row:has(input[name=articles]:checked) { background: var(--light); box-shadow: -10px 0 var(--light), 10px 0 var(--light); }
.select-article { display: none; place-items: center; width: 40px; height: 40px; margin: -8px 0 0 -11px; }
.article-title { font-size: 1rem; line-height: 1.45; font-weight: 600; letter-spacing: -.01em; margin: 0 0 4px; overflow-wrap: anywhere; }
.article-title a { color: var(--ink); text-decoration: none; }
.article-title a:hover .article-title-text { color: var(--accent); text-decoration: underline; }
.article-summary { min-width: 0; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 3px; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.article-row .article-meta { align-items: baseline; gap: 3px 0; overflow-wrap: anywhere; }
.article-row .article-meta > span { max-width: 100%; }
.meta-separator { display: inline-block; padding: 0 7px; }
.article-domain { font-weight: 400; }
.save-status, .reading-status { color: var(--muted); font-size: .75rem; line-height: 1.5; overflow-wrap: anywhere; }
.save-status[data-state="saved"] { color: var(--accent); }
.save-status:is([data-state="error"], [data-state="failed"]) { color: var(--error-ink); }
.article-row.is-saving { background: var(--light); box-shadow: -10px 0 var(--light), 10px 0 var(--light); }
.row-save-button { justify-self: start; }
.row-save-button[aria-disabled="true"] { cursor: wait; opacity: .7; }
.source-badge { display: inline-block; padding: 0 5px; border-radius: 3px; background: var(--source-soft); color: var(--source-ink); font-size: .75rem; line-height: 1.65; }
.status-reading { padding: 0 5px; border-radius: 3px; background: var(--progress-soft); color: var(--progress-ink); font-size: .6875rem; line-height: 1.65; }
.status-read { color: var(--accent); }
.article-excerpt { display: none; margin: 6px 0 0; color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.show-excerpts .article-excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-note { margin: 6px 0 0; font-size: .75rem; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.article-note > span { font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; list-style: none; margin: 6px 0 0; padding: 0; }
.tags a { display: block; border: 1px solid var(--tag-line); background: var(--tag-soft); border-radius: 3px; padding: 0 5px; font-size: .75rem; line-height: 1.65; color: var(--tag-ink); text-decoration: none; overflow-wrap: anywhere; }
.tags a:hover { border-color: var(--tag-hover-line); color: var(--accent); }
.article-row .tags { gap: 4px 12px; }
.article-row .tags a { border: 0; border-radius: 0; padding: 2px 0; background: transparent; color: var(--muted); line-height: 1.5; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.article-row .tags a:hover { color: var(--accent); text-decoration-color: currentColor; }
.article-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px 12px; margin-top: 6px; }
.article-primary-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 12px; min-width: 0; }
.article-actions:has(.save-status[data-state="error"]) .article-primary-actions { display: contents; }
.article-actions .save-status[data-state="error"] { grid-column: 1 / -1; grid-row: 2; }
.row-read-link { display: inline-flex; align-items: center; gap: 8px; min-height: var(--library-control-size); padding: 6px 0; color: var(--accent); font-size: .8125rem; line-height: 1.4; font-weight: 600; text-decoration: none; }
.row-read-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.article-actions .row-menu { grid-column: 2; grid-row: 1; }
.article-actions .row-menu > summary { width: var(--library-control-size); min-height: var(--library-control-size); }

.article-list .empty-state { margin-top: 16px; }
.selection-bar { position: sticky; bottom: 16px; z-index: 4; display: flex; align-items: center; justify-content: end; gap: 16px; margin-top: 12px; padding: 9px 12px; background: var(--paper); border: 1px solid var(--selection-line); border-radius: var(--radius); font-size: .8125rem; }
.selection-bar > span { margin-right: auto; }

/* Detail pages and forms */
.narrow { max-width: 600px; margin: 32px auto; }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--muted); font-size: .875rem; }
.detail-layout { max-width: 850px; margin: 28px auto; }
.article-heading h1 { font-size: 1.875rem; line-height: 1.35; overflow-wrap: anywhere; margin-bottom: 12px; }
.detail-actions { padding: 24px 0; }
.detail-actions > a:not(.button) { font-size: .875rem; }
.detail-excerpt { color: var(--muted); line-height: 1.7; }
.personal-note { background: var(--surface); padding: 16px 20px; margin: 20px 0 28px; border-left: 3px solid var(--note-line); }
.personal-note h2 { font-size: .875rem; margin-bottom: 8px; }
.personal-note p { margin-bottom: 0; font-size: .9375rem; }
.detail-meta { margin: 24px 0; border-top: 1px solid var(--line); font-size: .875rem; }
.detail-meta > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.detail-meta .tags { margin: 0; }
.saved-copy-info { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.stack-form p { margin-bottom: 20px; }
.stack-form label { margin-bottom: 6px; }
.stack-form input, .stack-form select, .stack-form textarea { font-size: 1rem; }
.stack-form .helptext { display: block; color: var(--muted); font-size: .8125rem; margin-top: 6px; }
.login-panel { max-width: 400px; margin: 64px auto; }
.login-panel h1 { font-size: 1.5rem; margin-bottom: 24px; }
.login-panel .fine { margin: 24px 0 0; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 32px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h3 { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.source-card { margin-bottom: 16px; }
.source-card > p { font-size: .875rem; }
.source-meta { display: grid; grid-template-columns: 1fr 2fr; margin: 0 0 20px; gap: 12px; font-size: .8125rem; }
.source-meta dt { margin-bottom: 2px; }
.source-meta dd { color: var(--ink); }

/* EPUBs are documents with a title and state, not decorative covers. */
.new-collection { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 24px; background: var(--surface); }
.new-collection label { flex: 1; min-width: 220px; }
.new-collection input { background: var(--paper); }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 12px; vertical-align: top; }
thead th { color: var(--muted); font-size: .8125rem; font-weight: 500; border-top: 1px solid var(--line); background: var(--surface); }
th[scope=row] { font-weight: 550; overflow-wrap: anywhere; }
th:first-child, td:first-child { padding-left: 0; }
thead th:first-child { padding-left: 12px; }
.table-actions { text-align: right; white-space: nowrap; }
.collection-table th[scope=row] { width: 45%; }
.collection-table time { white-space: nowrap; color: var(--muted); }
.collection-table .empty-state { border: 0; border-bottom: 1px solid var(--line); }
.collection-detail { max-width: 940px; margin: 28px auto; }
.collection-detail > .page-heading { padding: 0 0 24px; }
.section-title { margin: 28px 0 12px; }
.chapter-list { list-style: none; margin: 0 0 24px; padding: 0; border-top: 1px solid var(--line); }
.chapter-list > li { display: flex; align-items: start; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.chapter-number { width: 20px; flex-shrink: 0; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8125rem; padding-top: 3px; }
.chapter-summary { min-width: 0; flex: 1; }
.chapter-summary h3 { font-size: .9375rem; margin-bottom: 5px; overflow-wrap: anywhere; }
.chapter-list p { margin: 0; }
.chapter-actions { display: flex; flex-shrink: 0; align-items: center; gap: 7px; margin-left: auto; }
.chapter-actions .text-button { margin-left: 5px; font-size: .8125rem; }
.chapter-list .empty-state { border-left: 0; border-right: 0; border-radius: 0; }

@font-face { font-family: 'ET Book'; src: url('/static/fonts/et-book/et-book-roman-line-figures.woff') format('woff'); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: 'ET Book'; src: url('/static/fonts/et-book/et-book-display-italic-old-style-figures.woff') format('woff'); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: 'ET Book'; src: url('/static/fonts/et-book/et-book-bold-line-figures.woff') format('woff'); font-style: normal; font-weight: 700; font-display: swap; }

/* Reader: readable measure, familiar elements, isolated appearance preferences. */
.reader-page { color-scheme: light; --paper: #ffffff; --surface: #f6f7f9; --ink: #20262e; --muted: #59636e; --line: #d9dee4; --accent: #24705b; --button: #24705b; --button-hover: #1c5948; --control-line: #b9c2cc; --reader-size: 21px; --reader-line-height: 1.5; --reader-font: Georgia, 'Times New Roman', serif; }
.reader-header { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 67px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--paper); font-size: .8125rem; }
.reader-header > a { white-space: nowrap; }
.reader-header-title { max-width: 42%; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-header > div { display: flex; align-items: center; gap: 16px; }
.reader-details { display: inline-flex; align-items: center; min-height: 36px; white-space: nowrap; }
#save-status { font-size: .75rem; color: var(--muted); }
.reader-shell { position: relative; }
.prose { max-width: 750px; margin: 48px auto 88px; padding: 0 30px; font-family: var(--reader-font); font-size: var(--reader-size); line-height: var(--reader-line-height); overflow-wrap: anywhere; }
.prose h1 { font: 650 1.8em/1.25 var(--reader-font); letter-spacing: -.025em; margin-bottom: 20px; }
.prose h2 { font: 600 1.35em/1.35 var(--reader-font); margin: 1.7em 0 .7em; }
.prose h3 { font: 600 1.1em/1.4 var(--reader-font); margin: 1.5em 0 .6em; }
.prose p { margin-bottom: 1.25em; }
.prose img { display: block; max-width: 100%; height: auto; margin: 24px auto; }
.prose figure { margin: 24px 0; }
.prose figcaption { text-align: center; color: var(--muted); font-size: .75em; }
.prose blockquote { margin: 1.5em 0; padding-left: 24px; border-left: 3px solid var(--line); color: var(--muted); }
.prose pre { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); white-space: pre-wrap; overflow-x: auto; font-size: .75em; }
.prose code { font-size: .85em; }
.prose table { font-size: .8em; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px; }
.prose hr { margin: 28px 0; }
.prose .reader-meta { font: .8125rem/1.6 var(--sans); color: var(--muted); margin-bottom: 16px; }
.prose .byline { font-size: .85em; color: var(--muted); }
.reader-end { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); font: .875rem/1.6 var(--sans); }
.reader-end h2 { font: 600 1.125rem/1.4 var(--sans); margin: 0 0 16px; }
.reader-end form { display: inline-block; margin: 0 16px 16px 0; }
.reader-end .fine { margin: 4px 0 0; }
.reader-settings { position: fixed; top: 78px; right: 24px; z-index: 15; width: 290px; padding: 20px; background: var(--paper); box-shadow: 0 6px 20px #00000014; }
.reader-settings h2 { margin-bottom: 20px; }
.reader-settings label { margin-top: 14px; }
.reader-settings label select, .reader-settings label input[type=range] { display: block; width: 100%; margin-top: 6px; }
.reader-settings .range-label { display: flex; justify-content: space-between; align-items: center; }
.reader-settings output { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .8125rem; font-weight: 400; }
.reader-settings .checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.reader-progress { position: fixed; bottom: 0; left: 0; right: 0; height: 4px; background: var(--line); z-index: 11; }
.reader-progress > div { height: 100%; width: 0; background: var(--accent); }
.reader-progress > span { position: absolute; right: 14px; bottom: 11px; padding: 2px 6px; color: var(--muted); background: var(--paper); font: .75rem/1.4 var(--sans); }
#page-controls { display: flex; justify-content: center; align-items: center; gap: 20px; padding: 14px; background: var(--paper); border-top: 1px solid var(--line); font-size: .8125rem; }
.reader-page[data-theme=sepia] { --paper: #f4eddf; --surface: #eee4d1; --ink: #493e2f; --muted: #6e614d; --line: #d8cbb5; --accent: #72551f; --button: #5f4d32; }
.reader-page[data-theme=night] { color-scheme: dark; --control-line: #56616c; --button-hover: #48617b; --paper: #202429; --surface: #292f35; --ink: #e0e4e8; --muted: #a5afb9; --line: #444d57; --accent: #98c3eb; --button: #3a5067; }
.reader-page[data-theme=tufte] { --paper: #fffff8; --surface: #f6f6ed; --ink: #111; --muted: #66665c; --line: #d9d9cd; --accent: #33533f; --reader-font: 'ET Book', Palatino, Georgia, serif; }
.reader-page[data-theme=tufte] .prose { max-width: 850px; }
.reader-page[data-theme=tufte] .prose h1 { font-weight: 400; letter-spacing: 0; }
.reader-page[data-theme=tufte] .article-body h2, .reader-page[data-theme=tufte] .article-body h3 { font-weight: 400; font-style: italic; }
.reader-page[data-theme=tufte] .article-body a { color: inherit; text-decoration: underline; text-underline-offset: .15em; }
.reader-page[data-mode=pages] #reader-viewport { height: calc(100dvh - 140px); overflow: hidden; padding: 30px 0; }
.reader-page[data-mode=pages] .prose { margin: 0; max-width: none; width: 100%; height: 100%; column-width: calc(100vw - 60px); column-gap: 60px; column-fill: auto; padding: 0 30px; }
.reader-page[data-mode=pages] .prose h2 { break-after: avoid; }
.reader-page[data-mode=pages] .prose img { max-height: 45dvh; object-fit: contain; }
.reader-page[data-mode=pages] .reader-end { break-before: column; }
.reader-page[data-mode=pages] #page-controls { position: fixed; bottom: 4px; left: 0; right: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -70px; padding: 10px 14px; background: var(--paper); z-index: 50; }
.skip:focus { top: 8px; }

@media (min-width: 1000px) {
  .reader-page[data-mode=pages] #reader-viewport { max-width: 850px; margin: auto; }
  .reader-page[data-mode=pages] .prose { column-width: 790px; }
}
@media (max-width: 1100px) {
  .app-page .two-columns { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 1100px) {
  .filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .app-page > .page-body { margin-left: 0; min-height: calc(100dvh - 51px); }
  .mobile-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 51px; padding: 8px 18px; border-bottom: 1px solid var(--line); background: var(--paper); }
  .mobile-header > .button { margin-left: auto; }
  .mobile-header .wordmark { font-size: 1rem; }
  .sidebar-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--muted); padding: 0; font-size: 1rem; }
  .sidebar { z-index: 40; width: 240px; max-width: calc(100vw - 48px); visibility: hidden; transform: translateX(-100%); }
  .sidebar .sidebar-close { display: inline-grid; width: 44px; height: 44px; }
  .sidebar-open { overflow: hidden; }
  .sidebar-open .sidebar { visibility: visible; transform: translateX(0); }
  .sidebar-nav a, .sidebar .sidebar-add, .account-profile, .sidebar-account .text-button { min-height: 44px; }
  .account-profile { align-content: center; }
  .mobile-header > .button { min-height: 44px; }
  .two-columns { grid-template-columns: 1fr; gap: 24px; }
  .site-footer { margin-left: 28px; margin-right: 28px; }
}
@media (max-width: 600px) {
  .container { padding: 0 18px; }
  .nav-inner { padding: 0 18px; }
  .app-page .container { padding: 0 18px; }
  .app-page .page-heading { padding: 18px 0 14px; }
  h1 { font-size: 1.5rem; }
  .app-page .page-heading h1 { font-size: 1.25rem; }
  .library-workspace { --library-control-size: 44px; }
  .filters { margin-bottom: 18px; }
  .search-row { flex-wrap: wrap; margin-right: 0; }
  .filters .search-label { flex-basis: 100%; }
  .filters .source-label { flex: 1; }
  .search-row > .button { margin-left: auto; }
  .library-workspace input.library-control, .library-workspace select.library-control { font-size: 1rem; }
  .filter-panel { margin-top: 10px; }
  .filter-panel > summary { position: static; width: 100%; }
  .filter-panel[open] { margin-top: 10px; padding-top: 0; border-top: 0; }
  .filter-fields { margin-top: 12px; }
  .library-status { gap: 16px; }
  .library-status a { gap: 5px; font-size: .8125rem; }
  .page-heading:has(h1 + .muted) { align-items: start; flex-direction: column; }
  .filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .filter-checkbox { min-height: 44px; }
  .filter-chip, .reset-filters { min-height: 44px; }
  .reset-filters { display: inline-flex; align-items: center; padding: 10px 2px; }
  .list-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .result-count { font-size: .875rem; }
  .result-label { font-size: .75rem; }
  .list-toolbar > div { gap: 12px; }
  .list-toolbar .library-tools { display: contents; }
  .sort-tools { grid-column: 2; }
  .sort-control > span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .sort-control > select { width: 138px; max-width: 100%; min-height: 44px; font-size: 1rem; }
  .library-tools .selection-toggle { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .library-tools .view-menu { grid-column: 2; grid-row: 2; justify-self: end; }
  .sort-tools #apply-sort { min-height: 44px; }
  .library-tools .selection-toggle > summary, .library-tools .view-menu > summary { min-height: 44px; }
  .article-meta { font-size: .75rem; gap: 4px 8px; }
  .selection-bar { gap: 12px; padding: 10px; flex-wrap: wrap; bottom: 10px; }
  .selection-bar .button { width: 100%; }
  .selection-bar > span, .selection-bar .text-button { font-size: .8125rem; }
  .site-footer, .app-page .site-footer { margin: 32px 18px 0; padding-bottom: 24px; }
  .messages, .app-page .messages { padding: 12px 18px 0; }
  .panel { padding: 18px; }
  .narrow, .detail-layout, .collection-detail { margin-top: 22px; }
  .back-link { margin-bottom: 18px; }
  .article-heading h1 { font-size: 1.5rem; }
  .detail-actions { gap: 10px; }
  .detail-actions .button { font-size: .8125rem; }
  .detail-meta > div { grid-template-columns: 82px minmax(0, 1fr); gap: 12px; }
  .saved-copy-info { flex-direction: column; gap: 0; }
  .login-panel { margin: 32px auto; }
  .new-collection label { min-width: 100%; }
  .new-collection > .button { flex: 1; }
  .collection-table th, .collection-table td { padding: 12px 8px; }
  .collection-table th:nth-child(4), .collection-table td:nth-child(4) { display: none; }
  .collection-table th[scope=row] { width: 42%; }
  .collection-table td, .collection-table th { font-size: .8125rem; }
  .collection-table td:last-child { white-space: normal; }
  .collection-detail > .page-heading { align-items: start; flex-wrap: wrap; }
  .chapter-list > li { gap: 12px; flex-wrap: wrap; }
  .chapter-actions { margin-left: 32px; }
  .chapter-summary { flex-basis: calc(100% - 32px); }
  .chapter-summary h3 { font-size: .9375rem; }
  .empty-state { padding: 24px 18px; }
  .reader-header { padding: 12px 16px; gap: 10px; }
  .reader-header-title { display: none; }
  .reader-header > div { gap: 10px; }
  .reader-header #save-status { font-size: .6875rem; }
  .reader-header .button span { display: none; }
  .reader-settings { top: 76px; right: 16px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 92px); overflow-y: auto; }
  .prose { margin: 32px auto 72px; padding: 0 23px; }
  .prose h1 { font-size: 1.55em; }
  .reader-page[data-mode=pages] .prose { padding: 0 23px; column-width: calc(100vw - 46px); column-gap: 46px; }
}
@media (max-width: 420px) {
  .library-status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
  .library-status a { justify-content: space-between; }
  .reader-header { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; padding: 8px 16px; }
  .reader-header > div { display: contents; }
  .reader-header #save-status { grid-column: 1 / -1; grid-row: 2; line-height: 14px; }
  .reader-page[data-mode=pages] #reader-viewport { height: calc(100dvh - 144px); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Confirmation stays compact on narrow screens. */
.confirm-dialog { max-width: min(480px, calc(100vw - 36px)); padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: 0 16px 64px #0004; }
.confirm-dialog::backdrop { background: #0007; }
.confirm-dialog p { color: var(--muted); font-size: .875rem; }
.confirm-dialog .button-row { justify-content: end; }

/* Secondary actions and reversible status notifications. */
.control-menu { position: relative; font-size: .8125rem; }
.control-menu > summary { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 4px 9px; border-radius: var(--radius); color: var(--muted); cursor: pointer; list-style: none; white-space: nowrap; }
.control-menu > summary::-webkit-details-marker { display: none; }
.control-menu > summary::after { content: '⌄'; }
.control-menu > summary:hover, .control-menu[open] > summary { background: var(--surface); color: var(--ink); }
.row-menu > summary { width: 36px; padding: 0; font-size: 1.125rem; }
.row-menu > summary::after { content: none; }
.menu-panel { position: absolute; top: calc(100% + 5px); right: 0; z-index: 12; min-width: 180px; max-width: calc(100vw - 36px); padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); box-shadow: 0 8px 24px #0002; }
.menu-action { display: block; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: var(--radius); background: transparent; color: var(--ink); text-align: left; font-size: .8125rem; }
.menu-action:hover { background: var(--surface); }
.message:has(.undo-form) { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.undo-form { flex-shrink: 0; }
.status-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 25; display: flex; align-items: center; gap: 18px; width: max-content; max-width: calc(100vw - 36px); padding: 12px 16px; border: 1px solid var(--control-line); border-radius: 6px; background: var(--paper); color: var(--ink); box-shadow: 0 8px 32px #0003; font: .875rem/1.5 var(--sans); }
.status-toast .text-button { flex-shrink: 0; }
.status-toast .icon-button { flex-shrink: 0; border: 0; }

/* List preferences live in a quiet disclosure beside the result count. */
.view-menu .menu-panel { min-width: 220px; padding: 12px; }
.menu-heading { margin: 0 0 6px; padding: 0 4px; color: var(--muted); font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.view-menu label { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 4px; color: var(--ink); font-size: .8125rem; font-weight: 400; }
.view-menu .spacing-label { display: block; margin: 8px 0; }
.view-menu select { font-size: .8125rem; }
.hide-notes .article-note, .hide-tags .article-summary > .tags { display: none; }
.comfortable .article-row { padding-top: 23px; padding-bottom: 23px; }

/* Selection is an explicit mode; ordinary browsing keeps the full row width. */
.library-tools { margin-left: auto; }
.selection-toggle > summary { display: flex; align-items: center; min-height: 36px; padding: 4px 9px; border-radius: var(--radius); color: var(--muted); cursor: pointer; font-size: .8125rem; list-style: none; }
.selection-toggle > summary::-webkit-details-marker { display: none; }
.selection-toggle > summary:hover, .selection-toggle[open] > summary { background: var(--surface); color: var(--ink); }
.selection-toggle .when-selecting, .selection-toggle[open] .when-not-selecting { display: none; }
.selection-toggle[open] .when-selecting { display: inline; }
#selection-form:not(:has(#selection-toggle[open])) .select-all,
#selection-form:not(:has(#selection-toggle[open])) .selection-fallback { display: none; }
#selection-form:has(#selection-toggle[open]) .select-article { display: grid; }
#selection-form:has(#selection-toggle[open]) .article-row { grid-template-columns: 18px minmax(0, 1fr); }
#selection-form:has(#selection-toggle[open]) .article-summary,
#selection-form:has(#selection-toggle[open]) .article-actions { grid-column: 2; }
