:root {
  --bg: #fbf2f1;
  --surface: #fffcfa;
  --text: #1f181a;
  --muted: #74656a;
  --line: #eedbd9;
  --accent: #86651a;
  --accent-text: #1d1708;
  --accent-soft: #fbe6ec;
  --pink: #b0436e;
  --gold-line: #c9a653;
  --gold-grad: linear-gradient(135deg, #e3c87f 0%, #c39f48 50%, #e6cd8a 100%);
  --rose-line: linear-gradient(90deg, #c9a653, #e39ab5, #c9a653);
  --danger: #a3261e;
  --bubble: #f9e4ea;
  --shadow: 0 1px 2px rgba(29, 26, 20, 0.04), 0 8px 28px rgba(29, 26, 20, 0.06);
  --radius: 6px;
  --pill: 3px;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  /* il sito supporta sia il chiaro sia lo scuro: i browser non devono scurirlo da soli */
  color-scheme: light dark;
}

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

/* Tema scuro: segue il sistema, salvo scelta esplicita nel sito (data-theme sull'elemento html). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100b0d;
    --surface: #1a1316;
    --text: #f5ecee;
    --muted: #b09ea4;
    --line: #35262c;
    --accent: #d9b866;
    --accent-soft: #331c26;
    --pink: #f0a3bf;
    --gold-line: #8f7535;
    --danger: #ff8a80;
    --bubble: #2c1b23;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #100b0d;
  --surface: #1a1316;
  --text: #f5ecee;
  --muted: #b09ea4;
  --line: #35262c;
  --accent: #d9b866;
  --accent-soft: #331c26;
  --pink: #f0a3bf;
  --gold-line: #8f7535;
  --danger: #ff8a80;
  --bubble: #2c1b23;
  --shadow: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

h1,
h2,
p {
  margin: 0;
}

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

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

/* Quando un input file nascosto ha il focus, evidenzia la sua etichetta */
input[type="file"]:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.name {
  font-weight: 600;
}

a.name:hover {
  text-decoration: underline;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: 0.01em;
}

.logo {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

/* Simbolo del logo (specchio con la E) accanto al nome */
.topbar .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 7px;
}

/* Logo chiaro o scuro secondo il tema (stesse regole delle variabili dei colori) */
.logo-mark.logo-dark {
  display: none;
}

:root[data-theme="dark"] .logo-mark.logo-dark {
  display: block;
}

:root[data-theme="dark"] .logo-mark.logo-light {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-mark.logo-dark {
    display: block;
  }

  :root:not([data-theme="light"]) .logo-mark.logo-light {
    display: none;
  }
}

.logo-mark.big {
  width: 88px;
  height: 88px;
  margin: 0 auto 14px;
  border-radius: 18px;
}

@media (min-width: 860px) {
  .logo-mark.big {
    margin-left: 0;
  }
}

.logo.big {
  /* compensa la spaziatura dopo l'ultima lettera, così resta centrato */
  padding-left: 0.32em;
  font-size: clamp(1.75rem, 7vw, 3rem);
  line-height: 1.2;
}

.logo.big::after {
  content: "";
  display: block;
  width: 72px;
  height: 1px;
  margin: 18px auto 0;
  background: var(--rose-line);
}

/* ---------- Controlli ---------- */

input,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus,
textarea:focus {
  border-color: var(--gold-line);
}

textarea {
  resize: vertical;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin: 0;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--gold-line);
}

.btn.primary {
  border-color: var(--gold-line);
  background: var(--gold-grad);
  color: var(--accent-text);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.small {
  min-height: 34px;
  padding: 4px 14px;
  font-size: 0.75rem;
}

.btn.wide {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--pink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.link:hover {
  text-decoration: underline;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chips,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.tab {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.chip:hover,
.tab:hover {
  color: var(--text);
}

.chip.on,
.tab.on {
  border-color: var(--pink);
  background: var(--accent-soft);
  color: var(--pink);
}

.badge {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--gold-grad);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.empty {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Avatar ---------- */

.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  box-shadow: 0 0 0 1px var(--surface), 0 0 0 2px var(--gold-line);
}

.avatar.sm {
  width: 32px;
  height: 32px;
  font-size: 0.875rem;
}

.avatar.lg {
  width: 96px;
  height: 96px;
  font-size: 2.25rem;
}

.avatar-empty {
  background: var(--accent-soft);
  color: var(--pink);
  font-family: var(--serif);
  font-weight: 400;
}

/* ---------- Accesso ---------- */

.auth {
  display: grid;
  gap: 32px;
  align-content: center;
  max-width: 420px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 16px;
}

.auth-intro {
  text-align: center;
}

.auth-about h2 {
  font-size: 1.25rem;
}

.auth-about p {
  margin-top: 6px;
  color: var(--muted);
}

.auth-about .plan-list {
  margin-top: 10px;
}

/* Su schermi larghi: presentazione a sinistra, modulo a destra. */
@media (min-width: 860px) {
  .auth {
    grid-template-columns: 1fr 400px;
    grid-template-areas: "lang lang" "intro form" "about form" "settings settings";
    column-gap: 56px;
    max-width: 920px;
  }

  .auth-intro {
    grid-area: intro;
    align-self: end;
    text-align: left;
  }

  .auth-intro .logo.big {
    padding-left: 0;
  }

  .auth-intro .logo.big::after {
    margin-left: 0;
  }

  .auth-about {
    grid-area: about;
    align-self: start;
  }

  .auth > .card {
    grid-area: form;
    align-self: center;
  }
}

.auth-intro p {
  margin-top: 8px;
  color: var(--muted);
}

.auth-card {
  padding: 32px 28px;
  border-top: 2px solid var(--gold-line);
}

.auth-card h2 {
  font-size: 1.5rem;
  text-align: center;
}

.auth-card .btn {
  margin-top: 20px;
}

.hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  font-weight: 400;
  line-height: 1.4;
}

.check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--pink);
}

/* ---------- Protezione delle immagini ---------- */

img {
  -webkit-user-drag: none;
  -webkit-touch-callout: none; /* niente menu "Salva immagine" con la pressione lunga */
  user-select: none;
}

.protected {
  position: relative;
  overflow: hidden;
  user-select: none;
}

.protected img {
  pointer-events: none;
}

/* Strato sopra la foto: riceve clic e tocchi al posto dell'immagine e porta la filigrana. */
.shield {
  position: absolute;
  inset: -20%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  gap: 12px;
  transform: rotate(-24deg);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  opacity: 0.2;
  text-shadow: 0 0 2px #000;
  white-space: nowrap;
}

/* Le foto non si stampano e non finiscono nei PDF. */
@media print {
  img,
  .protected,
  .avatar {
    visibility: hidden !important;
  }
}

/* ---------- Segnalazioni, blocco, amministrazione ---------- */

select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.action.report {
  margin-left: auto;
  font-size: 0.8125rem;
}

.remove + .action.report {
  margin-left: 0;
}

.report-link {
  margin-left: 10px;
  font-size: 0.8125rem;
  font-weight: 400;
}

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

.report-box:empty {
  display: none;
}

.report-box {
  flex-basis: 100%;
  margin-top: 8px;
}

.report-box.padded {
  margin: 0;
  padding: 0 16px 16px;
}

.report-form {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.report-form .form-buttons {
  margin-top: 4px;
}

.profile-safety {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 0.875rem;
}

.section-title {
  margin: 28px 0 8px;
  font-size: 1.25rem;
}

.report-card {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.report-card .plan-current {
  margin: 0;
}

.report-image {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--pill);
}

.report-text {
  padding: 10px 12px;
  border-left: 2px solid var(--line);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.price-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.price-row {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  align-items: center;
  gap: 10px;
}

.price-row label {
  margin: 0;
}

.currency-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.currency-picker label {
  margin: 0;
  color: var(--muted);
}

.currency-select {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  font-size: 0.875rem;
}

@media (max-width: 480px) {
  .price-row {
    grid-template-columns: 1fr auto;
  }

  .price-row label {
    grid-column: 1 / -1;
  }
}

/* ---------- Termini e condizioni ---------- */

.terms h2 {
  margin-top: 22px;
  font-size: 1.125rem;
}

.terms p {
  margin-top: 8px;
}

.terms ul {
  margin: 8px 0 0;
  padding-left: 22px;
}

.terms li {
  margin-top: 4px;
}

.terms-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 24px;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.terms-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.site-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px 32px;
  font-size: 0.875rem;
  text-align: center;
}

/* Classifica delle più amate (Home) */
.ranking {
  margin-bottom: 16px;
  padding: 16px;
}

.ranking-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.ranking-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: var(--radius);
}

.ranking-pos {
  flex: none;
  width: 24px;
  font-family: var(--serif);
  font-size: 1.125rem;
  text-align: center;
  color: var(--muted);
}

.rank-1 .ranking-pos,
.rank-2 .ranking-pos,
.rank-3 .ranking-pos {
  color: var(--accent);
  font-weight: 700;
}

.rank-1 {
  background: var(--accent-soft);
}

.ranking-user {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
}

.ranking-user .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-likes {
  flex: none;
  color: var(--pink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ranking-more {
  display: inline-block;
  margin-top: 10px;
}

/* Home: classifica in colonna a sinistra sugli schermi larghi */
@media (min-width: 1000px) {
  .shell:has(.home-layout) .topbar-inner,
  .shell:has(.home-layout) .content {
    max-width: 1040px;
  }

  .home-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }

  /* resta visibile dall'alto al basso mentre si scorre il feed */
  .home-side {
    position: sticky;
    top: 72px; /* altezza della barra in alto + spazio */
    max-height: calc(100vh - 88px);
    overflow-y: auto;
  }

  .home-side .ranking {
    margin-bottom: 0;
  }
}

/* Menu a tendina per lingua, tema e vista */
.setting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.setting-select {
  min-height: 34px;
  padding: 4px 30px 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.setting-select:hover {
  border-color: var(--gold-line);
}

/* Pagina iniziale: lingua in alto a destra, tema e vista su una riga in fondo (anche con il layout a due colonne) */
.auth .lang-picker {
  justify-content: flex-end;
}

@media (min-width: 860px) {
  .auth .lang-picker {
    grid-area: lang;
  }

  .auth .auth-settings {
    grid-area: settings;
  }
}

.site-footer > .link {
  display: block;
  margin: 0 auto;
}

.site-footer .lang-picker,
.site-footer .display-picker {
  display: inline-flex;
  margin: 12px 10px 0;
  vertical-align: middle;
}

/* Tema e vista */
.display-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-top: 12px;
}

.setting-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.setting-label {
  margin-right: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-settings {
  margin-top: 24px;
  padding-bottom: 24px;
}

/* Su un telefono o tablet vero l'anteprima non serve. */
@media (max-width: 799px) {
  .view-picker {
    display: none;
  }
}

/* Anteprima tablet / cellulare */
.device-preview {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.device-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.device-stage {
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
}

.device-frame {
  box-sizing: content-box; /* la misura del dispositivo è quella dello schermo, il bordo è in più */
  max-width: calc(100% - 20px);
  max-height: calc(100vh - 140px);
  border: 10px solid var(--line);
  border-radius: 28px;
  background: var(--bg);
}

.device-tablet .device-frame {
  border-radius: 20px;
}

/* Scelta della lingua */
.lang-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.auth .lang-picker {
  justify-content: flex-end;
}

.site-footer .lang-picker {
  margin-top: 12px;
}

/* ---------- Piani ---------- */

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.plan {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.plan.featured {
  border-color: var(--gold-line);
  border-top-width: 2px;
}

.plan h2 {
  font-size: 1.375rem;
}

.plan-price {
  margin-top: 4px;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.75rem;
}

.plan-list {
  flex: 1;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.plan-list li {
  position: relative;
  padding: 6px 0 6px 24px;
  font-size: 0.9375rem;
}

.plan-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--pink);
  font-weight: 700;
}

.plan-action {
  margin-top: 20px;
}

.plan-lifetime {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.25rem;
}

.plan-limits {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.post-closed {
  padding: 6px 8px;
}

.profile-actions .muted {
  flex-basis: 100%;
}

.plan-current {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.plan-notice,
.plan-note {
  color: var(--muted);
  font-size: 0.9375rem;
}

.plan-note {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-left: 2px solid var(--pink);
  background: var(--accent-soft);
  color: var(--text);
}

.hint.center {
  margin-top: 10px;
  text-align: center;
}

.recovery {
  width: 100%;
}

.recovery-text {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.recovery-code {
  margin: 18px 0 4px;
  padding: 16px 12px;
  border: 1px dashed var(--gold-line);
  border-radius: var(--pill);
  background: var(--accent-soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  overflow-wrap: anywhere;
  user-select: all;
}

.form-error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
}

.form-error:empty {
  display: none;
}

.switch {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9375rem;
  text-align: center;
}

/* ---------- Struttura ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 22px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar nav a {
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  color: var(--muted);
}

.topbar nav a:hover,
.topbar nav a.active {
  color: var(--text);
}

.topbar nav a.active {
  border-bottom-color: var(--gold-line);
}

.topbar nav .link {
  letter-spacing: inherit;
  text-transform: inherit;
}

.topbar::after {
  content: "";
  display: block;
  height: 1px;
  background: var(--rose-line);
}

.content {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.page-title {
  margin-bottom: 16px;
  font-size: 1.5rem;
}

/* ---------- Bacheca e post ---------- */

.composer {
  padding: 16px;
}

.composer textarea {
  border: 0;
  padding: 4px;
  background: transparent;
}

.composer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.composer-category {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.composer-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.preview {
  display: grid;
  gap: 8px;
  justify-items: start;
  margin-top: 8px;
}

.preview img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
}

.feed-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 16px;
}

.post-list {
  display: grid;
  gap: 16px;
}

.post-list + .empty + .btn {
  margin-top: 16px;
}

.post {
  overflow: hidden;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.post-who {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.tag {
  flex: none;
  padding: 2px 10px;
  border: 1px solid currentColor;
  border-radius: var(--pill);
  flex: 0 1 auto;
  max-width: 45%;
  background: var(--accent-soft);
  color: var(--pink);
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.post-image {
  display: block;
  width: 100%;
  max-height: 720px;
  background: var(--bubble);
  object-fit: cover;
}

.post-text {
  padding: 12px 16px 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.post-actions {
  display: flex;
  gap: 4px;
  padding: 8px;
}

.action {
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--pill);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.action:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.action.liked {
  color: var(--pink);
}

.post-actions {
  flex-wrap: wrap;
}

.remove {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-left: auto;
}

.remove-ask {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.875rem;
}

.action.danger {
  color: var(--danger);
  border: 1px solid currentColor;
}

.comments {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

.comment-list {
  display: grid;
  gap: 12px;
}

.comment-list:not(:empty) {
  margin-bottom: 12px;
}

.comment {
  display: flex;
  gap: 10px;
}

.comment p {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

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

.inline-form input {
  flex: 1;
  min-width: 0;
  border-radius: var(--pill);
}

/* ---------- Profilo ---------- */

.profile {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px;
}

.profile-info {
  flex: 1;
  min-width: 220px;
}

.profile-info h1 {
  font-size: 1.5rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.bio {
  margin-top: 8px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 12px;
  color: var(--muted);
}

.stat-link {
  text-decoration: underline;
  text-decoration-color: var(--gold-line);
  text-underline-offset: 3px;
}

.stat-link:hover {
  color: var(--text);
}

.stats strong {
  color: var(--text);
}

.profile-actions,
.form-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.edit-form {
  width: 100%;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ---------- Elenchi di persone ---------- */

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.user-row:hover {
  border-color: var(--accent);
}

.user-row-text {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.user-row-text .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row.request {
  flex-wrap: wrap;
}

.user-row.request:hover {
  border-color: var(--line);
}

.request-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.user-row .time {
  flex: none;
}

/* ---------- Conversazione ---------- */

.thread {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 360px;
  padding: 16px;
}

.thread-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.thread-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thread-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
  overflow-y: auto;
}

.bubble {
  align-self: flex-start;
  max-width: 78%;
  padding: 8px 14px;
  border-radius: 18px 18px 18px 4px;
  background: var(--bubble);
}

.bubble.mine {
  align-self: flex-end;
  border-radius: 18px 18px 4px 18px;
  background: var(--gold-grad);
  color: var(--accent-text);
}

.bubble p {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.bubble .time {
  display: block;
  font-size: 0.6875rem;
  opacity: 0.75;
  text-align: right;
}

/* ---------- Avvisi ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border: 1px solid var(--gold-line);
  border-radius: var(--pill);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9375rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  #toast {
    transition: none;
  }
}

@media (max-width: 480px) {
  /* Su telefono il menu resta su una riga e scorre di lato. */
  .topbar nav {
    flex-wrap: nowrap;
    width: 100%;
    gap: 18px;
    font-size: 0.875rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .topbar nav::-webkit-scrollbar {
    display: none;
  }

  .topbar nav > * {
    flex: none;
    white-space: nowrap;
  }

  .profile {
    padding: 16px;
  }
}
