/* ==========================================================================
   editorial-hub — design system
   Estetica editoriale: serif per la lettura, sans per l'interfaccia,
   spaziature generose, palette calda e sobria.
   ========================================================================== */

:root {
  /* Colori */
  --paper: #fffefb;
  --surface: #ffffff;
  --ink: #1a1712;
  --ink-soft: #4b463d;
  --muted: #8a8378;
  --line: #ece7dd;
  --line-strong: #ddd6c8;
  --accent: #c2410c;        /* terracotta editoriale */
  --accent-soft: #fbeae0;
  --ok-bg: #e8f3ec; --ok-fg: #1f7a4d;
  --warn-bg: #fbf0d6; --warn-fg: #97650a;
  --err-bg: #fbe6e4; --err-fg: #b42318;
  --neutral-bg: #f1eee8; --neutral-fg: #6b6459;

  /* Tipografia */
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Charter, Georgia, "Times New Roman", serif;

  /* Forma */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(26, 23, 18, 0.06);
  --shadow: 0 6px 24px rgba(26, 23, 18, 0.08);
  --ring: 0 0 0 3px rgba(194, 65, 12, 0.15);

  /* Larghezze */
  --measure: 44rem;     /* colonna di lettura/scrittura */
  --wide: 60rem;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header ------------------------------------------------------------- */
.eh-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.75rem;
  padding: 0.85rem 1.5rem;
  background: rgba(255, 254, 251, 0.82);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.eh-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.eh-brand:hover { text-decoration: none; }
.eh-brand__mark {
  width: 1.6rem; height: 1.6rem;
  display: grid; place-items: center;
  background: var(--ink); color: var(--paper);
  border-radius: 7px;
  font-size: 0.95rem; font-weight: 700;
}
/* Desktop: la nav "si dissolve" nella riga flex dell'header, così i suoi figli
   (link, spacer, lingua, utente) restano allineati esattamente come prima.
   Su mobile riprende un box vero per diventare il pannello a tendina. */
.eh-nav { display: contents; }
.eh-nav a {
  color: var(--ink-soft);
  font-size: 0.94rem;
  font-weight: 500;
  padding: 0.2rem 0;
  margin-right: 1.1rem;
  border-bottom: 2px solid transparent;
}
.eh-nav a:hover { color: var(--ink); text-decoration: none; border-color: var(--line-strong); }
.eh-nav a.is-active { color: var(--ink); border-color: var(--accent); }
.eh-spacer { margin-left: auto; }
.eh-nav-toggle {
  display: none;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
}
.eh-nav-toggle__bar { width: 1.1rem; height: 2px; background: var(--ink); border-radius: 1px; }
.eh-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.eh-lang__label { color: var(--muted); font-size: 0.82rem; }

/* --- Layout ------------------------------------------------------------- */
.eh-main { max-width: var(--wide); margin: 2.5rem auto; padding: 0 1.5rem; }
.eh-main--reading { max-width: calc(var(--measure) + 3rem); }

.eh-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.eh-page-head h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin: 0;
}
.eh-page-head p { margin: 0.35rem 0 0; color: var(--muted); }

/* --- Bottoni ------------------------------------------------------------ */
.eh-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 999px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease, background 0.15s ease;
}
.eh-button:hover { text-decoration: none; opacity: 0.92; }
.eh-button:active { transform: translateY(1px); }
.eh-button--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.eh-button--ghost:hover { background: var(--surface); border-color: var(--muted); }
.eh-button--accent { background: var(--accent); border-color: var(--accent); }
.eh-button--sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }

/* --- Lista articoli (card) ---------------------------------------------- */
.eh-list { display: grid; gap: 0.9rem; }
.eh-card {
  display: block;
  padding: 1.35rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease;
}
.eh-card:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow); }
.eh-card__top { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.eh-card__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
  line-height: 1.25;
}
.eh-card__excerpt {
  font-family: var(--serif);
  color: var(--ink-soft);
  margin: 0.35rem 0 0.75rem;
  font-size: 1.02rem;
}
.eh-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.eh-card__meta a { color: var(--muted); }
.eh-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* --- Badge di stato ----------------------------------------------------- */
.eh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  white-space: nowrap;
}
.eh-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}
.eh-badge--ready, .eh-badge--published { background: var(--ok-bg); color: var(--ok-fg); }
.eh-badge--scheduled { background: var(--warn-bg); color: var(--warn-fg); }
.eh-badge--failed { background: var(--err-bg); color: var(--err-fg); }
.eh-badge--archived { background: var(--neutral-bg); color: var(--neutral-fg); }

