/* ═══════════════════════════════════════════════
   Groq AI Chat — Design System v2
   Dark glass, animazioni, mobile-first
   ═══════════════════════════════════════════════ */
:root {
  --bg: #070b15;
  --surface: rgba(20, 28, 48, 0.85);
  --surface-hover: rgba(30, 40, 65, 0.9);
  --border: rgba(120, 140, 180, 0.12);
  --text: #eef1f6;
  --text-muted: #8895b0;
  --accent: #7c5cfc;
  --accent2: #5b8def;
  --accent-glow: rgba(124, 92, 252, 0.2);
  --green: #2dd47a;
  --red: #f0506e;
  --orange: #f5a623;
  --gold: #f7c948;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 40px rgba(0,0,0,.5);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: radial-gradient(ellipse at 30% 0%, rgba(124,92,252,.08), transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; transition: .2s; }
a:hover { color: #a88cff; }
input, select, textarea, button { font-family: var(--font); }
button { cursor: pointer; border: none; background: none; color: inherit; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ───── SCROLLBAR ───── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ───── LAYOUT ───── */
.app-shell {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.screen { display: none; }
.screen.active { display: block; }
.main-content { width: 100%; max-width: 100%; }
body.chat-open .app-shell { max-width: 100%; width: 100%; margin: 0; padding: 0; }
body.chat-open .app-header { position: fixed; top: 0; left: 0; right: 0; z-index: 20; background: rgba(7,11,21,.94); border-bottom: 1px solid var(--border); }
body.chat-open .main-content { padding-top: 76px; }
body.chat-open #chat-screen { width: 100%; max-width: none; min-height: calc(100vh - 76px); border-radius: 0; }
body.chat-open .messages { max-height: calc(100vh - 280px); }
.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 30% 0%, rgba(124,92,252,.08), transparent 60%), var(--bg);
}
.page-card {
  width: min(520px, 100%);
  background: rgba(10, 18, 35, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

body.admin-page .page-shell {
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  min-height: 100vh;
}

body.admin-page .page-card#admin-card {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  border-radius: 0;
  padding: 28px 32px 40px;
  box-shadow: none;
  background: rgba(7, 11, 21, 0.98);
}

body.admin-page .page-card#admin-card section {
  margin-bottom: 24px;
}
.page-card h1 {
  font-size: 1.9rem;
  margin-bottom: 10px;
}
.page-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 22px;
}
.form-content {
  display: none;
  flex-direction: column;
  gap: 14px;
}
.form-content.active {
  display: flex;
}
.page-card input,
.page-card select,
.page-card textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.008));
  color: var(--text);
  font-size: .95rem;
  transition: box-shadow .18s ease, transform .12s ease, border-color .12s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.page-card textarea { resize: vertical; }
.page-card .form-error,
.page-card .form-success { font-size: .9rem; min-height: 24px; }
.page-card .form-error { color: var(--red); }
.page-card .form-success { color: var(--green); }
.page-card .tabs {
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.page-card .tabs .tab {
  flex: 1 1 120px;
  min-width: 120px;
  text-align: center;
}
.page-card .tabs .tab.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: white; }
.page-card .form-link { margin-top: 14px; text-align: center; }
.page-card .admin-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.page-card .admin-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: stretch; }
.page-card .admin-list > .card,
.page-card .admin-list > .info-card { width: 100%; max-width: none; }
  .page-card .admin-list > .admin-category-section { grid-column: 1 / -1; width: 100%; }

@media (max-width: 700px) {
  .page-card { padding: 20px 18px; }
  .page-card .tabs .tab { flex: 1 1 100%; min-width: 0; }
}

.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-left h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.03em; background: linear-gradient(135deg,var(--accent),var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.device-badge {
  font-size: .7rem; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); color: var(--text-muted); letter-spacing: .02em; text-transform: uppercase;
}
.header-center { display: flex; align-items: center; justify-content: center; flex: 1; padding: 0 12px; }
.header-center .search-input { min-width: 320px; max-width: 420px; width: 100%; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: transparent; color: var(--text); }
@media (max-width: 900px) { .header-center .search-input { min-width: 180px; max-width: 100%; } }
.header-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* Group character selector scroll fix: capture wheel events */
#group-character-select-list { overscroll-behavior: contain; }

/* ───── NAVIGATION ───── */
.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 0 20px;
}
.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}
.nav-link:hover {
  color: var(--accent);
  background: var(--surface);
}
.nav-link.active {
  color: var(--accent);
  background: var(--surface);
}

