/* Pagina degli appunti: intestazione, editor di testo, pagine a mano, pannelli laterali. */

.note-page { background: var(--bg); }
.note-head { align-items: flex-start; padding-bottom: 6px; }
.note-head > .icon-btn, .note-head > .btn, .note-head > span { margin-top: 1px; }
.note-head-main { display: flex; flex-direction: column; gap: 4px; }
.note-head-main h1 { line-height: 1.25; }
.note-title {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  padding: 0;
  border-bottom: 1px solid transparent;
}
.note-title:focus { border-bottom-color: var(--border-strong); }
.note-when { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text-2); }
.note-when span { display: inline-flex; align-items: center; gap: 5px; }
.save-state { font-size: 12px; color: var(--text-3); align-self: center; min-width: 52px; text-align: right; white-space: nowrap; }
.save-state.busy { color: var(--accent-text); }

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 2px 20px 10px 64px;
  flex: none;
}
.note-people { display: flex; flex-wrap: wrap; gap: 5px; }
.chip.person { padding-left: 2px; height: 26px; gap: 6px; }
.chip.person .avatar { width: 21px; height: 21px; font-size: 9.5px; }
.commessa-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--surface);
}
.commessa-pick:focus-within { border-style: solid; border-color: var(--accent); }
.commessa-pick input { border: 0; outline: 0; background: transparent; width: 170px; font-size: 13px; font-weight: 550; }
.commessa-pick input::placeholder { color: var(--text-3); font-weight: 400; }

.note-tabs { padding: 0 14px 8px; overflow-x: auto; flex: none; scrollbar-width: none; }
.note-tabs::-webkit-scrollbar { display: none; }
.dot-ai { width: 6px; height: 6px; border-radius: 50%; background: var(--ai); }

.note-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  border-top: 1px solid var(--border);
}
.note-layout.single { grid-template-columns: minmax(0, 1fr); }
.note-main {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 40px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.note-main > * { flex: none; width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; }
.note-main > .panel-stack, .note-main > .empty { padding-top: 14px; }
.note-side { min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--bg); }
.note-side-tabs { margin: 12px 14px 4px; align-self: flex-start; }
.note-side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px 32px; }

/* ---- Editor di testo ---- */

.mde { display: flex; flex-direction: column; min-height: 220px; }
.mde-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 8px 0 4px;
  margin-bottom: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.mde-bar::-webkit-scrollbar { display: none; }
.mde-bar .btn.on { background: var(--accent-soft); color: var(--accent-text); }
.mde-wrap { position: relative; flex: 1; display: flex; }
.mde-text {
  flex: 1;
  width: 100%;
  min-height: 240px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.6;
  padding: 6px 0;
  overflow: hidden;
  field-sizing: content;
}
.mde-text::placeholder { color: var(--text-3); }
.mde-preview { padding: 6px 0; min-height: 240px; font-size: 16px; }
.mde-suggest {
  position: absolute;
  left: 0;
  top: 4px;
  z-index: 6;
  width: min(360px, 100%);
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.mde-suggest button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  font-size: 14px;
}
.mde-suggest button.on, .mde-suggest button:hover { background: var(--accent-soft); }
.mde-suggest button span.ellipsis { flex: 1; }

/* ---- Pagine a mano (miniature) ---- */

.ink-section { margin-bottom: 0; padding-top: 14px; border-top: 1px solid var(--border); }
.ink-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ink-thumb {
  position: relative;
  aspect-ratio: 1200 / 1697;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.12s, border-color 0.12s;
}
.ink-thumb:hover { border-color: var(--accent); box-shadow: var(--shadow-2); }
.ink-thumb img { width: 100%; height: 100%; object-fit: contain; object-position: top; display: block; }
.ink-thumb-n {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(20, 22, 28, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---- Pannelli: briefing, cervello, attivita' ---- */

.panel-stack { display: flex; flex-direction: column; gap: 4px; }
.panel-stack .section { margin-bottom: 16px; }
.prev-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
.prev-card:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow-1); }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fact {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 6px 2px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.45;
}
.fact .icon { margin-top: 2px; color: var(--text-3); }
a.fact:hover { text-decoration: none; color: var(--accent-text); }
.ai-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--ai-soft);
  color: var(--ai);
  font-size: 13.5px;
  line-height: 1.45;
}
.ai-note .icon { margin-top: 1px; }
.ai-title { display: flex; align-items: center; gap: 6px; color: var(--ai); }
.ai-card { border-color: color-mix(in srgb, var(--ai) 28%, var(--border)); }
.ai-ink { color: var(--ai); }
.small-md { font-size: 14px; }

.proposal-list { display: flex; flex-direction: column; gap: 10px; }
.proposal { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.proposal.handled { opacity: 0.55; }
.proposal-src { display: block; margin-top: 2px; }

.transcript { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 8px 12px; }
.transcript + .transcript { margin-top: 6px; }
.transcript summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.transcript-text { white-space: pre-wrap; font-size: 14px; line-height: 1.55; padding: 8px 0; }
.transcript .md { padding: 8px 0; }

@media (max-width: 1099px) {
  .note-meta { padding-left: 20px; }
}
@media (max-width: 720px) {
  .note-head { padding-bottom: 4px; }
  .note-meta { padding: 2px 14px 8px; }
  .note-main { padding: 0 14px 32px; }
  .note-head h1.ellipsis { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 18px; }
  .commessa-pick input { width: 130px; }
  .save-state { display: none; }
  .ink-thumbs { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

.ink-thumb-wrap { position: relative; }
.ink-thumb-wrap .ink-thumb { width: 100%; }
.ink-thumb-del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 22, 28, 0.6);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.12s;
}
.ink-thumb-wrap:hover .ink-thumb-del, .ink-thumb-del:focus-visible { opacity: 1; }
@media (pointer: coarse) { .ink-thumb-del { opacity: 1; } }
.tpl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: -8px; }
.tpl-row .chip { cursor: pointer; }