body:has(dialog[open]) {
  overflow:hidden}
dialog {
  color:var(--ink);
  background:var(--surface);
  border:1px solid var(--border);
  padding:0;
  box-shadow:var(--shadow);
  max-height:90dvh}
dialog::backdrop {
  background:#0e163169;
  backdrop-filter:blur(3px)}
.term-dialog { width: min(460px,calc(100vw - 32px)); padding: 25px; border-radius: 12px; margin: auto; }
.term-dialog .dialog-head { align-items: flex-start; }
.term-dialog .dialog-head h2 { font-size: 25px; margin-top: 6px; }
.term-dialog>p { font-size: 16px; line-height: 1.85; color: var(--body); margin: 19px 0; }
.term-dialog>a { display: inline-block; font-size: 13px; line-height: 1.7; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.search-dialog {
  width:min(650px,calc(100vw - 32px));
  border-radius:12px;
  margin:13vh auto auto}
.search-input-row {
  display:flex;
  align-items:center;
  gap:14px;
  padding:18px 21px;
  border-bottom:1px solid var(--border)}
.search-input-row>svg {
  color:var(--accent);
  width:22px;
  height:22px}
.search-input-row input {
  flex:1;
  min-width:0;
  background:none;
  color:var(--ink);
  font-size:15px;
  border:0;
  outline:0;
  min-height:28px}
.search-input-row input::placeholder {
  color:var(--muted)}
.key-button {
  font:11px var(--sans);
  border:1px solid var(--border);
  border-radius:4px;
  padding:5px 7px;
  color:var(--muted)}
.search-context {
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--muted);
  font-size:11px;
  padding:13px 21px;
  background:var(--canvas)}
.search-results {
  max-height:48dvh;
  overflow-y:auto;
  padding:8px}
.search-result {
  display:block;
  padding:14px;
  border-radius:8px}
.search-result:hover,.search-result:focus {
  background:var(--accent-soft)}
.search-result .result-label {
  display:flex;
  gap:8px;
  align-items:center;
  color:var(--muted);
  font-size:11px;
  margin-bottom:7px}
.search-result h3 {
  font-size:14px;
  font-weight:550;
  margin:0 0 6px}
.search-result p {
  color:var(--body);
  font-size:14px;
  line-height:1.8;
  margin:0}
.search-result mark {
  background:#c4d0fc88;
  color:var(--ink);
  border-radius:2px}
.empty-state {
  padding:35px 20px;
  text-align:center;
  color:var(--muted);
  font-size:14px;
  line-height:1.9}
.dialog-foot {
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  padding:15px 20px;
  border-top:1px solid var(--border);
  font-size:11px;
  color:var(--muted)}
.side-dialog {
  position:fixed;
  inset:0 0 0 auto;
  margin:0;
  width:min(450px,100vw);
  height:100dvh;
  max-height:100dvh;
  border-radius:0;
  border-top:0;
  border-right:0;
  border-bottom:0;
  padding:28px;
  overflow-y:auto}
.dialog-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:28px}
.dialog-head h2 {
  font-family:var(--serif);
  font-size:26px;
  font-weight:650;
  letter-spacing:-.5px;
  margin:8px 0 0}
.dialog-head .eyebrow {
  font-size:11px}
.dialog-head .icon-button {
  margin-right:-7px}
.setting-group {
  padding:24px 0;
  border-top:1px solid var(--border)}
.setting-group h3 {
  font-size:14px;
  font-weight:600;
  margin:0 0 16px}
.theme-options {
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:10px}
.theme-options button {
  font-size:14px;
  line-height:1.8;
  padding:4px;
  color:var(--muted);
  border:1px solid transparent;
  border-radius:9px}
.theme-options button[aria-pressed=true] {
  border-color:var(--accent);
  color:var(--accent)}
.theme-preview {
  height:66px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid #0001;
  border-radius:5px;
  font:26px var(--serif);
  margin-bottom:7px}