/* ───── USER INFO & PROFILE ───── */
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.avatar-mini {
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-hover);
}
.user-name {
  font-weight: 500;
  font-size: 0.9rem;
}
.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
}
/* ───── BUTTONS ───── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700;
  padding: 10px 18px; border-radius: 12px; font-size: .9rem;
  transition: transform .12s ease, box-shadow .18s ease, background .12s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: white; box-shadow: 0 8px 30px rgba(124,92,252,0.12); }
.btn-primary:hover { box-shadow: 0 14px 45px rgba(124,92,252,0.14); }
.btn-outline { border: 1.5px solid rgba(255,255,255,0.06); color: var(--text); background: transparent; }
.btn-outline:hover { border-color: var(--accent); background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { background: linear-gradient(135deg, var(--red), #d6304a); color: white; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-icon { padding: 9px; font-size: 1.2rem; border-radius: 50%; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:hover { background: var(--surface); }
.btn-block { width: 100%; justify-content: center; }

/* ───── HERO ───── */
.hero { text-align: center; padding: 30px 0 18px; }
.hero h2 { font-size: clamp(1.4rem,4vw,2rem); font-weight: 800; background: linear-gradient(135deg,#fff,var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { margin-top: 8px; color: var(--text-muted); font-size: .95rem; max-width: 500px; margin-inline: auto; }

/* ───── SECTIONS ───── */
.section-header { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 12px; }
.section-header h3 { font-size: 1.1rem; font-weight: 700; }
.section-header .subtitle { color: var(--text-muted); font-size: .82rem; }

/* ───── CARDS GRID ───── */
.group-picker-section { margin-bottom: 16px; }
.group-picker-title { font-size: .95rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.group-picker-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.group-picker-card { padding: 12px; min-height: 220px; }
.group-picker-card .card-stats { display: flex; }
.group-card {
  min-height: 320px;
}
.group-card .bot-card-image {
  position: absolute;
  inset: 0;
  height: 100%;
}
.group-card .card-actions {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.group-card .card-actions .btn {
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
}
.group-card .card-stats {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 58px;
  z-index: 11;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cards-grid, .bots-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Supporto per scorrimento orizzontale: applicare classe .horizontal o .horizontal-scroll */
.cards-grid.horizontal, .cards-grid.horizontal-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 10px 6px 12px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.cards-grid.horizontal::-webkit-scrollbar, .cards-grid.horizontal-scroll::-webkit-scrollbar {
  height: 9px;
}
.cards-grid.horizontal::-webkit-scrollbar-thumb, .cards-grid.horizontal-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}
.cards-grid.horizontal .card, .cards-grid.horizontal-scroll .card {
  flex: 0 0 auto;
  min-width: 220px;
  max-width: 300px;
  scroll-snap-align: start;
}

.section-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 28px 0 14px; flex-wrap: wrap; }
.section-header h3 { font-size: 1.15rem; letter-spacing: .02em; }
.section-header .subtitle { color: var(--text-muted); font-size: .88rem; display: block; margin-top: 4px; }

/* small tweak: make site-logo look like button for home */
.site-logo { font-weight:800; font-size:1.05rem; text-decoration:none; color:transparent; background:linear-gradient(135deg,var(--accent),var(--accent2)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }

.profile-dropdown button#profile-menu-create-custom.hidden { display:none !important; }
.bots-grid {
  margin-bottom: 20px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0;
  transition: all .25s cubic-bezier(.4,0,.2,1); cursor: pointer;
  backdrop-filter: blur(10px);
  position: relative;
  height: 320px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-link {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.card-link:hover {
  text-decoration: none;
}
.card::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: rgba(255,255,255,0.75);
  z-index: 9;
}
.card:hover {
  transform: translateY(-4px); border-color: rgba(124,92,252,.3);
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.card .avatar { font-size: 2.4rem; display: block; margin-bottom: 0; }

.bot-card-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  overflow: hidden;
  border-radius: 0;
  background: rgba(255,255,255,0.03);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}
.bot-card-image .avatar {
  font-size: 3rem;
  margin-bottom: 0;
}
.bot-avatar-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bot-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 0;
  display: block;
}
.card h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  padding: 12px 14px 6px 14px;
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  background: transparent;
  color: #000;
  z-index: 10;
}
.card p {
  color: #000;
  font-size: .78rem;
  line-height: 1.4;
  margin: 0;
  padding: 0 14px 12px 14px;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: transparent;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  z-index: 10;
}
.card-stats { display: none; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.stat-pill {
  display: none;
  padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  background: rgba(124,92,252,.1); color: var(--accent);
}
.stat-pill.top { background: rgba(245,166,35,.12); color: var(--gold); }
.loader { color: var(--text-muted); padding: 30px; text-align: center; }

/* ───── INFO CARD ───── */
.info-card {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, rgba(124,92,252,.08), rgba(91,141,239,.04));
  border: 1px solid rgba(124,92,252,.15); border-left: 4px solid var(--accent);
  padding: 14px 18px; border-radius: var(--radius-sm); margin: 16px 0;
  font-size: .88rem; color: var(--text-muted);
}
.info-card span { font-size: 1.5rem; }

.section-title {
  font-size: 1rem; font-weight: 700; margin: 20px 0 10px; color: var(--text);
}

.guest-badge {
  padding: 8px 12px; border-radius: 999px; background: rgba(245,158,11,.12);
  color: #f5af56; font-weight: 700; font-size: .82rem; margin-top: 14px;
}

.card-actions { margin-top: 12px; display: flex; gap: 8px; }

/* ───── PLANS ───── */
.plans-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 10px auto 0;
  max-width: 1100px;
}
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  position: relative;
  backdrop-filter: blur(10px);
  transition: all .3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  min-height: 360px;
}
.plan-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  border-color: rgba(124,92,252,.25);
}
.plan-card.featured {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(124,92,252,.12), var(--surface));
  box-shadow: 0 0 30px rgba(124,92,252,0.08);
}
.plan-card.plan-base {
  border-color: rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.005));
  opacity: 0.92;
}
.plan-card.plan-base:hover {
  border-color: rgba(255,255,255,0.15);
  opacity: 1;
}
.plan-card h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.plan-card .price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin: 12px 0;
}
.plan-card .price span {
  font-size: .8rem;
  font-weight: 400;
  color: var(--text-muted);
}
.plan-card ul {
  list-style: none;
  text-align: left;
  font-size: .84rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.plan-card ul li {
  padding: 5px 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.plan-card.plan-base ul li:first-child {
  color: var(--green);
  font-weight: 600;
}
.plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-size: .68rem;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(124,92,252,0.25);
}

@media (max-width: 700px) {
  .plans-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
  }
  .plan-card {
    min-height: auto;
  }
}

