/* On Call: the notes (js/notes.js). A notebook with the shape people know: coloured section tabs along the top, a page list down
   the side, the page itself as a sheet, and a small flashcard test. On the page's tokens. Every class starts with nt- because ui.js
   looks for its own (.tab, .row, .card) across the whole page. */
:root { --nt-c0: #5ec1ff; --nt-c1: #4fd37f; --nt-c2: #f5be3f; --nt-c3: #ff8f6b; --nt-c4: #c9a7ff; --nt-c5: #f08fc0; --nt-c6: #7fe6e6; --nt-c7: #b6c2d1; --nt-sheet: #151b25; --nt-rule: rgba(151,168,189,.07); }

.nt-root { display: flex; flex-direction: column; gap: 10px; min-width: 0; font-size: 14px; }
.nt-book { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.nt-root h1 { margin: 0; font: 600 20px var(--font); }
.nt-root h3 { margin: 0; font: 500 12px var(--mono); color: var(--muted); letter-spacing: .02em; }
.nt-input, .nt-select { background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 3px; padding: 6px 10px; font: 13px var(--mono); min-width: 0; max-width: 100%; }
.nt-input:focus, .nt-select:focus { border-color: var(--acc); outline: none; box-shadow: none; }
#scrNotes.wrap { max-width: none; padding-inline: 20px; }
.nt-input { width: 100%; }

/* the top of the big layout */
.nt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 4px; }
.nt-search { flex: 1 1 200px; width: auto; padding-left: 32px; background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23687689' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") 10px center / 15px no-repeat; }
.nt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nt-testctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.nt-scope { padding: 4px 6px; font-size: 13px; }

/* search hits */
.nt-hits { display: grid; gap: 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--line-2); border-radius: 3px; padding: 0; background: var(--bg-2); }
.nt-hit { display: block; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 5px 8px; min-width: 0; } .nt-hit:first-child { border-top: 0; }
.nt-hit:hover, .nt-hit:focus-visible { background: var(--surface-2); }
.nt-hit-where { display: block; font-size: 12px; color: var(--muted); }
.nt-hit-line { display: block; font: 12.5px var(--mono); white-space: pre-wrap; }
.nt-hit-line mark { background: var(--warn-soft); color: var(--warn); border-radius: 3px; }
.nt-nohit { margin: 4px 8px; color: var(--muted); }

/* ── sections: coloured tabs along the top of the notebook, the open one joined to the sheet ── */
.nt-sections { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 3px; padding: 0 6px; position: relative; z-index: 1; }
.nt-sec { position: relative; background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 3px 3px 0 0; padding: 6px 12px 6px; font: 500 12.5px var(--mono); color: var(--muted); max-width: 100%; margin-bottom: -1px; transition: background .12s; }
.nt-sec::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--c, var(--line-3)); }
.nt-sec:hover { color: var(--text); }
.nt-sec.on { background: var(--nt-sheet); border-color: var(--line-2); color: var(--text); z-index: 2; }
.nt-sec-add { background: none; border-color: transparent; color: var(--dim); font-weight: 400; padding-inline: 10px; } .nt-sec-add::before { display: none; } .nt-sec-add:hover { color: var(--text); background: var(--surface-2); border-color: var(--line); }
/* the sheet: everything under the tabs */
.nt-secbar, .nt-main { background: var(--nt-sheet); border: 1px solid var(--line-2); }
.nt-secbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 6px 12px; border-radius: 0 3px 0 0; border-bottom: 1px solid var(--line); }
.nt-main { border-top: 0; border-radius: 0 0 3px 3px; padding: 14px; }
.nt-rename { flex: 1 1 160px; width: auto; }
.nt-seccount, .nt-pagecount { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.nt-seccount { margin-left: auto; }
.nt-pagecount.full { color: var(--warn); }

/* ── pages beside the page ── */
.nt-main { display: grid; grid-template-columns: minmax(160px, 230px) minmax(0, 1fr); gap: 18px; min-width: 0; }
.nt-pages { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-right: 14px; border-right: 1px solid var(--line); }
.nt-pages-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; }
.nt-pagelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 60vh; overflow-y: auto; scrollbar-width: thin; }
.nt-pagerow { display: flex; align-items: center; gap: 2px; border-radius: 0; min-width: 0; position: relative; }
.nt-pagerow.on { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--acc); }
.nt-pagebtn { flex: 1 1 auto; min-width: 0; background: none; border: 0; text-align: left; padding: 6px 10px 6px 12px; border-radius: 0; font-size: 13px; color: var(--muted); line-height: 1.3; }
.nt-pagerow.on .nt-pagebtn { color: var(--text); font-weight: 500; }
.nt-pagebtn:hover { background: var(--surface-2); color: var(--text); }
.nt-updown { flex: none; display: inline-flex; opacity: 0; transition: opacity .15s; } .nt-pagerow:hover .nt-updown, .nt-pagerow.on .nt-updown, .nt-pagerow:focus-within .nt-updown { opacity: 1; }
.nt-mini { background: none; border: 0; width: 22px; height: 24px; padding: 0; color: var(--muted); border-radius: 5px; }
.nt-mini:hover:not([disabled]) { background: var(--surface-3); color: var(--text); }
.nt-mini[disabled] { opacity: .3; cursor: default; }
.nt-nopages { color: var(--dim); padding: 6px 8px; }

