/* Notes tab: sidebar + editor, Obsidian-style. Colors come from the theme variables. */

.sd-notes { padding-bottom: 32px; }
/* Anki's base styles give every button a min-width and padding; fixed-size ones opt out */
.sd-wrap button { min-width: 0; }
.sd-icon-btn, .sd-nacts button, .sd-chev { box-sizing: border-box; padding: 0 !important; }

.sd-notes-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) auto;
  height: calc(100vh - 120px);
  min-height: 520px;
  border: 1px solid var(--sd-border);
  border-radius: var(--sd-radius);
  overflow: hidden;
  background: var(--sd-surface);
  box-shadow: inset 0 1px 0 rgb(var(--sd-light) / var(--sd-edge-max)), var(--sd-shadow);
}
.sd-notes-shell.side-hidden { grid-template-columns: 50px minmax(0, 1fr) auto; }
@media (max-width: 640px) { .sd-notes-shell, .sd-notes-shell.side-hidden { grid-template-columns: 1fr; height: auto; } .sd-nai { display: none !important; } }
.sd-nrail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0; }

/* Sidebar */
.sd-nside { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--sd-border); background: rgb(var(--sd-light) / 0.015); }
.sd-nside-top { display: flex; gap: 6px; padding: 12px; border-bottom: 1px solid var(--sd-border); }
.sd-nside-top { gap: 4px; }
.sd-nside-top .sd-icon-btn { width: 28px; height: 28px; align-self: center; }
.sd-nside-top .sd-input { flex: 1 1 0; min-width: 60px; padding: 7px 8px; border-radius: 10px; font-size: 13px; }
.sd-icon-btn {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--sd-border); border-radius: 10px; background: var(--sd-surface);
  color: var(--sd-muted); cursor: pointer;
}
.sd-icon-btn:hover { color: var(--sd-text); border-color: var(--sd-accent); }
.sd-notes svg { width: 15px; height: 15px; flex: none; }
.sd-ntree { flex: 1; overflow-y: auto; padding: 8px 6px; }
.sd-pad { padding: 8px 10px; font-size: 13px; }

.sd-nrow { position: relative; display: flex; align-items: center; border-radius: 8px; }
.sd-nrow:hover { background: var(--sd-hover); }
.sd-nrow.active { background: var(--sd-hover); box-shadow: inset 2px 0 0 var(--sd-accent); }
.sd-nrow-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px;
  padding: 6px 8px 6px calc(8px + var(--d, 0) * 14px);
  border: 0; background: none; color: var(--sd-text); font: 13px var(--sd-font); text-align: left; cursor: pointer;
}
.sd-nrow.note .sd-nrow-main { color: var(--sd-muted); }
.sd-nrow.note.active .sd-nrow-main, .sd-nrow.note:hover .sd-nrow-main { color: var(--sd-text); }
.sd-nrow-main span:not(.sd-chev) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-nrow-main small { margin-left: auto; padding-left: 6px; color: var(--sd-muted); font-size: 11px; white-space: nowrap; }
.sd-chev { display: inline-flex; transition: transform 0.15s; color: var(--sd-muted); }
.sd-chev svg { width: 11px; height: 11px; }
.sd-chev.open { transform: rotate(90deg); }
.sd-nacts { display: none; padding-right: 4px; }
.sd-nrow:hover .sd-nacts, .sd-nrow:focus-within .sd-nacts { display: flex; }
.sd-nrow:hover .sd-nrow-main small { display: none; }
.sd-nacts button, .sd-nconfirm button {
  display: grid; place-items: center; width: 24px; height: 24px;
  border: 0; border-radius: 6px; background: none; color: var(--sd-muted); cursor: pointer;
}
.sd-nacts button:hover { color: var(--sd-text); background: var(--sd-border); }
.sd-nconfirm { display: flex; align-items: center; gap: 2px; padding-right: 6px; color: var(--sd-learn); font-size: 12px; white-space: nowrap; }
.sd-nconfirm button { width: auto; padding: 0 6px; color: var(--sd-text); font: 12px var(--sd-font); }
.sd-nconfirm button:first-of-type { color: var(--sd-learn); font-weight: 600; }
.sd-nrename {
  width: 100%; margin: 2px 4px 2px calc(4px + var(--d, 0) * 14px); padding: 5px 8px;
  border: 1px solid var(--sd-accent); border-radius: 7px; background: var(--sd-bg); color: var(--sd-text); font: 13px var(--sd-font);
}
.sd-nrename:focus { outline: none; box-shadow: 0 0 0 3px rgb(41 151 255 / 0.2); }
.sd-drop-over { background: rgb(41 151 255 / 0.14) !important; box-shadow: inset 0 0 0 1px var(--sd-accent); }
.sd-nhit {
  display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 8px; background: none; color: var(--sd-text); font: 13px var(--sd-font); text-align: left; cursor: pointer;
}
.sd-nhit:hover { background: var(--sd-hover); }
.sd-nhit span, .sd-nhit small { color: var(--sd-muted); font-size: 11px; }
.sd-nfoot {
  padding: 10px 14px; border: 0; border-top: 1px solid var(--sd-border); background: none;
  color: var(--sd-muted); font: 12px var(--sd-font); text-align: left; cursor: pointer;
}
.sd-nfoot:hover { color: var(--sd-accent); }