/* --- Messaggi ----------------------------------------------------------- */
.eh-messages { max-width: var(--wide); margin: 1.25rem auto 0; padding: 0 1.5rem; list-style: none; display: grid; gap: 0.5rem; }
.eh-message {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--ok-bg); color: var(--ok-fg);
  font-size: 0.92rem;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}
.eh-message--error { background: var(--err-bg); color: var(--err-fg); }
.eh-message--warning { background: var(--warn-bg); color: var(--warn-fg); }

/* --- Stato vuoto -------------------------------------------------------- */
.eh-empty {
  text-align: center;
  padding: 4rem 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.eh-empty h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 0.5rem; }
.eh-empty p { color: var(--muted); margin: 0 0 1.5rem; }

/* ==========================================================================
   Editor (stile Substack): titolo/sottotitolo grandi senza bordi + corpo
   ========================================================================== */
.eh-editor { max-width: var(--measure); margin: 0 auto; }
.eh-editor__field { margin: 0; }

.editor-title,
.editor-subtitle {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--serif);
  color: var(--ink);
  padding: 0;
  resize: none;
  display: block;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.editor-title {
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-top: 0.5rem;
}
.editor-title::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }
.editor-subtitle {
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-soft);
  margin-top: 0.85rem;
}
.editor-subtitle::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }

.editor-rule { border: none; border-top: 1px solid var(--line); margin: 1.5rem 0; }

.editor-body-input { display: none; }

/* Quill (tema bubble) reso come prosa d'articolo */
#editor { font-family: var(--serif); }
#editor .ql-editor {
  padding: 0;
  min-height: 45vh;
  font-size: 1.2rem;
  line-height: 1.75;
  color: var(--ink);
}
#editor .ql-editor.ql-blank::before {
  left: 0; right: 0;
  font-style: normal;
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  font-size: 1.2rem;
}
#editor .ql-editor p { margin: 0 0 1.3rem; }
#editor .ql-editor h2 { font-weight: 600; font-size: 1.7rem; letter-spacing: -0.02em; margin: 1.8rem 0 0.6rem; }
#editor .ql-editor h3 { font-weight: 600; font-size: 1.35rem; margin: 1.5rem 0 0.5rem; }
#editor .ql-editor blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.4rem 0; padding: 0.2rem 0 0.2rem 1.2rem;
  color: var(--ink-soft); font-style: italic;
}
#editor .ql-editor pre.ql-syntax, #editor .ql-editor pre {
  background: #f6f3ec; border-radius: var(--radius-sm);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.9rem;
}
/* La bolla (toolbar) sopra la selezione */
.ql-bubble .ql-tooltip { border-radius: 999px; background: var(--ink); box-shadow: var(--shadow); }

/* --- Barra azioni dell'editor ------------------------------------------ */
.eh-editorbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: rgba(255, 254, 251, 0.85);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.eh-editorbar__hint { color: var(--muted); font-size: 0.85rem; }
.eh-editorbar__actions { margin-left: auto; display: flex; gap: 0.6rem; align-items: center; }

