﻿/* MyXml â€” foglio di stile unico, nessuna dipendenza esterna. */

:root {
  --bg: #f7f8f7;
  --bg-panel: #ffffff;
  --bg-sunken: #eef0ee;
  --border: #dce0dc;
  --text: #1c2320;
  --muted: #6b7770;
  --accent: #2f7d5d;
  --accent-soft: #e4f1ea;
  --tag: #1f6f8b;
  --editor-soft: #dceef4;
  --attr: #9a6a00;
  --value: #37474f;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 12px rgba(0, 0, 0, .04);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"], :root[data-theme="auto"] {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] { color-scheme: dark; }
  :root[data-theme="auto"] {
    --bg: #14181a;
    --bg-panel: #1a1f22;
    --bg-sunken: #101416;
    --border: #2c3438;
    --text: #dfe5e2;
    --muted: #8b9a94;
    --accent: #4cae86;
    --accent-soft: #1c3128;
    --tag: #63b8d4;
    --editor-soft: #16323c;
    --attr: #d9a441;
    --value: #b8c6cc;
    --danger: #f2857c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14181a;
  --bg-panel: #1a1f22;
  --bg-sunken: #101416;
  --border: #2c3438;
  --text: #dfe5e2;
  --muted: #8b9a94;
  --accent: #4cae86;
  --accent-soft: #1c3128;
  --tag: #63b8d4;
  --editor-soft: #16323c;
  --attr: #d9a441;
  --value: #b8c6cc;
  --danger: #f2857c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  height: 52px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 560;
  font-size: 16.5px;
  letter-spacing: -.015em;
  flex-shrink: 0;
}
.brand b { font-weight: 700; }
.brand .mark { width: 21px; height: 21px; }

.stats { display: flex; gap: 18px; color: var(--muted); font-size: 12.5px; }
.stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

/* -------------------------------------------------------------- layout */

/* `#app` avvolge tutto per poterlo nascondere prima dell'accesso, e deve
   propagare l'altezza: senza, la catena flex fra body e .layout si spezza e la
   barra laterale collassa sul proprio contenuto. */
#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#app.hidden { display: none; }

.layout { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 290px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px;
  font-size: 11px;
  font-weight: 660;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.tree { max-height: 38%; overflow: auto; padding: 4px 0; }
.doclist { flex: 1; overflow: auto; padding: 4px 0; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab {
  padding: 11px 15px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tabpanel { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tabpanel.active { display: flex; }

/* --------------------------------------------------------- alberi */

.tree-row, .doc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-row:hover, .doc-row:hover { background: var(--bg-sunken); }
.tree-row.sel, .doc-row.sel { background: var(--accent-soft); color: var(--accent); font-weight: 560; }

.chev {
  width: 14px; flex-shrink: 0;
  color: var(--muted);
  font-size: 10px;
  transition: transform .12s;
  text-align: center;
}
.chev.open { transform: rotate(90deg); }
.chev.leaf { visibility: hidden; }

.doc-row { flex-direction: column; align-items: stretch; gap: 1px; }
.doc-row .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.doc-row .meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------- albero dei nodi */

.crumbs {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--bg-panel);
  flex-shrink: 0;
}
.crumbs a { color: var(--accent); text-decoration: none; cursor: pointer; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); }

.nodetree-wrap { flex: 1; overflow: auto; }
.nodetree { padding: 10px 0 40px; font-family: var(--mono); font-size: 13px; line-height: 1.55; }

.nrow {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  padding: 1px 16px 1px 0;
  cursor: default;
  white-space: pre-wrap;
  word-break: break-word;
}
.nrow:hover { background: var(--bg-sunken); }
.nrow .chev { cursor: pointer; margin-top: 3px; }
.ntag { color: var(--tag); }
.nattr { color: var(--attr); }
.nattr .k { opacity: .85; }
.ntext { color: var(--value); }
.ncomment { color: var(--muted); font-style: italic; }
.nsize { color: var(--muted); font-size: 11px; margin-left: 6px; }
.nmore {
  margin: 4px 0 4px 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}
.nmore:hover { text-decoration: underline; }

.empty { padding: 40px 24px; color: var(--text); font-family: var(--sans); }
.empty p { margin: 0 0 8px; }

/* --------------------------------------------------- editing in linea */

.nbody { flex: 1; min-width: 0; }

.editable, .nattr .av {
  cursor: text;
  border-bottom: 1px dotted transparent;
}
.nrow:hover .editable, .nrow:hover .nattr .av { border-bottom-color: var(--muted); }
.editable:hover, .nattr .av:hover { background: var(--accent-soft); border-radius: 3px; }

.inline-input {
  font-family: var(--mono);
  font-size: 13px;
  padding: 0 4px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--bg-panel);
  color: var(--text);
  min-width: 120px;
}

.nacts {
  display: none;
  gap: 2px;
  margin-left: 10px;
  flex-shrink: 0;
  align-self: flex-start;
}
.nrow:hover .nacts { display: inline-flex; }

.nact {
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1;
  width: 20px; height: 20px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-panel);
  color: var(--muted);
  cursor: pointer;
}
.nact:hover { color: var(--accent); border-color: var(--accent); }
.nact.danger:hover { color: var(--danger); border-color: var(--danger); }

.nrow.flash { background: var(--accent-soft); transition: background 1s; }

.crumb-act {
  margin-left: 12px;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  text-decoration: none;
}
.crumb-act:hover { text-decoration: underline; }
.crumb-act.danger { color: var(--danger); }

/* ------------------------------------------------------------- query */

.queryhead {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.field.small { flex: 0 0 90px; }
.field.small2 { flex: 0 0 120px; }

select {
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-sunken);
  padding: 1px 5px;
  border-radius: 4px;
}
.field > span { font-size: 11px; font-weight: 620; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* Tutti i tipi testuali insieme: elencare solo `text` e `number` lasciava i
   campi password con gli stili predefiniti del browser — piu' bassi, con un
   altro bordo e un altro font — sia nel modulo di accesso sia nel dialogo di
   creazione utente. Un elenco di tipi va tenuto completo, o non serve.
   (`.code-area` e non `.editor`: quest'ultimo collideva con `.role-pill.editor`,
   che ne ereditava `min-height: 88px`.) */
input[type=text],
input[type=password],
input[type=number],
input[type=search],
input[type=email],
input[type=url],
.code-area {
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
input:focus, .code-area:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.code-area {
  margin: 12px 16px 0;
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
  flex-shrink: 0;
}

.examples { padding: 8px 16px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--muted);
  cursor: pointer;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }

.qmeta { padding: 10px 16px 0; font-size: 12.5px; color: var(--muted); }
.qmeta .badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 620;
  background: var(--accent-soft);
  color: var(--accent);
  margin-right: 8px;
}
.qmeta .badge.warn { background: #fdf1dc; color: #8a5d00; }
.qmeta .err { color: var(--danger); }

.results { flex: 1; overflow: auto; padding: 10px 16px 40px; }

/* --------------------------------------------------------- query salvate */

.saved-wrap { flex: 1; display: flex; min-height: 0; }

.saved-list {
  width: 232px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sqlist { flex: 1; overflow: auto; padding: 4px 0; }

.sq-row {
  padding: 7px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 2px solid transparent;
}
.sq-row:hover { background: var(--bg-sunken); }
.sq-row.sel { background: var(--accent-soft); border-left-color: var(--accent); }
.sq-row .name { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.sq-row.sel .name { color: var(--accent); font-weight: 560; }
.sq-row .meta { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.sq-flag {
  font-size: 9.5px;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 3px;
  background: #fdf1dc;
  color: #8a5d00;
  font-weight: 640;
}

/* L'editor scorre tutto insieme, risultati compresi: si scende dal corpo della
   query ai suoi risultati come si farebbe leggendo, senza due aree separate che
   scorrono per conto loro. */
.saved-main {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 14px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.saved-main > .field { flex: 0 0 auto; }
.saved-main .code-area.inline { margin: 0; }
.saved-main .qmeta { padding: 0; }
.saved-main .results { flex: 0 0 auto; overflow: visible; padding: 0; }
.saved-main .empty { padding: 32px 4px; }

.sq-head { display: flex; gap: 12px; align-items: flex-start; }
.sq-head .field { flex: 1; }

.sq-subhead {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.sq-subhead .btn { text-transform: none; letter-spacing: 0; margin-left: auto; }
.sq-subhead .btn + .btn { margin-left: 0; }
.sq-subhead .muted { text-transform: none; letter-spacing: 0; margin-left: auto; font-weight: 400; }

/* Griglia dei parametri: nome, tipo, obbligatorio, predefinito, valore di prova.
   `minmax(0, …)` sulle colonne di testo, altrimenti un valore lungo allarga la
   tabella oltre il pannello invece di restare dentro il suo campo. */
.ptable { display: flex; flex-direction: column; gap: 6px; }
.prow {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 104px 34px minmax(0, 1fr) minmax(0, 1.2fr) 28px;
  gap: 8px;
  align-items: center;
}
.prow input[type=checkbox] { justify-self: center; }
.prow .nact { display: inline-flex; }
.prow .pval { border-color: var(--accent); }
.phead {
  font-size: 10.5px;
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.phead span:nth-child(3) { text-align: center; }

.sq-acts { display: flex; gap: 8px; flex-wrap: wrap; }

.sq-call {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-sunken);
  overflow-x: auto;
}
.sq-call code { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.sq-verb {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.sq-verb.post { background: #fdf1dc; color: #8a5d00; }

.sq-warn {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid var(--attr);
  padding: 2px 0 2px 10px;
}

.result {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--bg-panel);
}
.result .rhead {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 11px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
}
.result .rhead .go { margin-left: auto; color: var(--accent); cursor: pointer; }
.result .rhead .go:hover { text-decoration: underline; }
.result pre {
  margin: 0;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

/* -------------------------------------------------------------- widget */

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 6px 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.icon { padding: 6px 9px; }
.btn.tiny { padding: 1px 7px; font-size: 14px; line-height: 1.2; }
.btn kbd { font-family: var(--mono); font-size: 10px; opacity: .8; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

.muted { color: var(--muted); font-weight: 400; }

/* ------------------------------------------------------------- dialoghi */

.x-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: var(--shadow);
  width: min(520px, 92vw);
}
.x-dialog.wide { width: min(720px, 94vw); }
.x-dialog::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(2px); }
.x-dialog form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.x-dialog h3 { margin: 0; font-size: 16px; font-weight: 620; }
.x-dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 4px 0 0; padding: 0; }
.x-dialog-body { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.x-dialog-body code { font-family: var(--mono); font-size: 12.5px; }
.x-dialog-error {
  color: var(--danger);
  font-size: 12.5px;
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border-left: 2px solid var(--danger);
  padding: 7px 10px;
  border-radius: 0 4px 4px 0;
}
.field .hint { font-style: normal; font-size: 11.5px; color: var(--muted); }
.x-dialog textarea {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.x-dialog textarea:focus,
.x-dialog select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--bg);
}
.checklist .check { font-family: var(--mono); font-size: 12.5px; padding: 2px 0; cursor: pointer; }
.checklist .check:hover { color: var(--accent); }

/* ------------------------------------------------------------ notifiche */

.x-toasts {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.x-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 13px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  max-width: min(560px, 90vw);
}
.x-toast.in { opacity: 1; transform: none; }
.x-toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.x-toast.error { border-color: var(--danger); }
.x-toast.error .x-toast-dot { background: var(--danger); }
@media (prefers-reduced-motion: reduce) {
  .x-toast { transition: none; opacity: 1; transform: none; }
}

/* ------------------------------------------------- schermi stretti (app) */

@media (max-width: 52rem) {
  /* La barra laterale passa sopra, bassa e scorrevole: 290px fissi su un
     telefono lasciano al documento una colonna illeggibile. */
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 42vh;
    overflow-y: auto;
  }
  .tree { max-height: none; }
  .doclist { flex: none; }

  .topbar { height: auto; padding: 8px 12px; flex-wrap: wrap; gap: 8px 12px; }
  /* Le statistiche sono la prima cosa che si sacrifica: informano, non servono. */
  .stats { display: none; }
  .topbar-actions { margin-left: auto; }

  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 10px 12px; }

  /* I controlli di query in colonna, e il pulsante a tutta larghezza. */
  .queryhead { flex-direction: column; align-items: stretch; gap: 10px; }
  .field.small, .field.small2 { flex: 1; }
  .queryhead .btn { width: 100%; justify-content: center; }
  .code-area { margin: 10px 12px 0; }
  .examples, .qmeta, .findopts { padding-left: 12px; padding-right: 12px; }
  .results { padding: 10px 12px 32px; }
  .qbar { flex-direction: column; gap: 8px; padding: 0 12px; align-items: stretch; }
  .qbar .qmeta { padding-left: 0; padding-right: 0; }

  .nodetree { font-size: 12.5px; }
  /* Le azioni per riga restano visibili: su touch non esiste il passaggio
     del mouse che le farebbe comparire. */
  .nacts { display: inline-flex; }
  .nact { width: 24px; height: 24px; font-size: 13px; }
  .crumbs { padding: 8px 12px; }
}

@media (max-width: 30rem) {
  .brand span { display: none; }
  .btn { padding: 6px 10px; }
  .whoami .role-pill { display: none; }
}

/* Su dispositivi senza mouse le azioni e i campi modificabili sono sempre
   visibili: `:hover` non è un'interazione disponibile. */
@media (hover: none) {
  .nacts { display: inline-flex; }
  .editable, .nattr .av { border-bottom-color: var(--border); }
}

/* --------------------------------------------------------------- accesso */

body.booting #app, body.booting #gate { visibility: hidden; }

/* La vetrina resta scura in entrambi i temi: è la superficie del marchio, e
   deve leggersi uguale a chiunque apra il link. Il pannello di accesso invece
   segue il tema, perché è la parte che si usa ogni giorno. */
.gate {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--bg);
  display: grid;
  grid-template-columns: 1fr;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.gate.hidden { display: none; }

@media (min-width: 62rem) {
  .gate {
    /* La vetrina prende più spazio del modulo, ma il modulo non si comprime. */
    grid-template-columns: minmax(0, 1fr) minmax(26rem, 34rem);
    overflow: hidden;
  }
  /* Il modulo è primo nel DOM (conta per mobile e per la tastiera) ma va a
     destra sullo schermo largo. */
  .gate-access {
    grid-column: 2;
    grid-row: 1;
    /* Nel tema scuro i due pannelli hanno luminosità vicina e il confine
       sparirebbe: la riga lo tiene leggibile in entrambi i temi. */
    border-left: 1px solid var(--border);
  }
  .gate-show { grid-column: 1; grid-row: 1; overflow-y: auto; }
}

/* ---- pannello di accesso ---- */

.gate-access {
  display: grid;
  align-content: safe center;
  justify-items: center;
  padding: clamp(1.75rem, 5vw, 3rem) clamp(1.25rem, 5vw, 3rem);
  background: var(--bg);
  min-width: 0;
}
.gate-card {
  width: min(24rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Le credenziali non sono codice: nel modulo di accesso gli input tornano al
   carattere di testo, piu' alti e piu' grandi di quelli dell'app. I 16px sotto
   i 40rem non sono un vezzo — con un carattere piu' piccolo iOS ingrandisce la
   pagina appena il campo prende il fuoco, e l'impaginazione salta. */
.gate-card input[type=text],
.gate-card input[type=password] {
  font-family: var(--sans);
  font-size: 14.5px;
  padding: 10px 12px;
  width: 100%;
}
@media (max-width: 40rem) {
  .gate-card input[type=text],
  .gate-card input[type=password] { font-size: 16px; }
}

.gate-heads { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 2px; }
.gate-heads h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 660;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.gate-lead { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.gate-foot {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}
.gate-foot code {
  display: inline-block;   /* non si spezza a meta' comando su una riga nuova */
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-sunken);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}
.btn.wide { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }

/* ---- marchio ---- */

.gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.gate-brand b { font-weight: 700; }
.gate-brand.small { font-size: 19px; }
.mark {
  width: 26px; height: 26px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
}
.mark circle { fill: var(--accent); stroke: none; }
.gate-brand.small .mark { width: 23px; height: 23px; }

/* ---- vetrina ---- */

.gate-show {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  /* Verde-nerissimo: la stessa famiglia cromatica dell'accento, non un grigio
     neutro preso a prestito. */
  background:
    radial-gradient(120% 80% at 8% 0%, #17342a 0%, transparent 55%),
    linear-gradient(160deg, #0e1614 0%, #101a17 55%, #0c1211 100%);
  color: #dfe9e4;
  padding: clamp(2rem, 5vw, 4rem) clamp(1.5rem, 5vw, 4rem);
  display: grid;
  /* `safe` e non semplicemente `center`: quando il contenuto supera il
     contenitore, il centraggio spinge la testa oltre il bordo superiore — e
     quella parte non si raggiunge scorrendo, perche' lo scorrimento parte da
     zero. Con `safe` il centraggio decade a `start` proprio in quel caso. */
  align-content: safe center;
  justify-items: start;
}
.gate-show .mark { stroke: #55c096; }
.gate-show .mark circle { fill: #55c096; }
.gate-show .gate-brand { color: #f0f5f2; }

/* Il documento in filigrana: è il soggetto stesso usato come texture, non un
   ornamento astratto. Sta nella metà destra del pannello — quella che il testo
   lascia vuota — e sfuma verso sinistra, così i due non si sovrappongono mai.
   Sotto i 62rem il pannello non è più affiancato e la filigrana sparisce. */
.gate-watermark {
  display: none;
  position: absolute;
  top: 0; bottom: 0;
  left: 38rem;
  right: -6rem;
  margin: 0;
  padding: 3rem 0 0 0;
  z-index: -1;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.85;
  color: #8fe3c0;
  opacity: .13;
  white-space: pre;
  pointer-events: none;
  user-select: none;
  mask-image: linear-gradient(100deg, transparent 0%, #000 22%, #000 60%, transparent 96%);
  -webkit-mask-image: linear-gradient(100deg, transparent 0%, #000 22%, #000 60%, transparent 96%);
}
@media (min-width: 78rem) {
  .gate-watermark { display: block; }
}

.gate-show-inner {
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.gate-pitch {
  margin: .6rem 0 0;
  font-size: clamp(1.85rem, 4.2vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -.025em;
  font-weight: 620;
  color: #ffffff;
  text-wrap: balance;
}
.gate-sub {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.62;
  color: #a9bdb5;
  max-width: 30rem;
}

.gate-points {
  list-style: none;
  margin: .4rem 0 0;
  padding: 0;
  display: grid;
  gap: .95rem;
}
@media (min-width: 34rem) {
  .gate-points { grid-template-columns: 1fr 1fr; gap: 1.15rem 1.6rem; }
}
.gate-points li {
  position: relative;
  padding-left: .95rem;
  font-size: 12.8px;
  line-height: 1.55;
  color: #9db1a9;
}
.gate-points li::before {
  content: "";
  position: absolute;
  left: 0; top: .48em;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #55c096;
}
.gate-points b {
  display: block;
  color: #edf3f0;
  font-weight: 600;
  font-size: 13.4px;
  margin-bottom: .18rem;
}
.gate-points code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: rgba(85, 192, 150, .13);
  color: #7fd8b4;
  padding: 1px 4px;
  border-radius: 3px;
}

.gate-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem 2.2rem;
  margin: .85rem 0 0;
  padding-top: 1.15rem;
  border-top: 1px solid rgba(255, 255, 255, .09);
}
.gate-figures dt {
  font-size: 1.32rem;
  font-weight: 620;
  letter-spacing: -.02em;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}
.gate-figures dd {
  margin: .1rem 0 0;
  font-size: 11.5px;
  color: #8fa39b;
  line-height: 1.4;
}

/* Su schermo stretto il pannello scuro è una sezione da leggere, non una
   vetrina da contemplare: meno aria, e i numeri su una riga sola. */
@media (max-width: 40rem) {
  .gate-show { padding-top: 2.25rem; padding-bottom: 2.75rem; }
  .gate-pitch { font-size: 1.7rem; }
  .gate-figures { gap: .9rem 1.6rem; }
  .gate-figures dt { font-size: 1.18rem; }
}

/* ------------------------------------------------------- utente e ruoli */

.whoami { display: flex; align-items: center; }
.btn.ghost { border-color: transparent; background: none; display: flex; align-items: center; gap: 7px; }
.btn.ghost:hover { border-color: var(--border); }

.role-pill {
  display: inline-block;
  flex: 0 0 auto;            /* dentro un flex non deve restringersi */
  white-space: nowrap;       /* ne' andare a capo lettera per lettera */
  font-size: 10.5px;
  font-weight: 620;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-sunken);
  color: var(--muted);
}
.role-pill.admin { background: var(--accent-soft); color: var(--accent); }
.role-pill.editor { background: var(--editor-soft); color: var(--tag); }
.role-pill.viewer { background: var(--bg-sunken); color: var(--muted); }

.userlist { display: flex; flex-direction: column; gap: 1px; background: var(--border);
            border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
            max-height: 50vh; overflow-y: auto; }
.userrow { background: var(--bg-panel); padding: 11px 14px; display: flex;
           flex-direction: column; gap: 5px; }
.userhead { display: flex; align-items: center; gap: 9px; }
.small { font-size: 12px; }
.useracts { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.btn.tiny-wide { padding: 3px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.tree-row.dim { opacity: .55; font-style: italic; }

/* Chi non puo' scrivere non deve leggere istruzioni su come scrivere. */
body[data-role="viewer"] .only-writers { display: none; }

/* ----------------------------------------------------- ricerca e export */

.findopts { padding: 10px 16px 0; }
.check.inline { font-size: 12.5px; }
.check.inline em { font-style: normal; }

.qbar { display: flex; align-items: baseline; gap: 16px; padding-right: 16px; }
.qbar .qmeta { flex: 1; }
.qexport { display: flex; align-items: center; gap: 6px; font-size: 12px; }

.result.compact pre { padding: 7px 12px; font-size: 12px; }
.findline { padding: 8px 12px; font-family: var(--mono); font-size: 12.5px; }

.match-pill {
  display: inline-block;
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 660;
  line-height: 1.6;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1px 8px;
  border-radius: 20px;
}
.match-pill.key { background: var(--editor-soft); color: var(--tag); }
.match-pill.val { background: var(--accent-soft); color: var(--accent); }

.warn-note { color: var(--attr); }
.qmeta .err { color: var(--danger); }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  transition: .15s;
}
.dropzone.hot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone p { margin: 0; }

.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; }
.check em { display: block; color: var(--muted); font-size: 11.5px; font-style: normal; }

.progress { height: 5px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.error { color: var(--danger); font-size: 12.5px; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
}
.toast.err { background: var(--danger); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
