/* ==========================================================================
   Quaderno
   ========================================================================== */
.nb-app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 70px); }
.nb-main { min-width: 0; }
@media (max-width: 900px) {
  .nb-app { grid-template-columns: minmax(0, 1fr); }
  .nb-side { display: none !important; }
}

/* --- cartelle (colonna sinistra) --- */
.nb-side {
  border-right: 1px solid var(--stroke);
  padding: 18px 10px 14px;
  position: sticky; top: 60px;
  height: calc(100vh - 70px);
  display: flex; flex-direction: column;
}
.nb-side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px 10px; font-size: 13.5px; color: var(--ink-3); }
.nb-side-head b { font-weight: 500; }
.nb-tree { flex: 1; overflow-y: auto; }
.nb-tree-item {
  display: flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 4px 8px 4px calc(4px + var(--d, 0) * 16px);
  border-radius: var(--r-sm);
  text-decoration: none; color: var(--ink); font-size: 14.5px;
}
.nb-tree-item:hover { background: var(--fill); }
.nb-tree-item.active { background: var(--fill-2); }
.nb-tree-item.drop { box-shadow: inset 0 0 0 2px var(--c); background: var(--fill); }
.nb-tree-chev { width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: var(--ink-3); transition: transform 0.2s var(--ease); cursor: pointer; }
.nb-tree-chev svg { width: 11px; height: 11px; }
.nb-tree-node.open > a .nb-tree-chev { transform: rotate(90deg); }
.nb-tree-kids { display: none; }
.nb-tree-node.open > .nb-tree-kids { display: block; }
.nb-tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-tree-count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nb-tree-item .ui-more { width: 40px; height: 40px; margin: -6px -8px -6px -2px; }
.nb-tree-item .ui-more svg { width: 17px; height: 17px; }
@media (hover: hover) and (pointer: fine) {
  .nb-tree-item { position: relative; }
  .nb-tree-item .ui-more { position: absolute; right: -2px; top: 50%; margin: -20px 0 0; }
  .nb-tree-item:is(:hover, :focus-within, .ui-ctx-target) .nb-tree-count { visibility: hidden; }
}
.nb-tree-ic { display: grid; place-items: center; color: var(--ink-2); }
.nb-tree-ic svg { width: 16px; height: 16px; }
.nb-side-foot { display: flex; gap: 8px; padding: 12px 4px 0; border-top: 1px solid var(--stroke); margin-top: 8px; }
.note-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--ink-3)); flex: none; display: inline-block; }

/* --- pulsanti e campi --- */
.nb-icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--stroke-2);
  background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.nb-icon-btn:hover { background: var(--fill); }
.nb-icon-btn svg { width: 18px; height: 18px; }
.nb-input {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--fill); border: 1px solid var(--stroke-2); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.nb-input:focus { border-color: var(--ink-3); }
select.nb-input { width: auto; padding: 6px 10px; }

/* --- pagine: home del quaderno e cartella --- */
.nb-page { max-width: 1120px; margin: 0 auto; padding: 40px 40px 110px; }
@media (max-width: 980px) { .nb-page { padding: 28px 20px 90px; } }
@media (max-width: 560px) { .nb-page { padding: 22px 16px 90px; } }
.nb-page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px 24px; flex-wrap: wrap; padding-bottom: 22px; }
.nb-page-head h1 { font-size: clamp(32px, 4vw, 44px); }
.nb-page-head .lead { margin-top: 8px; font-size: 17px; }
.nb-page-head .lead a { color: var(--ink); }
.nb-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nb-folder-title { display: flex; align-items: center; gap: 14px; }
.nb-folder-title .folder-ic { width: 46px; height: 46px; }
.nb-crumbs { display: flex; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--ink-3); margin-bottom: 12px; }
.nb-crumbs a { color: var(--ink-3); text-decoration: none; }
.nb-crumbs a:hover { color: var(--ink); }
.nb-search {
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--fill-2); color: var(--ink-3);
}
.nb-search svg { width: 18px; height: 18px; flex: none; }
.nb-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font: inherit; font-size: 16px; }
.nb-section { padding-top: 30px; }
.nb-h { font-family: var(--font); font-size: 13.5px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin: 0 0 12px; }
.nb-empty-line { color: var(--ink-3); }
.nb-empty-folder { border: 1px dashed var(--stroke-2); border-radius: var(--r-tray); padding: 40px 24px; text-align: center; }
.nb-empty-folder p { margin: 0 auto 18px; }
.nb-empty-folder .nb-actions { justify-content: center; }