/* Editor */
.sd-neditor { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sd-nempty { margin: auto; text-align: center; color: var(--sd-muted); }
.sd-ntoolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--sd-border);
}
.sd-ncrumb { color: var(--sd-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-ntools { display: flex; align-items: center; gap: 10px; }
.sd-ntools .sd-btn { padding: 5px 12px; font-size: 12px; }
.sd-nstatus { color: var(--sd-muted); font-size: 11px; min-width: 50px; text-align: right; }
.sd-seg { display: inline-flex; padding: 2px; border: 1px solid var(--sd-border); border-radius: 99px; }
.sd-seg button { padding: 4px 11px; border: 0; border-radius: 99px; background: none; color: var(--sd-muted); font: 500 12px var(--sd-font); cursor: pointer; }
.sd-seg button[aria-pressed="true"] { background: var(--sd-hover); color: var(--sd-text); }

.sd-ntitle {
  margin: 26px auto 6px; width: min(var(--sd-note-w, 720px), calc(100% - 2 * var(--sd-note-m, 32px))); padding: 0;
  border: 0; background: none; outline: none;
  color: var(--sd-text); font: 700 30px/1.2 var(--sd-font); letter-spacing: -0.025em;
}
#sd-nbody-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; overflow-y: auto; }
.sd-npreview {
  flex: 0 1 var(--sd-note-w, 720px); box-sizing: border-box; min-width: 0; margin: 0 var(--sd-note-m, 32px); padding: 10px 0 40px;
  color: var(--sd-text); font: var(--sd-note-font, 16px)/1.75 var(--sd-font);
}
.sd-npreview h1, .sd-npreview h2, .sd-npreview h3, .sd-npreview h4 { margin: 1.2em 0 0.4em; letter-spacing: -0.02em; line-height: 1.3; }
.sd-npreview h1 { font-size: 26px; } .sd-npreview h2 { font-size: 21px; } .sd-npreview h3 { font-size: 18px; } .sd-npreview h4 { font-size: 16px; }
.sd-npreview p { margin: 0 0 0.8em; }
.sd-npreview ul, .sd-npreview ol { margin: 0 0 0.8em; padding-left: 22px; }
.sd-npreview li { margin: 2px 0; }
.sd-npreview ul.sd-tasks { list-style: none; padding-left: 2px; }
.sd-npreview .sd-tasks li { display: flex; align-items: baseline; gap: 8px; }
.sd-npreview .sd-tasks li.done { color: var(--sd-muted); text-decoration: line-through; }
.sd-npreview .sd-tasks input { accent-color: var(--sd-accent); transform: translateY(1px); }
.sd-npreview blockquote { margin: 0 0 0.8em; padding: 2px 14px; border-left: 3px solid var(--sd-accent); color: var(--sd-muted); }
.sd-npreview code { font: 13px var(--sd-mono); padding: 1px 5px; border-radius: 5px; background: var(--sd-hover); }
.sd-npreview pre { margin: 0 0 0.8em; padding: 12px 14px; border-radius: 10px; background: var(--sd-bg); overflow-x: auto; }
.sd-npreview pre code { padding: 0; background: none; }
.sd-npreview mark { padding: 0 2px; border-radius: 3px; background: rgb(255 195 92 / 0.35); color: inherit; }
.sd-npreview hr { margin: 1.4em 0; border: 0; border-top: 1px solid var(--sd-border); display: block; }
.sd-wikilink, .sd-extlink {
  padding: 0; border: 0; background: none; color: var(--sd-accent); font: inherit; cursor: pointer;
  text-decoration: underline; text-decoration-color: rgb(41 151 255 / 0.35); text-underline-offset: 3px;
}
.sd-nfooter {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 16px; border-top: 1px solid var(--sd-border); color: var(--sd-muted); font-size: 11px;
}

/* Formatting toolbar */
.sd-nformat {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 6px 12px; border-bottom: 1px solid var(--sd-border);
}
.sd-nformat.disabled { opacity: 0.45; pointer-events: none; }
.sd-nformat button {
  display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 5px !important;
  border: 0; border-radius: 7px; background: none; color: var(--sd-text); font: 14px var(--sd-font); cursor: pointer;
}
.sd-nformat button:hover, .sd-nformat button[aria-expanded="true"] { background: var(--sd-hover); }
.sd-nformat select {
  height: 28px; padding: 0 8px; border: 1px solid var(--sd-border); border-radius: 7px;
  background: var(--sd-surface); color: var(--sd-text); font: 13px var(--sd-font);
}
.sd-nsep { width: 1px; height: 18px; margin: 0 6px; background: var(--sd-border); }
.sd-hl { padding: 0 3px; border-radius: 3px; background: rgb(255 195 92 / 0.45); }
.sd-ncolor { position: relative; display: inline-flex; align-items: center; }
.sd-ncolor > button i { display: block; width: 14px; height: 3px; margin-top: -3px; border-radius: 2px;
  background: linear-gradient(90deg, #ff6b6b, #ffb347, #ffd84d, #4cd471, #4aa8ff, #b48cff); }
.sd-npalette {
  position: absolute; top: 32px; left: 0; z-index: 5; display: grid; grid-template-columns: repeat(8, 22px); gap: 4px; padding: 8px;
  border: 1px solid var(--sd-border); border-radius: 10px; background: var(--sd-surface); box-shadow: var(--sd-shadow);
}
.sd-nformat .sd-npalette button.sw {
  min-width: 22px; width: 22px; height: 22px; padding: 0 !important; border: 1px solid color-mix(in srgb, var(--sd-text) 22%, transparent); border-radius: 5px;
}
.sd-nformat .sd-npalette button.sw:hover { transform: scale(1.18); }
.sd-npal-foot { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--sd-border); }
.sd-npal-foot button, .sd-npick { height: 28px; padding: 0 9px !important; border-radius: 7px; font: 12.5px var(--sd-font); white-space: nowrap; }
.sd-npick { position: relative; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--sd-text); }
.sd-npick:hover { background: var(--sd-hover); }
.sd-npick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.sd-nformat .sd-ncaret { min-width: 16px; width: 16px; padding: 0 !important; font-size: 10px; }
/* Font size like a Google Doc: − [ 16 ] + on the selected text */
.sd-nsize { display: inline-flex; align-items: center; gap: 2px; }
.sd-nsize input {
  width: 38px; height: 28px; padding: 0; border: 1px solid var(--sd-border); border-radius: 7px; text-align: center;
  background: var(--sd-surface); color: var(--sd-text); font: 13px var(--sd-font);
}
.sd-nsize input:focus { outline: 2px solid var(--sd-accent); outline-offset: 0; }
/* note width: Narrow (a comfortable reading column), Wide, or Full (the whole editor, small margins) */
.sd-notes-shell { --sd-note-w: 720px; --sd-note-m: 32px; }
.sd-notes-shell.w-wide { --sd-note-w: 1100px; }
.sd-notes-shell.w-full { --sd-note-w: 100%; --sd-note-m: 20px; }
.sd-nwidth { height: 28px; padding: 0 10px !important; border: 1px solid var(--sd-border); border-radius: 99px; background: none;
  color: var(--sd-muted); font: 12px var(--sd-font); white-space: nowrap; cursor: pointer; }
.sd-nwidth:hover { color: var(--sd-text); border-color: var(--sd-accent); }
.sd-nfont { min-width: 22px; color: var(--sd-muted); font: 11px var(--sd-mono); text-align: center; }
.sd-npreview s { color: var(--sd-muted); }
/* Text colors (light enough for dark mode, dark enough for light) */
.sd-c-red { color: #e5484d; } .sd-c-orange { color: #f76b15; } .sd-c-yellow { color: #d4a017; }
.sd-c-green { color: #30a46c; } .sd-c-blue { color: #3e8ef7; } .sd-c-purple { color: #8e4ec6; } .sd-c-gray { color: #8b8d98; }

/* Assistant panel (collapsible, resizable) */
.sd-nai { position: relative; display: flex; flex-direction: column; min-height: 0; width: 44px; border-left: 1px solid var(--sd-border); transition: width 0.2s ease; }
.sd-nai.open { width: var(--w, 360px); }
.sd-nai.resizing { transition: none; user-select: none; }
.sd-nai-rail {
  display: flex; flex-direction: column; align-items: center; gap: 10px; height: 100%; padding: 14px 0 !important;
  border: 0; background: none; color: var(--sd-muted); font: 600 11px var(--sd-font); cursor: pointer;
}
.sd-nai-rail:hover { color: var(--sd-text); background: var(--sd-hover); }
.sd-nai-rail img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.sd-nai-rail span { writing-mode: vertical-rl; letter-spacing: 0.08em; text-transform: uppercase; }
.sd-nai-grip { position: absolute; top: 0; bottom: 0; left: -4px; z-index: 3; width: 8px; cursor: col-resize; }
.sd-nai-grip:hover, .sd-nai.resizing .sd-nai-grip { background: linear-gradient(90deg, transparent 3px, var(--sd-accent) 3px, var(--sd-accent) 5px, transparent 5px); }
.sd-nai-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--sd-border); }
.sd-nai-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.sd-nai-title img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.sd-nai-title small { white-space: nowrap; padding: 1px 7px; border: 1px solid var(--sd-border); border-radius: 99px; color: var(--sd-muted); font: 10px var(--sd-mono); }
.sd-nai-acts { display: flex; gap: 2px; }
.sd-nai-acts button { display: grid; place-items: center; width: 26px; height: 26px; padding: 0 !important; border: 0; border-radius: 7px; background: none; color: var(--sd-muted); cursor: pointer; }
.sd-nai-acts button:hover { color: var(--sd-text); background: var(--sd-hover); }
.sd-nai-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; }
.sd-nai-log .sd-msg { max-width: 92%; font-size: 13px; }
.sd-nai-log .sd-msg.ai h1, .sd-nai-log .sd-msg.ai h2, .sd-nai-log .sd-msg.ai h3 { margin: 6px 0 4px; font-size: 14px; }
.sd-nai-empty { margin: auto 0; text-align: center; color: var(--sd-muted); font-size: 13px; }
.sd-nai-empty img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.sd-nai-change {
  display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 8px;
  border: 1px solid var(--sd-border); border-radius: 9px; background: var(--sd-surface); font-size: 12px;
}
.sd-nai-change em { margin-left: auto; color: var(--sd-muted); }
.sd-nai-undo { margin-left: auto; padding: 2px 9px !important; border: 1px solid var(--sd-border); border-radius: 99px; background: none; color: var(--sd-text); font: 11px var(--sd-font); cursor: pointer; }
.sd-nai-undo:hover { border-color: var(--sd-accent); }
.sd-nai-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--sd-border); }
.sd-nai-input textarea {
  flex: 1; min-width: 0; resize: none; padding: 8px 10px; border: 1px solid var(--sd-border); border-radius: 10px;
  background: var(--sd-bg); color: var(--sd-text); font: 13px/1.4 var(--sd-font);
}
.sd-nai-input textarea:focus { outline: none; border-color: var(--sd-accent); }
#sd-nbody-wrap .cm-editor:has(.cm-content[contenteditable="false"]) { opacity: 0.6; }


