/* News Manager — foglio di stile unico.
   Struttura: variabili, base, barra laterale, barra strumenti,
   schede articolo, lettore, pagine di gestione, adattamento mobile. */

/* --- Variabili --------------------------------------------------------- */

:root {
  --bg: #edeff1;
  --surface: #ffffff;
  --surface-2: #f5f7f8;
  --ink: #131a21;
  --ink-2: #3d4a57;
  --muted: #6b7a88;
  --line: #dde2e7;
  --line-strong: #c6ced6;
  --accent: #0f5e7a;
  --accent-hover: #0b4356;
  --accent-soft: #e3eef3;
  --star: #96650a;
  --danger: #a83a32;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, sans-serif;
  --font-read: "Iowan Old Style", "Palatino Linotype", Palatino,
               "Book Antiqua", Georgia, serif;

  --sidebar-w: 264px;
  --sidebar-min: 190px;
  --sidebar-max: 460px;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(19, 26, 33, .06), 0 6px 16px rgba(19, 26, 33, .05);
}

[data-theme="dark"] {
  --bg: #10151a;
  --surface: #171e25;
  --surface-2: #1d262f;
  --ink: #e3e8ed;
  --ink-2: #b7c1cb;
  --muted: #85929e;
  --line: #27323c;
  --line-strong: #384656;
  --accent: #5cb3d4;
  --accent-hover: #8ccde5;
  --accent-soft: #16323f;
  --star: #d4a63c;
  --danger: #e07a70;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151a;
    --surface: #171e25;
    --surface-2: #1d262f;
    --ink: #e3e8ed;
    --ink-2: #b7c1cb;
    --muted: #85929e;
    --line: #27323c;
    --line-strong: #384656;
    --accent: #5cb3d4;
    --accent-hover: #8ccde5;
    --accent-soft: #16323f;
    --star: #d4a63c;
    --danger: #e07a70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

/* --- Base -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- Barra laterale ---------------------------------------------------- */

.sidebar {
  grid-column: 1;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 18px 14px;
  font-weight: 640;
  font-size: 15px;
  letter-spacing: -.01em;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--accent);
  position: relative;
  flex: none;
}
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--surface);
}
.brand-mark::before { top: 6px; width: 12px; }
.brand-mark::after { top: 11px; width: 8px; opacity: .7; }

.nav-views {
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item,
.feed-item,
.folder-name {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px;
  transition: background .12s ease, color .12s ease;
}

.nav-item:hover,
.feed-item:hover,
.folder-name:hover { background: var(--surface-2); color: var(--ink); }

.nav-item.is-active,
.feed-item.is-active,
.folder-name.is-active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 560;
}

.nav-label, .feed-name, .folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--surface);
  background: var(--accent);
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.badge:empty { display: none; }

.badge-quiet { background: transparent; color: var(--muted); padding: 1px 2px; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 10px;
  border-top: 1px solid var(--line);
}

.folder { margin-bottom: 2px; }

.folder > summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  padding-right: 6px;
}
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 4px;
  margin-right: 2px;
  border-left: 4px solid var(--muted);
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform .15s ease;
  flex: none;
}
.folder[open] > summary::before { transform: rotate(90deg); }
.folder > summary .folder-name { flex: 1; }

.feed-list { list-style: none; margin: 0; padding: 0 0 0 14px; }
.feed-list-loose { padding-left: 0; margin-top: 4px; }

.feed-mark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 640;
  display: grid;
  place-items: center;
  flex: none;
}

.feed-item.has-error .feed-mark {
  border-color: var(--danger);
  color: var(--danger);
}

.sidebar-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 10px;
  margin: 0;
}

/* I pulsanti mantengono la loro misura e vanno a capo quando non ci
   stanno: allargando la barra si ricompongono su una riga sola, invece
   di stirarsi. */
