/* ── NOTES MODULE ─────────────────────────────────────────────────────────
   Freeform-canvas notes (OneNote-style): one open page with a page-wide ink
   layer + positioned text/image/math boxes. Naming: nt- prefix throughout
   (module code in js/modules/notes.js). */

.nt-wrap { display: flex; gap: 18px; align-items: flex-start; }
.nt-rail { flex: 0 0 240px; min-width: 210px; position: sticky; top: 8px; }
.nt-main { flex: 1; min-width: 320px; }

.nt-rail .card { padding: 12px; margin-bottom: 12px; }
.nt-rail-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 4px;
  font-size: 13px; color: var(--cream); cursor: pointer; text-decoration: none;
}
.nt-rail-item:hover { background: rgba(201,169,110,0.07); }
.nt-rail-item.active { background: rgba(201,169,110,0.12); color: var(--gold); font-weight: 600; }
.nt-rail-item .nt-count { margin-left: auto; font-size: 11px; color: var(--text-dim); }
/* category tree */
.nt-cat-chev { width: 16px; color: var(--text-dim); font-size: 10px; flex: 0 0 auto; }
.nt-cat-chev:hover { color: var(--gold); }
.nt-sub-item { padding-left: 30px; font-size: 12.5px; }
.nt-sub-add { color: var(--text-dim); font-size: 11.5px; }
.nt-sub-add:hover { color: var(--gold); }
.nt-sub-actions { display: none; gap: 2px; margin-left: 6px; }
.nt-sub-item:hover .nt-sub-actions { display: inline-flex; }
.nt-sub-actions button {
  background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 0 3px; font-size: 12px;
}
.nt-sub-actions button:hover { color: var(--gold); }
/* dashboard-widget toggle button state */
.nt-editor-tools .btn-secondary.nt-on { color: var(--gold); border-color: var(--gold); background: rgba(201,169,110,0.1); }
.nt-search-input {
  width: 100%; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 3px; color: var(--cream); font-size: 13px; font-family: 'DM Sans', sans-serif;
}
.nt-search-input:focus { border-color: var(--gold); outline: none; }

