
/* Glossa — la barra di aggiunta in alto, le viste a sinistra, la lista come registro denso a destra. */
:root {
  --bg: #EEF1EF;
  --surface: #FFFFFF;
  --ink: #15201C;
  --muted: #5B6A64;
  --line: #D6DDDA;
  --accent: #0D6B59;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEDE7;
  --star: #B87A06;
  --warn: #9A4A12;
  --warn-soft: #F7E8DC;
  --read: #3E5A9C;
  --read-soft: #E2E8F5;
  /* sottolineature: tinta sul testo e filetto delle citazioni */
  --hl-yellow: rgba(250, 204, 21, 0.38); --hl-yellow-edge: #C99A06;
  --hl-blue: rgba(96, 165, 250, 0.34);   --hl-blue-edge: #3E74C7;
  --hl-red: rgba(248, 113, 113, 0.34);   --hl-red-edge: #C2453D;
  --hl-green: rgba(74, 222, 128, 0.32);  --hl-green-edge: #2F9A5B;
  --paper: #FFFFFF; --reader-bg: #DDE3E0;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513; --surface: #17201D; --ink: #E3EAE7; --muted: #95A39D; --line: #2A3532;
    --accent: #4CC0A3; --accent-ink: #082019; --accent-soft: #173229; --star: #E5B040;
    --warn: #E7A06A; --warn-soft: #3A2618; --read: #9DB3E8; --read-soft: #1D2640; --hl-yellow-edge: #E5B040; --hl-blue-edge: #7FA8EA; --hl-red-edge: #E88B84; --hl-green-edge: #6CCB93; --reader-bg: #0B100E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1513; --surface: #17201D; --ink: #E3EAE7; --muted: #95A39D; --line: #2A3532;
  --accent: #4CC0A3; --accent-ink: #082019; --accent-soft: #173229; --star: #E5B040;
  --warn: #E7A06A; --warn-soft: #3A2618; --read: #9DB3E8; --read-soft: #1D2640; --hl-yellow-edge: #E5B040; --hl-blue-edge: #7FA8EA; --hl-red-edge: #E88B84; --hl-green-edge: #6CCB93; --reader-bg: #0B100E;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  background: var(--bg); color: var(--ink);
  margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 96px;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.86em; }
kbd {
  font-family: var(--font-mono); font-size: 12px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface); color: var(--ink);
}
.app { max-width: 1120px; margin: 0 auto; display: grid; gap: 24px; }