/* ════════════════════════════════════════════
   CHAT LAYOUT (chat.html full page)
   ════════════════════════════════════════════ */
.chat-container-full {
  width: 100vw;
  max-width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}
.chat-container-full::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(7, 11, 21, 0.65);
  z-index: 0;
}
.chat-container-full > * {
  position: relative;
  z-index: 1;
}

.chat-container-full .chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 12px;
  border-radius: 0;
  margin-bottom: 0;
}

.chat-container-full .chat-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.chat-container-full .chat-info .avatar { font-size: 2rem; }
.chat-container-full .chat-info h2 { margin: 0; font-size: 1.2rem; }
.chat-container-full .chat-info .subtitle { margin: 0; color: var(--text-muted); font-size: 0.85rem; }

.chat-container-full #messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  max-height: none;
  background: transparent;
  border: none;
  backdrop-filter: none;
  padding-bottom: 16px;
}

.chat-container-full .message {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  max-width: 100%;
  padding: 0;
  background: transparent;
}
.chat-container-full .message-user { justify-content: flex-end; }
.chat-container-full .message-assistant { justify-content: flex-start; }
.chat-container-full .message-content {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 90%;
  position: relative;
}
@media (min-width: 900px) { .chat-container-full .message-content { max-width: 80%; } }
.chat-container-full .message-delete-btn {
  appearance: none;
  border: none;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  margin-left: auto;
  align-self: flex-start;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, color 0.2s ease;
  pointer-events: none;
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10;
}
.chat-container-full .message:hover .message-delete-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.chat-container-full .message.selected .message-delete-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.chat-container-full .message.selected .message-content {
  box-shadow: inset 0 0 0 1px rgba(124, 92, 252, 0.35);
}
.chat-container-full .message-delete-btn:hover {
  background: rgba(240, 80, 110, 0.3);
  color: #ff6b6b;
  transform: scale(1.1) !important;
}
.chat-container-full .message-delete-btn:active {
  transform: scale(0.95) !important;
}
@media (min-width: 1400px) { .chat-container-full .message-content { max-width: 70%; } }
.chat-container-full .message-user .message-content { flex-direction: row-reverse; }
.chat-container-full .message-avatar { font-size: 1.5rem; flex-shrink: 0; }
.chat-container-full .message-avatar-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.chat-container-full .message-avatar-img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 50%;
}
.chat-avatar-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.chat-avatar-content img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-container-full .message-content p {
  background: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 0;
  word-wrap: break-word;
  color: var(--text);
}
.chat-container-full .message-user .message-content p {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}

/* Stile per le parti descrittive (marcate con *...*) */
.message-descriptive {
  display: inline;
  color: #e0a5ff;
  font-style: italic;
  font-weight: 500;
  opacity: 0.95;
  background: rgba(224, 165, 255, 0.1);
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.message-descriptive:hover {
  background: rgba(224, 165, 255, 0.15);
  color: #f0b5ff;
  text-shadow: 0 0 8px rgba(224, 165, 255, 0.3);
}

/* Variazione di colore per messaggi dell'utente */
.message-user .message-content p .message-descriptive {
  color: #fff9e6;
  background: rgba(255, 255, 230, 0.15);
}

.message-user .message-content p .message-descriptive:hover {
  background: rgba(255, 255, 230, 0.25);
  color: #fffaeb;
  text-shadow: 0 0 8px rgba(255, 255, 200, 0.3);
}

/* ───── BOTTONE GENERAZIONE IMMAGINE INLINE ───── */
.image-prompt-btn {
  display: none !important;
}

.chat-container-full .input-area {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
  position: static;
  border-radius: 0;
}

.chat-container-full .input-area input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 12px 18px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: .95rem;
  transition: .2s;
}
.chat-container-full .input-area input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-container-full .chat-actions .nsfw-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.06);
  transition: all 0.2s ease;
}
.chat-container-full .chat-actions .nsfw-toggle:hover {
  border-color: var(--accent);
  background: rgba(255,255,255,0.02);
}
.chat-container-full .chat-actions .nsfw-toggle input[type="checkbox"] { 
  cursor: pointer; 
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

/* Forza il colore del testo negli input della chat a bianco
   e applica lo stile primario blu al pulsante Invia */
.chat-container-full .input-area input[type="text"] {
  color: #ffffff;
}

.chat-container-full .input-area #send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #ffffff;
  box-shadow: 0 8px 30px rgba(124,92,252,0.12);
}
.chat-container-full .input-area #send-btn:hover {
  box-shadow: 0 14px 45px rgba(124,92,252,0.14);
}

/* Chat context textarea text color */
#chat-context-input {
  color: #ffffff;
}

/* ═══════════════════════════════════════════════
   TYPING INDICATOR ANIMATION
   ═══════════════════════════════════════════════ */
.typing-text {
  background: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 0;
  color: var(--text-muted);
  letter-spacing: 2px;
  font-weight: 600;
}