/* --- Pannello impostazioni di pubblicazione ----------------------------- */
.eh-settings {
  max-width: var(--measure);
  margin: 2.5rem auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.eh-settings__head {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.eh-settings__body { padding: 1.35rem; display: grid; gap: 1.25rem; }

.eh-field { display: grid; gap: 0.4rem; }
.eh-field__label { font-weight: 600; font-size: 0.88rem; color: var(--ink-soft); }
.eh-field__help { margin: 0; color: var(--muted); font-size: 0.82rem; }
.eh-field__error { margin: 0; color: var(--err-fg); font-size: 0.82rem; }
.eh-field--invalid .eh-control { border-color: var(--err-fg); box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12); }
.eh-req { color: var(--accent); }

.eh-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.eh-control:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.eh-control--select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a8378' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.eh-control--slug { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.88rem; }
.eh-control--sm { width: auto; padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.eh-control--select.eh-control--sm { padding-right: 1.85rem; }

/* Mini-form inline dentro una cella tabella (es. "segna come pubblicato"). */
.eh-cell-form { display: flex; align-items: center; gap: 0.4rem; }

.eh-form__errors {
  max-width: var(--measure); margin: 0 auto 1.25rem;
  padding: 0.85rem 1.1rem; border-radius: var(--radius-sm);
  background: var(--err-bg); color: var(--err-fg); list-style: none;
}

/* ==========================================================================
   Vista di lettura articolo
   ========================================================================== */
.eh-article { max-width: var(--measure); margin: 0 auto; }
.eh-article__kicker { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; color: var(--muted); font-size: 0.85rem; }
.eh-article__title {
  font-family: var(--serif); font-weight: 600;
  font-size: 2.8rem; line-height: 1.12; letter-spacing: -0.025em;
  margin: 0 0 0.75rem;
}
.eh-article__subtitle {
  font-family: var(--serif); font-weight: 400;
  font-size: 1.4rem; line-height: 1.4; color: var(--ink-soft);
  margin: 0 0 1.5rem;
}
.eh-article__toolbar { display: flex; gap: 0.6rem; padding: 1rem 0 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }

.eh-prose { font-family: var(--serif); font-size: 1.2rem; line-height: 1.8; color: var(--ink); }
.eh-prose > * + * { margin-top: 1.3rem; }
.eh-prose h2 { font-weight: 600; font-size: 1.8rem; letter-spacing: -0.02em; margin-top: 2.2rem; }
.eh-prose h3 { font-weight: 600; font-size: 1.4rem; margin-top: 1.8rem; }
.eh-prose blockquote { border-left: 3px solid var(--accent); padding-left: 1.2rem; color: var(--ink-soft); font-style: italic; }
.eh-prose a { text-decoration: underline; text-underline-offset: 2px; }
.eh-prose img { max-width: 100%; border-radius: var(--radius-sm); }
.eh-prose pre { background: #f6f3ec; padding: 1rem; border-radius: var(--radius-sm); overflow: auto; font-size: 0.9rem; }
.eh-prose code { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; }

.eh-prose[contenteditable="true"] { cursor: text; border-radius: var(--radius-sm); outline: 2px solid transparent; outline-offset: 8px; transition: outline-color .15s, background .15s; }
.eh-prose[contenteditable="true"]:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.eh-prose[contenteditable="true"]:focus { outline-color: var(--accent); background: color-mix(in srgb, var(--accent) 4%, transparent); }

.eh-prose-status {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  background: var(--ink); color: #fff; font-size: 0.85rem; line-height: 1;
  padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.eh-prose-status--visible { opacity: 1; transform: translateY(0); }
.eh-prose-status--error { background: var(--err-fg); }

/* --- Barra di formattazione fluttuante ---------------------------------- */
/* Compare sulla selezione, sia in anteprima (contenteditable) sia nell'editor. */
.eh-fmtbar {
  position: fixed; z-index: 60;
  display: flex; align-items: center; gap: 0.15rem;
  padding: 0.25rem;
  background: var(--ink); color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.eh-fmtbar[hidden] { display: none; }
.eh-fmtbar__sep { width: 1px; align-self: stretch; margin: 0.25rem 0.2rem; background: rgba(255, 255, 255, 0.22); }
.eh-fmtbar__btn {
  min-width: 1.9rem; height: 1.9rem;
  padding: 0 0.4rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 5px;
  color: inherit; font-family: var(--sans); font-size: 0.85rem; line-height: 1;
  cursor: pointer;
}
.eh-fmtbar__btn:hover { background: rgba(255, 255, 255, 0.14); }
.eh-fmtbar__btn.is-active { background: var(--accent); color: #fff; }
.eh-fmtbar__btn--bold { font-weight: 700; }
.eh-fmtbar__btn--italic { font-style: italic; font-family: var(--serif); }
.eh-fmtbar__btn--underline { text-decoration: underline; }
.eh-fmtbar__btn--strike { text-decoration: line-through; }
.eh-fmtbar__link { display: flex; align-items: center; gap: 0.15rem; margin-left: 0.25rem; }
.eh-fmtbar__link[hidden] { display: none; }
.eh-fmtbar__input {
  width: 15rem; height: 1.9rem;
  padding: 0 0.5rem;
  background: rgba(255, 255, 255, 0.12); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 5px;
  font-size: 0.85rem;
}
.eh-fmtbar__input::placeholder { color: rgba(255, 255, 255, 0.5); }
.eh-fmtbar__input:focus { outline: none; border-color: var(--accent); }

/* --- Metadati / tracciamento -------------------------------------------- */
.eh-meta-grid {
  max-width: var(--measure); margin: 2.5rem auto 0;
  display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.5rem;
  padding-top: 1.5rem; border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.eh-meta-grid dt { color: var(--muted); }
.eh-meta-grid dd { margin: 0; }

.eh-tracking { max-width: var(--measure); margin: 2.5rem auto 0; }
.eh-tracking h2 { font-family: var(--serif); font-weight: 600; font-size: 1.4rem; margin: 0 0 1rem; }

.eh-table {
  width: 100%; min-width: 42rem; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; font-size: 0.9rem;
}
.eh-table th, .eh-table td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.eh-table thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: color-mix(in srgb, var(--paper) 60%, var(--surface)); }
.eh-table tbody tr:last-child td { border-bottom: none; }

/* --- Paginazione -------------------------------------------------------- */
.eh-pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 2rem; color: var(--muted); font-size: 0.9rem; }

.eh-muted { color: var(--muted); }

/* --- Utente nell'header ------------------------------------------------- */
.eh-user { display: flex; align-items: center; gap: 0.7rem; }
.eh-user form { margin: 0; }
.eh-user__name {
  font-size: 0.9rem; font-weight: 500; color: var(--ink-soft);
  max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.eh-header--slim { justify-content: center; }
.eh-header--slim .eh-brand { font-size: 1.3rem; }

/* --- Pagine di autenticazione ------------------------------------------- */
.eh-main--auth { max-width: 27rem; margin-top: 3.5rem; }
.eh-auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.eh-auth-card__head { margin-bottom: 1.5rem; text-align: center; }
.eh-auth-card__head h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: 1.7rem; letter-spacing: -0.02em; margin: 0;
}
.eh-auth-card__sub { margin: 0.4rem 0 0; color: var(--muted); }
.eh-auth-form { display: grid; gap: 1.1rem; }
.eh-button--block { width: 100%; justify-content: center; padding: 0.7rem 1rem; margin-top: 0.25rem; }
.eh-auth-alt { text-align: center; margin: 1.25rem 0 0; color: var(--muted); font-size: 0.92rem; }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
  .editor-title, .eh-article__title { font-size: 2rem; }
  .editor-subtitle, .eh-article__subtitle { font-size: 1.2rem; }
  #editor .ql-editor, .eh-prose { font-size: 1.1rem; }
  .eh-meta-grid { grid-template-columns: 1fr; }

  /* Nav: menu a tendina dietro l'hamburger invece di sparire o schiacciarsi.
     Header ridotto a marchio + hamburger; link, lingua e utente si spostano
     tutti dentro il pannello, che riprende un box vero (non più display:contents). */
  .eh-nav-toggle { display: inline-flex; order: 1; margin-left: auto; }
  .eh-nav {
    order: 10;
    flex-basis: 100%;
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 0;
    margin-top: 0.65rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--line);
  }
  .eh-nav.is-open { display: flex; }
  .eh-nav .eh-spacer { display: none; }
  .eh-nav a {
    margin-right: 0;
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--line);
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  }
  .eh-nav a.is-active { border-left-color: var(--accent); border-bottom-color: var(--line); background: var(--surface); }

  /* Lingua e utente, spostati dentro il pannello: stessa riga di rispetto dei link. */
  .eh-nav .eh-lang, .eh-nav .eh-user {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--line);
  }
  .eh-nav .eh-lang { gap: 0.6rem; }
  .eh-nav .eh-lang__label { display: inline; color: var(--ink-soft); font-size: 0.94rem; font-weight: 500; }
  .eh-nav .eh-user { border-bottom: none; justify-content: space-between; }
  .eh-nav .eh-user__name { max-width: none; }
}

/* ==========================================================================
   Dashboard e liste di pubblicazione (code editoriali)
   ========================================================================== */
.eh-tracking--wide { max-width: var(--wide); }
.eh-section-hint { margin: -0.4rem 0 1rem; font-size: 0.9rem; }

.eh-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  margin: 0 0 2rem;
}
.eh-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.eh-stat__num { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; color: var(--ink); }
.eh-stat__label { font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.eh-subhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.eh-subhead h2 { margin: 0; }

.eh-table-scroll { overflow-x: auto; }

/* Badge cliccabile (link) nella matrice: eredita lo stile badge. */
a.eh-badge:hover { text-decoration: none; filter: brightness(0.97); }
.eh-badge--neutral, .eh-badge--draft { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Card statica (non link): usata per le code in dashboard. */
.eh-card--static { cursor: default; }
.eh-card--static:hover { border-color: var(--line); box-shadow: var(--shadow-sm); }
.eh-card__title-link { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--ink); }
.eh-card__title-link:hover { color: var(--accent); text-decoration: none; }

.eh-queue { margin: 0.75rem 0 0; padding-left: 1.3rem; display: grid; gap: 0.45rem; }
.eh-queue li { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.eh-lead { max-width: var(--measure); color: var(--ink-soft); font-size: 1.05rem; margin: 0 0 1.5rem; }

/* Pannello impostazioni usato come form autonomo (liste). */
.eh-settings--standalone { max-width: var(--measure); margin: 2rem auto 0; }
.eh-inline-form { display: grid; gap: 1rem; }
.eh-field--check { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; }
.eh-field--check .eh-field__label { margin: 0; }
.eh-form__actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.5rem; }
.eh-form__errors {
  list-style: none; margin: 0 0 1.25rem; padding: 0.8rem 1rem;
  background: var(--err-bg); color: var(--err-fg);
  border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}

@media (max-width: 720px) {
  .eh-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   Rilevamento testo-AI (Pangram)
   ========================================================================== */
.eh-ai { max-width: var(--measure); margin: 2.5rem auto 0; }
.eh-ai .eh-subhead h2 { font-family: var(--serif); font-weight: 600; font-size: 1.4rem; }
.eh-ai .eh-subhead form { margin: 0; }
.eh-ai__pending {
  margin: 0.25rem 0 0; padding: 0.7rem 1rem;
  background: var(--warn-bg); color: var(--warn-fg);
  border-radius: var(--radius-sm); font-size: 0.9rem;
}

.eh-ai-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1.35rem; margin-top: 0.5rem;
}
.eh-ai-card__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 0.9rem; margin-bottom: 1.1rem; }
.eh-ai-verdict {
  font-family: var(--serif); font-weight: 600; font-size: 1.05rem;
  padding: 0.15rem 0.7rem; border-radius: 999px;
  background: var(--neutral-bg); color: var(--neutral-fg); white-space: nowrap;
}
.eh-ai-verdict--ai { background: var(--err-bg); color: var(--err-fg); }
.eh-ai-verdict--human { background: var(--ok-bg); color: var(--ok-fg); }
.eh-ai-verdict--mixed { background: var(--warn-bg); color: var(--warn-fg); }
.eh-ai-card__detail { margin: 0; color: var(--ink-soft); font-size: 0.95rem; overflow-wrap: anywhere; }

