/* ============ Piazza — dual-accent dark ============ */
:root {
  --bg: #12121a;
  --surface: #1a1b26;
  --surface2: #22242f;
  --line: #2e3040;
  --text: #e7e7ef;
  --muted: #8b8da3;
  --acc-v: #a78bfa;   /* violet: thread, identità, link */
  --acc-g: #4ee1a0;   /* verde: spark, upvote */
  --danger: #f87171;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --radius: 12px;
  --topbar-h: 54px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--acc-v); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
:focus-visible { outline: 2px solid var(--acc-v); outline-offset: 2px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-left));
  height: var(--topbar-h); flex: none;
  background: rgba(18,18,26,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 18px; letter-spacing: -.02em; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 16px; height: 16px; border-radius: 5px;
  background: linear-gradient(135deg, var(--acc-v), var(--acc-g));
}
.topnav { display: flex; align-items: center; gap: 12px; }
.topnav .me { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.topnav .me a { color: var(--text); }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: 240px minmax(0, 660px);
  gap: 28px; max-width: 960px; margin: 0 auto;
  padding: 24px max(20px, env(safe-area-inset-right)) 80px max(20px, env(safe-area-inset-left));
}
/* sticky ma scrollabile: se il menu supera l'altezza della finestra il fondo
   deve restare raggiungibile (prima l'elemento restava fermo e il resto
   spariva sotto il bordo). */
.sidebar {
  position: sticky; top: calc(var(--topbar-h) + 24px); align-self: start;
  max-height: calc(100vh - var(--topbar-h) - 40px);
  max-height: calc(100dvh - var(--topbar-h) - 40px);
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; padding-right: 4px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.main { min-width: 0; }

/* ---------- sidebar ---------- */
.side-title {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); margin: 18px 0 8px;
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 14px;
}
.side-link:hover { background: var(--surface); text-decoration: none; }
.side-link.active { background: var(--surface2); }
.c-avatar {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 700; color: #0e0e14;
  background: linear-gradient(135deg, var(--acc-v), var(--acc-g));
}
.side-link .members { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 600;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface2); border-color: var(--muted); }
.btn.primary { background: var(--acc-v); border-color: var(--acc-v); color: #14101f; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface); }
.btn.small { padding: 4px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- composer ---------- */
.composer {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
}
.composer .tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.tab.active-spark { border-color: var(--acc-g); color: var(--acc-g); }
.tab.active-thread { border-color: var(--acc-v); color: var(--acc-v); }
.composer input[type=text], .composer textarea, .composer select,
.form input, .form textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; margin-bottom: 10px;
}
.composer textarea { resize: vertical; min-height: 64px; }
.composer .row { display: flex; align-items: center; gap: 10px; }
.composer select { width: auto; margin: 0; }
.charcount { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-left: auto; }
.charcount.over { color: var(--danger); }

/* ---------- feed ---------- */
.sortbar { display: flex; gap: 6px; margin-bottom: 14px; }
.sortbar .tab.on { border-color: var(--text); color: var(--text); }

.post {
  display: flex; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
  border-left: 3px solid var(--line);
}
.post.kind-spark  { border-left-color: var(--acc-g); }
.post.kind-thread { border-left-color: var(--acc-v); }

.votecol { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; width: 34px; }
.vote {
  background: none; border: none; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 4px; border-radius: 6px;
}
.vote:hover { background: var(--surface2); color: var(--text); }
.vote.up.on { color: var(--acc-g); }
.vote.down.on { color: var(--danger); }
.score { font-family: var(--mono); font-size: 13px; font-weight: 700; }

.post-body { min-width: 0; flex: 1; }
.post-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 5px;
}
.post-meta a { color: var(--muted); }
.post-meta a:hover { color: var(--text); }
.kindtag { letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
.kindtag.spark { color: var(--acc-g); }
.kindtag.thread { color: var(--acc-v); }
.ctag { color: var(--acc-v) !important; }

.post-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; }
.post-title a { color: var(--text); }
.post-text { white-space: pre-wrap; word-wrap: break-word; color: var(--text); }
.post-text.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.post-actions { display: flex; gap: 14px; margin-top: 9px; font-family: var(--mono); font-size: 12px; }
.post-actions a, .post-actions button {
  color: var(--muted); background: none; border: none; padding: 0; font-family: var(--mono); font-size: 12px;
}
.post-actions a:hover, .post-actions button:hover { color: var(--text); text-decoration: none; }

/* ---------- comments ---------- */
.comment { margin-top: 14px; padding-left: 14px; border-left: 2px solid var(--line); }
.comment .post-meta { margin-bottom: 3px; }
.comment-body { white-space: pre-wrap; word-wrap: break-word; }
.comment .children { margin-left: 6px; }
.replybox textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px; margin: 8px 0; resize: vertical; min-height: 56px;
}
.inline-vote { display: inline-flex; align-items: center; gap: 4px; }
.inline-vote .vote { font-size: 13px; padding: 2px 4px; }
.inline-vote .score { font-size: 12px; }

/* ---------- forms / pages ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
}
.card h1 { font-size: 20px; letter-spacing: -.02em; margin-bottom: 14px; }
.card h2 { font-size: 16px; margin-bottom: 10px; }
.form label { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.form .err { color: var(--danger); font-size: 13px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }

.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 22px; letter-spacing: -.02em; }
.page-head .desc { color: var(--muted); margin-top: 4px; }
.page-head .stats { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 6px; }
.page-head .stats b { color: var(--acc-g); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-family: var(--mono); font-size: 13px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; z-index: 50;
}

/* ---------- responsive ---------- */
@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; padding: 16px 12px 80px; }
  .sidebar { position: static; order: 2; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============ v2: social ============ */

/* avatars */
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar.sm { width: 24px; height: 24px; }
.avatar.lg { width: 84px; height: 84px; border: 3px solid var(--bg); }
.avatar-fallback {
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--acc-v), var(--acc-g));
  color: #0e0e14; font-weight: 800; font-family: var(--mono);
}
.avatar-fallback.sm { font-size: 11px; }
.avatar-fallback.lg { font-size: 32px; }
.nav-me { display: flex; align-items: center; gap: 8px; }
.nav-me:hover { text-decoration: none; }
.meta-avatar { display: inline-flex; }
.meta-name { color: var(--text) !important; font-weight: 700; font-family: var(--sans); font-size: 13px; }