.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing-pulse 1.4s infinite;
  margin: 0 2px;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-pulse {
  0%, 60%, 100% {
    opacity: 0.5;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-8px);
  }
}

/* ════════════════════════════════════════════
   CHAT (index.html inline chat screen)
   ════════════════════════════════════════════ */
.chat-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 4px;
  background: var(--surface); padding: 14px 18px; border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
}
.chat-character { display: flex; align-items: center; gap: 14px; }
.chat-avatar-lg { font-size: 2.6rem; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; background: var(--surface); border-radius: 50%; }
.chat-avatar-lg img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; }
.chat-avatar { width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; background: var(--surface); border-radius: 50%; overflow: hidden; margin-right: 12px; font-size: 1.7rem; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-character-desc { color: var(--text-muted); margin-top: 4px; font-size: 0.92rem; }
.chat-meta { color: var(--text-muted); font-size: .82rem; margin-top: 2px; }
.chat-actions { display: flex; gap: 4px; flex-wrap: wrap; }

#messages {
  background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: 18px; min-height: 360px; max-height: calc(100vh - 140px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  backdrop-filter: blur(10px);
  padding-bottom: 80px;
}
#chat-screen .message {
  padding: 12px 16px; border-radius: var(--radius-sm); line-height: 1.5;
  max-width: 85%; word-break: break-word; animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

#chat-screen .message.user {
  background: linear-gradient(135deg, rgba(124,92,252,.2), rgba(91,141,239,.12));
  align-self: flex-end; border-bottom-right-radius: 4px;
}
#chat-screen .message.assistant {
  background: rgba(255,255,255,.04); align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.message .meta { font-size: .68rem; color: var(--text-muted); margin-top: 4px; opacity: .6; }
.welcome-msg {
  display: flex; align-items: center; gap: 12px;
  background: rgba(124,92,252,.06); padding: 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .88rem;
}
.msg-avatar { font-size: 1.8rem; }

/* ═════ INLINE CHAT INPUT (index.html) ═════ */
#chat-screen .input-area {
  display: flex; gap: 8px; padding: 14px 18px;
  background: var(--surface); border-top: 1px solid var(--border);
  border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius);
}
#chat-screen .input-area input {
  flex: 1; padding: 12px 18px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font-size: .95rem; transition: .2s;
}
#chat-screen .input-area input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
#chat-screen .input-area input::placeholder { color: var(--text-muted); }

/* ───── AVATAR GRANDI ───── */
.large-avatar {
  font-size: 4rem; display: block; text-align: center; margin: 10px 0;
}

/* ───── MODAL ───── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 21, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 20px;
  backdrop-filter: blur(14px);
  animation: fadeIn .3s ease;
}

.modal-content {
  background: linear-gradient(180deg, rgba(13, 21, 38, 0.98), rgba(12, 18, 33, 0.98));
  border: 1px solid rgba(124, 92, 252, 0.22);
  border-radius: 28px;
  padding: 32px;
  max-width: 580px;
  width: min(100%, 580px);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  animation: popIn .28s ease;
}

@keyframes popIn {
  from { transform: translateY(-12px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-overlay {
  position: fixed; inset: 0; background: linear-gradient(180deg, rgba(3,6,12,0.75), rgba(3,6,12,0.9));
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 18px; backdrop-filter: blur(6px) saturate(1.05);
  animation: fadeIn .26s cubic-bezier(.2,.9,.24,1);
}

.chat-overlay {
  inset: 0; z-index: 110; display: flex; flex-direction: column; 
  background: radial-gradient(ellipse at 30% 0%, rgba(124,92,252,.08), transparent 60%), var(--bg);
}

.chat-overlay .chat-screen {
  flex: 1; max-width: 100%; width: 100%;
  margin: 0; padding: 0;
  background: transparent; box-shadow: none;
}

.chat-overlay .modal-close {
  display: none;
}

.chat-overlay .messages {
  max-height: calc(100vh - 180px);
}

@media (max-width: 700px) {
  .chat-overlay .messages {
    max-height: calc(100vh - 220px);
  }
}
.generated-image-preview {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}
.generated-image-preview img {
  width: 100%;
  display: block;
}
.profile-avatar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.profile-avatar-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  width: 100%;
  margin-top: 8px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
}
.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.modal-card {
  background: linear-gradient(180deg, rgba(12,20,36,0.96), rgba(8,14,28,0.96));
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 18px; padding: 26px; max-width: 540px; width: 100%;
  position: relative; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.65), 0 6px 16px rgba(124,92,252,0.04) inset;
  transform: translateY(-6px);
  transition: transform .22s cubic-bezier(.2,.9,.24,1), box-shadow .18s ease;
}
.modal-card .form-group {
  margin: 16px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-card .form-group label {
  font-size: .9rem;
  color: var(--text);
  font-weight: 600;
}
.modal-card input,
.modal-card select,
.modal-card textarea {
  color: #ffffff;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
}
.modal-card input[disabled], .modal-card input[readonly] {
  background: rgba(255,255,255,0.02);
  color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,0.04);
  cursor: default;
}
.modal-card .form-group { gap: 6px; }
.modal-card .form-group input::placeholder,
.modal-card .form-group textarea::placeholder,
.modal-card .form-group select::placeholder {
  color: rgba(255,255,255,0.45);
}
.modal-card .form-actions { display:flex; gap:10px; margin-top:8px; align-items:center }
.modal-card .form-actions .btn { padding: 10px 16px; border-radius: 12px; }
.modal-card .modal-note { font-size: .85rem; color: var(--text-muted); margin-top:8px }
.modal-card .form-group select,
.modal-card .form-group input[type="checkbox"] {
  width: 100%;
}
.modal-card .switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal-card #chat-nsfw-btn {
  min-width: 160px;
  padding: 10px 14px;
}
.modal-card .form-note {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.modal-close {
  position: absolute; right: 18px; top: 18px; font-size: 1.2rem;
  color: var(--text-muted); transition: .2s ease; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.modal-close:hover {
  background: rgba(124,92,252,0.16);
  color: white;
  transform: scale(1.05);
}
.modal-content h2 {
  font-size: 1.6rem;
  margin-bottom: 14px;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.modal-content p,
.modal-card p {
  color: var(--text-muted);
  margin-bottom: 16px;
}
.modal-card h2 { margin-bottom: 10px; font-weight: 700; }
.tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.tab {
  flex: 1; text-align: center; padding: 8px 12px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--text-muted); transition: all .2s;
}
.tab.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: white; box-shadow: 0 4px 12px var(--accent-glow); }
.form-content { display: none; flex-direction: column; gap: 12px; }
.form-content.active { display: flex; }
.form-content label { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-top: 4px; }
.form-content input, .form-content select, .form-content textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04);
  color: var(--text); font-size: .9rem; transition: all .2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.25);
}
.form-content input::placeholder, .form-content textarea::placeholder {
  color: rgba(255,255,255,0.55);
}
.form-content input:focus, .form-content select:focus, .form-content textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(124,92,252,0.08), 0 0 0 4px rgba(124,92,252,0.06);
  transform: translateY(-2px);
}

/* Global input treatment for consistent modern look */
input, select, textarea {
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  padding: 11px 12px;
  color: #ffffff;
  transition: box-shadow .18s ease, transform .12s ease, border-color .12s ease;
}