.folder-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 10px; }
.folder-tile {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-items: center;
  padding: 14px; min-height: 70px;
  border: 1px solid var(--stroke); border-radius: var(--r);
  text-decoration: none; color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.folder-tile:hover { background: var(--fill); border-color: var(--stroke-2); }
.folder-tile.drop { box-shadow: inset 0 0 0 2px var(--c); }
.folder-tile .folder-ic { grid-row: span 2; }
/* ⋯ del riquadro: in basso a destra, sulla riga del numero di note (come nelle schede delle
   note), così il nome della cartella ha tutta la larghezza */
.folder-tile:has(> .ui-more) { grid-template-columns: auto minmax(0, 1fr) auto; }
.folder-tile > b { grid-column: 2 / 4; }
.folder-tile > small { grid-column: 2; }
.folder-tile > .ui-more { grid-column: 3; grid-row: 2; margin: -14px -10px -14px 0; }
.folder-tile b { font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-tile small { font-size: 13px; color: var(--ink-3); }
.folder-ic {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: var(--c);
  background: var(--fill-2);
  background: color-mix(in srgb, var(--c) 15%, transparent);
}
.folder-ic svg { width: 20px; height: 20px; }

.note-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.note-card {
  display: flex; flex-direction: column; min-height: 128px;
  border: 1px solid var(--stroke); border-radius: var(--r); overflow: hidden;
  text-decoration: none; color: var(--ink); background: var(--sheet);
  transition: background 0.15s, border-color 0.15s;
  -webkit-touch-callout: none;
}
.note-card:hover { border-color: var(--stroke-2); background: var(--fill); }
.note-thumb { display: grid; place-items: center; height: 124px; background: var(--tray); border-bottom: 1px solid var(--stroke); overflow: hidden; color: var(--ink); }
.note-thumb img { width: 100%; height: 100%; object-fit: cover; }
.note-thumb svg { width: 100%; height: 100%; padding: 10px; }
.note-card-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; flex: 1; min-width: 0; }
.note-card-body b { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.note-type { display: grid; place-items: center; color: var(--ink-3); flex: none; }
.note-type svg { width: 15px; height: 15px; }
.note-snippet { font-size: 14px; color: var(--ink-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-card small { margin-top: auto; padding-top: 6px; font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 7px; }
/* ⋯ della scheda: in fondo a destra, sulla riga della data, senza alzarla (margini negativi) */
.note-card small .ui-more { margin: -14px -15px -14px auto; }

/* --- nota aperta --- */
.nb-editor-wrap { display: flex; flex-direction: column; min-height: calc(100vh - 70px); }
.nb-ed-top {
  display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 16px;
  border-bottom: 1px solid var(--stroke);
  background: var(--sheet);
  position: sticky; top: 60px; z-index: 20;
}
.nb-folder-chip {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 220px;
  height: 36px; padding: 0 14px; border-radius: 999px; border: 0;
  background: var(--fill-2); color: var(--ink); font-size: 14px; cursor: pointer;
}
.nb-folder-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-grow { flex: 1; }
.nb-status { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.nb-ed-inner { max-width: 840px; margin: 0 auto; padding: 34px 40px 140px 80px; }
.nb-title {
  width: 100%; border: 0; background: transparent; outline: none; color: var(--ink); padding: 0;
  font-family: var(--font-display); font-size: clamp(28px, 4vw, 38px); font-weight: 650; letter-spacing: -0.025em;
}
.nb-title::placeholder { color: var(--ink-4); }
.nb-title-sm { flex: 1; min-width: 60px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.nb-ed-meta { font-size: 13px; color: var(--ink-3); margin: 6px 0 18px; }
.nb-tip { font-size: 13.5px; color: var(--ink-3); margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--stroke); }
.nb-tip kbd { font-family: var(--mono); background: var(--fill-2); border-radius: 5px; padding: 0 6px; }
@media (max-width: 980px) {
  .nb-side { top: 52px; height: calc(100vh - 52px); }
  .nb-ed-top { top: 52px; padding: 0 10px; gap: 6px; }
  .nb-ed-inner { padding: 22px 16px 120px 52px; }
}
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .nb-folder-chip { max-width: 120px; padding: 0 10px; }
  .nb-status { display: none; }
}

/* pulsanti della barra sulla selezione */
.tb {
  flex: none; min-width: 40px; height: 40px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.tb:hover { background: var(--fill-2); color: var(--ink); }
.tb.on { background: var(--fill-3); color: var(--ink); }
.tb svg { width: 19px; height: 19px; }
.tb-txt { font-family: var(--font-display); font-size: 14.5px; font-weight: 650; line-height: 1; }
.tb-sep { width: 1px; height: 22px; background: var(--stroke-2); margin: 0 4px; flex: none; }

/* testo della nota */
.nb-doc {
  position: relative; outline: none; min-height: 40vh; padding-bottom: 20vh;
  font-size: 17px; line-height: 1.7; color: var(--ink); caret-color: var(--ink);
  overflow-wrap: anywhere;
}
.nb-ed-shell.is-empty .nb-doc::before { content: attr(data-placeholder); position: absolute; top: 0; left: 0; color: var(--ink-4); pointer-events: none; }
.nb-doc > :first-child { margin-top: 0; }
.nb-doc p { margin: 0 0 10px; color: var(--ink); max-width: none; }
.nb-doc h1 { font-size: 30px; line-height: 1.2; margin: 30px 0 10px; letter-spacing: -0.02em; }
.nb-doc h2 { font-size: 24px; line-height: 1.25; margin: 26px 0 8px; }
.nb-doc h3 { font-size: 19.5px; line-height: 1.3; margin: 22px 0 6px; }
.nb-doc ul, .nb-doc ol { color: var(--ink); max-width: none; margin: 0 0 12px; padding-left: 26px; }
.nb-doc li { margin: 3px 0; }
.nb-doc li::marker { color: var(--ink-3); }
.nb-doc ul.nb-check { list-style: none; padding-left: 0; }
.nb-doc ul.nb-check > li { position: relative; padding-left: 34px; }
.nb-doc ul.nb-check > li::before {
  content: ""; position: absolute; left: 2px; top: 0.28em;
  width: 20px; height: 20px; border: 1.6px solid var(--ink-3); border-radius: 6px; cursor: pointer;
}
.nb-doc ul.nb-check > li[data-checked="true"]::before { background: var(--ok); border-color: var(--ok); }
.nb-doc ul.nb-check > li[data-checked="true"]::after {
  content: ""; position: absolute; left: 9px; top: calc(0.28em + 4px);
  width: 6px; height: 11px; border: solid #fff; border-width: 0 2.2px 2.2px 0; transform: rotate(45deg);
}
.nb-doc ul.nb-check > li[data-checked="true"] { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-4); }
.nb-doc blockquote { margin: 12px 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--ink-4); color: var(--ink-2); }
.nb-doc blockquote.nb-key { border: 1px solid var(--stroke-2); border-left: 4px solid var(--c, var(--ink-2)); background: var(--fill); border-radius: 10px; padding: 12px 16px; color: var(--ink); }
.nb-doc hr { margin: 26px 0; }
.nb-doc mark { background: rgba(255, 214, 10, 0.34); color: inherit; border-radius: 3px; padding: 0 2px; }
:root[data-theme="light"] .nb-doc mark { background: rgba(255, 214, 10, 0.5); }
.nb-doc a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.nb-doc code { font-size: 0.88em; }
.nb-term {
  cursor: pointer; border-radius: 4px; padding: 0 2px;
  border-bottom: 2px dotted #ff375f;
  background: rgba(255, 55, 95, 0.1);
}
.nb-term::after {
  content: ""; display: inline-block; width: 10px; height: 8px; margin-left: 4px; vertical-align: 1px;
  border: 1.5px solid currentColor; border-radius: 2px; opacity: 0.45;
}
.nb-term[data-img]::after { background: currentColor; opacity: 0.55; }

/* atomi: immagini, disegni, audio, formule */
.nb-fig { position: relative; margin: 18px 0; text-align: center; }
.nb-fig img { display: block; margin: 0 auto; max-width: 100%; border-radius: 10px; cursor: zoom-in; background: var(--fill); min-height: 40px; }
.nb-fig[data-size="s"] img { max-width: 40%; }
.nb-fig[data-size="m"] img { max-width: 72%; }
@media (max-width: 600px) { .nb-fig[data-size="s"] img { max-width: 60%; } .nb-fig[data-size="m"] img { max-width: 100%; } }
.nb-fig figcaption { font-size: 14px; color: var(--ink-3); margin-top: 8px; outline: none; min-height: 1.4em; }
.nb-fig figcaption:empty::before { content: attr(data-placeholder); color: var(--ink-4); }
.nb-fig:not(.sel):not(:focus-within) figcaption:empty { display: none; }
.nb-fig.sel img { outline: 2px solid var(--ink-3); outline-offset: 3px; }
.nb-fig-ui {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  display: none; gap: 2px; padding: 4px;
  background: rgba(20, 20, 22, 0.8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-radius: 12px;
}
.nb-fig-ui button {
  min-width: 36px; height: 36px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.nb-fig-ui button:hover { background: rgba(255, 255, 255, 0.16); }
.nb-fig-ui svg { width: 16px; height: 16px; }
.nb-fig.sel > .nb-fig-ui, .nb-draw.sel > .nb-fig-ui { display: flex; }
@media (hover: hover) { .nb-fig:hover > .nb-fig-ui, .nb-draw:hover > .nb-fig-ui { display: flex; } }
.nb-draw { position: relative; margin: 18px 0; padding: 10px; border: 1px solid var(--stroke); border-radius: 12px; background: var(--tray); cursor: pointer; color: var(--ink); }
.nb-draw.sel { border-color: var(--ink-3); }
.nb-draw-svg svg { display: block; width: 100%; height: auto; max-height: 460px; }
.nb-audio { display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 10px 12px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--tray); }
.nb-audio-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--fill-2); display: grid; place-items: center; flex: none; color: var(--ink); }
.nb-audio-ic svg { width: 20px; height: 20px; }
.nb-audio-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.nb-audio-main b { font-size: 14.5px; font-weight: 600; }
.nb-audio-main small { font-size: 12.5px; color: var(--ink-3); }
.nb-audio-main audio { width: 100%; height: 38px; margin-top: 6px; }
.nb-audio-ui button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--stroke-2); background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.nb-audio-ui svg { width: 17px; height: 17px; }
.nb-math { margin: 14px 0; padding: 10px; border-radius: 10px; cursor: pointer; overflow-x: auto; text-align: center; }
.nb-math:hover, .nb-imath:hover { background: var(--fill-2); }
.nb-imath { cursor: pointer; padding: 0 2px; border-radius: 4px; }

/* --- menu «/» e menu a comparsa --- */
.nb-menu, .nb-pop {
  position: fixed; z-index: 300;
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--stroke-2); border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
  padding: 6px; overflow-y: auto;
}
.nb-menu-item { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 10px; border-radius: 9px; cursor: pointer; font-size: 15px; }
.nb-menu-item.active, .nb-menu-item:hover { background: var(--fill-2); }
.nb-menu-ic { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--stroke-2); display: grid; place-items: center; flex: none; color: var(--ink-2); }
.nb-menu-ic svg { width: 17px; height: 17px; }
.nb-menu-ic .tb-txt { font-size: 12.5px; }
.nb-menu-item kbd { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.nb-menu-empty { padding: 12px; color: var(--ink-3); font-size: 14px; }
.nb-pop { min-width: 230px; }
.nb-pop button { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-size: 14.5px; text-align: left; cursor: pointer; }
.nb-pop button:hover { background: var(--fill-2); }
.nb-pop button svg { width: 17px; height: 17px; color: var(--ink-2); }
.nb-pop button.danger, .nb-pop button.danger svg { color: var(--ko); }
.nb-pop hr { margin: 6px 4px; }

/* --- finestre --- */
.nb-modal-back {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center; padding: 16px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.45);
  opacity: 0; transition: opacity 0.16s;
}
.nb-modal-back.in { opacity: 1; }
.nb-modal-back.out { opacity: 0; }
.nb-modal {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--stroke-2); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  padding: 22px;
  transform: translateY(8px) scale(0.985); transition: transform 0.2s var(--ease);
}
.nb-modal-back.in .nb-modal { transform: none; }
.nb-modal h3 { margin: 0 0 14px; font-size: 19px; }
.nb-modal-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.nb-ask { width: min(440px, 100%); }

.nb-modal.nb-images { width: min(880px, 100%); height: min(740px, calc(100dvh - 32px)); padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.nb-img-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--stroke); }
.nb-img-search { flex: 1; display: flex; gap: 8px; align-items: center; min-width: 0; }
.nb-img-ic { color: var(--ink-3); display: grid; place-items: center; }
.nb-img-ic svg { width: 20px; height: 20px; }
.nb-img-body { flex: 1; overflow: auto; padding: 14px; }
.nb-img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.nb-img-grid[hidden], .nb-img-preview[hidden] { display: none; }
.nb-img-cell { aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--fill-2); cursor: pointer; }
.nb-img-cell img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.nb-img-cell:hover img { transform: scale(1.04); }
.nb-img-msg { grid-column: 1 / -1; color: var(--ink-3); padding: 28px 12px; text-align: center; }
.nb-img-big img { display: block; max-width: 100%; max-height: 52vh; margin: 0 auto; border-radius: 12px; cursor: zoom-in; }
.nb-img-info { text-align: center; margin: 12px 0; line-height: 1.35; }
.nb-img-info b { display: block; font-weight: 600; }
.nb-img-info small { color: var(--ink-3); font-size: 13px; }
.nb-img-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.nb-img-pinned { display: flex; gap: 14px; align-items: center; padding: 10px; border: 1px solid var(--stroke); border-radius: 12px; margin-bottom: 14px; }
.nb-img-pinned img { width: 110px; height: 84px; object-fit: cover; border-radius: 8px; cursor: zoom-in; flex: none; }
.nb-img-pinned p { margin: 2px 0 0; }
.nb-img-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--stroke); }
.nb-img-foot .small-note { margin: 0; }