/* Live-preview editor (CodeMirror): formatted everywhere; the cursor's line shows its Markdown */
#sd-nbody-wrap .cm-editor {
  flex: 0 1 var(--sd-note-w, 720px); min-width: 0; min-height: 100%; margin: 0 var(--sd-note-m, 32px); background: none;
  color: var(--sd-text); font: var(--sd-note-font, 16px)/1.75 var(--sd-font);
}
#sd-nbody-wrap .cm-editor.cm-focused { outline: none; }
#sd-nbody-wrap .cm-scroller { font-family: inherit; line-height: inherit; overflow: visible; }
#sd-nbody-wrap .cm-content { padding: 10px 0 40px; caret-color: var(--sd-accent); }
#sd-nbody-wrap .cm-line { padding: 0; }
#sd-nbody-wrap .cm-cursor { border-left: 2px solid var(--sd-accent); }
#sd-nbody-wrap .cm-selectionBackground, #sd-nbody-wrap .cm-focused .cm-selectionBackground { background: rgb(41 151 255 / 0.28) !important; }
#sd-nbody-wrap .cm-placeholder { color: var(--sd-muted); opacity: 0.6; }
.cm-line.cm-h1 { font-size: 1.62em; font-weight: 700; letter-spacing: -0.02em; line-height: 1.35; padding-top: 0.5em !important; }
.cm-line.cm-h2 { font-size: 1.31em; font-weight: 650; letter-spacing: -0.015em; line-height: 1.4; padding-top: 0.4em !important; }
.cm-line.cm-h3 { font-size: 1.12em; font-weight: 650; padding-top: 0.3em !important; }
.cm-strong { font-weight: 700; }
.cm-em { font-style: italic; }
.cm-strike, .cm-done { color: var(--sd-muted); text-decoration: line-through; }
.cm-code { padding: 1px 4px; border-radius: 5px; background: var(--sd-hover); font: 0.86em var(--sd-mono); }
.cm-hl { padding: 0 2px; border-radius: 3px; background: rgb(255 195 92 / 0.35); }
.cm-line.cm-quote { padding-left: 14px !important; border-left: 3px solid var(--sd-accent); color: var(--sd-muted); }
.cm-line.cm-codeblock { padding: 0 12px !important; background: var(--sd-bg); font: 0.86em/1.7 var(--sd-mono); }
.cm-bullet { display: inline-block; width: 1.1em; color: var(--sd-accent); font-weight: 700; }
.cm-check { margin: 0 8px 0 2px; accent-color: var(--sd-accent); vertical-align: -2px; cursor: pointer; }
.cm-rule { display: inline-block; width: 100%; height: 1px; vertical-align: middle; background: var(--sd-border); }
.cm-link, .cm-wiki { color: var(--sd-accent); text-decoration: underline; text-decoration-color: rgb(41 151 255 / 0.35); text-underline-offset: 3px; }
[data-url], [data-wiki] { cursor: pointer; }