.eh-ai-bar {
  display: flex; height: 12px; border-radius: 999px;
  overflow: hidden; background: var(--neutral-bg);
}
.eh-ai-bar__seg { height: 100%; }
.eh-ai-bar__seg--ai { background: var(--err-fg); }
.eh-ai-bar__seg--assisted { background: var(--warn-fg); }
.eh-ai-bar__seg--human { background: var(--ok-fg); }

.eh-ai-legend { display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; margin: 0.85rem 0 0; padding: 0; list-style: none; font-size: 0.85rem; color: var(--ink-soft); }
.eh-ai-legend li { display: flex; align-items: center; gap: 0.4rem; }
.eh-ai-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.eh-ai-swatch--ai { background: var(--err-fg); }
.eh-ai-swatch--assisted { background: var(--warn-fg); }
.eh-ai-swatch--human { background: var(--ok-fg); }

.eh-ai-card__foot {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem;
  margin-top: 1.1rem; padding-top: 0.85rem; border-top: 1px solid var(--line);
  font-size: 0.82rem; color: var(--muted);
}
.eh-ai-history { margin-top: 1.25rem; }
.eh-ai-history summary { cursor: pointer; color: var(--ink-soft); font-size: 0.9rem; padding: 0.3rem 0; }

/* Badge verdetto AI nel kicker/lista */
.eh-ai-badge--ai { background: var(--err-bg); color: var(--err-fg); }
.eh-ai-badge--human { background: var(--ok-bg); color: var(--ok-fg); }
.eh-ai-badge--mixed { background: var(--warn-bg); color: var(--warn-fg); }
a.eh-ai-badge:hover { text-decoration: none; filter: brightness(0.97); }

