:root {
  --bg: #050507;
  --panel: #0c0c12;
  --panel-2: #12121a;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.28);
  --txt: #f4f4f7;
  --muted: #9b9baa;
  --white: #ffffff;
  --black: #0a0a0c;
  --gold: #ffd54a;
  --gold-soft: rgba(255, 213, 74, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  user-select: none;
}

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

.hidden { display: none !important; }

.gold { color: var(--gold); }

/* ---------- sfondo animato ---------- */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.aura {
  position: fixed;
  width: 64vw;
  height: 64vw;
  max-width: 920px;
  max-height: 920px;
  left: 50%;
  top: -26%;
  transform: translateX(-50%);
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.12), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(255,213,74,0.09), transparent 45%);
  border-radius: 50%;
  filter: blur(34px);
  animation: auraPulse 9s ease-in-out infinite;
}

@keyframes auraPulse {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.95; transform: translateX(-50%) scale(1.08); }
}

.grid-fade {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, black 0%, transparent 70%);
}

.content { position: relative; z-index: 2; flex: 1; overflow-y: auto; }

/* ---------- nav ---------- */
.nav {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.orb {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.orb .ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255,255,255,0.85);
  border-top-color: transparent;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(255,255,255,0.35);
  animation: spin 5.5s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.orb .ring::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255,255,255,0.9);
}

.orb .core {
  position: absolute;
  inset: 12px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(255,255,255,0.75);
  animation: corePulse 2.4s ease-in-out infinite;
}

@keyframes corePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.82); opacity: 0.55; }
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 6px;
  white-space: nowrap;
}

.brand-text p {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- bottoni ---------- */
.btn {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 11px 20px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 30px rgba(255,255,255,0.18); border-color: var(--white); }
.btn:active { transform: translateY(0) scale(0.97); }

.btn.white { background: var(--white); color: var(--black); border-color: var(--white); }
.btn.white:hover { box-shadow: 0 8px 38px rgba(255,255,255,0.35); }

.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--txt); background: rgba(255,255,255,0.07); box-shadow: none; border-color: transparent; }

.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: ripple 0.55s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* ---------- landing / hero ---------- */
.hero {
  min-height: calc(100vh - 74px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 40px 20px 60px;
  text-align: center;
}

.hero-title {
  font-size: clamp(46px, 9vw, 92px);
  font-weight: 900;
  letter-spacing: 10px;
  background: linear-gradient(90deg, #ffffff 0%, #c9c9d4 45%, #ffffff 55%, #8a8a99 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 6s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

.hero-tag {
  font-size: clamp(15px, 2.4vw, 19px);
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.typed-box {
  width: min(600px, 92vw);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 18px 22px;
  text-align: left;
  box-shadow: 0 10px 50px rgba(0,0,0,0.5), 0 0 60px rgba(255,255,255,0.04);
  animation: fadeUp 0.8s cubic-bezier(0.22, 0.9, 0.3, 1);
}

.typed-box .orb-mini {
  position: relative;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.7);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 4s linear infinite;
}

.typed-text {
  flex: 1;
  font-size: clamp(14px, 2.3vw, 17px);
  color: var(--txt);
  min-height: 1.3em;
  white-space: pre-wrap;
  word-break: break-word;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--white);
  animation: blinkCaret 1s steps(1) infinite;
}

@keyframes blinkCaret { 50% { opacity: 0; } }

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  animation: fadeUp 1s ease;
}

.hero-sub {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.4px;
  max-width: 560px;
  animation: fadeUp 1.2s ease;
}

.divider {
  width: min(700px, 86vw);
  height: 1px;
  margin: 30px auto 0;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.download-card {
  margin: 40px auto 80px;
  width: min(720px, 90vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 30px;
  display: flex;
  align-items: center;
  gap: 24px;
  text-align: left;
  box-shadow: 0 20px 70px rgba(0,0,0,0.5);
  animation: fadeUp 1.4s ease;
}

.download-icon {
  font-size: 40px;
  flex-shrink: 0;
}

.download-card h3 { font-size: 19px; letter-spacing: 1px; }
.download-card p { font-size: 13.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.download-cta { margin-left: auto; flex-shrink: 0; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.footer {
  position: relative;
  z-index: 2;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 18px;
  border-top: 1px solid var(--line);
  background: rgba(8,8,12,0.5);
  backdrop-filter: blur(10px);
}

/* ---------- pagina autenticazione ---------- */
.auth-wrap {
  min-height: calc(100vh - 74px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 18px 60px;
}

.auth-card {
  width: 420px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 34px 30px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 60px rgba(255,255,255,0.05);
  animation: pop 0.4s cubic-bezier(0.2, 1.3, 0.4, 1);
  text-align: center;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.9) translateY(14px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-card .crown { font-size: 34px; }

.auth-card h2 { font-size: 20px; letter-spacing: 1px; margin: 10px 0 6px; }
.auth-card .subtle { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 22px; }

.auth-card .field { margin-bottom: 14px; text-align: left; }

.auth-card .field label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 7px 3px;
  font-weight: 600;
}

.auth-card .field .input { margin-bottom: 0; }

.auth-card .pwd { position: relative; }

.auth-card .pwd .eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  opacity: 0.55;
  padding: 8px 10px;
  line-height: 1;
  transition: opacity 0.2s ease;
}

.auth-card .pwd .eye:hover { opacity: 1; }

.auth-card .btn.white {
  margin-top: 8px;
  width: 100%;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 15px;
  padding: 14px 18px;
}

.input {
  width: 100%;
  background: var(--black);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 13px 15px;
  font-family: inherit;
  font-size: 15px;
  color: var(--txt);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.input::placeholder { color: var(--muted); }

.input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft), 0 0 24px rgba(255,213,74,0.15);
}

.auth-error {
  display: none;
  font-size: 12.5px;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  background: var(--gold-soft);
  padding: 10px 13px;
  border-radius: 11px;
  margin-bottom: 14px;
  animation: fadeUp 0.3s ease;
}

.auth-error.show { display: block; }

.auth-back {
  display: block;
  margin-top: 22px;
  font-size: 13px;
  color: var(--gold);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  transition: opacity 0.2s ease;
  font-family: inherit;
}

.auth-back:hover { opacity: 0.8; }

/* ---------- app chat ---------- */
.app-layout { display: flex; flex: 1; min-height: 0; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-header {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,0.04);
  color: var(--txt);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.pro-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 5px 12px;
  border-radius: 999px;
  animation: crownGlow 2s ease-in-out infinite;
  white-space: nowrap;
}

@keyframes crownGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255,213,74,0.2); }
  50% { box-shadow: 0 0 26px rgba(255,213,74,0.55); }
}

.user-mini {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.sidebar {
  width: 262px;
  min-width: 262px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  background: rgba(8, 8, 12, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
}

.new-chat { width: 100%; }

.new-chat .plus { font-size: 16px; }

#chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

#chat-list::-webkit-scrollbar { width: 7px; }
#chat-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 999px; }

.chat-empty { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12.5px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.25s ease, transform 0.15s ease;
  animation: fadeUp 0.3s ease;
}

.chat-item:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.06); }

.chat-item.active {
  border-color: var(--white);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 18px rgba(255,255,255,0.1);
}

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

.chat-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }

