/* Notes — visual layer (notes-visual.js): subject icons, coloured note cards, "Notes desk" in the empty editor.
   Loaded last in index.html; every rule is scoped to #notes-main.nv-on. */
#notes-main.nv-on {
  --nv-paper: #FFFDF7; --nv-rule: rgba(30, 64, 175, .07); --nv-gold: #B7791F;
  --nv-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Sans Devanagari", serif;
}
:root[data-theme="dark"] #notes-main.nv-on { --nv-paper: #161E31; --nv-rule: rgba(148, 163, 184, .07); --nv-gold: #F6C453; }

/* ---------- folder list ---------- */
#notes-main.nv-on #groups .group-row > button.nv-folder { display: flex !important; align-items: center; gap: 10px; }
#notes-main.nv-on .nv-ico {
  width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: 14px;
  background: color-mix(in srgb, var(--sc) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sc) 22%, transparent);
}
#notes-main.nv-on .nv-folder-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
#notes-main.nv-on .nv-count { flex: none; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--sc) 14%, transparent); color: var(--sc); }
#notes-main.nv-on #groups .group-row.topic > button.nv-folder::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sc); flex: none; margin-left: 4px; }
#notes-main.nv-on #groups .group-row > button.nv-folder.active { box-shadow: inset 3px 0 0 var(--sc) !important; }

/* ---------- note cards ---------- */
#notes-main.nv-on #notes .note-card.nv-card {
  position: relative; border-radius: 14px !important; padding: 12px 14px 11px 16px !important; margin: 0 0 8px !important;
  background: var(--color-surface) !important; border: 1px solid var(--color-border-subtle) !important; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
#notes-main.nv-on #notes .note-card.nv-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sc); }
#notes-main.nv-on #notes .note-card.nv-card:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -16px var(--sc); }
#notes-main.nv-on #notes .note-card.nv-card.active { border-color: color-mix(in srgb, var(--sc) 55%, var(--color-border)) !important; background: color-mix(in srgb, var(--sc) 7%, var(--color-surface)) !important; }
#notes-main.nv-on #notes .note-card.nv-card strong { font-family: var(--nv-serif); font-size: 15px !important; }
#notes-main.nv-on #notes .note-card.nv-card small { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
#notes-main.nv-on .nv-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--sc) 13%, transparent); color: var(--sc); max-width: 70%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#notes-main.nv-on .nv-when { font-size: 11px; color: var(--color-muted); }
#notes-main.nv-on #notes > p.nv-list-empty { text-align: center; padding: 34px 14px !important; margin: 6px 0 !important; border: 1.5px dashed var(--color-border); border-radius: 16px; color: var(--color-text-secondary); font-size: 13.5px; }
#notes-main.nv-on #notes > p.nv-list-empty::before { content: "🗂️"; display: block; font-size: 34px; margin-bottom: 8px; }

/* ---------- notes desk (empty editor) ---------- */
#notes-main.nv-on #empty.nv-has-desk { max-width: 1060px !important; width: 100%; margin: 0 auto !important; padding: 28px clamp(16px, 3vw, 40px) 40px !important; text-align: left !important; box-sizing: border-box; container-type: inline-size; }
#notes-main.nv-on #empty.nv-has-desk > :not(#nv-desk) { display: none !important; }
#notes-main .nv-desk { display: flex; flex-direction: column; gap: 28px; color: var(--color-text); }

#notes-main .nv-head {
  position: relative; overflow: hidden; border-radius: 22px; padding: 24px 26px 22px 38px;
  background: repeating-linear-gradient(to bottom, transparent 0 31px, var(--nv-rule) 31px 32px), var(--nv-paper);
  border: 1px solid var(--color-border); box-shadow: 0 18px 40px -30px rgba(15, 23, 42, .45);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px 24px;
}
#notes-main .nv-head::before { content: ""; position: absolute; left: 22px; top: 0; bottom: 0; width: 2px; background: linear-gradient(#E11D48, rgba(225, 29, 72, .15)); }
#notes-main .nv-eyebrow { margin: 0 0 6px !important; font-size: 11.5px !important; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--nv-gold) !important; }
#notes-main .nv-head h2 { margin: 0 0 6px !important; font: 700 clamp(24px, 2.4vw, 30px)/1.2 var(--nv-serif) !important; color: var(--color-text) !important; letter-spacing: -.01em; }
#notes-main .nv-sub { margin: 0 !important; font-size: 14px !important; color: var(--color-text-secondary) !important; }
#notes-main .nv-stats { display: grid; grid-template-columns: repeat(4, minmax(78px, 1fr)); gap: 8px; }
#notes-main .nv-stat { text-align: center; padding: 10px 8px; border-radius: 14px; background: var(--color-surface); border: 1px solid var(--color-border); }
#notes-main .nv-stat-ico { display: block; font-size: 16px; line-height: 1; margin-bottom: 4px; }
#notes-main .nv-stat strong { display: block; font-size: 20px; font-weight: 800; line-height: 1.15; color: var(--color-text); font-variant-numeric: tabular-nums; }
#notes-main .nv-stat small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-muted); }

#notes-main .nv-sec h3 { margin: 0 0 12px !important; font: 700 19px/1.3 var(--nv-serif) !important; color: var(--color-text) !important; }
#notes-main .nv-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
#notes-main .nv-link { background: none !important; border: 0 !important; padding: 4px 6px !important; color: var(--color-primary) !important; font-weight: 650 !important; font-size: 13px !important; cursor: pointer; }

