/* ---- Notes ------------------------------------------------------------------
   Classes down the side, a class's items as cards, an item opened in place. */
.notes-side { width: 260px; flex-shrink: 0; border-right: 1px solid var(--glass-brd); background: var(--glass); backdrop-filter: blur(var(--glass-blur)) saturate(150%); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%); overflow-y: auto; padding: 16px 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.notes-side > * { flex-shrink: 0; }
.nb-side-item { padding: 8px 10px; gap: 10px; }
.notes-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.nb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cls); flex-shrink: 0; display: inline-block; }
.nb-dot.lg { width: 14px; height: 14px; border-radius: 5px; }

.nb-lib { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.nb-head { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--glass-2); backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%); flex-shrink: 0; }
.nb-scopes { display: none; gap: 6px; padding: 10px 14px 0; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.nb-scopes::-webkit-scrollbar { display: none; }
.nb-scopes .chip { white-space: nowrap; flex-shrink: 0; }
.nb-filters { display: flex; align-items: center; gap: 10px; padding: 12px 18px 4px; flex-wrap: wrap; flex-shrink: 0; }
.nb-filters .segmented { overflow-x: auto; max-width: 100%; }
.nb-count { margin-left: 5px; font-size: 10.5px; color: var(--text-3); font-weight: 600; }
.segmented .on .nb-count { color: inherit; opacity: .7; }
.nb-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 18px 40px; }
@media (max-width: 1000px) { .notes-side { display: none; } .nb-scopes { display: flex; } }
@media (max-width: 760px) { .nb-head { padding: 8px 12px; } .nb-filters { padding: 10px 12px 2px; } .nb-scroll { padding: 8px 12px 30px; } }

/* ---- Unit folders ---- */
.nb-section-head { display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 8px; }
.nb-section-head + .nb-grid { margin-bottom: 4px; }
.nb-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 22px; }
.nb-folder-wrap { position: relative; min-width: 0; }
.nb-folder { display: flex; align-items: center; gap: 12px; width: 100%; height: 64px; padding: 0 40px 0 12px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text); transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s, background .2s; }
.nb-folder:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--cls) 55%, var(--border)); }
.nb-folder-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: color-mix(in srgb, var(--cls) 16%, transparent); color: var(--cls); }
.nb-folder-name { display: block; font-weight: 600; font-size: 13.5px; }
.nb-folder-menu { position: absolute; right: 6px; top: 50%; margin-top: -15px; opacity: .6; }
.nb-folder-wrap:hover .nb-folder-menu { opacity: 1; }
.nb-folder.add { justify-content: center; padding: 0 12px; border-style: dashed; box-shadow: none; background: none; color: var(--text-2); font-weight: 500; font-size: 13px; gap: 8px; }
.nb-folder.add:hover { color: var(--accent); border-color: var(--accent); transform: none; box-shadow: none; }
.nb-folder.drop-hot, .nb-crumb.drop-hot { border-color: var(--cls, var(--accent)); background: color-mix(in srgb, var(--cls, var(--accent)) 14%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cls, var(--accent)) 30%, transparent); }
.nb-crumb { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; border: 1px solid transparent; background: none; padding: 0 4px; margin-left: -4px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.nb-crumb:hover { color: var(--accent); }
.nb-side-folder { padding: 6px 10px 6px 30px; gap: 8px; font-size: 13px; }
.nb-side-folder svg { color: var(--cls); flex-shrink: 0; }
.nb-pick-folder { padding-left: 34px; gap: 9px; font-size: 13px; }
.nb-pick-folder svg:first-child { color: var(--cls); }
.nb-card.dragging { opacity: .45; }
@media (max-width: 520px) { .nb-folders { grid-template-columns: 1fr 1fr; gap: 8px; } .nb-folder { height: 58px; gap: 9px; padding-right: 34px; } .nb-folder-icon { width: 32px; height: 32px; } }

.nb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .nb-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.nb-card { display: flex; flex-direction: column; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; min-width: 0; }
.nb-card:hover, .nb-card:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--cls) 55%, var(--border)); outline: none; }
.nb-thumb { height: 116px; position: relative; overflow: hidden; display: grid; place-items: center; background: color-mix(in srgb, var(--cls) 12%, var(--surface-2)); border-bottom: 1px solid var(--border); color: color-mix(in srgb, var(--cls) 70%, var(--text)); }
.nb-thumb::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cls); z-index: 1; }
.nb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nb-paper { position: absolute; inset: 12px 14px 0 18px; padding: 10px 12px; background: var(--surface); border-radius: 8px 8px 0 0; box-shadow: var(--shadow-sm); font-size: 10.5px; line-height: 1.55; color: var(--text-2); overflow: hidden;
  background-image: repeating-linear-gradient(transparent 0 15.5px, var(--border) 15.5px 16.5px); background-position: 0 9px; }