.chat-del {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.chat-item:hover .chat-del { opacity: 1; visibility: visible; }
.chat-del:hover { background: rgba(255,255,255,0.14); color: var(--txt); }

.chat-main { flex: 1; overflow-y: auto; padding: 26px 20px 10px; scroll-behavior: smooth; }

.chat-main::-webkit-scrollbar { width: 9px; }
.chat-main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 999px; }

#messages { display: flex; flex-direction: column; gap: 18px; max-width: 860px; margin: 0 auto; }

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 78%; animation: fadeUp 0.4s cubic-bezier(0.22, 0.9, 0.3, 1); }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; align-items: flex-start; }

.msg-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 0 8px rgba(255,255,255,0.9);
}

.bubble {
  padding: 11px 15px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 16px;
}

.msg.user .bubble {
  background: var(--white);
  color: var(--black);
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 24px rgba(255,255,255,0.18);
}

.msg.bot .bubble {
  background: var(--panel);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
}

.msg.bot .bubble.streaming::after {
  content: "▎";
  margin-left: 2px;
  color: var(--white);
  animation: blink 0.85s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0.8;
}

.empty-state .ghost-orb {
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 4s linear infinite;
  box-shadow: 0 0 34px rgba(255,255,255,0.2);
}

.empty-state h2 { font-weight: 700; letter-spacing: 3px; font-size: 17px; color: var(--txt); }
.empty-state p { font-size: 13px; letter-spacing: 0.4px; }

.input-wrap {
  border-top: 1px solid var(--line);
  background: rgba(8, 8, 12, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 12px 18px 12px;
}

.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto;
}

.send-hint {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  margin-top: 7px;
  pointer-events: none;
}

.attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  height: 46px;
  padding: 0 13px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.attach-btn:hover { border-color: var(--white); box-shadow: 0 0 0 3px rgba(255,255,255,0.08); }

.attach-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.attach-ico { font-size: 16px; }
.attach-txt { font-size: 12.5px; color: var(--txt); font-weight: 600; }

.send-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 14px;
  background: var(--white);
  color: var(--black);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 22px rgba(255,255,255,0.25);
}

.send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(255,255,255,0.35); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto 10px;
}

.attach-preview.hidden { display: none; }