/* note list */
.nt-note-row {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 5px; margin-bottom: 10px;
  background: var(--navy-mid); cursor: pointer; transition: border-color .15s;
}
.nt-note-row:hover { border-color: var(--border-bright); }
.nt-note-title { font-size: 14.5px; color: var(--cream); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.nt-note-preview { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.45;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nt-note-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.nt-chip {
  font-size: 10.5px; padding: 2px 9px; border-radius: 10px; border: 1px solid var(--border);
  color: var(--text-muted); white-space: nowrap;
}
.nt-chip.nt-client { color: var(--gold); border-color: var(--border-bright); }
.nt-chip.nt-tag { cursor: pointer; }
.nt-chip.nt-tag:hover { color: var(--gold); border-color: var(--border-bright); }
.nt-note-upd { margin-left: auto; font-size: 11px; color: var(--text-dim); }
.nt-pin { color: var(--gold); font-size: 12px; }

/* editor header */
.nt-editor-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.nt-title-input {
  flex: 1; min-width: 240px; background: none; border: none; outline: none;
  font-family: 'Cormorant Garamond', serif; font-size: 26px; color: var(--cream); padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.nt-title-input:focus { border-bottom-color: var(--border-bright); }
.nt-save-state { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.nt-save-state.saving { color: #e08a3c; }
.nt-save-state.saved { color: var(--success); }
.nt-editor-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.nt-editor-tools select {
  padding: 7px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 3px; color: var(--cream); font-size: 12.5px; font-family: 'DM Sans', sans-serif;
}

/* mode toolbar (one bar for the whole page) */
.nt-ink-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px;
  position: sticky; top: 0; z-index: 40; margin: 6px 0 10px;
  -webkit-user-select: none; user-select: none;
}
.nt-tb-sep { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }
.nt-ink-btn {
  min-width: 44px; height: 38px; display: flex; align-items: center; justify-content: center; gap: 4px;
  background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--text-muted);
  cursor: pointer; font-size: 13px; padding: 0 10px; touch-action: manipulation;
}
.nt-ink-btn.active { color: var(--gold); border-color: var(--gold); background: rgba(201,169,110,0.1); }
.nt-ink-btn:disabled { opacity: .35; cursor: default; }
.nt-ink-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.nt-ink-swatch.active { border-color: var(--gold); }
/* swatch grid: 2 even rows of 6 (inks then light highlight pastels) */
.nt-swatch-rows { display: grid; grid-template-columns: repeat(6, 18px); gap: 4px; }
.nt-swatch-rows .nt-ink-swatch { width: 18px; height: 18px; }
/* thickness slider */
.nt-size-wrap { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.nt-size-wrap input[type=range] { width: 90px; accent-color: var(--gold); cursor: pointer; touch-action: manipulation; }
.nt-size-wrap #ntSizeDot { border-radius: 50%; background: var(--cream); display: inline-block; transition: width .1s, height .1s; }

/* ── the PAGE ── */
.nt-page-scroll { overscroll-behavior: contain; }
.nt-page {
  position: relative; width: 100%; min-height: 400px;
  background: #10141f;
  background-image: radial-gradient(rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  border: 1px solid var(--border); border-radius: 5px; overflow: hidden;
  /* nothing on the page is natively selectable/callout-able — a drag over
     KaTeX glyphs or text must never turn into a selection that cancels the
     pointer stream mid-stroke. Edit-mode textareas re-enable below. */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none;
}
.nt-page textarea, .nt-page input { -webkit-user-select: text; user-select: text; }
/* touch-action resolution WALKS UP ONLY TO THE NEAREST SCROLLER — an inner
   overflow:auto element (math boxes scroll horizontally for wide formulas)
   swallows the page's touch-action:none, so pen/finger strokes starting on a
   formula got claimed as scroll attempts and pointercancel'd mid-stroke.
   Every descendant is explicitly non-scrollable-by-gesture; edit-mode fields
   keep native behaviour. */
.nt-page *:not(textarea):not(input):not(select) { touch-action: none; }
.nt-page-ink { position: absolute; inset: 0; width: 100%; z-index: 30; pointer-events: none; }

/* boxes */
.nt-box { position: absolute; z-index: 10; min-height: 30px; border-radius: 4px; border: 1px solid transparent; }
.nt-box:hover, .nt-box.editing { border-color: rgba(201,169,110,0.25); background: rgba(11,15,30,0.35); }
.nt-box-chrome {
  position: absolute; top: -30px; left: 0; display: none; gap: 2px; align-items: center; z-index: 12;
}
.nt-box:hover .nt-box-chrome, .nt-box.editing .nt-box-chrome { display: flex; }
.nt-box-drag {
  width: 34px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: rgba(11,15,30,0.9); border: 1px solid var(--border-bright); border-radius: 3px;
  color: var(--text-muted); cursor: grab; touch-action: none;
}
.nt-box-drag:active { cursor: grabbing; }
.nt-box-x {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: rgba(11,15,30,0.9); border: 1px solid var(--border); border-radius: 3px;
  color: var(--text-muted); cursor: pointer; padding: 0;
}
.nt-box-x:hover { color: var(--danger); border-color: var(--danger); }
.nt-box-resize {
  position: absolute; top: 0; right: -6px; width: 12px; height: 100%; cursor: ew-resize;
  touch-action: none; z-index: 12;
}
.nt-box:hover .nt-box-resize::after {
  content: ''; position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 3px; height: 26px; border-radius: 2px; background: var(--border-bright);
}

/* box content — user-select none so a touch-drag over text PANS the page
   instead of starting a text selection (edit-mode textarea selects normally) */
.nt-text-read { padding: 6px 8px; font-size: 14px; line-height: 1.55; color: var(--text); cursor: text; min-height: 28px; word-break: break-word;
  -webkit-user-select: none; user-select: none; }
.nt-text-read h2 { font-family: 'Cormorant Garamond', serif; font-weight: 500; font-size: 22px; color: var(--cream); margin: 4px 0 3px; }
.nt-text-read h3 { font-size: 15px; font-weight: 600; color: var(--cream); margin: 4px 0 3px; }
.nt-text-read ul { margin: 2px 0; padding-left: 22px; }
.nt-text-read li { margin: 2px 0; }
.nt-text-read code { background: rgba(255,255,255,0.07); border-radius: 3px; padding: 1px 5px; font-size: 12.5px; }
.nt-text-read a { color: var(--gold); }
.nt-text-read .nt-check { cursor: pointer; }
.nt-text-read .nt-tag-inline { color: var(--gold); background: rgba(201,169,110,0.1); border-radius: 3px; padding: 0 5px; cursor: pointer; font-size: 12.5px; }
.nt-text-read .katex { font-size: 1.05em; }
.nt-placeholder { color: var(--text-dim); font-style: italic; }
.nt-textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-bright); border-radius: 4px;
  color: var(--cream); font-size: 13.5px; line-height: 1.55; padding: 8px 10px; resize: none;
  font-family: 'DM Sans', sans-serif; outline: none; min-height: 46px;
}
/* per-box text format bar (edit mode) */
.nt-fmt-bar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px;
  background: rgba(11,15,30,0.95); border: 1px solid var(--border-bright); border-radius: 4px;
  margin-bottom: 4px; -webkit-user-select: none; user-select: none;
}
.nt-fmt-bar button {
  min-width: 30px; height: 28px; background: none; border: 1px solid var(--border); border-radius: 3px;
  color: var(--cream); cursor: pointer; font-size: 12.5px; padding: 0 7px; font-family: 'DM Sans', sans-serif;
  touch-action: manipulation;
}
.nt-fmt-bar button:hover { border-color: var(--gold); color: var(--gold); }
.nt-fmt-bar select {
  height: 28px; padding: 0 6px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 3px; color: var(--cream); font-size: 11.5px; font-family: 'DM Sans', sans-serif;
}
.nt-fmt-swatch { width: 18px !important; min-width: 18px !important; height: 18px !important; border-radius: 50% !important; padding: 0 !important; }
.nt-fmt-swatch.active { border-color: var(--gold) !important; box-shadow: 0 0 0 1px var(--gold); }

.nt-math-read { padding: 10px 8px; text-align: center; cursor: pointer; color: var(--cream); overflow-x: auto; }
.nt-math-preview { padding: 8px; text-align: center; color: var(--cream); min-height: 30px; }
.nt-img-wrap { padding: 2px; }
.nt-img-wrap img { max-width: 100%; border-radius: 4px; display: block; -webkit-user-drag: none; }
.nt-img-cap { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }

/* lasso floating menu */
.nt-lasso-menu {
  position: absolute; z-index: 45; display: flex; gap: 4px; align-items: center;
  background: rgba(11,15,30,0.95); border: 1px solid var(--border-bright); border-radius: 5px;
  padding: 4px 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}

/* linked reminders strip */
.nt-rem-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; }
.nt-rem-chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 5px;
}
.nt-rem-chip:hover { border-color: var(--border-bright); color: var(--cream); }
.nt-rem-chip.done { text-decoration: line-through; opacity: .55; }

