/* Note tools: contextual, content-first utilities without permanently shrinking the editor. */
.note-tools-toggle { position: relative; }
.note-tools-toggle svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.note-tools-toggle > span {
  position: absolute; top: -2px; right: -3px; display: grid; min-width: 15px; height: 15px; padding: 0 4px;
  place-items: center; border: 2px solid var(--surface); border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 8px; font-weight: 750; line-height: 1;
}
.note-tools-toggle[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }

.note-tools-panel {
  position: absolute; z-index: 55; top: 82px; right: 12px; display: flex; width: min(350px, calc(100% - 24px));
  max-height: calc(100dvh - 98px); flex-direction: column; overflow: hidden; border: 1px solid color-mix(in srgb, var(--text) 12%, var(--border));
  border-radius: 14px; background: color-mix(in srgb, var(--surface) 98%, transparent); color: var(--text);
  box-shadow: 0 24px 70px rgba(31, 35, 41, .16), 0 3px 12px rgba(31, 35, 41, .07);
  backdrop-filter: blur(18px) saturate(1.06); animation: note-tools-enter 180ms cubic-bezier(.2,.8,.2,1);
}
.note-tools-panel[hidden] { display: none !important; }
@keyframes note-tools-enter { from { opacity: 0; transform: translateY(-5px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
.note-tools-head { display: grid; min-height: 55px; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px; padding: 8px 9px 7px 15px; border-bottom: 1px solid var(--border-soft); }
.note-tools-head > div { display: grid; gap: 1px; }
.note-tools-head > div span { color: var(--text-tertiary); font-size: 8px; font-weight: 750; letter-spacing: .15em; }
.note-tools-head strong { font-size: 14px; font-weight: 680; letter-spacing: -.02em; }
.note-tools-head button { display: grid; width: 36px; height: 36px; cursor: pointer; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-tertiary); }
.note-tools-head button:hover { background: var(--surface-hover); color: var(--text); }
.note-tools-head svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.7; }
.comment-total { display: grid; min-width: 23px; height: 23px; padding: 0 7px; place-items: center; border-radius: 12px; background: var(--surface-hover); color: var(--text-secondary); font-size: 10px; font-weight: 650; font-variant-numeric: tabular-nums; }

.note-tools-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 7px; border-bottom: 1px solid var(--border-soft); background: var(--surface-soft); }
.note-tools-tabs button { min-height: 35px; cursor: pointer; border: 0; border-radius: 7px; background: transparent; color: var(--text-tertiary); font-size: 11px; font-weight: 580; }
.note-tools-tabs button:hover { background: var(--surface-hover); color: var(--text); }
.note-tools-tabs button[aria-selected="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(31,35,41,.08); }
.note-tools-tabs button span { display: inline-grid; min-width: 17px; height: 17px; margin-left: 2px; place-items: center; border-radius: 9px; background: var(--surface-hover); color: var(--text-tertiary); font-size: 9px; }
.note-tools-tabs button[aria-selected="true"] span { background: var(--accent-soft); color: var(--accent); }
.note-tools-body { min-height: 0; overflow: auto; padding: 10px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.note-tool-pane { display: grid; gap: 10px; }
.note-tool-pane[hidden] { display: none !important; }
.note-tool-pane > label, .comment-composer label { color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.note-tool-pane input, .note-tool-pane textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; outline: 0; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; }
.note-tool-pane input { height: 39px; padding: 0 10px; }
.note-tool-pane textarea { padding: 9px 10px; resize: vertical; line-height: 1.55; }
.note-tool-pane input:focus, .note-tool-pane textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.comment-composer { display: grid; gap: 8px; padding: 11px; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border)); border-radius: 10px; background: color-mix(in srgb, var(--accent-soft) 38%, var(--surface)); }
.comment-composer > span { color: var(--accent); font-size: 9px; font-weight: 750; letter-spacing: .08em; }
.comment-composer blockquote { max-height: 72px; margin: 0; overflow: auto; padding-left: 9px; border-left: 2px solid color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--text-secondary); font-size: 11px; line-height: 1.55; }
.comment-composer > div, .replace-actions { display: flex; justify-content: flex-end; gap: 6px; }
.comment-composer button, .replace-actions button, #noteTagForm button { min-height: 34px; cursor: pointer; padding: 0 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text-secondary); font-size: 11px; font-weight: 620; }
.comment-composer button[type="submit"], .replace-actions button:last-child, #noteTagForm button { border-color: var(--accent); background: var(--accent); color: #fff; }
.note-tool-filter { display: flex; align-items: center; gap: 3px; }
.note-tool-filter button { height: 30px; cursor: pointer; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--text-tertiary); font-size: 10px; }
.note-tool-filter button.active { background: var(--surface-hover); color: var(--text); font-weight: 650; }
.comment-list, .bookmark-list { display: grid; gap: 7px; }
.comment-card, .bookmark-card { display: grid; width: 100%; gap: 7px; padding: 11px 12px; cursor: pointer; border: 1px solid var(--border-soft); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; text-align: left; transition: border-color .15s ease, background-color .15s ease; }
.comment-card:hover, .bookmark-card:hover { border-color: var(--border); background: color-mix(in srgb, var(--surface-hover) 35%, var(--surface)); }
.comment-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.comment-card-head, .bookmark-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.comment-card-head div { display: flex; min-width: 0; align-items: center; gap: 6px; }
.comment-avatar { display: grid; width: 22px; height: 22px; flex: 0 0 22px; place-items: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 9px; font-weight: 750; }
.comment-card-head strong, .bookmark-card-head strong { min-width: 0; overflow: hidden; color: var(--text); font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.comment-card-head time, .bookmark-card-head span { color: var(--text-tertiary); font-size: 9px; white-space: nowrap; }
.comment-quote { overflow: hidden; color: var(--text-tertiary); font-size: 10px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.comment-text { margin: 0; color: var(--text); font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.comment-actions, .bookmark-actions { display: flex; justify-content: flex-end; gap: 3px; }
.comment-actions button, .bookmark-actions button { height: 29px; cursor: pointer; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text-tertiary); font-size: 10px; }
.comment-actions button:hover, .bookmark-actions button:hover { background: var(--surface-hover); color: var(--text); }
.comment-actions .danger:hover, .bookmark-actions .danger:hover { background: var(--danger-bg); color: var(--danger); }
.note-tool-empty { display: grid; min-height: 140px; place-items: center; align-content: center; gap: 5px; color: var(--text-tertiary); text-align: center; }
.note-tool-empty svg { width: 28px; height: 28px; margin-bottom: 3px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.35; opacity: .65; }
.note-tool-empty strong { color: var(--text-secondary); font-size: 12px; }
.note-tool-empty span, .note-tool-intro { margin: 0; color: var(--text-tertiary); font-size: 10px; line-height: 1.55; }

.find-input-row { position: relative; }
.find-input-row input { padding-right: 62px; }
.find-input-row span { position: absolute; top: 50%; right: 9px; color: var(--text-tertiary); font-size: 9px; font-variant-numeric: tabular-nums; transform: translateY(-50%); }
.find-options { display: grid; grid-template-columns: auto 1fr 34px 34px; align-items: center; gap: 4px; }
.find-options label { display: flex; align-items: center; gap: 5px; color: var(--text-tertiary); font-size: 10px; }
.find-options input { width: 14px; height: 14px; accent-color: var(--accent); }
.find-options button { display: grid; width: 34px; height: 34px; cursor: pointer; place-items: center; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text-secondary); }
.find-options button:hover { border-color: var(--accent); color: var(--accent); }
::highlight(luma-note-find) { color: inherit; background: color-mix(in srgb, #f7c948 45%, transparent); }
::highlight(luma-note-find-current) { color: inherit; background: color-mix(in srgb, #f59e0b 68%, transparent); text-decoration: underline; text-decoration-color: #a16207; }

.note-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.note-stat { display: grid; gap: 2px; min-height: 66px; align-content: center; padding: 8px; border: 1px solid var(--border-soft); border-radius: 9px; background: var(--surface-soft); text-align: center; }
.note-stat strong { color: var(--text); font-size: 17px; font-weight: 720; font-variant-numeric: tabular-nums; }
.note-stat span { color: var(--text-tertiary); font-size: 9px; }
.note-info-section { display: grid; gap: 8px; padding: 11px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface); }
.note-info-title { display: flex; align-items: center; justify-content: space-between; }
.note-info-title strong { font-size: 11px; }
.note-info-title span { color: var(--text-tertiary); font-size: 9px; }
.note-tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.note-tag { display: inline-flex; min-height: 26px; align-items: center; gap: 4px; padding: 0 5px 0 8px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.note-tag button { display: grid; width: 18px; height: 18px; cursor: pointer; place-items: center; border: 0; border-radius: 5px; background: transparent; color: inherit; }
.note-tag button:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
#noteTagForm { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.note-info-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.note-info-actions button { display: flex; min-height: 42px; cursor: pointer; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-secondary); font-size: 11px; text-align: left; }
.note-info-actions button:hover { border-color: color-mix(in srgb, var(--accent) 42%, var(--border)); background: var(--accent-soft); color: var(--accent); }
.note-info-actions button.active { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: var(--accent-soft); color: var(--accent); }
.note-info-actions svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.comment-anchor { border-bottom: 2px solid color-mix(in srgb, #e3a008 68%, transparent); background: color-mix(in srgb, #fde68a 28%, transparent); cursor: pointer; }
.comment-anchor.resolved { border-bottom-style: dotted; background: transparent; opacity: .72; }
.comment-anchor.note-jump-active { background: color-mix(in srgb, #fde047 48%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, #facc15 18%, transparent); }
.block-row.note-jump-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.block-row.bookmarked::after { position: absolute; top: 8px; right: -2px; width: 4px; height: 16px; border-radius: 3px; background: var(--accent); content: ""; opacity: .72; }
.note-item.favorite-note .note-icon { color: #b7791f; opacity: 1; }
.note-item.favorite-note .note-item-title::after { display: inline-block; width: 7px; height: 7px; margin-left: 6px; background: #b7791f; clip-path: polygon(50% 0,61% 36%,100% 36%,69% 58%,80% 96%,50% 73%,20% 96%,31% 58%,0 36%,39% 36%); content: ""; vertical-align: 1px; }

.app-shell.note-focus-mode { grid-template-columns: 0 minmax(0, 1fr) 0 !important; }
.app-shell.note-focus-mode > .sidebar, .app-shell.note-focus-mode > .outline-panel { visibility: hidden; pointer-events: none; }
.app-shell.note-focus-mode .breadcrumb span, .app-shell.note-focus-mode .breadcrumb b { display: none; }

@media (max-width: 920px) {
  .note-tools-panel { position: fixed; top: auto; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); left: 8px; width: auto; max-height: min(78dvh, 680px); border-radius: 16px; }
  .note-tools-tabs button, .note-tools-head button, .note-info-actions button, .comment-composer button, .replace-actions button { min-height: 44px; }
  .note-tools-body { min-height: 0; }
  .main-panel:has(.note-tools-panel:not([hidden])) .document-scroller { padding-bottom: min(52dvh, 430px); }
}
@media (max-width: 520px) {
  .note-info-actions { grid-template-columns: 1fr; }
  .note-tools-toggle { display: grid !important; }
}
@media print { .note-tools-panel, .note-tools-toggle { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .note-tools-panel { animation: none; } }
