/* === Note templates: the toolbar menu and the manager dialog (features/note-templates.js) ===
   The dialog sits on <body>, outside the chart's variables, so chart tokens have fallbacks.
   Desktop: list on the start side, editor on the end side. Phones: full screen, the
   list first and the editor as its own step. */

.ntm-menu { min-width: 240px; max-width: 320px; }
.ntm-menu-item { display: flex; align-items: center; gap: 8px; }
.ntm-menu-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.ntm-menu-def { flex: none; font-size: 11.5px; color: var(--text-secondary); margin-inline-start: 6px; }
.ntm-menu-sep { height: 1px; background: var(--border-light, #e5e7eb); margin: 4px 0; }

body.ntm-open { overflow: hidden; }
.ntm-overlay {
  position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .42); padding: 24px;
}
.ntm-overlay[hidden] { display: none; }
.ntm-dialog {
  width: min(1080px, 100%); height: min(720px, 100%); display: flex; flex-direction: column;
  background: var(--surface, #fff); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22); overflow: hidden;
}
.ntm-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-light, var(--border)); flex: none; }
.ntm-title { margin: 0; font: 600 16px/1.3 var(--font); flex: 1 1 auto; }
.ntm-body { flex: 1 1 auto; min-height: 0; display: flex; }
.ntm-side { width: 340px; flex: none; border-inline-end: 1px solid var(--border-light, var(--border)); overflow-y: auto; padding: 12px; box-sizing: border-box; }
.ntm-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 18px; overflow: hidden; box-sizing: border-box; }

.ntm-new { width: 100%; justify-content: center; margin-bottom: 14px; }
.ntm-def-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); margin: 0 4px 6px; }
.ntm-rows { display: flex; flex-direction: column; }
.ntm-row {
  display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 4px; border-radius: 4px;
  border-bottom: 1px solid var(--border-light, var(--border));
}
.ntm-row-name {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; text-align: start; border: 0; background: none;
  font: 400 14px/1.3 var(--font); color: var(--text); padding: 8px 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ntm-row-on { background: var(--pressed, rgba(0,0,0,.06)); }
.ntm-row-on .ntm-row-name { font-weight: 600; }
.ntm-row:hover { background: var(--hover-neutral, rgba(0,0,0,.04)); }
.ntm-row-acts { display: inline-flex; gap: 0; flex: none; }
.ntm-row-acts .ch-iconbtn { width: 28px; height: 28px; color: var(--text-secondary); }
.ntm-row-acts .ch-iconbtn:disabled { opacity: .35; cursor: default; }
.ntm-row-acts .ntm-del:hover { color: var(--danger); }
.ntm-muted { color: var(--text-secondary); font-weight: 400; }

.ntm-field { display: flex; flex-direction: column; gap: 4px; }
.ntm-field .ch-sec-label { margin: 0; }
.ntm-note { margin: 0; font-size: 13px; color: var(--text-secondary); }
.ntm-toolbar { border: 1px solid var(--border-light, var(--border)); border-radius: 4px; padding: 2px 4px; flex: none; }
.ntm-toolbar[hidden] { display: none; }
.ntm-editor {
  flex: 1 1 auto; min-height: 160px; overflow-y: auto; padding: 12px 14px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface, #fff); color: var(--text); font: 15px/1.65 var(--font);
}
.ntm-editor:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.ntm-editor[aria-readonly="true"] { background: var(--bg, #f8fafc); cursor: default; }
.ntm-foot { display: flex; justify-content: flex-end; gap: 8px; flex: none; }
.ntm-empty { color: var(--text-secondary); margin: auto; }
.ntm-back { display: none; align-self: flex-start; }

/* Phones: full screen; the list, then the editor as its own step. */
@media (max-width: 767px) {
  .ntm-overlay { padding: 0; }
  .ntm-dialog { width: 100%; height: 100%; border-radius: 0; border: 0; }
  .ntm-body { position: relative; }
  .ntm-side { width: 100%; border: 0; }
  .ntm-main { position: absolute; inset: 0; background: var(--surface, #fff); display: none; padding: 12px; }
  .ntm-overlay.ntm-editing .ntm-main { display: flex; }
  .ntm-overlay.ntm-editing .ntm-side { visibility: hidden; }
  .ntm-back { display: inline-flex; }
  .ntm-row { min-height: 48px; }
  .ntm-row-acts .ch-iconbtn { width: 36px; height: 36px; }
  .ntm-editor, .ntm-field .ch-input { font-size: 16px; }
}

/* Chart tokens are not set on <body>: the dialog's controls get their own. */
.ntm-dialog .ch-input { border: 1px solid var(--border); background: var(--surface, #fff); color: var(--text); height: 36px; padding: 0 10px; border-radius: 4px; font: 400 14px var(--font); box-sizing: border-box; width: 100%; }
.ntm-dialog .ch-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.ntm-dialog .ch-input[readonly] { background: var(--bg, #f8fafc); }
.ntm-dialog .ch-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 4px; font: 500 13px var(--font); cursor: pointer; border: 1px solid transparent; }
.ntm-dialog .ch-btn-sm { height: 30px; padding: 0 10px; }
.ntm-dialog .ch-btn-primary { background: var(--primary); color: #fff; }
.ntm-dialog .ch-btn-secondary { background: var(--surface, #fff); color: var(--text); border-color: var(--border); }
.ntm-dialog .ch-btn-ghost { background: none; color: var(--text-secondary); }
.ntm-dialog .ch-btn-ghost:hover, .ntm-dialog .ch-btn-secondary:hover { background: var(--hover-neutral, rgba(0,0,0,.04)); color: var(--text); }
.ntm-dialog .ch-iconbtn { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: 4px; cursor: pointer; }
.ntm-dialog .ch-iconbtn:hover:not(:disabled) { background: var(--hover-neutral, rgba(0,0,0,.05)); }

/* Default for new notes: plain rows, a text badge, a quiet action. */
.ntm-def-label { margin-bottom: 2px; }
.ntm-def-help { margin: 0 4px 8px; font-size: 12.5px; line-height: 1.45; color: var(--text-secondary); }
.ntm-def-none { margin: 0 4px 8px; font-size: 13px; color: var(--text-secondary); }
.ntm-row { align-items: center; }
.ntm-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; row-gap: 0; }
.ntm-row-main .ntm-row-name { flex: 1 1 100%; padding-bottom: 2px; }
.ntm-row-main:has(.ntm-badge, .ntm-link) { padding-bottom: 6px; }
.ntm-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--success, #0f6b58); padding-inline-start: 4px; }
.ntm-link { border: 0; background: none; padding: 2px 4px; font: 400 12.5px var(--font); color: var(--text-secondary); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; border-radius: 3px; }
.ntm-link:hover, .ntm-link:focus-visible { color: var(--text); }
.ntm-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.ntm-link-set { opacity: 0; padding-inline-start: 4px; }
.ntm-row:hover .ntm-link-set, .ntm-link-set:focus-visible, .ntm-row:focus-within .ntm-link-set { opacity: 1; }
@media (hover: none) { .ntm-link-set { opacity: 1; } }
.ntm-link-set { color: var(--primary); }
.ntm-row-def .ntm-row-name { font-weight: 600; }

/* New visit started from the default template. */
.ntm-started { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0 0 6px; font-size: 12.5px; line-height: 1.4; color: var(--text-secondary); }
.ntm-started-text { min-width: 0; overflow-wrap: anywhere; }
.ntm-started .ntm-link { color: var(--primary); }