/* client FAB + slide-over */
#ntClientFab {
  position: fixed; right: 22px; bottom: 22px; z-index: 800;
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--border-bright);
  background: var(--navy-mid); color: var(--gold); cursor: pointer; display: none;
  align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  touch-action: manipulation;
}
#ntClientFab:hover { background: var(--surface-2); }
#ntClientFab .nt-fab-badge {
  position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--gold); color: #1b2440; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
#ntClientPanel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 94vw; z-index: 900;
  background: var(--navy-mid); border-left: 1px solid var(--border-bright);
  box-shadow: -10px 0 30px rgba(0,0,0,0.5); display: none; flex-direction: column;
}
#ntClientPanel.open { display: flex; }
.nt-panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.nt-panel-title { font-family: 'Cormorant Garamond', serif; font-size: 19px; color: var(--cream); flex: 1; }
.nt-panel-body { flex: 1; overflow-y: auto; padding: 12px 16px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.nt-panel-body::-webkit-scrollbar { width: 8px; }
.nt-panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* wikilinks */
.nt-wikilink { color: var(--gold); text-decoration: none; border-bottom: 1px solid rgba(201,169,110,0.5); cursor: pointer; }
.nt-wikilink:hover { border-bottom-color: var(--gold); }
.nt-wikilink.nt-broken { color: var(--text-dim); border-bottom-style: dashed; }
.nt-wikilink.nt-broken:hover { color: var(--gold); }
/* [[ autocomplete dropdown (sits under the textarea) */
.nt-ac-drop {
  position: relative; z-index: 60; margin-top: 2px;
  background: rgba(11,15,30,0.97); border: 1px solid var(--border-bright); border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5); max-height: 220px; overflow-y: auto;
}
.nt-ac-item { padding: 7px 12px; font-size: 12.5px; color: var(--cream); cursor: pointer; }
.nt-ac-item:hover, .nt-ac-item.active { background: rgba(201,169,110,0.12); color: var(--gold); }