.sidebar-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.foot-link {
  flex: 0 0 auto;
  text-align: center;
  padding: 6px 11px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.foot-link:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

/* --- Area principale --------------------------------------------------- */

.main {
  grid-column: 2;
  min-width: 0;
  padding: 0 0 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: flex-end;
  justify-content: space-between;
}

.topbar-title h1 {
  margin: 0;
  font-family: var(--font-read);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.topbar-note {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 60ch;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search input {
  width: 200px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.search input::placeholder { color: var(--muted); }

.layout-switch {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.layout-switch a {
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
}
.layout-switch a + a { border-left: 1px solid var(--line); }
.layout-switch a.is-active { background: var(--accent-soft); color: var(--accent-hover); }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 520;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .12s ease;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled {
  opacity: 1;
  cursor: default;
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

/* In tema scuro l'accento è chiaro, quindi il pulsante pieno vuole il
   testo scuro. La regola deve però risparmiare i pulsanti a sfondo
   scuro, che altrimenti restano scritti in nero su nero. */
[data-theme="dark"] .btn:not(.btn-quiet):not(:disabled) { color: #0b1116; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn:not(.btn-quiet):not(:disabled) {
    color: #0b1116;
  }
}

[data-theme="dark"] .btn-quiet { color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-quiet { color: var(--ink-2); }
}

.btn-quiet {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-2);
}
.btn-quiet:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }

/* --- Schede articolo --------------------------------------------------- */

.article-area {
  padding: 14px 28px 0;
  max-width: 980px;
}

.card {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  margin-bottom: 10px;
  position: relative;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card:focus-visible { outline-offset: 3px; }

.card::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.card.is-read::before { display: none; }

.card-body { flex: 1; min-width: 0; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 5px;
}

.card-source { color: var(--accent); font-weight: 560; }
.card.is-read .card-source { color: var(--muted); font-weight: 500; }
.card-dot { opacity: .55; }

.card-muted-tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 8px;
  font-size: 11.5px;
}

.card-title {
  margin: 0 0 6px;
  font-family: var(--font-read);
  font-size: 19px;
  line-height: 1.28;
  font-weight: 600;
  letter-spacing: -.01em;
}
.card-title a:hover { color: var(--accent); }
.card.is-read .card-title { font-weight: 500; color: var(--ink-2); }

.card-snippet {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 72ch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tools {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.tool {
  font: inherit;
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tool:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-2); }
.tool.is-on { color: var(--star); border-color: var(--star); }
.tool-danger:hover { color: var(--danger); border-color: var(--danger); }

.card-thumb {
  flex: none;
  width: 168px;
  height: 112px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.is-read .card-thumb img { opacity: .72; }

/* Elenco compatto */
.layout-compact .card { padding: 10px 14px; gap: 12px; margin-bottom: 4px; }
.layout-compact .card-thumb { width: 76px; height: 52px; }
.layout-compact .card-title { font-size: 16px; margin-bottom: 2px; }
.layout-compact .card-snippet { display: none; }
.layout-compact .card-tools { margin-top: 6px; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-2);
}
.empty p { margin: 0 0 6px; font-size: 17px; font-family: var(--font-read); }
.empty-sub { color: var(--muted); font-size: 14px !important; font-family: var(--font-ui) !important; }

.load-more-wrap { padding: 8px 28px 40px; max-width: 980px; }
.load-more-wrap .btn { width: 100%; }

/* --- Lettore ----------------------------------------------------------- */

.reader-panel {
  position: fixed;
  inset: 0 0 0 var(--sidebar-w);
  background: var(--bg);
  z-index: 40;
  overflow-y: auto;
}

.reader-standalone { padding: 0; }

.reader-inner, .reader-standalone .reader { max-width: 760px; margin: 0 auto; }

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.reader-bar-right { display: flex; gap: 6px; align-items: center; }

.reader-article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 36px 40px;
  margin: 20px 24px 60px;
}

.reader-meta {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.reader-source { color: var(--accent); font-weight: 560; }

.reader-title {
  margin: 0 0 18px;
  font-family: var(--font-read);
  font-size: 32px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -.02em;
}

.reader-hero {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  display: block;
}

.reader-content {
  font-family: var(--font-read);
  font-size: 17.5px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 68ch;
}
.reader-content p { margin: 0 0 1.1em; }
.reader-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.reader-content h1, .reader-content h2, .reader-content h3 {
  font-size: 1.25em;
  line-height: 1.3;
  margin: 1.6em 0 .5em;
}
.reader-content img, .reader-content video {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 1em 0;
}
.reader-content figure { margin: 1.4em 0; }
.reader-content figcaption { font-size: .8em; color: var(--muted); font-family: var(--font-ui); }
.reader-content blockquote {
  margin: 1.3em 0;
  padding-left: 18px;
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
}
.reader-content pre {
  background: var(--surface-2);
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: .82em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.reader-content code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }
.reader-content table { border-collapse: collapse; width: 100%; font-size: .9em; }
.reader-content th, .reader-content td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }

.reader-empty { color: var(--muted); font-style: italic; }

.reader-foot {
  margin: 32px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 14px;
}
.reader-foot a { color: var(--accent); }

/* --- Pagine di gestione ------------------------------------------------ */

.page { padding: 20px 28px; max-width: 900px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -.01em;
}

.panel-hint, .panel-empty {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 68ch;
}
.panel-empty { margin-bottom: 0; }

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.inline-form input[type="text"] { flex: 1; min-width: 220px; }

input[type="text"], input[type="search"], select, input[type="file"] {
  font: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
input[type="file"] { padding: 5px; background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; font-weight: 560; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12.5px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 170px; }

.check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 14px; }

.rule-form-foot { display: flex; gap: 8px; }

.form-message { margin: 10px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.form-message.is-error { color: var(--danger); }
.form-message.is-ok { color: var(--accent); }

.chip-list { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; padding: 0; margin: 14px 0 0; }
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 6px 3px 12px;
  font-size: 13px;
}
.chip-remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 50%;
}
.chip-remove:hover { color: var(--danger); background: var(--surface); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 620;
  color: var(--muted);
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 14px; }
.table tr.is-off { opacity: .5; }

.table-title { font-weight: 560; color: var(--ink); display: block; }
.table-title:hover { color: var(--accent); }
.table-sub { color: var(--muted); font-size: 12.5px; }

.tag {
  font-size: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 0 6px;
  color: var(--muted);
  margin-left: 6px;
}

.status { font-size: 12.5px; color: var(--muted); }
.status-error { color: var(--danger); }
.status-quiet { opacity: .7; }

.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

/* --- Finestra di dialogo ----------------------------------------------- */

.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  max-width: 520px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(10, 16, 22, .45); }

.dialog-form { padding: 22px 24px; margin: 0; }
.dialog-form h2 { margin: 0 0 4px; font-size: 17px; }
.dialog-hint { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.dialog-preview { margin: 4px 0 0; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* --- Notifiche --------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 20px;
  z-index: 90;
  box-shadow: var(--shadow);
  max-width: calc(100% - 40px);
}

/* --- Elementi mobile --------------------------------------------------- */

.drawer-toggle {
  display: none !important;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 60;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  padding: 10px 9px;
  flex-direction: column;
  justify-content: space-between;
}
.drawer-toggle span { display: block; height: 2px; background: var(--ink-2); border-radius: 1px; }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 22, .4);
  z-index: 45;
}

