:root {
  color-scheme: light dark;
  --ink: #1c2731;
  --muted: #5f6f7a;
  --text-secondary: #4f5f6c;
  --text-tertiary: #5f6b76;
  --line: #e1e7eb;
  --paper: #fff;
  --canvas: #f5f7f8;
  --soft: #f8fafb;
  /* Warm My Scholar accent. Category colors stay distinct, while the
     application chrome and manual annotations use the user's amber accent. */
  --accent: #b45309;
  --accent-dark: #92400e;
  --accent-soft: #fff3d6;
  --accent-fill: #b45309;
  --accent-fill-hover: #92400e;
  --on-accent: #fff;
  --green: #299a73;
  --yellow: #f1a340;
  --blue: #2f7fc1;
  --highlight-orange: #f59e0b;
  --user-highlight: #f59e0b;
  --highlight-goal: #2f9d72;
  --highlight-method: #e39a22;
  --highlight-innovation: #8b6edb;
  --highlight-conclusion: #d15d79;
  /* Elevation follows the macOS pattern: a hairline definition ring plus a
     soft, wide ambient shadow that grows with the surface's height. */
  --shadow: 0 1px 3px rgba(28, 39, 49, .07);
  --shadow-pop: 0 0 0 .5px rgba(20, 32, 45, .08), 0 2px 10px rgba(20, 32, 45, .08), 0 12px 40px rgba(20, 32, 45, .18);
  --shadow-window: 0 0 0 .5px rgba(20, 32, 45, .10), 0 10px 30px rgba(20, 32, 45, .16), 0 28px 90px rgba(20, 32, 45, .26);
  --material-bar: color-mix(in srgb, var(--paper) 76%, transparent);
  --material-overlay: color-mix(in srgb, var(--paper) 70%, transparent);
  --material-filter: blur(28px) saturate(190%);
  /* Motion mirrors AppKit timing: menus snap open, panels glide, and page
     transitions decelerate. The spring curve overshoots by a hair, the way
     macOS popovers settle. */
  --motion-fast: 150ms;
  --motion-panel: 200ms;
  --motion-page: 260ms;
  --motion-ease-out: cubic-bezier(.22, 1, .36, 1);
  --motion-ease-spring: cubic-bezier(.3, 1.25, .4, 1);
  --motion-ease-exit: cubic-bezier(.4, 0, 1, 1);
  --reader-font: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  --app-font: var(--reader-font);
  --toolbar-font-size: 11px;
  --reader-font-scale: 1;
  --reader-line-height: 1.72;
  --reader-content-font-family: "Times New Roman", Times, "Songti SC", STSong, "Noto Serif CJK SC", serif;
  --reader-content-font-size: 17px;
  --reader-heading-font-size: 15px;
  --reader-support-font-size: 14px;
  --reader-caption-font-size: 12px;
}

.vocabulary-layout { max-width: 1120px; margin: 0 auto; padding: 30px 32px 60px; }
.vocabulary-toolbar,.vocabulary-filters,.vocabulary-card-heading,.vocabulary-card-actions,.vocabulary-edit-actions,.vocabulary-review-heading,.vocabulary-review-actions { display: flex; align-items: center; gap: 12px; }
.vocabulary-filters { flex-wrap: wrap; margin: 8px 0 22px; }
.vocabulary-filters .search-box { flex: 1; min-width: 230px; }
.vocabulary-filters select { max-width: 220px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.vocabulary-list { display: grid; gap: 16px; }
.vocabulary-card,.vocabulary-review { padding: 22px 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.vocabulary-card h2 { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.vocabulary-review-status { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.vocabulary-card-actions { margin-left: auto; flex-shrink: 0; gap: 5px; }
.vocabulary-meaning,.vocabulary-note,.vocabulary-review-meaning { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; -webkit-user-select: text; user-select: text; }
.vocabulary-note,.vocabulary-field-hint { color: var(--muted); font-size: 13px; }
.vocabulary-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.vocabulary-tags button { padding: 3px 9px; background: var(--accent-soft); color: var(--accent-dark); border: 0; border-radius: 12px; font-size: 12px; }
.vocabulary-sources { margin-top: 15px; display: grid; gap: 10px; }
.vocabulary-source { border-left: 2px solid var(--line); padding-left: 12px; }
.vocabulary-source blockquote,.vocabulary-review blockquote { margin: 0 0 5px; color: var(--text-secondary); line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; user-select: text; }
.vocabulary-edit { display: grid; gap: 12px; margin-top: 16px; }
.vocabulary-edit label { display: grid; gap: 6px; font-size: 13px; }
.vocabulary-edit input,.vocabulary-edit textarea { box-sizing: border-box; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); color: var(--ink); font: inherit; }
.vocabulary-edit textarea { resize: vertical; }
.vocabulary-review { max-width: 740px; margin: 25px auto; padding: 30px; }
.vocabulary-review h2 { font-size: 32px; margin: 35px 0 20px; overflow-wrap: anywhere; }
.vocabulary-review-heading { justify-content: space-between; color: var(--muted); }
.vocabulary-review blockquote { margin-bottom: 25px; }
.vocabulary-review-actions { margin-top: 24px; }
.vocabulary-review-meaning { margin-top: 20px; }
.vocabulary-details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.vocabulary-details > summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.vocabulary-details-badge { margin-left: 8px; color: var(--muted); font-size: 11px; font-weight: 400; }
.vocabulary-details dl { display: grid; gap: 14px; margin: 16px 0 0; }
.vocabulary-detail-field dt { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.vocabulary-detail-field dd { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; user-select: text; }
.vocabulary-details-editor { display: grid; gap: 12px; margin-top: 14px; }
.vocabulary-explain { margin-top: 8px; }
#vocabulary-status.error { color: #c24136; }
#selection-add-vocabulary:disabled { color: var(--muted); cursor: default; }
@media (max-width: 700px) {
  .vocabulary-layout { padding: 20px 16px 50px; }
  .vocabulary-card { padding: 17px; }
  .vocabulary-card-heading { flex-wrap: wrap; gap: 8px; }
  .vocabulary-card h2 { font-size: 19px; }
  .vocabulary-toolbar { flex-wrap: wrap; }
  .vocabulary-review { padding: 20px; }
}
* { box-sizing: border-box; }
/* Application chrome is an interaction surface, not document content. Keep
   selection available only for fields and the user's own rendered notes. */
*, *::before, *::after { -webkit-user-select: none; user-select: none; }
input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--app-font); line-height: 1.55; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:not(:disabled):active { transform: translateY(.5px) scale(.99); filter: brightness(.97); }
button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }

/* Overlay-style scrollbars, matching macOS "show when scrolling" bars. */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 99px; background-clip: padding-box; background-color: color-mix(in srgb, var(--ink) 22%, transparent); }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--ink) 36%, transparent); }

.app-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 25px; height: 60px; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--material-bar); backdrop-filter: var(--material-filter); }
.desktop-macos .app-header { padding-left: 96px; -webkit-app-region: drag; }
.desktop-macos .app-header button, .desktop-macos .app-header input, .desktop-macos .app-header a, .desktop-macos .app-header [role="button"] { -webkit-app-region: no-drag; }
.brand-mark { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 680; letter-spacing: .01em; white-space: nowrap; }
.brand-glyph-frame { display: block; width: 26px; height: 26px; flex: 0 0 26px; }
.brand-glyph { display: block; width: 100%; height: 100%; object-fit: contain; }
.top-nav { display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.nav-button { display: inline-flex; height: 37px; align-self: flex-end; align-items: center; justify-content: center; padding: 0 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease; }
.nav-button:hover, .nav-button.active { color: var(--ink); border-bottom-color: var(--accent); }
.nav-count { display: inline-flex; min-width: 17px; height: 17px; align-items: center; justify-content: center; margin-left: 4px; padding: 0 5px; border-radius: 5px; background: var(--soft); color: var(--text-secondary); font-size: 11px; }
.header-spacer { min-width: 0; flex: 1 1 auto; }
.app-header.has-document-tabs .header-spacer { flex: 0 0 0; width: 0; }
.app-shell { position: relative; max-width: 1760px; min-height: calc(100vh - 106px); margin: 0 auto; padding: 24px 22px 65px; }
.view { display: none; }
.view.active-view { display: block; }
#reader-view.active-view { animation: none; }
body.reader-mode { height: 100vh; overflow: hidden; background: var(--paper); }
body.reader-mode .app-header { position: relative; }
body.reader-mode .app-shell { width: 100%; max-width: none; height: calc(100vh - 60px); min-height: 0; margin: 0; padding: 0; }
#reader-view.active-view { width: 100%; height: 100%; min-height: 0; flex-direction: column; overflow: hidden; }
body.reader-mode #reader-view.active-view { display: flex; }
#reader-view.is-reader-parked { position: fixed; top: 60px; left: 0; display: flex; flex-direction: column; width: var(--parked-reader-width); height: var(--parked-reader-height); overflow: hidden; visibility: hidden; opacity: 0; pointer-events: none; }
.eyebrow { display: none; }
h1 { margin: 9px 0 14px; font-size: clamp(30px, 4.6vw, 54px); line-height: 1.06; letter-spacing: -.045em; }
h1 em { color: var(--accent); font-style: normal; }
h2 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.02em; }