.preview-light {
  background:#ffffff;
  color:#151b2c}
.preview-dark {
  background:#171e2f;
  color:#f0f3fc}
.preview-paper {
  background:#f4f0e7;
  color:#302e29}
.setting-title {
  display:flex;
  justify-content:space-between}
.setting-title output {
  font:13px var(--mono);
  color:var(--accent)}
.size-slider {
  display:flex;
  gap:15px;
  align-items:center}
.size-slider span:first-child {
  font-size:14px}
.size-slider span:last-child {
  font-size:20px}
.size-slider input {
  width:100%;
  accent-color:var(--accent)}
.setting-group>.text-button {
  font-size:14px;
  margin-top:12px}
.toggle-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:15px}
.toggle-row strong {
  font-size:14px;
  font-weight:600}
.toggle-row small {
  display:block;
  font-size:14px;
  line-height:1.7;
  color:var(--muted);
  margin-top:5px}
.toggle-row input {
  width:18px;
  height:18px;
  accent-color:var(--accent)}
.setting-action {
  display:flex;
  gap:12px;
  align-items:center;
  width:100%;
  padding:14px 0;
  color:var(--body);
  font-size:14px}
.setting-action svg {
  width:16px;
  height:16px;
  color:var(--muted)}
.setting-action>svg:last-child {
  margin-left:auto}
.small-copy {
  font-size:14px;
  line-height:1.9;
  color:var(--muted)}
.import-label {
  cursor:pointer}
.panel-tabs {
  display:flex;
  gap:17px;
  border-bottom:1px solid var(--border);
  margin-bottom:20px}
.panel-tabs button {
  padding:0 0 13px;
  font-size:14px;
  color:var(--muted);
  border-bottom:2px solid transparent}
.panel-tabs button.active {
  color:var(--accent);
  border-color:var(--accent)}
.panel-tabs button span {
  font-size:11px;
  margin-left:3px}
.panel-search {
  width:100%;
  min-height:40px;
  padding:0 12px;
  border:1px solid var(--border);
  border-radius:8px;
  color:var(--ink);
  background:var(--canvas);
  font-size:14px;
  margin-bottom:22px}
.notebook-card {
  padding:18px 0;
  border-bottom:1px solid var(--border)}
.notebook-card .note-meta {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  font-size:11px;
  color:var(--muted);
  margin-bottom:12px}
.note-meta .tag {
  font-size:7px}
.notebook-card blockquote {
  margin:0 0 11px;
  border-left:2px solid var(--border);
  padding-left:12px;
  font:14px/1.8 var(--serif);
  color:var(--body)}
.notebook-card .note-body {
  font-size:14px;
  line-height:1.9;
  white-space:pre-wrap;
  overflow-wrap:anywhere}
.note-actions {
  display:flex;
  gap:18px;
  align-items:center;
  margin-top:12px}
.note-actions a,.note-actions button {
  font-size:11px;
  color:var(--accent);
  padding:3px 0}
.note-actions .remove-note {
  color:var(--muted)}
.panel-bottom {
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  border-top:1px solid var(--border);
  padding-top:18px;
  margin-top:25px}
.panel-bottom>span {
  font-size:11px;
  color:var(--muted)}
.panel-bottom .text-button {
  font-size:14px}
.saved-chapter {
  display:block;
  padding:18px 0;
  border-bottom:1px solid var(--border)}
.saved-chapter h3 {
  font:600 17px var(--sans);
  margin:7px 0}
.saved-chapter p {
  font-size:14px;
  color:var(--muted);
  margin:0}
.glossary-entry {
  padding:18px 0;
  border-bottom:1px solid var(--border)}
.glossary-entry h3 {
  font:600 20px var(--sans);
  margin-bottom:8px}
.glossary-entry p {
  font-size:14px;
  line-height:1.9;
  color:var(--body)}
.glossary-entry a {
  font-size:14px;
  color:var(--accent)}
.selection-tools {
  position:fixed;
  z-index:45;
  display:flex;
  gap:7px;
  align-items:center;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:9px;
  box-shadow:var(--shadow);
  padding:8px 10px}
.highlight-swatch {
  width:21px;
  height:21px;
  border-radius:50%;
  border:1px solid #0001}
.highlight-swatch:hover {
  transform:scale(1.12)}
.highlight-swatch.yellow {
  background:#ead17b}
.highlight-swatch.green {
  background:#abc58d}
.highlight-swatch.pink {
  background:#e4adb9}
.highlight-swatch.blue {
  background:#a1c4dd}
.selection-tools>span {
  height:18px;
  width:1px;
  background:var(--border);
  margin:0 2px}
.selection-note {
  font-size:14px;
  display:flex;
  align-items:center;
  gap:5px;
  padding:3px}
.selection-note svg {
  width:13px;
  height:13px}
.note-dialog {
  width:min(450px,calc(100vw - 30px));
  border-radius:10px;
  padding:25px}
.note-dialog .dialog-head {
  margin-bottom:20px}
.note-dialog .dialog-head h2 {
  font-size:23px;
  margin:0}
.note-dialog blockquote {
  font:14px/1.8 var(--serif);
  color:var(--body);
  border-left:2px solid var(--accent);
  margin:0 0 18px;
  padding-left:15px;
  max-height:160px;
  overflow:auto}
.note-dialog textarea {
  width:100%;
  resize:vertical;
  min-height:110px;
  border:1px solid var(--border);
  border-radius:8px;
  padding:13px;
  background:var(--canvas);
  color:var(--ink);
  font-size:14px;
  line-height:1.8;
  margin-bottom:18px}
.note-dialog .button-row {
  justify-content:flex-end}
.toast-region {
  position:fixed;
  bottom:24px;
  left:50%;
  transform:translateX(-50%);
  z-index:100;
  pointer-events:none}
.toast {
  background:var(--ink);
  color:var(--surface);
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  border-radius:9px;
  padding:12px 18px;
  font-size:14px;
  line-height:1.7;
  max-width:min(430px,90vw);
  animation:toast-in .15s ease-out}
@keyframes toast-in {
  from {
  transform:translateY(8px);
  opacity:0}
to {
  transform:none;
  opacity:1}
}