.attach-preview .ap-item {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

.attach-preview .ap-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-preview .ap-item .ap-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-preview .ap-item .ap-remove:hover { background: rgba(0,0,0,0.92); }

.msg .bubble img {
  max-width: 260px;
  max-height: 220px;
  border-radius: 10px;
  display: block;
}

.gen-img {
  max-width: 300px;
  max-height: 300px;
  width: auto;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  display: block;
  animation: genIn 0.6s cubic-bezier(0.2, 1.1, 0.3, 1);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.gen-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.gen-download {
  background: var(--white);
  color: var(--black);
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 22px rgba(255,255,255,0.22);
  transition: transform 0.15s ease, opacity 0.2s ease;
  animation: fadeUp 0.5s ease;
}

.gen-download:hover { transform: translateY(-1px); }
.gen-download:disabled { opacity: 0.5; cursor: wait; }

@keyframes genIn {
  from { opacity: 0; transform: scale(0.9) rotate(2deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.quota-badge {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--white);
  color: var(--black);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
}

.quota-badge.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.bubble-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.copy-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.copy-btn:hover { color: var(--white); border-color: var(--white); }

.input-bar:focus-within #message-area {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08), 0 0 30px rgba(255,255,255,0.08);
}

#message-area {
  flex: 1;
  resize: none;
  max-height: 140px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--txt);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  overflow-y: auto;
}

#message-area::placeholder { color: var(--muted); }

#message-area:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08), 0 0 30px rgba(255,255,255,0.08);
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 60;
  transform: translateX(-50%);
  background: var(--white);
  color: var(--black);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 0 26px rgba(255,255,255,0.2);
  animation: toastIn 0.4s cubic-bezier(0.2, 1.2, 0.4, 1);
  max-width: 84vw;
}

#toast.error {
  background: var(--black);
  color: var(--txt);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

#toast.gone { animation: toastOut 0.35s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.9); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.92); } }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .menu-btn { display: block; }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    width: 280px;
    max-width: 84vw;
    background: rgba(8,8,12,0.97);
    box-shadow: 0 0 60px rgba(0,0,0,0.7);
  }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 44;
    background: rgba(0,0,0,0.55);
    display: none;
  }
  .scrim.show { display: block; }
  .msg { max-width: 92%; }
  .user-mini { max-width: 110px; }
  .download-card { flex-direction: column; text-align: center; }
  .download-cta { margin-left: 0; }
}

@media (max-width: 520px) {
  .nav { padding: 12px 16px; }
  .brand-text p { display: none; }
  .hero { justify-content: flex-start; padding-top: 60px; }
  .hero-sub { font-size: 12px; }
  .typed-box { padding: 15px 16px; }
  .hero-cta { flex-direction: column; width: min(600px, 92vw); }
  .hero-cta .btn { width: 100%; }
  .attach-txt { display: none; }
  .input-wrap { padding: 10px 12px; }
  .attach-btn { padding: 0 12px; height: 44px; }
  .send-btn { width: 44px; height: 44px; }
  .send-hint { font-size: 10px; }
  .user-mini { display: none; }
  .credits-pill { font-size: 12px; padding: 6px 10px; }
}

/* ---------- crediti ---------- */
.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--white);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(255,255,255,0.06);
  transition: transform 0.15s ease, background 0.2s ease;
}
.credits-pill:hover { transform: translateY(-1px); background: rgba(255,255,255,0.12); }
.credits-pill .credits-ico { font-size: 15px; }

.credits-page {
  min-height: calc(100vh - 76px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 34px 16px;
}
.credits-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 26px 24px;
  box-shadow: 0 26px 70px rgba(0,0,0,0.5);
  animation: fadeUp 0.5s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.credits-card h2 { margin: 0; font-size: 22px; }
.muted { color: var(--muted); }
.hint { font-size: 13px; margin-top: -8px; min-height: 18px; }

.key-box { display: flex; flex-direction: column; gap: 8px; }
.key-box label { font-size: 12px; color: var(--muted); }
.key-row { display: flex; gap: 8px; }
.key-row input {
  flex: 1;
  background: #0a0a0e;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--white);
  padding: 12px 14px;
  font-size: 13px;
  font-family: inherit;
  letter-spacing: 0.5px;
}
.key-row input.filled { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(120,120,255,0.12); }

.credit-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 14px 16px;
}
.credit-balance span { color: var(--muted); font-size: 13px; }
.credit-balance strong { font-size: 20px; }

.btn.sm { padding: 8px 12px; font-size: 12px; width: auto; }
.btn.big { padding: 15px; font-size: 15px; }
.btn.block { width: 100%; }

/* modale get credit */
.get-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.get-modal-card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: fadeUp 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.get-modal-card h3 { margin: 0; font-size: 18px; }