/* ── the page: a sheet with a big title, faint rules, and the count in the corner ── */
.nt-editor { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.nt-title { font-family: var(--font); font-size: 17px; font-weight: 600; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 4px 2px 8px; }
.nt-title:focus { box-shadow: none; border-bottom-color: var(--acc); }
.nt-pagetools { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.nt-pagetools .nt-select { padding: 3px 6px; font-size: 13px; max-width: 160px; }
.nt-body { width: 100%; min-height: 240px; height: 40vh; resize: vertical; background: var(--bg-2) repeating-linear-gradient(transparent 0 calc(1.6em - 1px), var(--nt-rule) calc(1.6em - 1px) 1.6em) 0 10px / 100% 1.6em; background-origin: content-box; background-attachment: local; color: var(--text); border: 1px solid var(--line-2); border-radius: 3px; padding: 10px 14px; font: 13.5px/1.6 var(--mono); tab-size: 4; scrollbar-width: thin; }
.nt-body:focus { border-color: var(--acc); outline: none; box-shadow: none; }
.nt-body[disabled] { opacity: .55; }
.nt-body::placeholder { color: var(--dim); font-family: var(--font); font-style: italic; }
.nt-status { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.nt-saved { color: var(--dim); display: inline-flex; align-items: center; gap: 6px; }
.nt-saved::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .7; }
.nt-saved[data-state="saved"] { color: var(--ok); }
.nt-saved[data-state="waiting"], .nt-saved[data-state="saving"] { color: var(--warn); }
.nt-saved[data-state="bad"] { color: var(--bad); }
.nt-count { color: var(--dim); font: 12px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.nt-count.near { color: var(--warn); }
.nt-count.full { color: var(--warn); font-weight: 700; }
.nt-fullnote { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; padding: 6px 0 6px 10px; font: 12.5px var(--mono); color: var(--warn); background: none; border-left: 2px solid var(--warn); border-radius: 0; }

/* ── on this page: the cards a page holds, each with its box on the ladder ── */
.nt-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.nt-entries { display: grid; gap: 6px; }
.nt-entry { display: grid; gap: 3px; background: none; border: 0; border-top: 1px solid var(--line); border-left: 2px solid var(--acc); border-radius: 0; padding: 7px 10px; min-width: 0; }
.nt-entry[data-kind="qa"] { border-left-color: var(--nt-c4); }
.nt-entry-cmd { background: none; padding: 0; font-size: 12.5px; color: var(--text); }
.nt-entry-q { font-weight: 600; }
.nt-entry-sub { font-size: 13px; color: var(--muted); }
.nt-fromdocs { font-style: italic; color: var(--dim); }
.nt-entry-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; }
/* five boxes, filled up to the one the card is in */
.nt-box { display: inline-flex; align-items: center; gap: 7px; font: 11.5px var(--font); color: var(--dim); margin-right: auto; font-variant-numeric: tabular-nums; --n: 0; }
.nt-box::before { content: ''; width: 54px; height: 9px; border-radius: 2px; background: linear-gradient(90deg, var(--ok) 0 calc(var(--n) * 20%), var(--surface-3) calc(var(--n) * 20%) 100%); -webkit-mask: linear-gradient(90deg, #000 0 8px, transparent 8px 100%) 0 0 / 11.5px 100%; mask: linear-gradient(90deg, #000 0 8px, transparent 8px 100%) 0 0 / 11.5px 100%; }
.nt-box[data-box="1"] { --n: 1; } .nt-box[data-box="2"] { --n: 2; } .nt-box[data-box="3"] { --n: 3; } .nt-box[data-box="4"] { --n: 4; } .nt-box[data-box="5"] { --n: 5; }
.nt-box[data-box="5"]::before { background: var(--ok); }

/* ── messages, the honest line, the offer ── */
.nt-msg { margin: 0; padding: 6px 0 6px 10px; font: 12.5px var(--mono); border-radius: 0; background: none; border-left: 2px solid var(--acc); color: var(--text); animation: msg-in calc(var(--m) * .2s) ease-out both; }
.nt-msg.warn { border-left-color: var(--warn); color: var(--warn); }
.nt-msg.bad { border-left-color: var(--bad); color: var(--bad); }
.nt-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; font-size: 13px; border: 1px solid var(--line-2); border-left: 2px solid var(--acc); border-radius: 0 3px 3px 0; background: var(--bg-2); }
.nt-offer span { flex: 1 1 200px; }
.nt-foot { display: grid; gap: 3px; margin-top: 4px; }
.nt-honest { margin: 0; font-size: 12px; color: var(--dim); }
.nt-honest.warn { color: var(--warn); }
.nt-stats { margin: 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Test me: a card from a deck ── */
.nt-test { display: flex; flex-direction: column; gap: 12px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 3px; padding: 14px 16px 16px; min-width: 0; position: relative; box-shadow: none; margin-bottom: 14px; animation: dlg-in calc(var(--m) * .15s) ease-out both; }
.nt-test-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.nt-test-head h3 { color: var(--text); font: 500 12.5px var(--mono); }
.nt-progress { margin: 0; font: 500 11.5px var(--mono); letter-spacing: 0; color: var(--dim); }
.nt-prompt { margin: 0; font: 500 16px/1.4 var(--font); color: var(--text); }
.nt-hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.nt-answerrow { display: flex; align-items: center; gap: 8px; font-family: var(--mono); min-width: 0; background: var(--term-bg, #0b100c); border: 1px solid var(--line-2); border-radius: 3px; padding: 4px 6px 4px 12px; }
.nt-answerrow:focus-within { border-color: var(--acc); box-shadow: none; }
.nt-mark { color: var(--term-prompt, var(--ok)); white-space: pre; flex: none; font-weight: 700; }
.nt-answer { font-family: var(--mono); font-size: 16px; flex: 1 1 auto; width: auto; background: none; border: 0; color: var(--term-fg-bright, var(--text)); padding: 6px 4px; } .nt-answer:focus { box-shadow: none; }
.nt-row { display: flex; flex-wrap: wrap; gap: 6px; }
.nt-feedback { display: grid; gap: 8px; }
.nt-feedback p { margin: 0; }
.nt-right { color: var(--ok); font: 500 14px var(--mono); display: flex; align-items: center; gap: 8px; animation: msg-in calc(var(--m) * .2s) ease-out both; }
.nt-right::before { content: '✓'; font: 500 15px var(--mono); }
.nt-miss { color: var(--warn); font: 500 14px var(--mono); animation: msg-in calc(var(--m) * .2s) ease-out both; }
.nt-answertext { font-size: 14px; } .nt-answertext code { font-size: 13.5px; }
.nt-words { display: flex; flex-wrap: wrap; gap: 5px; font: 13.5px var(--mono); }
.nt-w { padding: 2px 8px; border-radius: 2px; background: var(--surface-2); min-width: 0; }
.nt-w.same { color: var(--ok); background: var(--ok-soft); }
.nt-w.extra { color: var(--warn); background: var(--warn-soft); text-decoration: underline dotted; }
.nt-w.missing { color: var(--warn); background: none; border: 1px dashed var(--warn); }
.nt-feedback .nt-box { margin: 2px 0 0; }

/* ── the compact side panel ── */
.nt-compact .nt-pickers { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.nt-compact .nt-select { width: 100%; padding: 5px 6px; font-size: 13px; }
.nt-compact .nt-body { height: 34vh; min-height: 130px; font-size: 13px; }
.nt-compact .nt-scope { width: auto; }
.nt-compact-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.nt-compact .nt-test { padding: 12px 14px 14px; }
.nt-compact .nt-prompt { font-size: 16px; }

/* the whole window (openBig): one column */
.bigview:has(.big-notes) .big-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.bigview:has(.big-notes) .big-side { display: none; }

/* ── saving with one tap: on a typed line, on a card, on a selection ── */
.ln.cmd { position: relative; }
.nt-linesave { position: absolute; right: 0; top: 0; padding: 0 8px; height: calc(var(--term-lh) * 1em); font: 500 11px/1 var(--mono); color: var(--term-fg); background: var(--term-bg); border: 1px solid var(--term-dim); border-radius: 2px; opacity: 0; user-select: none; -webkit-user-select: none; text-shadow: none; cursor: pointer; transition: opacity .12s; }
.nt-linesave::after { content: 'Save'; }
.nt-linesave:hover { border-color: var(--term-fg); }
.ln.cmd:hover .nt-linesave, .nt-linesave:focus-visible { opacity: 1; }
@media (hover: none) { .nt-linesave { display: none; } }
.nt-cardsave { margin-top: 8px; }
.nt-rowsave { margin-left: 8px; background: none; border: 1px solid var(--line-2); border-radius: 2px; padding: 0 7px; font: 11.5px var(--mono); color: var(--muted); }
.nt-rowsave:hover, .nt-rowsave:focus-visible { color: var(--text); border-color: var(--acc); }
.nt-selsave { position: fixed; z-index: 45; display: inline-flex; align-items: center; gap: 7px; background: var(--acc-2); color: var(--acc-ink); border: 1px solid var(--acc-2); border-radius: 3px; padding: 4px 10px 4px 9px; font: 500 12.5px var(--mono); box-shadow: none; user-select: none; -webkit-user-select: none; animation: msg-in calc(var(--m) * .18s) ease-out both; }
.nt-selsave::before { content: ''; width: 12px; height: 14px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h12v18l-6-4-6 4z'/%3E%3C/svg%3E") center / contain no-repeat; }
.nt-selsave:hover, .nt-selsave:focus-visible { background: var(--acc-3); }

/* a toast that can be answered */
.toast.nt-toast { padding-left: 12px; border-left-color: var(--acc); pointer-events: auto; overflow-wrap: anywhere; }
.toast.nt-toast::before { content: none; }
.nt-toast-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.nt-toast-b { background: var(--surface-2); border: 1px solid var(--line-3); border-radius: 3px; padding: 3px 10px; font: 500 12px var(--mono); color: var(--text); pointer-events: auto; }
.nt-toast-b:hover, .nt-toast-b:focus-visible { border-color: var(--acc); background: var(--acc-soft); }

@media (max-width: 720px) {
  .nt-main { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 10px; }
  .nt-pages { padding-right: 0; border-right: 0; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .nt-pagelist { max-height: 170px; }
  .nt-body { height: 44dvh; }
  .nt-tools { width: 100%; }
  .nt-test { padding: 14px; }
}
/* a phone with the keyboard up, typing a note: the notes get the room that the terminal has otherwise */
@media (max-width: 860px) and (max-height: 520px) {
  .rungrid:has(.nt-root :is(textarea, input):focus) { grid-template-rows: 44px minmax(0, 1fr); }
  .rungrid:has(.nt-root :is(textarea, input):focus) .nt-pickers, .rungrid:has(.nt-root :is(textarea, input):focus) .nt-compact-actions, .rungrid:has(.nt-root :is(textarea, input):focus) .nt-foot, .rungrid:has(.nt-root :is(textarea, input):focus) .nt-cards { display: none; }
  .nt-compact .nt-body { height: 100%; min-height: 96px; }
}
html[data-motion="calm"] .nt-toast, html[data-motion="calm"] .nt-test, html[data-motion="calm"] .nt-right, html[data-motion="calm"] .nt-right::before, html[data-motion="calm"] .nt-miss, html[data-motion="calm"] .nt-msg, html[data-motion="calm"] .nt-selsave { animation: none !important; }

/* paper: one page, on its own */
#ntPrint { display: none; }
@media print {
  body.nt-printing { height: auto !important; overflow: visible !important; display: block !important; background: #fff !important; }
  body.nt-printing > *:not(#ntPrint) { display: none !important; }
  body.nt-printing #ntPrint { display: block; color: #000; font: 11pt/1.5 var(--mono); }
  #ntPrint h1 { font: 700 16pt var(--font); margin: 0 0 10pt; color: #000; }
  #ntPrint pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font: inherit; color: #000; }
}