/* scope (Seguiti / Esplora) */
.scopebar { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.scope {
  flex: 1; background: none; border: none; color: var(--muted);
  font-weight: 700; font-size: 14px; padding: 10px 0;
  border-bottom: 2px solid transparent;
}
.scope.on { color: var(--text); border-bottom-color: var(--acc-v); }
.scope:hover { color: var(--text); }

/* like */
.likerow { display: inline-flex; align-items: center; gap: 5px; }
.like { background: none; border: none; font-size: 15px; padding: 2px 4px; border-radius: 6px; }
.like:hover { background: var(--surface2); }
.likerow .score { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--muted); }
.likerow .like.on + .score { color: var(--acc-g); }

/* media nel post */
.post-media { display: grid; gap: 6px; margin-top: 10px; border-radius: 10px; overflow: hidden; }
.post-media.n1 { grid-template-columns: 1fr; }
.post-media.n2, .post-media.n4 { grid-template-columns: 1fr 1fr; }
.post-media.n3 { grid-template-columns: 1fr 1fr 1fr; }
.post-media img {
  width: 100%; max-height: 420px; object-fit: cover; display: block;
  background: var(--surface2); cursor: zoom-in; border-radius: 8px;
}
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.88);
  display: grid; place-items: center; cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 8px; }

/* composer: anteprime */
.cp-previews { display: flex; gap: 8px; flex-wrap: wrap; }
.cp-prev { position: relative; }
.cp-prev img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.cp-prev button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%; border: none;
  background: var(--surface2); color: var(--text); font-size: 10px; line-height: 1;
}

/* stories bar */
.stories-bar {
  display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px;
  scrollbar-width: thin;
}
.story-circle {
  background: none; border: none; display: flex; flex-direction: column;
  align-items: center; gap: 5px; flex: none; position: relative; width: 66px;
}
.story-circle .ring {
  width: 58px; height: 58px; border-radius: 50%; padding: 3px;
  background: linear-gradient(135deg, var(--acc-v), var(--acc-g));
  display: grid; place-items: center;
}
.story-circle .ring.plain { background: var(--line); }
.story-circle .ring .avatar { width: 100%; height: 100%; border: 2px solid var(--bg); }
.story-name {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.story-plus {
  position: absolute; bottom: 18px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--acc-g); color: #0e0e14; font-weight: 800;
  display: grid; place-items: center; font-size: 14px; line-height: 1;
  border: 2px solid var(--bg);
}

/* story viewer */
.story-viewer {
  position: fixed; inset: 0; z-index: 90; background: rgba(8,8,12,.94);
  display: grid; place-items: center;
}
.sv-frame {
  position: relative; width: min(440px, 96vw); height: min(88vh, 780px);
  background: var(--surface); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
}
.sv-bars { display: flex; gap: 4px; padding: 10px 12px 0; }
.sv-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.sv-bar.done { background: var(--muted); }
.sv-bar.on { background: linear-gradient(90deg, var(--acc-v), var(--acc-g)); }
.sv-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; font-size: 13px; z-index: 2;
}
.sv-head .mono { font-size: 11px; }
.sv-close, .sv-del {
  background: none; border: none; color: var(--muted); font-size: 15px; padding: 4px 6px;
}
.sv-close { margin-left: auto; }
.sv-del { margin-left: auto; }
.sv-del + .sv-close { margin-left: 0; }
.sv-close:hover, .sv-del:hover { color: var(--text); }
.sv-img { flex: 1; width: 100%; object-fit: contain; min-height: 0; background: #000; }
.sv-caption { padding: 12px 14px; font-size: 14px; }
.sv-zone { position: absolute; top: 60px; bottom: 0; width: 40%; background: none; border: none; }
.sv-zone.left { left: 0; }
.sv-zone.right { right: 0; width: 60%; }

/* profilo */
.profile { padding: 0; overflow: hidden; }
.profile .banner { height: 140px; background-size: cover; background-position: center; }
.profile-row {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 0 20px 18px; margin-top: -32px;
}
.profile-info { flex: 1; padding-top: 36px; }
.profile-info h1 { font-size: 20px; letter-spacing: -.02em; }
.profile-row > div:last-child { padding-top: 42px; }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(8,8,12,.7);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(440px, 94vw); margin: 0;
  /* se il contenuto supera lo schermo scorre la modale stessa, cosi' il fondo
     (e i bottoni) resta sempre raggiungibile */
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto; overscroll-behavior: contain;
}

/* infinite scroll sentinel */
.sentinel { text-align: center; font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 16px; }

/* ============ v2.1: sidebar icons + kind filter ============ */
.side-icon {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center;
  color: var(--muted);
}
.side-link.active .side-icon, .side-link:hover .side-icon { color: var(--text); }
.side-icon .avatar.sm { width: 20px; height: 20px; }

.kindbar { display: flex; gap: 6px; margin-bottom: 10px; }
.kindbar .tab.on { border-color: var(--text); color: var(--text); }
.kindbar .tab.spark-on { border-color: var(--acc-g); color: var(--acc-g); }
.kindbar .tab.thread-on { border-color: var(--acc-v); color: var(--acc-v); }

/* ============ v2.2: badges ============ */
.badge {
  display: inline-block; vertical-align: middle;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 8px; border-radius: 999px; margin-left: 6px;
}
.badge.admin { border: 1px solid var(--acc-v); color: var(--acc-v); }
.badge.banned { border: 1px solid var(--danger); color: var(--danger); }
.profile-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 42px; }