/* Images and PDFs in notes (editor.js shows a line with just ![[file]] as the file) */
.cm-embed { position: relative; margin: 10px 0; }
.cm-embed img { display: block; max-width: 100%; max-height: 70vh; border-radius: 12px; border: 1px solid var(--sd-border); }
.cm-embed-pdf { border: 1px solid var(--sd-border); border-radius: 14px; overflow: hidden; background: var(--sd-surface); }
.cm-embed-pdf img { max-height: none; width: 100%; border: 0; border-radius: 0; }
.cm-embed-bar { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--sd-border); font-size: 12.5px; }
.cm-embed-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cm-pdf-page { color: var(--sd-muted); font: 11.5px var(--sd-mono); white-space: nowrap; }
.cm-embed button {
  padding: 3px 9px; border: 1px solid var(--sd-border); border-radius: 7px; cursor: pointer;
  background: var(--sd-bg); color: var(--sd-text); font: 12px var(--sd-font);
}
.cm-embed button:hover:not(:disabled) { background: var(--sd-hover); }
.cm-embed button:disabled { opacity: 0.35; cursor: default; }
.cm-embed-tools { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity 0.15s; }
.cm-embed:hover .cm-embed-tools { opacity: 1; }
.cm-embed-tools button { background: color-mix(in srgb, var(--sd-surface) 85%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.cm-embed-note:empty { display: none; }
.cm-embed-note { padding: 10px 12px; color: var(--sd-muted); font-size: 12.5px; }
.sd-nformat button.sd-nattach { width: auto; padding: 0 9px; font-size: 12px; }
/* a PDF in a note scrolls inside its own frame */
.cm-pdf-scroll { max-height: 72vh; overflow-y: auto; overscroll-behavior: contain; background: var(--sd-bg); }
.cm-pdf-host { display: flex; flex-direction: column; gap: 10px; padding: 10px; width: calc(100% * var(--z, 1)); }
.cm-embed-edit:not(:disabled) { border-color: transparent !important; background: var(--sd-accent) !important; color: #fff !important; }

/* PDF pages (web/pdfview.js): a white box per page, drawn when it scrolls near */
.sdpdf-page { position: relative; width: 100%; background: #fff; border-radius: 4px; box-shadow: 0 2px 10px rgb(0 0 0 / 0.25); overflow: hidden; }
.sdpdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* zoom pill over a PDF (pdfview.js mount) */
.sdpdf-zoomhost { position: relative; }
.cm-pdf-host { box-sizing: border-box; margin: 0 auto; }
.sdpdf-zoom {
  position: absolute; right: 14px; bottom: 14px; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: 99px; background: var(--sd-tip-bg); /* dark in every theme: it sits on white pages */
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.3); opacity: 0.8; transition: opacity 0.15s;
}
.sdpdf-zoomhost:hover .sdpdf-zoom, .sdpdf-zoom:focus-within { opacity: 1; }
.sdpdf-zoom button {
  min-width: 28px; height: 26px; padding: 0 6px; border: 0; border-radius: 99px; background: none;
  color: var(--sd-tip-text); font: 600 15px var(--sd-font); cursor: pointer;
}
.sdpdf-zoom button:hover { background: rgb(255 255 255 / 0.14); }
.sdpdf-zoom button:focus-visible { outline: 2px solid var(--sd-accent); outline-offset: 1px; }
.sdpdf-zoom .sdpdf-zpct { min-width: 48px; font: 500 11.5px var(--sd-mono); color: var(--sd-tip-muted); }
.sdpdf-ink { mix-blend-mode: multiply; pointer-events: none; }

/* PDF editor: full screen over the app */
.sdpdf-ed {
  position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--sd-bg) 92%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); animation: sd-rise 0.2s ease both;
}
.sdpdf-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--sd-border); background: var(--sd-surface); font: 13px var(--sd-font); color: var(--sd-text);
}
.sdpdf-bar button {
  height: 30px; padding: 0 11px; border: 1px solid var(--sd-border); border-radius: 9px; cursor: pointer;
  background: var(--sd-bg); color: var(--sd-text); font: 12.5px var(--sd-font); white-space: nowrap;
}
.sdpdf-bar button:hover:not(:disabled) { background: var(--sd-hover); }
.sdpdf-bar button:disabled { opacity: 0.4; cursor: default; }
.sdpdf-bar button.primary { border-color: transparent; background: var(--sd-accent); color: #fff; }
.sdpdf-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sdpdf-tools { display: flex; gap: 2px; padding: 2px; border-radius: 11px; background: var(--sd-hover); }
.sdpdf-tools button { display: flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--sd-muted); }
.sdpdf-tools button[aria-pressed="true"] { background: var(--sd-surface); color: var(--sd-text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); }
.sdpdf-colors { display: flex; gap: 5px; }
.sdpdf-text { caret-color: #1d1d1f; }
.sdpdf-text-back {
  position: absolute; z-index: 3; box-sizing: content-box; padding: 0; margin: 0; pointer-events: none; overflow: hidden;
  border: 1px solid transparent; white-space: pre-wrap; overflow-wrap: break-word;
  font-family: -apple-system, "Segoe UI", sans-serif; line-height: 1.25;
}
/* text size, shown with the Text tool; it resizes the text being typed */
.sdpdf-size { display: flex; align-items: center; gap: 2px; }
.sdpdf-ed:not([data-tool="text"]) .sdpdf-size { display: none; }
.sdpdf-sizev { min-width: 22px; text-align: center; color: var(--sd-muted); font: 12px var(--sd-mono); }
.sdpdf-colors button { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--c) padding-box; }
.sdpdf-colors button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--sd-surface), 0 0 0 4px var(--c); }
.sdpdf-count, .sdpdf-status { color: var(--sd-muted); font: 12px var(--sd-mono); white-space: nowrap; }
.sdpdf-spacer { flex: 1; }
.sdpdf-scroll { flex: 1; overflow-y: auto; }
.sdpdf-host { display: flex; flex-direction: column; gap: 14px; width: calc(min(980px, 100% - 32px) * var(--z, 1)); margin: 18px auto 40px; }
.sdpdf-ed[data-tool="hl"] .sdpdf-page, .sdpdf-ed[data-tool="pen"] .sdpdf-page { cursor: crosshair; touch-action: none; }
.sdpdf-ed[data-tool="text"] .sdpdf-page { cursor: text; }
.sdpdf-ed[data-tool="erase"] .sdpdf-page { cursor: cell; touch-action: none; }
.sdpdf-text {
  position: absolute; z-index: 2; box-sizing: content-box; padding: 0; margin: 0; resize: none; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: break-word;
  border: 1px dashed var(--sd-accent); background: rgb(255 255 255 / 0.85); outline: none;
  font-family: -apple-system, "Segoe UI", sans-serif; line-height: 1.25;
}