input::placeholder, select::placeholder, textarea::placeholder {
  color: rgba(255,255,255,0.55);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 12px 40px rgba(124,92,252,0.12), 0 0 0 5px rgba(124,92,252,0.06);
  transform: translateY(-2px);
}
.form-error { color: var(--red); font-size: .85rem; padding: 4px 0; }
.form-success { color: var(--green); font-size: .85rem; padding: 4px 0; }
.form-link { text-align: center; font-size: .82rem; margin-top: 6px; }

/* ───── AVATAR PICKER ───── */
.avatar-picker { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* ───── AVATAR BUILDER SELECTS ───── */
.av-select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: rgba(15,23,42,.95);
  color: var(--text); font-size: .85rem; cursor: pointer; transition: .2s;
  appearance: none; -webkit-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='%238895b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.av-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.av-select option { background: #101a2e; color: var(--text); }
.avatar-option {
  font-size: 2rem; padding: 8px; cursor: pointer; border-radius: 50%;
  transition: all .2s; border: 2px solid transparent; width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
}
.avatar-option:hover { transform: scale(1.15); }
.avatar-option.selected { border-color: var(--accent); background: var(--accent-glow); transform: scale(1.1); }

/* ───── UPGRADE BANNER ───── */
.upgrade-banner {
  background: linear-gradient(135deg, rgba(124,92,252,.12), rgba(91,141,239,.06));
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
}

/* ───── CHARACTER MODAL FORM ───── */
.character-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(124,92,252,0.15);
  border-radius: 12px;
  transition: all .2s;
}

.form-section:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(124,92,252,0.25);
}

.form-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-row .form-group {
  min-width: 150px;
}

.character-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.character-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  text-transform: none;
}

.character-form input::placeholder,
.character-form textarea::placeholder {
  color: rgba(255,255,255,0.4);
}

/* ───── ADMIN PANEL BUTTONS ───── */
.admin-category-section .card {
  height: auto;
  min-height: 320px;
  overflow: visible;
}

.admin-category-section .card::before {
  display: none;
}

.admin-category-section .bot-card-image {
  position: relative;
  height: 160px;
  bottom: auto;
}

.admin-category-section .card h4,
.admin-category-section .card p {
  position: static;
  background: transparent;
  color: #ffffff;
  z-index: auto;
  margin: 0;
}

.admin-category-section .card h4 {
  padding: 16px 14px 6px;
}

.admin-category-section .card p {
  display: block;
  padding: 0 14px 12px;
  line-height: 1.4;
  max-height: none;
  -webkit-line-clamp: unset;
}

.admin-category-section .card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
  padding: 0 14px 16px;
}

.admin-category-section .card-stats {
  display: flex !important;
  padding: 0 14px 10px;
}

.admin-category-section .stat-pill {
  display: inline-block !important;
}

.admin-category-section .btn {
  font-size: 0.75rem;
  padding: 6px 10px;
  white-space: nowrap;
}

.admin-category-section .btn-outline {
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  transition: all .2s;
}

.admin-category-section .btn-outline:hover {
  background: rgba(124,92,252,0.15);
  color: #ffffff;
  border-color: rgba(124,92,252,0.5);
}

.admin-category-section .btn-danger {
  color: rgba(220,80,80,0.95);
  border: 1px solid rgba(220,80,80,0.35);
  background: rgba(220,80,80,0.08);
  transition: all .2s;
}

.admin-category-section .btn-danger:hover {
  background: rgba(220,80,80,0.2);
  color: #ff7b7b;
  border-color: rgba(220,80,80,0.65);
}