/* ============ v2.5: echo + hashtags ============ */
.hashtag { color: var(--acc-v); font-weight: 600; }
.echo-head { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.echo-head a { color: var(--muted); font-weight: 700; }
.echo-btn {
  background: none; border: none; color: var(--muted);
  font-family: var(--mono); font-size: 12px; padding: 0;
}
.echo-btn:hover { color: var(--acc-g); }
.orig-card {
  display: block; margin-top: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
.orig-card:hover { text-decoration: none; border-color: var(--muted); }
.orig-card .post-media img { max-height: 260px; }

/* ============ v2.6 QoL: custom action icons + full-ratio single images ============ */
.post-actions { align-items: center; }
.post-actions .action {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted); background: none; border: none; padding: 0;
  font-family: var(--mono); font-size: 12px;
}
.post-actions .action:hover { color: var(--text); text-decoration: none; }
.echo-btn.action:hover { color: var(--acc-g); }
.ic { display: block; }
.like { display: inline-flex; align-items: center; color: var(--muted); }
.like:hover { color: var(--acc-g); background: none; }
.like .ic { width: 17px; height: 17px; }
.like.on { color: var(--acc-g); }
.like.on .ic { fill: currentColor; }
.echo-head { display: flex; align-items: center; gap: 6px; }
.echo-head .ic { width: 13px; height: 13px; }
.echo-title { display: flex; align-items: center; gap: 8px; }
.echo-title .ic { width: 20px; height: 20px; color: var(--acc-g); }

/* sparks: single image keeps its natural aspect ratio (X-style) */
.post.kind-spark .post-media.n1 img {
  width: 100%; height: auto; max-height: 640px; object-fit: cover;
}
.orig-card .post-media.n1 img { max-height: 300px; }

/* ============ v2.7: story avatar fit, notification rows, themes ============ */

/* pfp fits the story ring exactly */
.story-circle .ring .avatar {
  width: 52px; height: 52px; min-width: 52px;
  border-radius: 50%; object-fit: cover;
  border: 2px solid var(--bg);
}
.story-circle .ring .avatar-fallback { font-size: 20px; display: grid; place-items: center; }

/* notifications: one clear row per interaction, wrapped text, dividers */
.notif {
  align-items: flex-start;
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.notif:last-child { border-bottom: none; }
.notif-text {
  white-space: normal;
  overflow: visible; text-overflow: clip;
  line-height: 1.45;
}
.notif .mono.muted { flex: none; margin-left: 8px; }
.notif.unread { border-radius: 8px; }

/* settings: theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.theme-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 14px; border-radius: 10px; text-align: left;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
}
.theme-card:hover { border-color: var(--muted); }
.theme-card.on { border-color: var(--acc-g); box-shadow: 0 0 0 1px var(--acc-g); }
.theme-dots { display: flex; gap: 6px; }
.theme-dots span { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); }

/* ---- theme: Deep Blue (dark blue on black) ---- */
:root[data-theme="blue"] {
  --bg: #04070d;
  --surface: #0a111d;
  --surface2: #101a2b;
  --line: #1a2740;
  --text: #e4eaf5;
  --muted: #7d8ba6;
  --acc-v: #5b8cff;
  --acc-g: #22d3ee;
}

/* ---- theme: Soft Pink (pastel pink on black, low glare) ---- */
:root[data-theme="pink"] {
  --bg: #0d090b;
  --surface: #171013;
  --surface2: #20161b;
  --line: #2e2027;
  --text: #f0e6ea;
  --muted: #a18b95;
  --acc-v: #f2a6c5;
  --acc-g: #f7c6da;
}
:root[data-theme="pink"] .btn.primary { color: #201017; }

/* ============ v2.8: IG-style story progress ============ */
.sv-bar { position: relative; overflow: hidden; }
.sv-bar.on { background: var(--line); }
.sv-bar.on::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--acc-v), var(--acc-g));
  transform: scaleX(0); transform-origin: left;
  animation: svfill var(--dur, 6000ms) linear forwards;
}
.sv-frame.loading .sv-bar.on::after,
.sv-frame.paused .sv-bar.on::after { animation-play-state: paused; }
@keyframes svfill { to { transform: scaleX(1); } }
.sv-zone { touch-action: none; }

/* ============ v2.8.2 fix: gray ring for fully-seen stories ============ */
.story-circle .ring.seen { background: var(--line); }

/* ============ v2.9: legal pages, terms checkbox, danger zone ============ */
.legal-doc { line-height: 1.65; }
.legal-doc h1 { font-size: 22px; margin-bottom: 14px; letter-spacing: -.02em; }
.legal-doc h2 { font-size: 16px; margin: 20px 0 8px; }
.legal-doc p { margin-bottom: 10px; }
.legal-doc ul { margin: 0 0 10px 20px; }
.legal-doc li { margin-bottom: 4px; }
.terms-check {
  display: flex !important; gap: 9px; align-items: flex-start;
  font-family: var(--sans) !important; font-size: 13px !important;
  color: var(--text) !important; text-transform: none !important;
  letter-spacing: 0 !important; line-height: 1.5; margin-bottom: 12px !important;
}
.terms-check input { width: auto; margin-top: 2px; }
.side-footer { font-size: 11px; color: var(--muted); padding: 14px 10px 0; }
.side-footer a { color: var(--muted); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.terms-overlay { z-index: 95; }
.report-btn.action:hover { color: var(--danger); }

/* ============ v2.9.1: reintegro blocco v2.3 (perso) — regole base notifiche/search ============ */
.notif-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--acc-g); color: #0e0e14;
  font-family: var(--mono); font-size: 10.5px; font-weight: 800;
  display: grid; place-items: center;
}
.notif-list { padding: 6px; }
.notif {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; color: var(--text); font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.notif:hover { background: var(--surface2); text-decoration: none; }
.notif:last-child { border-bottom: none; }
.notif.unread { background: rgba(167,139,250,.07); border-left: 2px solid var(--acc-v); border-radius: 8px; }
.notif-text { flex: 1; min-width: 0; white-space: normal; line-height: 1.45; }
.notif .mono.muted { flex: none; margin-left: 8px; }
.mention { color: var(--acc-g); font-weight: 600; }
.search-input {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 11px 18px; margin-bottom: 16px; font-size: 15px;
}

/* ============ v2.9.1: admin reports page ============ */
.report-item { border-bottom: 1px solid var(--line); padding: 12px 4px; }
.report-item:last-child { border-bottom: none; }
.report-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.report-reason { margin: 6px 0 8px; }
.report-actions { display: flex; gap: 8px; }
.report-item.resolved { opacity: .55; }

/* ============ v3.0: bookmarks, pin, user lists ============ */
.bookmark-btn.on { color: var(--acc-v); }
.bookmark-btn.on .ic { fill: currentColor; }
.bookmark-btn:hover { color: var(--acc-v); }
.pin-btn:hover { color: var(--acc-v); }
.pinned-tag {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--acc-v); font-weight: 700; letter-spacing: .04em;
}
.profile .stats a { color: var(--muted); }
.profile .stats a:hover { color: var(--text); text-decoration: none; }
.profile .stats a b { color: var(--acc-g); }
.modal .notif-list { max-height: 340px; overflow-y: auto; }

/* ============ v3.1: post UI cleanup — ⋯ menu, split action rows ============ */
.post-meta { position: relative; }
.post-menu-wrap { margin-left: auto; position: relative; }
.post-menu-btn {
  background: none; border: none; color: var(--muted);
  padding: 2px 6px; border-radius: 6px; display: inline-flex;
}
.post-menu-btn:hover { color: var(--text); background: var(--surface2); }
.post-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 15;
  display: flex; flex-direction: column; min-width: 140px;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.post-menu[hidden] { display: none; }
.post-menu button {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text);
  font-size: 13px; padding: 8px 10px; border-radius: 7px; text-align: left;
  font-family: var(--sans);
}
.post-menu button:hover { background: var(--surface); }
.post-menu button.danger { color: var(--danger); }
.post-menu .ic { flex: none; }