.nb-modal-back:has(.nb-lightbox) { background: rgba(0, 0, 0, 0.9); padding: 0; }
.nb-modal.nb-lightbox { width: 100%; height: 100%; max-height: none; background: transparent; border: 0; box-shadow: none; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.nb-lb-img { max-width: 100%; max-height: calc(100dvh - 90px); overflow: auto; touch-action: pinch-zoom pan-x pan-y; }
.nb-lb-img img { max-width: 100%; max-height: calc(100dvh - 90px); object-fit: contain; margin: 0 auto; }
.nb-lb-cap { color: #fff; opacity: 0.85; margin-top: 12px; text-align: center; font-size: 14px; max-width: 760px; }
.nb-lb-close { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; display: grid; place-items: center; cursor: pointer; }
.nb-lb-close svg { width: 20px; height: 20px; }

.nb-tex-preview { min-height: 76px; display: grid; place-items: center; background: var(--fill); border-radius: 12px; margin-bottom: 10px; padding: 12px; overflow-x: auto; }
.nb-tex { font-family: var(--mono); font-size: 15px; resize: vertical; }
.nb-tex-keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.nb-tex-keys button { height: 38px; min-width: 42px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--stroke-2); background: transparent; color: var(--ink); font-size: 15px; cursor: pointer; }
.nb-tex-keys button:hover { background: var(--fill-2); }

.nb-pick-list { max-height: 60vh; overflow: auto; }
.nb-pick-row { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 12px 0 calc(12px + var(--d) * 18px); border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 15px; text-align: left; cursor: pointer; }
.nb-pick-row:hover { background: var(--fill-2); }
.nb-pick-row.active { background: var(--fill-3); }

/* disegno nel testo: finestra a tutto schermo */
.nb-modal-back:has(.nb-drawing) { padding: 0; }
.nb-modal.nb-drawing { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; padding: 0; display: flex; flex-direction: column; background: var(--sheet); overflow: hidden; }
.nb-draw-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--stroke); }
.nb-draw-tools { border-bottom: 1px solid var(--stroke); }
.nb-draw-board { flex: 1; min-height: 0; display: flex; padding: 12px; }

/* barra in basso (registrazione, dettatura) */
.nb-floatbar {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 350;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px);
  padding: 8px 8px 8px 16px;
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--stroke-2); border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, 20px); opacity: 0; transition: transform 0.25s var(--ease), opacity 0.25s;
}
.nb-floatbar.in { transform: translate(-50%, 0); opacity: 1; }
.nb-rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff453a; flex: none; animation: nbPulse 1.2s ease-in-out infinite; }
.nb-rec-dot.listen { background: var(--ok); }
@keyframes nbPulse { 50% { opacity: 0.35; transform: scale(0.8); } }
.nb-rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.nb-rec-label { font-size: 14px; color: var(--ink-2); min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-interim { color: var(--ink-3); }
.nb-floatbar .btn svg { width: 14px; height: 14px; }

/* ==========================================================================
   Scrittura a mano
   ========================================================================== */
.nb-editor-wrap.ink-mode { height: calc(100dvh - 70px); min-height: 0; }
@media (max-width: 980px) { .nb-editor-wrap.ink-mode { height: calc(100dvh - 52px); } }
.nb-ink-tools { border-bottom: 1px solid var(--stroke); background: var(--sheet); }
.nb-ink-body { flex: 1; min-height: 0; display: flex; position: relative; }
.nb-ink-area { flex: 1; min-width: 0; display: flex; }
.ink-host { flex: 1; display: flex; min-width: 0; min-height: 0; }
.ink-scroll { position: relative; flex: 1; min-width: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: var(--app); -webkit-user-select: none; user-select: none; }
.ink-note .ink-scroll { padding: 16px 0 0; }
.ink-pages {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--ink-gap, 34px);
  min-width: min-content; padding: 0 16px;
  touch-action: pan-x pan-y;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.ink-host.finger-draw .ink-pages { touch-action: none; }
/* penna su Windows e Android: mentre è vicina allo schermo le pagine non scorrono al tocco, la penna scrive */
.ink-host.pen-near .ink-pages { touch-action: none; }
/* lo sfondo (righe, quadretti…) è un'immagine SVG messa da ink.js: c'è subito, anche prima della tela */
.ink-page { position: relative; flex: none; background: var(--raised) no-repeat 0 0 / 100% 100%; border-radius: 6px; box-shadow: 0 0 0 1px var(--stroke), 0 8px 26px rgba(0, 0, 0, 0.16); }
.ink-page canvas { position: absolute; left: 0; top: 0; display: block; max-width: none; border-radius: 6px; }
.ink-host[data-tool="pen"] .ink-page canvas, .ink-host[data-tool="hl"] .ink-page canvas { cursor: crosshair; }
.ink-host[data-tool="eraser"] .ink-page canvas { cursor: cell; }
.ink-overlay { position: absolute; left: 0; top: 0; pointer-events: none; max-width: none; }
.ink-page-foot { position: absolute; left: 0; right: 0; top: 100%; display: flex; justify-content: space-between; align-items: center; padding: 6px 4px 0; font-size: 12.5px; color: var(--ink-3); }
/* rimpicciolendo, lo spazio tra le pagine si stringe: il piede della pagina si stringe con lui */
.ink-note .ink-page-foot { right: auto; width: calc(100% / var(--ink-fz, 1)); transform: scale(var(--ink-fz, 1)); transform-origin: 0 0; }
.ink-delpage { border: 0; background: none; color: var(--ink-3); font-size: 12.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; padding: 4px; }
.ink-page:only-child .ink-delpage { display: none; }
.ink-addpage { display: block; margin: 40px auto 48px; height: 46px; padding: 0 22px; border-radius: 999px; border: 1px dashed var(--stroke-2); background: transparent; color: var(--ink-2); font-size: 15px; cursor: pointer; }
.ink-addpage:hover { background: var(--fill); color: var(--ink); }
.ink-drawing .ink-scroll { background: transparent; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ink-drawing .ink-pages { padding: 0; }
.ink-drawing .ink-page { box-shadow: 0 0 0 1px var(--stroke-2); }

.ink-tools { display: flex; align-items: center; gap: 6px; padding: 6px 10px; overflow-x: auto; scrollbar-width: none; }
.ink-tools::-webkit-scrollbar { display: none; }
.ink-group { display: flex; align-items: center; gap: 2px; flex: none; padding-right: 6px; border-right: 1px solid var(--stroke); }
.ink-group:last-child { border-right: 0; }
.ink-btn {
  min-width: 44px; height: 44px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 11px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.ink-btn:hover { background: var(--fill-2); color: var(--ink); }
.ink-btn.active { background: var(--fill-3); color: var(--ink); }
.ink-btn:disabled { opacity: 0.32; cursor: default; background: transparent; }
.ink-btn svg { width: 22px; height: 22px; }
.ink-finger span { font-size: 13px; white-space: nowrap; }
@media (max-width: 700px) { .ink-finger span { display: none; } }
.ink-colors { padding-left: 2px; transition: opacity 0.15s; }
.ink-colors.dim { opacity: 0.35; }
.ink-swatch { width: 30px; height: 30px; margin: 0 3px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.ink-swatch.active { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--ink-2); }
.ink-w i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink-3); }
.ink-w.active i { background: var(--ink); }
.ink-select { display: inline-flex; align-items: center; gap: 4px; height: 44px; padding: 0 8px; border-radius: 11px; color: var(--ink-2); cursor: pointer; }
.ink-select:hover { background: var(--fill-2); }
.ink-select svg { width: 21px; height: 21px; }
.ink-select select { -webkit-appearance: none; appearance: none; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; padding: 0 2px; }

.nb-transcript { width: 340px; flex: none; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-left: 1px solid var(--stroke); background: var(--sheet); overflow: auto; }
.nb-transcript[hidden] { display: none; }
.nb-transcript .small-note { margin: 0; }
.nb-tr-head { display: flex; justify-content: space-between; align-items: center; }
.nb-tr-row { display: flex; gap: 8px; flex-wrap: wrap; }
.nb-tr-text { flex: 1; min-height: 180px; resize: vertical; line-height: 1.5; }
@media (max-width: 760px) {
  .nb-transcript { position: absolute; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%; z-index: 5; border-left: 0; border-top: 1px solid var(--stroke); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.25); }
}

