:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1d2330; --muted: #565e6b; --line: #e3e6eb;
  --accent: #2457d6; --accent-ink: #fff; --ok: #14773f; --warn: #9a5b00; --err: #b42318;
  --todo: #fff3a3; --tint: #eef3ff;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
::selection { background: #cfdcff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
tr.click:focus-visible { outline-offset: -2px; }
.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 16px; }
.top nav a { color: var(--ink); padding: 4px 2px; border-bottom: 2px solid transparent; }
.top nav a.active { border-color: var(--accent); }
.status { margin-left: auto; display: flex; gap: 10px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; background: var(--err); }
.dot.ok { background: var(--ok); }
main { max-width: 1400px; margin: 0 auto; padding: 20px; }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 18px 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button, .btn { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--err); }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=search], input[type=password], select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; }
textarea { resize: vertical; min-height: 60px; }
textarea.md { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 140px; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover { background: #f0f4ff; }
button.ren { padding: 0 6px; margin-left: 4px; font-size: 12px; line-height: 18px; border-color: transparent; background: transparent; color: var(--muted); }
table.list tr:hover button.ren:not(:disabled) { border-color: var(--line); color: var(--ink); }
button.ren:hover:not(:disabled) { background: #fff; }
table.list tr:hover button.del:not(:disabled) { color: var(--err); }
.badge { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 10px; background: #eef1f5; color: var(--muted); }
.badge.ready { background: #e3f6ea; color: var(--ok); }
.badge.error { background: #fde8e8; color: var(--err); }
.badge.running, .badge.analyzing { background: #fff4de; color: var(--warn); }
.badge + .badge { margin-left: 4px; }
.badge.todo { background: var(--todo); color: #7a5b00; }
.badge.check { background: #ffe0b2; color: #7a3d00; }
.drop { border: 2px dashed var(--line); border-radius: 8px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: #f0f4ff; }
.split { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.1fr); gap: 16px; align-items: start; }
.sticky { position: sticky; top: 64px; }
iframe.pdf { width: 100%; height: calc(100vh - 110px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
pre.log { background: #0f1420; color: #cfd6e4; font-size: 12px; padding: 10px; border-radius: 6px; max-height: 260px; overflow: auto; white-space: pre-wrap; margin: 0; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 8px 8px; }
.thumb { position: relative; flex: 0 0 auto; border: 1px solid var(--line); background: #fff; }
.thumb img { display: block; height: 260px; }
.thumb .ov { position: absolute; border: 1px solid; pointer-events: none; }
.thumb .cap { position: absolute; bottom: 2px; left: 4px; font-size: 12px; background: rgba(255,255,255,.85); padding: 0 4px; }
.thumb.click { cursor: zoom-in; }
.thumb.click:hover { outline: 2px solid var(--accent); }
.viewer { position: fixed; inset: 0; z-index: 40; background: rgba(15,20,32,.75); display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.vbar { display: flex; gap: 12px; align-items: center; background: var(--panel); border-radius: 8px; padding: 8px 12px; }
.vbody { flex: 1; min-height: 0; display: flex; gap: 12px; justify-content: center; overflow: auto; }
.vpage { position: relative; height: 100%; flex: 0 1 auto; background: #fff; }
.vpage img { display: block; width: 100%; height: 100%; }
.vpage .ov { position: absolute; border: 1px solid; pointer-events: none; opacity: .7; }
.vsec { position: absolute; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 7%, transparent); cursor: pointer; margin: -3px; padding: 3px; box-sizing: content-box; }
.vsec span { position: absolute; top: -2px; left: -2px; transform: translateY(-100%); background: var(--c); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 3px 3px 0 0; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.vsec:hover, .vsec.hl { background: color-mix(in srgb, var(--c) 18%, transparent); border-width: 3px; z-index: 1; }
.vlist { width: 280px; flex: 0 0 auto; background: var(--panel); border-radius: 8px; padding: 10px 12px; overflow-y: auto; }
.vlist h3 { margin-top: 0; }
.vitem { border-left: 4px solid var(--c); padding: 5px 8px; margin-bottom: 6px; cursor: pointer; border-radius: 3px; }
.vitem:hover, .vitem.hl { background: #f0f4ff; }
.vitem.lvl2 { margin-left: 12px; } .vitem.lvl3 { margin-left: 24px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; margin: 6px 0; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 4px; border: 2px solid var(--c); vertical-align: -1px; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.style-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.style-card .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.style-card .sample { margin: 6px 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid var(--line); vertical-align: -2px; margin-right: 3px; }
.sec { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; background: #fff; }
.sec > .hd { display: flex; gap: 8px; align-items: center; padding: 8px 10px; cursor: pointer; }
.sec > .hd .t { font-weight: 600; flex: 1; }
.sec > .bd { padding: 0 10px 10px; display: none; }
.sec.open > .bd { display: block; }
.sec.lvl2 { margin-left: 18px; } .sec.lvl3 { margin-left: 36px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 6px; max-width: 420px; z-index: 50; }
.toast.err { background: var(--err); }
.hidden { display: none !important; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.fields td:first-child { width: 40%; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } .grid2 { grid-template-columns: 1fr; } iframe.pdf { height: 70vh; } }
/* revisione del documento */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 8px 12px; color: var(--muted); }
.tabs button.active { border-color: var(--accent); color: var(--ink); font-weight: 600; }
.tabcnt { font-size: 12px; color: var(--muted); margin-left: 2px; }
.seg .n { color: var(--muted); }
.rvbar { margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); padding: 5px 10px; }
.seg button:last-child { border-right: 0; }
.seg button.active { background: #eef3ff; color: var(--accent); font-weight: 600; }
/* il tipo di segno lo dice il badge; la scheda resta un pannello normale */
.rvcard > * + * { margin-top: 10px; }
.rvdesc { font-size: 13px; }
/* contesto del segno: un estratto del testo, non un riquadro nel riquadro */
.rvctx { background: #f6f7f9; padding: 8px 10px; margin-left: -10px; margin-right: -10px; font-size: 13px; overflow-x: auto; }
.rvctx > div + div { margin-top: 4px; }
table.ctx { border-collapse: collapse; font-size: 12px; margin: 2px 0; }
table.ctx th, table.ctx td { border: 1px solid var(--line); padding: 3px 6px; vertical-align: top; }
table.ctx th { background: #eef1f5; font-weight: 600; }
mark.cur { background: #ffd54f; padding: 0 2px; border-radius: 3px; font-weight: 600; }
.othermark { color: #4a3a00; font-size: 12px; }
#rvin { width: 100%; }
textarea#rvin { font: inherit; min-height: 44px; }
.rvsrc { padding: 12px; }
.rvsrc input { padding: 4px 8px; }
.srchit { border-top: 1px solid var(--line); padding: 8px 0; }
.srchit:first-child { border-top: 0; }
.srctext { margin-top: 4px; font-size: 12px; line-height: 1.45; max-height: 260px; overflow: auto; }
.srctext > div { max-width: 62ch; }
.srctext mark.term { background: #fff1a8; color: inherit; padding: 0 1px; border-radius: 2px; }
.srctext .num { cursor: pointer; border-radius: 2px; text-decoration: underline dotted #9aa6bd; text-underline-offset: 3px; }
.srctext .num:hover { background: var(--tint); color: var(--accent); text-decoration-color: var(--accent); }
button.mini { padding: 2px 8px; font-size: 12px; }
img.srcpage { height: 100%; max-width: 100%; object-fit: contain; background: #fff; }
/* accesso, utenti, ricerca */
body.anon .top nav, body.anon #qsearch, body.anon #status, body.anon #user { display: none; }
.panel.login { max-width: 360px; margin: 60px auto; }
.user { display: flex; gap: 6px; align-items: center; font-size: 12px; white-space: nowrap; }
#qsearch input { width: 200px; padding: 4px 8px; }
.badge.owner { background: #eef3ff; color: var(--accent); }
.viewer.modal { align-items: center; justify-content: center; }
.mbox { width: min(480px, 100%); max-height: 90vh; overflow: auto; margin: 0; }
.mbox h2 { margin-top: 0; }
button.mini.danger { color: var(--err); }
/* risultati della pagina Cerca (classe propria: non tocca i brani delle fonti in Revisione) */
.shit { display: block; color: inherit; padding: 10px 8px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 4px; }
.shit:hover { background: #f0f4ff; text-decoration: none; }
.shit .small { max-width: 62ch; margin-top: 2px; }
.shit mark { background: #ffe58a; padding: 0 1px; }
@media (max-width: 900px) { #qsearch { display: none; } }

/* pagina del documento: titolo con stato del PDF, azione principale, menu */
.dochead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.dtitle { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.dtitle h1 { margin: 0; overflow-wrap: anywhere; }
.dactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 10px; white-space: nowrap; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.ok { background: #e3f6ea; color: var(--ok); }
.state.warn { background: #fff4de; color: var(--warn); }
.state.busy { background: var(--tint); color: var(--accent); }
details.menu { position: relative; }
details.menu > summary { list-style: none; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 220px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(20, 30, 50, .14); padding: 4px; display: flex; flex-direction: column; }
.menu-pop.right { left: auto; right: 0; }
.menu-pop > a, .menu-pop > button { display: flex; justify-content: space-between; gap: 12px; text-align: left; border: 0; border-radius: 6px; padding: 9px 10px;
  background: none; color: var(--ink); width: 100%; }
.menu-pop > a:hover, .menu-pop > button:hover { background: #f0f4ff; text-decoration: none; }
.menu-pop > button.danger { color: var(--err); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* revisione: avanzamento, avviso quando Invio non conferma */
.rvprog { margin-bottom: 10px; }
.rvprog .progress { margin: 6px 0 0; }
.rvprog .progress > div { background: var(--ok); }
#rvhint.nudge { color: var(--warn); font-weight: 600; animation: nudge .25s ease-out; }
@keyframes nudge { 0% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 100% { transform: none; } }
#rvsrcnote:empty { display: none; }

/* sezioni raggruppate per capitolo */
.sec > .hd .marks { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.sec.chap { background: #fafbfd; }
.sec.chap > .hd .t { font-weight: 700; }
.chev { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 4px; color: var(--muted); flex: 0 0 auto; }
.chev:hover { background: #eef1f5; color: var(--ink); }
.sec.folded { display: none; }
input.title-input { font-size: 18px; font-weight: 600; width: 100%; max-width: 560px; border-color: transparent; background: transparent; }
input.title-input:hover, input.title-input:focus { border-color: var(--line); background: #fff; }
.svc { display: inline-flex; gap: 10px; align-items: center; color: var(--muted); }
.svc.warn { color: var(--err); font-weight: 600; }
.svc:hover { text-decoration: none; color: var(--ink); }
.toast { cursor: pointer; }
.empty b { color: var(--ink); }
.empty { line-height: 1.6; }

/* telefono e tablet stretto */
@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 6px 14px; padding: 8px 16px; position: static; }
  .top nav { order: 3; width: 100%; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .top nav a { padding: 10px 8px; white-space: nowrap; }
  .status { margin-left: auto; }
  .user { gap: 4px; }
  .user > span { display: none; }
  main { padding: 12px; }
  .panel { padding: 12px; }
  button, .btn, details.menu > summary { min-height: 44px; }
  button.mini { min-height: 36px; padding: 4px 10px; }
  button.ren { min-width: 40px; min-height: 40px; font-size: 15px; }
  input[type=text], input[type=number], input[type=search], input[type=password], select { min-height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
  .hide-m { display: none; }
  table.list { display: block; overflow-x: auto; }
  .dochead { align-items: flex-start; }
  .dactions { width: 100%; }
  .dactions #render { flex: 1; }
  .sticky { position: static; }
  .rvbar .seg { width: 100%; overflow-x: auto; }
  .seg button { flex: 1; white-space: nowrap; }
  .vbar { flex-wrap: wrap; }
}
.ico { width: 1em; height: 1em; vertical-align: -0.125em; flex: 0 0 auto; }
button.ren .ico { width: 15px; height: 15px; }
.split > * { min-width: 0; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs button { white-space: nowrap; }
@media (max-width: 900px) {
  .menu-pop { left: auto; right: 0; }
  .sec > .hd { flex-wrap: wrap; }
}
/* elenchi: nome e azioni sulla stessa riga */
.namecell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.namecell .nm { min-width: 0; }
.namecell .badge { white-space: nowrap; flex: 0 0 auto; }
.namecell .acts { display: inline-flex; gap: 2px; flex: 0 0 auto; margin-left: 2px; }
.namecell .acts button.ren { margin-left: 0; }

/* pannello di destra: PDF generato o pagina della fonte */
.panebar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.panebar .seg button { padding: 5px 10px; }
.sticky .panebar:not(.hidden) ~ iframe.pdf { height: calc(100vh - 160px); }
.srcpane { height: calc(100vh - 160px); overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.srcpane img.srcpage { display: block; width: 100%; height: auto; }
.srcpane .empty { padding: 40px 20px; }
/* brani delle fonti: pertinenza, valore, espansione */
.rel { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.rel i { display: block; width: 4px; border-radius: 1px; background: #d5dae3; }
.rel i:nth-child(1) { height: 5px; } .rel i:nth-child(2) { height: 8px; } .rel i:nth-child(3) { height: 12px; }
.rel.r1 i:nth-child(1), .rel.r2 i:nth-child(-n+2), .rel.r3 i { background: var(--accent); }
.srcnote { background: #fff4de; color: #6b4200; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 4px 0; min-height: 0; }
.linkbtn:hover { text-decoration: underline; }
.warntext { color: var(--warn); }
#rvok .ico { margin-right: 2px; }
.rvctx > div { max-width: 80ch; }
table.ctx th, table.ctx td { padding: 4px 8px; }
input:disabled, select:disabled, textarea:disabled { background: #f3f4f6; color: var(--muted); cursor: not-allowed; }
input[type=number] { max-width: 160px; }
.drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-s { display: none; }

@media (max-width: 900px) {
  #secq { min-width: 100%; }
  .nav-l { display: none; }
  .nav-s { display: inline; }
  .top nav a { padding: 10px 6px; }
  /* tabelle degli elenchi come righe a due livelli: prima il nome, poi stato e conteggi */
  table.list.cards, table.list.cards tbody, table.list.cards tr, table.list.cards td { display: block; overflow: visible; }
  table.list.cards tr:first-child { display: none; }
  table.list.cards tr { padding: 10px 4px; border-bottom: 1px solid var(--line); }
  table.list.cards td { border: 0; padding: 2px 4px; display: inline-block; vertical-align: middle; }
  table.list.cards td:first-child { display: block; }
  .panebar { display: none; }
  .srcpane { height: 70vh; }
}
button.shit { width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; font: inherit; }
.chev .ico { transition: transform .15s ease-out; }
.chev.closed .ico { transform: rotate(-90deg); }
summary.btn .ico { vertical-align: -0.15em; }
#secs .sec:not(.chap) > .hd .chev, #secs .sec:not(.chap) > .hd .edit-chap { display: none; }
.thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table.list select { min-width: 130px; }
@media (min-width: 901px) { .rvbar { flex-wrap: nowrap; } .rvbar .seg { flex: 0 1 auto; overflow-x: auto; } }
/* revisione: valore e azioni, conferma senza fonte */
.rvrow #rvin { flex: 1 1 220px; min-width: 0; }
.nosrc { background: #fff4de; border-radius: 6px; padding: 8px 10px; margin-top: 6px; }
.nosrc label { display: block; margin-bottom: 6px; color: #6b4200; }
#rvnosrc { margin-top: 2px; }
.toastbtn { margin-left: 10px; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); padding: 3px 10px; min-height: 0; }
.skiprow { margin-top: 10px; color: var(--muted); }
/* anello del focus interno per i controlli dentro contenitori che tagliano */
.seg { overflow: visible; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.tabs button:focus-visible, .seg button:focus-visible { outline-offset: -3px; }
.num:focus-visible { outline-offset: 1px; }
@media (max-width: 900px) {
  .svctext { display: none; }
  #user { min-width: 128px; justify-content: flex-end; }
  .rvbar .seg { flex-wrap: wrap; overflow: visible; }
  .rvbar .seg button { border-radius: 0; }
  .tabs button { padding: 8px 9px; }
}
/* home: avanzamento della revisione per documento */
.rprog { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.rprog .progress { margin: 0; height: 5px; }
.rprog .progress > div { background: var(--ok); }
td .sub { margin-top: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.danger-fill { background: var(--err) !important; border-color: var(--err) !important; color: #fff !important; }
/* revisione: azioni di gruppo, alternative, legenda */
.batch { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--tint); border-radius: 6px; padding: 8px 10px; margin-top: 8px; }
.rvalt { gap: 16px; }
.keys { margin-top: 4px; }
#rvok:disabled { opacity: .55; }
#rvchap { width: auto; max-width: 230px; padding: 5px 8px; }
#srcuse:disabled { opacity: .55; }
/* focus non tagliato dai contenitori che scorrono */
.top nav a:focus-visible, .thumb:focus-visible { outline-offset: -2px; }
.srctext { padding-top: 2px; }
@media (max-width: 900px) {
  table.list.fields, table.list.fields tbody, table.list.fields tr, table.list.fields td { display: block; width: 100%; }
  table.list.fields td:first-child { padding-bottom: 4px; border-bottom: 0; }
  .rvctx { margin-left: 0; margin-right: 0; }
  .svc { padding: 10px 6px; }
  #rvchap { max-width: 100%; width: 100%; }
}
.panebar #srcinfo { order: 5; flex-basis: 100%; }
.rvbar .seg button { white-space: nowrap; }

/* ---------------------------------------------------------------------------------------------------------
   Editor di testo (editor.js): tre colonne, il foglio al centro.
   La pagina esce dalla larghezza massima del resto dell'applicazione (1400 px) perché qui la larghezza è
   spazio di lavoro: le colonne laterali tolgono al foglio, e un foglio stretto è il difetto che rende
   faticoso scrivere in una finestra di browser.
--------------------------------------------------------------------------------------------------------- */
main:has(.ed3) { max-width: none; }
.edhead { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 10px; }
.edhead .dtitle { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.edhead h1 { margin: 0; }
.edhead .dactions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.edchk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.edchk input { margin: 0; }

.ed3 { display: flex; align-items: stretch; gap: 0; height: calc(100vh - 150px); min-height: 420px; }
.edside { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: flex;
  flex-direction: column; min-width: 180px; overflow: hidden; }
.edside.folded { width: 40px !important; min-width: 40px; }
.edside.folded .edside-sub, .edside.folded .edside-body, .edside.folded .edtabs, .edside.folded b { display: none; }
.edside.folded .edside-head { padding: 8px 6px; }
.edside-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.edside-head b { font-size: 13px; }
.edside-head .edfold { margin-left: auto; padding: 2px 6px; }
.edside-sub { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.edside-body { flex: 1; overflow: auto; padding: 10px; }
.edgrip { width: 10px; flex: 0 0 10px; cursor: col-resize; position: relative; }
.edgrip::after { content: ""; position: absolute; inset: 10px 4px; border-radius: 2px; background: transparent; }
.edgrip:hover::after, .edgrip:focus-visible::after { background: var(--accent); }

.edmain { flex: 1; min-width: 320px; display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.edtool { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line);
  background: #fafbfc; }
.edtgrp { display: flex; gap: 2px; align-items: center; padding-right: 6px; border-right: 1px solid var(--line); }
.edtgrp:last-child { border-right: 0; }
.edtgrp.right { margin-left: auto; border-right: 0; }
button.edb { padding: 4px 8px; min-width: 30px; border-color: transparent; background: transparent; line-height: 20px; }
button.edb:hover:not(:disabled) { background: #fff; border-color: var(--line); }
button.edb.on { background: var(--tint); border-color: #b9c9f5; color: var(--accent); }
button.edb .ico { width: 16px; height: 16px; vertical-align: -3px; }
select.edsel { width: auto; padding: 4px 6px; font-size: 13px; }
select.edsel.narrow { width: 64px; }

.edpaper { flex: 1; overflow: auto; background: #eceef2; padding: 20px 0 60px; }
.edsheet { width: min(860px, calc(100% - 40px)); margin: 0 auto; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(0,0,0,.06); padding: 48px 60px 60px; }
.edsec { scroll-margin-top: 12px; }
.edsec.skipped { opacity: .55; }
.edsechead { display: flex; align-items: baseline; gap: 10px; }
.edsechead .edtitle { margin: 18px 0 8px; flex: 1; }
.edsec:first-child .edtitle { margin-top: 0; }
.edmeta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.edbody { border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; margin: 0 -8px; }
.edbody:not(.locked):not(.live):hover { border-color: var(--line); background: #fcfdff; cursor: text; }
.edbody.live { border-color: var(--accent); background: #fff; }
.edbody.locked { color: var(--muted); }
.edbody table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.edbody th, .edbody td { border: 1px solid var(--line); padding: 5px 8px; vertical-align: top; }
.edbody th { background: #f5f6f8; }
.edbody img { max-width: 100%; height: auto; }
.edbody mark.todo { background: var(--todo); }
.edbody mark.check { background: #ffe0b2; }
.edbody .ProseMirror { outline: none; min-height: 24px; }
.edbody .ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--muted);
  float: left; height: 0; pointer-events: none; }
/* «centro dell'attenzione»: solo il blocco su cui si scrive resta leggibile */
.edsheet.focusmode .edbody.live .ProseMirror > *:not(.has-focus) { color: #c3c8d0; }
.edsheet.focusmode .edbody:not(.live), .edsheet.focusmode .edtitle { color: #c3c8d0; }
.edsheet.focusmode .edbody.live .ProseMirror > .has-focus { color: var(--ink); }

/* colonna di sinistra */
.edblock { margin-bottom: 14px; }
.edblock-h { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted);
  margin-bottom: 6px; }
.edblock-h .ico { width: 14px; height: 14px; }
.edref { border-left: 2px solid var(--line); padding: 2px 0 6px 8px; margin-bottom: 8px; }
.edref-h { font-size: 12px; color: var(--muted); }

/* colonna di destra */
.edtabs { display: flex; gap: 2px; }
.edtabs button { padding: 4px 8px; font-size: 13px; border-color: transparent; background: transparent; }
.edtabs button.active { background: var(--tint); border-color: #b9c9f5; color: var(--accent); }
.ednavchap { margin-bottom: 10px; }
.ednavchap-h { display: flex; gap: 6px; align-items: baseline; font-size: 12px; font-weight: 600;
  color: var(--muted); padding: 3px 4px; border-radius: 4px; }
.ednavchap-h:hover { background: #f0f4ff; text-decoration: none; }
.ednavchap.here .ednavchap-h { color: var(--accent); }
.ednavitem { display: flex; gap: 6px; align-items: baseline; padding: 3px 4px; border-radius: 4px; color: var(--ink);
  font-size: 13px; }
.ednavitem:hover { background: #f0f4ff; text-decoration: none; }
.ednavitem.here { background: var(--tint); color: var(--accent); }
.ednavitem.lv2 { padding-left: 14px; } .ednavitem.lv3 { padding-left: 26px; } .ednavitem.lv4 { padding-left: 38px; }
.ednavp { margin-left: auto; font-size: 11px; color: var(--muted); }
.ednavpage { display: flex; gap: 8px; align-items: baseline; padding: 4px; border-radius: 4px; color: var(--ink); }
.ednavpage:hover { background: #f0f4ff; text-decoration: none; }
.ednavpage.here { background: var(--tint); }
.ednavpn { min-width: 28px; text-align: right; font-size: 12px; color: var(--muted); }
.ednavpt { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.errtext { color: var(--err); }

@media (max-width: 1100px) {
  .ed3 { flex-direction: column; height: auto; }
  .edside { width: auto !important; max-height: 280px; }
  .edgrip { display: none; }
  .edpaper { max-height: 70vh; }
}
/* segni della revisione nell'editor: decorazione, non testo (vedi edMarksExtension in editor.js) */
.edbody .edmark.todo { background: var(--todo); border-radius: 2px; }
.edbody .edmark.check { background: #ffe0b2; border-radius: 2px; }