.primary-button, .secondary-button, .tiny-button, .action-button, .toolbar-icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 7px; text-decoration: none; transition: all var(--motion-fast) var(--motion-ease-out); }
/* Push buttons carry the AppKit bezel: a faint top sheen and 1px drop. */
.primary-button { margin-top: 16px; padding: 10px 16px; border: 1px solid var(--accent-fill); background: var(--accent-fill) linear-gradient(rgba(255,255,255,.16), rgba(255,255,255,0) 60%); color: var(--on-accent); font-weight: 650; box-shadow: 0 1px 2px color-mix(in srgb, var(--accent-fill) 34%, transparent); }
.primary-button:hover { border-color: var(--accent-fill-hover); background-color: var(--accent-fill-hover); }
.primary-button:disabled, .secondary-button:disabled, .action-button:disabled, .tiny-button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.secondary-button { padding: 8px 12px; border: 1px solid var(--line); background: #fff; color: #3e5364; font-size: 12px; font-weight: 600; box-shadow: 0 1px 2px rgba(28,39,49,.06); }
.secondary-button:hover, .tiny-button:hover { border-color: color-mix(in srgb,var(--accent) 44%,var(--line)); background: var(--accent-soft); color: var(--accent-dark); }
.tiny-button { padding: 5px 8px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 11px; }
.toolbar-icon-button { width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.toolbar-icon-button:hover { background: var(--accent-soft); color: var(--accent-dark); }
.inline-error { margin-top: 12px; color: #bd3b47; font-size: 12px; }
.progress-card { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.progress-head { display: flex; justify-content: space-between; color: #4b5e6c; font-size: 12px; font-weight: 650; }
.progress-track { height: 7px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: #e7edf1; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--accent-fill); transition: width var(--motion-page) var(--motion-ease-out); }
.progress-detail { margin-top: 7px; color: var(--muted); font-size: 11px; }
.search-box { display: flex; width: 220px; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); font-size: 12px; }
.empty-state { grid-column: 1 / -1; padding: 40px 18px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); text-align: center; }

.header-document-tabs { display: flex; min-width: 0; max-width: none; flex: 1 1 0; height: 100%; align-items: flex-end; gap: 4px; margin-left: 8px; }
.desktop-macos .header-document-tabs { -webkit-app-region: drag; }
.desktop-macos .header-document-tabs .document-tab, .desktop-macos .header-document-tabs .document-tab button { -webkit-app-region: no-drag; }
.header-document-tabs[hidden] { display: none; }
.header-document-tabs .document-tab { min-width: 170px; max-width: 280px; height: 37px; align-self: flex-end; font-size: 14px; line-height: 1; }
.document-tabs { display: flex; min-width: 0; flex: 1; align-items: center; gap: 5px; overflow-x: auto; scrollbar-width: thin; }
.document-tab { display: inline-flex; min-width: 220px; max-width: 320px; height: 36px; align-self: flex-end; align-items: center; gap: 6px; padding: 0 10px 0 14px; border: 1px solid transparent; border-radius: 7px 7px 0 0; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.document-tab:hover { background: #fff; color: var(--ink); }
.document-tab.active { border-color: #e3e4e8; border-bottom-color: #fff; background: #fff; color: var(--ink); font-weight: 650; box-shadow: none; }
.document-tab-label { overflow: hidden; text-overflow: ellipsis; }
.document-tab-close { padding: 0; border: 0; background: transparent; color: #9ca7af; font-size: 13px; line-height: 1; }
.document-tab-close:hover { color: #bd3b47; }
.document-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--paper); color: var(--ink); }
.reader-action-bar { display: grid; min-height: 42px; flex: 0 0 42px; grid-template-columns: clamp(380px,28vw,430px) minmax(0,1fr); align-items: stretch; gap: 0; padding: 0; border-bottom: 1px solid var(--line); background: var(--material-bar); backdrop-filter: var(--material-filter); }
.reader-heading { display: flex; min-width: 0; align-items: center; padding: 0 14px; border-right: 1px solid #e3e6e9; }
.reader-title { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.reader-meta { display: none; color: var(--muted); font-size: 10px; }
.reader-actions { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 3px; overflow-x: auto; padding: 0 12px; scrollbar-width: none; }
.reader-actions::-webkit-scrollbar { display: none; }
.action-button { padding: 6px 8px; border: 1px solid transparent; background: transparent; color: #333b43; font-size: var(--toolbar-font-size); font-weight: 590; white-space: nowrap; }
.action-button:hover, .action-button.active { border-color: #d5daf8; background: var(--accent-soft); color: var(--accent-dark); }
.action-icon { display: inline-flex; min-width: 18px; justify-content: center; color: var(--accent); font-size: 12px; font-weight: 760; }
/* A split action: the main button runs with the remembered scope, the caret
   opens the scope menu. */
.action-split { display: inline-flex; align-items: stretch; }
.action-split .action-button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.action-split-caret { margin-left: -1px; padding-inline: 5px; border-top-left-radius: 0; border-bottom-left-radius: 0; font-size: 11px; line-height: 1; }
.action-split-caret[aria-expanded="true"] { border-color: color-mix(in srgb,var(--accent) 36%,var(--line)); background: var(--accent-soft); color: var(--accent-dark); }
.typography-control { position: relative; display: inline-flex; }
.typography-popover { position: absolute; z-index: 80; top: calc(100% + 8px); right: 0; display: grid; min-width: 220px; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--material-overlay); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop); color: var(--ink); transform-origin: top right; animation: menu-pop var(--motion-fast) var(--motion-ease-spring); }
.reader-overlay-layer { position: fixed; z-index: 119; inset: 0; overflow: visible; pointer-events: none; }
.reader-overlay-layer .typography-popover { pointer-events: auto; }
.global-menu-layer { position: fixed; z-index: 130; inset: 0; overflow: visible; pointer-events: none; }
.global-menu-layer > [role="menu"],.global-menu-layer > [role="listbox"] { pointer-events: auto; }
.global-menu-layer > [hidden] { display: none; }
.typography-popover.is-closing,.selection-popover.is-closing,.image-context-menu.is-closing { opacity: 0; transform: scale(.985) translateY(-2px); pointer-events: none; animation: none; transition: opacity var(--motion-fast) ease-in,transform var(--motion-fast) ease-in; }
.typography-popover label { display: grid; grid-template-columns: 42px minmax(96px,1fr) 64px; align-items: center; gap: 7px; font-size: 11px; }
.typography-popover input[type="range"] { width: 100%; accent-color: var(--accent-fill); }
.typography-number-control { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 2px; color: var(--muted); font-size: 10px; }
.typography-number-control input { width: 48px; min-width: 0; padding: 4px 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; text-align: right; }
.typography-number-control input:focus-visible { border-color: var(--accent); outline: 2px solid color-mix(in srgb,var(--accent) 24%,transparent); outline-offset: 1px; }
.translation-progress { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--material-overlay); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop); color: var(--text-secondary); font-size: 11px; animation: rise-in var(--motion-panel) var(--motion-ease-out); }
.translation-progress-dots { display: inline-flex; flex: 0 0 auto; gap: 4px; }
.translation-progress-dots span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: chat-thinking-bounce 1.2s ease-in-out infinite; }
.translation-progress-dots span:nth-child(2) { animation-delay: .15s; }
.translation-progress-dots span:nth-child(3) { animation-delay: .3s; }
.translation-progress:is([data-state="complete"],[data-state="completed"],[data-state="failed"],[data-state="cancelled"]) .translation-progress-dots { display: none; }
.translation-progress-main { display: grid; flex: 1; min-width: 0; gap: 4px; }
/* The head is a grid item, and a grid item will not shrink below its own
   content without this -- so a long status line pushed the label and the
   percentage out of the panel instead of the text truncating inside it. */
.translation-progress-head { display: flex; min-width: 0; align-items: baseline; gap: 8px; }
.translation-progress-head #translation-progress-label { flex: 0 0 auto; font-weight: 640; }
.translation-progress-head #reflow-progress-label { flex: 0 0 auto; font-weight: 640; }
.translation-progress-count { overflow: hidden; color: color-mix(in srgb, currentColor 72%, transparent); white-space: nowrap; text-overflow: ellipsis; }
.translation-progress-head #translation-progress-value { margin-left: auto; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.translation-progress-head #reflow-progress-value { margin-left: auto; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.translation-progress-track { position: relative; height: 6px; overflow: hidden; border-radius: 99px; background: var(--soft); }
.translation-progress-bar { position: relative; width: 0; height: 100%; overflow: hidden; border-radius: inherit; background: var(--accent-fill); transition: width var(--motion-page) var(--motion-ease-out); }
.translation-progress-bar::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%); transform: translateX(-100%); animation: translation-shimmer 1.4s ease-in-out infinite; }
.translation-progress[data-state="running"] .translation-progress-track::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, transparent, color-mix(in srgb, currentColor 20%, transparent), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: translation-scan 1.8s linear infinite; }
.translation-progress:is([data-state="complete"],[data-state="completed"],[data-state="failed"],[data-state="cancelled"]) .translation-progress-bar::after { animation: none; content: none; }
.translation-progress-detail { overflow: hidden; color: color-mix(in srgb, currentColor 62%, transparent); font-size: 10.5px; white-space: nowrap; text-overflow: ellipsis; }
@keyframes translation-shimmer { to { transform: translateX(100%); } }
@keyframes translation-scan { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.translation-progress .tiny-button { margin-left: 3px; }
.reflow-progress[data-state="failed"] { border-color: color-mix(in srgb,#bd3b47 55%,var(--line)); color: #bd3b47; }
/* A failure is the one status worth reading in full, so it wraps rather than
   truncating to a fragment nobody can act on. */
.translation-progress[data-state="failed"] .translation-progress-head { align-items: flex-start; }
.translation-progress[data-state="failed"] .translation-progress-count { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
.reflow-progress[data-state="cancelled"] { color: var(--muted); }
.toast { position: fixed; z-index: 100; right: 26px; bottom: calc(25px + var(--background-tasks-offset, 0px)); max-width: 360px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--material-overlay); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop); color: var(--ink); font-size: 12px; animation: rise-in var(--motion-panel) var(--motion-ease-out); transition: opacity var(--motion-fast) ease, transform var(--motion-fast) ease, bottom var(--motion-fast) var(--motion-ease-out); }
.toast.is-closing { opacity: 0; transform: translateY(6px); pointer-events: none; }
.toast.error { border-color: #f0c4c7; color: #a5424c; }
/* The shared progress strip keeps background work reachable across views. */
.background-tasks { position: fixed; right: 26px; bottom: 25px; z-index: 90; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: min(400px, calc(100vw - 48px)); }
.background-tasks:not(:has(.translation-progress:not([hidden]))) { display: none; }
.background-tasks-cards { display: flex; flex-direction: column; gap: 8px; }
.background-tasks-list { display: contents; }
.background-tasks-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; align-self: flex-end; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--material-overlay); backdrop-filter: var(--material-filter); box-shadow: var(--shadow); color: var(--text-secondary); font-size: 11px; font-weight: 640; cursor: pointer; }
.background-tasks-toggle:hover, .background-tasks-toggle:focus-visible { outline: 0; border-color: color-mix(in srgb,var(--accent) 46%,var(--line)); color: var(--accent-dark); }
.background-tasks-chevron { transition: transform var(--motion-fast) var(--motion-ease-out); }
.background-tasks.is-collapsed .background-tasks-cards { display: none; }
.background-tasks.is-collapsed .background-tasks-chevron { transform: rotate(180deg); }
.background-task-kind { flex: 0 0 auto; font-weight: 640; }
.background-task-value { margin-left: auto; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.background-task-actions { display: inline-flex; flex: 0 0 auto; gap: 4px; }
.translation-progress[data-state="queued"] .translation-progress-dots span { animation-play-state: paused; opacity: .35; }
.document-tab.is-busy .document-tab-label::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; animation: settings-save-pulse .9s ease-in-out infinite alternate; }

.drop-overlay { position: fixed; z-index: 90; inset: 0; display: grid; place-content: center; gap: 8px; border: 4px solid color-mix(in srgb,var(--accent) 70%,transparent); background: color-mix(in srgb,var(--accent-soft) 78%,transparent); color: var(--accent-dark); text-align: center; pointer-events: none; backdrop-filter: blur(4px); }
.drop-overlay strong { font-size: 24px; }.drop-overlay span { font-size: 13px; color: var(--muted); }
.import-queue-card { margin-top: 10px; }.import-queue-list { display: grid; gap: 4px; margin-top: 10px; max-height: 150px; overflow: auto; }.import-queue-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 7px; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: 10px; }.import-queue-item strong { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }.import-queue-item.failed { color: #b54d58; }.import-queue-item.done { color: var(--green); }

.library-dialog,.metadata-dialog { width: min(560px,calc(100vw - 28px)); max-width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-window); }.metadata-dialog { width: min(760px,calc(100vw - 28px)); }.library-dialog::backdrop,.metadata-dialog::backdrop { background: rgba(19,28,38,.3); backdrop-filter: blur(10px); }.library-dialog form,.metadata-dialog form { padding: 20px; }.library-dialog form { display: flex; max-height: calc(100vh - 30px); flex-direction: column; overflow: hidden; }.library-dialog .dialog-content { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding-right: 4px; }.library-dialog .dialog-actions { flex: 0 0 auto; }.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }.dialog-heading h2 { margin-top: 5px; }.dialog-close { width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }.dialog-close:hover { background: var(--accent-soft); color: var(--accent-dark); }.dialog-content,.metadata-content { display: grid; gap: 12px; margin-top: 18px; }.dialog-content label,.metadata-field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }.dialog-content input,.dialog-content textarea,.dialog-content select,.metadata-field input,.metadata-field textarea { width: 100%; min-height: 34px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: var(--paper); color: var(--ink); font-size: 12px; }.dialog-content textarea,.metadata-field textarea { min-height: 90px; resize: vertical; }.dialog-content input:focus,.dialog-content textarea:focus,.dialog-content select:focus,.metadata-field input:focus,.metadata-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }.dialog-actions .primary-button { margin-top: 0; }.tag-option-list,.folder-option-list { display: flex; flex-wrap: wrap; gap: 6px; }.tag-option,.folder-option { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); color: var(--muted); font-size: 11px; cursor: pointer; }.tag-option.active,.folder-option.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }.rating-picker { display: flex; gap: 4px; }.rating-picker button { padding: 2px; border: 0; background: transparent; color: #b77914; font-size: 17px; }.metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }.metadata-field.full { grid-column: 1 / -1; }.metadata-field small { color: #9aa6af; font-size: 10px; }.metadata-candidate-list { display: grid; gap: 6px; }.metadata-candidate { padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); font-size: 11px; }.metadata-candidate button { margin-top: 5px; }
.confirm-dialog { width: min(460px, calc(100vw - 28px)); }
.library-dialog .dialog-content { overscroll-behavior: contain; }
#library-editor-dialog:has(.columns-editor) { width: min(1280px,calc(100vw - 48px)); height: min(820px,calc(100vh - 48px)); }
#library-editor-dialog:has(.columns-editor) form { height: 100%; padding: 24px 28px 20px; }
#library-editor-dialog:has(.columns-editor) .dialog-heading { flex: 0 0 auto; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
#library-editor-dialog:has(.columns-editor) .dialog-content { margin-top: 0; padding: 20px 2px 2px 0; }
#library-editor-dialog:has(.columns-editor) .dialog-actions { margin-top: 16px; }
html:has(dialog[open]),body:has(dialog[open]) { overflow: hidden; overscroll-behavior: none; }
.confirm-message { margin: 18px 0 0; color: var(--ink); font-size: 14px; line-height: 1.65; white-space: pre-wrap; }

.reader-grid { position: relative; display: grid; min-width: 0; min-height: 0; flex: 1; grid-template-columns: 0 minmax(0,1fr); margin: 0; overflow: hidden; transition: grid-template-columns var(--motion-panel) var(--motion-ease-out); }
.reader-grid:has(.reader-sidebar.is-open) { grid-template-columns: clamp(380px,28vw,430px) minmax(0,1fr); }
.reader-sidebar { position: relative; z-index: 5; display: flex; width: 100%; height: 100%; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; border: 0; border-right: 1px solid #e1e4e8; border-radius: 0; background: #fff; box-shadow: none; opacity: 0; pointer-events: none; transform: translateX(-18px); visibility: hidden; transition: transform var(--motion-panel) var(--motion-ease-out),opacity var(--motion-fast) var(--motion-ease-out),visibility var(--motion-panel); }
.reader-sidebar.is-open { opacity: 1; pointer-events: auto; transform: translateX(0); visibility: visible; }
.reader-sidebar-resizer { position: absolute; z-index: 12; top: 0; bottom: 0; left: 0; width: 10px; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; cursor: col-resize; touch-action: none; }
.reader-sidebar-resizer::before { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: var(--line); content: ""; transition: width var(--motion-fast) ease,background var(--motion-fast) ease,box-shadow var(--motion-fast) ease; }
.reader-sidebar-resizer:hover::before,.reader-sidebar-resizer:focus-visible::before,.reader-sidebar-resizer:active::before { width: 3px; background: var(--accent); box-shadow: 2px 0 8px color-mix(in srgb,var(--accent) 28%,transparent); }
body.resizing-reader-assistant { cursor: col-resize; }
body.resizing-reader-assistant * { cursor: col-resize !important; }
#reader-view.is-resizing-assistant .reader-action-bar,#reader-view.is-resizing-assistant .reader-grid,#reader-view.is-resizing-assistant .reader-sidebar { transition: none !important; }
#reader-view.is-resizing-assistant #html-preview { pointer-events: none; }
.assistant-toggle { width: auto; height: 30px; justify-content: flex-start; gap: 7px; padding: 4px 2px; border: 0; border-radius: 6px; color: #303940; font-size: var(--toolbar-font-size); font-weight: 680; line-height: 1.2; }
.assistant-toggle:hover, .assistant-toggle.active { border-color: transparent; background: transparent; color: var(--accent-dark); }
.assistant-toggle-icon { width: 19px; height: 19px; flex: 0 0 19px; }
.assistant-toggle-label { font-size: inherit; }
.sidebar-caption { display: none; }
.sidebar-caption-mark { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent-dark); font-size: 9px; font-weight: 800; }
.sidebar-tabs { display: flex; min-height: 44px; flex: 0 0 44px; flex-wrap: nowrap; gap: 0; overflow-x: auto; padding: 0 9px; border-bottom: 1px solid #e4e7ea; scrollbar-width: none; }
.sidebar-tabs::-webkit-scrollbar { display: none; }
.sidebar-tab { position: relative; min-width: max-content; flex: 0 0 auto; padding: 0 7px; border: 0; border-radius: 0; background: transparent; color: #67727b; font-size: 11px; white-space: nowrap; }
.sidebar-tab::after { position: absolute; right: 5px; bottom: 0; left: 5px; height: 2px; border-radius: 2px 2px 0 0; background: transparent; content: ""; }
.sidebar-tab:hover,.sidebar-tab.active { background: transparent; color: #242b31; font-weight: 680; }
.sidebar-tab.active::after { background: #242b31; }
.sidebar-panel { min-height: 0; flex: 1; flex-direction: column; overflow: hidden; padding: 16px 14px 14px; }
.sidebar-panel.active-panel { display: flex; }
.sidebar-panel.is-closing { position: absolute; z-index: 1; inset: 44px 0 0; display: flex; width: 100%; background: inherit; opacity: 0; transform: translateX(-4px); pointer-events: none; transition: opacity var(--motion-fast) ease-in,transform var(--motion-fast) ease-in; }
.sidebar-panel.active-panel { position: relative; z-index: 2; }
.panel-intro { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.panel-intro strong { font-size: 13px; }
.panel-intro span { color: var(--muted); font-size: 11px; }
.annotations-panel-header { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 12px; }
.annotations-panel-heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.danger-button { color: #a74416; }
.danger-button:not(:disabled):hover { border-color: #e3a274; background: #fff2e8; color: #85310e; }
.selected-context { position: relative; display: grid; max-height: 120px; overflow: auto; gap: 3px; margin-bottom: 8px; padding: 8px 30px 8px 10px; border-left: 3px solid var(--accent); background: color-mix(in srgb,var(--accent-soft) 74%,var(--paper)); color: var(--text-secondary); font-size: 11px; }
.selected-context-label { color: var(--accent-dark); font-size: 10px; font-weight: 720; }.selected-context-quote { line-height: 1.5; }.selected-context-clear { position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.selected-context-image { display: block; width: 100%; max-height: 116px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.selected-context:has(.selected-context-image) { max-height: 260px; }
.chat-messages { min-height: 0; flex: 1; overflow: auto; padding: 2px 1px 10px; }.chat-empty { padding: 20px 8px; color: #9aa6af; font-size: 12px; line-height: 1.6; }.chat-bubble { max-width: 92%; margin: 7px 0; padding: 9px 10px; border-radius: 10px; font-size: 13px; white-space: pre-wrap; }.chat-bubble.user { margin-left: auto; background: var(--accent-soft); color: var(--accent-dark); }.chat-bubble.assistant { background: #f5f7f8; color: #384a58; }.chat-bubble small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; }.chat-form { margin-top: auto; padding-top: 9px; border-top: 1px solid var(--line); }.chat-form textarea { display: block; width: 100%; resize: vertical; padding: 8px; border: 1px solid var(--line); border-radius: 8px; outline: 0; font-size: 13px; }.chat-form textarea:focus, .notes-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 16%,transparent); }.chat-form .primary-button { width: 100%; margin-top: 7px; padding: 8px 12px; font-size: 12px; }.chat-form .primary-button span { opacity: .75; font-size: 10px; }.panel-status { margin-top: 8px; color: var(--muted); font-size: 11px; }.panel-status.error { color: #bd3b47; }
.chat-subview { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.chat-subview[hidden] { display: none; }
.chat-session-toolbar { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 8px; margin: -4px 0 10px; }
.chat-session-switcher { display: inline-flex; min-width: 0; flex: 1; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--text-secondary); text-align: left; }
.chat-session-switcher:hover,.chat-session-switcher:focus-visible,.chat-session-switcher[aria-expanded="true"] { border-color: color-mix(in srgb,var(--accent) 46%,var(--line)); outline: none; background: var(--accent-soft); color: var(--accent-dark); }
#chat-current-session-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-chevron { flex: 0 0 auto; color: var(--text-tertiary); }
.chat-history-list { min-height: 0; flex: 1; overflow: auto; }
.chat-history-item { display: grid; width: 100%; gap: 3px; margin-bottom: 5px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); text-align: left; cursor: pointer; }
.chat-history-item:hover,.chat-history-item:focus-visible,.chat-history-item[aria-current="true"] { border-color: color-mix(in srgb,var(--accent) 46%,var(--line)); background: color-mix(in srgb,var(--accent-soft) 50%,var(--paper)); outline: none; }
.chat-history-item-title { overflow: hidden; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.chat-history-item-pin { display: inline-flex; margin-right: 6px; padding: 1px 5px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-size: 9px; font-weight: 700; vertical-align: .08em; }
.chat-history-item-meta { color: var(--muted); font-size: 10px; line-height: 1.35; }
.chat-session-menu { position: fixed; z-index: 1; display: grid; min-width: 148px; max-height: calc(100vh - 16px); gap: 2px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--material-overlay); box-shadow: var(--shadow-pop); backdrop-filter: var(--material-filter); transform-origin: top left; animation: menu-pop var(--motion-fast) var(--motion-ease-spring); }
.chat-session-menu[data-placement="top"] { transform-origin: bottom left; }
.translation-scope-menu { min-width: 220px; }
.translation-menu-heading { padding: 6px 10px 3px; color: var(--text-tertiary); font-size: 10.5px; }
.translation-menu-divider { height: 1px; margin: 5px 4px; background: var(--line); }
.translation-scope-menu button { display: grid; gap: 2px; }
.translation-scope-menu button small { color: var(--text-tertiary); font-size: 10.5px; line-height: 1.35; }
.translation-scope-menu button[aria-checked="true"] { color: var(--accent-dark); }
.translation-scope-menu button[aria-checked="true"] span::before { content: "✓ "; }
.chat-session-menu button { width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); text-align: left; }
.chat-session-menu button:not(:disabled):hover,.chat-session-menu button:not(:disabled):focus-visible { outline: none; background: var(--accent-soft); color: var(--accent-dark); }
.chat-session-menu button:disabled { opacity: .45; cursor: not-allowed; }
.chat-session-menu button.is-danger:not(:disabled):hover,.chat-session-menu button.is-danger:not(:disabled):focus-visible { background: #fff1e5; color: #a34b15; }
.chat-session-rename-dialog { width: min(360px,calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-window); }
.chat-session-rename-dialog::backdrop { background: rgba(19,28,38,.3); backdrop-filter: blur(8px); }
.chat-session-rename-dialog form { display: grid; gap: 12px; padding: 18px; }
.chat-session-rename-dialog label { font-size: 13px; font-weight: 680; }
.chat-session-rename-dialog input { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--paper); color: var(--ink); }
.chat-session-rename-dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 16%,transparent); }
.chat-session-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.chat-bubble { position: relative; }
.chat-bubble, .chat-bubble * { -webkit-user-select: text; user-select: text; }
.chat-bubble small, .chat-copy, .chat-block-reference { -webkit-user-select: none; user-select: none; }
.chat-copy { position: absolute; top: 6px; right: 6px; padding: 2px 8px; border: 0; border-radius: 5px; background: color-mix(in srgb, currentColor 10%, transparent); color: inherit; font-family: var(--app-font); font-size: 10px; line-height: 1.4; opacity: 0; transition: opacity var(--motion-fast) var(--motion-ease-out); }
.chat-bubble:hover .chat-copy, .chat-copy:focus-visible { opacity: 1; }
.chat-block-reference { display: inline; margin: 0 .08em; padding: 0 .18em; border: 0; border-radius: 4px; background: color-mix(in srgb,var(--accent) 10%,transparent); color: var(--accent-dark); font: inherit; line-height: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb,currentColor 42%,transparent); text-underline-offset: .16em; }
.chat-block-reference:hover,.chat-block-reference:focus-visible { background: color-mix(in srgb,var(--accent) 18%,transparent); text-decoration-color: currentColor; }
.chat-thinking { display: flex; align-items: center; gap: 4px; padding: 3px 0 1px; }
.chat-thinking-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: chat-thinking-bounce 1.2s ease-in-out infinite; }
.chat-thinking-dot:nth-child(2) { animation-delay: .15s; }
.chat-thinking-dot:nth-child(3) { animation-delay: .3s; }
.chat-thinking-label { margin-left: 5px; color: var(--muted); font-family: var(--app-font); font-size: 11px; }
@keyframes chat-thinking-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-quote { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; margin-bottom: .45em; padding: .32em .55em; border-left: 3px solid var(--accent); border-radius: .3em; background: color-mix(in srgb, currentColor 8%, transparent); font-size: 11.5px; line-height: 1.45; opacity: .85; white-space: normal; }
.chat-math-block { margin: .5em 0; padding: .4em .6em; border-radius: .4em; background: color-mix(in srgb, currentColor 6%, transparent); text-align: center; overflow-x: auto; white-space: normal; }
.chat-math-block code { padding: 0; background: transparent; }
.chat-math-block math { font-size: 1.1em; }
.chat-bubble .chat-markdown { white-space: normal; }
.chat-markdown > :first-child { margin-top: 0; }
.chat-markdown > :last-child { margin-bottom: 0; }
.chat-markdown p, .chat-markdown ul, .chat-markdown ol, .chat-markdown pre, .chat-markdown table, .chat-markdown blockquote { margin: .5em 0; }
.chat-markdown h1, .chat-markdown h2, .chat-markdown h3, .chat-markdown h4, .chat-markdown h5, .chat-markdown h6 { margin: .7em 0 .3em; font-size: 1em; font-weight: 650; line-height: 1.4; }
.chat-markdown h1 { font-size: 1.12em; }
.chat-markdown h2 { font-size: 1.06em; }
.chat-markdown ul, .chat-markdown ol { padding-left: 1.35em; }
.chat-markdown li { margin: .18em 0; }
.chat-markdown code { padding: .08em .32em; border-radius: .3em; background: color-mix(in srgb, currentColor 9%, transparent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.chat-markdown pre { overflow-x: auto; padding: .6em .7em; border-radius: .5em; background: color-mix(in srgb, currentColor 8%, transparent); }
.chat-markdown pre code { padding: 0; background: transparent; white-space: pre; }
.chat-markdown blockquote { padding: .1em .8em; border-left: 3px solid var(--line); color: var(--muted); }
.chat-markdown table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.chat-markdown th, .chat-markdown td { padding: .3em .55em; border: 1px solid var(--line); }
.chat-markdown a { color: var(--accent-dark); }
.chat-markdown hr { margin: .6em 0; border: 0; border-top: 1px solid var(--line); }
.chat-bubble.is-streaming .chat-markdown::after { content: "▍"; margin-left: .08em; color: var(--muted); animation: selection-stream-blink 1s steps(2, start) infinite; }
.outline-list { min-height: 0; overflow: auto; }.outline-item { display: flex; width: 100%; align-items: baseline; gap: 7px; padding: 7px 6px 7px calc(6px + var(--outline-indent, 0px)); border: 0; border-radius: 7px; background: transparent; color: #536575; text-align: left; font-size: 11px; }.outline-item:hover { background: var(--accent-soft); color: var(--accent-dark); }.outline-item small { min-width: 25px; color: #9ca8b1; font-size: 10px; }.outline-item[data-outline-level="1"] { font-weight: 700; }.outline-item[data-outline-level="2"] { font-weight: 650; }
.highlight-filters { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }.highlight-filter { padding: 4px 8px; border: 1px solid var(--line); border-radius: 99px; background: var(--paper); color: var(--muted); font-size: 10px; }.highlight-filter:hover,.highlight-filter.active { border-color: #f2b65d; background: #fff4df; color: #9a6208; }.highlight-filter[data-highlight-filter="research_goal"].active { border-color: var(--highlight-goal); background: rgba(47,157,114,.12); color: #237653; }.highlight-filter[data-highlight-filter="method"].active { border-color: var(--highlight-method); background: rgba(227,154,34,.14); color: #9a6208; }.highlight-filter[data-highlight-filter="innovation"].active { border-color: var(--highlight-innovation); background: rgba(139,110,219,.13); color: #6950ae; }.highlight-filter[data-highlight-filter="conclusion"].active { border-color: var(--highlight-conclusion); background: rgba(209,93,121,.13); color: #a44661; }.highlights-list { min-height: 0; overflow: auto; padding-right: 2px; }.highlight-group { --group-color: var(--highlight-method); --group-border: rgba(227,154,34,.42); --group-tint: rgba(227,154,34,.08); --group-label-bg: rgba(227,154,34,.18); --group-label-ink: #9a6208; margin-bottom: 12px; padding: 9px; border: 1px solid var(--group-border); border-radius: 10px; background: var(--group-tint); }.highlight-group-research_goal { --group-color: var(--highlight-goal); --group-border: rgba(47,157,114,.42); --group-tint: rgba(47,157,114,.08); --group-label-bg: rgba(47,157,114,.17); --group-label-ink: #237653; }.highlight-group-innovation { --group-color: var(--highlight-innovation); --group-border: rgba(139,110,219,.45); --group-tint: rgba(139,110,219,.08); --group-label-bg: rgba(139,110,219,.17); --group-label-ink: #6950ae; }.highlight-group-conclusion { --group-color: var(--highlight-conclusion); --group-border: rgba(209,93,121,.45); --group-tint: rgba(209,93,121,.08); --group-label-bg: rgba(209,93,121,.16); --group-label-ink: #a44661; }.highlight-group h3 { display: inline-block; margin: 0 0 8px; padding: 3px 7px; border-radius: 6px; background: var(--group-label-bg); color: var(--group-label-ink); font-size: 11px; }.highlight-card { display: block; width: 100%; margin-top: 7px; padding: 9px 10px; border: 1px solid var(--group-border); border-left: 3px solid var(--group-color); border-radius: 8px; background: var(--paper); color: var(--ink); text-align: left; }.highlight-card:hover { background: color-mix(in srgb,var(--group-tint) 55%,var(--paper)); }.highlight-card-quote,.highlight-card-reason { display: block; line-height: 1.48; }.highlight-card-quote { font-family: "Times New Roman",Times,serif; font-size: 12px; }.highlight-card-reason { margin-top: 5px; color: var(--muted); font-size: 10px; }
.highlight-card.is-suggested { border-style: dashed; border-left-style: solid; }
.highlight-card.is-accepted { border-left-color: var(--group-color); background: color-mix(in srgb,var(--group-tint) 72%,var(--paper)); box-shadow: inset 0 0 0 1px color-mix(in srgb,var(--accent) 18%,transparent); }
.highlight-card.is-ignored { opacity: .68; border-style: dashed; background: color-mix(in srgb,var(--muted) 5%,var(--paper)); }
.highlight-card-main { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.highlight-card-main:focus-visible { outline: 2px solid color-mix(in srgb,var(--group-color) 52%,transparent); outline-offset: 3px; }
.highlight-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 7px; border-top: 1px solid color-mix(in srgb,var(--group-color) 24%,var(--line)); }
.highlight-card-state { flex: 0 1 auto; color: var(--group-label-ink); font-size: 9px; font-weight: 720; }
.highlight-card.is-accepted .highlight-card-state { color: var(--group-label-ink); }
.highlight-card.is-ignored .highlight-card-state { color: var(--muted); }
.highlight-card-actions { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.highlight-card-actions button { padding: 3px 5px; border: 1px solid color-mix(in srgb,var(--group-color) 35%,var(--line)); border-radius: 5px; background: var(--paper); color: var(--muted); font-size: 9px; cursor: pointer; }
.highlight-card-actions button:hover,.highlight-card-actions button:focus-visible { border-color: var(--group-color); background: color-mix(in srgb,var(--group-color) 11%,var(--paper)); color: var(--ink); outline: none; }
.notes-tools { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 8px; }
.notes-format-button { display: inline-flex; min-width: 29px; height: 29px; align-items: center; justify-content: center; padding: 0 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--text-secondary); font-size: 11px; cursor: pointer; }
.notes-format-button:hover,.notes-format-button:focus-visible { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); outline: 0; }
.notes-format-button:disabled { opacity: .55; cursor: wait; }
.notes-format-wide { min-width: 38px; }
.notes-save-button { margin-left: auto; }
.saved-state { min-width: 40px; color: var(--green); font-size: 10px; text-align: right; }
.saved-state.error { color: #bd3b47; }
.notes-editor { width: 100%; min-height: 0; flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; padding: 12px; border: 1px solid var(--line); border-radius: 9px; outline: 0; background: var(--paper); color: var(--ink); font-family: var(--app-font); font-size: 12px; line-height: 1.62; white-space: normal; }
.notes-editor[contenteditable="false"] { opacity: .62; cursor: progress; }
.notes-editor.is-empty::before { color: var(--text-tertiary); content: attr(data-placeholder); pointer-events: none; }
.notes-editor h1,.notes-editor h2,.notes-editor h3 { margin: .6em 0 .3em; color: var(--ink); font-size: 16px; line-height: 1.35; }
.notes-editor p { margin: .45em 0; }
.notes-editor ul,.notes-editor ol { margin: .5em 0; padding-left: 22px; }
.notes-editor blockquote { margin: .65em 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--highlight-orange); color: var(--muted); }
.notes-editor img { display: block; max-width: 100%; height: auto; margin: 9px 0; border-radius: 7px; }
.notes-editor code { padding: 2px 4px; border-radius: 4px; background: color-mix(in srgb,var(--accent) 8%,var(--soft)); font-family: ui-monospace,SFMono-Regular,Menlo,monospace; }

/* Rich note content. Colours are named tokens so light and dark themes can
   resolve them independently; the markdown only ever stores the name. */
:root {
  --note-red:#c0392b; --note-orange:#b3610e; --note-yellow:#8a6d0b; --note-green:#1f7a45;
  --note-blue:#1663a6; --note-purple:#6b45c0; --note-gray:#6b7684;
  --note-mark-red:#ffd9d2; --note-mark-orange:#ffe3c2; --note-mark-yellow:#fff3b0; --note-mark-green:#cdf0d8;
  --note-mark-blue:#d2e7fb; --note-mark-purple:#e6ddfb; --note-mark-gray:#e3e7ec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --note-red:#ff9b8f; --note-orange:#ffbe7a; --note-yellow:#f2d472; --note-green:#79dda2;
    --note-blue:#8bc2f5; --note-purple:#bda6f5; --note-gray:#aeb8c2;
    --note-mark-red:#5d2a25; --note-mark-orange:#5a3c17; --note-mark-yellow:#544716; --note-mark-green:#1f4630;
    --note-mark-blue:#1d3a55; --note-mark-purple:#372a55; --note-mark-gray:#333a42;
  }
}
.note-color-red { color: var(--note-red); }
.note-color-orange { color: var(--note-orange); }
.note-color-yellow { color: var(--note-yellow); }
.note-color-green { color: var(--note-green); }
.note-color-blue { color: var(--note-blue); }
.note-color-purple { color: var(--note-purple); }
.note-color-gray { color: var(--note-gray); }
.note-mark { padding: .05em .2em; border-radius: .2em; background: var(--note-mark-yellow); color: inherit; }
.note-mark-red { background: var(--note-mark-red); }
.note-mark-orange { background: var(--note-mark-orange); }
.note-mark-yellow { background: var(--note-mark-yellow); }
.note-mark-green { background: var(--note-mark-green); }
.note-mark-blue { background: var(--note-mark-blue); }
.note-mark-purple { background: var(--note-mark-purple); }
.note-mark-gray { background: var(--note-mark-gray); }
.notes-editor del,.annotation-note del { color: var(--muted); }
.notes-editor hr,.annotation-note hr { margin: .9em 0; border: 0; border-top: 1px solid var(--line); }
.notes-editor pre,.annotation-note pre { margin: .6em 0; padding: 9px 11px; overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }
.notes-editor pre code,.annotation-note pre code { padding: 0; background: transparent; font-size: .94em; line-height: 1.55; }
.notes-editor ul.note-todo,.annotation-note ul.note-todo { padding-left: 2px; list-style: none; }
.notes-editor ul.note-todo li,.annotation-note ul.note-todo li { display: flex; align-items: flex-start; gap: 7px; }
.notes-editor ul.note-todo input,.annotation-note ul.note-todo input { flex: 0 0 auto; margin-top: .28em; accent-color: var(--accent-fill); }
.notes-editor ul.note-todo li[data-checked="true"] { color: var(--muted); text-decoration: line-through; }
.notes-editor details,.annotation-note details { margin: .6em 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }
.notes-editor details summary,.annotation-note details summary { cursor: pointer; font-weight: 600; }
.note-format-bar { position: fixed; z-index: 60; display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); box-shadow: var(--shadow); }
.note-format-bar[hidden] { display: none; }
.note-format-action { display: inline-flex; min-width: 27px; height: 27px; align-items: center; justify-content: center; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 12px; line-height: 1; cursor: pointer; }
.note-format-action:hover { background: var(--soft); }
.note-format-action[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-dark); }
.note-format-separator { width: 1px; height: 17px; margin: 0 3px; background: var(--line); }
.note-format-palette { position: absolute; top: calc(100% + 6px); left: 0; display: flex; flex-wrap: wrap; gap: 4px; width: 168px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); box-shadow: var(--shadow); }
.note-format-palette[hidden] { display: none; }
.note-format-swatch { width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 5px; background: var(--swatch-color,transparent); color: var(--muted); font-size: 10px; cursor: pointer; }
.note-format-swatch-color { background: var(--paper); color: var(--swatch-color); font-weight: 800; }
.note-format-swatch-color::after { content: 'A'; }
.note-format-swatch-none { background: var(--soft); }
.note-slash-menu { position: fixed; z-index: 60; max-height: 260px; width: 210px; overflow: auto; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); box-shadow: var(--shadow); }
.note-slash-menu[hidden] { display: none; }
.note-slash-item { display: flex; width: 100%; align-items: center; gap: 8px; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 12px; text-align: left; cursor: pointer; }
.note-slash-item:hover,.note-slash-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-dark); }
.note-slash-item span:first-child { width: 18px; color: var(--muted); text-align: center; }
.note-slash-empty { padding: 8px; color: var(--muted); font-size: 12px; }
.note-math { display: inline-block; }
.note-math.math-display { display: block; margin: .8em 0; overflow-x: auto; text-align: center; }
.annotations-list { min-height: 0; overflow: auto; }.annotation-item { --annotation-color: var(--highlight-orange); position: relative; margin: 6px 0; padding: 8px 8px 7px 10px; border-left: 3px solid var(--annotation-color); border-radius: 0 8px 8px 0; background: color-mix(in srgb,var(--annotation-color) 9%,var(--paper)); }.annotation-quote { color: #405261; font-size: calc(var(--reader-content-font-size) * .78); line-height: 1.48; cursor: pointer; }.annotation-note { margin-top: 4px; color: var(--muted); font-size: calc(var(--reader-content-font-size) * .74); line-height: 1.48; }.annotation-note p { margin: .25em 0; }.annotation-note ul,.annotation-note ol { margin: .25em 0; padding-left: 17px; }.annotation-note blockquote { margin: .35em 0; padding-left: 8px; border-left: 2px solid var(--annotation-color); }.annotation-note h1,.annotation-note h2,.annotation-note h3 { margin: .4em 0 .2em; color: var(--ink); font-size: 1.08em; }.annotation-note code { padding: 1px 3px; border-radius: 3px; background: color-mix(in srgb,var(--annotation-color) 10%,var(--soft)); }.annotation-note img { display: block; max-width: 100%; height: auto; margin: 6px 0; border-radius: 7px; }.annotation-meta { display: flex; justify-content: space-between; margin-top: 5px; color: #99a4ad; font-size: 10px; }.annotation-meta button { padding: 0; border: 0; background: transparent; color: #9aa6af; font-size: 10px; }

.reader-sidebar { --reader-chrome-font-size: var(--toolbar-font-size); font-size: 13px; line-height: 1.45; }
.reader-sidebar :is(.selected-context-quote,.highlight-card-quote,.notes-editor) { font-family: var(--reader-content-font-family); }
.reader-sidebar :is(.chat-bubble,.chat-form textarea,.selected-context-quote,.highlight-card-quote,.notes-editor) { font-size: calc(13px * var(--reader-font-scale, 1)); line-height: 1.6; }
.reader-sidebar .chat-bubble, .reader-sidebar .chat-form textarea { font-family: var(--app-font); }
.reader-sidebar .chat-quote { font-family: var(--reader-content-font-family); font-size: calc(var(--reader-content-font-size) * .82); line-height: 1.5; }
.reader-sidebar :is(.annotation-quote,.annotation-note) { font-family: var(--reader-content-font-family); }
.reader-sidebar .panel-intro strong { font-size: var(--reader-heading-font-size); line-height: 1.4; }
.reader-sidebar :is(.sidebar-tab,.panel-intro span,.selected-context-label,.panel-status,.chat-empty,.outline-item,.highlight-card-reason,.chat-form .primary-button,.notes-format-button,.chat-history-item,.tiny-button,.quick-preview-actions button) { font-family: var(--app-font); font-size: var(--reader-chrome-font-size); line-height: 1.45; }
.reader-sidebar :is(.chat-bubble small,.outline-item small,.highlight-filter,.highlight-group h3,.highlight-card-state,.highlight-card-actions button,.saved-state,.annotation-meta,.annotation-meta button,.chat-form .primary-button span) { font-family: var(--app-font); font-size: 11px; line-height: 1.35; }
.reader-sidebar .notes-editor h1,.reader-sidebar .notes-editor h2,.reader-sidebar .notes-editor h3,.reader-sidebar .annotation-note h1,.reader-sidebar .annotation-note h2,.reader-sidebar .annotation-note h3 { font-family: inherit; font-size: 1.12em; line-height: inherit; }
.quick-preview-heading { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 10px; }
.quick-preview-heading > div { display: grid; min-width: 0; gap: 2px; }
.quick-preview-content { min-height: 0; flex: 1; overflow: auto; color: var(--ink); -webkit-user-select: text; user-select: text; }
.quick-preview-card { display: grid; gap: 10px; }
.quick-preview-card h3 { margin: 0; font-family: var(--reader-content-font-family); font-size: var(--reader-heading-font-size); line-height: 1.4; }
.quick-preview-card img { display: block; width: auto; max-width: 100%; max-height: 52vh; margin-inline: auto; object-fit: contain; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.quick-preview-card img.quick-preview-zoomable { cursor: zoom-in; transition: border-color var(--motion-fast) var(--motion-ease-out); }
.quick-preview-card img.quick-preview-zoomable:hover { border-color: var(--accent); }
.quick-preview-card img.quick-preview-zoomable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quick-preview-table { max-width: 100%; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.quick-preview-table table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 11px; }
.quick-preview-table :is(th,td) { padding: 5px 7px; border: 1px solid var(--line); }
.quick-preview-caption,.quick-preview-reference { font-family: var(--reader-content-font-family); font-size: calc(var(--reader-content-font-size) * .88); line-height: 1.58; }
.quick-preview-caption { display: block; }
.quick-preview-caption math,.quick-preview-translation math { max-width: 100%; overflow-x: auto; }
.quick-preview-content .inline-legend-marker { position: relative; display: inline-block; width: 1.45em; height: .86em; margin: 0 .12em; vertical-align: -.12em; }
.quick-preview-content .inline-legend-marker-gray { color: #8c8c8c; }
.quick-preview-content .inline-legend-marker-blue { color: #2f80ed; }
.quick-preview-content .inline-legend-marker-orange { color: #d97706; }
.quick-preview-content .inline-legend-marker-green { color: #2f855a; }
.quick-preview-content .inline-legend-marker-red { color: #d14343; }
.quick-preview-content .inline-legend-marker-purple { color: #805ad5; }
.quick-preview-content .inline-legend-marker-pink { color: #d53f8c; }
.quick-preview-content .pdf-text-tone { font-weight: inherit; }
.quick-preview-content .pdf-text-tone-blue { color: #1769aa; }
.quick-preview-content .pdf-text-tone-orange { color: #a85d00; }
.quick-preview-content .pdf-text-tone-green { color: #237a4b; }
.quick-preview-content .pdf-text-tone-red { color: #b23a3a; }
.quick-preview-content .pdf-text-tone-purple { color: #7047a8; }
.quick-preview-content .pdf-text-tone-pink { color: #a93a6f; }
.quick-preview-content .inline-legend-line { position: absolute; top: 50%; right: .04em; left: .04em; height: 1px; background: currentColor; }
.quick-preview-content .inline-legend-shape { position: absolute; top: 50%; left: 50%; width: .48em; height: .48em; background: currentColor; transform: translate(-50%,-50%); }
.quick-preview-content .inline-legend-marker-circle .inline-legend-shape { border-radius: 50%; }
.quick-preview-translation { padding: 8px 10px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: color-mix(in srgb,var(--accent-soft) 34%,var(--paper)); color: var(--ink); font-family: var(--reader-content-font-family); font-size: calc(var(--reader-content-font-size) * .88); line-height: 1.58; }
.quick-preview-reference { padding: 10px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: color-mix(in srgb,var(--accent-soft) 44%,var(--paper)); }
.quick-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-preview-ai { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-family: var(--reader-content-font-family); font-size: calc(var(--reader-content-font-size) * .88); line-height: 1.62; }
.quick-preview-ai-source { color: var(--muted); font-family: var(--app-font); font-size: 10px; line-height: 1.45; }

.reader-frame-wrap { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; border: 0; border-radius: 0; background: #fff; box-shadow: none; }
#reader-documents { position: absolute; inset: 0; }
.reader-document-frame { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 0; border: 0; background: var(--paper,#fff); }
.reader-document-frame:not(#html-preview) { visibility: hidden; pointer-events: none; }
.reader-search { position: absolute; top: 12px; right: 16px; z-index: 8; display: flex; min-width: min(330px,calc(100% - 32px)); max-width: calc(100% - 32px); align-items: center; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--material-overlay); box-shadow: var(--shadow-pop); backdrop-filter: var(--material-filter); }
.reader-search[hidden] { display: none; }
.reader-search input { min-width: 0; width: min(190px,34vw); flex: 1 1 150px; height: 28px; padding: 4px 7px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.reader-search input:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-soft); border-radius: 5px; }
.reader-search-count { min-width: 42px; padding: 0 4px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
.reader-search-button { display: inline-flex; width: 27px; height: 27px; flex: 0 0 27px; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); font-size: 14px; line-height: 1; }
.reader-search-button:hover,.reader-search-button:focus-visible { outline: 0; background: var(--accent-soft); color: var(--accent-dark); }
.reader-search-button:disabled { opacity: .38; pointer-events: none; }
.reader-search-close { margin-left: 1px; color: var(--muted); font-size: 18px; }
.selection-popover { position: absolute; z-index: 4; display: flex; flex-direction: column; width: min(580px,calc(100% - 20px)); max-width: calc(100% - 20px); max-height: calc(100% - 16px); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb,var(--paper) 92%,transparent); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop); animation: menu-pop var(--motion-fast) var(--motion-ease-spring); font-family: var(--app-font); font-size: calc(var(--reader-support-font-size) * .9); line-height: 1.3; }
.selection-popover > .selection-actions { flex: 0 0 auto; }
.selection-popover > .selection-actions:first-child { position: relative; padding-right: 76px; }
.selection-popover.hide-shortcut-hints > .selection-actions:first-child { padding-right: 43px; }
.selection-hover-note { flex: 0 1 auto; min-height: 0; max-height: 180px; overflow: auto; padding: 10px 14px; border-top: 1px solid var(--line); font-family: var(--reader-content-font-family); font-size: calc(var(--reader-content-font-size) * .88); line-height: 1.6; }
.selection-hover-note-label { color: var(--annotation-color,var(--accent-dark)); font-family: var(--app-font); font-size: .86em; font-weight: 600; }
.selection-hover-note-body > :first-child { margin-top: .3em; }
.selection-hover-note-body > :last-child { margin-bottom: 0; }
.selection-actions { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 3px; padding: 7px; }
.selection-actions button { display: inline-flex; min-width: 0; min-height: 30px; align-items: center; justify-content: center; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); font-family: inherit; font-size: inherit; font-weight: 500; line-height: inherit; white-space: nowrap; transition: background var(--motion-fast),color var(--motion-fast); }
.selection-actions button:not(:disabled):hover { background: var(--accent-soft); color: var(--accent-dark); }
.selection-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.selection-actions button[data-selection-shortcut]::after { content: attr(data-selection-shortcut); display: inline-flex; width: 15px; height: 15px; flex: 0 0 15px; align-items: center; justify-content: center; margin-left: 5px; border: 1px solid color-mix(in srgb,var(--muted) 16%,transparent); border-radius: 3px; background: color-mix(in srgb,var(--soft) 80%,transparent); color: var(--muted); font: 500 9px/1 var(--app-font); }
.selection-popover.hide-shortcut-hints .selection-actions button[data-selection-shortcut]::after { display: none; }
#selection-shortcut-settings { position: absolute; top: 7px; right: 43px; width: 30px; padding: 6px; color: var(--muted); }
#selection-shortcut-settings svg { width: 17px; height: 17px; }
#selection-add-vocabulary { position: absolute; top: 7px; right: 7px; width: 30px; padding: 6px; }
#selection-add-vocabulary svg { width: 17px; height: 17px; }
#selection-add-vocabulary:disabled { opacity: .4; }
.selection-action-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.selection-translation-result { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--ink); font-family: var(--reader-content-font-family); font-size: calc(var(--reader-content-font-size) * .88); line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.selection-translation-result[data-state="loading"] { color: var(--muted); font-family: var(--app-font); font-size: calc(var(--reader-support-font-size) * .88); line-height: 1.35; }
.selection-translation-result[data-state="streaming"]::after { content: "▍"; margin-left: .08em; color: var(--muted); animation: selection-stream-blink 1s steps(2, start) infinite; }
@keyframes selection-stream-blink { to { visibility: hidden; } }
.selection-translation-result[data-state="error"] { display: flex; align-items: center; justify-content: space-between; gap: .7em; color: #a5424c; font-family: var(--app-font); font-size: calc(var(--reader-support-font-size) * .88); line-height: 1.35; }
.selection-translation-result button { flex: 0 0 auto; padding: .36em .62em; border: 1px solid currentColor; border-radius: .45em; background: transparent; color: inherit; font-size: inherit; line-height: inherit; }

.settings-test-button { margin-top: 8px; }.settings-gateway-hint { min-height: 14px; }

@media (prefers-color-scheme: dark) {
  :root { --ink:#dfe3e7; --muted:#aeb8c2; --text-secondary:#c7ced6; --text-tertiary:#aeb8c2; --line:#3e444b; --paper:#1e2124; --canvas:#17191c; --soft:#262a2e; --accent:#8d98ff; --accent-dark:#aab2ff; --accent-soft:#24283d; --accent-fill:#8d98ff; --on-accent:#11131d; --shadow:0 16px 42px rgba(0,0,0,.34); --shadow-pop:0 0 0 .5px rgba(0,0,0,.45), 0 2px 10px rgba(0,0,0,.35), 0 12px 40px rgba(0,0,0,.5); --shadow-window:0 0 0 .5px rgba(0,0,0,.55), 0 10px 30px rgba(0,0,0,.42), 0 28px 90px rgba(0,0,0,.6); }
  body,body.reader-mode { background:var(--canvas); }
  .reader-sidebar,.reader-frame-wrap,#html-preview { background:var(--paper); }
  .app-header,.reader-action-bar { background:var(--material-bar); }
  .reader-heading,.reader-sidebar,.sidebar-tabs { border-color:var(--line); }
  .document-tab:hover,.document-tab.active { border-color:var(--line); border-bottom-color:var(--paper); background:var(--paper); color:var(--ink); }
  .action-button { color:#d9dde1; }.toolbar-icon-button,.secondary-button,.tiny-button,.search-box,.progress-card { border-color:var(--line); background:var(--paper); color:var(--ink); }
  .search-box input,.chat-form textarea { background:var(--paper); color:var(--ink); }
  .reader-title,.assistant-toggle,.sidebar-tab:hover,.sidebar-tab.active { color:var(--ink); }.reader-sidebar { box-shadow:none; }
  .chat-bubble.user { background:var(--accent-soft); color:var(--accent-dark); }.chat-bubble.assistant { background:var(--soft); color:var(--ink); }.selected-context { background:color-mix(in srgb,var(--accent-soft) 74%,var(--paper)); }.selected-context-label { color:var(--accent-dark); }
  .translation-progress { border-color:var(--line); background:var(--material-overlay); color:var(--text-secondary); }.translation-progress-track { background:#353a52; }.toast,.reader-search,.selection-popover { border-color:var(--line); background:var(--material-overlay); color:var(--ink); }
  .quick-preview-content .pdf-text-tone-blue { color:#7cc4ff; }.quick-preview-content .pdf-text-tone-orange { color:#f0ad4e; }.quick-preview-content .pdf-text-tone-green { color:#6fd39d; }.quick-preview-content .pdf-text-tone-red { color:#ff8b8b; }.quick-preview-content .pdf-text-tone-purple { color:#c4a5ff; }.quick-preview-content .pdf-text-tone-pink { color:#ff93c1; }
  .highlight-filter:hover,.highlight-filter.active { border-color:#8f6529; background:#342512; color:#ffc46c; }.highlight-filter[data-highlight-filter="research_goal"].active { border-color:#4fc58f; background:#173528; color:#8fe0ba; }.highlight-filter[data-highlight-filter="method"].active { border-color:#dca54e; background:#342512; color:#ffc46c; }.highlight-filter[data-highlight-filter="innovation"].active { border-color:#a894ef; background:#29223e; color:#c9bcff; }.highlight-filter[data-highlight-filter="conclusion"].active { border-color:#ed8ca5; background:#3b202a; color:#ffb5c7; }.highlight-group { border-color:var(--group-color); background:color-mix(in srgb,var(--group-color) 12%,var(--paper)); }.highlight-group h3 { background:color-mix(in srgb,var(--group-color) 24%,var(--paper)); color:color-mix(in srgb,var(--group-color) 66%,#fff); }.highlight-card { border-color:color-mix(in srgb,var(--group-color) 66%,var(--line)); background:var(--paper); color:var(--ink); }.highlight-card:hover { background:color-mix(in srgb,var(--group-color) 16%,var(--paper)); }
  .annotation-quote,.outline-item { color:#cbd1d6; }.drop-overlay { background:color-mix(in srgb,var(--accent-soft) 88%,transparent); }.library-dialog,.metadata-dialog { box-shadow:0 24px 80px rgba(0,0,0,.55); }.tag-option,.folder-option,.metadata-candidate { background:var(--soft); }
}

@media (max-width: 1160px) {
  .action-button { padding: 6px 5px; }
}
@media (max-width: 880px) {
  .app-header { padding: 0 15px; gap: 12px; }
  .header-spacer { display: none; }
  .app-shell { padding: 18px 13px 50px; }
  .search-box { width: 100%; }
  .header-document-tabs { max-width: none; margin-left: 0; }
  .reader-action-bar { display: grid; grid-template-columns: auto minmax(0,1fr); }
  .reader-heading { padding: 0 9px; }
  .assistant-toggle-label { display: none; }
  .reader-actions { justify-content: flex-start; padding: 0 6px; }
  .reader-grid,.reader-grid:has(.reader-sidebar.is-open) { grid-template-columns: minmax(0,1fr); }
  .reader-sidebar { position: absolute; z-index: 45; top: 0; bottom: 0; left: 0; width: min(420px,calc(100vw - 34px)); height: 100%; border-right: 1px solid #dde1e5; box-shadow: 14px 0 38px rgba(31,43,54,.16); opacity: 0; transform: translateX(calc(-100% - 20px)); }
  .reader-sidebar.is-open { opacity: 1; transform: translateX(0); }
  .reader-frame-wrap,#html-preview { width: 100%; height: 100%; min-height: 0; }
  .reader-search { top: 8px; right: 8px; min-width: calc(100% - 16px); max-width: calc(100% - 16px); }
  .reader-search input { width: auto; }
}
@media (max-width: 520px) {
  .document-tab { min-width: 170px; max-width: 210px; }
  .sidebar-tab { min-width: max-content; }
  .app-shell { padding-left: 8px; padding-right: 8px; }
  .reader-frame-wrap { border-radius: 0; }
  .metadata-grid { grid-template-columns: 1fr; }.metadata-field.full { grid-column: auto; }
}

/* Library v2: a quiet Zotero-like table with folders and saved views. */
.nav-settings { margin-left: auto; }
.library-layout,.views-layout { display: grid; min-height: calc(100vh - 155px); grid-template-columns: 250px minmax(0,1fr); gap: 22px; }
.library-layout { grid-template-columns: 250px minmax(0,1fr) 296px; gap: 0; }
/* The dividers sit on the main column, which spans the whole row, so they
   read the same in list and graph mode instead of stopping wherever the
   sticky sidebar or details panel happens to end. */
.library-layout > .library-main { padding-inline: 20px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.library-layout > .library-sidebar { border-right: 0; }
.library-layout > .library-details { border-left: 0; }
.library-details { position: sticky; top: 60px; align-self: start; display: flex; flex-direction: column; max-height: calc(100vh - 60px); overflow-y: auto; padding: 22px 18px 26px 20px; border-left: 1px solid var(--line); font-size: 12.5px; -webkit-user-select: text; user-select: text; }
.library-details * { -webkit-user-select: text; user-select: text; }
.library-details :is(button,button *,select,select *) { -webkit-user-select: none; user-select: none; }
.library-details :is(input,textarea,[contenteditable="true"]),.library-details :is(input,textarea,[contenteditable="true"]) * { -webkit-user-select: text; user-select: text; }
.library-details-empty { margin: auto; color: var(--text-tertiary); text-align: center; font-size: 12.5px; line-height: 1.7; }
.library-details h2 { margin: 0 0 6px; font-size: 15.5px; font-weight: 680; line-height: 1.45; }
.details-original-title { margin: -2px 0 8px; font-style: italic; overflow-wrap: anywhere; }
.details-meta { margin: 0 0 3px; color: var(--text-secondary); line-height: 1.55; }
.details-meta.secondary { color: var(--text-tertiary); }
.details-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.details-actions .primary-button { margin-top: 0; padding: 7px 14px; font-size: 12.5px; }
.details-actions .secondary-button { padding: 6px 10px; }
.details-fields { display: grid; gap: 0; margin: 10px 0 0; }
.details-field { display: grid; grid-template-columns: 76px minmax(0,1fr); align-items: start; gap: 10px; padding: 8px 0; border-top: 1px solid color-mix(in srgb, var(--line) 62%, transparent); }
.details-field > dt { color: var(--text-tertiary); font-size: 12px; line-height: 1.6; }
.details-field > dd { margin: 0; min-width: 0; color: var(--ink); line-height: 1.6; overflow-wrap: anywhere; }
.details-stars { display: inline-flex; gap: 1px; }
.details-stars button { padding: 0 1px; border: 0; background: transparent; color: var(--text-tertiary); font-size: 16px; line-height: 1.2; }
.details-stars button.is-filled { color: #b77914; }
.details-status-select { width: 100%; min-height: 30px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); font-size: 12.5px; }
.details-status-select:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 16%,transparent); }
.details-edit-value { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 5px; }
.details-edit-button { padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--text-tertiary); font-size: 11px; }
.details-edit-button:hover { border-color: var(--accent); color: var(--accent-dark); }
.details-abstract-heading { margin: 14px 0 5px; color: var(--text-tertiary); font-size: 12px; font-weight: 640; }
.details-abstract { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.68; }
.copyable-data { -webkit-user-select: text; user-select: text; cursor: text; }
.library-details-close { display: none; }
/* A value cell is a button so a change can start where the value is read.
   Being a button is also what keeps row selection, double-click-to-open and
   the marquee drag from firing on the same press. */
.row-cell-button { display: flex; width: 100%; min-width: 0; align-items: center; margin: -3px -5px; padding: 3px 5px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; }
.row-cell-button > * { min-width: 0; }
.row-cell-button:hover,.row-cell-button:focus-visible { border-color: color-mix(in srgb,var(--accent) 34%,var(--line)); outline: none; background: color-mix(in srgb,var(--accent-soft) 60%,transparent); }
/* A table cell that shifts under the pointer reads as a glitch. */
.row-cell-button:not(:disabled):active { transform: none; filter: none; }
.cell-editor-popover { position: fixed; z-index: 130; display: grid; gap: 8px; width: 248px; max-height: calc(100vh - 16px); overflow-y: auto; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--material-overlay); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop); transform-origin: top left; animation: menu-pop var(--motion-fast) var(--motion-ease-spring); }
.cell-editor-popover[data-placement="top"] { transform-origin: bottom left; }
.cell-editor-title { color: var(--text-tertiary); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.cell-editor-options { display: grid; gap: 2px; }
.cell-editor-option { display: flex; width: 100%; align-items: center; gap: 7px; padding: 7px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); font-size: 13px; text-align: left; }
.cell-editor-option:hover,.cell-editor-option:focus-visible { outline: none; background: var(--accent-soft); color: var(--accent-dark); }
.cell-editor-option[aria-selected="true"] { color: var(--accent-dark); font-weight: 650; }
.cell-editor-option[aria-selected="true"]::after { content: "✓"; margin-left: auto; }
.cell-editor-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.cell-editor-tag { padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text-secondary); font-size: 12px; }
.cell-editor-tag[aria-pressed="true"] { border-color: color-mix(in srgb,var(--accent) 46%,var(--line)); background: var(--accent-soft); color: var(--accent-dark); }
.cell-editor-input { width: 100%; min-height: 32px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: var(--paper); color: var(--ink); font-size: 13px; }
.cell-editor-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 16%,transparent); }
.cell-editor-stars { display: flex; gap: 2px; }
.cell-editor-stars button { padding: 2px 3px; border: 0; background: transparent; color: var(--text-tertiary); font-size: 20px; line-height: 1; }
.cell-editor-stars button.is-filled { color: #b77914; }
.cell-editor-actions { display: flex; justify-content: flex-end; gap: 6px; }
.cell-editor-hint { color: var(--text-tertiary); font-size: 10.5px; line-height: 1.45; }
.row-stars { color: #8f5c0d; font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.row-stars .star-empty { color: color-mix(in srgb, var(--text-tertiary) 46%, transparent); }
.row-status { color: var(--text-secondary); font-size: 12.5px; }
.row-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--text-tertiary); vertical-align: 1px; }
.row-status[data-status="阅读中"]::before { background: var(--yellow); }
.row-status[data-status="已完成"]::before { background: var(--green); }
.row-status[data-status="计划中"]::before { background: var(--blue); }
.row-venue,.row-plain { overflow: hidden; color: var(--text-secondary); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
/* Three columns need room. Below that the details panel is not dropped,
   it becomes the bottom sheet phones use — otherwise a 1040px window
   (the desktop minimum) would have no way to reach a paper's fields. */
@media (max-width: 1119px) { .library-layout { grid-template-columns: 250px minmax(0,1fr); } .library-layout > .library-main { border-right: 0; } }
@media (min-width: 861px) and (max-width: 1119px) { .library-layout { grid-template-columns: 210px minmax(0,1fr); } }
.library-sidebar,.views-sidebar { min-width: 0; padding: 20px 14px; border-right: 1px solid var(--line); }
.library-sidebar { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; padding-inline: 6px; }
.library-sidebar-heading,.views-sidebar-heading,.property-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); font-size: 16px; }
.library-sidebar-heading { padding-inline: 8px; }
.tiny-icon-button { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--muted); font-size: 18px; }
.tiny-icon-button:hover { border-color: #b1c0ea; background: var(--accent-soft); color: var(--accent-dark); }
.folder-tree,.system-filter-list { display: grid; gap: 3px; margin-top: 12px; }
.folder-tree-node { min-width: 0; }
.folder-row { display: flex; align-items: center; gap: 2px; padding-left: calc(var(--folder-depth, 0) * 12px); border-radius: 7px; }
.folder-row:hover { background: var(--soft); }
.folder-button,.system-filter { display: flex; min-width: 0; min-height: 34px; flex: 1; align-items: center; gap: 8px; padding: 7px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); text-align: left; font-size: 13.5px; font-weight: 540; line-height: 1.35; }
.folder-button:hover,.folder-button.active,.system-filter:hover,.system-filter.active { background: var(--accent-soft); color: var(--accent-dark); }
.sidebar-item-icon { display: block; width: 20px; height: 20px; flex: 0 0 20px; }
.folder-label,.system-filter-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-button b,.system-filter b { min-width: 22px; margin-left: auto; color: var(--text-tertiary); font-size: 12px; font-weight: 600; text-align: right; }
.folder-actions { display: inline-flex; align-items: center; gap: 1px; opacity: 0; transition: opacity var(--motion-fast) var(--motion-ease-out); }
.folder-row:hover .folder-actions,.folder-row:focus-within .folder-actions,.folder-button:focus-visible + .folder-actions { opacity: 1; }
.folder-action { width: 26px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-tertiary); font-size: 14px; }
.folder-action:hover { background: var(--accent-soft); color: var(--accent-dark); }
.folder-action.folder-delete:hover { background: #fff0f0; color: #b54d58; }
.folder-empty { padding: 13px 8px; color: var(--text-tertiary); font-size: 14px; line-height: 1.5; }
.library-sidebar-divider,.views-sidebar-divider { height: 1px; margin: 18px 4px 13px; background: var(--line); }
.library-sidebar-divider { margin-inline: 8px; }
.library-main,.view-editor { min-width: 0; padding: 20px 0 48px; }
.library-main-heading { display: flex; min-width: 0; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.library-main-heading > :first-child { min-width: 0; flex: 1 1 auto; }
.library-main-heading h1 { min-width: 0; margin: 0 0 3px; overflow: hidden; font-size: 21px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.library-subtitle { min-width: 0; margin: 0; overflow: hidden; color: var(--text-secondary); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.library-main-actions { display: flex; min-width: 0; flex: 0 1 auto; align-items: center; gap: 8px; }
.library-main-actions .search-box { width: min(300px,28vw); min-width: 140px; min-height: 36px; flex: 1 1 300px; padding: 7px 10px; }
.library-main-actions .search-box input { font-size: 13px; }
.library-main-actions select { min-height: 36px; flex: 0 0 auto; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.library-main-actions select.is-filtering { border-color: color-mix(in srgb,var(--accent) 46%,var(--line)); background: var(--accent-soft); color: var(--accent-dark); }
.library-main-actions .compact-button { min-height: 36px; flex: 0 0 auto; padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.compact-button { min-height: 38px; margin-top: 0; padding: 8px 13px; font-size: 14px; }
.library-columns,.library-row { display: grid; align-items: center; column-gap: 8px; }
.library-columns { padding: 0 12px 7px; color: var(--text-tertiary); font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
/* The name column stays put while the rest of the row scrolls; it swallows
   the row padding so nothing peeks out on its left, and carries the
   selection bar the row used to draw underneath it. */
.library-column-header:first-child, .library-row-name { position: sticky; left: 0; z-index: 3; margin-left: -12px; padding-left: 12px; }
.library-column-header:first-child { background: var(--canvas); }
.library-row-name { background: inherit; }
/* The header and the rows share one horizontal scroller so the columns stay
   aligned however far the table is scrolled. */
.library-table-scroll { min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.library-list { min-width: 0; min-height: 140px; padding-bottom: 140px; }
.library-row { position: relative; min-width: max(640px, var(--library-table-min-width, 0px)); min-height: 54px; margin: 0; padding: 8px 12px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--paper); box-shadow: none; transition: background var(--motion-fast) var(--motion-ease-out); overflow: visible; }
.library-row:last-child { border-bottom: 1px solid var(--line); }
.library-row:hover { border-color: var(--line); background: color-mix(in srgb,var(--accent-soft) 38%,var(--paper)); box-shadow: none; transform: none; }
.library-row.is-selected { background: color-mix(in srgb,var(--accent-soft) 56%,var(--paper)); }
.library-row.is-selected .library-row-name { box-shadow: inset 3px 0 var(--accent); }
.library-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.library-row.is-trashed { opacity: .72; }
.library-selection-marquee { position: fixed; z-index: 90; pointer-events: none; border: 1px solid color-mix(in srgb, var(--accent) 82%, #fff); border-radius: 3px; background: color-mix(in srgb, var(--accent-soft) 72%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent); }
body.library-marquee-selecting, body.library-marquee-selecting * { cursor: crosshair !important; }
body.library-marquee-selecting { -webkit-user-select: none; user-select: none; }
.library-row-name { display: flex; min-width: 0; align-items: center; gap: 9px; }
.library-row-name-text { min-width: 0; }
.library-row-name strong,.library-row-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-row-name strong { color: var(--ink); font-size: 14px; font-weight: 660; line-height: 1.35; }
.library-row-name small { margin-top: 2px; color: var(--text-tertiary); font-size: 12px; line-height: 1.35; }
.library-row-title { overflow: hidden; color: var(--text-secondary); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.library-tags { display: flex; min-width: 0; align-items: center; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tag-chip { display: inline-flex; max-width: 100%; flex: 0 0 auto; align-items: center; overflow: hidden; margin: 0 4px 0 0; padding: 5px 8px; border-radius: 6px; background: color-mix(in srgb,var(--accent) 12%,transparent); color: var(--accent-dark); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.property-placeholder { color: var(--text-tertiary); }
.library-row-actions { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.row-more-button { padding: 4px 5px; border: 0; border-radius: 5px; background: transparent; color: var(--text-tertiary); font-size: 15px; font-weight: 620; line-height: 1; white-space: nowrap; }
.row-more-button:hover { background: var(--accent-soft); }
.views-layout { grid-template-columns: 245px minmax(0,1fr); }
.views-sidebar { padding-top: 18px; }.views-sidebar-heading h2 { margin: 4px 0 0; font-size: 17px; }
.views-back-button { display: flex; align-items: center; gap: 4px; margin: 0 0 12px; padding: 5px 8px 5px 4px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); font-size: 13px; }
.views-back-button:hover { background: var(--accent-soft); color: var(--accent-dark); }.saved-views-list,.properties-list { display: grid; gap: 3px; margin-top: 12px; }
.saved-view { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); text-align: left; font-size: 14px; }.saved-view:hover,.saved-view.active { background: var(--accent-soft); color: var(--accent-dark); }
.property-heading { margin-top: 3px; }.property-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 6px; padding: 9px 2px; border-bottom: 1px solid var(--line); color: var(--text-secondary); font-size: 13px; }.property-row small,.property-row em { color: var(--text-tertiary); font-size: 11px; font-style: normal; }.property-row button { padding: 3px 5px; border: 0; background: transparent; color: #b54d58; font-size: 11px; }
.view-form { max-width: 720px; padding: 18px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }.view-form > label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 13px; }.view-form input,.filter-row select,.filter-row input { min-height: 36px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--paper); color: var(--ink); font-size: 13px; }.filter-builder { margin-top: 18px; }.filter-builder-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--text-secondary); font-size: 13px; }.view-filters { display: grid; gap: 7px; }.filter-row { display: grid; grid-template-columns: 1fr 1fr 1.2fr 30px; gap: 6px; }.filter-row button { border: 1px solid var(--line); border-radius: 7px; background: var(--soft); color: var(--text-secondary); }.view-form-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }.view-form-actions .panel-status { margin: 0; }.view-form-actions .primary-button { margin-top: 0; }

@media (prefers-color-scheme: dark) {
  .library-sidebar,.views-sidebar { border-color: var(--line); }.folder-row:hover,.library-row:hover { background: color-mix(in srgb,var(--accent-soft) 52%,var(--paper)); }.view-form { background: var(--paper); }.library-main-actions select { background: var(--paper); color: var(--ink); }.folder-action.folder-delete:hover { background: #3b202a; }.property-row button { color: #ffb0b0; }
  /* The light-theme amber only cleared the 4.5:1 floor against the old
     near-black surface. Stars stay gold whatever accent the user picks. */
  .row-stars { color: #f3b34c; }
}
@media (max-width: 1360px) {
  /* Give the title a full row before the desktop grid leaves it at min-content width. */
  .library-main-heading { align-items: stretch; flex-direction: column; gap: 10px; }
  .library-main-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
}
@media (min-width: 861px) and (max-width: 1360px) {
  .library-main-actions .search-box { flex-basis: 100%; }
}
@media (max-width: 980px) {
  .library-layout,.views-layout { grid-template-columns: 210px minmax(0,1fr); gap: 16px; }.library-layout { gap: 0; }.library-main-actions .search-box { width: min(250px,100%); }.library-columns { display: none; }.library-row { min-width: max(640px, var(--library-table-min-width, 0px)); }
}
@media (max-width: 700px) {
  .library-layout,.views-layout { display: block; }.library-sidebar,.views-sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }.library-sidebar { padding-bottom: 12px; }.library-main,.view-editor { padding-top: 18px; }.library-main-heading { align-items: flex-start; flex-direction: column; }.library-main-actions { width: 100%; justify-content: flex-start; }.library-main-actions .search-box { flex: 1; width: auto; }.folder-actions { opacity: 1; }.views-sidebar { margin-bottom: 4px; }.filter-row { grid-template-columns: 1fr 1fr; }.filter-row input { grid-column: 1 / -1; }.filter-row button { grid-column: 2; justify-self: end; width: 30px; }.view-form-actions { flex-wrap: wrap; }
  .image-lightbox { padding: 48px 14px 18px; }
  .image-lightbox-image { max-height: calc(100vh - 96px); }
}

/* v7 library/readability refinements */
.library-columns,.library-row { grid-template-columns: var(--library-grid-template, minmax(150px,1.65fr) minmax(92px,1.05fr) minmax(86px,.8fr) minmax(84px,.82fr) minmax(96px,1.08fr) minmax(40px,auto)); }
/* The list publishes the sum of its column minimums; a row never ends
   before its last track does, so its background reaches every column. */
.library-columns,.library-row { min-width: max(720px, var(--library-table-min-width, 0px)); }
.library-row-name { gap: 0; }
.document-tab.active { position: relative; }
.document-tab.active::after { position: absolute; right: 9px; bottom: -1px; left: 9px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); content: ""; }
.row-more-menu { position: fixed; z-index: 120; top: 0; left: 0; display: none; min-width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: var(--material-overlay); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop); transform-origin: top; animation: menu-pop var(--motion-fast) var(--motion-ease-spring); }
.row-more-menu.menu-up { bottom: auto; }
.library-row.menu-open { z-index: 21; }
.library-row.menu-open .row-more-menu { display: grid; gap: 2px; }
.row-more-menu button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 20px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); text-align: left; font-size: 13px; }
.row-more-menu button:not(:disabled):hover { background: var(--accent-soft); color: var(--accent-dark); }
.row-more-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); color: var(--accent-dark); }
.row-more-menu button:disabled { opacity: .45; cursor: not-allowed; }
.row-more-menu button.is-danger:hover,.row-more-menu button.is-danger:focus-visible { background: #fff1e5; color: #a34b15; }
.row-more-menu kbd { color: var(--text-tertiary); font-family: var(--app-font); font-size: 11px; font-weight: 500; }
.row-menu-separator { height: 1px; margin: 4px 5px; background: var(--line); }
.image-lightbox {
  position: fixed;
  z-index: 180;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 54px;
  overflow: auto;
  background: rgba(7,8,10,.9);
  backdrop-filter: blur(7px);
  cursor: zoom-out;
  animation: scholar-lightbox-enter var(--motion-panel) ease-out both;
  transition: opacity var(--motion-panel) ease;
}
.image-lightbox.is-closing { opacity: 0; pointer-events: none; }
.image-lightbox[hidden],.image-context-menu[hidden] { display: none; }
.image-lightbox-content {
  display: grid;
  max-width: min(94vw,1600px);
  max-height: calc(100vh - 76px);
  justify-items: center;
  gap: 12px;
  margin: 0;
  cursor: default;
  animation: scholar-image-enter var(--motion-panel) var(--motion-ease-out) both;
  transition: opacity var(--motion-panel) ease, transform var(--motion-panel) var(--motion-ease-out);
}
.image-lightbox.is-closing .image-lightbox-content { opacity: 0; transform: scale(.985); }
.image-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 112px);
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(0,0,0,.48);
  user-select: none;
  -webkit-user-drag: none;
}
.image-lightbox-caption {
  max-width: min(82vw,1100px);
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(8,9,11,.74);
  color: #eef0f2;
  font-family: var(--app-font);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}
.image-lightbox-close {
  position: fixed;
  z-index: 1;
  top: 18px;
  right: 20px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 50%;
  background: rgba(12,13,16,.68);
  color: #fff;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}
.image-lightbox-close:hover,.image-lightbox-close:focus-visible {
  border-color: rgba(255,255,255,.62);
  background: rgba(36,38,42,.9);
  outline: none;
}
.image-context-menu {
  position: fixed;
  z-index: 200;
  top: 0;
  left: 0;
  display: grid;
  min-width: 210px;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--material-overlay);
  backdrop-filter: var(--material-filter);
  box-shadow: var(--shadow-pop);
  animation: menu-pop var(--motion-fast) var(--motion-ease-spring);
}
.image-context-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--app-font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.image-context-menu button:hover,.image-context-menu button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-dark);
  outline: none;
}
.image-context-menu button:disabled { opacity: .52; cursor: wait; }
.image-context-menu kbd { color: var(--text-tertiary); font-family: var(--app-font); font-size: 11px; font-weight: 500; }
body.image-lightbox-open { overflow: hidden; }
.library-row-actions { position: static; overflow: visible; }
.columns-editor { display: grid; min-height: 100%; grid-template-areas: "intro intro" "existing creator"; grid-template-columns: minmax(0,1fr) minmax(300px,340px); align-items: start; gap: 18px 24px; }
.columns-editor-intro { grid-area: intro; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 16px; border: 1px solid color-mix(in srgb,var(--accent) 24%,var(--line)); border-radius: 11px; background: color-mix(in srgb,var(--accent-soft) 35%,var(--paper)); }
.columns-editor-intro p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.55; }
.columns-editor-intro span { flex: 0 0 auto; color: var(--text-tertiary); font-size: 11px; white-space: nowrap; }
.dialog-hint { margin: 0 0 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.columns-existing,.column-creator,.columns-list { display: grid; gap: 10px; }
.columns-existing { grid-area: existing; min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb,var(--soft) 46%,var(--paper)); }
.columns-list { grid-template-columns: repeat(2,minmax(0,1fr)); align-content: start; }
.columns-editor-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.columns-editor-heading strong { color: var(--ink); font-size: 15px; }
.columns-editor-heading span { color: var(--text-tertiary); font-size: 11px; }
.column-label-input { min-width: 0; width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font-size: 13px; }
.column-system-note { color: var(--muted); font-size: 11px; white-space: nowrap; }
.column-creator { position: sticky; top: 0; grid-area: creator; align-self: start; padding: 18px; border: 1px solid color-mix(in srgb,var(--accent) 28%,var(--line)); border-radius: 14px; background: color-mix(in srgb,var(--accent-soft) 34%,var(--paper)); }
.column-creator .columns-editor-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
.column-creator-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.column-visibility-toggle { display: flex !important; align-items: center; gap: 8px !important; color: var(--text-secondary) !important; font-size: 13px !important; }
.column-visibility-toggle input { width: auto !important; min-height: 0 !important; }
.column-creator-note { margin: 2px 0 0; padding-top: 12px; border-top: 1px solid color-mix(in srgb,var(--accent) 22%,var(--line)); color: var(--text-tertiary); font-size: 11px; line-height: 1.55; }
.view-results-card { margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.view-results-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.view-results-card .library-table-scroll { margin: 0 -14px -14px; }
.view-results-card .library-row { border-left: 0; border-right: 0; }

/* Settings: modelled on macOS System Settings — a vibrancy sidebar whose
   rows carry colored icon tiles, and a scrolling column of grouped cards. */
.settings-product { position: relative; display: grid; --settings-sidebar-width: 250px; min-height: calc(100vh - 155px); grid-template-columns: 250px minmax(0,1fr); gap: 30px; }
.settings-product::before { position: absolute; top: 0; bottom: 0; left: calc(var(--settings-sidebar-width) - 1px); width: 1px; background: var(--line); content: ""; pointer-events: none; }
.settings-navigation { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; padding: 16px 14px 18px; }
.settings-navigation-heading { display: grid; gap: 3px; padding: 0 8px; }
.settings-navigation-heading strong { color: var(--ink); font-size: 16px; }
.settings-navigation-heading span { color: var(--text-tertiary); font-size: 12px; }
.settings-navigation-links { display: grid; gap: 2px; margin-top: 14px; }
.settings-navigation a { position: relative; display: flex; min-height: 38px; align-items: center; gap: 10px; margin: 0; padding: 6px 10px; border-radius: 8px; color: var(--text-secondary); font-size: 13px; font-weight: 560; text-decoration: none; transition: background-color var(--motion-fast) ease,color var(--motion-fast) ease; }
.settings-navigation a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.settings-navigation a.active,.settings-navigation a[aria-current] { background: var(--accent-fill); color: var(--on-accent); }
.settings-navigation a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -2px; }
/* System Settings-style icon tiles: a white glyph over a per-section color. */
.settings-navigation-icon { display: inline-flex; width: 26px; height: 26px; flex: 0 0 26px; align-items: center; justify-content: center; border-radius: 7px; background: var(--tile, #8e8e93); color: #fff; box-shadow: inset 0 -1px 1px rgba(0,0,0,.12), inset 0 1px 1px rgba(255,255,255,.28); }
.settings-navigation a[data-tile="amber"] { --tile: #e8930c; }
.settings-navigation a[data-tile="indigo"] { --tile: #5e5ce6; }
.settings-navigation a[data-tile="blue"] { --tile: #0a84ff; }
.settings-navigation a[data-tile="teal"] { --tile: #30b0c7; }
.settings-navigation a[data-tile="violet"] { --tile: #af52de; }
.settings-navigation a[data-tile="gray"] { --tile: #8e8e93; }
.settings-navigation-icon svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.settings-product-form { display: grid; min-width: 0; align-content: start; gap: 14px; margin: 24px 0; padding: 0; border: 0; background: transparent; }
.settings-page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin: 0 0 2px; padding: 2px 4px 10px; border: 0; }
.settings-page-heading h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -.015em; }
.settings-page-heading p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.settings-save-status { display: inline-flex; min-height: 26px; flex: 0 0 auto; align-items: center; gap: 6px; margin-top: 2px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--text-secondary); font-size: 11px; font-weight: 620; transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease; }
.settings-save-status::before { width: 6px; height: 6px; border-radius: 50%; background: #2e9b6b; content: ""; }
.settings-save-status[data-state="pending"]::before,.settings-save-status[data-state="saving"]::before { background: #d0872f; animation: settings-save-pulse 1s ease-in-out infinite alternate; }
.settings-save-status[data-state="error"] { color: #a5424c; }
.settings-save-status[data-state="error"]::before { background: #c44f45; animation: none; }
@keyframes settings-save-pulse { to { opacity: .35; } }
.settings-section { min-width: 0; scroll-margin-top: 76px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: 0 0 0 .5px color-mix(in srgb, var(--ink) 3%, transparent), 0 1px 2px rgba(28,39,49,.04); }
.settings-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 8px; }
.settings-section-heading h2 { margin: 0 0 3px; font-size: 16px; letter-spacing: -.01em; }
.settings-section-heading p { max-width: 660px; margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.settings-badge,.settings-value { flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); color: var(--text-secondary); font-size: 11px; font-weight: 600; white-space: nowrap; }
.settings-control-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-bottom: 2px; }
/* Appearance pickers render as grouped-list rows instead of field cards. */
.settings-control-grid:has(.settings-select-field) { grid-template-columns: 1fr; gap: 0; }
.settings-control-grid .settings-select-field:first-child { border-top: 0; }
/* Grouped-list rows: label on the left, a compact popup button on the right,
   hairline separators between rows — the System Settings idiom. */
.settings-select-field { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 24px; padding: 13px 0; border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent); }
.settings-select-field > span { min-width: 0; }
.settings-select-field strong,.settings-select-field small { display: block; }
.settings-select-field strong { color: var(--ink); font-size: 13.5px; font-weight: 590; }
.settings-select-field small { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.45; }
.settings-select-field select { flex: 0 0 auto; width: auto; min-width: 176px; max-width: 260px; min-height: 32px; padding: 5px 26px 5px 10px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--paper); color: var(--ink); font: inherit; font-size: 13px; box-shadow: 0 1px 2px rgba(28,39,49,.06); }
.settings-select-field select:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.settings-row,.settings-toggle { display: flex !important; align-items: center; justify-content: space-between; gap: 24px; margin: 0 !important; padding: 13px 0; border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent); color: var(--ink) !important; }
.settings-row strong,.settings-toggle strong { display: block; font-size: 13.5px; font-weight: 590; }
.settings-row small,.settings-toggle small { display: block; max-width: 680px; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.45; }
/* Accent picker: round swatches with a white check, like the System Settings
   accent-color row. */
.settings-accent-row { align-items: center; }
.settings-accent-options { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 10px; }
.settings-accent-option { --swatch:#d97706; position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px; border: 0; background: transparent; color: var(--text-tertiary); font-size: 10px; cursor: pointer; }
.settings-accent-option[data-accent="blue"] { --swatch:#2563eb; }
.settings-accent-option[data-accent="emerald"] { --swatch:#059669; }
.settings-accent-option[data-accent="violet"] { --swatch:#7c3aed; }
.settings-accent-option[data-accent="rose"] { --swatch:#e11d48; }
.settings-accent-option[data-accent="graphite"] { --swatch:#59636e; }
.settings-accent-option input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: .01; cursor: pointer; }
.settings-accent-swatch { position: relative; width: 24px; height: 24px; flex: 0 0 auto; border: 0; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 1px 1px rgba(255,255,255,.35), inset 0 -1px 1px rgba(0,0,0,.14), 0 1px 2px rgba(0,0,0,.12); transition: transform var(--motion-fast) var(--motion-ease-spring), box-shadow var(--motion-fast) ease; }
.settings-accent-check { position: absolute; top: 4px; left: 50%; z-index: 2; width: auto; color: #fff; font-size: 12px; font-weight: 800; line-height: 1.35; opacity: 0; transform: translateX(-50%) scale(.6); transition: opacity var(--motion-fast) ease, transform var(--motion-fast) var(--motion-ease-spring); pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.28); }
.settings-accent-option:hover .settings-accent-swatch { transform: scale(1.12); }
.settings-accent-option:has(input:checked) { color: var(--ink); }
.settings-accent-option:has(input:checked) .settings-accent-swatch { box-shadow: inset 0 1px 1px rgba(255,255,255,.35), inset 0 -1px 1px rgba(0,0,0,.14), 0 0 0 2px var(--paper), 0 0 0 4px color-mix(in srgb, var(--swatch) 70%, var(--line)); }
.settings-accent-option:has(input:checked) .settings-accent-check { opacity: 1; transform: translateX(-50%) scale(1); }
.settings-accent-option:has(input:focus-visible) .settings-accent-swatch { outline: 3px solid color-mix(in srgb, var(--swatch) 45%, transparent); outline-offset: 2px; }
.settings-appearance-preview { --preview-app-font:var(--app-font); --preview-reader-font:var(--reader-content-font-family); overflow: hidden; margin: 2px 0 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.appearance-preview-chrome { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: color-mix(in srgb,var(--soft) 72%,var(--paper)); font-family: var(--preview-app-font); font-size: 12px; }
/* Faux macOS traffic lights ground the preview as a window. */
.appearance-preview-chrome::before { content: ""; width: 10px; height: 10px; flex: 0 0 10px; margin-right: 34px; border-radius: 50%; background: #ff5f57; box-shadow: 16px 0 0 #febc2e, 32px 0 0 #28c840; }
.appearance-preview-mark { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 7px; background: var(--accent-fill); color: var(--on-accent); font-size: 11px; }
.appearance-preview-tab { margin-left: auto; padding-bottom: 2px; border-bottom: 2px solid var(--accent); color: var(--text-secondary); }
.appearance-preview-content { display: grid; grid-template-columns: minmax(180px,.72fr) minmax(260px,1.28fr); min-height: 148px; }
.appearance-preview-controls { display: flex; flex-direction: column; align-items: flex-start; gap: 11px; padding: 18px; border-right: 1px solid var(--line); font-family: var(--preview-app-font); color: var(--text-secondary); font-size: 12px; }
.appearance-preview-line { width: 82%; height: 8px; border-radius: 99px; background: var(--line); }
.appearance-preview-line.short { width: 54%; }
.appearance-preview-controls label { display: flex; align-items: center; gap: 6px; }
.appearance-preview-controls input { accent-color: var(--accent-fill); }
.appearance-preview-controls button { margin-top: auto; padding: 6px 10px; border: 1px solid var(--accent-fill); border-radius: 7px; background: var(--accent-fill); color: var(--on-accent); font-family: inherit; font-size: 12px; }
.appearance-preview-paper { padding: 18px 20px; background: var(--paper); color: var(--ink); font-family: var(--preview-reader-font); }
.appearance-preview-paper strong { font-size: 17px; }
.appearance-preview-paper p { margin: 9px 0 0; font-size: 15px; line-height: 1.65; }
/* AppKit-proportioned switch: pill track, white knob with a soft drop, and a
   springy slide. */
.settings-toggle input[type="checkbox"] { position: relative; flex: 0 0 auto; width: 40px; height: 24px; margin: 0; appearance: none; border: 0; border-radius: 999px; outline: 0; background: color-mix(in srgb, var(--ink) 16%, var(--line)); cursor: pointer; transition: background var(--motion-panel) ease; box-shadow: inset 0 1px 2px rgba(0,0,0,.10); }
.settings-toggle input[type="checkbox"]::after { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 .5px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.22); content:""; transition: transform var(--motion-panel) var(--motion-ease-spring); }
.settings-toggle input[type="checkbox"]:checked { background: var(--accent-fill); }
.settings-toggle input[type="checkbox"]:checked::after { transform: translateX(16px); }
.settings-toggle input[type="checkbox"]:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.ai-advanced-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.ai-advanced-settings > summary { color: var(--text-secondary); font-size: 13px; cursor: pointer; }
.ai-advanced-settings[open] > summary { margin-bottom: 12px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 14px; margin-top: 10px; }
.shortcut-grid label,.settings-field { display: grid; gap: 6px; color: var(--text-secondary); font-size: 13px; }
.shortcut-grid input,.settings-field input,.settings-field select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: var(--paper); color: var(--ink); font: inherit; font-size: 13px; box-shadow: 0 1px 2px rgba(28,39,49,.05); transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease; }
.shortcut-grid input:focus-visible,.settings-field input:focus-visible,.settings-field select:focus-visible,.settings-select-field select:focus-visible { border-color: var(--accent); outline: 3px solid color-mix(in srgb,var(--accent) 32%,transparent); outline-offset: 0; }
.shortcut-grid input { cursor: default; font-variant-numeric: tabular-nums; }
.shortcut-grid input.is-capturing { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.shortcut-grid input.is-invalid { border-color: #c44f45; background: color-mix(in srgb,#c44f45 6%,var(--paper)); }
.shortcut-status { display: block; min-height: 19px; margin-top: 9px; color: var(--muted); font-size: 11.5px; }
.shortcut-status.is-error { color: #a5424c; }
.settings-field { margin-top: 16px; }
.settings-field-with-action { gap: 6px; }
.settings-field-with-action > label { color: var(--text-secondary); font-size: 13px; }
.settings-input-action { display: grid; min-width: 0; grid-template-columns: minmax(0,1fr) auto; align-items: stretch; gap: 8px; }
.settings-input-action input { min-width: 0; }
.settings-clear-key { min-width: 56px; min-height: 40px; margin-top: 0; padding: 8px 11px; }
.settings-field select { padding-right: 34px; cursor: pointer; }
.settings-field-hint { margin: 8px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.settings-field small { color: var(--muted); font-size: 11px; }
.settings-inline-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.settings-library-location { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin: 10px 0 2px; padding: 14px 15px; border: 1px solid color-mix(in srgb,var(--accent) 22%,var(--line)); border-radius: 11px; background: color-mix(in srgb,var(--accent-soft) 36%,var(--paper)); }
.settings-library-location-copy { display: grid; min-width: 0; gap: 3px; }
.settings-library-location-copy strong { color: var(--ink); font-size: 14px; }
.settings-library-location-copy small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.settings-library-location-copy code { max-width: min(660px,60vw); margin-top: 7px; overflow: hidden; color: var(--text-secondary); font-family: ui-monospace,"SFMono-Regular",Menlo,Consolas,monospace; font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; user-select: text; -webkit-user-select: text; }
.settings-library-location-actions { display: grid; flex: 0 0 auto; justify-items: end; gap: 6px; }
.settings-library-location-actions small { max-width: 220px; color: var(--muted); font-size: 11px; line-height: 1.4; text-align: right; }
.settings-library-location.is-migrating { border-color: color-mix(in srgb,var(--accent) 55%,var(--line)); }
.settings-library-location.is-error { border-color: color-mix(in srgb,#c44f45 55%,var(--line)); }
.parsing-provider-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); border-top: 1px solid var(--line); }
.parsing-provider-card { min-width: 0; padding: 16px 16px 2px 0; }
.parsing-provider-card + .parsing-provider-card { padding-right: 0; padding-left: 16px; border-left: 1px solid var(--line); }
.parsing-provider-heading { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; }
.parsing-provider-heading h3,.parsing-provider-heading p { margin: 0; }
.parsing-provider-heading h3 { color: var(--ink); font-size: 14px; }
.parsing-provider-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.parsing-provider-facts { margin: 14px 0 0; }
.parsing-provider-facts > div { display: grid; min-width: 0; grid-template-columns: max-content minmax(0,1fr); align-items: baseline; gap: 12px; padding-top: 9px; border-top: 1px solid var(--line); }
.parsing-provider-facts dt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.parsing-provider-facts dd { min-width: 0; margin: 0; color: var(--text-secondary); font-size: 12px; font-weight: 650; overflow-wrap: anywhere; text-align: right; }
.parsing-provider-detail { min-height: 36px; margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.parsing-provider-card.is-error .parsing-provider-detail { color: #a5424c; }
.parsing-provider-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.parsing-provider-actions .compact-button { min-height: 34px; }
.danger-button { border-color: color-mix(in srgb,#c44f45 48%,var(--line)); color: #a5424c; }
.danger-button:hover { border-color: #c44f45; background: color-mix(in srgb,#c44f45 8%,var(--paper)); }
.component-progress { display: grid; gap: 7px; margin-top: 13px; }
.component-progress > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--text-secondary); font-size: 11.5px; }
.component-progress strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.component-progress span { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.update-summary-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.update-summary-grid > div { display: grid; gap: 5px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb,var(--soft) 60%,var(--paper)); }
.update-summary-grid span { color: var(--muted); font-size: 11px; }
.update-summary-grid strong { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.update-status-card { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; align-items: center; gap: 13px; margin-top: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: color-mix(in srgb,var(--soft) 44%,var(--paper)); }
.update-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-tertiary); }
.update-status-copy { display: grid; min-width: 0; gap: 3px; }
.update-status-copy strong { font-size: 14px; }
.update-status-copy small,.update-status-copy time { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.update-status-copy time:empty { display: none; }
.update-status-actions { display: flex; align-items: center; gap: 8px; }
.update-status-card.is-checking .update-status-dot { background: var(--accent); animation: settings-save-pulse .8s ease-in-out infinite alternate; }
.update-status-card.is-current .update-status-dot { background: #2e9b6b; }
.update-status-card.is-available { border-color: color-mix(in srgb,var(--accent) 38%,var(--line)); background: color-mix(in srgb,var(--accent-soft) 34%,var(--paper)); }
.update-status-card.is-available .update-status-dot { background: var(--accent-fill); }
.update-status-card.is-error .update-status-dot { background: #c44f45; }
.update-release-details { display: grid; gap: 9px; margin-top: 12px; padding: 14px; border: 1px solid color-mix(in srgb,var(--accent) 24%,var(--line)); border-radius: 10px; background: color-mix(in srgb,var(--accent-soft) 30%,var(--paper)); }
.update-release-details > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.update-release-details strong { font-size: 14px; }
.update-release-details small { color: var(--muted); font-size: 11px; }
.update-release-details p { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.update-release-details code { overflow: hidden; color: var(--text-tertiary); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.ai-service-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.ai-credentials-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.ai-credential-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb,var(--soft) 60%,var(--paper)); }
.ai-credential-heading { display: grid; grid-template-columns: 34px minmax(0,1fr); align-items: center; gap: 10px; margin-bottom: 4px; }
.ai-credential-heading h3,.ai-credential-heading p { margin: 0; }
.ai-credential-heading h3 { color: var(--ink); font-size: 14px; }
.ai-credential-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.ai-credential-card .settings-field { margin-top: 12px; }
.ai-credential-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ai-credential-actions .compact-button { min-height: 34px; padding: 7px 10px; font-size: 12px; }
.ai-model-picker { display: grid; gap: 8px; margin-top: 10px; padding: 10px; border: 1px solid color-mix(in srgb,var(--accent) 24%,var(--line)); border-radius: 9px; background: color-mix(in srgb,var(--accent-soft) 32%,var(--paper)); }
.ai-model-picker .settings-field { margin-top: 0; }
.ai-model-picker select { width: 100%; min-height: 108px; padding: 5px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: var(--paper); color: var(--ink); font-size: 12px; }
.ai-model-picker select:focus-visible { border-color: var(--accent); outline: 2px solid color-mix(in srgb,var(--accent) 28%,transparent); outline-offset: 1px; }
.ai-model-picker small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.source-attribution-row { align-items: flex-start; margin-top: 14px !important; }
.source-attribution-row .secondary-button { margin-top: 0; text-decoration: none; }
.ai-service-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb,var(--soft) 60%,var(--paper)); }
.ai-service-card-heading { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; }
.ai-service-icon { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); font-size: 12px; font-weight: 750; }
.ai-service-card h3,.ai-service-card p { margin: 0; }
.ai-service-card h3 { color: var(--ink); font-size: 14px; }
.ai-service-card-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.ai-service-status { padding: 4px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.ai-service-status.is-ready { background: color-mix(in srgb,#2e9b6b 14%,var(--paper)); color: #237953; }
.ai-service-status.is-unavailable { background: color-mix(in srgb,#c44f45 12%,var(--paper)); color: #a53f37; }
.ai-service-status.is-unknown { background: color-mix(in srgb,var(--text-tertiary) 10%,var(--paper)); color: var(--text-tertiary); }
.ai-service-status.is-loading { background: color-mix(in srgb,var(--accent) 12%,var(--paper)); color: var(--accent-dark); }
.ai-service-card dl { margin: 14px 0 0; }
.ai-service-card dl > div { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.ai-service-card dt { color: var(--muted); font-size: 12px; }
.ai-service-card dd { min-width: 0; margin: 0; overflow: hidden; color: var(--text-secondary); font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.ai-service-result { margin-top: 10px !important; padding-top: 9px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }
.ai-service-result.is-success { color: #237953; }
.ai-service-result.is-error { color: #a53f37; }
.ai-status-overview { display: grid; grid-template-columns: 13px minmax(0,1fr) auto; align-items: center; gap: 12px; margin-bottom: 12px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--soft); }
.ai-status-overview-dot { width: 11px; height: 11px; border: 2px solid color-mix(in srgb,var(--text-tertiary) 42%,transparent); border-radius: 50%; background: var(--text-tertiary); box-shadow: 0 0 0 4px color-mix(in srgb,var(--text-tertiary) 9%,transparent); }
.ai-status-overview h3,.ai-status-overview p { margin: 0; }
.ai-status-overview h3 { color: var(--ink); font-size: 14px; }
.ai-status-overview p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.ai-status-overview time { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; }
.ai-status-overview.is-operational { border-color: color-mix(in srgb,#2e9b6b 30%,var(--line)); background: color-mix(in srgb,#2e9b6b 7%,var(--paper)); }
.ai-status-overview.is-operational .ai-status-overview-dot { border-color: color-mix(in srgb,#2e9b6b 42%,transparent); background: #2e9b6b; box-shadow: 0 0 0 4px color-mix(in srgb,#2e9b6b 11%,transparent); }
.ai-status-overview.is-partial { border-color: color-mix(in srgb,#d0872f 34%,var(--line)); background: color-mix(in srgb,#d0872f 8%,var(--paper)); }
.ai-status-overview.is-partial .ai-status-overview-dot { border-color: color-mix(in srgb,#d0872f 42%,transparent); background: #d0872f; box-shadow: 0 0 0 4px color-mix(in srgb,#d0872f 11%,transparent); }
.ai-status-overview.is-outage { border-color: color-mix(in srgb,#c44f45 34%,var(--line)); background: color-mix(in srgb,#c44f45 7%,var(--paper)); }
.ai-status-overview.is-outage .ai-status-overview-dot { border-color: color-mix(in srgb,#c44f45 42%,transparent); background: #c44f45; box-shadow: 0 0 0 4px color-mix(in srgb,#c44f45 11%,transparent); }
.ai-status-history { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.ai-status-history-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ai-status-history-heading strong { color: var(--ink); font-size: 13px; }
.ai-status-history-heading small { color: var(--text-tertiary); font-size: 11px; }
.ai-status-history ol { display: grid; gap: 0; margin: 8px 0 0; padding: 0; list-style: none; }
.ai-status-history li { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; align-items: center; gap: 9px; min-height: 34px; padding: 7px 2px; border-top: 1px solid color-mix(in srgb,var(--line) 72%,transparent); color: var(--text-secondary); font-size: 12px; }
.ai-status-history li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); }
.ai-status-history li.is-operational::before { background: #2e9b6b; }
.ai-status-history li.is-partial::before { background: #d0872f; }
.ai-status-history li.is-outage::before { background: #c44f45; }
.ai-status-history li time { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; }
.ai-status-history .ai-status-history-empty { display: block; color: var(--muted); }
.ai-status-history .ai-status-history-empty::before { display: none; }
.ai-status-history-pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }
.ai-status-history-pagination .compact-button { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.ai-status-history-pagination span { min-width: 68px; color: var(--muted); font-size: 11px; text-align: center; }
@media(max-width:980px) {
  .settings-product { --settings-sidebar-width: 210px; grid-template-columns: 210px minmax(0,1fr); gap: 16px; }
  .settings-navigation { padding-inline: 10px; }
  .settings-control-grid { grid-template-columns: 1fr; }
  .ai-credentials-grid { grid-template-columns: 1fr; }
  .parsing-provider-grid { grid-template-columns: 1fr; }
  .parsing-provider-card { padding-right: 0; }
  .parsing-provider-card + .parsing-provider-card { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .settings-accent-row { display: block !important; }
  .settings-accent-options { margin-top: 12px; }
  .appearance-preview-content { grid-template-columns: minmax(150px,.65fr) minmax(220px,1.35fr); }
}
@media(max-width:700px) {
  .settings-product { display: block; }
  .settings-product::before { display: none; }
  .settings-navigation { position: static; max-height: none; padding: 16px 0 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-navigation-heading { padding: 0 2px; }
  .settings-navigation-links { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
  .settings-navigation a { min-height: 36px; padding: 7px 10px; font-size: 13px; }
  .settings-product-form { gap: 10px; margin-top: 18px; padding: 0; }
  .settings-page-heading { padding: 0 2px 8px; }
  .settings-page-heading h1 { font-size: 24px; }
  .settings-section { padding: 18px; }
  .shortcut-grid,.ai-service-grid { grid-template-columns: 1fr; }
  .update-summary-grid { grid-template-columns: 1fr; }
  .update-status-card { grid-template-columns: 10px minmax(0,1fr); }
  .update-status-actions { grid-column: 2; flex-wrap: wrap; }
  .settings-library-location { align-items: stretch; flex-direction: column; }
  .settings-library-location-copy code { max-width: 100%; }
  .settings-library-location-actions { justify-items: start; }
  .settings-library-location-actions small { max-width: none; text-align: left; }
  .parsing-provider-heading { grid-template-columns: 34px minmax(0,1fr); }
  .parsing-provider-heading .ai-service-status { grid-column: 2; justify-self: start; }
  .ai-status-overview { grid-template-columns: 13px minmax(0,1fr); }
  .ai-status-overview time { grid-column: 2; }
  .appearance-preview-content { grid-template-columns: 1fr; }
  .appearance-preview-controls { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* Keep the assistant beside the reading surface on wide screens. */
#reader-view { --reader-assistant-width: 380px; }
.reader-action-bar { grid-template-columns: minmax(0,1fr) auto; transition: grid-template-columns var(--motion-panel) var(--motion-ease-out); }
#reader-view:has(.reader-sidebar.is-open) .reader-action-bar { grid-template-columns: minmax(0,1fr) var(--reader-assistant-width); }
.reader-actions { grid-column: 1; grid-row: 1; }
.reader-heading { grid-column: 2; grid-row: 1; border-right: 0; border-left: 1px solid var(--line); }
.reader-grid { grid-template-columns: minmax(0,1fr) 0; }
.reader-grid:has(.reader-sidebar.is-open) { grid-template-columns: minmax(0,1fr) var(--reader-assistant-width); }
.reader-frame-wrap { grid-column: 1; grid-row: 1; }
.reader-sidebar { grid-column: 2; grid-row: 1; border-right: 0; border-left: 1px solid var(--line); box-shadow: none; transform: translateX(18px); }
.reader-sidebar.is-open { transform: translateX(0); }
.sidebar-caption { justify-content: flex-start; }
@media(max-width:880px) {
  .reader-action-bar,#reader-view:has(.reader-sidebar.is-open) .reader-action-bar { grid-template-columns: minmax(0,1fr) auto; }
  .reader-grid,.reader-grid:has(.reader-sidebar.is-open) { grid-template-columns: minmax(0,1fr); }
  .reader-frame-wrap { grid-column: 1; }
  .reader-sidebar { grid-column: 1; left: auto; right: 0; border-left: 1px solid var(--line); border-right: 0; transform: translateX(calc(100% + 20px)); }
  .reader-sidebar.is-open { transform: translateX(0); }
  .reader-sidebar-resizer { display: none; }
}
.secondary-button:hover, .tiny-button:hover, .toolbar-icon-button:hover { border-color: color-mix(in srgb,var(--accent) 44%,var(--line)); background: var(--accent-soft); color: var(--accent-dark); }
.action-button:hover, .action-button.active { border-color: color-mix(in srgb,var(--accent) 36%,var(--line)); background: var(--accent-soft); color: var(--accent-dark); }
.action-icon { color: var(--accent); }
.translation-progress { border-color: color-mix(in srgb,var(--accent) 34%,var(--line)); background: color-mix(in srgb,var(--accent-soft) 70%,var(--paper)); color: var(--accent-dark); }
.translation-progress-track { background: color-mix(in srgb,var(--accent-soft) 72%,var(--line)); }
.translation-progress-bar, .progress-bar { background: var(--accent-fill); }
.toast { border-color: color-mix(in srgb,var(--accent) 34%,var(--line)); color: var(--accent-dark); }
.drop-overlay { border-color: color-mix(in srgb,var(--accent) 70%,transparent); background: color-mix(in srgb,var(--accent-soft) 78%,transparent); color: var(--accent-dark); }
.chat-bubble.user { background: var(--accent-soft); color: var(--accent-dark); }
.outline-item:hover { background: var(--accent-soft); color: var(--accent-dark); }
.chat-form textarea:focus, .notes-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 16%,transparent); }
.typography-popover { position: fixed; top: 0; left: 0; right: auto; z-index: 120; }

@media (prefers-color-scheme: dark) {
  :root { --accent: #f3b34c; --accent-dark: #ffd07a; --accent-soft: #3a2b16; --accent-fill: #b45309; --accent-fill-hover: #92400e; --on-accent: #fff; --user-highlight: #f3b34c; }
  .app-header, .reader-action-bar { background: var(--material-bar); }
  .secondary-button:hover, .tiny-button:hover, .toolbar-icon-button:hover { background: var(--accent-soft); border-color: color-mix(in srgb,var(--accent) 42%,var(--line)); color: var(--accent-dark); }
  .translation-progress { border-color: color-mix(in srgb,var(--accent) 34%,var(--line)); background: color-mix(in srgb,var(--accent-soft) 68%,var(--paper)); color: var(--accent-dark); }
  .translation-progress-track { background: color-mix(in srgb,var(--accent-soft) 72%,var(--line)); }
  .toast, .selection-popover { border-color: color-mix(in srgb,var(--accent) 30%,var(--line)); background: var(--material-overlay); color: var(--ink); }
  .chat-bubble.user { background: var(--accent-soft); color: var(--accent-dark); }
  .notes-editor, .chat-form textarea { background: var(--paper); color: var(--ink); }
  .drop-overlay { background: color-mix(in srgb,var(--accent-soft) 88%,transparent); }
  .tag-chip { background: color-mix(in srgb,var(--accent) 20%,transparent); color: var(--accent-dark); }
  .ai-service-status.is-ready,.ai-service-result.is-success { color: #6ee7b7; }
  .ai-service-status.is-unavailable,.ai-service-result.is-error { color: #fca5a5; }
  .row-more-menu button.is-danger:hover,.row-more-menu button.is-danger:focus-visible { background: #3b2020; color: #ffb6b6; }
  .column-delete-button:hover,.column-delete-button:focus-visible { background: #3b2020; color: #ffb6b6; }
}

@media (max-width: 960px) {
  #library-editor-dialog:has(.columns-editor) { width: calc(100vw - 24px); height: calc(100vh - 24px); }
  #library-editor-dialog:has(.columns-editor) form { padding: 20px; }
  .columns-editor { grid-template-areas: "intro" "existing" "creator"; grid-template-columns: minmax(0,1fr); }
  .column-creator { position: static; }
}

@media (max-width: 700px) {
  #library-editor-dialog:has(.columns-editor) form { padding: 17px; }
  .columns-editor-intro,.columns-editor-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .columns-editor-intro span { white-space: normal; }
  .columns-list { grid-template-columns: minmax(0,1fr); }
}

/* Library interaction controls. Keep these controls on the same warm, quiet
   visual language as the rest of the shell instead of exposing browser UI. */
.library-grouping-heading { align-items: center; }
.grouping-select-button { min-width: 86px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); color: var(--text-secondary); font-size: 12px; text-align: center; }
.grouping-select-button:hover,.grouping-select-button[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.library-grouping-list { position: relative; display: grid; gap: 6px; margin: 9px 8px 0; }
.grouping-field-menu { position: fixed; z-index: 1; display: grid; max-height: min(360px,calc(100vh - 16px)); gap: 2px; overflow-y: auto; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--material-overlay); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop); transform-origin: top left; animation: menu-pop var(--motion-fast) var(--motion-ease-spring); }
.grouping-field-menu[data-placement="top"] { transform-origin: bottom left; }
.grouping-option,.grouping-value { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); font-size: 12px; text-align: left; }
.grouping-option:hover,.grouping-option:focus-visible,.grouping-option.active,.grouping-value:hover,.grouping-value:focus-visible,.grouping-value.active { background: var(--accent-soft); color: var(--accent-dark); outline: none; }
.grouping-option span:first-child,.grouping-value span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grouping-value-list { display: grid; gap: 2px; }
.grouping-value b { min-width: 20px; color: var(--text-tertiary); font-size: 11px; text-align: right; }
.grouping-empty { padding: 5px 8px; color: var(--text-tertiary); font-size: 11px; }
.library-column-header { position: relative; display: flex; min-width: 0; align-items: center; gap: 4px; }
.library-column-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-resizer { position: absolute; z-index: 2; top: -7px; right: -7px; bottom: -7px; width: 14px; padding: 0; border: 0; border-right: 2px solid transparent; background: transparent; cursor: col-resize; }
.column-resizer:hover,.column-resizer:focus-visible,.column-resizer.is-active { border-right-color: var(--accent); outline: 0; }
.library-actions-header { min-width: 40px; }
body.resizing-library-column, body.resizing-library-column * { cursor: col-resize !important; }
.library-drag-ghost { position: fixed; z-index: 200; max-width: 280px; padding: 8px 11px; border: 1px solid var(--accent); border-radius: 8px; background: var(--paper); box-shadow: 0 12px 28px rgba(42,31,20,.22); color: var(--ink); font-size: 12px; pointer-events: none; transform: translateZ(0); }
.library-row.is-dragging { opacity: .48; outline: 2px dashed var(--accent); outline-offset: -3px; }
.library-drop-target { background: var(--accent-soft) !important; color: var(--accent-dark) !important; outline: 2px solid var(--accent); outline-offset: -2px; }
.columns-list { gap: 7px; }
.column-option { display: grid !important; grid-template-columns: 24px 24px minmax(0,1fr) 30px; align-items: center; gap: 9px; min-height: 68px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb,var(--soft) 84%,var(--paper)); }
.column-option:hover,.column-option:focus-within { border-color: color-mix(in srgb,var(--accent) 52%,var(--line)); background: color-mix(in srgb,var(--accent-soft) 30%,var(--paper)); }
.column-option.is-dragging { opacity: .55; border-style: dashed; }
.column-grip { padding: 3px; border: 0; background: transparent; color: var(--text-tertiary); font-size: 15px; letter-spacing: -3px; cursor: grab; }
.column-grip:active { cursor: grabbing; }
.column-visibility { display: inline-flex !important; width: 21px; height: 21px; align-items: center; justify-content: center; margin: 0 !important; cursor: pointer; }
.column-visibility { position: relative; }
/* Keep the native checkbox in the hit-testing tree.  The custom mark is
   visual-only, while Playwright, keyboard users and assistive technology can
   still toggle the actual input. */
.column-visibility input { position: absolute; inset: 0; z-index: 2; width: 21px !important; height: 21px !important; min-height: 21px !important; margin: 0; padding: 0 !important; opacity: .01; pointer-events: auto; cursor: pointer; }
.column-visibility-toggle input { position: relative; z-index: 2; width: 19px !important; height: 19px !important; min-height: 19px !important; margin: 0; padding: 0 !important; opacity: .01; pointer-events: auto; cursor: pointer; }
.column-visibility .custom-check,.column-visibility-toggle .custom-check { pointer-events: none; }
.custom-check { display: inline-flex; width: 19px; height: 19px; align-items: center; justify-content: center; border: 1px solid var(--text-tertiary); border-radius: 5px; color: transparent; font-size: 13px; font-weight: 800; }
.column-visibility input:checked + .custom-check,.column-visibility-toggle input:checked + .custom-check { border-color: var(--accent-fill); background: var(--accent-fill); color: var(--on-accent); }
.column-option-main { display: grid; min-width: 0; gap: 3px; }
.column-option-main .column-label-input { min-width: 0; }
.column-delete-button,.column-delete-spacer { width: 30px; height: 30px; }
.column-delete-button { display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--text-tertiary); cursor: pointer; }
.column-delete-button svg { width: 17px; height: 17px; }
.column-delete-button:hover,.column-delete-button:focus-visible { outline: 0; background: #fff1e5; color: #a34b15; }
.column-delete-button:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.column-delete-button:disabled { opacity: .45; cursor: wait; }
.column-visibility-toggle { position: relative; align-items: center; }

/* Motion follows one restrained paper-lift gesture across app surfaces. */
.view.active-view { animation: scholar-view-enter 100ms ease-out backwards; }
/* The outgoing view keeps painting for one short exit, laid over the
   incoming one, so a page change dissolves instead of cutting. */
.view.is-leaving { position: absolute; z-index: 1; top: 24px; right: 22px; left: 22px; display: block; pointer-events: none; animation: scholar-view-exit 100ms ease-out both; }
body.reader-mode .view.is-leaving { top: 0; right: 0; left: 0; }
/* Switching the library between its list and its graph slides the new
   surface in the way a settings pane does. */
.library-surface-entering { animation: scholar-panel-enter var(--motion-panel) var(--motion-ease-out) both; }
.sidebar-panel.active-panel { animation: scholar-panel-enter var(--motion-panel) var(--motion-ease-out) both; }
.document-tab.is-entering { animation: scholar-tab-enter var(--motion-panel) var(--motion-ease-out) both; }
.document-tab.is-closing { animation: scholar-tab-exit var(--motion-fast) var(--motion-ease-exit) both; pointer-events: none; }
#html-preview { opacity: 1; transition: opacity 100ms ease-out; }
#reader-view.is-document-loading #html-preview { opacity: 0; visibility: hidden; pointer-events: none; }

/* Dialogs present like macOS sheets: they settle in with a decelerating
   drop while the backdrop dims, and slip away on close. */
.library-dialog,.metadata-dialog {
  opacity: 0;
  transform: translateY(14px) scale(.97);
  transition: opacity var(--motion-panel) var(--motion-ease-out), transform var(--motion-panel) var(--motion-ease-out), overlay var(--motion-panel) allow-discrete, display var(--motion-panel) allow-discrete;
}
.library-dialog[open],.metadata-dialog[open] { opacity: 1; transform: translateY(0) scale(1); }
.library-dialog::backdrop,.metadata-dialog::backdrop {
  opacity: 0;
  transition: opacity var(--motion-panel) ease, overlay var(--motion-panel) allow-discrete, display var(--motion-panel) allow-discrete;
}
.library-dialog[open]::backdrop,.metadata-dialog[open]::backdrop { opacity: 1; }

@starting-style {
  .library-dialog[open],.metadata-dialog[open] { opacity: 0; transform: translateY(14px) scale(.97); }
  .library-dialog[open]::backdrop,.metadata-dialog[open]::backdrop { opacity: 0; }
}

@keyframes scholar-view-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scholar-view-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes scholar-panel-enter {
  from { opacity: 0; transform: translateX(6px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes scholar-tab-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scholar-tab-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes scholar-lightbox-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes scholar-image-enter {
  from { opacity: 0; transform: scale(.975); }
  to { opacity: 1; transform: scale(1); }
}

:is(.app-header,.reader-action-bar,.typography-popover,.translation-progress,.toast,.reader-search,.selection-popover,.row-more-menu,.image-context-menu,.grouping-field-menu,.chat-session-menu,.graph-property-options,.graph-node-tooltip,.graph-legend) { -webkit-backdrop-filter: var(--material-filter); }
.image-lightbox { -webkit-backdrop-filter: blur(7px); }

@supports not (backdrop-filter: blur(1px)) {
  :root { --material-bar: var(--paper); --material-overlay: var(--paper); --material-filter: none; }
  .image-lightbox { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(7,8,10,.94); }
}

@keyframes menu-pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes rise-in-centered { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  .view.active-view,.settings-section.is-active,.sidebar-panel.active-panel,.document-tab.is-entering,.document-tab.is-closing,.image-lightbox,.image-lightbox-content,.selection-popover { animation: none !important; }
  .library-dialog,.metadata-dialog { opacity: 1; transform: none; }
  .library-dialog::backdrop,.metadata-dialog::backdrop { opacity: 1; }
}

/* Read-only showcase: every write/AI affordance disappears; browsing,
   reading and cached translations remain. */
.readonly-mode :is(#import-pdf-button, #import-zotero-button, #setting-import-zotero, #create-folder-button, .folder-actions, #manage-views-button, #columns-button, .nav-settings, [data-view="market-view"], [data-plugin-nav], #reflow-button, #new-chat-session, #open-chat-history, .sidebar-tab[data-panel="chat-panel"], .sidebar-tab[data-panel="highlights-panel"], .sidebar-tab[data-panel="annotations-panel"], .sidebar-tab[data-panel="notes-panel"], #chat-panel, #highlights-panel, #annotations-panel, #notes-panel, #full-translate-button, #auto-highlight-button, #share-button, .chat-form, .selection-popover, .details-edit-button, .details-actions button:not([data-details-action="open"]), .highlight-card-actions, .annotation-meta button, .notes-tools, .row-more-button) { display: none !important; }
.readonly-mode :is(.details-stars button, .details-status-select, .row-cell-button) { pointer-events: none; }
.readonly-preview-badge { display: none; }
.readonly-mode .readonly-preview-badge { display: inline-flex; flex: 0 0 auto; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--text-secondary); background: var(--soft); font-size: 11px; white-space: nowrap; }

/* Relationship graph: a library mode that keeps the existing folder and
   details columns while replacing the table with an explorable network. */
.library-graph-surface { min-width: 0; }
.graph-header-actions .search-box { width: min(260px,26vw); }
.graph-toolbar { position: relative; z-index: 5; display: flex; min-height: 44px; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 8px 10px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--paper); color: var(--text-secondary); font-size: 12px; }
.graph-toolbar-group { display: inline-flex; align-items: center; gap: 6px; }
.graph-toggle { position: relative; display: inline-flex; min-height: 30px; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); cursor: pointer; }
.graph-toggle:hover { border-color: color-mix(in srgb,var(--accent) 42%,var(--line)); color: var(--accent-dark); }
.graph-toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent-fill); }
.graph-similarity-switch input { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.graph-switch-track { position: relative; width: 24px; height: 14px; border: 1px solid color-mix(in srgb,var(--text-tertiary) 55%,var(--line)); border-radius: 999px; background: var(--paper); transition: border-color var(--motion-fast) var(--motion-ease-out),background-color var(--motion-fast) var(--motion-ease-out); }
.graph-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--text-tertiary); transition: transform var(--motion-fast) var(--motion-ease-out),background-color var(--motion-fast) var(--motion-ease-out); }
.graph-similarity-switch input:checked + .graph-switch-track { border-color: var(--accent-fill); background: var(--accent-fill); }
.graph-similarity-switch input:checked + .graph-switch-track::after { background: var(--on-accent); transform: translateX(10px); }
.graph-similarity-switch:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb,var(--accent) 18%,transparent); }
.graph-property-picker { position: relative; }
.graph-property-picker > summary { min-height: 30px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); color: var(--text-secondary); cursor: pointer; list-style: none; }
.graph-property-picker > summary::-webkit-details-marker { display: none; }
.graph-property-picker > summary::after { content: "⌄"; margin-left: 6px; color: var(--text-tertiary); }
.graph-property-picker[open] > summary { border-color: color-mix(in srgb,var(--accent) 46%,var(--line)); color: var(--accent-dark); }
.graph-property-options { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: grid; width: 230px; max-height: 310px; gap: 2px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--material-overlay); box-shadow: var(--shadow-pop); backdrop-filter: var(--material-filter); }
.graph-property-option { display: flex; min-height: 32px; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 6px; color: var(--text-secondary); cursor: pointer; }
.graph-property-option:hover { background: var(--accent-soft); color: var(--accent-dark); }
.graph-property-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent-fill); }
.graph-property-option small { margin-left: auto; color: var(--text-tertiary); font-size: 10.5px; }
.graph-zoom-control { display: inline-grid; min-height: 30px; grid-template-columns: auto 76px 34px; align-items: center; gap: 7px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); color: var(--text-secondary); white-space: nowrap; }
.graph-zoom-control input[type="range"] { width: 76px; margin: 0; accent-color: var(--accent-fill); cursor: pointer; }
.graph-zoom-control output { color: var(--text-tertiary); font-size: 10.5px; font-variant-numeric: tabular-nums; text-align: right; }
.graph-drag-hint { color: var(--text-tertiary); white-space: nowrap; }
.graph-stats { min-width: 0; margin-left: auto; color: var(--text-tertiary); white-space: nowrap; }
.graph-stage { position: relative; height: clamp(500px,calc(100vh - 232px),760px); min-height: 500px; overflow: hidden; border: 1px solid var(--line); border-radius: 0 0 10px 10px; background: radial-gradient(circle at 50% 45%,color-mix(in srgb,var(--accent-soft) 24%,var(--paper)) 0,var(--paper) 62%); }
.library-graph-canvas { position: absolute; inset: 0; width: 100%; height: 100%; outline: 0; }
.library-graph-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.graph-node-tooltip { position: absolute; z-index: 8; max-width: min(340px,calc(100% - 24px)); padding: 7px 10px; border: 1px solid color-mix(in srgb,var(--accent) 28%,var(--line)); border-radius: 8px; background: var(--material-overlay); box-shadow: var(--shadow-pop); color: var(--ink); font-family: var(--reader-content-font-family); font-size: 11px; font-weight: 620; line-height: 1.45; text-align: center; overflow-wrap: anywhere; pointer-events: none; transform: translate(-50%,-100%); backdrop-filter: var(--material-filter); }
.graph-node-tooltip.graph-node-tooltip-below { transform: translate(-50%,0); }
.library-graph-status { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; gap: 5px; padding: 32px; color: var(--text-secondary); text-align: center; line-height: 1.6; }
.library-graph-status strong { color: var(--ink); font-size: 15px; }
.library-graph-status span { max-width: 420px; font-size: 12px; }
.graph-empty { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; padding: 30px; background: color-mix(in srgb,var(--paper) 88%,transparent); color: var(--text-secondary); text-align: center; line-height: 1.7; }
.graph-legend { position: absolute; z-index: 3; bottom: 12px; left: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; max-width: calc(100% - 24px); padding: 7px 9px; border: 1px solid color-mix(in srgb,var(--line) 70%,transparent); border-radius: 8px; background: var(--material-overlay); color: var(--text-tertiary); font-size: 10.5px; backdrop-filter: var(--material-filter); pointer-events: none; }
.graph-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-node { display: inline-block; width: 11px; height: 11px; border-radius: 50%; }
.legend-paper { border: 2px solid var(--accent-dark); background: var(--paper); }
.legend-attribute { border: 1px solid color-mix(in srgb,var(--accent) 44%,var(--line)); border-radius: 3px; background: var(--accent-soft); }
.legend-line { display: inline-block; width: 18px; border-top: 2px solid var(--text-tertiary); }
.legend-similarity { border-top-style: dashed; border-top-color: var(--accent); }
.graph-accessible-results { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--text-secondary); font-size: 12px; }
.graph-accessible-results > summary { padding: 8px 10px; cursor: pointer; }
.graph-accessible-list { display: grid; max-height: 190px; overflow-y: auto; padding: 0 8px 8px; }
.graph-accessible-list button { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text-secondary); text-align: left; }
.graph-accessible-list button:hover,.graph-accessible-list button:focus-visible { outline: 0; background: var(--accent-soft); color: var(--accent-dark); }
.graph-detail-kicker { margin: 0 0 5px; color: var(--accent-dark); font-size: 10.5px; font-weight: 720; letter-spacing: .05em; text-transform: uppercase; }
.graph-connection-card { margin-top: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.graph-connection-card strong,.graph-related-paper strong { display: block; color: var(--ink); }
.graph-connection-card p { margin: 5px 0 0; color: var(--text-secondary); line-height: 1.55; }
.graph-related-list { display: grid; gap: 4px; margin-top: 10px; }
.graph-related-paper { padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--text-secondary); text-align: left; }
.graph-related-paper:hover { border-color: color-mix(in srgb,var(--accent) 40%,var(--line)); background: var(--accent-soft); }

@media (prefers-color-scheme: dark) {
  .graph-stage { background: radial-gradient(circle at 50% 45%,color-mix(in srgb,var(--accent-soft) 34%,var(--paper)) 0,var(--paper) 66%); }
  .graph-toolbar,.graph-accessible-results { background: var(--paper); }
}

/* ---------------------------------------------------------------- mobile
   Phones and tablets share one code path with the desktop; the layout
   collapses to a single column with an off-canvas sidebar and a details
   sheet, and touch targets grow to the 44px Apple minimum. */
.mobile-sidebar-toggle { display: none; width: 34px; height: 34px; padding: 0; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); }
.mobile-sidebar-toggle svg { width: 20px; height: 20px; }
.library-scrim { display: none; }

@supports (padding: max(0px)) {
  .app-header { padding-left: max(28px, env(safe-area-inset-left)); padding-right: max(28px, env(safe-area-inset-right)); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 860px) {
  .mobile-sidebar-toggle { display: inline-flex; }
  .app-header { gap: 10px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .desktop-macos .app-header { padding-left: max(12px, env(safe-area-inset-left)); }
  .brand-mark span { display: none; }
  .app-shell { padding: 12px 12px 28px; }

  /* Library: one column; the sidebar slides over content on demand. */
  .library-layout { position: relative; display: block; min-height: 0; }
  .library-layout > .library-main { padding-inline: 0; border-left: 0; border-right: 0; }
  .library-sidebar {
    position: fixed; z-index: 60; top: 60px; bottom: 0; left: 0;
    width: min(300px, 82vw); max-height: none; padding: 16px 14px 24px;
    border-right: 1px solid var(--line); background: var(--material-overlay);
    -webkit-backdrop-filter: var(--material-filter); backdrop-filter: var(--material-filter);
    box-shadow: 12px 0 34px rgba(31,43,54,.18);
    transform: translateX(-102%); transition: transform var(--motion-panel) var(--motion-ease-out);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  body.sidebar-open .library-sidebar { transform: translateX(0); }
  body.sidebar-open .library-scrim { display: block; position: fixed; z-index: 55; inset: 60px 0 0; background: rgba(16,20,24,.42); }
  .library-main { padding-top: 0; }
  .library-main-heading { display: block; margin-bottom: 10px; }
  .library-main-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
  .library-main-actions .search-box { min-width: 0; flex: 1 1 100%; }
  #library-sort, #library-status-filter, #columns-button { flex: 1 1 auto; }
  .library-columns { display: none; }
  .graph-header-actions .search-box { width: auto; }
  .graph-stage { height: max(440px,calc(100vh - 250px)); min-height: 440px; }
  .graph-toolbar { align-items: flex-start; }
  .graph-zoom-control { min-height: 44px; max-width: 100%; padding-block: 0; }
  .graph-zoom-control input[type="range"] { height: 44px; }
  .graph-drag-hint { width: 100%; white-space: normal; }
  .graph-stats { width: 100%; margin-left: 0; }
  /* Rows become two-line cards: everything else lives in the sheet. */
  .library-table-scroll { overflow-x: hidden; }
  .library-column-header:first-child, .library-row-name { position: static; margin-left: 0; padding-left: 0; }
  .library-row { display: flex; min-width: 0; min-height: 62px; align-items: center; gap: 10px; padding: 10px 4px; }
  .library-row > *:not(.library-row-name):not(.library-row-actions) { display: none; }
  .library-row-name { flex: 1; }
  .library-row-name strong { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .library-row-actions { position: static; flex: 0 0 auto; opacity: 1; }
  .row-more-button { display: inline-flex; width: 34px; height: 34px; }

  /* Reader: full-bleed page, assistant already uses a drawer above. */
  .reader-action-bar { grid-template-columns: minmax(0,1fr) auto; }
  .reader-heading { padding-left: 8px; }

  /* Settings: navigation becomes a horizontal chip row. */
  .settings-product { display: block; }
  .settings-product::before { display: none; }
  .settings-navigation { position: static; max-height: none; padding: 4px 0 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-navigation-heading { display: none; }
  .settings-navigation-links { display: flex; gap: 6px; overflow-x: auto; margin-top: 0; -webkit-overflow-scrolling: touch; }
  .settings-navigation a { flex: 0 0 auto; min-height: 34px; border: 1px solid var(--line); border-radius: 999px; }
  .settings-product-form { margin-top: 14px; padding: 0; }
  .settings-section { padding: 16px 14px; }
  .settings-control-grid { grid-template-columns: minmax(0,1fr); }

  /* iOS zooms the page when a focused field is under 16px. */
  input, textarea, select { font-size: 16px; }
  .search-box input { font-size: 16px; }

  /* Touch targets: Apple's 44px minimum for anything tappable. */
  .system-filter, .folder-button, .grouping-option, .grouping-value, .details-status-select, .sidebar-tab { min-height: 40px; }
  .grouping-option { min-height: 44px; }
  .details-stars button { min-width: 34px; min-height: 34px; font-size: 20px; }
  .dialog-close { width: 40px; height: 40px; }
}

@media (max-width: 520px) {
  .details-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .details-actions button { width: 100%; }
  .library-details { padding-inline: 14px; }
  .toast { right: 12px; left: 12px; bottom: calc(16px + env(safe-area-inset-bottom) + var(--background-tasks-offset, 0px)); max-width: none; }
  .background-tasks { right: 12px; left: 12px; width: auto; bottom: calc(16px + env(safe-area-inset-bottom)); }
}


@media (max-width: 1119px) {
  /* Details become a bottom sheet raised by a selection. */
  .library-details {
    position: fixed; z-index: 70; inset: auto 0 0 0; top: auto;
    max-height: min(76vh, 620px); padding: 16px 18px calc(22px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); border-left: 0;
    border-radius: 16px 16px 0 0; background: var(--material-overlay);
    -webkit-backdrop-filter: var(--material-filter); backdrop-filter: var(--material-filter); box-shadow: var(--shadow-pop);
    transform: translateY(102%); transition: transform var(--motion-panel) var(--motion-ease-out);
  }
  .library-details-close { position: absolute; z-index: 2; top: 15px; right: 14px; display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--material-overlay); color: var(--text-secondary); font-size: 22px; line-height: 1; }
  .library-details-close:hover,.library-details-close:focus-visible { border-color: color-mix(in srgb,var(--accent) 40%,var(--line)); background: var(--accent-soft); color: var(--accent-dark); }
  .library-details { padding-top: 54px; }
  body.details-open .library-details { transform: translateY(0); }
  .library-details::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; border-radius: 99px; background: color-mix(in srgb, var(--text-tertiary) 45%, transparent); transform: translateX(-50%); }
  .library-details h2 { margin-top: 8px; }
  .details-field { grid-template-columns: 72px minmax(0,1fr); }
}

/* Coarse pointers get no hover-only affordances. */
@media (hover: none) {
  .folder-actions, .chat-copy { opacity: 1; }
  .library-row-actions { opacity: 1; }
}

/* First-launch guide. It uses the same material and accent tokens as the app,
   while the native dialog keeps the rest of the window inert and focus-safe. */
.onboarding-dialog {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0;
  overflow: hidden; border: 0; background: transparent; color: var(--ink);
}
.onboarding-dialog::backdrop { background: color-mix(in srgb, #111827 34%, transparent); -webkit-backdrop-filter: blur(18px) saturate(130%); backdrop-filter: blur(18px) saturate(130%); }
.onboarding-dialog[open] { display: grid; place-items: center; padding: 30px 32px; animation: onboarding-backdrop-in 260ms ease-out both; }
.onboarding-dialog.is-closing { opacity: 0; transition: opacity var(--motion-fast) var(--motion-ease-exit); }
.onboarding-surface {
  position: relative; display: grid; width: min(980px,calc(100vw - 64px)); height: min(690px,calc(100vh - 60px)); min-height: 600px;
  grid-template-rows: auto auto minmax(0,1fr) auto auto; overflow: hidden;
  border: 1px solid color-mix(in srgb,var(--line) 76%,transparent); border-radius: 24px;
  background:
    radial-gradient(circle at 8% 10%,color-mix(in srgb,var(--accent-soft) 76%,transparent),transparent 34%),
    color-mix(in srgb,var(--paper) 89%,transparent);
  -webkit-backdrop-filter: blur(34px) saturate(180%); backdrop-filter: blur(34px) saturate(180%);
  box-shadow: 0 1px 0 rgba(255,255,255,.55) inset,0 30px 90px rgba(17,24,39,.26);
  animation: onboarding-window-in 340ms var(--motion-ease-out) both;
}
.onboarding-surface::after { content: ""; position: absolute; z-index: -1; right: -110px; bottom: -150px; width: 360px; height: 360px; border-radius: 50%; background: color-mix(in srgb,var(--accent) 9%,transparent); filter: blur(4px); }
.onboarding-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 78px; padding: 21px 28px 15px; }
.onboarding-brand { display: flex; align-items: center; gap: 11px; }
.onboarding-brand picture { display: block; width: 35px; height: 35px; flex: 0 0 35px; }
.onboarding-brand img { display: block; width: 100%; height: 100%; object-fit: contain; }
.onboarding-brand span { display: grid; gap: 1px; }
.onboarding-brand strong { font-size: 14px; letter-spacing: .01em; }
.onboarding-brand small { color: var(--text-tertiary); font-size: 11px; }
.onboarding-skip { padding: 7px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--text-tertiary); font-size: 12px; font-weight: 600; transition: background-color var(--motion-fast),color var(--motion-fast); }
.onboarding-skip:hover,.onboarding-skip:focus-visible { background: var(--accent-soft); color: var(--accent-dark); }
.onboarding-progress-row { display: flex; align-items: center; gap: 12px; padding: 0 28px 9px; color: var(--text-tertiary); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.onboarding-progress { width: 104px; height: 3px; overflow: hidden; border-radius: 99px; background: color-mix(in srgb,var(--line) 78%,transparent); }
.onboarding-progress span { display: block; width: 25%; height: 100%; border-radius: inherit; background: var(--accent-fill); transition: width 260ms var(--motion-ease-out); }
.onboarding-stage { position: relative; display: grid; min-height: 0; padding: 0 28px; }
.onboarding-slide {
  grid-area: 1 / 1; display: grid; min-height: 0; grid-template-columns: minmax(300px,.9fr) minmax(0,1.1fr); align-items: center; gap: clamp(34px,5vw,70px);
  visibility: hidden; opacity: 0; pointer-events: none; transform: translateX(34px) scale(.985);
  transition: opacity 240ms ease,transform 280ms var(--motion-ease-out),visibility 0s linear 280ms;
}
.onboarding-slide.is-before { transform: translateX(-34px) scale(.985); }
.onboarding-slide.is-after { transform: translateX(34px) scale(.985); }
.onboarding-slide.is-active { visibility: visible; opacity: 1; pointer-events: auto; transform: translateX(0) scale(1); transition-delay: 0s; }
.onboarding-library-recovery { display: grid; gap: 11px; margin-top: 18px; padding: 12px 13px; border: 1px solid color-mix(in srgb,var(--accent) 28%,var(--line)); border-radius: 10px; background: color-mix(in srgb,var(--accent-soft) 38%,var(--paper)); }
.onboarding-library-recovery > div:first-child { display: grid; gap: 3px; }
.onboarding-library-recovery strong { font-size: 12.5px; }
.onboarding-library-recovery small { color: var(--text-secondary); font-size: 11px; line-height: 1.45; }
.onboarding-library-recovery.is-warning { border-color: color-mix(in srgb,#c8872d 52%,var(--line)); background: color-mix(in srgb,#c8872d 9%,var(--paper)); }
.onboarding-library-conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.onboarding-library-conflict-actions button { min-height: 34px; }
.onboarding-visual { position: relative; display: grid; min-height: 350px; place-items: center; overflow: hidden; border: 1px solid color-mix(in srgb,var(--line) 70%,transparent); border-radius: 21px; background: linear-gradient(145deg,color-mix(in srgb,var(--accent-soft) 82%,var(--paper)),color-mix(in srgb,var(--paper) 92%,transparent)); box-shadow: 0 12px 34px color-mix(in srgb,var(--ink) 8%,transparent); }
.onboarding-welcome-visual::before { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; background: color-mix(in srgb,var(--accent) 10%,transparent); filter: blur(1px); }
.onboarding-hero-logo { position: relative; z-index: 2; display: block; width: 122px; height: 122px; padding: 21px; border: 1px solid color-mix(in srgb,var(--line) 66%,transparent); border-radius: 31px; background: color-mix(in srgb,var(--paper) 80%,transparent); box-shadow: 0 18px 46px color-mix(in srgb,var(--ink) 12%,transparent); transform: rotate(-2deg); }
.onboarding-hero-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.onboarding-orbit { position: absolute; z-index: 1; border: 1px solid color-mix(in srgb,var(--accent) 24%,transparent); border-radius: 50%; }
.onboarding-orbit.orbit-one { width: 260px; height: 186px; transform: rotate(22deg); }
.onboarding-orbit.orbit-two { width: 206px; height: 274px; transform: rotate(-31deg); }
.onboarding-floating-chip { position: absolute; z-index: 3; padding: 7px 10px; border: 1px solid color-mix(in srgb,var(--line) 68%,transparent); border-radius: 999px; background: color-mix(in srgb,var(--paper) 78%,transparent); box-shadow: 0 8px 24px color-mix(in srgb,var(--ink) 8%,transparent); color: var(--text-secondary); font-size: 10.5px; font-weight: 650; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.onboarding-floating-chip.chip-library { top: 48px; left: 35px; }
.onboarding-floating-chip.chip-reading { top: 92px; right: 25px; }
.onboarding-floating-chip.chip-graph { right: 44px; bottom: 47px; }
.onboarding-illustration { display: block; width: 88%; height: auto; max-height: 300px; }
.onboarding-svg-soft { fill: color-mix(in srgb,var(--paper) 70%,transparent); stroke: color-mix(in srgb,var(--accent) 30%,var(--line)); stroke-width: 2; }
.onboarding-svg-line { stroke: color-mix(in srgb,var(--text-tertiary) 36%,transparent); stroke-width: 2.2; stroke-linecap: round; }
.onboarding-svg-dashed { stroke: color-mix(in srgb,var(--accent) 28%,transparent); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 6 8; }
.onboarding-svg-card { fill: color-mix(in srgb,var(--paper) 84%,transparent); stroke: color-mix(in srgb,var(--accent) 52%,var(--line)); stroke-width: 2; }
.onboarding-svg-accent { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.onboarding-svg-node { fill: color-mix(in srgb,var(--paper) 90%,var(--accent-soft)); stroke: color-mix(in srgb,var(--accent) 64%,var(--line)); stroke-width: 3; }
.onboarding-graph-illustration .onboarding-svg-node:nth-of-type(2) { fill: color-mix(in srgb,var(--accent-soft) 78%,var(--paper)); }
.onboarding-ready-visual { background: radial-gradient(circle at 50% 42%,color-mix(in srgb,var(--accent) 13%,transparent),transparent 48%),linear-gradient(145deg,color-mix(in srgb,var(--accent-soft) 72%,var(--paper)),var(--paper)); }
.onboarding-ready-card { position: relative; display: grid; width: min(250px,80%); justify-items: center; gap: 6px; padding: 38px 24px 31px; border: 1px solid color-mix(in srgb,var(--line) 74%,transparent); border-radius: 20px; background: color-mix(in srgb,var(--paper) 84%,transparent); box-shadow: 0 20px 55px color-mix(in srgb,var(--ink) 13%,transparent); text-align: center; }
.onboarding-ready-card picture { display: block; width: 70px; height: 70px; margin-bottom: 8px; }
.onboarding-ready-card img { display: block; width: 100%; height: 100%; object-fit: contain; }
.onboarding-ready-card strong { font-size: 15px; }
.onboarding-ready-card small { color: var(--text-tertiary); font-size: 11px; }
.onboarding-ready-check { position: absolute; top: -14px; right: -12px; display: grid; width: 38px; height: 38px; place-items: center; border: 4px solid var(--paper); border-radius: 50%; background: #299a73; color: #fff; font-size: 17px; font-weight: 800; box-shadow: 0 8px 18px rgba(41,154,115,.2); }
.onboarding-copy { min-width: 0; padding-right: 4px; }
.onboarding-kicker { display: block; margin-bottom: 11px; color: var(--accent-dark); font-size: 10px; font-weight: 760; letter-spacing: .13em; }
.onboarding-copy h1 { margin: 0; font-size: clamp(30px,3.4vw,43px); line-height: 1.12; letter-spacing: -.045em; }
.onboarding-copy h1:focus { outline: 0; }
.onboarding-copy > p { max-width: 500px; margin: 17px 0 0; color: var(--text-secondary); font-size: 14px; line-height: 1.75; }
.onboarding-points { display: grid; gap: 10px; margin: 25px 0 0; padding: 0; list-style: none; color: var(--text-secondary); font-size: 12px; }
.onboarding-points li { display: grid; grid-template-columns: 27px minmax(0,1fr); align-items: baseline; gap: 10px; }
.onboarding-points span { color: var(--accent); font-size: 9.5px; font-weight: 780; font-variant-numeric: tabular-nums; letter-spacing: .07em; }
.onboarding-footer { display: grid; min-height: 78px; grid-template-columns: 130px 1fr 130px; align-items: center; gap: 18px; padding: 13px 28px 21px; border-top: 1px solid color-mix(in srgb,var(--line) 68%,transparent); }
.onboarding-footer .primary-button,.onboarding-footer .secondary-button { min-height: 38px; margin: 0; }
.onboarding-back { justify-self: start; }
.onboarding-next { min-width: 122px; justify-self: end; }
.onboarding-dots { display: flex; justify-content: center; gap: 7px; }
.onboarding-dots span { width: 6px; height: 6px; border-radius: 999px; background: color-mix(in srgb,var(--text-tertiary) 30%,transparent); transition: width 220ms var(--motion-ease-out),background-color 220ms ease; }
.onboarding-dots span.is-active { width: 19px; background: var(--accent); }
.onboarding-status { margin: -14px 28px 13px; color: #bd3b47; font-size: 11px; text-align: right; }
@supports not (backdrop-filter: blur(1px)) {
  .onboarding-dialog::backdrop { background: rgba(17,24,39,.52); }
  .onboarding-surface,.onboarding-floating-chip { -webkit-backdrop-filter: none; backdrop-filter: none; background-color: var(--paper); }
}
@media (max-width: 760px) {
  .onboarding-dialog[open] { padding: 12px; }
  .onboarding-surface { width: calc(100vw - 24px); height: calc(100vh - 24px); min-height: 0; border-radius: 18px; overflow-y: auto; }
  .onboarding-header { min-height: 64px; padding: 15px 17px 10px; }
  .onboarding-progress-row { padding: 0 17px 7px; }
  .onboarding-stage { padding: 0 17px; }
  .onboarding-slide { grid-template-columns: 1fr; align-content: start; gap: 19px; padding: 7px 0 20px; }
  .onboarding-visual { min-height: 210px; }
  .onboarding-hero-logo { width: 88px; height: 88px; padding: 15px; border-radius: 23px; }
  .onboarding-orbit.orbit-one { width: 210px; height: 130px; }
  .onboarding-orbit.orbit-two { width: 150px; height: 196px; }
  .onboarding-floating-chip.chip-library { top: 28px; left: 18px; }
  .onboarding-floating-chip.chip-reading { top: 55px; right: 15px; }
  .onboarding-floating-chip.chip-graph { right: 25px; bottom: 22px; }
  .onboarding-illustration { max-height: 205px; }
  .onboarding-copy h1 { font-size: clamp(28px,8vw,38px); }
  .onboarding-copy > p { margin-top: 11px; }
  .onboarding-points { gap: 7px; margin-top: 15px; }
  .onboarding-footer { position: sticky; bottom: 0; min-height: 67px; grid-template-columns: 92px 1fr 112px; padding: 12px 17px; background: color-mix(in srgb,var(--paper) 90%,transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
}
@media (prefers-reduced-motion: reduce) {
  .onboarding-dialog[open],.onboarding-surface { animation: none !important; }
  .onboarding-dialog.is-closing { transition: none !important; }
  .onboarding-slide { transition: none !important; }
}
@keyframes onboarding-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes onboarding-window-in { from { opacity: 0; transform: translateY(13px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

.reader-action-bar { position: relative; }
.reader-progress-track { position: absolute; z-index: 2; right: 0; bottom: -1px; left: 0; height: 2px; overflow: hidden; background: color-mix(in srgb,var(--line) 55%,transparent); pointer-events: none; }
.reader-progress-bar { width: 100%; height: 100%; background: var(--accent-fill); transform: scaleX(0); transform-origin: left center; transition: transform 120ms linear; }
.outline-item.active,.outline-item[aria-current="location"] { background: color-mix(in srgb,var(--accent-soft) 76%,var(--paper)); color: var(--accent-dark); font-weight: 680; }
.reader-chapter-rail { position: absolute; z-index: 3; top: 10px; bottom: 10px; left: 8px; width: 34px; color: var(--text-secondary); pointer-events: none; }
.reader-chapter-rail-toggle { position: relative; z-index: 2; display: none; width: 34px; height: 34px; align-items: center; gap: 8px; overflow: hidden; padding: 0 9px; border: 1px solid color-mix(in srgb,var(--line) 82%,transparent); border-radius: 9px; background: color-mix(in srgb,var(--paper) 90%,transparent); color: inherit; box-shadow: 0 5px 16px rgba(30,42,54,.08); backdrop-filter: blur(16px) saturate(145%); cursor: pointer; pointer-events: auto; transition: width var(--motion-panel) var(--motion-ease-out),background-color var(--motion-fast) ease,box-shadow var(--motion-fast) ease; }
.reader-chapter-rail-toggle:hover,.reader-chapter-rail-toggle:focus-visible { border-color: color-mix(in srgb,var(--accent) 42%,var(--line)); color: var(--accent-dark); outline: none; }
.reader-chapter-rail-icon { display: grid; width: 14px; flex: 0 0 14px; gap: 3px; }
.reader-chapter-rail-icon i { display: block; height: 1.5px; border-radius: 99px; background: currentColor; }
.reader-chapter-rail-icon i:nth-child(2) { width: 10px; }
.reader-chapter-rail-icon i:nth-child(3) { width: 7px; }
.reader-chapter-rail-label { overflow: hidden; opacity: 0; font-size: var(--toolbar-font-size); font-weight: 680; white-space: nowrap; transition: opacity var(--motion-fast) ease; }
.reader-chapter-list { position: absolute; top: 0; bottom: 0; left: 0; display: flex; width: 34px; flex-direction: column; justify-content: safe center; gap: 0; overflow: hidden auto; padding: 3px; border: 1px solid transparent; border-radius: 10px; pointer-events: auto; scrollbar-width: none; }
.reader-chapter-list::-webkit-scrollbar { display: none; }
.reader-chapter-list-item { display: flex; min-width: 0; min-height: 8px; max-height: 8px; flex: 0 0 8px; }
.reader-chapter-item { display: flex; width: 26px; height: 100%; min-height: 0; align-items: center; gap: 7px; overflow: visible; padding: 0 2px; border: 0; border-radius: 4px; background: transparent; color: var(--text-tertiary); text-align: left; cursor: pointer; transition: background-color var(--motion-fast) ease,color var(--motion-fast) ease; }
.reader-chapter-dot { width: var(--reader-section-bar-width,16px); min-width: var(--reader-section-bar-width,16px); height: 2px; flex: 0 0 auto; margin-left: var(--reader-section-rail-indent,0px); border-radius: 99px; background: currentColor; opacity: .56; transform-origin: left center; transition: width var(--motion-fast) ease,opacity var(--motion-fast) ease,transform var(--motion-fast) ease,background-color var(--motion-fast) ease; }
.reader-chapter-title { display: none; overflow: hidden; flex: 1; opacity: 0; font-family: var(--app-font); font-size: var(--toolbar-font-size); line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; transition: opacity var(--motion-fast) ease; }
.reader-chapter-item:hover,.reader-chapter-item:focus-visible { background: var(--accent-soft); color: var(--accent-dark); outline: none; }
.reader-chapter-item.active,.reader-chapter-item[aria-current="location"] { color: var(--accent-dark); }
.reader-chapter-item:hover .reader-chapter-dot,.reader-chapter-item:focus-visible .reader-chapter-dot { opacity: .82; }
.reader-chapter-item.active .reader-chapter-dot,.reader-chapter-item[aria-current="location"] .reader-chapter-dot { background: var(--accent-fill); opacity: 1; transform: scaleX(1.16); }
@media(min-width:881px) {
  .reader-chapter-list-item:has(> .reader-chapter-item:is(:hover,:focus-visible)) > .reader-chapter-item > .reader-chapter-dot { opacity: 1; transform: translateX(6px) scaleX(1.3); }
  .reader-chapter-list-item:has(+ .reader-chapter-list-item > .reader-chapter-item:is(:hover,:focus-visible)) > .reader-chapter-item > .reader-chapter-dot,
  .reader-chapter-list-item:has(> .reader-chapter-item:is(:hover,:focus-visible)) + .reader-chapter-list-item > .reader-chapter-item > .reader-chapter-dot { opacity: .84; transform: translateX(4px) scaleX(1.16); }
  .reader-chapter-list-item:has(+ .reader-chapter-list-item + .reader-chapter-list-item > .reader-chapter-item:is(:hover,:focus-visible)) > .reader-chapter-item > .reader-chapter-dot,
  .reader-chapter-list-item:has(> .reader-chapter-item:is(:hover,:focus-visible)) + .reader-chapter-list-item + .reader-chapter-list-item > .reader-chapter-item > .reader-chapter-dot { opacity: .7; transform: translateX(2px) scaleX(1.06); }
}
.reader-chapter-tooltip { position: fixed; z-index: 6; max-width: min(320px,calc(100vw - 24px)); padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: color-mix(in srgb,var(--paper) 96%,transparent); color: var(--ink); box-shadow: 0 10px 28px rgba(30,42,54,.16); backdrop-filter: blur(18px) saturate(150%); font-family: var(--app-font); font-size: 13px; font-weight: 560; line-height: 1.45; white-space: normal; pointer-events: none; animation: menu-pop var(--motion-fast) var(--motion-ease-spring); }

@media(max-width:880px) {
  .reader-chapter-rail { top: 8px; bottom: 8px; left: 7px; width: 40px; }
  .reader-chapter-rail-toggle { display: flex; width: 40px; height: 40px; padding: 0 12px; }
  .reader-chapter-list { top: 46px; bottom: auto; width: min(260px,calc(100vw - 24px)); max-height: calc(100% - 46px); justify-content: flex-start; gap: 2px; overflow-y: auto; padding: 6px; border-color: var(--line); background: color-mix(in srgb,var(--paper) 97%,transparent); box-shadow: 0 12px 32px rgba(30,42,54,.16); opacity: 0; visibility: hidden; transform: translateX(-5px); pointer-events: none; scrollbar-width: thin; transition: opacity var(--motion-fast) ease,transform var(--motion-fast) ease,visibility var(--motion-fast) ease; }
  .reader-chapter-list-item { min-height: 44px; max-height: none; flex: 0 0 auto; }
  .reader-chapter-item { width: 100%; height: auto; min-height: 44px; padding-right: 9px; padding-left: calc(9px + var(--reader-section-indent,0px)); }
  .reader-chapter-title { display: block; opacity: 1; }
  .reader-chapter-tooltip { display: none !important; }
  .reader-chapter-rail:not(.is-open):is(:hover,:focus-within) .reader-chapter-rail-toggle { width: 40px; }
  .reader-chapter-rail:not(.is-open):is(:hover,:focus-within) .reader-chapter-rail-label { opacity: 0; }
  .reader-chapter-rail:not(.is-open):is(:hover,:focus-within) .reader-chapter-list { opacity: 0; visibility: hidden; transform: translateX(-5px); pointer-events: none; }
  .reader-chapter-rail.is-open .reader-chapter-rail-toggle { width: min(260px,calc(100vw - 24px)); }
  .reader-chapter-rail.is-open .reader-chapter-list { width: min(260px,calc(100vw - 24px)); opacity: 1; visibility: visible; transform: translateX(0); pointer-events: auto; }
  .reader-chapter-rail.is-open .reader-chapter-item { width: 100%; }
}
@media(min-width:881px) {
  /* Keep the collapsed progress markers on one left baseline; hierarchy is
     communicated by their lengths, while the expanded/mobile list keeps its
     title indentation. */
  .reader-chapter-dot { margin-left: 0; }
}
@media(prefers-reduced-motion:reduce) {
  .reader-progress-bar,.reader-chapter-rail-toggle,.reader-chapter-list,.reader-chapter-item,.reader-chapter-dot,.reader-chapter-title,.reader-chapter-rail-label,.reader-chapter-tooltip { animation: none !important; transition: none !important; }
}

/* Tabs keep touchpad and keyboard scrolling without a permanent horizontal bar. */
.document-tabs { scrollbar-width: none; }
.document-tabs::-webkit-scrollbar { display: none; }
:is(.library-sidebar,.settings-navigation,.settings-content,.sidebar-panel,.chat-messages,.chat-history-list,.reader-chapter-list,.library-table-scroll) { scrollbar-width: thin; scrollbar-color: color-mix(in srgb,var(--ink) 28%,transparent) transparent; }
:is(.library-sidebar,.settings-navigation,.settings-content,.sidebar-panel,.chat-messages,.chat-history-list,.reader-chapter-list,.library-table-scroll)::-webkit-scrollbar { width: 7px; height: 7px; }
:is(.library-sidebar,.settings-navigation,.settings-content,.sidebar-panel,.chat-messages,.chat-history-list,.reader-chapter-list,.library-table-scroll)::-webkit-scrollbar-thumb { border-width: 1px; }
.background-tasks { position: relative; inset: auto; z-index: 29; width: 100%; max-height: min(220px,25vh); overflow: auto; gap: 4px; padding: 5px 18px; border-bottom: 1px solid var(--line); background: var(--material-bar); }
.background-tasks-cards { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.background-tasks .translation-progress { flex: 1 1 320px; min-width: 0; padding: 6px 10px; border-radius: 7px; box-shadow: none; animation: none; }
.background-tasks .translation-progress-main { gap: 3px; }
.background-tasks .translation-progress-dots { display: none; }
.background-tasks .translation-progress-track { height: 3px; }
.background-tasks-toggle { position: relative; padding: 2px 8px; font-size: 10px; }
body.reader-mode .app-shell { height: calc(100vh - 60px - var(--background-tasks-height,0px)); }
.translation-language-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.annotation-action-settings { container-type: inline-size; margin-top: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.annotation-action-settings h3 { margin: 0; font-size: 13.5px; font-weight: 590; }
.annotation-action-settings > .settings-field-hint { margin: 4px 0 0; font-size: 12px; }
.annotation-builtin-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0 24px; margin: 10px 0 12px; }
.annotation-builtin-options .settings-toggle { min-width: 0; gap: 12px; padding: 8px 0; border: 0; font-size: 13px; }
.annotation-custom-heading { flex-wrap: wrap; gap: 12px; }
.annotation-custom-heading > div { flex: 1 1 180px; }
#add-annotation-action { flex: 0 0 auto; min-height: 32px; padding: 5px 10px; font-size: 12px; }
#setting-annotation-custom { display: grid; gap: 8px; }
.annotation-action-row { display: grid; grid-template-columns: minmax(120px,1fr) 92px 32px 82px 32px; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.annotation-action-row input[type="text"],.annotation-action-row select { width: 100%; min-width: 0; height: 32px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: var(--ink); background: var(--paper); font: 13px/1.45 var(--app-font); box-shadow: 0 1px 2px rgba(28,39,49,.05); }
.annotation-action-row input[type="text"]::placeholder { color: var(--text-tertiary); }
.annotation-action-style { position: relative; min-width: 0; }
.annotation-action-style select { appearance: none; padding-right: 26px; cursor: pointer; }
.annotation-action-style::after { position: absolute; top: 11px; right: 11px; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); pointer-events: none; content: ""; }
.annotation-action-row input[type="color"] { appearance: none; width: 32px; height: 32px; padding: 3px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer; }
.annotation-action-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.annotation-action-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.annotation-action-row input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }
.annotation-action-row :is(input[type="text"],input[type="color"],select):focus-visible { border-color: var(--accent); outline: 3px solid color-mix(in srgb,var(--accent) 32%,transparent); outline-offset: 0; }
.annotation-action-row .annotation-action-enabled { gap: 8px; padding: 0; border: 0; font-size: 12px; }
.annotation-action-remove { width: 32px; height: 32px; padding: 7px; }
.annotation-action-remove svg { width: 16px; height: 16px; }
@container (max-width:540px) {
  .annotation-builtin-options { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 16px; }
  .annotation-action-row { grid-template-columns: minmax(80px,1fr) 32px 82px 32px; }
  .annotation-action-name { grid-column: 1 / -1; }
}
@container (max-width:300px) { .annotation-builtin-options { grid-template-columns: minmax(0,1fr); } }
.semantic-action-swatch { display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; margin-right: 6px; border-radius: 50%; background: var(--semantic-color); }
#selection-custom-actions { flex-wrap: wrap; gap: 6px; max-height: 112px; overflow: auto; padding: 8px 12px; border-top: 1px solid var(--line); background: color-mix(in srgb,var(--soft) 60%,transparent); }
#selection-custom-actions::before { content: '标记'; margin-right: 2px; color: var(--muted); font-size: .86em; }
#selection-custom-actions button { max-width: min(240px,100%); min-height: 28px; padding: 4px 8px; border-color: color-mix(in srgb,var(--semantic-color) 20%,transparent); border-radius: 6px; background: color-mix(in srgb,var(--semantic-color) 7%,var(--paper)); color: var(--ink); font-weight: 400; }
#selection-custom-actions button:not(:disabled):hover { border-color: color-mix(in srgb,var(--semantic-color) 44%,transparent); background: color-mix(in srgb,var(--semantic-color) 14%,var(--paper)); color: var(--ink); }
#translation-provider-test-result { font-size: 11px; overflow-wrap: anywhere; }
@media (max-width:600px) { .background-tasks { padding-inline: 8px; } }

.ai-inference-controls { margin-top: 12px; padding-top: 2px; border-top: 1px solid var(--line); }
.chat-session-options { flex: 0 0 auto; margin: 0 12px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; }
.chat-session-options > summary { cursor: pointer; padding: 8px; color: var(--ink); }
.chat-session-options > summary span { color: var(--muted); margin-left: 6px; }
.chat-options-fields { padding: 0 10px 10px; max-height: 260px; overflow-y: auto; }
.chat-options-fields .settings-field { margin-top: 8px; font-size: 11px; }
.chat-options-fields input, .chat-options-fields select { min-width: 0; width: 100%; }
.chat-context-status { flex: 0 0 auto; margin: 0 14px 8px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.settings-field-hint.error { color: #bd3b47; }

.zotero-import-dialog { width: min(820px,calc(100vw - 28px)); }
.zotero-dialog-shell { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); padding: 22px; }
.zotero-dialog-shell .dialog-heading { flex: 0 0 auto; }
.zotero-dialog-content { min-height: 0; overflow-y: auto; padding: 0 3px 2px 0; }
.zotero-dialog-shell .dialog-actions { justify-content: space-between; }
.zotero-target,.zotero-dialog-shell .dialog-actions > span { color: var(--muted); font-size: 11px; }
.zotero-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.zotero-filters label,.zotero-attachment-field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.zotero-import-dialog select,.zotero-search input { width: 100%; min-width: 0; min-height: 34px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); font: inherit; font-size: 12px; }
.zotero-search { display: flex; gap: 8px; margin: 12px 0; }
.zotero-search input { flex: 1; }
.zotero-search button { flex: 0 0 auto; }
.zotero-items { display: grid; gap: 8px; }
.zotero-item { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.zotero-item.is-unavailable { opacity: .75; }
.zotero-item-heading { display: flex; align-items: flex-start; gap: 8px; }
.zotero-item-heading input { flex: 0 0 auto; margin-top: 2px; accent-color: var(--accent); }
.zotero-item-heading label { color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.zotero-item-meta,.zotero-item-tags,.zotero-item-reason { margin: 6px 0 0 24px; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.zotero-item-reason { color: var(--accent-dark); }
.zotero-attachment-field { margin: 10px 0 0 24px; }
.zotero-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0; color: var(--muted); font-size: 11px; }
.zotero-empty { padding: 16px 8px; color: var(--muted); font-size: 12px; }
.zotero-batch { padding-top: 14px; border-top: 1px solid var(--line); }
.zotero-batch > p { font-size: 12px; color: var(--ink); }
.zotero-batch progress { width: 100%; accent-color: var(--accent); }
.zotero-batch ol { display: grid; gap: 8px; padding: 0; list-style: none; }
.zotero-result { display: grid; gap: 4px; padding: 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; overflow-wrap: anywhere; }
.zotero-result span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.zotero-result.is-failed span { color: #bd3b47; }
@media(max-width: 600px) { .zotero-dialog-shell { padding: 16px; } .zotero-filters { grid-template-columns: 1fr; } .zotero-dialog-shell .dialog-actions { align-items: stretch; flex-direction: column; } }

#zotero-selection-actions { flex-wrap: wrap; justify-content: flex-start; }
.zotero-results { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }

.market-layout { max-width: 1120px; margin: 0 auto; padding: 30px 32px 70px; }
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.market-card,.market-install-card { border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 22px; }
.market-card { display: flex; flex-direction: column; }
.market-card-heading,.market-card-actions,.market-install-controls,.market-preview-heading { display: flex; align-items: center; gap: 10px; }
.market-card-heading h3 { margin: 0; font-size: 18px; }
.market-badge { margin-left: auto; color: var(--accent-dark); background: var(--accent-soft); border-radius: 5px; padding: 2px 7px; font-size: 11px; white-space: nowrap; }
.market-card-version { color: var(--muted); font-size: 11px; margin-top: 5px; overflow-wrap: anywhere; }
.market-card p { color: var(--text-secondary); font-size: 13px; }
.market-permissions { display: grid; gap: 5px; font-size: 12px; color: var(--muted); margin: 17px 0; }
.market-card-actions { flex-wrap: wrap; margin-top: auto; padding-top: 20px; }
.market-card-actions button { height: 34px; min-height: 34px; min-width: 64px; margin: 0; padding: 7px 12px; font-size: 13px; font-weight: 600; line-height: 1; }
.market-card[data-draft] .market-card-actions button { width: 80px; }
.market-install-card h2 { font-size: 17px; margin: 0 0 15px; }
.market-install-controls { flex-wrap: wrap; margin-bottom: 12px; }
#market-github-form { display: flex; flex: 1; gap: 8px; min-width: 240px; }
#market-github-url,#market-github-sha256 { width: 100%; min-width: 100px; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; background: var(--canvas); color: var(--ink); }
#market-github-form button { flex-shrink: 0; }
.market-section-title { font-size: 17px; margin: 30px 0 14px; }
.market-preview-layout { max-width: 1280px; margin: 0 auto; padding: 26px 32px 50px; }
.market-preview-heading { justify-content: space-between; align-items: flex-start; gap: 24px; }
.market-preview-heading h1 { margin: 5px 0 8px; font-size: 24px; overflow-wrap: anywhere; }
.market-preview-actions { display: flex; gap: 10px; flex-shrink: 0; }
.market-preview-actions button { width: 96px; height: 34px; margin: 0; padding: 7px 12px; font-size: 13px; line-height: 1; }
.market-preview-info { margin: 16px 0; padding: 10px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.market-preview-info p { margin: 5px 0; }
#settings-mcp-scopes { display: flex; flex-wrap: wrap; gap: 12px 20px; border: 1px solid var(--line); padding: 15px; border-radius: 8px; margin: 16px 0; font-size: 13px; }
#settings-mcp-scopes legend { color: var(--muted); padding: 0 5px; font-size: 12px; }
#settings-mcp-scopes label { display: flex; align-items: center; gap: 5px; }
.settings-mcp-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.settings-mcp-connection { max-height: 240px; overflow: auto; padding: 12px; border-radius: 8px; background: var(--canvas); color: var(--text-secondary); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.plugin-frame { display: block; width: 100%; height: calc(100vh - 64px); min-height: 500px; border: 0; background: var(--canvas); }
#market-preview .plugin-frame { height: max(500px, calc(100vh - 310px)); border: 1px solid var(--line); border-radius: 10px; }
.plugin-runtime-status { padding: 12px 24px; color: #c24136; }
.selection-plugin-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.notes-conflict { margin: 12px 0; padding: 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft); font-size: 12px; }
.notes-conflict p { margin: 6px 0; }
.notes-conflict label { display: grid; gap: 5px; }
.notes-conflict textarea { width: 100%; margin-bottom: 8px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 5px; padding: 7px; user-select: text; }
@media (max-width:700px) { .market-layout { padding: 20px 16px 50px; } .market-grid { grid-template-columns: 1fr; } #market-github-form { flex-wrap: wrap; } }
@media (max-width:700px) { .market-preview-layout { padding: 20px 16px 40px; } .market-preview-heading { flex-direction: column; gap: 12px; } }

#market-github-sha256 { width: 220px; flex: 0 1 220px; }

.settings-mcp-format-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin-top: 15px; }
#settings-mcp-format { padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }

.browser-demo-banner { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 80; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 28px); padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); box-shadow: 0 3px 16px #0002; font-size: 12px; }
.browser-demo-banner button { flex-shrink: 0; }
.browser-demo-ai-notice, .browser-demo-section-message { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--text-secondary); font-size: 12px; line-height: 1.7; }
.browser-demo-ai-notice { margin: 8px 12px; }
.browser-demo-mode .browser-demo-unavailable-section > :not(.browser-demo-section-message) { display: none !important; }
.browser-demo-mode [aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
@media (max-width: 600px) { .browser-demo-banner { gap: 8px; font-size: 10px; padding: 7px 9px; } }

.browser-demo-invalidated-dialog { width: min(420px, calc(100vw - 40px)); padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-window); }
.browser-demo-invalidated-dialog::backdrop { background: #0007; }
.browser-demo-invalidated-dialog h2 { margin: 0 0 12px; font-size: 18px; }
.browser-demo-invalidated-dialog p { margin: 0 0 20px; color: var(--text-secondary); line-height: 1.7; }