.admin-category-section .btn-secondary {
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  transition: all .2s;
}

.admin-category-section .btn-secondary:hover {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  border-color: rgba(255,255,255,0.35);
}

/* ───── ADMIN FORM MODAL OVERLAY ───── */
#ai-form-container.modal-overlay.hidden {
  display: none !important;
}

#ai-form-container.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 21, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 20px;
  backdrop-filter: blur(12px);
  animation: fadeIn 0.3s ease;
}

#ai-form-container.modal-overlay .modal-card {
  background: linear-gradient(180deg, rgba(13, 21, 38, 0.98), rgba(12, 18, 33, 0.98));
  border: 1px solid rgba(124, 92, 252, 0.22);
  border-radius: 20px;
  padding: 32px;
  max-width: 700px;
  width: 100%;
  max-height: 95vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  animation: slideUp 0.35s cubic-bezier(0.2, 0.9, 0.24, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#ai-form-container .modal-card h2 {
  color: #ffffff;
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 20px 0;
}

#ai-form-container .modal-card form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#ai-form-container .modal-card .form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#ai-form-container .modal-card .form-group label {
  font-size: 0.95rem;
  color: #ffffff;
  font-weight: 600;
}

#ai-form-container .modal-card input,
#ai-form-container .modal-card select,
#ai-form-container .modal-card textarea {
  color: #ffffff;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  transition: all 0.2s;
}

#ai-form-container .modal-card input:focus,
#ai-form-container .modal-card select:focus,
#ai-form-container .modal-card textarea:focus {
  outline: none;
  background: rgba(255,255,255,0.08);
  border-color: rgba(124,92,252,0.5);
  box-shadow: 0 0 0 2px rgba(124,92,252,0.1);
}

#ai-form-container .modal-card .form-note {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
}

#ai-form-container .modal-card .form-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 12px;
}

#ai-form-container .modal-card .form-actions .btn {
  padding: 12px 28px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 140px;
}

#ai-form-container .modal-card .form-actions .btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 1px solid rgba(124,92,252,0.3);
  color: #ffffff;
}

#ai-form-container .modal-card .form-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(124,92,252,0.3);
}

#ai-form-container .modal-card .form-actions .btn-secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}

#ai-form-container .modal-card .form-actions .btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
}

/* Image generation button + preview */
.create-image-btn {
  margin-left: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  color: var(--text-muted);
  font-weight: 700;
}
.create-image-btn:hover { background: rgba(124,92,252,0.08); color: white; border-color: rgba(124,92,252,0.18); }
.generated-image { display: block; margin-top: 10px; width: 90vw; max-width: 600px; height: auto; border-radius: 12px; border: 1px solid rgba(255,255,255,0.06); }
.generated-image-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.generated-image-download { display: inline-flex; align-items: center; justify-content: center; padding: 6px 10px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.04); color: inherit; text-decoration: none; font-size: 0.92rem; transition: background 0.2s ease; }
.generated-image-download:hover { background: rgba(255,255,255,0.08); }
.generated-image-caption { color: var(--text-muted); font-size: 0.84rem; }

.generate-image-btn, .create-image-btn {
  display: inline-block;
}
.image-loading {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}
.generated-image-container { margin-top: 10px; }
.generated-image-container p { margin: 8px 0; font-size: .85rem; }
.upgrade-banner span { font-size: 1.4rem; }

/* ───── BADGE & HIDDEN ───── */
.hidden { display: none !important; }