/* --- Dettaglio per paragrafo (windows di Pangram) ----------------------- */
.eh-ai-segments { margin-top: 1.1rem; }
.eh-ai-segments > summary { cursor: pointer; color: var(--ink-soft); font-size: 0.9rem; padding: 0.3rem 0; }
.eh-seg-list { list-style: none; margin: 0.7rem 0 0; padding: 0; display: grid; gap: 0.7rem; }
.eh-seg { border-left: 3px solid var(--line-strong); padding: 0.4rem 0 0.4rem 0.9rem; }
.eh-seg--ai { border-color: var(--err-fg); }
.eh-seg--human { border-color: var(--ok-fg); }
.eh-seg--mixed { border-color: var(--warn-fg); }
.eh-seg__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.65rem; margin-bottom: 0.3rem; font-size: 0.78rem; }
.eh-seg__score { font-weight: 700; }
.eh-seg--ai .eh-seg__score { color: var(--err-fg); }
.eh-seg--human .eh-seg__score { color: var(--ok-fg); }
.eh-seg--mixed .eh-seg__score { color: var(--warn-fg); }
.eh-seg__label { color: var(--ink-soft); }
.eh-seg__conf { color: var(--muted); }
.eh-seg__text { margin: 0; font-family: var(--serif); font-size: 0.95rem; line-height: 1.55; color: var(--ink-soft); overflow-wrap: anywhere; }

