/* ── Chat nativa ──────────────────────────────────────────── */
.chat {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0 10px;
  font-size: var(--chat-size);
  line-height: 1.5;
}

.chat-empty {
  display: grid;
  place-content: center;
  gap: 6px;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: var(--text-3);
}
.chat-empty strong { font: 600 15px/1.3 var(--font-ui); letter-spacing: 0.04em; color: var(--text-2); }

.msg {
  position: relative;
  padding: 3px 14px;
  overflow-wrap: anywhere;
}
.msg:hover { background: var(--hull-2); }
.msg-time {
  margin-right: 8px;
  font: 12px/1 var(--font-data);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}
.msg-badges { display: inline; }
.badge {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 4px;
  vertical-align: -3px;
}
.badge-text {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 4px;
  vertical-align: 1px;
  background: var(--badge, var(--line-hi));
  color: var(--ink);
  font: 700 10px/1 var(--font-ui);
}
.msg-name {
  padding: 0;
  border: 0;
  background: none;
  font-weight: 700;
  cursor: pointer;
}
.msg-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.msg-colon { margin-right: 6px; color: var(--text-3); }
.msg-text { color: var(--text); }
.msg.is-action .msg-text { font-style: italic; color: var(--user-color, var(--text)); }
.msg.is-deleted .msg-text { text-decoration: line-through; color: var(--text-3); }
.msg.is-deleted .emote { opacity: 0.35; }
.msg.is-mention { background: color-mix(in srgb, var(--volt) 13%, transparent); }
.msg.is-first { background: color-mix(in srgb, var(--pink) 12%, transparent); }
.msg.is-highlight { background: color-mix(in srgb, var(--ultra) 18%, transparent); }
.msg.is-self .msg-text { color: var(--text-2); }

.msg-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 5px;
  background: var(--pink);
  color: var(--ink);
  font: 700 10px/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 2px;
}
.msg-tag[data-kind='bits'] { background: var(--ultra); }
.msg-tag[data-kind='reward'] { background: var(--amber); }

.msg-reply .icon { width: 13px; height: 13px; vertical-align: -2px; }
.msg-reply {
  display: block;
  margin-bottom: 1px;
  font-size: 0.82em;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emote {
  display: inline-block;
  height: 1.8em;
  width: auto;
  margin: -0.4em 1px;
  vertical-align: middle;
}

.mention { color: var(--volt); font-weight: 600; }

.redact {
  padding: 0 2px;
  background: var(--hood);
  color: transparent;
  cursor: help;
  transition: color var(--fast), background var(--fast);
}
.redact:hover,
.redact:focus { color: var(--text); background: color-mix(in srgb, var(--hood) 30%, transparent); outline: none; }

.msg-actions {
  position: absolute;
  top: 50%;
  right: 8px;
  z-index: 2;
  display: none;
  translate: 0 -50%;
  background: var(--hull-3);
  box-shadow: inset 0 0 0 1px var(--line-hi);
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 30px; height: 28px; color: var(--text-2); }
.msg-actions .icon-btn:hover { background: var(--hull-2); color: var(--text); }
.msg-actions .icon-btn[data-act='ban']:hover,
.msg-actions .icon-btn[data-act='delete']:hover { color: var(--hood); }
.msg-actions .icon { width: 16px; height: 16px; }

/* Eventi nel flusso della chat */
.chat-event {
  --tone: var(--volt);
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--tone) 13%, var(--hull));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 45%, transparent);
}
.chat-event-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  background: var(--tone);
  color: var(--ink);
}
.chat-event-icon .icon { stroke-width: 2; }
.chat-event-text { display: grid; gap: 2px; min-width: 0; }
.chat-event-title { font: 700 15px/1.2 var(--font-ui); letter-spacing: 0.02em; }
.chat-event-title b { color: var(--tone); }
.chat-event-msg { color: var(--text-2); font-size: 0.92em; overflow-wrap: anywhere; }

.chat-system {
  padding: 4px 14px;
  color: var(--text-3);
  font-size: 0.88em;
}
.chat-system.is-error { color: var(--amber); }

.chat-new {
  position: absolute;
  left: 50%;
  bottom: calc(var(--composer-h, 60px) + 10px);
  z-index: 3;
  translate: -50% 0;
}

/* ── Casella di scrittura ─────────────────────────────────── */
.composer {
  position: relative;
  flex: none;
  display: grid;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: var(--hull);
}
.composer-reply {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 4px 4px 10px;
  background: var(--hull-2);
  color: var(--text-2);
  font-size: 12px;
}
.composer-reply span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-reply .icon-btn { width: 24px; height: 24px; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer-input {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  padding: 8px 10px;
  font: 14px/1.4 var(--font-body);
}
.composer-send { min-height: 38px; }
.composer-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.2;
}
.composer-count { font: 12px/1.2 var(--font-data); font-variant-numeric: tabular-nums; }
.composer-foot .is-over { color: var(--hood); }
.composer-login {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 4px 6px;
  color: var(--text-2);
  font-size: 13px;
}

.cmd-hints {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(100% + 4px);
  z-index: 4;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--hull-3);
  box-shadow: inset 0 0 0 1px var(--line-hi), var(--lift);
}
.cmd-hints li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}
.cmd-hints li[aria-selected='true'],
.cmd-hints li:hover { background: var(--hull-2); }
.cmd-hints code { font: 12px/1.4 var(--font-data); color: var(--volt); }
.cmd-hints span { color: var(--text-3); text-align: right; }

/* ── Chat ufficiale Twitch (iframe) ───────────────────────── */
.embed-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #18181b;
}
.embed-warning {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: var(--text-2);
}
.embed-warning strong { font: 600 16px/1.3 var(--font-ui); color: var(--text); }

/* ── Scheda utente ────────────────────────────────────────── */
.user-card {
  position: fixed;
  z-index: 60;
  width: 300px;
  padding: 14px;
  background: var(--hull-3);
  box-shadow: inset 0 0 0 1px var(--line-hi), var(--lift);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
.uc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.uc-name { font: 700 20px/1.15 var(--font-ui); letter-spacing: 0.02em; overflow-wrap: anywhere; }
.uc-meta { color: var(--text-3); font-size: 12px; margin-bottom: 12px; }
.uc-section { margin-top: 10px; }
.uc-label {
  margin-bottom: 6px;
  font: 600 10px/1 var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.uc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.uc-grid .btn { padding: 0 4px; }
.uc-row { display: flex; flex-wrap: wrap; gap: 4px; }
.uc-recent { max-height: 120px; overflow-y: auto; font-size: 13px; color: var(--text-2); }
.uc-recent p { padding: 3px 0; border-bottom: 1px solid var(--line); }

.chat-scroll.no-time .msg-time { display: none; }
.chat-scroll.no-censor .redact { padding: 0; background: none; color: inherit; cursor: auto; }