/* new-note split button + template panel */
.nt-new-split { display: flex; gap: 4px; }
.nt-new-split .btn-primary:first-child { flex: 1; }
.nt-new-caret { flex: 0 0 40px; padding: 0; }
.nt-tpl-panel { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.nt-tpl-row { display: flex; align-items: center; gap: 6px; padding: 5px 4px; }
.nt-tpl-row a { flex: 1; color: var(--cream); text-decoration: none; font-size: 12.5px; }
.nt-tpl-row a:hover { color: var(--gold); }
.nt-tpl-row button { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 2px; }
.nt-tpl-row button:hover { color: var(--danger); }

/* share modal rows */
.nt-share-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.nt-share-row select {
  padding: 5px 8px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 3px; color: var(--cream); font-size: 12px; font-family: 'DM Sans', sans-serif;
}
#ntShareModal select { background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; color: var(--cream); padding: 7px 9px; font-size: 12.5px; font-family: 'DM Sans', sans-serif; }

/* dashboard widget — OneNote-style pastel note cards, 2-up grid */
.nt-dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nt-dash-note {
  --tint: #fff9c4;
  background: color-mix(in srgb, var(--tint) 13%, var(--navy-mid));
  border: 1px solid color-mix(in srgb, var(--tint) 30%, transparent);
  border-left: 3px solid var(--tint);
  border-radius: 6px; padding: 10px 12px; cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.nt-dash-note:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--tint) 55%, transparent); }
.nt-dash-crumb { font-size: 9.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--tint); opacity: .85; margin-bottom: 3px; }
.nt-dash-title { font-size: 13px; font-weight: 600; color: var(--cream); line-height: 1.3;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nt-dash-prev { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; margin-top: 4px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.nt-dash-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 10.5px; color: var(--text-dim); }
.nt-dash-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--tint); }
@media (max-width: 700px) { .nt-dash-grid { grid-template-columns: 1fr; } }

/* tablet / mobile */
@media (max-width: 900px) {
  .nt-wrap { flex-direction: column; }
  .nt-rail { position: static; flex: none; width: 100%; }
  .nt-rail .card { margin-bottom: 8px; }
  .nt-title-input { font-size: 22px; }
  #ntClientPanel { width: 100vw; max-width: 100vw; }
}
.nt-editor { padding-bottom: env(safe-area-inset-bottom); }