/* templates: little paper pages */
#notes-main .nv-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
#notes-main .nv-tpl {
  --sc: var(--color-text-secondary);
  display: flex !important; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 12px !important; border-radius: 16px !important; background: var(--color-surface) !important; border: 1px solid var(--color-border) !important;
  cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; color: var(--color-text) !important;
}
#notes-main .nv-tpl:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--sc) 50%, var(--color-border)) !important; box-shadow: 0 16px 30px -20px var(--sc); }
#notes-main .nv-page {
  position: relative; width: 100%; height: 112px; margin-bottom: 8px; border-radius: 10px; padding: 12px 12px 10px 18px; box-sizing: border-box;
  background: repeating-linear-gradient(to bottom, transparent 0 19px, var(--nv-rule) 19px 20px), var(--nv-paper);
  border: 1px solid var(--color-border-subtle); display: flex; flex-direction: column; gap: 6px; overflow: hidden;
}
#notes-main .nv-page::before { content: ""; position: absolute; left: 9px; top: 0; bottom: 0; width: 1.5px; background: color-mix(in srgb, var(--sc) 55%, transparent); }
#notes-main .nv-page-ico { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; background: color-mix(in srgb, var(--sc) 15%, transparent); }
#notes-main .nv-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
#notes-main .nv-line b { font: 700 9.5px/1 var(--font-sans); text-transform: uppercase; letter-spacing: .05em; color: var(--sc); white-space: nowrap; }
#notes-main .nv-line i { flex: 1; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--color-text-secondary) 18%, transparent); }
#notes-main .nv-tpl strong { font-size: 14.5px; font-weight: 750; }
#notes-main .nv-tpl small { font-size: 12px; color: var(--color-text-secondary); line-height: 1.35; }
#notes-main .nv-tpl.blank .nv-page { display: grid; place-items: center; background: var(--nv-paper); border-style: dashed; border-width: 1.5px; border-color: var(--color-border); }
#notes-main .nv-tpl.blank .nv-page::before { display: none; }
#notes-main .nv-plus { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 400; color: #fff; background: linear-gradient(135deg, #6366F1, #8B5CF6); box-shadow: 0 10px 20px -10px #6366F1; }

/* subject shelf: book-like tiles */
#notes-main .nv-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
#notes-main .nv-book {
  position: relative; display: flex !important; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; overflow: hidden;
  padding: 14px 14px 12px 20px !important; border-radius: 6px 14px 14px 6px !important; cursor: pointer;
  background: linear-gradient(135deg, color-mix(in srgb, var(--sc) 14%, var(--color-surface)), var(--color-surface)) !important;
  border: 1px solid color-mix(in srgb, var(--sc) 25%, var(--color-border)) !important; color: var(--color-text) !important;
  transition: transform .16s ease, box-shadow .16s ease;
}
#notes-main .nv-book::before { /* book spine */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--sc) 80%, #000), var(--sc));
}
#notes-main .nv-book::after { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .35); }
#notes-main .nv-book:hover { transform: translateY(-3px) rotate(-.4deg); box-shadow: 0 16px 28px -18px var(--sc); }
#notes-main .nv-book-ico { font-size: 22px; margin-bottom: 4px; }
#notes-main .nv-book strong { font-size: 14px; font-weight: 750; font-family: var(--nv-serif); }
#notes-main .nv-book small { font-size: 12px; color: var(--color-text-secondary); }
#notes-main .nv-book-bar { display: block; width: 100%; height: 4px; margin-top: 8px; border-radius: 999px; background: color-mix(in srgb, var(--sc) 14%, transparent); overflow: hidden; }
#notes-main .nv-book-bar i { display: block; height: 100%; background: var(--sc); border-radius: inherit; min-width: 0; }

/* recent notes */
#notes-main .nv-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
#notes-main .nv-rcard {
  display: flex !important; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; position: relative; overflow: hidden;
  padding: 14px 14px 12px 18px !important; border-radius: 14px !important; cursor: pointer;
  background: var(--color-surface) !important; border: 1px solid var(--color-border) !important; color: var(--color-text) !important;
  transition: transform .15s ease, box-shadow .15s ease;
}
#notes-main .nv-rcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sc); }
#notes-main .nv-rcard:hover { transform: translateY(-2px); box-shadow: 0 14px 26px -18px var(--sc); }
#notes-main .nv-rcard strong { font: 700 15px/1.35 var(--nv-serif); }
#notes-main .nv-rcard p { margin: 0 !important; font-size: 12.5px !important; color: var(--color-text-secondary) !important; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#notes-main .nv-rcard small { font-size: 11.5px; color: var(--color-muted); }
#notes-main .nv-empty { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 16px; border: 1.5px dashed var(--color-border); }
#notes-main .nv-empty-art { font-size: 40px; }
#notes-main .nv-empty p { margin: 0 !important; font-size: 13.5px !important; color: var(--color-text-secondary) !important; line-height: 1.5; }

@container (max-width: 820px) {
  #notes-main .nv-head { grid-template-columns: 1fr; }
}
@container (max-width: 520px) {
  #notes-main .nv-head { padding: 20px 16px 18px 30px; }
  #notes-main .nv-head::before { left: 15px; }
  #notes-main .nv-stats { grid-template-columns: repeat(2, 1fr); }
  #notes-main .nv-tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #notes-main .nv-page { height: 92px; }
  #notes-main .nv-shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { #notes-main.nv-on * { transition: none !important; } }

/* editor: classic serif title */
#notes-main.nv-on #title.document-title-input { font-family: var(--nv-serif) !important; font-weight: 700 !important; letter-spacing: -.005em !important; }
#notes-main .nv-rcard strong, #notes-main .nv-book strong, #notes-main .nv-tpl strong { white-space: normal; overflow-wrap: anywhere; }
#notes-main .nv-tpl, #notes-main .nv-book, #notes-main .nv-rcard { min-width: 0; white-space: normal; }
#notes-main .nv-tpl small, #notes-main .nv-book small { white-space: normal; overflow-wrap: anywhere; }