/* --- Adattamento a schermi stretti ------------------------------------- */

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }

  .scrim:not([hidden]) { display: block; }

  /* Zona sensibile sul bordo sinistro: si scorre il dito da lì per far
     comparire l'elenco delle fonti. */
  .edge-grab {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    z-index: 44;
    touch-action: pan-y;
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    width: min(84vw, var(--sidebar-w));
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }

  .main { grid-column: 1; }

  /* Sul telefono la barra in cima occupava quasi metà schermo: titolo,
     spiegazione e tre file di comandi prima di arrivare alle notizie.
     Ora la spiegazione sparisce, il titolo si riduce e i comandi stanno
     su una riga sola che scorre di lato. */
  .topbar {
    padding: 8px 12px 8px 14px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .topbar-title h1 { font-size: 20px; }
  .topbar-note { display: none; }

  .topbar-actions {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions > * { flex: none; }

  .search { flex: 1 1 auto; min-width: 130px; }
  .search input { width: 100%; }

  .article-area { padding-top: 10px; }

  .article-area, .page { padding-left: 16px; padding-right: 16px; }
  .load-more-wrap { padding-left: 16px; padding-right: 16px; }

  .card { gap: 12px; padding: 13px 14px; }
  .card-thumb { width: 96px; height: 72px; }
  .card-title { font-size: 17px; }
  .card-snippet { -webkit-line-clamp: 3; line-clamp: 3; }
  .card-tools { opacity: 1; }

  .reader-panel { inset: 0; }
  .reader-article { padding: 22px 20px 32px; margin: 14px 14px 50px; }
  .reader-title { font-size: 25px; }
  .reader-content { font-size: 17px; }
}

@media (max-width: 560px) {
  .card { flex-direction: column-reverse; }
  .card-thumb { width: 100%; height: 168px; }
  .layout-compact .card { flex-direction: row; }
  .layout-compact .card-thumb { width: 68px; height: 48px; }
  .row-actions { justify-content: flex-start; }
  .table thead { display: none; }
  .table td { display: block; border: none; padding: 3px 0; }
  .table tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .table .num { text-align: left; }
}

/* --- Pagina «Aggiungi fonti» (delta 2) --------------------------------- */

.page-add { max-width: 780px; }

.source-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.source-tab {
  font: inherit;
  font-size: 14px;
  padding: 9px 14px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.source-tab:hover { color: var(--ink); }
.source-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 560; }

.source-search {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 6px 6px 12px;
}
.source-search:focus-within { border-color: var(--accent); }
.source-search input[type="search"] {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 6px 0;
  font-size: 15px;
}
.source-search input[type="search"]:focus { outline: none; }
.source-search select { border-color: transparent; background: var(--surface-2); }

.source-hint { color: var(--muted); font-size: 13px; margin: 10px 2px 16px; }

.source-results { display: flex; flex-direction: column; gap: 6px; }

.source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.source-item:hover { border-color: var(--line-strong); }

.source-item-body { flex: 1; min-width: 0; }
.source-item-title { font-weight: 560; font-size: 14.5px; display: block; }
.source-item-desc {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
.source-item-hint {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 8px;
  margin-left: 8px;
  white-space: nowrap;
}

.source-empty { color: var(--muted); font-size: 14px; padding: 24px 2px; }

.panel-fallback { margin-top: 18px; border-color: var(--accent); }
.fallback-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.fallback-url { color: var(--muted); font-size: 13px; word-break: break-all; }

/* Sovrapposizione per la scelta della notizia */

.picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.picker-overlay[hidden] { display: none; }

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.picker-sub { color: var(--muted); font-size: 13px; margin-left: 10px; }

#pickerFrame { flex: 1; width: 100%; border: none; background: #fff; }

.picker-preview {
  border-top: 1px solid var(--line);
  background: var(--surface);
  max-height: 46vh;
  overflow-y: auto;
  padding: 14px 18px 18px;
}
.picker-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.picker-preview-actions { display: flex; gap: 8px; }

.picker-preview-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.picker-preview-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
}
.picker-preview-list img {
  width: 56px; height: 40px; object-fit: cover;
  border-radius: 4px; flex: none; background: var(--surface-2);
}
.picker-preview-list .pv-title { font-weight: 540; }
.picker-preview-list .pv-sub { color: var(--muted); font-size: 12.5px; }

@media (max-width: 900px) {
  .picker-preview { max-height: 52vh; }
  .picker-head { padding: 10px 14px; }
  .picker-sub { display: none; }
}

.sidebar-version {
  margin: 0;
  padding: 0 10px 10px;
  font-size: 11px;
  color: var(--muted);
  opacity: .7;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.table-error {
  display: block;
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 2px;
  max-width: 46ch;
}

/* --- Vista a griglia (delta 4) ----------------------------------------
   Schede affiancate con l'immagine in alto: è la disposizione più adatta
   a scorrere molte notizie insieme, e quella a cui Fabio è abituato. */

.article-area.layout-grid {
  display: grid;
  /* La larghezza minima di un riquadro decide quanti ne stanno per riga:
     la griglia riempie da sola lo spazio disponibile. */
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
  gap: 26px 22px;
  max-width: var(--grid-max);
  align-items: start;
}

/* La larghezza massima decide quanti riquadri stanno per riga. Il medio è
   tarato per mostrarne 5, come nell'uso abituale. */
body.grid-small  { --tile: 210px; --grid-max: 1400px; }  /* 6 per riga */
body.grid-medium { --tile: 250px; --grid-max: 1400px; }  /* 5 per riga */
body.grid-large  { --tile: 320px; --grid-max: 1360px; }  /* 4 per riga */
body.grid-xlarge { --tile: 430px; --grid-max: 1400px; }  /* 3 per riga */

/* Nei riquadri piccoli il testo va ridotto, o il titolo occupa tutto. */
body.grid-small .layout-grid .card-title { font-size: 15px; }
body.grid-small .layout-grid .card-snippet {
  font-size: 12.5px;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
body.grid-large .layout-grid .card-title { font-size: 19px; }
body.grid-xlarge .layout-grid .card-title { font-size: 21px; }
body.grid-xlarge .layout-grid .card-snippet {
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

.layout-grid .card {
  flex-direction: column-reverse;
  gap: 0;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.layout-grid .card:hover { box-shadow: none; border: none; }
.layout-grid .card::before { display: none; }

.layout-grid .card-thumb {
  width: 100%;
  height: auto;
  /* La forma si sceglie dalle Opzioni: nessuna proporzione va bene per
     tutte le fonti, un quotidiano e un sito di vignette vogliono cose
     diverse. */
  aspect-ratio: var(--tile-ratio, 3 / 2);
  margin-bottom: 11px;
  border-radius: var(--radius-sm);
}

/* Per i browser che non conoscono aspect-ratio (Safari vecchi). */
@supports not (aspect-ratio: 1) {
  .layout-grid .card-thumb { height: 170px; }
}

body.ratio-wide    { --tile-ratio: 16 / 9; }
body.ratio-photo   { --tile-ratio: 3 / 2; }
body.ratio-classic { --tile-ratio: 4 / 3; }
body.ratio-square  { --tile-ratio: 1 / 1; }

.layout-grid .card-body { width: 100%; }

/* Nella griglia il titolo viene prima della riga della fonte, come nella
   disposizione di riferimento: si legge la notizia, poi da dove viene. */
.layout-grid .card-body { display: flex; flex-direction: column; }
.layout-grid .card-title { order: 1; font-size: 17px; line-height: 1.25; margin-bottom: 6px; }
.layout-grid .card-meta { order: 2; margin-bottom: 6px; }
.layout-grid .card-snippet { order: 3; -webkit-line-clamp: 3; line-clamp: 3; font-size: 13.5px; }
.layout-grid .card-tools { order: 4; }

.layout-grid .card.is-read .card-title { color: var(--muted); }
.layout-grid .card.is-read .card-snippet { opacity: .7; }

.layout-grid .empty { grid-column: 1 / -1; }

/* Senza cornice il fuoco da tastiera va reso visibile a modo. */
.layout-grid .card:focus-visible { outline-offset: 6px; }

@media (max-width: 900px) {
  .article-area.layout-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px 14px;
  }
  .layout-grid .card-thumb { aspect-ratio: var(--tile-ratio, 3 / 2); }
  .layout-grid .card-title { font-size: 15px; }
  .layout-grid .card-snippet { display: none; }
}

@media (max-width: 560px) {
  /* Sul telefono ogni notizia occupa una riga, con l'immagine a destra e
     il testo a sinistra, come nell'app di riferimento: la griglia a più
     colonne rende i riquadri troppo piccoli da leggere. */
  .article-area.layout-grid { grid-template-columns: 1fr; }
  .layout-grid .card {
    flex-direction: row;
    gap: 12px;
    align-items: flex-start;
  }
  .layout-grid .card-thumb {
    order: 2;
    width: 108px;
    height: 84px;
    aspect-ratio: auto;
    flex: none;
    margin: 0;
  }
  .layout-grid .card-body { order: 1; }
  .layout-grid .card-title { order: 1; font-size: 15.5px; }
  .layout-grid .card-meta { order: 2; }
  .layout-grid .card-snippet { display: none; }
}

/* --- Articoli riservati agli abbonati (delta 5) ------------------------ */

.card-thumb, .reader-hero-wrap { position: relative; }

.reader-hero-wrap { margin-bottom: 22px; }
.reader-hero-wrap .reader-hero { margin-bottom: 0; }

.thumb-lock {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #b3261e;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  pointer-events: none;
}

.reader-hero-wrap .thumb-lock { right: 10px; bottom: 10px; width: 26px; height: 26px; }

.lock-svg { width: 13px; height: 13px; display: block; }
.reader-hero-wrap .lock-svg { width: 15px; height: 15px; }

.meta-lock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #b3261e;
  font-size: 12px;
}
[data-theme="dark"] .meta-lock { color: #f2837a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .meta-lock { color: #f2837a; }
}
.meta-lock .lock-svg { width: 11px; height: 11px; }

.card.is-read .thumb-lock { opacity: .8; }

.reader-paywall {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border-left: 3px solid #b3261e;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink-2);
}
.reader-paywall .lock-svg { color: #b3261e; width: 15px; height: 15px; flex: none; }

/* --- Pagine di accesso (delta 7) -------------------------------------- */

.gate-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100vh;
}

.gate {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 30px 22px;
  box-shadow: var(--shadow);
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 640;
  font-size: 16px;
  margin-bottom: 18px;
}

.gate-intro {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.gate-form .field { margin-bottom: 14px; }
.gate-form input[type="password"] { width: 100%; font-size: 15px; padding: 9px 11px; }

.gate-submit { width: 100%; padding: 10px; font-size: 14px; margin-top: 4px; }

.gate-error {
  margin: 0 0 12px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
}

.gate-version {
  margin: 20px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

.foot-form { flex: 0 0 auto; display: flex; }

.gate-note {
  margin: 2px 0 14px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

/* --- Riordino per trascinamento (delta 8) ----------------------------- */

.sidebar-scroll .folder > summary,
.feed-list li { touch-action: pan-y; }

/* Le voci della barra laterale sono collegamenti, e i collegamenti il
   browser li trascina per conto suo: quel gesto nativo annullava gli
   eventi puntatore su cui è costruito il riordino, che quindi sul
   computer non partiva mai. */
.sidebar-scroll a,
.sidebar-scroll summary {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.sidebar-scroll.is-sorting,
.feed-list.is-sorting,
.sidebar-scroll.is-sorting a,
.feed-list.is-sorting a { user-select: none; -webkit-user-select: none; }

.sidebar-scroll.is-sorting,
.feed-list.is-sorting { touch-action: none; }

.is-dragging {
  opacity: .55;
}
.is-dragging > .feed-item,
.is-dragging > summary {
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.feed-list.is-sorting li:not(.is-dragging),
.sidebar-scroll.is-sorting .folder:not(.is-dragging) {
  transition: transform .12s ease;
}

/* Il cursore dice che l'elemento si può spostare, senza aggiungere
   maniglie che ruberebbero spazio in una barra già stretta. */
.sidebar-scroll .folder > summary:hover,
.feed-list li:hover > .feed-item { cursor: grab; }
.sidebar-scroll.is-sorting * { cursor: grabbing !important; }

/* Una cartella vuota deve restare un bersaglio raggiungibile col dito,
   altrimenti non ci si potrebbe trascinare dentro la prima fonte. */
.feed-list:empty { min-height: 26px; }
.feed-list.is-sorting {
  outline: 1px dashed var(--line-strong);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.feed-list.is-sorting:empty::after {
  content: "trascina qui";
  display: block;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
}

/* --- Applicazione installabile (delta 9) ------------------------------- */

.install-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 28px);
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 13.5px;
}

/* In modalità applicazione la barra di sistema può coprire il bordo dello
   schermo: si lascia spazio alle zone sicure del dispositivo. */
@media (display-mode: standalone) {
  .sidebar { padding-top: env(safe-area-inset-top); }
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .drawer-toggle { top: calc(10px + env(safe-area-inset-top)); }
  .reader-bar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .install-bar { display: none; }
}

@media (max-width: 560px) {
  .install-bar { left: 14px; right: 14px; transform: none; max-width: none; }
}

/* Le immagini dei feed hanno risoluzioni molto diverse: quelle piccole
   vengono centrate su fondo neutro invece di essere ingrandite fino a
   sgranarsi. */
.card-thumb img { object-fit: cover; background: var(--surface-2); }
.reader-hero { max-width: 100%; height: auto; }

/* --- Chiusura del lettore (delta 14) ---------------------------------- */

.reader-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: background .12s ease, color .12s ease;
}
.reader-close:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}
.reader-close svg { width: 17px; height: 17px; display: block; }

/* --- Impostazioni (delta 15) ------------------------------------------ */

.page-settings { max-width: 860px; }

.setting {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.setting:last-child { border-bottom: none; padding-bottom: 0; }

.setting-text { flex: 1; min-width: 220px; }
.setting-title { font-weight: 560; font-size: 14px; display: block; }
.setting-help {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  max-width: 56ch;
}
.setting-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 0 7px;
  margin-left: 7px;
  vertical-align: 1px;
}

.setting-choice, .choice-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-radius: var(--radius-sm);
}

.choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.choice:hover { border-color: var(--line-strong); color: var(--ink); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked), .choice.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
  font-weight: 560;
}
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Carattere, dimensione e densità ---------------------------------- */

/* Il carattere scelto vale per titoli e corpo degli articoli. Se il file
   non arriva — connessione assente, blocco degli script di terze parti —
   la ricaduta è il carattere di sistema, senza che nulla si rompa. */
body.font-merriweather { --font-read: "Merriweather", Georgia, serif; }
body.font-inter        { --font-read: "Inter", var(--font-ui); }
body.font-noto         { --font-read: "Noto Sans", var(--font-ui); }
body.font-system       { --font-read: var(--font-ui); }
body.font-opendyslexic {
  --font-read: "OpenDyslexic", "Open Dyslexic", var(--font-ui);
}
/* OpenDyslexic è largo: senza questo le righe diventano troppo corte. */
body.font-opendyslexic .reader-content { max-width: 78ch; letter-spacing: -.01em; }
body.font-opendyslexic .card-title { line-height: 1.35; }

body.text-small  .card-title { font-size: 16px; }
body.text-large  .card-title { font-size: 21px; }
body.text-xlarge .card-title { font-size: 23px; }
body.text-small  .card-snippet { font-size: 13px; }
body.text-large  .card-snippet { font-size: 15px; }
body.text-xlarge .card-snippet { font-size: 16px; }
body.text-small  .reader-content { font-size: 16px; }
body.text-large  .reader-content { font-size: 19.5px; }
body.text-xlarge .reader-content { font-size: 22px; }
body.text-large  .reader-title { font-size: 35px; }
body.text-xlarge .reader-title { font-size: 39px; }

body.density-compact .card { padding-top: 9px; padding-bottom: 9px; margin-bottom: 5px; }
body.density-compact .layout-grid { gap: 18px 16px; }
body.density-comfortable .card { padding-top: 20px; padding-bottom: 20px; margin-bottom: 16px; }
body.density-comfortable .layout-grid { gap: 34px 26px; }

/* --- Pulsante grande di fine elenco ----------------------------------- */

.giant-mark-wrap { padding: 28px 28px 48px; max-width: 1280px; }
.giant-mark {
  width: 100%;
  padding: 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 560;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
}
.giant-mark:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* --- Menu del periodo per «segna tutti letti» ------------------------- */

.period-menu {
  position: absolute;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  min-width: 190px;
}
.period-menu button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  border: none;
  background: none;
  color: var(--ink-2);
  border-radius: 4px;
  cursor: pointer;
}
.period-menu button:hover { background: var(--surface-2); color: var(--ink); }

.badge[data-mark-feed] { cursor: inherit; }
body[data-badge-marks-read="yes"] .badge[data-mark-feed] { cursor: pointer; }
body[data-badge-marks-read="yes"] .badge[data-mark-feed]:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 900px) {
  .giant-mark-wrap { padding-left: 16px; padding-right: 16px; }
  .setting { gap: 10px; }
}

/* --- Impaginazione della pagina Feed (delta 16) ----------------------- */

/* La tabella ha guadagnato colonne strada facendo: le serve più spazio
   della larghezza usata dalle altre pagine. */
.page-feeds { max-width: 1180px; }

/* Rete di sicurezza: su schermi stretti la tabella scorre invece di
   uscire dal riquadro. */
.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.table td, .table th { vertical-align: middle; }

/* I menu a tendina non devono allargare la tabella oltre il necessario. */
.table select { max-width: 160px; width: 100%; }

/* I pulsanti di riga vanno a capo invece di sforare, e restano allineati
   a destra su una o due file. */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  min-width: 168px;
}
.row-actions .tool { flex: none; }