/* "Jump back in": recent notes, shown when no note is open */
.sd-nrecent { height: 100%; overflow-y: auto; padding: 34px clamp(20px, 4vw, 48px); box-sizing: border-box; }
.sd-nrecent-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.sd-nrecent-head h2 {
  margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
  background-image: var(--sd-titanium); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sd-nrecent-head p { margin: 4px 0 0; color: var(--sd-muted); font-size: 13px; }
.sd-nrecent-head .sd-btn { display: inline-flex; align-items: center; gap: 6px; }
.sd-nrecent-head .sd-btn svg { width: 13px; height: 13px; }
.sd-nrecent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.sd-nrecent-card {
  display: flex; flex-direction: column; gap: 8px; min-height: 138px; padding: 14px 16px; box-sizing: border-box;
  border: 1px solid var(--sd-border); border-radius: 16px; background: var(--sd-surface); color: var(--sd-text);
  text-align: left; font: inherit; cursor: pointer;
  box-shadow: inset 0 1px 0 rgb(var(--sd-light) / var(--sd-edge-max));
  animation: sd-rise 0.35s ease both; animation-delay: calc(var(--i) * 35ms);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.sd-nrecent-card:hover { border-color: color-mix(in srgb, var(--sd-accent) 55%, var(--sd-border)); transform: translateY(-2px); box-shadow: 0 0 22px -8px var(--sd-accent); }
.sd-nrecent-card:focus-visible { outline: 2px solid var(--sd-accent); outline-offset: 2px; }
.sd-nrecent-top { display: flex; align-items: center; gap: 6px; color: var(--sd-muted); font-size: 11.5px; }
.sd-nrecent-top svg { width: 13px; height: 13px; flex: none; }
.sd-nrecent-folder { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-nrecent-card b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-nrecent-snip {
  color: var(--sd-muted); font-size: 12.5px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
html.reduce-motion .sd-nrecent-card { animation: none; }

/* Read aloud: the player in the toolbar, and the highlight in the note */
.sd-read-go { display: inline-flex; align-items: center; gap: 6px; }
.sd-read-go svg { width: 11px; height: 11px; }
.sd-reader button { display: inline-grid; place-items: center; }
.sd-reader button svg { width: 13px; height: 13px; }
.sd-reader {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px; border: 1px solid var(--sd-border); border-radius: 12px;
  background: var(--sd-surface); box-shadow: 0 0 18px -8px var(--sd-accent); animation: sd-rise 0.2s ease both;
}
.sd-reader button {
  min-width: 28px; height: 26px; padding: 0 6px; border: 0; border-radius: 8px; cursor: pointer;
  background: none; color: var(--sd-muted); font: 12px var(--sd-font);
}
.sd-reader button:hover { background: var(--sd-hover); color: var(--sd-text); }
.sd-reader .sd-read-pp { background: var(--sd-accent); color: #fff; }
.sd-reader .sd-read-pp:hover { background: var(--sd-accent); color: #fff; filter: brightness(1.1); }
.sd-read-pos { min-width: 36px; padding: 0 4px; color: var(--sd-muted); font: 11px var(--sd-mono); text-align: center; }
.sd-reader select {
  height: 26px; max-width: 130px; padding: 0 6px; border: 1px solid var(--sd-border); border-radius: 8px;
  background: var(--sd-bg); color: var(--sd-text); font: 12px var(--sd-font);
}
.cm-read-s { background: color-mix(in srgb, var(--sd-accent) 12%, transparent); border-radius: 3px; }
.cm-read-w { background: color-mix(in srgb, var(--sd-accent) 38%, transparent); border-radius: 3px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--sd-accent) 45%, transparent); }

/* Recordings in notes (Voice Memos and other audio) and their clickable [12:30] times */
.cm-embed-audio, .cm-embed-file { border: 1px solid var(--sd-border); border-radius: 14px; background: var(--sd-surface); overflow: hidden; }
.cm-embed-file .cm-embed-bar { border-bottom: 0; padding: 9px 8px 9px 14px; font-size: 13.5px; }
.cm-audio { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.cm-audio-pp {
  display: grid !important; place-items: center; width: 34px; height: 34px; padding: 0 !important; flex: none;
  border: 0 !important; border-radius: 50% !important; background: var(--sd-accent) !important; color: #fff !important;
}
.cm-audio-pp svg { width: 14px; height: 14px; }
.cm-embed-audio.playing .cm-audio-pp { box-shadow: 0 0 16px -3px var(--sd-accent); }
.cm-audio-t, .cm-audio-dur { min-width: 44px; color: var(--sd-muted); font: 12px var(--sd-mono); text-align: center; }
.cm-audio-bar {
  flex: 1; height: 4px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 99px; cursor: pointer;
  background: linear-gradient(90deg, var(--sd-accent) var(--p, 0%), var(--sd-hover) var(--p, 0%));
}
.cm-audio-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.4); }
.cm-audio-speed { height: 28px; padding: 0 4px; border: 1px solid var(--sd-border); border-radius: 8px; background: var(--sd-bg); color: var(--sd-text); font: 12px var(--sd-font); }
.cm-embed-ai { border-color: transparent !important; background: color-mix(in srgb, var(--sd-accent) 18%, transparent) !important; color: var(--sd-accent) !important; }
.cm-embed-ai:hover { background: var(--sd-accent) !important; color: #fff !important; }
.cm-ts {
  padding: 0 4px; border-radius: 5px; cursor: pointer;
  background: color-mix(in srgb, var(--sd-accent) 14%, transparent); color: var(--sd-accent); font: 0.86em var(--sd-mono);
}
.cm-ts:hover { background: var(--sd-accent); color: #fff; }

/* Anki Inbox: recordings waiting to be added, on "Jump back in" */
.sd-memos { margin: 0 0 22px; padding: 14px 16px; border: 1px solid var(--sd-border); border-radius: 16px; background: var(--sd-surface); }
.sd-memos-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.sd-memos .sd-link { border: 0; background: none; color: var(--sd-accent); font: 12.5px var(--sd-font); cursor: pointer; }
.sd-memo { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--sd-border); }
.sd-memos-head + .sd-memo { border-top: 0; }
.sd-memo-ic {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px;
  background: color-mix(in srgb, #ff453a 16%, transparent); font-size: 16px;
}
.sd-memo-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.sd-memo-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.sd-memo-main small { color: var(--sd-muted); font-size: 12px; }
.sd-memo-done { color: var(--sd-review); font-size: 12.5px; white-space: nowrap; }
.sd-memos-hint p { margin: 2px 0 0; font-size: 12.5px; }
.sd-memos-head span { display: flex; gap: 12px; }
.sd-setup { margin: 12px 0 2px; padding-left: 20px; color: var(--sd-text); font-size: 13px; line-height: 1.7; }
.sd-setup b { font-weight: 600; }
.sd-nempty .sd-memos { max-width: 720px; text-align: left; }