/* ==========================================================================
   Schermo intero (appunti a scuola)
   ========================================================================== */
body.nb-focus .sidebar, body.nb-focus .topbar, body.nb-focus .scrim, body.nb-focus .nb-side { display: none !important; }
body.nb-focus .main { margin-left: 0; padding: 0; }
body.nb-focus .sheet { border: 0; border-radius: 0; }
body.nb-focus .nb-app { display: block; }
body.nb-focus .nb-editor-wrap {
  position: fixed; inset: 0; z-index: 60; height: auto; min-height: 0;
  background: var(--sheet);
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
body.nb-focus .nb-editor-wrap.text-mode { overflow-y: auto; -webkit-overflow-scrolling: touch; }
body.nb-focus .nb-ed-top { top: 0; }

/* ==========================================================================
   Carta: note pronte per PDF e stampa (sempre chiare, a prescindere dal tema)
   ========================================================================== */
.nb-paper { display: block; color: #1d1b18; font-family: var(--font); font-size: 11.5pt; line-height: 1.55; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.nb-paper * { color: inherit; }
.nb-paper .print-note + .print-note { break-before: page; }
.nb-paper .print-note > header { border-bottom: 1px solid #ccc; margin-bottom: 14pt; padding-bottom: 8pt; }
.nb-paper .print-note > header h1 { font-size: 22pt; line-height: 1.15; color: #111; margin: 0; }
.nb-paper .print-note > header p { margin: 4pt 0 0; color: #666; font-size: 9.5pt; }
.nb-paper h1, .nb-paper h2, .nb-paper h3 { color: #111; font-family: var(--font-display); break-after: avoid; }
.nb-paper h2 { font-size: 16pt; margin: 16pt 0 6pt; }
.nb-paper h3 { font-size: 13pt; margin: 12pt 0 4pt; }
.nb-paper p, .nb-paper li { color: #222; max-width: none; margin: 0 0 6pt; }
.nb-paper ul, .nb-paper ol { color: #222; max-width: none; }
.nb-paper figure { margin: 10pt 0; text-align: center; break-inside: avoid; }
.nb-paper img { max-width: 100%; max-height: 120mm; margin: 0 auto; display: block; }
.nb-paper .nb-fig[data-size="s"] img { max-width: 45%; }
.nb-paper .nb-fig[data-size="m"] img { max-width: 75%; }
.nb-paper figcaption { font-size: 9pt; color: #666; margin-top: 4pt; }
.nb-paper blockquote { border-left: 3px solid #bbb; padding-left: 10pt; margin: 8pt 0; color: #444; }
.nb-paper blockquote.nb-key { border: 1px solid #ccc; border-left: 4px solid #888; padding: 8pt 10pt; border-radius: 6pt; }
.nb-paper mark { background: #fff1a6; }
.nb-paper code { background: #f0f0f0; }
.nb-paper ul.nb-check { list-style: none; padding-left: 0; }
.nb-paper ul.nb-check li::before { content: "☐  "; }
.nb-paper ul.nb-check li[data-checked="true"]::before { content: "☑  "; }
.nb-paper .nb-term { border-bottom: 1px dotted #999; background: none; padding: 0; }
.nb-paper .nb-term::after { display: none; }
.nb-paper .nb-draw { border: 1px solid #ddd; border-radius: 6pt; padding: 4pt; margin: 10pt 0; break-inside: avoid; }
.nb-paper .nb-draw svg { width: 100%; height: auto; max-height: 110mm; display: block; }
.nb-paper .nb-math { margin: 8pt 0; text-align: center; }
.nb-paper .print-audio { color: #666; font-style: italic; }
.nb-paper hr { border: 0; border-top: 1px solid #ccc; margin: 14pt 0; }
.nb-paper .print-page { break-after: page; }
.nb-paper .print-ink .print-page:last-of-type { break-after: auto; }
.nb-paper .print-page svg { display: block; width: 100%; height: auto; max-height: 246mm; margin: 0 auto; border: 1px solid #eee; }
.nb-paper .print-page-num { text-align: center; font-size: 8pt; color: #999; margin-top: 3pt; }
.nb-paper .print-transcript { break-before: page; }
.nb-paper .print-terms { break-before: page; }
.nb-paper .print-terms figure { display: inline-block; width: 46%; margin: 6pt 1.5%; vertical-align: top; }
.nb-paper .print-terms img { max-height: 70mm; }
.nb-paper .print-note > header { margin-top: 0; }
.nb-paper .paper-body > :first-child { margin-top: 0; }
#nb-print { display: none; }
.nb-pdf-stage .pdf-title { display: block; padding: 8px 0 16px; font-size: 22pt; font-weight: 700; line-height: 1.35; color: #111; overflow: visible; }
.nb-pdf-stage { position: fixed; left: -12000px; top: 0; background: #fff; padding: 0; z-index: -1; }
.nb-pdf-stage .print-page, .nb-pdf-stage .print-terms, .nb-pdf-stage .print-transcript { break-before: auto; }
.nb-pdf-stage .print-terms { margin-top: 18pt; }
@media print {
  @page { margin: 16mm 14mm; }
  html, body { background: #fff !important; }
  body > *:not(#nb-print) { display: none !important; }
  #nb-print { display: block; }
}

@media (max-width: 700px) {
  /* telefono: gli strumenti in una riga sola che scorre col dito (come GoodNotes), non quattro righe */
  .ink-tools { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding: 4px 8px; gap: 4px;
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent); }
  .ink-group { scroll-snap-align: start; }
  .ink-tools .ink-btn { min-width: 40px; height: 40px; }
  .ink-swatch { width: 28px; height: 28px; margin: 0 2px; }
}
@media (max-width: 600px) {
  /* barra della nota: il PDF è nel menu ⋯; icone a misura piena, la cartella non si schiaccia */
  .nb-ed-top [data-act=pdf], .nb-ed-top [data-act=mapimg] { display: none; }
  .nb-ed-top .btn, .nb-ed-top .nb-icon-btn { flex: none; }
  .nb-ed-top .btn svg { width: 18px; height: 18px; flex: none; }
  .nb-ed-top .nb-folder-chip { flex: 0 1 auto; min-width: 46px; }
  .nb-ed-top .nb-title-sm { min-width: 40px; }
}

/* ==========================================================================
   Popup comuni (js/ui.js)
   ========================================================================== */
.ui-menu {
  position: fixed; z-index: 380; min-width: 230px; max-width: min(320px, calc(100vw - 16px));
  overflow-y: auto; padding: 6px;
  background: var(--raised); color: var(--ink);
  border: 1px solid var(--stroke-2); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  opacity: 0; transform: translateY(-4px) scale(0.98); transform-origin: top left;
  transition: opacity 0.12s, transform 0.16s var(--ease);
}
.ui-menu.in { opacity: 1; transform: none; }
.ui-menu-title { padding: 8px 10px 6px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.ui-menu-head { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.ui-menu button {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink);
  font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
}
.ui-menu button:hover, .ui-menu button:focus-visible { background: var(--fill-2); outline: none; }
.ui-menu button:disabled { opacity: 0.38; cursor: default; background: transparent; }
.ui-menu button.danger, .ui-menu button.danger .ui-menu-ic { color: var(--ko); }
.ui-menu-ic { width: 20px; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.ui-menu-ic svg { width: 18px; height: 18px; }
.ui-menu-ic .tb-txt { font-size: 12px; }
.ui-menu-preview { width: 34px; height: 34px; flex: none; color: var(--ink-2); }
.ui-menu-preview svg { width: 100%; height: 100%; }
.ui-menu-label { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ui-menu-label small { font-size: 12.5px; color: var(--ink-3); }
.ui-menu-check { color: var(--ink); display: grid; place-items: center; }
.ui-menu-check svg { width: 16px; height: 16px; }
.ui-menu kbd { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.ui-menu hr { margin: 6px 4px; height: 1px; border: 0; background: var(--stroke); }
.ui-menu-bg button { min-height: 50px; }
.ui-confirm-text { margin: -4px 0 4px; color: var(--ink-2); font-size: 15px; }
.btn-danger { background: var(--ko); color: #fff; border-color: transparent; }
.btn-danger:hover { background: var(--ko); opacity: 0.9; }
/* l'elemento di cui è aperto il menu (⋯ o tasto destro): il contorno segue i suoi angoli */
.ui-ctx-target { outline: 2px solid var(--ink-3); outline-offset: 2px; }
[data-folder], [data-note] { -webkit-touch-callout: none; }

/* --- pulsante ⋯ (ui.moreBtn), lo stesso ovunque ---
   Al tocco sempre visibile; si vede un cerchio di 32 px ma si tocca in 44 px (--mb: il
   cerchio è uno sfondo sfumato, niente elementi in più sopra ogni scheda: le schede che
   scivolano mentre trascini restano leggere). Col mouse compare passando sopra l'elemento
   o arrivandoci con Tab. */
.ui-more {
  --mb: transparent;
  flex: none; display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0; margin: -6px;
  border: 0; border-radius: 50%; color: var(--ink-3);
  background: radial-gradient(circle closest-side, var(--mb) 72%, transparent 74%);
  font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  transition: color 0.15s, opacity 0.15s, transform 0.2s var(--ease);
}
.ui-more svg { width: 18px; height: 18px; pointer-events: none; }
.ui-more:hover, .ui-more[aria-expanded="true"] { --mb: var(--fill-2); color: var(--ink); }
.ui-more:active { transform: scale(0.88); --mb: var(--fill-3, var(--fill-2)); }
.ui-more:focus-visible { outline: 2px solid var(--solid); outline-offset: -4px; opacity: 1; }
/* premendo il ⋯ si preme lui, non tutta la scheda */
:is(.note-card, .folder-tile):has(.ui-more:active) { transform: none; }
@media (hover: hover) and (pointer: fine) {
  .ui-more { opacity: 0; }
  :is(.note-card, .folder-tile, .nb-tree-item, .fc-card, .cd-row, .at-item, .rg-item):is(:hover, :focus-within) .ui-more,
  .ui-ctx-target .ui-more, .ui-more[aria-expanded="true"] { opacity: 1; }
}
/* computer con lo schermo touch: il dito non passa sopra e tenere premuto non apre menu, il ⋯ resta visibile */
@media (any-pointer: coarse) { .ui-more { opacity: 1; } }

/* --- quaderno: barra laterale e trascinamento --- */
.nb-side-head span { display: flex; gap: 6px; }
.nb-icon-btn.sm { width: 34px; height: 34px; }
.nb-icon-btn.sm svg { width: 16px; height: 16px; }
.nb-side-hint { margin: 10px 8px 0; padding-top: 10px; border-top: 1px solid var(--stroke); font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.nb-tr-lang { gap: 6px; }
.ink-caret { width: 12px; height: 12px; opacity: 0.7; }

/* --- scrittura a mano: sfondo e dimensione della gomma --- */
.ink-bg span { font-size: 14px; color: var(--ink); }
.ink-widths.eraser-sizes .ink-w i { background: transparent; border: 1.5px dashed var(--ink-3); }
.ink-widths.eraser-sizes .ink-w.active i { border-color: var(--ink); border-style: solid; }

/* ==========================================================================
   Editor a blocchi
   ========================================================================== */
.nb-ed-shell { position: relative; }
.nb-gutter { position: absolute; left: -66px; display: flex; gap: 2px; z-index: 5; }
.nb-gutter.in-list { left: -86px; }
.nb-gutter[hidden] { display: none; }
.nb-gutter button {
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;
  display: grid; place-items: center; background: transparent; color: var(--ink-3); cursor: pointer;
  touch-action: none;
}
.nb-gutter button:hover, .nb-gutter button[aria-expanded="true"] { background: var(--fill-2); color: var(--ink); }
.nb-gutter svg { width: 18px; height: 18px; }
.nb-g-handle { cursor: grab !important; }
.nb-g-handle:active { cursor: grabbing !important; }
@media (max-width: 980px) {
  .nb-gutter { left: -40px; }
  .nb-gutter.in-list { left: -60px; }
  .nb-g-plus { display: none !important; }
}

/* barra di formattazione che compare sulla selezione */
.nb-bubble {
  position: fixed; z-index: 320;
  display: flex; align-items: center; gap: 1px; padding: 4px;
  background: var(--raised); border: 1px solid var(--stroke-2); border-radius: 13px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
  max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none;
}
.nb-bubble[hidden] { display: none; }
.nb-bubble::-webkit-scrollbar { display: none; }
.nb-bubble .tb { min-width: 38px; height: 38px; }
.nb-bubble .tb-sep { height: 20px; margin: 0 3px; }

/* html2canvas (PDF scaricato) sbaglia la posizione del testo con interlinee strette
   e con i marcatori nativi degli elenchi: valori espliciti e pallini disegnati */
.nb-paper, .nb-paper * { letter-spacing: 0; font-feature-settings: normal; }
.nb-paper .print-note { padding-bottom: 8px; }
.nb-paper h1, .nb-paper h2, .nb-paper h3 { line-height: 1.3; }
.nb-paper .print-note > header h1 { line-height: 1.25; }
.nb-paper .paper-body h1 { font-size: 20pt; margin: 16pt 0 6pt; }
.nb-paper p, .nb-paper li, .nb-paper blockquote { line-height: 1.55; }
.nb-paper ul:not(.nb-check) { list-style: none; padding-left: 18pt; }
.nb-paper ul:not(.nb-check) > li { position: relative; }
.nb-paper ul:not(.nb-check) > li::before { content: ""; position: absolute; left: -11pt; top: 0.62em; width: 4.5pt; height: 4.5pt; border-radius: 50%; background: #444; }
.nb-paper ol { padding-left: 20pt; }

/* ==========================================================================
   Scrittura a mano: strumenti in stile GoodNotes
   ========================================================================== */
.ink-host { position: relative; }
.ink-page.paper { background: #fff; }
.ink-addpage { display: flex; align-items: center; gap: 8px; }
.ink-addpage svg { width: 16px; height: 16px; }
.ink-pagemenu { width: 32px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); display: grid; place-items: center; cursor: pointer; }
.ink-pagemenu:hover { background: var(--fill-2); color: var(--ink); }
.ink-pagemenu svg { width: 18px; height: 18px; }
.ink-pageno {
  position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 6;
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px;
  border: 1px solid var(--stroke-2); border-radius: 999px; cursor: pointer;
  background: var(--raised); background: color-mix(in srgb, var(--raised) 88%, transparent); color: var(--ink);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); font: inherit; font-size: 13.5px; font-variant-numeric: tabular-nums;
  transition: transform 0.2s var(--ease), background 0.15s;
}
.ink-pageno svg { width: 17px; height: 17px; color: var(--ink-2); }
.ink-pageno:active { transform: scale(0.95); }
.ink-btn { transition: background 0.15s, color 0.15s, transform 0.15s var(--ease); }
.ink-btn:active:not(:disabled) { transform: scale(0.92); }
.ink-btn.active svg { animation: inkPop 0.28s var(--ease); }
@keyframes inkPop { 40% { transform: scale(1.14); } }
.ink-main .ink-btn { position: relative; }
.ink-main .ink-btn.active::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.ink-zoom { font-size: 13px; min-width: 52px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
/* tirare in fondo per una pagina nuova: il cerchio che si riempie sotto l'ultima pagina */
.ink-pull {
  position: absolute; left: 50%; bottom: 0; z-index: 5; width: 44px; height: 44px;
  display: grid; place-items: center; pointer-events: none; opacity: 0;
  color: var(--ink-2); transform: translate3d(-50%, 0, 0) scale(0.6);
}
.ink-pull-ring { position: absolute; inset: 0; width: 44px; height: 44px; overflow: visible; transform: rotate(-90deg); }
.ink-pull-ring circle { fill: none; stroke: var(--stroke-2); stroke-width: 2.5; transition: fill 0.12s, stroke 0.12s; }
.ink-pull-ring .bar { stroke: var(--ink-2); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; }
.ink-pull > svg:last-child { position: relative; width: 20px; height: 20px; transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.ink-pull.full { color: var(--app); }
.ink-pull.full .ink-pull-ring circle { fill: var(--ink); stroke: var(--ink); }
.ink-pull.full > svg:last-child { transform: scale(1.18) rotate(90deg); }
.ink-pull.done { opacity: 0 !important; transition: opacity 0.08s; }
.ink-widths.dim { opacity: 0.35; }
.ink-swatch { transition: transform 0.15s var(--ease), box-shadow 0.15s; }
.ink-swatch:active { transform: scale(0.88); }
.ink-swatch.active { transform: scale(1.08); }
.ink-custom { position: relative; display: inline-block; overflow: hidden; vertical-align: middle; background: conic-gradient(#ff453a, #ff9f0a, #ffd60a, #30d158, #64d2ff, #2997ff, #bf5af2, #ff375f, #ff453a); }

/* selettore di colore */
.ink-picker { width: min(336px, calc(100vw - 16px)); }
.ink-pick-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; padding: 0 2px 12px; }
.ink-pick-sw { aspect-ratio: 1; width: 100%; padding: 0; border: 0; border-radius: 50%; background: var(--sw); cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); transition: transform 0.12s var(--ease), box-shadow 0.12s; }
.ink-pick-sw:active { transform: scale(0.88); }
.ink-pick-sw.active { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--ink-2); }
.ink-pick-sv {
  position: relative; height: 150px; border-radius: 12px; touch-action: none; cursor: crosshair;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(var(--h, 210), 100%, 50%));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.ink-pick-sv i { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3); pointer-events: none; }
.ink-picker input.ink-pick-hue { display: block; width: 100%; height: 28px; margin: 10px 0 8px; }
.ink-picker input.ink-pick-hue::-webkit-slider-runnable-track { height: 22px; border-radius: 11px; background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.ink-picker input.ink-pick-hue::-moz-range-track { height: 22px; border-radius: 11px; background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00); }
.ink-picker input.ink-pick-hue::-moz-range-progress { background: transparent; }
.ink-picker input.ink-pick-hue::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -2px; border: 3px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3); }
.ink-picker input.ink-pick-hue::-moz-range-thumb { width: 20px; height: 20px; border: 3px solid #fff; border-radius: 50%; background: transparent; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
.ink-pick-row { display: flex; align-items: center; gap: 10px; }
.ink-pick-prev { flex: none; width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.ink-pick-hex { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 1px solid var(--stroke-2); border-radius: 10px; background: var(--fill); color: var(--ink); font: 500 16px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: lowercase; }
.ink-dot { display: block; width: 22px; height: 22px; margin: 6px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }

/* opzioni dello strumento */
.ink-pop {
  position: fixed; z-index: 370; width: min(320px, calc(100vw - 16px));
  padding: 12px; background: var(--raised); color: var(--ink);
  border: 1px solid var(--stroke-2); border-radius: 16px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  opacity: 0; transform: translateY(-6px) scale(0.97); transform-origin: top center;
  transition: opacity 0.14s, transform 0.2s var(--ease);
}
.ink-pop.in { opacity: 1; transform: none; }
.ink-pop-title { font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); padding: 2px 4px 8px; }
.ink-pop-hint { margin: 10px 4px 2px; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.ink-pens { display: grid; gap: 4px; }
.ink-pen { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 6px 8px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.ink-pen:hover { background: var(--fill); }
.ink-pen.active { border-color: var(--stroke-2); background: var(--fill-2); }
.ink-pen-prev { grid-row: span 2; width: 96px; height: 22px; color: var(--ink); }
.ink-pen b { font-size: 14.5px; font-weight: 600; }
.ink-pen small { font-size: 12.5px; color: var(--ink-3); }
.ink-range { display: grid; grid-template-columns: auto 1fr 36px; align-items: center; gap: 10px; padding: 12px 4px 2px; font-size: 14px; color: var(--ink-2); }
.ink-range input { width: 100%; accent-color: var(--ink); }
.ink-range output { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.ink-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 12px; background: var(--fill-2); }
.ink-seg button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.ink-seg button svg { width: 18px; height: 18px; }
.ink-seg button.active { background: var(--raised); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }
.ink-check { display: flex; align-items: center; gap: 10px; padding: 10px 4px 0; font-size: 14px; color: var(--ink); cursor: pointer; }
.ink-check input { width: 18px; height: 18px; accent-color: var(--ink); flex: none; }

/* selezione del lazo */
.ink-sel {
  position: absolute; z-index: 4; border: 1.5px dashed #2997ff; border-radius: 8px;
  background: rgba(41, 151, 255, 0.05); touch-action: none; cursor: move;
  opacity: 0; transition: opacity 0.15s;
}
.ink-sel.in { opacity: 1; }
.ink-sel-handle { position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; border-radius: 50%; background: #2997ff; border: 3px solid var(--raised); cursor: nwse-resize; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.ink-sel-bar {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  display: flex; gap: 2px; padding: 4px; white-space: nowrap;
  background: var(--raised); border: 1px solid var(--stroke-2); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); cursor: default;
}
.ink-sel.bar-below .ink-sel-bar { bottom: auto; top: calc(100% + 16px); }
.ink-sel-bar button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.ink-sel-bar button:hover { background: var(--fill-2); }
.ink-sel-bar button.danger { color: var(--ko); }
.ink-sel-bar svg { width: 19px; height: 19px; }

/* navigatore delle pagine */
.nb-modal.ink-nav { width: min(860px, 100%); height: min(760px, calc(100dvh - 32px)); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.ink-nav-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--stroke); }
.ink-nav-head h3 { margin: 0; flex: 1; }
.ink-nav-grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px; padding: 18px; align-content: start; }
.ink-nav-item { display: flex; flex-direction: column; gap: 6px; animation: rise 0.3s var(--ease) both; animation-delay: calc(min(var(--i), 12) * 25ms); }
.ink-nav-page { aspect-ratio: 1000 / 1414; padding: 0; border: 1px solid var(--stroke-2); border-radius: 8px; background: var(--raised); color: var(--ink); overflow: hidden; cursor: pointer; transition: transform 0.18s var(--ease), box-shadow 0.18s; }
.ink-nav-page.paper { background: #fff; }
.ink-nav-page:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18); }
.ink-nav-page svg { width: 100%; height: 100%; display: block; }
/* miniature: tela piccola sopra lo sfondo CSS della pagina (righe, quadretti) */
.ink-nav-page { background-repeat: no-repeat; background-size: 100% 100%; }
.ink-nav-page canvas { display: block; width: 100%; height: 100%; }
.ink-nav-item.current .ink-nav-page { box-shadow: 0 0 0 2px var(--ink-2); }
.ink-nav-foot { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--ink-3); padding: 0 2px; }
.note-thumb.paper { background: #fff; }
.note-thumb.paper svg { padding: 0; }

/* ==========================================================================
   File caricati
   ========================================================================== */
.note-card.is-file .note-thumb { position: relative; }
.file-badge { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--c, var(--ink-2)); }
.file-badge svg { width: 38px; height: 38px; padding: 0; }
.file-badge b { font-size: 11.5px; letter-spacing: 0.06em; color: var(--ink-3); }
.note-card.is-file .note-thumb img { position: relative; z-index: 1; background: var(--tray); }
.nb-dropping .nb-main { outline: 2px dashed var(--ink-3); outline-offset: -10px; border-radius: 18px; }
.nb-editor-wrap.file-mode { height: calc(100dvh - 70px); min-height: 0; }
@media (max-width: 980px) { .nb-editor-wrap.file-mode { height: calc(100dvh - 52px); } }
body.nb-focus .nb-editor-wrap.file-mode { height: auto; }
.nb-file-area { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fv { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.fv-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--stroke); flex-wrap: wrap; }
.fv-kind { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-3); }
.fv-kind svg { width: 18px; height: 18px; }
.fv-grow { flex: 1; }
.fv-zoom { display: inline-flex; align-items: center; gap: 2px; }
.fv-zoom[hidden] { display: none; }
.fv-zv { min-width: 54px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
.fv-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--app); position: relative; }
.fv-body > * { transform-origin: 50% 0; }
.fv-msg { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.fv-img { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.fv-img img { max-width: 100%; max-height: calc(100dvh - 180px); border-radius: 6px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.22); cursor: zoom-in; animation: rise 0.35s var(--ease) both; }
.fv-pages { display: flex; flex-direction: column; align-items: center; gap: 30px; padding: 16px 16px 40px; min-width: min-content; }
.fv-page { position: relative; background: #fff; border-radius: 4px; box-shadow: 0 0 0 1px var(--stroke), 0 8px 26px rgba(0, 0, 0, 0.16); }
.fv-page canvas { display: block; max-width: none; border-radius: 4px; }
.fv-page span { position: absolute; right: 4px; bottom: -22px; font-size: 12px; color: var(--ink-3); }
.fv-media { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.fv-media video { max-width: 100%; max-height: calc(100dvh - 180px); border-radius: 10px; background: #000; }
.fv-audio { gap: 14px; text-align: center; align-content: center; }
.fv-audio audio { width: min(460px, 90vw); }
.fv-big { width: 84px; height: 84px; border-radius: 24px; display: grid; place-items: center; background: var(--fill-2); color: var(--c, var(--ink-2)); margin: 0 auto; }
.fv-big svg { width: 42px; height: 42px; }
.fv-text { margin: 0; padding: 20px; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--ink); }
.fv-other { max-width: 440px; margin: 0 auto; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.fv-other b { font-size: 17px; word-break: break-word; }
.fv-other small { color: var(--ink-3); }
.fv-other p { color: var(--ink-2); font-size: 14.5px; }
.fv-frame { width: 100%; height: 70vh; border: 0; background: #fff; }
.nb-modal-back:has(.nb-fileview) { padding: 0; }
.nb-modal.nb-fileview { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; padding: 0; display: flex; flex-direction: column; background: var(--sheet); overflow: hidden; }
.nb-fileview-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fv-title { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-ready { text-align: center; }
.nb-ready-ic { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; display: grid; place-items: center; background: var(--fill-2); color: var(--ink-2); }
.nb-ready-ic svg { width: 28px; height: 28px; }
.nb-ready .nb-modal-actions { justify-content: center; }

/* allegato dentro una nota */
.nb-doc .nb-file { position: relative; display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 12px 14px; border: 1px solid var(--stroke-2); border-radius: 14px; background: var(--fill); cursor: pointer; transition: background 0.15s, transform 0.15s var(--ease); }
.nb-doc .nb-file:hover { background: var(--fill-2); }
.nb-doc .nb-file:active { transform: scale(0.99); }
.nb-file-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--fill-2); color: var(--ink-2); flex: none; }
.nb-file-ic svg { width: 22px; height: 22px; }
.nb-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nb-file-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-file-main small { font-size: 12.5px; color: var(--ink-3); }
.nb-doc .nb-file .nb-audio-ui { display: flex; gap: 6px; }
.nb-audio-ui button svg { width: 17px; height: 17px; }

/* barra di formattazione agganciata sopra la tastiera (iPad, telefono) */
.nb-bubble.docked {
  border-radius: 16px; padding: 5px;
  background: var(--raised); background: color-mix(in srgb, var(--raised) 90%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  max-width: min(760px, calc(100vw - 16px));
}
.nb-bubble.docked .tb { min-width: 42px; height: 42px; }
.nb-bubble:not([hidden]) { animation: bubbleIn 0.18s var(--ease); }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
.tb { transition: background 0.12s, color 0.12s, transform 0.12s var(--ease); }
.tb:active { transform: scale(0.9); }

/* comparsa di schede, cartelle e note */
.folder-tile, .note-card { animation: rise 0.36s var(--ease) both; }
.folder-tiles > :nth-child(2), .note-cards > :nth-child(2) { animation-delay: 30ms; }
.folder-tiles > :nth-child(3), .note-cards > :nth-child(3) { animation-delay: 60ms; }
.folder-tiles > :nth-child(4), .note-cards > :nth-child(4) { animation-delay: 90ms; }
.folder-tiles > :nth-child(5), .note-cards > :nth-child(5) { animation-delay: 120ms; }
.folder-tiles > :nth-child(6), .note-cards > :nth-child(6) { animation-delay: 150ms; }
.folder-tiles > :nth-child(n+7), .note-cards > :nth-child(n+7) { animation-delay: 180ms; }
.folder-tile, .note-card { transition: background 0.15s, border-color 0.15s, transform 0.2s var(--ease), box-shadow 0.2s; }
.folder-tile:active, .note-card:active { transform: scale(0.98); }
@media (hover: hover) {
  .note-card:hover, .folder-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14); }
}
.nb-editor-wrap { animation: fadeIn 0.25s ease-out both; }
.nb-page { animation: fadeIn 0.22s ease-out both; }
.nb-tree-item { transition: background 0.15s, color 0.15s; }
.nb-tree-node .nb-tree-chev { transition: transform 0.22s var(--ease); }
.nb-modal-back.in .nb-modal { animation: none; }
.nb-floatbar { transition: opacity 0.2s, transform 0.25s var(--ease); }

/* barra di stato dell'iPad (app sulla Home): spazi in alto del quaderno */
.nb-app { min-height: calc(100vh - 70px - var(--sat)); }
.nb-side { top: calc(60px + var(--sat)); height: calc(100vh - 70px - var(--sat)); }
.nb-ed-top { top: calc(60px + var(--sat)); }
.nb-editor-wrap { min-height: calc(100vh - 70px - var(--sat)); }
.nb-editor-wrap.ink-mode, .nb-editor-wrap.file-mode { height: calc(100dvh - 70px - var(--sat)); }
@media (max-width: 980px) {
  .nb-side { top: calc(52px + var(--sat)); height: calc(100vh - 52px - var(--sat)); }
  .nb-ed-top { top: calc(52px + var(--sat)); }
  .nb-editor-wrap.ink-mode, .nb-editor-wrap.file-mode { height: calc(100dvh - 52px - var(--sat)); }
}
body.nb-focus .nb-ed-top { top: 0; }
body.nb-focus .nb-editor-wrap.ink-mode, body.nb-focus .nb-editor-wrap.file-mode { height: auto; }
body.nb-focus::before { background: var(--sheet); }

/* caselle di testo sulle pagine a mano */
.ink-textedit {
  position: absolute; z-index: 5; margin: 0; padding: 3px; resize: none; overflow: hidden;
  border: 1.5px dashed #2997ff; border-radius: 6px; background: rgba(41, 151, 255, 0.05);
  outline: none; -webkit-user-select: text; user-select: text; touch-action: auto;
}
.ink-page.paper .ink-textedit { background: rgba(41, 151, 255, 0.04); }
.ink-host[data-tool="text"] .ink-page canvas { cursor: text; }
.ink-seg3 { grid-template-columns: repeat(3, 1fr); }
.ink-seg3 span { font-weight: 600; line-height: 1; }
.nb-paper .print-map svg { width: 100%; height: auto; max-height: 240mm; }

/* menu dei modelli: voci con descrizione, più ariose */
.ui-menu.ui-menu-tpl { min-width: 280px; max-width: min(360px, calc(100vw - 16px)); padding: 8px; }
.ui-menu-tpl button { align-items: flex-start; gap: 12px; min-height: 0; padding: 11px 12px; margin: 2px 0; }
.ui-menu-tpl .ui-menu-ic { margin-top: 1px; }
.ui-menu-tpl .ui-menu-label { gap: 3px; }
.ui-menu-tpl .ui-menu-label small { line-height: 1.4; }
.ui-menu-tpl .ui-menu-head { padding: 10px 12px 4px; }
.ui-menu-tpl hr { margin: 8px 6px; }

/* anteprima della punta (Apple Pencil vicina allo schermo, mouse) */
.ink-hover { position: absolute; left: 0; top: 0; z-index: 3; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity 0.12s, width 0.12s, height 0.12s; will-change: transform; }
.ink-hover.on { opacity: 1; }
.ink-hover.pen { background: var(--hc); opacity: 0; }
.ink-hover.pen.on { opacity: 0.5; box-shadow: 0 0 0 1.5px rgba(var(--ink-rgb), 0.25); }
.ink-hover.hl.on { background: var(--hc); opacity: 0.3; }
.ink-hover.eraser { border: 1.5px solid rgba(var(--ink-rgb), 0.55); background: rgba(var(--ink-rgb), 0.05); }
.ink-pop-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ink-tape-cols { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0 4px; }
.ink-host[data-tool="tape"] .ink-page canvas { cursor: crosshair; }
.ink-wprev { display: block; width: 100%; height: 44px; margin: 2px 0 6px; color: var(--ink); }

/* ricerca: risultati con la frase, barra nella nota, segni sulla pagina */
.nb-hits { display: grid; gap: 8px; }
.nb-hit { display: grid; gap: 4px; padding: 12px 14px; border-radius: 14px; background: var(--fill); text-decoration: none; color: var(--ink); box-shadow: inset 3px 0 0 var(--c); transition: background 0.15s; }
.nb-hit:hover { background: var(--fill-2); }
.nb-hit-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.nb-hit-top b { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-hit-top small { flex: none; font-size: 12.5px; color: var(--ink-3); }
.nb-hit-top .note-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); align-self: center; }
.nb-hit-snip { font-size: 14px; line-height: 1.5; color: var(--ink-2); overflow-wrap: anywhere; }
.nb-hit-snip mark, .nb-find-mark { background: rgba(255, 214, 10, 0.45); color: inherit; border-radius: 3px; padding: 0 1px; }
.nb-find { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 6px; margin: 0 0 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--stroke-2); border-radius: 14px; background: var(--raised); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14); animation: rise 0.2s var(--ease) both; }
.nb-find > svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); }
.nb-find input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font: inherit; font-size: 16px; padding: 6px 0; }
.nb-find-n { flex: none; font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.nb-find.none .nb-find-n { color: var(--ko); }
.nb-find .nb-icon-btn svg { width: 18px; height: 18px; }
::highlight(nb-find) { background-color: rgba(255, 214, 10, 0.4); }
::highlight(nb-find-cur) { background-color: #ff9f0a; color: #000; }
.ink-find { position: absolute; z-index: 2; border-radius: 6px; background: rgba(255, 214, 10, 0.28); box-shadow: inset 0 0 0 1.5px rgba(255, 196, 0, 0.7); pointer-events: none; transition: background 0.2s; }
.ink-find.cur { background: rgba(255, 159, 10, 0.38); box-shadow: inset 0 0 0 2px #ff9f0a, 0 0 0 4px rgba(255, 159, 10, 0.2); }

/* ritaglio delle immagini */
.nb-modal.nb-crop-modal { width: min(820px, calc(100vw - 24px)); }
.nb-crop-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.nb-crop-head h3 { margin: 0; }
.nb-crop-size { font: 500 12.5px/1 'SF Mono', ui-monospace, monospace; color: var(--ink-3); }
.nb-crop-stage { display: grid; place-items: center; padding: 14px; border-radius: 14px; background: repeating-conic-gradient(rgba(var(--ink-rgb), 0.06) 0 25%, transparent 0 50%) 0 0 / 18px 18px; }
.nb-crop-img { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
.nb-crop-img img { display: block; width: 100%; height: 100%; object-fit: fill; border-radius: 2px; pointer-events: none; }
.nb-crop-box { position: absolute; outline: none; cursor: move; touch-action: none; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.52); border: 1.5px solid #fff; }
.nb-crop-stage { overflow: hidden; }
.nb-crop-box:focus-visible { border-color: #2997ff; }
.nb-crop-grid { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.15s;
  background: linear-gradient(90deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.6) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.6) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.6) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.6) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
              linear-gradient(180deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.6) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.6) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.6) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.6) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)); }
.nb-crop-box.dragging .nb-crop-grid { opacity: 1; }
.nb-crop-h { position: absolute; width: 26px; height: 26px; touch-action: none; }
.nb-crop-h::after { content: ""; position: absolute; inset: 8px; border-radius: 3px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.nb-crop-h[data-h="nw"] { left: -13px; top: -13px; cursor: nwse-resize; }
.nb-crop-h[data-h="ne"] { right: -13px; top: -13px; cursor: nesw-resize; }
.nb-crop-h[data-h="se"] { right: -13px; bottom: -13px; cursor: nwse-resize; }
.nb-crop-h[data-h="sw"] { left: -13px; bottom: -13px; cursor: nesw-resize; }
.nb-crop-h[data-h="n"] { left: calc(50% - 13px); top: -13px; cursor: ns-resize; }
.nb-crop-h[data-h="s"] { left: calc(50% - 13px); bottom: -13px; cursor: ns-resize; }
.nb-crop-h[data-h="e"] { right: -13px; top: calc(50% - 13px); cursor: ew-resize; }
.nb-crop-h[data-h="w"] { left: -13px; top: calc(50% - 13px); cursor: ew-resize; }
.nb-crop-h[data-h="n"]::after, .nb-crop-h[data-h="s"]::after { inset: 10px 4px; }
.nb-crop-h[data-h="e"]::after, .nb-crop-h[data-h="w"]::after { inset: 4px 10px; }
.nb-crop-ratios { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }
.nb-crop-ratios button { padding: 6px 12px; border: 1px solid var(--stroke-2); border-radius: 999px; background: transparent; color: var(--ink-2); font: inherit; font-size: 13.5px; cursor: pointer; }
.nb-crop-ratios button.active { background: var(--solid); color: var(--on-solid); border-color: transparent; }


/* ==========================================================================
   Cartelle nascoste mentre scrivi (js/nb/notebook.js: side-off, side-peek)
   ========================================================================== */
.nb-app { transition: grid-template-columns 0.36s var(--ease); }
@media (min-width: 901px) {
  .nb-side { transition: opacity 0.26s ease 0.06s, transform 0.36s var(--ease), visibility 0s; }
  .nb-app.side-off { grid-template-columns: 0px minmax(0, 1fr); }
  .nb-app.side-off .nb-side {
    opacity: 0; transform: translateX(-28px) scale(0.98); visibility: hidden; pointer-events: none; overflow: hidden;
    transition: opacity 0.18s ease, transform 0.36s var(--ease), visibility 0s linear 0.36s;
  }
}
.nb-side-btn[aria-pressed="true"] { background: var(--fill-3); }
@media (max-width: 600px) { .nb-side-btn { display: none !important; } }
body.nb-focus .nb-side-btn { display: none !important; }
/* schermo stretto: la colonna si apre sopra la nota */
@media (max-width: 900px) {
  .nb-app.side-peek .nb-side {
    display: flex !important; position: fixed; z-index: 90;
    left: calc(8px + env(safe-area-inset-left, 0px)); top: calc(8px + var(--sat, 0px)); bottom: calc(8px + var(--sab, 0px)); height: auto !important; /* sopra la barra della Home */
    width: min(300px, 84vw); margin: 0;
    background: var(--raised); border-radius: 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3), inset 0 0 0 0.5px var(--card-edge, var(--stroke));
    animation: nbSideIn 0.32s var(--ease) both;
  }
  .nb-side-scrim { position: fixed; inset: 0; z-index: 89; background: rgba(0, 0, 0, 0.32); animation: fadeIn 0.2s ease-out both; }
}
@keyframes nbSideIn { from { transform: translateX(-40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .nb-app, .nb-side { transition: none !important; }
  .nb-app.side-peek .nb-side, .nb-side-scrim { animation: none; }
}

/* ==========================================================================
   Trascinare cartelle, note e blocchi (js/drag.js e gridSort in notebook.js)
   ========================================================================== */
.note-card, .folder-tile, .nb-tree-item { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.nb-calm .folder-tile, .nb-calm .note-card { animation: none; }
/* transition: none — la copia la muove la molla di drag.js a ogni fotogramma; la transizione delle
   schede (transform 0,4 s) la faceva restare indietro. Il rilascio mette la sua transizione inline */
.dg-ghost.note-card, .dg-ghost.folder-tile { transition: none; box-shadow: 0 22px 46px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--stroke); }
.dg-ghost.nb-tree-node { padding: 2px 6px; background: var(--raised); }
.dg-ghost.nb-tree-node .nb-tree-kids { display: none; }
.folder-tile.dg-into, .nb-tree-item.dg-into { outline: 2px solid var(--c, var(--solid)); }
/* blocco della nota mentre vola: stesso testo, su un foglio */
.dg-ghost.nb-ghost-blk { padding: 0; list-style: none; overflow: visible; margin: 0; border: 0; background: var(--raised); outline: 8px solid var(--raised); }
.dg-ghost.nb-ghost-blk::before, .dg-ghost.nb-ghost-blk::after { display: none; }
.nb-doc > .dg-hole, .nb-doc li.dg-hole { opacity: 0; }

/* ==========================================================================
   Editor di testo: titolo, colonna, maniglie, segnaposto, barra
   ========================================================================== */
/* line-height dopo font: la scorciatoia font la riportava a quella del testo (1,6) */
textarea.nb-title { display: block; resize: none; overflow: hidden; min-height: 1.2em; font: inherit; line-height: 1.15; font-family: var(--font-display); font-size: clamp(28px, 4vw, 38px); font-weight: 650; letter-spacing: -0.025em; }
.nb-wc { font-variant-numeric: tabular-nums; }
.nb-doc { -webkit-text-size-adjust: 100%; }
.nb-doc a { cursor: pointer; }
/* segnaposto del blocco vuoto dove c'è il cursore */
.nb-doc [data-ph] { position: relative; }
.nb-doc [data-ph]::after { content: attr(data-ph); position: absolute; left: 0; top: 0; color: var(--ink-4); pointer-events: none; white-space: nowrap; font-weight: inherit; }
.nb-doc blockquote[data-ph]::after { left: 18px; top: 2px; }
.nb-doc blockquote.nb-key[data-ph]::after { left: 16px; top: 12px; }
/* concentrazione: gli altri paragrafi si attenuano */
.nb-doc.dim > *, .nb-doc.dim > :is(ul, ol) > li { transition: opacity 0.25s ease; }
.nb-doc.dim > :not(ul):not(ol):not(.is-cur), .nb-doc.dim > :is(ul, ol) > li:not(.is-cur) { opacity: 0.3; }
.nb-gutter button { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 600px) {
  .nb-ed-inner { padding: 18px 16px 120px 38px; }
  .nb-gutter { left: -36px; }
  .nb-gutter.in-list { left: -56px; }
  .nb-gutter .nb-g-handle { width: 30px; height: 36px; }
  .nb-doc { font-size: 17px; line-height: 1.65; }
  .nb-tip { font-size: 13px; }
}
@media (pointer: coarse) {
  /* col dito la maniglia è più grande da prendere (la zona attiva va oltre il disegno) */
  .nb-g-handle { position: relative; }
  .nb-g-handle::before { content: ""; position: absolute; inset: -8px -6px; }
}
/* barra di formattazione: una riga che scorre (con dissolvenza ai bordi), il tasto per chiudere la tastiera fermo */
.nb-bubble { gap: 0; }
.nb-bubble .nbt-row { display: flex; align-items: center; gap: 1px; min-width: 0; flex: 1; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.nb-bubble .nbt-row::-webkit-scrollbar { display: none; }
.nb-bubble:not(.in-list) .tb-list { display: none; }
.nb-bubble .tb:disabled { opacity: 0.35; cursor: default; background: transparent; }
.nb-bubble .nbt-end { display: flex; align-items: center; flex: none; padding-left: 4px; margin-left: 2px; border-left: 1px solid var(--stroke-2); }
.nb-bubble.docked { position: fixed; touch-action: pan-x; }
.nb-bubble.docked .nbt-row { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent); padding-right: 18px; }
.nb-bubble.docked .tb { min-width: 44px; height: 44px; border-radius: 12px; }
.nb-bubble.docked.full { max-width: none; border-radius: 18px; }
.nb-bubble.docked .tb.on { background: var(--fill-3); color: var(--ink); }
/* nella nota la fine del testo resta sopra la barra */
@media (pointer: coarse) { .nb-doc { padding-bottom: max(20vh, 140px); } }
/* iPad: testo un filo più grande, si legge a distanza di braccio */
@media (min-width: 700px) and (pointer: coarse) { .nb-doc { font-size: 18px; } }