@media (max-width: 1100px) {
  .row-actions { min-width: 0; }
}

/* --- Barra laterale ridimensionabile (delta 17) ----------------------- */

.sidebar-grip {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 55;
  background: transparent;
  touch-action: none;
}
.sidebar-grip::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: transparent;
  transition: background .12s ease;
}
.sidebar-grip:hover::after,
body.is-resizing .sidebar-grip::after { background: var(--accent); }

body.is-resizing { cursor: col-resize; user-select: none; }
body.is-resizing .main { pointer-events: none; }

/* L'icona del sito al posto dell'iniziale. */
.feed-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 3px;
}
.feed-mark:has(img) { background: transparent; border-color: transparent; }

@media (max-width: 900px) {
  .sidebar-grip { display: none; }
}

/* --- Fuoco da tastiera sulle schede (delta 18) ------------------------ */

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius);
}
.layout-grid .card:focus-visible { outline-offset: 6px; }

/* --- Rinomina di una fonte (delta 18) --------------------------------- */

.rename-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  vertical-align: -2px;
  opacity: 0;
  transition: opacity .12s ease;
}
.table tr:hover .rename-btn,
.rename-btn:focus-visible { opacity: 1; }
.rename-btn:hover { color: var(--accent); background: var(--surface-2); }
.rename-btn svg { width: 13px; height: 13px; display: block; }