/* Header and add bar */
.top { display: grid; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand h1 { font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.01em; margin: 0; }
.proto { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.adder {
  display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.adder:focus-within, .adder.flash { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.adder input {
  flex: 1 1 260px; min-width: 0; border: 0; background: transparent; padding: 10px 10px;
  font-size: 17px; outline: none;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; padding: 9px 14px; font-weight: 500; font-size: 14px;
  border: 1px solid var(--line); background: var(--surface);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--warn); }
.hints { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; align-items: center; }
.try { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.try button {
  font-family: var(--font-mono); font-size: 12px; border: 1px dashed var(--line); background: transparent;
  border-radius: 6px; padding: 2px 8px; color: var(--ink);
}
.try button:hover { border-color: var(--accent); color: var(--accent); }

/* Body */
.body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.side {
  display: grid; gap: 18px; align-content: start; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px);
  /* più lunga dello schermo: scorre da sola, così le ultime voci restano raggiungibili */
  max-height: calc(100vh - 32px - env(safe-area-inset-top, 0px)); overflow-y: auto; overscroll-behavior: contain;
  padding-right: 6px; margin-right: -6px; scrollbar-width: thin;
}
.side h2 { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.navlist { display: grid; gap: 2px; }
.navbtn {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left;
  border: 0; background: transparent; border-radius: 7px; padding: 6px 10px; font-size: 14.5px;
}
.navbtn:hover { background: var(--surface); }
.navbtn.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.navbtn .n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; font-weight: 400; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--bg); }
.taglist { display: flex; flex-wrap: wrap; gap: 6px; }
.tagbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.tagbtn.on { border-color: var(--accent); background: var(--accent-soft); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; font-size: 13px; color: var(--muted); align-items: center; margin: 0; }
.keys dt { justify-self: start; }
.keys dd { margin: 0; }

main { min-width: 0; display: grid; gap: 12px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; margin: 0; text-wrap: balance; }
.toolbar input[type="search"] {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 12px; min-width: 0; width: min(280px, 100%);
}
.note {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px;
}
.note button { border: 0; background: transparent; color: var(--accent); font-weight: 500; padding: 0; }

/* List */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item { border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item.is-sel { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.item.is-new { animation: arrive .6s ease-out; }
@keyframes arrive { from { background: var(--accent-soft); } }
.row { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 14px; }
.pill {
  border: 0; border-radius: 999px; padding: 3px 0; font-size: 12px; font-weight: 600; width: 100%;
  margin-top: 2px; letter-spacing: 0.01em;
}
.pill-to_read { background: var(--accent-soft); color: var(--accent); }
.pill-reading { background: var(--warn-soft); color: var(--warn); }
.pill-read { background: var(--read-soft); color: var(--read); }
.txt { min-width: 0; cursor: pointer; }
.ttl { font-weight: 600; font-size: 15.5px; line-height: 1.35; overflow-wrap: anywhere; }
.is-pending .ttl { color: var(--muted); font-weight: 500; }
.sub { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 2px 10px; overflow-wrap: anywhere; }
.kind { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.aside { display: flex; align-items: center; gap: 8px; }
.mini { color: var(--star); font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.fav { border: 0; background: transparent; font-size: 19px; line-height: 1; color: var(--line); padding: 2px 4px; }
.fav:hover { color: var(--muted); }
.fav.on { color: var(--star); }
.spin {
  display: inline-block; width: 11px; height: 11px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; margin-right: 6px; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.panel { padding: 2px 14px 16px calc(14px + 104px + 12px); display: grid; gap: 12px; }
.warn { font-size: 13px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; }
.fld { display: grid; gap: 4px; }
.fld > span, .lbl { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.fld input, .fld textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; resize: vertical;
}
.prow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stars { display: inline-flex; gap: 2px; }
.stars button { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--line); padding: 0 2px; }
.stars button.on { color: var(--star); }
.stars:hover button { color: var(--star); }
.stars button:hover ~ button { color: var(--line); }
.hint { font-size: 12.5px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; background: var(--surface); }
.tags input { border: 0 !important; padding: 3px 4px !important; flex: 1 1 120px; outline: none; background: transparent; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); border-radius: 999px; padding: 1px 4px 1px 10px; font-size: 13px; }
.chip button { border: 0; background: transparent; color: var(--muted); padding: 0 4px; font-size: 14px; line-height: 1; }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.sugg button { border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 1px 9px; font-size: 12.5px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; }
.links a { color: var(--accent); text-decoration: none; font-weight: 500; }
.links a:hover { text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { padding: 6px 12px; font-size: 13.5px; }
.prov { font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; margin: 0; }

/* Drop overlay and toast */
.drop {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
}
.drop div {
  border: 2.5px dashed var(--accent); border-radius: 18px; padding: 48px 40px; text-align: center; background: var(--surface);
  font-family: var(--font-display); font-size: 24px; font-weight: 600; max-width: 100%;
}
.drop small { display: block; font-family: var(--font-body); font-size: 14px; font-weight: 400; color: var(--muted); margin-top: 6px; }
.toast {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: min(560px, calc(100vw - 32px));
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}
.toast .msg { flex: 1 1 200px; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.toast button { border: 0; background: transparent; color: var(--bg); font-weight: 600; font-size: 13.5px; padding: 6px 8px; border-radius: 6px; text-decoration: underline; text-underline-offset: 3px; }
.toast button:hover { background: rgb(127 127 127 / 0.25); }

@media (max-width: 860px) {
  .body { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .pill { grid-column: 1 / -1; width: auto; justify-self: start; padding: 2px 10px; margin: 0; }
  .panel { padding-left: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Accesso, configurazione, conferma rapida */
.center-card {
  max-width: 420px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 24px; display: grid; gap: 12px;
}
.center-card h1 { font-family: var(--font-display); font-weight: 700; font-size: 26px; margin: 0; }
.center-card p { margin: 0; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 6px; }
.stack label { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-top: 6px; }
.stack input { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 9px 12px; min-width: 0; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack .inline { margin-top: 12px; }
.formmsg { margin: 0; min-height: 1.2em; font-size: 13.5px; color: var(--muted); }
.formmsg.err { color: var(--warn); }
a.btn { text-decoration: none; color: var(--ink); }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

.who { font-size: 13px; color: var(--muted); margin-left: auto; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; font-size: 13.5px; text-align: left; }
.linkbtn:hover { text-decoration: underline; }
.tools { display: grid; gap: 8px; justify-items: start; }
.bookmarklet {
  display: inline-block; text-decoration: none; font-size: 13px; font-weight: 600; color: var(--accent);
  border: 1px dashed var(--accent); border-radius: 999px; padding: 3px 12px; cursor: grab;
}
.hint { font-size: 12.5px; color: var(--muted); }
.thumb { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex: none; }
.abstract { font-size: 13.5px; color: var(--muted); max-width: 72ch; margin: 0; }
.abstract summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.sync { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- catalogazione */
.active-proj { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.active-proj select {
  font: inherit; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1px solid transparent;
  border-radius: 999px; padding: 3px 10px; max-width: 220px;
}
.navbtn .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.newproj input { width: 100%; border: 1px dashed var(--line); background: transparent; border-radius: 7px; padding: 5px 10px; font-size: 13.5px; margin-top: 4px; }
.newproj input:focus { border-style: solid; background: var(--surface); }
.tree { display: grid; gap: 1px; }
.tbtn { display: flex; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: transparent; border-radius: 6px; padding: 4px 8px; font-size: 13.5px; line-height: 1.3; }
.tbtn:hover { background: var(--surface); }
.tbtn.on { background: var(--accent-soft); font-weight: 600; }
.tbtn .n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 400; }
.tbtn.l0 { font-weight: 600; }
.tbtn.l1 { padding-left: 18px; }
.tbtn.l2 { padding-left: 30px; font-size: 13px; color: var(--muted); }
.tbtn.l2.on { color: var(--ink); }
.saved { display: flex; align-items: center; }
.saved .navbtn { flex: 1; min-width: 0; }
.saved .x { border: 0; background: transparent; color: var(--muted); padding: 2px 6px; font-size: 15px; opacity: 0; }
.saved:hover .x, .saved .x:focus-visible { opacity: 1; }

.filterbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.fchip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; }
.fchip button { border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 0 5px; }
.saveform { display: inline-flex; gap: 6px; align-items: center; }
.saveform input { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 4px 8px; min-width: 0; width: 200px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.projectbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.pstats { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; min-width: 0; }
.pstats strong { font-family: var(--font-display); font-size: 17px; }
.pstats span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pacts { display: flex; flex-wrap: wrap; gap: 6px; }

.tchip, .pchip { font-size: 12px; border-radius: 5px; padding: 0 6px; line-height: 1.6; }
.tchip { background: var(--read-soft); color: var(--read); }
.pchip { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.hcount { color: var(--star); font-weight: 600; }
.chip.pchip-on { background: var(--accent); color: var(--accent-ink); }
.chip.pchip-on button { color: var(--accent-ink); opacity: .8; }
.topicline { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 13.5px; }
.fld select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
.hline { font-size: 13.5px; color: var(--muted); }

/* ---------------------------------------------------------------- citazioni e diario */
.notes { display: grid; gap: 14px; }
.notesbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; }
.nacts { display: flex; gap: 6px; flex-wrap: wrap; }
.qgroup { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.qhead { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.qtitle { flex: 1 1 260px; min-width: 0; display: grid; gap: 2px; }
.qitem { font-weight: 600; font-size: 15px; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
.qtitle .sub { margin: 0; }
.qcount { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.quote { border-left: 3px solid var(--hl-yellow-edge); padding: 2px 0 2px 12px; display: grid; gap: 4px; }
.quote.c-blue { border-color: var(--hl-blue-edge); } .quote.c-red { border-color: var(--hl-red-edge); } .quote.c-green { border-color: var(--hl-green-edge); }
.quote blockquote { margin: 0; font-size: 15px; line-height: 1.55; max-width: 72ch; overflow-wrap: anywhere; }
.qmeta { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; font-size: 12.5px; color: var(--muted); }
.qtag { font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.c-yellow > .qmeta .qtag { color: var(--hl-yellow-edge); } .c-blue > .qmeta .qtag { color: var(--hl-blue-edge); }
.c-red > .qmeta .qtag { color: var(--hl-red-edge); } .c-green > .qmeta .qtag { color: var(--hl-green-edge); }
.qact { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; margin-left: auto; }
.qact .linkbtn { font-size: 12.5px; }
.linkbtn.danger { color: var(--warn); }
.qnote { border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 6px; margin-left: -6px; font-size: 13.5px; color: var(--muted); resize: vertical; max-width: 72ch; width: 100%; }
.qnote:hover, .qnote:focus { border-color: var(--line); background: var(--bg); color: var(--ink); }
.day { display: grid; gap: 10px; }
.day h3 { margin: 6px 0 0; font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.daysum { margin: -6px 0 0; color: var(--muted); font-size: 13px; }
.readlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.readlist .pill { width: auto; padding: 1px 8px; margin: 0 6px 0 0; }
.readlist .linkbtn { color: var(--ink); font-size: 14px; }

/* ---------------------------------------------------------------- reader PDF */
body.reading { overflow: hidden; }
.reader {
  position: fixed; inset: 0; z-index: 30; background: var(--reader-bg); display: grid; grid-template-rows: auto minmax(0, 1fr);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.rbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.rtitle { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rpage { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rzoom { display: inline-flex; gap: 4px; }
.rzoom .btn { padding: 5px 11px; }
.rbody { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
.rpages { overflow: auto; padding: 16px; outline: none; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.rstack { display: grid; justify-content: center; align-content: start; gap: 14px; width: max-content; min-width: 100%; }
.rp { position: relative; background: var(--paper); box-shadow: 0 1px 3px rgb(0 0 0 / .18); }
.rp canvas { display: block; }
.rpnum { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #9AA59F; font-size: 13px; }
.hlLayer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.hl { position: absolute; border-radius: 2px; mix-blend-mode: multiply; background: var(--hl-yellow); transition: outline-color .3s; outline: 2px solid transparent; }
.hl.c-blue { background: var(--hl-blue); } .hl.c-red { background: var(--hl-red); } .hl.c-green { background: var(--hl-green); }
.hl.flash { outline-color: var(--accent); }
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: hidden; opacity: 1; line-height: 1; z-index: 2; -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgba(13, 107, 89, 0.28); }
.textLayer br::selection { background: transparent; }
.rmsg { margin: 48px auto; max-width: 52ch; text-align: center; color: var(--muted); display: grid; gap: 8px; }
.rmsg.err p { margin: 0; }
.rmsg a { color: var(--accent); }
.rside { width: 300px; overflow: auto; background: var(--surface); border-left: 1px solid var(--line); padding: 12px; }
.rlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rlist li { border-left: 3px solid var(--hl-yellow-edge); padding-left: 8px; }
.rlist li.c-blue { border-color: var(--hl-blue-edge); } .rlist li.c-red { border-color: var(--hl-red-edge); } .rlist li.c-green { border-color: var(--hl-green-edge); }
.rlist button { border: 0; background: transparent; text-align: left; padding: 2px 0; font-size: 13.5px; line-height: 1.45; color: var(--ink); }
.rp-n { display: block; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rnote { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.rempty { color: var(--muted); font-size: 13.5px; margin: 0; }
.rtool, .rpop { position: fixed; z-index: 35; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .22); }
.rtool { display: flex; gap: 2px; padding: 4px; }
.sw { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: inherit; font-size: 13px; font-weight: 500; padding: 6px 9px; border-radius: 7px; }
.sw:hover, .sw.on { background: rgb(127 127 127 / .3); }
.sw span { width: 12px; height: 12px; border-radius: 3px; background: #FACC15; }
.sw.c-blue span { background: #60A5FA; } .sw.c-red span { background: #F87171; } .sw.c-green span { background: #4ADE80; }
.rpop { width: 280px; padding: 10px; display: grid; gap: 8px; }
.rpop textarea { width: 100%; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 6px 8px; resize: vertical; }
.swrow, .poprow { display: flex; gap: 4px; justify-content: space-between; }
.rpop .linkbtn { color: var(--accent); }
.rpop .linkbtn.danger { color: var(--warn); }
@media (max-width: 860px) {
  .rside { position: absolute; right: 0; top: 0; bottom: 0; width: min(300px, 85vw); box-shadow: -6px 0 18px rgb(0 0 0 / .2); }
  .rbody { position: relative; }
  .rbar { flex-wrap: wrap; }
  .rtitle { order: 5; flex-basis: 100%; }
}
@media (max-width: 860px) {
  .qact { margin-left: 0; }
}

/* reader su telefono: zoom col pizzico, barre a tutta larghezza lontane dal menu di selezione di Android */
@media (pointer: coarse) {
  .rzoom { display: none; }
  .rtool {
    left: 8px !important; right: 8px; top: auto !important; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    justify-content: space-between; flex-wrap: wrap;
  }
  .rtool .sw { padding: 10px 8px; font-size: 13.5px; flex: 1 1 auto; justify-content: center; }
  .rpop { left: 8px !important; right: 8px; width: auto; top: calc(64px + env(safe-area-inset-top, 0px)) !important; }
  .rpop .sw { padding: 10px 14px; }
  .rpop textarea { font-size: 16px; }
}
.sw.note { border-left: 1px solid rgb(127 127 127 / .35); border-radius: 0 7px 7px 0; }

/* ---------------------------------------------------------------- gruppi */
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 11.5px; font-weight: 700; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.a1 { background: #0D6B59; } .avatar.a2 { background: #3E5A9C; } .avatar.a3 { background: #9A4A12; } .avatar.a4 { background: #7A3E8C; }
.avatar.a5 { background: #2F7D8C; } .avatar.a6 { background: #8C6A12; } .avatar.a7 { background: #B23A5B; } .avatar.a8 { background: #4D6B2A; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11.5px; font-weight: 700; padding: 0 7px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.joinnote { margin: 0; background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.groupview { display: grid; gap: 14px; }
.ghead { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 10px; }
.gtop { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: space-between; align-items: flex-start; }
.gtitle { min-width: 0; }
.gtitle h3 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.gtitle .sub { margin: 2px 0 0; }
.gfaces { display: flex; }
.gfaces .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.gfaces .more { font-size: 12px; color: var(--muted); align-self: center; margin-left: 6px; }
.gstats { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.gacts { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.iam { margin-left: auto; font-size: 13px; color: var(--muted); }
.gpanel { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 8px; font-size: 14px; }
.gpanel p { margin: 0; }
.linkrow { display: flex; gap: 6px; flex-wrap: wrap; }
.linkrow input { flex: 1 1 220px; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 10px; font-family: var(--font-mono); font-size: 12.5px; }
.linkrow input[type="email"] { font-family: var(--font-body); font-size: 14px; }
.mlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mlist li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.mname { display: grid; min-width: 0; flex: 1 1 160px; font-weight: 600; }
.mname small { font-weight: 400; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.role { font-size: 12px; color: var(--muted); }
.glist .row.grow { grid-template-columns: 28px minmax(0, 1fr) auto; }
.newdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 2px; }
.gcounts { gap: 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.inlib { color: var(--accent); font-weight: 700; }
.glist .panel.gpanelx { padding-left: calc(14px + 28px + 12px); }
.thread { display: grid; gap: 8px; }
.thread h4 { margin: 4px 0 0; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.clist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cmt { display: flex; gap: 8px; align-items: flex-start; }
.cbody { min-width: 0; flex: 1; }
.cmeta { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; font-size: 12.5px; color: var(--muted); }
.cmeta strong { color: var(--ink); font-size: 13px; }
.cmeta .linkbtn { font-size: 12px; margin-left: auto; }
.cbody p { margin: 2px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: flex; gap: 6px; align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; resize: vertical; font-size: 14px; }
.ghl { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.ghl .quote { gap: 6px; }
.ghl .qmeta strong { color: var(--ink); font-size: 13px; }
.hnote { margin: 0; font-size: 13.5px; color: var(--muted); }
.ghl .clist { padding-left: 4px; }
.gchip { font-size: 12px; color: var(--read); }
.chip.gchip-on { background: var(--read-soft); }
.chip.gchip-on .linkbtn { color: var(--read); font-size: 13px; }
.sharesel { border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 2px 8px; font-size: 13px; color: var(--muted); }
.hl.other { background: transparent !important; border-bottom: 2px solid var(--hl-yellow-edge); mix-blend-mode: normal; }
.hl.other.c-blue { border-color: var(--hl-blue-edge); } .hl.other.c-red { border-color: var(--hl-red-edge); } .hl.other.c-green { border-color: var(--hl-green-edge); }
.pauthor, .pnote { margin: 0; font-size: 13.5px; }
.pnote { color: var(--muted); }
.pthread { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; max-height: 260px; overflow: auto; }
.pthread textarea { width: 100%; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 6px 8px; resize: vertical; }
.pthread .btn { justify-self: end; }
@media (max-width: 860px) {
  .glist .panel.gpanelx { padding-left: 14px; }
  .iam { margin-left: 0; }
}

/* ---------------------------------------------------------------- menu laterale */
.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; border-radius: 6px; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary h2 { margin: 0; }
.sec > summary::after { content: "▾"; color: var(--muted); font-size: 12px; transition: transform .15s; padding: 0 4px; }
.sec:not([open]) > summary::after { transform: rotate(-90deg); }
details.sec[open] > summary { margin-bottom: 6px; }
.sec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.newproj { display: flex; gap: 6px; margin-top: 6px; }
.newproj input { flex: 1; min-width: 0; margin-top: 0; }
.newproj .btn { flex: none; }
.newproj input:placeholder-shown + .btn { opacity: .55; }
.side-head, .menubtn, .scrim { display: none; }
.iconbtn { border: 0; background: transparent; font-size: 24px; line-height: 1; padding: 4px 10px; border-radius: 8px; color: var(--ink); }
.iconbtn:hover { background: var(--surface); }

@media (max-width: 860px) {
  .menubtn {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    border-radius: 999px; padding: 6px 14px 6px 12px; font-weight: 600; font-size: 14px; max-width: 60vw; overflow: hidden;
  }
  #menuLabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand h1 { display: none; }
  .side {
    position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: min(330px, 88vw); max-height: none; margin: 0;
    background: var(--bg); box-shadow: 6px 0 24px rgb(0 0 0 / .25); gap: 16px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
  }
  .side.open { transform: none; visibility: visible; transition: transform .2s ease; }
  .side-head { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-display); font-size: 18px; }
  .side .navbtn { padding-top: 9px; padding-bottom: 9px; }
  .side-keys { display: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgb(0 0 0 / .35); }
  .scrim[hidden] { display: none; }
  body.menu-open { overflow: hidden; }
}

/* ---------------------------------------------------------------- scheda dell'articolo */
.pact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pact .btn { padding: 7px 14px; font-size: 14px; }
.pact a.btn.primary { color: var(--accent-ink); }
.pact .stars { margin-left: 4px; }
.psec { border-top: 1px solid var(--line); }
.psec > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; padding: 9px 2px; min-height: 40px;
}
.psec > summary::-webkit-details-marker { display: none; }
.psec > summary::before { content: "▸"; color: var(--muted); font-size: 12px; width: 10px; flex: none; transition: transform .15s; }
.psec[open] > summary::before { transform: rotate(90deg); }
.psec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.psl { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; flex: none; min-width: 88px; }
.psp { font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.psec[open] .psp { visibility: hidden; }
.psb { display: grid; gap: 12px; padding: 2px 0 12px 22px; }
.psb textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; resize: vertical; color: var(--ink); }
.psb .abstract { max-width: 72ch; }
@media (max-width: 860px) {
  .psb { padding-left: 4px; }
  .psl { min-width: 76px; }
  .pact .btn { flex: 1 1 auto; text-align: center; }
  .pact .stars { flex-basis: 100%; margin-left: 0; }
}
/* sul telefono le scorciatoie da tastiera e il trascinamento non servono */
@media (max-width: 860px) { .hints > span { display: none; } }

/* ---------------------------------------------------------------- segnalibro e PDF mancante */
.prog { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pbar { display: inline-block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.rmissing { max-width: 560px; margin: 8vh auto; display: grid; gap: 10px; text-align: left; line-height: 1.5; }
.rmissing p { margin: 0; }
.rattach { cursor: pointer; display: inline-block; }

/* ---------------------------------------------------------------- suggerimento dell'estensione */
.exthint {
  position: fixed; z-index: 40; right: 20px; bottom: 20px; width: min(420px, calc(100vw - 40px));
  display: flex; gap: 8px; align-items: flex-start; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 8px 16px 18px; box-shadow: 0 10px 30px rgb(0 0 0 / .18);
}
.exthint[hidden] { display: none; }
.exthint-body { display: grid; gap: 8px; flex: 1; min-width: 0; }
.exthint p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.exthint-act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.exthint-never { font-size: 13px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.extdialog { max-width: 560px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 22px 24px; }
.extdialog::backdrop { background: rgb(0 0 0 / .4); }
.extdialog h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 20px; }
.extdialog ol { padding-left: 20px; display: grid; gap: 10px; line-height: 1.5; font-size: 14px; }
.extdialog li[hidden] { display: none; }
.extdialog form { text-align: right; }