/* --- Evidenziazione AI sui paragrafi reali dell'articolo ----------------- */
/* Attiva solo col toggle: aggiunge un tint di sfondo al paragrafo abbinato a un
   segmento Pangram, con un chip della percentuale. `box-decoration-break: clone`
   fa sì che il tint segua il testo anche su più righe. */
.eh-prose--highlight .eh-hl {
  border-radius: 5px;
  padding: 0.12rem 0.4rem;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: background 0.15s ease;
}
.eh-prose--highlight .eh-hl--ai { background: var(--err-bg); }
.eh-prose--highlight .eh-hl--mixed { background: var(--warn-bg); }
.eh-prose--highlight .eh-hl--human { background: var(--ok-bg); }
.eh-prose--highlight .eh-hl[data-aipct]::after {
  content: "AI " attr(data-aipct);
  display: inline-block;
  margin-left: 0.5rem;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.4;
  padding: 0.02rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
  background: rgba(26, 23, 18, 0.07);
  color: var(--ink-soft);
}
.eh-prose--highlight .eh-hl--ai[data-aipct]::after { background: color-mix(in srgb, var(--err-fg) 16%, transparent); color: var(--err-fg); }
.eh-prose--highlight .eh-hl--human[data-aipct]::after { background: color-mix(in srgb, var(--ok-fg) 16%, transparent); color: var(--ok-fg); }

/* --- Editor: toolbar snow integrata nella barra sticky ------------------- */
.eh-editorbar { flex-wrap: wrap; }
/* Rimuovo i bordi di Quill snow per preservare il canvas pulito "Substack". */
.eh-editorbar .ql-toolbar.ql-snow { border: none; padding: 0; }
.eh-toolbar.ql-snow .ql-formats { margin-right: 0.7rem; }
.eh-editor .ql-container.ql-snow { border: none; font-family: var(--serif); }
/* Stati attivi/hover coerenti con l'accento del tema. */
.ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar .ql-picker-label:hover .ql-stroke { stroke: var(--accent); }
.ql-snow .ql-toolbar button.ql-active .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent); }
.ql-snow .ql-toolbar button.ql-active .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }
.ql-snow.ql-toolbar button:hover, .ql-snow.ql-toolbar button.ql-active { color: var(--accent); }
/* Il popover del link deve stare sopra la barra sticky. */
.ql-snow .ql-tooltip { z-index: 30; }

/* ==========================================================================
   Robustezza layout: niente testo che sfora (URL/parole lunghe, tabelle)
   ========================================================================== */
body { overflow-wrap: break-word; }
/* Gli item di grid non si restringono sotto il contenuto se non azzeri min-width:
   senza questo, un URL lungo nel canonico sfonda la griglia dei metadati. */
.eh-meta-grid dd { min-width: 0; overflow-wrap: anywhere; }
.eh-meta-grid dd a { overflow-wrap: anywhere; }
.eh-prose { overflow-wrap: break-word; }
.eh-prose a { overflow-wrap: anywhere; }
.eh-card__title, .eh-card__excerpt, .eh-card__title-link { overflow-wrap: break-word; }
.eh-table td, .eh-table th { overflow-wrap: anywhere; }
.eh-queue li a { overflow-wrap: anywhere; min-width: 0; }

/* Header e intestazioni di pagina: su schermi stretti vanno a capo invece di
   sforare in orizzontale. */
.eh-page-head { flex-wrap: wrap; }
@media (max-width: 640px) {
  .eh-header { flex-wrap: wrap; gap: 0.6rem 1rem; padding: 0.7rem 1rem; }
}
