#dictionary-dialog {
  position: fixed;
  top: calc(var(--visible-screen-top, 0px) + var(--visible-screen-height, 100dvh) / 2);
  left: 50%;
  right: auto;
  bottom: auto;
  margin: 0;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  box-sizing: border-box;
  max-height: min(780px, 88dvh, calc(var(--visible-screen-height, 100dvh) - 32px));
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--note-body-font);
}
#dictionary-dialog::backdrop { background: rgba(36, 35, 31, .38); }
.dictionary-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dictionary-header h2 { margin: 0; font-size: 1.25rem; }
#dictionary-close { padding: 3px 9px; background: transparent; color: var(--ink); font-size: 1.4rem; }
.dictionary-tabs { display: flex; gap: 8px; margin: 18px 0; border-bottom: 1px solid var(--line); }
.dictionary-tabs button { padding: 8px 10px; background: transparent; color: var(--muted); border-radius: 0; border-bottom: 2px solid transparent; }
.dictionary-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent); }
#dictionary-dialog label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 5px; }
.dictionary-search { display: flex; align-items: center; gap: 8px; }
#dictionary-dialog input { min-width: 0; box-sizing: border-box; width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink); font: inherit; }
.dictionary-search button { flex-shrink: 0; padding: 10px; }
#dictionary-result h3 { font-size: 1.2rem; margin: 20px 0 5px; overflow-wrap: anywhere; }
#dictionary-result h4 { margin: 16px 0 6px; color: var(--accent); font-size: .85rem; }
#dictionary-result ol { margin: 0; padding-left: 24px; }
#dictionary-result li { padding: 5px 0; line-height: 1.6; overflow-wrap: anywhere; }
.dictionary-synonyms { display: block; color: var(--muted); font-size: .8rem; }
#dictionary-save { margin-top: 16px; }
#dictionary-save[hidden], #dictionary-load-more[hidden], #dictionary-dialog section[hidden], #dictionary-selection[hidden] { display: none; }
#dictionary-word-list { list-style: none; margin: 12px 0; padding: 0; }
#dictionary-word-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding: 8px 0; }
#dictionary-word-list button { background: transparent; color: var(--accent); text-align: left; padding: 5px; overflow-wrap: anywhere; }
#dictionary-word-list button[data-remove-word] { color: var(--muted); flex-shrink: 0; }
.dictionary-list-actions { display: flex; flex-wrap: wrap; gap: 10px; }
#dictionary-status, #dictionary-list-status { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
#dictionary-status.is-error { color: var(--danger); }
.dictionary-credit { font-size: .7rem; color: var(--muted); margin: 22px 0 0; line-height: 1.5; }
.dictionary-credit a { color: inherit; }
#note-selection-actions[hidden], #selection-ignore[hidden] { display: none; }
#note-selection-actions { position: fixed; z-index: 85; display: flex; gap: 8px; box-sizing: border-box; padding: 6px; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 12px #0002; background: var(--paper); color: var(--accent); }
#note-selection-actions button { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--accent); font: 600 .8rem var(--note-body-font); white-space: nowrap; }
#note-selection-actions.is-docked { width: min(440px, calc(100vw - 16px)); }
#note-selection-actions.is-docked button { min-height: 44px; min-width: 0; flex: 1; white-space: normal; }
#note-selection-actions button:disabled { color: var(--muted); opacity: .6; }
#note-selection-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 480px) { #dictionary-dialog { padding: 16px; } }

#spelling-dialog { width: min(560px, calc(100vw - 32px)); box-sizing: border-box; max-height: 88dvh; overflow-y: auto; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); }
#spelling-dialog::backdrop { background: rgba(36, 35, 31, .38); }
#spelling-dialog p { font-size: .85rem; line-height: 1.6; color: var(--muted); }
#spelling-enabled { display: inline-block; width: auto; margin-right: 6px; accent-color: var(--accent); }
#spelling-dialog button:focus-visible, #spelling-dialog input:focus-visible, #spelling-dialog select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#spelling-word, #spelling-name { min-width: 0; width: 100%; box-sizing: border-box; padding: 9px 10px; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; }
#spelling-close { padding: 3px 9px; background: transparent; color: var(--ink); font-size: 1.4rem; }
#spelling-ignored-list, #spelling-names-list { list-style: none; padding: 0; }
#spelling-dialog .spelling-entry-text { min-width: 0; flex: 1; overflow-wrap: anywhere; }
#spelling-ignored-list button, #spelling-names-list button { flex-shrink: 0; }
#spelling-ignored-more[hidden], #spelling-names-more[hidden] { display: none; }
#spelling-dialog .spelling-search-label { display: block; margin: 16px 0 6px; color: var(--muted); font-size: .8rem; }
#spelling-ignored-search, #spelling-names-search { width: 100%; min-width: 0; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; }
.spelling-transfer { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 12px; }
.spelling-transfer summary { cursor: pointer; color: var(--accent); font-weight: 600; }
#spelling-import-form { display: grid; gap: 10px; margin-top: 16px; }
#spelling-import-form label { color: var(--muted); font-size: .8rem; }
#spelling-import-form input, #spelling-import-form select { min-width: 0; max-width: 100%; box-sizing: border-box; color: var(--ink); }
#spelling-import-form select { min-height: 40px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
#spelling-import-form button { justify-self: start; }
#spelling-transfer-status { overflow-wrap: anywhere; }
#spelling-ignored-list li, #spelling-names-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#spelling-ignored-list button, #spelling-names-list button { flex-shrink: 0; padding: 6px; background: transparent; color: var(--accent); }
#spelling-name-form label[for="spelling-name-kind"] { display: block; margin: 16px 0 8px; }
#spelling-name-kind { display: block; margin: 0; min-height: 36px; min-width: 140px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
#dictionary-ignore { margin-top: 16px; }
#dictionary-ignore[hidden], #note-context-menu[hidden] { display: none; }
#note-context-menu { position: fixed; z-index: 95; display: grid; gap: 2px; width: min(240px, calc(100vw - 16px)); box-sizing: border-box; padding: 6px; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px #0002; background: var(--paper); color: var(--ink); }
#note-context-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; text-align: left; padding: 8px 10px; border: 0; background: transparent; color: var(--ink); border-radius: 6px; cursor: pointer; }
#note-context-menu button:hover, #note-context-menu button:focus-visible { background: var(--accent-soft); color: var(--accent); }
#note-context-menu button span { padding: 0; font-size: .8rem; color: inherit; }
#note-context-menu .text-action-icon { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#note-context-menu button:disabled { opacity: .4; cursor: default; }
#note-context-menu button:disabled:hover { background: transparent; color: var(--ink); }
#note-context-dictionary { margin-top: 4px; border-top: 1px solid var(--line) !important; }
.note-action-toast { pointer-events: none; }