/* Profile trigger: avatar + name clickable */
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 12px;
  transition: background 0.15s;
}
.profile-trigger:hover {
  background: var(--surface-hover);
}
.chevron-down {
  font-size: .6rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.profile-dropdown:not(.hidden) ~ .profile-trigger .chevron-down,
.profile-trigger[aria-expanded="true"] .chevron-down {
  transform: rotate(180deg);
}

/* Profilo menu dropdown - YouTube Music style */
.profile-menu {
  position: relative; display: inline-block;
}
.profile-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: #1a1f2e; border: 1px solid rgba(124,92,252,0.15);
  border-radius: 16px; min-width: 260px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6); z-index: 50;
  overflow: hidden;
  backdrop-filter: blur(20px);
  padding: 8px 0;
}
.profile-dropdown .dropdown-highlight {
  background: linear-gradient(135deg, rgba(124,92,252,0.15), rgba(91,141,239,0.08));
  border: 1px solid rgba(124,92,252,0.2);
  color: var(--accent) !important;
  font-weight: 700 !important;
  margin: 4px 12px !important;
  border-radius: 12px !important;
  width: calc(100% - 24px) !important;
  padding: 12px 16px !important;
  display: flex !important;
  align-items: center;
  gap: 10px;
}
.profile-dropdown .dropdown-highlight:hover {
  background: linear-gradient(135deg, rgba(124,92,252,0.25), rgba(91,141,239,0.15)) !important;
  border-color: rgba(124,92,252,0.3) !important;
}
.profile-dropdown .dropdown-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.profile-dropdown .dropdown-user-info:hover {
  background: rgba(255,255,255,0.04);
}
.profile-dropdown .dropdown-avatar {
  font-size: 2rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-dropdown .dropdown-user-name {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
}
.profile-dropdown .dropdown-user-plan {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.profile-dropdown a, .profile-dropdown button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: .85rem; width: 100%; text-align: left;
  border: none; background: none; color: var(--text); transition: .15s;
}
.profile-dropdown a:hover, .profile-dropdown button:hover {
  background: rgba(255,255,255,0.04);
}
.profile-dropdown .divider { border-top: 1px solid rgba(255,255,255,0.06); margin: 4px 12px; }

/* Upgrade modal special */
.upgrade-modal .modal-card {
  max-width: 520px; text-align: center;
}
.upgrade-plans { display: grid; gap: 12px; margin: 16px 0; }
.upgrade-plan {
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: .2s;
}
.upgrade-plan:hover, .upgrade-plan.selected { border-color: var(--accent); background: rgba(124,92,252,.06); }
.upgrade-plan h4 { font-size: 1rem; }
.upgrade-plan .price { font-size: 1.5rem; font-weight: 800; color: var(--accent); }

/* ───── RESPONSIVE ───── */
@media (max-width: 1080px) {
  .app-shell { padding: 0 14px; }
  .main-nav { justify-content: center; gap: 16px; }
  .cards-grid, .bots-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .section-header { margin: 24px 0 12px; }
  .card { height: 300px; }
}

@media (max-width: 900px) {
  .app-header { flex-direction: column; align-items: stretch; }
  .header-left { width: 100%; display: flex; align-items: center; justify-content: space-between; }
  .header-center { order: 3; width: 100%; padding: 4px 0; }
  .header-center input { width: 100% !important; min-width: 0 !important; }
  .header-right { justify-content: space-between; width: 100%; flex-wrap: wrap; }
  .main-nav { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
  .cards-grid.horizontal .card, .cards-grid.horizontal-scroll .card { min-width: 200px; }
  .device-badge { display: none; }
  /* Profile dropdown: centra su tablet */
  .profile-dropdown { right: auto; left: 0; }
}

@media (max-width: 700px) {
  .app-shell { padding: 0 10px; }
  .app-header { align-items: flex-start; padding-bottom: 14px; }
  .header-left { width: 100%; flex-wrap: wrap; gap: 6px; }
  .header-left .site-logo { font-size: 0.95rem; }
  .header-right { justify-content: center; gap: 8px; width: 100%; }
  .main-nav { justify-content: center; gap: 8px; width: 100%; }
  .main-nav .nav-link { font-size: 0.82rem; padding: 6px 10px; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .cards-grid.horizontal, .cards-grid.horizontal-scroll { padding-left: 6px; padding-right: 6px; gap: 10px; }
  .cards-grid.horizontal .card, .cards-grid.horizontal-scroll .card { min-width: 170px; max-width: 260px; }
  .section-header { justify-content: flex-start; }
  .section-header h3 { font-size: 1rem; }
  .card { height: 280px; min-height: 280px; }
  .card h4 { font-size: 0.9rem; bottom: 52px; padding: 10px 12px 4px; }
  .card p { font-size: 0.72rem; padding: 0 12px 10px; }
  .chat-container-full .chat-header { flex-direction: column; gap: 8px; padding: 10px; }
  .chat-container-full .chat-header .chat-actions { width: 100%; flex-wrap: wrap; justify-content: center; }
  .chat-container-full .chat-header .chat-actions select { min-width: 90px !important; }
  .chat-container-full .chat-header .chat-info h2 { font-size: 1rem; }
  .chat-container-full .chat-header .chat-info .chat-character-desc { font-size: 0.8rem; }
  .chat-container-full .chat-header .chat-info .chat-avatar { width: 40px; height: 40px; font-size: 1.4rem; }
  .chat-container-full .messages { padding: 10px; }
  .chat-container-full .message-content { max-width: 95%; }
  .chat-container-full .message-content p { padding: 8px 12px; font-size: 0.88rem; }
  .chat-container-full .input-area { padding: 10px; gap: 6px; }
  .chat-container-full .input-area input[type="text"] { min-width: 120px; padding: 10px 14px; font-size: 0.88rem; }
  .chat-actions { width: 100%; flex-wrap: wrap; }
  .plans-grid { grid-template-columns: 1fr; }
  #messages { min-height: 220px; max-height: 38vh; padding-bottom: 70px; }
  .input-area { flex-wrap: wrap; }
  .input-area input { min-width: 100%; }
  .modal-card { margin: 6px; padding: 16px; }
  .avatar-picker { gap: 4px; }
  .avatar-option { width: 40px; height: 40px; font-size: 1.5rem; }
  .modal-card h2 { font-size: 1.15rem; }
  .profile-dropdown { right: auto; left: 0; min-width: 220px; }
  .site-footer { margin-top: 40px; padding: 24px 0 16px; }
  .footer-content { gap: 20px; }
  .hero { padding: 20px 0 12px; }
  .hero h2 { font-size: 1.25rem; }
  .hero p { font-size: 0.85rem; }
}

/* Su dispositivi touch (mobile/tablet) il pulsante elimina deve essere sempre visibile */
@media (hover: none) and (pointer: coarse) {
  .chat-container-full .message-delete-btn {
    opacity: 1 !important;
    transform: scale(1) !important;
    pointer-events: auto !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 1.3rem !important;
  }
}

/* Su schermi medi e piccoli il pulsante elimina è sempre visibile (no hover necessario) */
@media (max-width: 900px) {
  .chat-container-full .message-delete-btn {
    opacity: 1 !important;
    transform: scale(1) !important;
    pointer-events: auto !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 1.3rem !important;
  }
}

/* Anche su desktop, quando il messaggio è toccato/cliccato, mostra il bottone con area maggiore */
.chat-container-full .message.selected .message-delete-btn {
  width: 36px;
  height: 36px;
  font-size: 1.3rem;
}

@media (max-width: 520px) {
  .app-shell { padding: 0 8px; }
  .main-nav { gap: 6px; }
  .main-nav .nav-link { font-size: 0.75rem; padding: 5px 8px; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .cards-grid.horizontal .card, .cards-grid.horizontal-scroll .card { min-width: 155px; max-width: 230px; }
  .card { height: 260px; min-height: 260px; }
  .header-left .site-logo { font-size: 0.85rem; }
  .header-right .btn { font-size: 0.78rem; padding: 6px 10px; }
  .device-badge { display: none; }
  .chat-container-full .chat-header .chat-actions .btn { font-size: 0.75rem; padding: 4px 10px; }
  #reroll-btn { font-size: 0.75rem; padding: 4px 10px; }
  .profile-dropdown { min-width: 200px; }
}

/* Fix: pulsante reroll nella chat */
#reroll-btn { display: inline-flex; }

/* Character Profiles Admin */
.character-profile-fields { margin-top: 12px; }
.field-group { margin-bottom: 12px; }
.field-group label { display: block; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.profile-field {
  width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg); color: var(--text); font-family: inherit; resize: vertical;
}
.profile-field:focus { outline: none; border-color: var(--accent); }

/* ═══════ ADMIN TABS ═══════ */
.admin-tabs {
  display: flex;
  gap: 6px;
  margin: 20px 0 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  flex-wrap: wrap;
}
.admin-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  transition: all 0.2s ease;
  margin-bottom: -1px;
}
.admin-tab:hover {
  color: var(--accent);
  background: rgba(124,92,252,0.04);
}
.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}
.admin-tab-content {
  display: none;
}
.admin-tab-content.active {
  display: block;
}

/* ═══════ USERS HORIZONTAL SCROLL ═══════ */
.users-horizontal-scroll {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 12px;
  padding: 8px 4px 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.users-horizontal-scroll::-webkit-scrollbar {
  height: 6px;
}
.users-horizontal-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.users-horizontal-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 9px;
}
.users-horizontal-scroll .user-card {
  scroll-snap-align: start;
  min-width: 200px;
  max-width: 220px;
  flex: 0 0 auto;
}

/* ═══════ SITE FOOTER ═══════ */
.site-footer {
  margin-top: 60px;
  padding: 32px 0 20px;
  border-top: 1px solid var(--border);
}
.footer-content {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: center;
  max-width: 800px;
  margin: 0 auto;
}
.footer-section {
  flex: 1 1 280px;
  text-align: center;
}
.footer-section h4 {
  font-size: 1rem;
  margin-bottom: 8px;
}
.footer-section p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.contact-link {
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}
.contact-link:hover {
  color: #a88cff;
}
.footer-bottom {
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   MESSAGE 3-DOT MENU (⋮)
   ═══════════════════════════════════════════════ */
.msg-menu-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  flex-shrink: 0;
}

.msg-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.2s ease;
  line-height: 1;
}

.message:hover .msg-menu-btn,
.message.selected .msg-menu-btn {
  opacity: 0.8;
}

.msg-menu-btn:hover {
  opacity: 1 !important;
  background: rgba(255,255,255,0.08);
}

.msg-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  min-width: 180px;
  background: rgba(15, 22, 40, 0.98);
  border: 1px solid rgba(124, 92, 252, 0.25);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.15s ease;
}