.post-actions { display: flex; justify-content: space-between; margin-top: 10px; }
.pa-left { display: inline-flex; align-items: center; gap: 20px; }
.pa-right { display: inline-flex; align-items: center; gap: 14px; }

/* ============ v3.3: mobile bottom bar + sidebar drawer ============ */
.bottombar { display: none; }
.drawer-backdrop { display: none; }

@media (max-width: 780px) {
  .layout { padding-bottom: 84px; }

  /* bottom bar fissa, solo icone */
  .bottombar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(56px + var(--shape-rise) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: transparent; border: none; overflow: visible;
    align-items: flex-end;
  }
  /* il fondo della barra E' l'SVG: include gia' l'incavo, quindi si fondono */
  .bb-bg {
    position: absolute; left: 0; right: 0; bottom: 0;
    width: 100%; height: calc(56px + var(--shape-rise) + env(safe-area-inset-bottom));
    z-index: 0; overflow: visible;
    filter: drop-shadow(0 -1px 0 var(--line));
  }
  .bb-bg path {
    fill: color-mix(in srgb, var(--bg) 96%, transparent);
    transition: d .34s cubic-bezier(.5, 0, .3, 1);
  }
  :root[data-theme="blue"] .bb-bg path { fill: rgba(4,7,13,.96); }
  :root[data-theme="pink"] .bb-bg path { fill: rgba(13,9,11,.96); }
  /* --shape-rise: quanto si solleva la bolla e quanto e' profonda la gobba */
  .bottombar { --shape-rise: 26px; overflow: visible; }

  /* la gobba: un SVG che scorre orizzontalmente sotto l'item attivo */
  .bb-notch {
    position: absolute; left: 0; bottom: 0;
    width: calc(100% / 5); height: calc(56px + var(--shape-rise) + env(safe-area-inset-bottom));
    fill: rgba(18,18,26,.92);
    transition: transform .34s cubic-bezier(.5, 0, .3, 1), opacity .2s ease;
    pointer-events: none;
  }
  :root[data-theme="blue"] .bb-notch { fill: rgba(4,7,13,.92); }
  :root[data-theme="pink"] .bb-notch { fill: rgba(13,9,11,.92); }

  .bb-item {
    flex: 1; display: grid; place-items: center; position: relative; z-index: 1;
    height: 56px; color: var(--muted); background: none; border: none; padding: 0;
  }
  /* il cerchio che contiene l'icona: da normale a "bolla" sollevata */
  .bb-frame {
    display: grid; place-items: center;
    width: 42px; height: 42px; border-radius: 50%;
    transition: transform .34s cubic-bezier(.34, 1.4, .5, 1), background .3s ease;
  }
  .bb-item.on { color: #0e0e14; }
  .bb-item.on .bb-frame {
    transform: translateY(calc(-1 * var(--shape-rise)));
    background: var(--acc-v);
    box-shadow: 0 6px 16px rgba(0,0,0,.35);
  }
  /* etichetta accento anche per icone a colore singolo */
  .bb-item.on .bb-frame svg { stroke: #0e0e14; }
  .bb-item .avatar.sm { width: 30px; height: 30px; }
  .bb-item.on .avatar.sm { outline: 2px solid #fff; }
  .bb-badge {
    position: absolute; top: 4px; right: calc(50% - 20px);
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
    background: var(--acc-g); color: #0e0e14;
    font-family: var(--mono); font-size: 9.5px; font-weight: 800;
    display: grid; place-items: center; z-index: 3;
  }
  @media (prefers-reduced-motion: reduce) {
    .bb-frame, .bb-notch { transition: none; }
  }

  /* la sidebar diventa un drawer da sinistra */
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 45;
    width: min(80vw, 300px); order: 0; max-height: none;
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 16px 12px calc(76px + env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-102%);
    transition: transform .22s ease;
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 44;
    background: rgba(0,0,0,.5); opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
  }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .drawer-backdrop { transition: none; }
}

/* ============ v3.4: live layer ============ */
.newposts-pill {
  display: block; margin: 0 auto 14px; padding: 8px 18px;
  border-radius: 999px; border: 1px solid var(--acc-v);
  background: var(--surface); color: var(--acc-v);
  font-weight: 700; font-size: 13px;
  position: sticky; top: 64px; z-index: 12;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.newposts-pill:hover { background: var(--surface2); }
.avatar-wrap { position: relative; display: inline-block; }
.online-dot {
  position: absolute; bottom: 4px; right: 4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--acc-g); border: 3px solid var(--surface);
}

/* ============ v3.5: shop, cornici avatar, stili nome, recovery ============ */
/* cornici avatar */
.af { display: inline-flex; border-radius: 50%; padding: 2px; }
.af .avatar { display: block; }
.af.frame_violet { background: var(--acc-v); }
.af.frame_gold { background: linear-gradient(135deg, #f5d060, #b8860b, #ffe9a0); }
.af.frame_neon { background: var(--acc-g); box-shadow: 0 0 8px var(--acc-g), 0 0 18px color-mix(in srgb, var(--acc-g) 60%, transparent); }
.af.frame_rainbow {
  background: conic-gradient(#f87171, #fbbf24, #4ade80, #38bdf8, #a78bfa, #f472b6, #f87171);
  animation: afspin 3s linear infinite;
}
@keyframes afspin { to { filter: hue-rotate(360deg); } }

/* stili nome */
.name_green { color: var(--acc-g) !important; }
.name_gradient {
  background: linear-gradient(90deg, var(--acc-v), var(--acc-g));
  -webkit-background-clip: text; background-clip: text; color: transparent !important;
}
.name_rainbow {
  background: linear-gradient(90deg, #f87171, #fbbf24, #4ade80, #38bdf8, #a78bfa, #f472b6);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent !important;
  animation: nameflow 4s linear infinite;
}
@keyframes nameflow { to { background-position: 300% 0; } }
.pname { font-weight: 700; }

/* shop */
.coin-balance { display: flex; align-items: center; gap: 6px; }
.coin-balance .ic { color: #f5d060; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.shop-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px; border-radius: 10px; text-align: center;
  background: var(--bg); border: 1px solid var(--line);
}
.shop-card.equipped { border-color: var(--acc-g); }
.shop-preview { min-height: 44px; display: grid; place-items: center; }
.shop-card .btn .ic { color: #f5d060; }
.shop-card b { font-size: 13.5px; }

/* recovery codes */
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recovery-codes code {
  font-family: var(--mono); font-size: 14px; letter-spacing: .06em;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .af.frame_rainbow, .name_rainbow { animation: none; }
}

/* ============ v3.6: ruoli, badge custom, timeout ============ */
.ubadge {
  display: inline-block; vertical-align: middle;
  font-family: var(--mono); font-size: 10px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
  padding: 1.5px 7px; border-radius: 999px;
  border: 1px solid var(--bc, var(--acc-v));
  color: var(--bc, var(--acc-v));
  background: color-mix(in srgb, var(--bc, var(--acc-v)) 12%, transparent);
}
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; margin-bottom: 4px; }
.perm-check {
  display: flex !important; gap: 8px; align-items: center;
  font-family: var(--sans) !important; text-transform: none !important;
  letter-spacing: 0 !important; margin: 0 !important;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); cursor: pointer;
}
.perm-check input { width: auto; margin: 0; }
.role-head { display: flex; align-items: center; gap: 10px; }
.role-card input[type="color"] { padding: 2px; height: 36px; width: 70px; }
.cdel {
  background: none; border: none; color: var(--muted);
  font-size: 11px; padding: 0 4px; margin-left: 4px;
}
.cdel:hover { color: var(--danger); }

/* ============ v3.7: studio, oggetti custom, temi custom ============ */
.af-anim { animation: afspin 3s linear infinite; }
/* gradiente animato: scorre, NON ruota la tinta (hue-rotate faceva arcobaleno) */
.af-flow { animation: nameflow 4s linear infinite; }
.name-anim { animation: nameflow 4s linear infinite; }
.theme-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.theme-colors label { font-size: 10.5px; }
.theme-colors input[type="color"] { width: 100%; height: 34px; padding: 2px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); }
.form input[type="color"] { height: 36px; width: 70px; padding: 2px; }
@media (prefers-reduced-motion: reduce) { .af-anim, .af-flow, .name-anim { animation: none; } }

/* ============ v3.8: badge shapes/medaglie, cornici con immagine, fix animazioni ============ */
/* fix: animazione nome per colore singolo (hue) */
.name-hue { animation: afspin 3s linear infinite; }

/* badge title colorati (chip pieni) */
.ubadge-c {
  display: inline-block; vertical-align: middle;
  font-family: var(--mono); font-size: 10px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 8px; color: #0e0e14; line-height: 1.5;
}
.ub-pill { border-radius: 999px; }
.ub-square { border-radius: 4px; }
.ub-hex { clip-path: polygon(8% 0, 92% 0, 100% 50%, 92% 100%, 8% 100%, 0 50%); padding: 2px 12px; }
.ub-flow { animation: nameflow 4s linear infinite; }

/* badge title da immagine */
.ubadge-img {
  display: inline-block; vertical-align: middle;
  height: 17px; width: auto; max-width: 64px; object-fit: cover;
}
img.ub-pill { border-radius: 999px; }
img.ub-square { border-radius: 4px; }
img.ub-hex { clip-path: polygon(8% 0, 92% 0, 100% 50%, 92% 100%, 8% 100%, 0 50%); }

/* medaglie */
.medal {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 20px; height: 20px; overflow: hidden;
}
.medal img { width: 100%; height: 100%; object-fit: cover; }
.md-txt { font-family: var(--mono); font-size: 8.5px; font-weight: 800; color: #0e0e14; }
.md-circle { border-radius: 50%; }
.md-square { border-radius: 5px; }
.md-shield { clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%); }
.medal.name-hue { animation: afspin 3s linear infinite; }

/* cornici con immagine overlay */
.af-imgw { position: relative; }
.af-overlay {
  position: absolute; inset: -16%; width: 132%; height: 132%;
  pointer-events: none; object-fit: contain;
}
.bb-item .af-overlay { inset: -12%; width: 124%; height: 124%; }

@media (prefers-reduced-motion: reduce) {
  .name-hue, .ub-flow, .medal.name-hue { animation: none; }
}

/* ============ v3.10: studio UI, badge grandi stile civitai, temi per zona ============ */
.studio-card h2 { margin-bottom: 12px; }
.studio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .studio-grid { grid-template-columns: 1fr; } }
.fx-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.fx-row input[type="color"] { width: 46px; height: 32px; padding: 2px; }
.studio-preview { min-height: 64px; border: 1px dashed var(--line); }
.up-slot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); margin-bottom: 8px;
}
.up-ctrl { display: flex; gap: 8px; align-items: center; }
.up-thumb { width: 40px; height: 30px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.up-ctrl label.btn { cursor: pointer; }
.studio-item {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.studio-item:last-child { border-bottom: none; }
.studio-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.studio-item-ctrl { display: flex; gap: 8px; align-items: center; }
.studio-item-ctrl .ei-price {
  width: 76px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px;
}
.studio-item-ctrl .ic { color: #f5d060; }

/* badge piu' grandi e leggibili (stile civitai) */
.medal { width: 28px; height: 28px; }
.md-txt { font-size: 10px; }
.ubadge-img { height: 22px; max-width: 92px; border-radius: 6px; }
.ubadge-c { font-size: 11px; padding: 3px 10px; }
.profile h1 .medal { width: 36px; height: 36px; }
.profile h1 .ubadge-img { height: 27px; max-width: 120px; }
.comment .medal { width: 22px; height: 22px; }

/* ============ v3.11: assign row, badge tooltip ============ */
.assign-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.assign-row input[type="text"] {
  flex: 1; min-width: 120px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
}
.assign-row select {
  flex: 1; min-width: 140px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
}
.has-tip { cursor: help; }

/* ============ v3.12: multi-stop colors, item editor, theme box explanations ============ */
.stops-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stop { position: relative; display: inline-flex; }
.stop input[type="color"] { width: 42px; height: 34px; padding: 2px; }
.stop-x {
  position: absolute; top: -6px; right: -6px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none;
  font-size: 9px; line-height: 1; cursor: pointer; padding: 0;
}
.theme-colors { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.theme-color-box {
  display: flex; gap: 10px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.theme-color-box input[type="color"] { width: 40px; height: 40px; padding: 2px; flex: none; }
.tcb-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tcb-info b { font-size: 12.5px; }
.tcb-info span { font-size: 10.5px; color: var(--muted); line-height: 1.3; }

/* ============ v3.12.1 fix: gradient su nomi custom ============ */
/* .meta-name ha color:var(--text) !important che vinceva sulla trasparenza dei nomi
   gradient. Le classi name-grad/name-solid + -webkit-text-fill-color inline risolvono. */
.meta-name.name-grad, .pname.name-grad {
  color: transparent !important;
  display: inline-block; vertical-align: bottom;
}
.meta-name.name-solid, .pname.name-solid { color: inherit !important; }

/* ============ v3.13: sezione "Your items" + tag exclusive ============ */
.owned-card { border-color: color-mix(in srgb, var(--acc-g) 35%, var(--line)); }
.shop-card { position: relative; }
.shop-tag {
  position: absolute; top: 6px; right: 6px;
  font-family: var(--mono); font-size: 8.5px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 999px;
  background: linear-gradient(90deg, #f5d060, #ff8800);
  color: #0e0e14;
}

/* ============ v3.17: transizione d'ingresso pagine ============ */
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main.page-enter { animation: pageEnter .26s cubic-bezier(.22, .8, .3, 1); }
@media (prefers-reduced-motion: reduce) {
  .main.page-enter { animation: none; }
}

/* ============ v3.18: link cliccabili nei post ============ */
.ext-link {
  color: var(--acc-v);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--acc-v) 45%, transparent);
  text-underline-offset: 2px;
  word-break: break-word;
}
.ext-link:hover {
  text-decoration-color: var(--acc-v);
}
.post.kind-spark .ext-link { color: var(--acc-g); text-decoration-color: color-mix(in srgb, var(--acc-g) 45%, transparent); }
.post.kind-spark .ext-link:hover { text-decoration-color: var(--acc-g); }

/* ============ v4.0: inviti tracciati e log ============ */
.inv-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 10px; }
.invite-row { padding: 11px 4px; border-bottom: 1px solid var(--line); }
.invite-row:last-child { border-bottom: none; }
.invite-row.spent { opacity: .55; }
.invite-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.invite-code {
  font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: .08em;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 10px; color: var(--acc-v);
}
.invite-status {
  font-family: var(--mono); font-size: 9.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 999px;
}
.st-active { background: color-mix(in srgb, var(--acc-g) 20%, transparent); color: var(--acc-g); }
.st-revoked, .st-expired { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.st-used-up { background: var(--surface2); color: var(--muted); }
.invite-meta { font-size: 11px; margin: 5px 0 7px; line-height: 1.5; }
.invite-ctrl { display: flex; gap: 8px; }

.log-row {
  display: flex; gap: 12px; align-items: baseline;
  padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.log-row:last-child { border-bottom: none; }
.log-time { flex: none; min-width: 74px; font-size: 11px; }
.log-text { flex: 1; min-width: 0; line-height: 1.45; }
.ev-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 5px;
  background: var(--surface2); color: var(--muted); margin-right: 4px;
}
.log-row.ev-fail .ev-tag, .log-row.ev-banned .ev-tag { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.log-row.ev-ok .ev-tag { background: color-mix(in srgb, var(--acc-g) 18%, transparent); color: var(--acc-g); }

/* ============ v4.1: automod e coda di revisione ============ */
.automod-rule {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.automod-rule:last-child { border-bottom: none; }
.automod-rule.off { opacity: .5; }
.ar-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ar-info .mono { font-size: 11px; }
.ar-action {
  font-family: var(--mono); font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 999px;
}
.ar-action.block { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.ar-action.review { background: color-mix(in srgb, var(--acc-v) 20%, transparent); color: var(--acc-v); }
.am-cfg { margin-top: 4px; }
.queue-item {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; background: var(--bg);
}
.queue-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; margin-bottom: 8px; }
.q-reason {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  color: var(--acc-v); background: color-mix(in srgb, var(--acc-v) 12%, transparent);
  padding: 2px 8px; border-radius: 999px;
}
.queue-preview { line-height: 1.5; margin-bottom: 8px; word-break: break-word; }
.queue-media { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.queue-media img { width: 74px; height: 74px; object-fit: cover; border-radius: 8px; }
.queue-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================================
   v5.0 — "Immersive" redesign (direzione 1c)
   Blocco SOLO-OVERRIDE: aggiunto in coda, non modifica nulla sopra.
   Usa esclusivamente le variabili colore esistenti -> temi admin e cosmetici
   dello shop (cornici .af*, nomi .name_*, medaglie/badge) restano intatti.
   Per tornare all'aspetto precedente basta cancellare da qui in giu'.
   ============================================================================ */

/* ---- Bottoni primari: gradiente viola->verde in tutto il sito ------------- */
.btn.primary {
  background: linear-gradient(135deg, var(--acc-v), var(--acc-g));
  border-color: transparent; color: #12121a; font-weight: 800;
}
.btn.primary:hover { filter: brightness(1.06); }

/* ---- Card generiche: angoli piu' morbidi (pagine, modali, admin, studio) -- */
.card { border-radius: 16px; }

/* ---- Composer: pannello con leggera tinta bi-accento --------------------- */
.composer {
  background:
    linear-gradient(120deg,
      color-mix(in srgb, var(--acc-v) 9%, var(--surface)),
      color-mix(in srgb, var(--acc-g) 7%, var(--surface)));
  border-radius: 16px;
}
.composer .tab.active-spark  { background: color-mix(in srgb, var(--acc-g) 15%, transparent); }
.composer .tab.active-thread { background: color-mix(in srgb, var(--acc-v) 15%, transparent); }

/* ---- Sidebar: voci arrotondate + attivo a gradiente ---------------------- */
.side-link {
  border-radius: 10px; font-weight: 600;
  position: relative; transition: background .12s ease, color .12s ease;
}
.side-link:hover { background: var(--surface2); }
.side-link.active {
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--acc-v) 22%, var(--surface2)),
    color-mix(in srgb, var(--acc-g) 14%, var(--surface2)));
  color: var(--text); box-shadow: none;
}
/* barretta accento a sinistra della voce attiva */
.side-link.active::before {
  content: ""; position: absolute; left: 4px; top: 18%; bottom: 18%;
  width: 3px; border-radius: 999px;
  background: linear-gradient(180deg, var(--acc-v), var(--acc-g));
}
.side-link.active .side-icon { color: var(--acc-g); }
/* icone community piu' vivaci */
.c-avatar { box-shadow: 0 2px 8px color-mix(in srgb, var(--acc-v) 40%, transparent); }
/* titoli di sezione con pallino accento */
.side-title { display: flex; align-items: center; gap: 7px; }
.side-title::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: linear-gradient(135deg, var(--acc-v), var(--acc-g));
}

/* ---- Feed: base card ------------------------------------------------------ */
.post {
  border-radius: 16px;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

/* ===== SPARK: card social immersiva (glow verde, avatar ring, azioni pill) = */
.post.kind-spark {
  /* glow verde radiale sopra al fondo pagina, niente striscia laterale */
  background:
    radial-gradient(120% 85% at 18% -12%,
      color-mix(in srgb, var(--acc-g) 13%, transparent), transparent 58%),
    var(--bg);
  border: 1px solid color-mix(in srgb, var(--acc-g) 16%, var(--line));
  border-left-width: 1px;
}
.post.kind-spark:hover { border-color: color-mix(in srgb, var(--acc-g) 34%, var(--line)); }
.post.kind-spark .post-text { font-size: 15.5px; }

/* anello gradiente sull'avatar — SOLO se l'utente non ha una cornice cosmetica */
.post.kind-spark .meta-avatar:not(:has(.af)) {
  padding: 2px; border-radius: 50%;
  background: linear-gradient(135deg, var(--acc-g), #22d3ee);
}
.post.kind-spark .meta-avatar:not(:has(.af)) .avatar { border: 2px solid var(--bg); }

/* barra reazioni "flottante" a pillola */
.post.kind-spark .pa-left {
  gap: 4px; padding: 5px 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.28);
}
.post.kind-spark .pa-left .action,
.post.kind-spark .pa-left .likerow { padding: 4px 12px; border-radius: 999px; }
/* niente sfondo sul bottone: e' il cuore stesso a riempirsi di verde
   (regole base: .like.on { color: var(--acc-g) } + .ic { fill: currentColor }) */
.post.kind-spark .pa-left .like.on + .score { color: var(--acc-g); }

/* ===== THREAD: blocco forum tinto viola + rail voto a capsula ============== */
.post.kind-thread {
  background: color-mix(in srgb, var(--acc-v) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--acc-v) 22%, var(--line));
  border-left-width: 1px;
}
.post.kind-thread:hover { border-color: color-mix(in srgb, var(--acc-v) 40%, var(--line)); }
.post.kind-thread .post-title { font-size: 18px; }
.post.kind-thread .post-title a { color: var(--text); }

/* la colonna di voto diventa una capsula a gradiente */
.post.kind-thread .votecol {
  align-self: flex-start;
  padding: 8px 0; width: 40px;
  border-radius: 999px;
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--acc-v) 28%, var(--surface2)), var(--surface2));
}
.post.kind-thread .vote.up.on { color: var(--acc-g); }

/* ---- Profilo: banner con fallback a gradiente bi-accento ------------------
   background-color/-image inline (banner caricato dall'utente) vincono su
   questa regola, quindi il banner personale NON viene sovrascritto.         */
.profile .banner {
  background-color: #1a1030;
  background-image: linear-gradient(120deg, #2a2450, #173c33 55%, #1a3a4a);
}

/* ---- Titoli sezione dentro le card: accento a gradiente ------------------ */
/* copre Shop (Avatar frames / Name styles / Badges), Settings, Studio,
   Roles, Invites, Automod, ecc. — ogni pagina che usa .card h2.           */
.card h2 {
  display: flex; align-items: center; gap: 9px;
  letter-spacing: -.01em;
}
.card h2::before {
  content: ""; flex: none; width: 4px; height: 15px; border-radius: 999px;
  background: linear-gradient(180deg, var(--acc-v), var(--acc-g));
}

/* ---- Shop: card cosmetici piu' vive, hover, "equipped" evidenziato ------- */
.shop-grid { gap: 14px; }
.shop-card {
  border-radius: 14px; padding: 18px 12px;
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.shop-card:hover {
  border-color: color-mix(in srgb, var(--acc-v) 45%, var(--line));
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0,0,0,.32);
}
.shop-card.equipped {
  border-color: var(--acc-g);
  box-shadow: 0 0 0 1px var(--acc-g), 0 0 22px color-mix(in srgb, var(--acc-g) 22%, transparent);
}
.shop-preview { min-height: 52px; }
/* saldo monete piu' in risalto */
.coin-balance {
  font-family: var(--mono); font-weight: 700;
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; color: #f5d060;
}

/* ---- Community (pagina c/…): riusa .page-head come header brandizzato -----
   La community page monta un .page-head.card come intestazione: qui gli diamo
   il banner immersivo. Le regole restano innocue se la struttura e' diversa. */
.page-head.card {
  border-radius: 16px;
  background:
    linear-gradient(120deg,
      color-mix(in srgb, var(--acc-v) 16%, var(--surface)),
      color-mix(in srgb, var(--acc-g) 10%, var(--surface)));
  border-color: color-mix(in srgb, var(--acc-v) 20%, var(--line));
}
.page-head.card .stats b { color: var(--acc-g); }

/* ---- Coda di moderazione: item con angoli morbidi, chip motivo invariata - */
.queue-item { border-radius: 14px; }

/* ---- riduzione movimento --------------------------------------------------*/
@media (prefers-reduced-motion: reduce) {
  .post, .btn.primary { transition: none; }
}
/* ---- v5.1: editor dei temi -------------------------------------------------*/
.theme-adv {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 14px; margin-bottom: 12px;
}
.theme-adv > span { display: flex; flex-direction: column; gap: 3px; }
.theme-adv label { font-size: 11.5px; color: var(--muted); margin: 0; }
.theme-adv label b { color: var(--text); font-family: var(--mono); }
.theme-adv select { width: 100%; }
.theme-adv input[type="color"] { width: 100%; height: 32px; padding: 2px; }
.theme-adv input[type="range"] { width: 100%; accent-color: var(--acc-v); margin: 0; }
.theme-editor { width: min(900px, 96vw); }
.te-body {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4px 24px; align-items: start;
}
.te-col { min-width: 0; }
.te-col > label { display: block; margin-top: 12px; }
.te-col > label:first-child { margin-top: 0; }
.theme-editor .theme-colors { margin-bottom: 4px; }
.theme-editor .up-slot { margin-bottom: 6px; }
.theme-editor .up-thumb { max-height: 34px; border-radius: 6px; }
/* barra azioni ancorata al fondo: resta visibile mentre si scorre */
.te-actions {
  position: sticky; bottom: -22px; z-index: 2;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px -22px -22px; padding: 12px 22px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.te-live-wrap { margin: 0 0 0 auto; font-size: 12.5px; }
@media (max-width: 760px) {
  .te-body { grid-template-columns: 1fr; }
  .te-col > label:first-child { margin-top: 12px; }
  .te-col:first-child > label:first-child { margin-top: 0; }
}

/* ---- v5.2: edges — bordi acquistabili per post e profilo -------------------*/
.edge-prev {
  display: inline-grid; border-radius: 12px; line-height: 1;
}
.edge-prev-in {
  display: grid; place-items: center; min-width: 70px; min-height: 34px;
  padding: 4px 12px; border-radius: 9px;
  background: var(--surface); color: var(--text);
  font-family: var(--mono); font-size: 11.5px;
}
#si-edge-opts label { display: block; font-size: 11.5px; color: var(--muted); }
#si-edge-opts label b { color: var(--text); font-family: var(--mono); }
#si-edge-opts input[type="range"] { width: 100%; accent-color: var(--acc-v); margin-bottom: 8px; }
.shop-card .edge-prev { margin: 2px 0; }
/* la scheda profilo ritaglia il banner: il bordo deve restarci dentro */
.profile[class*="edge-"] { overflow: hidden; }

/* ---- v5.6: fix di formattazione (mobile + desktop) ------------------------*/
/* Rete di sicurezza: un URL lungo incollato in un post o in una bio non deve
   allargare la card e far comparire lo scroll orizzontale su tutta la pagina. */
body { overflow-wrap: break-word; }
.post-text, .comment-body, .desc, .bio, .log-text, .queue-preview,
.studio-item-info, .notif-text, .bundle-desc { overflow-wrap: anywhere; }
/* nessun elemento puo' sfondare la sua colonna */
img, video, canvas, svg, pre, table { max-width: 100%; }
pre { overflow-x: auto; }

/* Righe di controllo dei pannelli admin: erano flex rigidi, e con l'aggiunta
   di nuovi bottoni (Duplicate) uscivano dallo schermo su mobile. */
.studio-item, .automod-rule, .log-row { flex-wrap: wrap; }
.studio-item-ctrl { flex-wrap: wrap; }

@media (max-width: 640px) {
  /* i controlli scendono sotto e prendono tutta la riga, invece di stringersi */
  .studio-item { align-items: flex-start; gap: 10px; }
  .studio-item-info { flex: 1 1 100%; order: 2; }
  .studio-item-ctrl { flex: 1 1 100%; order: 3; justify-content: flex-start; }
  .studio-item-ctrl input[type="number"] { width: 78px; }
  .studio-item > .shop-preview { order: 1; flex: none; }

  .automod-rule { align-items: flex-start; }
  .automod-rule > *:last-child { margin-left: 0; }

  .log-row { gap: 4px 10px; }
  .log-time { flex: 1 1 100%; min-width: 0; }

  /* liste di scelte: una colonna sola sotto i 400px logici */
  .perm-grid { grid-template-columns: 1fr; }
  .bundle-picker { grid-template-columns: 1fr; max-height: 220px; }

  /* i pulsanti delle card shop stavano stretti in due colonne */
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }

  /* le barre di filtri/tab scorrono invece di stringersi fino a spezzare
     le parole (Activity/Security nei log, i tab del composer, i filtri feed) */
  .scopebar, .composer .tabs, .filterbar {
    overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
  }
  .scopebar::-webkit-scrollbar, .composer .tabs::-webkit-scrollbar,
  .filterbar::-webkit-scrollbar { display: none; }
  .scopebar > .scope { flex: 0 0 auto; padding: 10px 16px; }
}

/* Il contenuto non deve mai finire sotto la bottom bar fissa. */
@media (max-width: 780px) {
  .layout { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* ---- v5.5: bundle ---------------------------------------------------------*/
.bundle-prev {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px; min-height: 44px;
}
.bundle-slot { display: inline-flex; align-items: center; }
.bundle-slot .avatar { width: 26px; height: 26px; font-size: 12px; }
.bundle-slot .meta-name { font-size: 12px; }
.bundle-slot .edge-prev-in { min-width: 42px; min-height: 24px; font-size: 10px; padding: 2px 7px; }
.bundle-note { display: block; font-size: 11px; color: var(--acc-g); margin-top: 2px; }
.bundle-desc {
  display: block; font-size: 11.5px; color: var(--muted);
  margin: 2px 0 4px; line-height: 1.35;
}
.bundle-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 6px; max-height: 260px; overflow-y: auto;
  padding: 8px; margin-bottom: 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.bundle-opt {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); cursor: pointer;
}
.bundle-opt.on { border-color: var(--acc-v); background: var(--surface2); }
.bundle-opt input { accent-color: var(--acc-v); flex: none; }
.bundle-opt-mini { display: inline-flex; align-items: center; flex: none; }
.bundle-opt-mini .avatar { width: 22px; height: 22px; font-size: 11px; }
.bundle-opt-mini .edge-prev-in { min-width: 32px; min-height: 20px; font-size: 9px; padding: 1px 5px; }
.bundle-opt-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.bundle-opt-txt b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bundle-opt-txt span { font-size: 10.5px; }
.bundle-sum { font-size: 11.5px; margin-bottom: 10px; }

/* ---- v5.5: scheda profilo su schermi stretti ------------------------------*/
/* Prima: avatar, testo e bottone su una riga sola anche a 380px, quindi la
   colonna centrale restava larghissima 100px e ogni parola andava a capo. */
@media (max-width: 640px) {
  .profile .banner { height: 104px; }
  .profile-row {
    flex-wrap: wrap; gap: 10px 12px;
    padding: 0 14px 16px; margin-top: -28px;
  }
  .profile-row > .avatar-wrap { order: 1; }
  /* i bottoni restano in alto a destra, accanto all'avatar */
  .profile-row > div:last-child {
    order: 2; margin-left: auto; padding-top: 34px;
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end;
  }
  /* il testo scende sotto e prende tutta la larghezza */
  .profile-info { order: 3; flex: 1 1 100%; padding-top: 0; min-width: 0; }
  .profile-info h1 {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px;
    font-size: 18px; margin-bottom: 4px;
  }
  .profile .stats { font-size: 11.5px; line-height: 1.7; }
  .profile h1 .medal { width: 28px; height: 28px; }
  .profile h1 .ubadge-img { height: 22px; max-width: 96px; }
}

/* ---- v5.4: anteprima "come sta su di me" ----------------------------------*/
.cp-modal { width: min(620px, 96vw); }
.cp-stage {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; color: var(--text);
}
.cp-stage .card, .cp-stage .post { margin-bottom: 0; }
.cp-stage .profile { margin-bottom: 12px; overflow: hidden; }
.cp-stage .banner {
  height: 62px; background: linear-gradient(120deg, var(--acc-v), var(--acc-g));
  opacity: .55;
}
.cp-stage .post-text { margin-top: 6px; }
.cp-stage .stats { font-size: 12px; }
.cp-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.shop-btns { display: flex; gap: 6px; align-items: center; justify-content: center; }
.shop-btns .btn.ghost { padding: 4px 8px; line-height: 0; }

/* ============================ fine v5.0 ==================================== */