.nb-stack { position: relative; width: 110px; height: 72px; }
.nb-stack i, .nb-stack div { position: absolute; inset: 0; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.nb-stack i:nth-child(1) { transform: rotate(-7deg) translate(-6px, 2px); }
.nb-stack i:nth-child(2) { transform: rotate(4deg) translate(5px, -1px); }
.nb-stack div { display: grid; place-items: center; align-content: center; font-family: var(--font-display); font-size: 26px; color: var(--text); line-height: 1; }
.nb-stack small { font-family: var(--font); font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.nb-slide { width: 128px; aspect-ratio: 16 / 9; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: grid; place-items: center; align-content: center; gap: 4px; }
.nb-slide small, .nb-filethumb b { font-size: 10.5px; color: var(--text-3); font-weight: 600; letter-spacing: .04em; }
.nb-filethumb { display: grid; place-items: center; gap: 6px; }
.nb-card-body { padding: 10px 12px 11px; display: flex; flex-direction: column; flex: 1; min-width: 0; }
.nb-card-title { font-weight: 600; font-size: 13.5px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.nb-card-menu { margin: -4px -6px 0 0; opacity: .6; }
.nb-card:hover .nb-card-menu { opacity: 1; }
.nb-card-preview { font-size: 12px; line-height: 1.45; color: var(--text-3); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.nb-card-meta { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 9px; font-size: 11.5px; color: var(--text-3); min-width: 0; }
.nb-card-meta .tag { flex-shrink: 0; }
.nb-card-meta > :last-child { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 520px) {
  .nb-card-meta .nb-card-class { display: none; }
  .nb-thumb { height: 96px; }
  .nb-card-meta .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
}

.nb-welcome { max-width: 640px; margin: 30px auto; text-align: center; }
.nb-welcome p { line-height: 1.6; }
.nb-welcome-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0 24px; text-align: left; }
.nb-welcome-points > div { padding: 14px; border-radius: 13px; border: 1px solid var(--glass-brd); background: var(--glass-2); display: flex; flex-direction: column; gap: 4px; }
.nb-welcome-points svg { color: var(--accent); margin-bottom: 4px; }
.nb-welcome-points span { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
@media (max-width: 600px) { .nb-welcome-points { grid-template-columns: 1fr; } }

.nb-drop { position: absolute; inset: 8px; z-index: 6; border: 2px dashed var(--accent); border-radius: 16px; background: color-mix(in srgb, var(--accent-soft) 80%, var(--bg)); display: grid; place-items: center; text-align: center; color: var(--accent); pointer-events: none; }
.nb-uploads { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.nb-upload { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }

/* ---- An open item ---- */
.nb-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.nb-pane-head { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--glass-2); backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%); flex-shrink: 0; }
.nb-title-input { min-width: 0; border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 8px; font-family: var(--font-display); font-size: 21px; color: var(--text); outline: none; }
.nb-title-input:hover { border-color: var(--border); }
.nb-title-input:focus { border-color: var(--accent); box-shadow: var(--focus); background: var(--surface); }
.nb-save { color: var(--text-3); white-space: nowrap; }
.nb-save.err { color: var(--danger); font-weight: 600; }
@media (max-width: 600px) { .nb-save { display: none; } .nb-title-input { font-size: 18px; } }
.nb-pane-body { flex: 1; min-height: 0; overflow-y: auto; }
.nb-sheet { max-width: 820px; margin: 0 auto; padding: 22px 24px 60px; }
.nb-sheet.wide { max-width: 1100px; }
@media (max-width: 600px) { .nb-sheet { padding: 16px 14px 40px; } }
.nb-tools { display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--border); border-bottom: none; border-radius: 12px 12px 0 0; background: var(--surface-2); flex-wrap: wrap; }
.nb-tool { min-width: 32px; height: 30px; padding: 0 7px; border: none; background: none; border-radius: 7px; color: var(--text-2); display: grid; place-items: center; font-size: 14px; }
.nb-tool:hover { background: var(--hover); color: var(--text); }
.nb-editor { display: block; width: 100%; min-height: max(360px, calc(100dvh - 300px)); resize: vertical; border: 1px solid var(--border); border-radius: 0 0 12px 12px; background: var(--surface); color: var(--text); padding: 18px 20px; font: inherit; font-size: 15px; line-height: 1.7; outline: none; }
.nb-editor:focus { border-color: var(--accent); box-shadow: var(--focus); }
.nb-read { font-size: 15.5px; line-height: 1.75; }
.nb-att-media { position: relative; }
.nb-att-x { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, .55); color: #fff; opacity: 0; transition: opacity .15s; }
.nb-att-media:hover .nb-att-x, .nb-att-x:focus-visible { opacity: 1; }
@media (hover: none) { .nb-att-x { opacity: 1; } }
.nb-preview-img { display: block; max-width: 100%; max-height: 72vh; border: none; padding: 0; border-radius: 12px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.nb-preview-img img { object-fit: contain !important; }
.nb-preview-video { width: 100%; max-height: 72vh; border-radius: 12px; background: #000; }
.nb-pdf { width: 100%; height: min(78vh, 1000px); border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.nb-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: 14px; line-height: 1.65; margin: 0; padding: 18px 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.import-row.picked { background: var(--accent-soft); }

/* ---- Flashcards ---- */
.fc-list { display: flex; flex-direction: column; gap: 8px; }
.fc-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: 8px; align-items: start; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.fc-row.known { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.fc-row.known .fc-n { color: var(--success); }
.fc-row .textarea { min-height: 44px; resize: vertical; font-size: 14px; }
.fc-q { font-weight: 600; }
.fc-n { font-size: 12px; font-weight: 700; color: var(--text-3); padding-top: 12px; text-align: center; }
.fc-row .icon-btn { margin-top: 6px; }
@media (max-width: 600px) {
  .fc-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .fc-n { display: none; }
  .fc-a { grid-column: 1 / -1; grid-row: 2; }
}

.study { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: var(--bg); animation: pop .16s var(--ease); }
.study-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--glass-2); flex-wrap: wrap; }
.study-stage { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 18px; }
.flash { width: min(680px, 100%); aspect-ratio: 16 / 10; max-height: 62vh; perspective: 1600px; border: none; background: none; padding: 0; cursor: pointer; color: var(--text); }
.flash-in { position: relative; width: 100%; height: 100%; transition: transform .5s var(--ease); transform-style: preserve-3d; }
.flash.flipped .flash-in { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; padding: 40px 32px 28px; overflow-y: auto; }
.flash-face.back { transform: rotateY(180deg); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.flash-text { margin: auto; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; font-size: clamp(17px, 2.6vw, 26px); line-height: 1.45; }
.flash-face:not(.back) .flash-text { font-weight: 600; }
.flash-tag { position: absolute; top: 14px; left: 18px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.study-actions { display: flex; gap: 12px; margin-top: 22px; width: min(680px, 100%); }
.study-actions .btn { flex: 1; justify-content: center; }
.study-yes { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.study-yes:hover { background: var(--success); color: #fff; }
.study-no { background: var(--surface); }
.study-done { text-align: center; max-width: 480px; }
@media (prefers-reduced-motion: reduce) { .flash-in { transition: none; } }

/* ---- Documents, laid out ---- */
.nb-doc { display: flex; flex-direction: column; gap: 14px; }
.nb-doc-sec { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 16px 20px 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.nb-doc.k-slides .nb-doc-sec { border-left: 4px solid var(--accent); }
.nb-doc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.nb-doc-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 19px; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.nb-doc-num { min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; flex-shrink: 0; }
.nb-doc-sec .md { font-size: 14.5px; }
.nb-doc-picrow { display: grid; grid-template-columns: minmax(160px, 260px) minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 12px; }
.nb-doc-picrow:not(:has(.nb-doc-reading)) { grid-template-columns: minmax(160px, 320px); }
.nb-doc-reading { min-width: 0; padding-left: 14px; border-left: 2px solid var(--border); }
.nb-doc-reading .nb-by { margin-bottom: 6px; }
@media (max-width: 700px) { .nb-doc-picrow { grid-template-columns: 1fr; } .nb-doc-reading { padding-left: 0; border-left: none; } }
.nb-by { flex-shrink: 0; display: inline-flex; gap: 4px; }
.nb-by.aria { background: var(--accent-soft); color: var(--accent); }
.nb-aria-read { align-items: flex-start; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.nb-aria-read .switch { margin-top: 2px; }
.nb-doc-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.nb-doc-pic { border: 1px solid var(--border); border-radius: 10px; padding: 0; background: var(--surface-2); overflow: hidden; cursor: zoom-in; aspect-ratio: 4 / 3; }
.nb-doc-pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.nb-doc-notes { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; line-height: 1.55; color: var(--text-2); white-space: pre-wrap; }
.nb-doc-notes b { display: block; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.nb-figure { margin: 14px 0; }
.nb-figure-img { display: block; max-width: 100%; max-height: 520px; border: 1px solid var(--border); border-radius: 12px; padding: 0; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.nb-figure-img img { object-fit: contain !important; max-height: 520px; }
.nb-figure figcaption { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.nb-read .md + .md, .nb-read .nb-figure + .md { margin-top: 12px; }
.nb-read hr { margin: 26px 0; }
/* Save as notes or files */
.nb-mode { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--text); text-align: left; transition: border-color .15s, background .15s; }
.nb-mode:hover, .nb-mode:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.nb-mode.on { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.nb-mode-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.nb-read .md { font-size: 15.5px; line-height: 1.75; }
.nb-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; min-width: 0; }
.nb-crumbs .nb-crumb { max-width: 180px; }