.rename-input {
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  width: 100%;
  max-width: 320px;
  padding: 4px 8px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
}

/* --- Articoli doppi (delta 19) ---------------------------------------- */

.card-copies {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 20px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 560;
}

.reader-copies {
  margin: 26px 0 0;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 13.5px;
}
.reader-copies-title { color: var(--muted); }
.reader-copies ul { list-style: none; margin: 8px 0 0; padding: 0;
                    display: flex; flex-wrap: wrap; gap: 6px 14px; }
.reader-copies a { color: var(--accent); text-decoration: underline;
                   text-underline-offset: 2px; }

/* --- Scorrimento continuo, rinomina cartelle, lucchetto (delta 21) ---- */

.scroll-sentinel { height: 1px; }
.scroll-status {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
  margin: 0;
}

.chip-rename {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 4px;
  display: inline-flex;
}
.chip-rename:hover { color: var(--accent); background: var(--surface); }
.chip-rename svg { width: 12px; height: 12px; display: block; }

.rename-chip { max-width: 160px; padding: 2px 6px; font-size: 13px; }

.tool-lock.is-on { color: #b3261e; border-color: #b3261e; }
[data-theme="dark"] .tool-lock.is-on { color: #f2837a; border-color: #f2837a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tool-lock.is-on {
    color: #f2837a; border-color: #f2837a;
  }
}