.msg-menu-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.msg-menu-option:hover {
  background: rgba(124, 92, 252, 0.15);
}

/* ═══════════════════════════════════════════════
   COPY FEEDBACK TOAST
   ═══════════════════════════════════════════════ */
.copy-feedback {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 22, 40, 0.95);
  border: 1px solid rgba(124, 92, 252, 0.3);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.95rem;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  pointer-events: none;
}

.copy-feedback-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ───── MESSAGGI DI GRUPPO (baloon separati per AI) ───── */
.message-group-assistant {
    border-left: 3px solid var(--ai-color, var(--accent));
    margin-left: 8px;
    padding-left: 4px;
    background: linear-gradient(90deg, rgba(0,0,0,0.15), transparent);
    border-radius: 0 18px 18px 0;
}

.message-group-assistant .message-content {
    position: relative;
}

.message-group-assistant .message-avatar {
    border: 2px solid var(--ai-color, var(--accent));
}

.message-group-assistant .message-avatar-wrapper img {
    border: 2px solid var(--ai-color, var(--accent));
    border-radius: 50%;
}

.message-ai-name {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
    margin-top: -2px;
    opacity: 0.9;
}

/* Partecipanti del gruppo nell'header */
.group-participants-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin: 6px 0 10px 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
}

.group-participants-bar::-webkit-scrollbar { display: none; }

.group-participant-avatar {
    font-size: 1.2rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-hover);
    flex-shrink: 0;
}

.group-participant-avatar img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.group-participant-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ───── MODELLO BADGE (solo admin) ───── */
.model-badge {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.06);
  padding: 1px 8px;
  border-radius: 8px;
  display: inline-block;
  margin-top: 2px;
  letter-spacing: 0.3px;
  font-family: 'SF Mono', 'Consolas', monospace;
  line-height: 1.4;
}
.model-badge:not(.hidden) {
  display: inline-block;
}