/* --- Comandi rapidi sulla scheda (delta 23) --------------------------- */

.card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* Sopra l'immagine: in alto a destra, su una pastiglia scura che li
   rende leggibili qualunque fotografia ci sia sotto. */
.card-thumb .card-actions {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 3px;
  border-radius: 20px;
  background: rgba(16, 21, 26, .72);
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .13s ease, transform .13s ease;
}
.card:hover .card-thumb .card-actions,
.card:focus-within .card-thumb .card-actions {
  opacity: 1;
  transform: none;
}

/* Senza immagine restano sotto il testo, sempre visibili. */
.card-body > .card-actions { margin-top: 10px; }

.act {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  color: #e8eaed;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.act:hover { background: rgba(255, 255, 255, .16); }
.act svg { width: 16px; height: 16px; display: block; }
.act.act-star.is-on { color: #ffd166; }
.act.act-lock.is-on { color: #ff8a80; }

/* Fuori dall'immagine i colori sono quelli del tema. */
.card-body > .card-actions .act { color: var(--muted); }
.card-body > .card-actions .act:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.card-body > .card-actions .act.act-star.is-on { color: var(--star); }
.card-body > .card-actions .act.act-lock.is-on { color: var(--danger); }

/* Il lucchetto dell'articolo riservato si sposta a sinistra, per non
   finire sotto i comandi. */
.card-thumb .thumb-lock { left: 6px; right: auto; }

/* Su telefono i comandi sull'immagine si nascondono del tutto: mentre si
   scorre danno solo fastidio, e per agire su una notizia c'è lo
   scorrimento verso sinistra o il lettore. Restano quelli sotto il testo
   delle schede senza immagine. */
@media (hover: none) {
  .card-thumb .card-actions { display: none; }
}

/* --- Gesti su telefono (delta 29) ------------------------------------- */

.edge-grab { display: none; }
@media (max-width: 900px) { .edge-grab { display: block; } }

.card.is-swiping {
  transition: none;
  will-change: transform;
}
.card.is-swiped-out {
  transition: transform .18s ease, opacity .18s ease;
  transform: translateX(-60%);
  opacity: 0;
}

/* Traccia che compare sotto la scheda mentre la si trascina. */
.card { overflow: hidden; }
.card::after {
  content: "letto";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
}
.card.is-swiping::after { opacity: 1; }

/* --- Contatori (delta 44) --------------------------------------------- */

/* Contatori dentro la barra fissa in alto, accanto al titolo. */
.counters {
  display: flex;
  gap: 14px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.counter-n {
  font-weight: 640;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
#counterUnread { color: var(--accent); }

@media (max-width: 900px) {
  /* Su telefono la riga dei contatori è sottile: caratteri piccoli e
     poco spazio, così ruba meno schermo. */
  .counters { margin-top: 2px; gap: 12px; font-size: 11px; }
  .topbar-title h1 { margin-bottom: 0; }
}

/* Segnaposto delle schede rimosse dal documento per risparmiare memoria. */
.card-placeholder {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 0 10px !important;
}
.card-placeholder::before, .card-placeholder::after { display: none !important; }

/* --- Segnaposto per le notizie senza immagine (delta 50) -------------- */
.card-thumb-placeholder img {
  object-fit: cover;
  opacity: 0.85;
}
