/* UnityChat - Unified Chat Styles */

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

:root {
  --bg-primary: #0e0e10;
  --bg-secondary: #18181b;
  --bg-tertiary: #1f1f23;
  --bg-hover: #26262c;
  --text-primary: #efeff1;
  --text-secondary: #adadb8;
  --text-muted: #848494;
  --border: #2f2f35;
  --tw: #9146ff;
  --yt: #ff0000;
  --ki: #53fc18;
  --accent: #ff8c00;
  --accent-light: #ffc800;
  --accent-gradient: linear-gradient(160deg, #ffc800, #ff8c00);
  --accent-glow: 0 0 8px rgba(255, 140, 0, 0.5);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: text;
}

/* ---- Layout sizes ---- */
body.layout-medium { font-size: 14px; }
body.layout-medium .msg { padding: 4px 12px; line-height: 1.5; }
body.layout-medium .msg .pi { font-size: 9px; line-height: 16px; padding: 1px 4px; }
body.layout-medium .msg .ts { font-size: 11px; }
body.layout-medium .bdg-img { height: 20px; width: 20px; }
body.layout-medium .msg .tx img.emote { height: 2.25em; }
body.layout-medium #settings .setting-row label { font-size: 12px; }
body.layout-medium #settings input[type="text"],
body.layout-medium #settings input[type="color"],
body.layout-medium #settings select,
body.layout-medium #settings button { font-size: 14px; }

body.layout-large { font-size: 16px; }
body.layout-large .msg { padding: 5px 14px; line-height: 1.5; }
body.layout-large .msg .pi { font-size: 10px; line-height: 18px; padding: 1px 5px; }
body.layout-large .msg .ts { font-size: 12px; }
body.layout-large .bdg-img { height: 22px; width: 22px; }
body.layout-large .msg .tx img.emote { height: 2.5em; }
body.layout-large #msg-input { font-size: 14px; padding: 8px 10px; }
body.layout-large .reply-ctx { font-size: 12px; }
body.layout-large #settings .setting-row label { font-size: 13px; }
body.layout-large #settings input[type="text"],
body.layout-large #settings select { font-size: 15px; padding: 8px 10px; }
body.layout-large #settings button { font-size: 15px; padding: 8px 14px; }
body.layout-large #settings details summary { font-size: 15px; }

/* ---- Header ---- */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#header-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hdr-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: default;
}

.hdr-logo {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 0 6px rgba(255, 140, 0, 0.5));
}

/* Update dot + tooltip: both hidden unless .has-update is on the wrap.
   Tooltip anchors to the left edge of the logo so it doesn't run off the
   right side of a narrow side panel — the panel can be as tight as
   ~300px and the tooltip is ~290px wide. */
.hdr-logo-wrap .update-dot,
.hdr-logo-wrap .update-tooltip {
  display: none;
}
.hdr-logo-wrap.has-update {
  cursor: pointer;
}
/* Inside the tooltip, revert to the default text/arrow cursor — the whole
   card isn't clickable, only the inline link is. Link gets pointer back
   via the <a> user-agent default. */
.hdr-logo-wrap.has-update .update-tooltip {
  cursor: default;
}
.hdr-logo-wrap.has-update .update-dot {
  display: block;
  position: absolute;
  top: -2px;
  right: -3px;
  width: 9px;
  height: 9px;
  background: #e5484d;
  border: 1.5px solid var(--bg);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(229, 72, 77, 0.85);
  animation: update-pulse 1.5s ease-in-out infinite;
  pointer-events: none;
}
.hdr-logo-wrap.has-update .update-tooltip {
  display: block;
  position: absolute;
  /* Offset enough for the arrow to sit between the logo and the card. */
  top: calc(100% + 14px);
  left: -8px;
  min-width: 260px;
  /* Layout-scale variable drives size across layout-small/medium/large.
     Resolves to 1 by default, 1.1 at medium, 1.22 at large. */
  --ut-scale: 1;
  max-width: min(calc(300px * var(--ut-scale)), calc(100vw - 24px));
  padding: calc(14px * var(--ut-scale));
  background: #151518;
  border: 1px solid rgba(255, 140, 0, 0.45);
  border-radius: 6px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.7), 0 0 18px rgba(255, 140, 0, 0.15);
  z-index: 200;
  font-size: calc(12px * var(--ut-scale));
  line-height: 1.45;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden; /* so countdown bar matches tooltip corners */
}

/* Scale tooltip with layout size (body.layout-medium/large set globally) */
body.layout-medium .hdr-logo-wrap.has-update .update-tooltip { --ut-scale: 1.1; }
body.layout-large  .hdr-logo-wrap.has-update .update-tooltip { --ut-scale: 1.22; }

/* Speech-bubble arrow pointing up to the logo. Two stacked triangles
   (outer=border color, inner=panel fill) positioned between logo and
   tooltip. Rendered as direct children of .hdr-logo-wrap (not inside
   .update-tooltip) so the tooltip's overflow:hidden doesn't clip them. */
.hdr-logo-wrap.has-update .ut-arrow-outer,
.hdr-logo-wrap.has-update .ut-arrow-inner {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  transform: translateY(-4px);
  z-index: 201;
}
.hdr-logo-wrap.has-update .ut-arrow-outer {
  top: calc(100% + 2px);
  left: 4px;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 12px solid rgba(255, 140, 0, 0.55);
  filter: drop-shadow(0 -1px 0 rgba(255, 140, 0, 0.25));
}
.hdr-logo-wrap.has-update .ut-arrow-inner {
  top: calc(100% + 4px);
  left: 5px;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 11px solid #151518;
}

/* Show tooltip + arrow on JS-controlled hover-intent OR during auto-reveal.
   JS toggles .is-hovering with a 250ms hide delay, so the cursor can cross
   the pixel gap between logo and tooltip without losing visibility. */
.hdr-logo-wrap.has-update.is-hovering .update-tooltip,
.hdr-logo-wrap.has-update.is-hovering .ut-arrow-outer,
.hdr-logo-wrap.has-update.is-hovering .ut-arrow-inner,
.hdr-logo-wrap.has-update.auto-reveal .update-tooltip,
.hdr-logo-wrap.has-update.auto-reveal .ut-arrow-outer,
.hdr-logo-wrap.has-update.auto-reveal .ut-arrow-inner {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Countdown bar — starts 100% width, scales to 0 from the right edge over
   10s. Visible only during .auto-reveal phase. transform-origin: left
   keeps the bar "running" right-to-left as remaining time depletes. */
.hdr-logo-wrap.has-update .ut-countdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff7a00, #ffc25a);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}
.hdr-logo-wrap.has-update.auto-reveal .ut-countdown {
  animation: ut-countdown 10s linear forwards;
}
@keyframes ut-countdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.hdr-ver {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.hdr-beta {
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.5;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

#btn-popout, #btn-dump, #btn-settings {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

@keyframes update-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.25); opacity: 0.7; }
}
.ut-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}
.ut-version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.ut-text {
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.ut-text code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: rgba(255, 140, 0, 0.12);
  border: 1px solid rgba(255, 140, 0, 0.3);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}
.ut-text a {
  color: #ffc800;
  text-decoration: underline;
  transition: color 0.12s ease, text-shadow 0.12s ease;
}
.ut-text a:hover,
.ut-text a:focus-visible {
  color: #ffe28a;
  text-shadow: 0 0 8px rgba(255, 200, 0, 0.35);
}
.ut-explorer {
  background: #1c1c20;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
}
.ut-exp-path {
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 600;
}
.ut-exp-list {
  list-style: none;
  padding: 0 0 0 10px;
  margin: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.12);
}
.ut-exp-list li {
  padding: 1px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ut-exp-highlight {
  color: var(--accent);
  font-weight: 700;
  background: rgba(255, 140, 0, 0.12);
  border-radius: 3px;
  padding: 2px 4px !important;
  margin: 2px -4px;
}
.ut-exp-arrow {
  color: var(--accent);
  animation: arrow-bounce 1.1s ease-in-out infinite;
  font-size: 12px;
}
@keyframes arrow-bounce {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-3px); }
}

#btn-dump, #btn-popout {
  font-size: 14px;
}

#btn-popout:hover, #btn-dump:hover, #btn-settings:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ---- Settings ---- */

#settings {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

#settings.hidden {
  display: none;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-row > label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-row input[type="text"],
.setting-row select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.setting-row input[type="text"]:focus {
  border-color: var(--accent);
}

.platforms {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
}

.platform-check {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px !important;
  color: var(--text-primary) !important;
  text-transform: none !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
}

.platform-check input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

.badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  color: #fff;
  line-height: 14px;
}

.badge.tw { background: var(--tw); }
.badge.yt { background: var(--yt); }
.badge.ki { background: var(--ki); color: #000; }

.actions {
  flex-direction: row;
  gap: 6px;
}

.actions button {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
}

.actions button:hover {
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--accent-gradient) !important;
  color: #000 !important;
  border-color: var(--accent) !important;
  box-shadow: var(--accent-glow);
}

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

/* "Jsem streamer" inline button — sits in the Kanály summary header */
#channels-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-streamer-inline {
  padding: 4px 10px;
  background: var(--accent-gradient);
  color: #000;
  font-weight: 600;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.2px;
  line-height: 1.4;
  margin-right: 8px;
}
.btn-streamer-inline:hover { filter: brightness(1.1); }
.btn-streamer-inline:active { transform: translateY(1px); }

/* Auto-switch loading banner (shown during reconnect to new streamer) */
.switch-banner {
  padding: 8px 14px;
  background: var(--accent-gradient);
  color: #000;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  animation: pulse 1.5s ease-in-out infinite;
}
.switch-banner.hidden { display: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ---- Nickname setting ---- */

.save-row {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}
#input-username[readonly],
#input-channel[readonly],
#input-kick-channel[readonly],
#input-yt-channel[readonly] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-nick {
  background: var(--accent-gradient);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 5px 12px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.btn-nick:disabled { opacity: 0.5; cursor: default; }
/* ---- Collapsible channel settings ---- */

.settings-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
}
.settings-section summary {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.settings-section summary::-webkit-details-marker { display: none; }
.settings-section summary::after {
  content: '+';
  font-size: 14px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.settings-section[open] summary::after {
  content: '−';
}
.settings-section .setting-row {
  padding: 4px 10px 6px;
}
.settings-section .setting-row:last-child {
  padding-bottom: 10px;
}

.nick-status {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  color: var(--text-muted);
  min-height: 15px;
}
.color-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 2px;
}
.color-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.color-row input[type="color"] {
  width: 32px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px;
  background: var(--bg-secondary);
  cursor: pointer;
}
.color-row input[type="text"] {
  flex: 1;
  font-family: monospace;
  font-size: 12px;
}
.nick-status.error { color: #ff4444; }

/* ---- Dev tools ---- */

.dev-mode-row { border-top: 1px solid rgba(255, 255, 255, 0.06); padding-top: 8px; margin-top: 4px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
.dev-mode-row label { font-size: 10px; color: var(--text-muted); opacity: 0.4; }
.dev-mode-row label:hover { opacity: 0.7; }
.kofi-link { font-size: 11px; color: var(--text-muted); opacity: 0.55; text-decoration: none; transition: opacity 0.15s; }
.kofi-link:hover { opacity: 0.9; color: #ff5e5b; }

/* Author credit stack — sits to the right of Dev mode checkbox */
.author-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  line-height: 1.2;
}
.author-link {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.55;
  text-decoration: none;
  transition: opacity 0.15s, color 0.15s;
  font-family: 'JetBrains Mono', monospace, monospace;
}
.author-link .author-by { opacity: 0.7; }
.author-link .author-name { font-weight: 600; color: var(--accent); opacity: 0.85; }
.author-link:hover { opacity: 1; }
.author-link:hover .author-name { color: #ffc800; }
.dev-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dev-tools.hidden { display: none; }
.dev-tools button {
  font-size: 11px;
  padding: 4px 10px;
  background: rgba(255, 60, 60, 0.1);
  border: 1px solid rgba(255, 60, 60, 0.3);
  border-radius: 4px;
  color: #ff6b6b;
  cursor: pointer;
}
.dev-tools button:hover {
  background: rgba(255, 60, 60, 0.2);
}
.nick-status.success { color: #53fc18; }

/* ---- Status + Filter Bar ---- */

#bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

#statuses {
  display: flex;
  gap: 10px;
}

.st {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #555;
  display: inline-block;
  flex-shrink: 0;
}

.dot.connected { background: #00e676; box-shadow: 0 0 4px #00e676; }
.dot.connecting { background: #ffc107; animation: pulse 1s infinite; }
.dot.error { background: #ff5252; }
.dot.disabled { background: #333; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#filters {
  display: flex;
  gap: 3px;
}

.fbtn {
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 16px;
}

.fbtn.active {
  color: var(--text-primary);
  border-color: var(--border);
}

.fbtn:hover {
  background: var(--bg-hover);
}

/* ---- Chat ---- */

#chat-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#chat {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
  /* Reserve scrollbar gutter even when content doesn't overflow yet — stops
     the width change (and resulting multi-message reflow / "vibration")
     the moment chat first grows past viewport. */
  scrollbar-gutter: stable;
  /* Hard-pin overflow anchor off — browsers sometimes try to "hold" scroll
     at a message during reflows, which on fast chat reads as jitter. */
  overflow-anchor: none;
}

#chat::-webkit-scrollbar { width: 5px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#chat::-webkit-scrollbar-thumb:hover { background: #555; }

/* ---- Cleared messages (timeout / ban / single delete) ----
   Mirrors vanilla Twitch: the message stays visible but greyed + line-
   through, with a small inline label noting the moderator action. Live
   clears (CLEARCHAT/CLEARMSG over IRC) and cached _cleared field both
   feed the same .cleared class so reload preserves history. */
.msg.cleared {
  opacity: 0.55;
}
.msg.cleared .tx,
.msg.cleared .reply-ctx {
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  text-decoration-thickness: 1px;
  font-style: italic;
}
.cleared-note {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  background: rgba(229, 72, 77, 0.15);
  border: 1px solid rgba(229, 72, 77, 0.4);
  color: #ff9a9d;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-radius: 3px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ---- Loading overlay ---- */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at center,
    rgba(20, 20, 25, 0.96) 0%,
    rgba(14, 14, 16, 0.98) 60%,
    rgba(10, 10, 13, 1) 100%);
  z-index: 50;
  pointer-events: auto;
  transition: opacity 0.45s ease, visibility 0.45s ease;
  opacity: 1;
}
.loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loading-overlay.hidden { display: none; }

.lo-logo-stack {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lo-logo {
  width: 56px;
  height: 56px;
  filter: drop-shadow(0 0 12px rgba(255, 140, 0, 0.55));
  animation: lo-logo-pulse 1.8s ease-in-out infinite;
  position: relative;
  z-index: 2;
}
.lo-logo-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle at center,
    rgba(255, 140, 0, 0.45) 0%,
    rgba(255, 140, 0, 0.18) 35%,
    transparent 70%);
  animation: lo-glow-pulse 1.8s ease-in-out infinite;
  z-index: 1;
}
@keyframes lo-logo-pulse {
  0%, 100% { transform: scale(0.88); filter: drop-shadow(0 0 10px rgba(255, 140, 0, 0.45)); }
  50%      { transform: scale(1.14); filter: drop-shadow(0 0 28px rgba(255, 140, 0, 0.95)); }
}
@keyframes lo-glow-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.7; }
  50%      { transform: scale(1.25); opacity: 1; }
}

.lo-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  position: relative;
}
/* Animated trailing dots after the label, cycling . / .. / ... */
.lo-text::after {
  content: '';
  display: inline-block;
  width: 20px;
  text-align: left;
  color: var(--accent);
  animation: lo-dots 1.4s steps(4, end) infinite;
}
@keyframes lo-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

.lo-platforms {
  display: flex;
  gap: 8px;
}
.lo-pill {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 3px 10px;
  opacity: 0.4;
  transition: opacity 0.25s, color 0.25s, background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.lo-pill.lo-pulse {
  /* Currently-connecting platform pulses softly */
  animation: lo-pill-pulse 1.2s ease-in-out infinite;
  opacity: 1;
}
.lo-pill.lo-connected {
  /* Connected platform: lit, no animation, brand color */
  opacity: 1;
  animation: none;
  color: #0a0a0d;
  background: linear-gradient(135deg, #ffc25a, #ff7a00);
  border-color: transparent;
  box-shadow: 0 0 10px rgba(255, 140, 0, 0.45);
}
@keyframes lo-pill-pulse {
  0%, 100% { background: rgba(255, 140, 0, 0.10); border-color: rgba(255, 140, 0, 0.25); color: var(--text-primary); }
  50%      { background: rgba(255, 140, 0, 0.25); border-color: rgba(255, 140, 0, 0.55); color: #ffc25a; }
}

/* Indeterminate progress bar — bouncing left-to-right slug. Using
   transform/will-change so the animation stays on the compositor
   thread even when the main thread is busy hydrating the cache. */
.lo-bar {
  width: 160px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.lo-bar > span {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 45%;
  background: linear-gradient(90deg, transparent 0%, #ff7a00 30%, #ffc25a 55%, #ff7a00 75%, transparent 100%);
  border-radius: 2px;
  transform: translateX(-100%);
  will-change: transform;
  animation: lo-bar-slide 1.35s cubic-bezier(0.55, 0.1, 0.45, 0.9) infinite;
  box-shadow: 0 0 8px rgba(255, 122, 0, 0.55);
}
@keyframes lo-bar-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(355%); }
}

/* Message */

.msg {
  position: relative;
  padding: 2px 10px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  /* Isolate each message's layout from its neighbors — when a message's
     own content changes (emote/avatar async load, paint retint, cleared
     banner), the reflow stops at its boundary instead of cascading
     through the list as sub-pixel jitter. */
  contain: layout style;
}

.msg:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Hover action buttons (reply etc.) */
.msg-actions {
  display: none;
  position: absolute;
  right: 4px;
  /* Float the action cluster above the message line so it doesn't sit
     on top of inline emotes the user wants to hover for the preview. */
  top: -14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 5;
}

.msg:hover .msg-actions {
  display: flex;
  gap: 0;
}

.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 20px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
}

.msg-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.msg-action-btn svg {
  display: block;
  width: 11px;
  height: 11px;
}

.msg .pi {
  display: inline-block;
  font-size: 8px;
  font-weight: 800;
  padding: 0 3px;
  border-radius: 2px;
  color: #fff;
  margin-right: 3px;
  vertical-align: middle;
  line-height: 14px;
  letter-spacing: 0.3px;
}

.msg .pi.tw { background: var(--tw); }
.msg .pi.yt { background: var(--yt); }
.msg .pi.ki { background: var(--ki); color: #000; }

.msg .ts {
  color: var(--text-muted);
  font-size: 10px;
  margin-right: 3px;
}

/* User-toggled via settings — hides timestamps without re-rendering msgs. */
body.no-timestamps .msg .ts { display: none; }

.msg .bdg {
  margin-right: 2px;
  display: inline;
  vertical-align: middle;
}

.bdg-img {
  height: 18px;
  width: 18px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 1px;
}

.msg .pi.uc { background: linear-gradient(160deg, #ffc800, #ff8c00); color: #000; box-shadow: 0 0 6px rgba(255, 140, 0, 0.5); }

/* Custom tooltip pro platform badges — JS-positioned, viewport-clamped */
.msg .pi[data-tooltip] {
  cursor: default;
}

.uc-tooltip {
  position: fixed;
  display: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
}
.uc-tooltip.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* @mention / reply-to-you highlight */
.msg.mentioned {
  background: rgba(200, 50, 50, 0.2);
  border-left: 2px solid #cc3333;
  padding-left: 8px;
}

.msg.mentioned:hover {
  background: rgba(200, 50, 50, 0.35);
}

/* First-time chatter */
.msg.first-msg {
  background: rgba(145, 70, 255, 0.12);
  border-left: 2px solid #9146ff;
  padding-left: 8px;
}

.msg.first-msg:hover {
  background: rgba(145, 70, 255, 0.22);
}

/* (first-label removed — replaced by right-side .msg-tag system) */

/* Right-aligned tag line above message content */
.msg-tag-line {
  text-align: right;
  padding: 1px 4px 0 18px;
  line-height: 4pt;
}
.msg-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.85;
}
/* @mention inside message text — bold + colored to the target user's
   chat color (JS writes inline color via _processMentions). Unknown
   users fall back to default bold styling. */
.tx .mention {
  font-weight: 700;
}

.msg-tag.tag-reply { color: #cc3333; }
.msg-tag.tag-mention { color: #cc3333; }
.msg-tag.tag-first { color: #9146ff; }
.msg-tag.tag-raid { color: #ff6b6b; }
.msg-tag.tag-raider { color: #b2e63d; }
.msg-tag.tag-sus { color: #ffc107; }

/* Announcement (USERNOTICE msg-id=announcement) — callout-style block with
   bilateral accent bars (left + right) whose color/gradient is driven by
   msg-param-color. Prominent by design: stronger background, vertical
   spacing, glow, and a pulsing icon so it stands out in a fast chat. */
.msg.announcement {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  /* Left + right borders; top/bottom intentionally 0 so we can run a gradient
     across both vertical edges via border-image without ugly corner pieces. */
  border-style: solid;
  border-color: #9146ff;
  border-width: 0 5px 0 5px;
  padding: 8px 12px;
  margin: 6px 0;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 16px rgba(145, 70, 255, 0.18);
}

/* PRIMARY = gold shimmer gradient on both edges (warmer / premium feel
   than the rainbow). `border-image` with `slice: 1` fills each edge
   strip with the full gradient; top/bottom have zero width so there
   are no stretched corner artifacts. */
.msg.announcement[data-announcement-color="PRIMARY"] {
  border-color: transparent;
  /* Mirrored: edges darker, middle brighter — gives the strip a "lit
     from the centre" glint rather than uniform gold. */
  border-image: linear-gradient(
    180deg,
    #8a5a00 0%,
    #c98a11 20%,
    #ffd93d 45%,
    #fff1a8 50%,
    #ffd93d 55%,
    #c98a11 80%,
    #8a5a00 100%
  ) 1;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 20px rgba(255, 200, 40, 0.35);
}
.msg.announcement[data-announcement-color="BLUE"]   { border-color: #00d7ec; box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset, 0 0 16px rgba(0, 215, 236, 0.28); }
.msg.announcement[data-announcement-color="GREEN"]  { border-color: #00db84; box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset, 0 0 16px rgba(0, 219, 132, 0.28); }
.msg.announcement[data-announcement-color="ORANGE"] { border-color: #ffb31e; box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset, 0 0 16px rgba(255, 179, 30, 0.3); }
.msg.announcement[data-announcement-color="PURPLE"] { border-color: #9146ff; box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset, 0 0 16px rgba(145, 70, 255, 0.28); }

.announcement-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding-bottom: 5px;
  color: #fff;
  opacity: 0.92;
}
.announcement-icon {
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(255, 175, 20, 0.5));
  animation: announcement-pulse 2.4s ease-in-out infinite;
}
.msg.announcement[data-announcement-color="PRIMARY"] .announcement-label {
  /* Mirror the border gradient: dark amber edges, bright gold center
     for consistent "lit from the middle" feel across label + border. */
  background: linear-gradient(90deg, #8a5a00, #c98a11, #ffd93d, #fff1a8, #ffd93d, #c98a11, #8a5a00);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
@keyframes announcement-pulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 4px rgba(255,175,20,0.5)); }
  50%      { transform: scale(1.12); filter: drop-shadow(0 0 8px rgba(255,175,20,0.75)); }
}

/* Raid — same prominence treatment as Announcements: bilateral accent
   borders + glow + pulsing rocket icon header so it never gets lost in
   fast chat. */
.msg.raid {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.18), rgba(255, 107, 107, 0.06));
  border-style: solid;
  border-color: transparent;
  border-width: 0 5px 0 5px;
  border-image: linear-gradient(180deg, #ff4500 0%, #ff6b6b 50%, #ffaf14 100%) 1;
  padding: 8px 12px;
  margin: 6px 0;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 18px rgba(255, 107, 107, 0.32);
}
.msg.raid:hover {
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.26), rgba(255, 107, 107, 0.1));
}

.raid-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding-bottom: 5px;
  color: #fff;
  opacity: 0.95;
}
.raid-icon {
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(255, 107, 107, 0.55));
  animation: raid-pulse 1.6s ease-in-out infinite;
  transform-origin: center;
}
.raid-label {
  background: linear-gradient(90deg, #ffaf14, #ff4500, #ff6b6b);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.raid-count {
  margin-left: auto;
  background: rgba(255, 69, 0, 0.18);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: #ffd9c2;
  text-transform: none;
}
@keyframes raid-pulse {
  0%, 100% { transform: translateX(0) scale(1); filter: drop-shadow(0 0 4px rgba(255,107,107,0.55)); }
  40%      { transform: translateX(2px) scale(1.18); filter: drop-shadow(0 0 10px rgba(255,107,107,0.85)); }
}

/* (raid-label legacy comment removed — replaced by header system) */

/* Raider (came from raid) */
.msg.raider-msg {
  background: rgba(178, 230, 61, 0.12);
  border-left: 2px solid #b2e63d;
  padding-left: 8px;
}
.msg.raider-msg:hover {
  background: rgba(178, 230, 61, 0.22);
}

/* ==== Community highlights (hype train / gift leaderboard / pinned) ==== */
#highlights-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: linear-gradient(135deg, rgba(0, 216, 217, 0.14), rgba(145, 70, 255, 0.1));
  border-bottom: 1px solid rgba(0, 216, 217, 0.3);
  overflow-x: hidden;
}
#highlights-banner.hidden { display: none; }
.hl-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.92em;
  color: #e8e8ef;
  line-height: 1.35;
}
.hl-card .hl-icon { flex-shrink: 0; font-size: 1.2em; }
.hl-card .hl-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.hl-card .hl-body {
  flex: 1;
  min-width: 0;
  /* Multi-line — let the raider/gifter/whatever text wrap instead of
     being truncated with "…". 3-line clamp caps runaway captions. */
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hl-card.hl-hype-train {
  background: linear-gradient(90deg, rgba(0, 216, 217, 0.3), rgba(0, 216, 217, 0.12));
  box-shadow: 0 0 10px rgba(0, 216, 217, 0.2);
}
.hl-card.hl-gift-leaderboard {
  background: linear-gradient(90deg, rgba(145, 70, 255, 0.28), rgba(145, 70, 255, 0.12));
}
/* Raid callout — full width, bilateral red→gold border, pulsing
   rocket header + structured body (raider → target + viewer count +
   points). Matches the .msg.raid chat-line treatment so the raid
   identity reads consistent across both the banner and chat. */
/* Pin highlight card — fancy amber/gold design with layered glow,
   bilateral gradient borders, pulsing pin icon, and strong contrast
   for author names (readableColor() in JS clamps dark hues). */
.hl-card.hl-pin {
  display: block;
  padding: 0;
  position: relative;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 183, 77, 0.10), transparent 60%),
    linear-gradient(155deg, rgba(230, 161, 26, 0.18) 0%, rgba(184, 106, 0, 0.08) 55%, rgba(120, 60, 0, 0.04) 100%);
  /* border-image breaks border-radius in Chrome (spec: ignored when
     border-image is set). Use a solid amber border + layered box-shadow
     for the gradient ring effect so the rounded corners stay smooth. */
  border: 1px solid rgba(230, 161, 26, 0.45);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(255, 195, 80, 0.18),
    0 0 14px -2px rgba(230, 161, 26, 0.28),
    0 4px 18px -4px rgba(120, 60, 0, 0.35),
    inset 0 1px 0 rgba(255, 220, 150, 0.12),
    inset 0 -1px 0 rgba(120, 60, 0, 0.18);
  overflow: hidden;
  animation: hl-pin-glow 5s ease-in-out infinite;
}
.hl-card.hl-pin::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 195, 80, 0.55) 30%, rgba(255, 230, 150, 0.85) 50%, rgba(255, 195, 80, 0.55) 70%, transparent);
  opacity: 0.85;
  pointer-events: none;
}
@keyframes hl-pin-glow {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255, 195, 80, 0.16),
      0 0 14px -2px rgba(230, 161, 26, 0.22),
      0 4px 18px -4px rgba(120, 60, 0, 0.32),
      inset 0 1px 0 rgba(255, 220, 150, 0.12),
      inset 0 -1px 0 rgba(120, 60, 0, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 210, 120, 0.30),
      0 0 22px -2px rgba(255, 195, 80, 0.45),
      0 6px 24px -4px rgba(120, 60, 0, 0.45),
      inset 0 1px 0 rgba(255, 235, 180, 0.18),
      inset 0 -1px 0 rgba(120, 60, 0, 0.18);
  }
}
.hl-pin-wrap { display: block; position: relative; }
.hl-pin-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  background: linear-gradient(180deg, rgba(255, 183, 77, 0.08), transparent);
}
.hl-pin-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  color: #ffc34d;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255, 195, 80, 0.55));
  animation: hl-pin-icon-pulse 2.6s ease-in-out infinite;
}
@keyframes hl-pin-icon-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(255, 195, 80, 0.55)); }
  50%      { transform: scale(1.1); filter: drop-shadow(0 0 8px rgba(255, 210, 120, 0.85)); }
}
.hl-pin-head-text {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text-muted, #b5b5c0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 600;
}
.hl-pin-head-user {
  color: #ffc34d;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12.5px;
  margin-left: 2px;
  text-shadow: 0 0 8px rgba(255, 195, 80, 0.4);
}
.hl-pin-btn {
  flex-shrink: 0;
  display: inline-flex;
  width: 24px;
  height: 24px;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #9a9aa6);
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.hl-pin-btn:hover {
  background: rgba(255, 195, 80, 0.14);
  color: #ffd680;
  transform: translateY(-1px);
}
.hl-pin-chev { transition: transform 0.22s cubic-bezier(.4,.0,.2,1); transform-origin: 12px 12px; }
.hl-pin-wrap.collapsed .hl-pin-chev { transform: rotate(-90deg); }
.hl-pin-body {
  padding: 4px 14px 12px 14px;
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.22s ease, padding 0.22s ease, opacity 0.15s ease;
}
.hl-pin-wrap.collapsed .hl-pin-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}
.hl-pin-body-text {
  font-size: 14.5px;
  line-height: 1.45;
  font-weight: 600;
  color: #f6f2ea;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.hl-pin-body-text a {
  color: #ffc34d;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(255, 195, 80, 0.5);
  text-underline-offset: 2px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.hl-pin-body-text a:hover {
  color: #ffdc80;
  text-decoration-color: #ffdc80;
}
.hl-pin-body-text img.emote {
  height: 1.7em;
  vertical-align: middle;
  margin: -2px 2px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
/* Author footer: badges + display name + timestamp. Warm divider,
   padded chip-like rows. Name uses readableColor() in JS + text-shadow
   for guaranteed contrast against the amber background. */
.hl-pin-foot {
  margin-top: 10px;
  padding: 8px 2px 2px;
  border-top: 1px solid rgba(255, 195, 80, 0.22);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted, #b5b5c0);
  flex-wrap: nowrap;
  min-width: 0;
  position: relative;
}
.hl-pin-author {
  white-space: nowrap;
  flex-shrink: 0;
}
.hl-pin-time {
  flex-shrink: 0;
  white-space: nowrap;
}
.hl-pin-foot::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 210, 120, 0.7), transparent);
  pointer-events: none;
}
.hl-pin-badges {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 6px;
}
.hl-pin-badge {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.hl-pin-author {
  font-weight: 800;
  font-size: 13.5px;
  letter-spacing: 0.1px;
  /* JS applies readableColor() to ensure dark hex colors are
     brightened enough to read against the amber card. Stacked
     shadows lock in contrast for any hue. */
  text-shadow:
    0 0 6px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.7);
}
.hl-pin-time {
  color: #d4a85a;
  font-size: 11px;
  font-weight: 600;
  margin-left: auto;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 195, 80, 0.15);
  border-radius: 10px;
  letter-spacing: 0.2px;
}

.hl-card.hl-raid {
  display: block;
  padding: 0;
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.22), rgba(255, 107, 107, 0.07));
  border-style: solid;
  border-color: transparent;
  border-width: 0 5px 0 5px;
  border-image: linear-gradient(180deg, #ff4500 0%, #ff6b6b 50%, #ffaf14 100%) 1;
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 14px rgba(255, 107, 107, 0.32);
}
.hl-raid-wrap { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; }
.hl-raid-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.hl-raid-icon {
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(255, 107, 107, 0.55));
  animation: raid-pulse 1.6s ease-in-out infinite;
  transform-origin: center;
}
.hl-raid-label {
  background: linear-gradient(90deg, #ffaf14, #ff4500, #ff6b6b);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.hl-raid-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hl-raid-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 107, 107, 0.7);
  box-shadow: 0 0 10px rgba(255, 107, 107, 0.45);
}
.hl-raid-body {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.hl-raid-title {
  font-size: 0.98em;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hl-raid-raider { color: #ffd9c2; }
.hl-raid-arrow { color: #ffaf14; margin: 0 4px; font-weight: 900; }
.hl-raid-target { color: #ffeaa1; }
.hl-raid-meta {
  margin-top: 3px;
  display: flex;
  gap: 12px;
  font-size: 0.86em;
  color: #e0c7a8;
}
.hl-raid-meta .hl-raid-points { color: #ffd93d; font-weight: 700; }
.hl-raid-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  color: #ffd9c2;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  margin-left: auto;
}
.hl-raid-close:hover {
  background: rgba(255, 107, 107, 0.25);
  color: #fff;
  transform: scale(1.08);
}
.hl-card.hl-raid.has-accent .hl-raid-close {
  border-color: rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.35);
}
.hl-card.hl-raid.has-accent .hl-raid-close:hover {
  background: rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.3);
}
/* Countdown progress bar — fills from 100% to 0 over duration, giving
   a visual sense of the "raid in N seconds" deadline. */
.hl-raid-bar {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  margin-top: 2px;
}
.hl-raid-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, #ff6b6b 0%, #ffaf14 50%, #ffd93d 100%);
  box-shadow: 0 0 6px rgba(255, 175, 20, 0.55);
  animation: hl-raid-countdown linear forwards;
  transform-origin: left center;
}
@keyframes hl-raid-countdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
.hl-card.hl-raid.has-accent .hl-raid-bar-fill {
  background: linear-gradient(
    90deg,
    rgb(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b)) 0%,
    rgb(255, 175, 20) 60%,
    rgb(255, 217, 61) 100%
  );
  box-shadow: 0 0 6px rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.6);
}
/* When the card sampled a dominant colour from the avatar, recolor
   the background + border + glow ring from that accent so the banner
   feels "themed" to the raider's brand instead of a fixed red/gold. */
.hl-card.hl-raid.has-accent {
  background: linear-gradient(
    180deg,
    rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.32),
    rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.1)
  );
  border-image: linear-gradient(
    180deg,
    rgb(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b)) 0%,
    rgb(calc(var(--hl-accent-r) * 0.7), calc(var(--hl-accent-g) * 0.7), calc(var(--hl-accent-b) * 0.7)) 50%,
    rgb(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b)) 100%
  ) 1;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 14px rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.4);
}
.hl-card.hl-raid.has-accent .hl-raid-avatar {
  border-color: rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.8);
  box-shadow: 0 0 12px rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.55);
}

/* ==== Subscription gift events ==== */
/* Bundle header: full-width purple pill */
.msg.gift-bundle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin: 4px 0;
  background: linear-gradient(135deg, rgba(145, 70, 255, 0.28), rgba(145, 70, 255, 0.18));
  border: 1px solid rgba(145, 70, 255, 0.5);
  border-radius: 10px;
  color: #e8dcff;
  box-shadow: 0 0 16px rgba(145, 70, 255, 0.25);
}
.msg.gift-bundle .gift-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(145, 70, 255, 0.35);
  color: #fff;
  flex-shrink: 0;
}
.msg.gift-bundle .gift-body {
  flex: 1;
  min-width: 0;
}
.msg.gift-bundle .un {
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.msg.gift-bundle .gift-count {
  font-weight: 700;
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

/* Individual subgift line: compact row with purple left border */
.msg.sub-gift {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  margin: 2px 0;
  background: rgba(145, 70, 255, 0.06);
  border-left: 3px solid #9146ff;
  border-radius: 4px;
  color: var(--text, #d7d7e0);
}
.msg.sub-gift .gift-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  color: #b78cff;
  flex-shrink: 0;
}
.msg.sub-gift .gift-body {
  flex: 1;
  min-width: 0;
}
.msg.sub-gift .un {
  font-weight: 700;
  cursor: pointer;
  margin-right: 2px;
}
.msg.sub-gift .gift-line {
  font-size: 0.95em;
  color: var(--text, #c7c7d0);
  margin-top: 1px;
}
.msg.sub-gift .gift-line strong {
  color: #fff;
  font-weight: 700;
}

/* ==== Subscribe / Resubscribe events ==== */
/* Match the prominence of Announcements / Raids — bilateral accent
   borders, gentle gradient background, glow, and a tier label that
   color-codes Tier 1/2/3 (purple/blue/gold) and Prime (cyan). */
.msg.sub-event {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  margin: 6px 0;
  background: linear-gradient(180deg, rgba(145, 70, 255, 0.18), rgba(145, 70, 255, 0.06));
  border-style: solid;
  border-color: #9146ff;
  border-width: 0 5px 0 5px;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 16px rgba(145, 70, 255, 0.25);
}
.msg.sub-event:hover {
  background: linear-gradient(180deg, rgba(145, 70, 255, 0.26), rgba(145, 70, 255, 0.1));
}
/* Prime sub gets the Twitch-Prime cyan/blue accent + crown icon so it
   reads instantly different from a paid Tier 1/2/3 sub. */
.msg.sub-event.tier-2 {
  background: linear-gradient(180deg, rgba(0, 215, 236, 0.16), rgba(0, 215, 236, 0.06));
  border-color: #00d7ec;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 16px rgba(0, 215, 236, 0.25);
}
.msg.sub-event.tier-2 .sub-icon { color: #00d7ec; filter: drop-shadow(0 0 4px rgba(0, 215, 236, 0.55)); }
.msg.sub-event.tier-2 .sub-tier {
  background: linear-gradient(90deg, #5ce0ee, #00d7ec, #009ec0);
  background-clip: text; -webkit-background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.msg.sub-event.tier-3 {
  background: linear-gradient(180deg, rgba(255, 179, 30, 0.18), rgba(255, 179, 30, 0.06));
  border-color: #ffb31e;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 16px rgba(255, 179, 30, 0.3);
}
.msg.sub-event.tier-3 .sub-icon { color: #ffd93d; filter: drop-shadow(0 0 4px rgba(255, 179, 30, 0.6)); }
.msg.sub-event.tier-3 .sub-tier {
  background: linear-gradient(90deg, #ffe57a, #ffd93d, #ffaf14);
  background-clip: text; -webkit-background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.msg.sub-event.prime {
  background: linear-gradient(180deg, rgba(0, 173, 239, 0.18), rgba(0, 173, 239, 0.06));
  border-color: #00adef;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 16px rgba(0, 173, 239, 0.28);
}
.msg.sub-event.prime:hover {
  background: linear-gradient(180deg, rgba(0, 173, 239, 0.28), rgba(0, 173, 239, 0.1));
}
.msg.sub-event.prime .sub-icon {
  color: #00adef;
  filter: drop-shadow(0 0 4px rgba(0, 173, 239, 0.55));
}
.sub-tier {
  background: linear-gradient(90deg, #b78cff, #9146ff, #7a3ce6);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}
.sub-tier-prime {
  background: linear-gradient(90deg, #00d7ec, #00adef, #0091ff);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}
.msg.sub-event .sub-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  color: #b78cff;
  filter: drop-shadow(0 0 4px rgba(145, 70, 255, 0.5));
  flex-shrink: 0;
  margin-top: 1px;
}
.msg.sub-event .sub-body {
  flex: 1;
  min-width: 0;
}
.msg.sub-event .un {
  font-weight: 700;
  cursor: pointer;
}
.msg.sub-event .sub-line {
  font-size: 0.95em;
  color: var(--text, #d0d0da);
  margin-top: 2px;
  line-height: 1.4;
}
.msg.sub-event .sub-line strong {
  color: #fff;
  font-weight: 700;
}
.msg.sub-event .sub-text {
  margin-top: 4px;
  color: var(--text, #d0d0da);
}

/* ==== Channel Points redeem events ==== */
.msg.redeem {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 8px;
  margin: 2px 0;
  background: rgba(145, 70, 255, 0.06);
  border-left: 3px solid #9146ff;
  border-radius: 4px;
}
.msg.redeem .redeem-icon {
  color: #b78cff;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.msg.redeem .redeem-body {
  flex: 1;
  min-width: 0;
}
.msg.redeem .un {
  font-weight: 700;
  cursor: pointer;
}
.msg.redeem .redeem-body strong {
  color: #fff;
  font-weight: 700;
}
.msg.redeem .redeem-cost {
  font-weight: 600;
  color: #b78cff;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(145, 70, 255, 0.15);
  flex-shrink: 0;
}
.msg.redeem .redeem-text {
  width: 100%;
  margin-top: 4px;
}
.msg.highlight {
  background: linear-gradient(90deg, rgba(145, 70, 255, 0.18), rgba(145, 70, 255, 0.04));
  border-left: 3px solid #9146ff;
  padding-left: 8px;
}

/* Suspicious user */
.msg.sus-msg {
  background: rgba(255, 193, 7, 0.1);
  border-left: 2px solid #ffc107;
  padding-left: 8px;
}
.msg.sus-msg:hover {
  background: rgba(255, 193, 7, 0.2);
}

/* Reply context */
.reply-ctx {
  font-size: 11px;
  color: var(--text-muted);
  padding: 1px 0 1px 18px;
  opacity: 0.7;
}

.reply-ctx.clickable {
  cursor: pointer;
  transition: opacity 0.15s;
}

.reply-ctx.clickable:hover {
  opacity: 1;
}

/* Flash animace - když se scrollne k původní zprávě */
@keyframes msg-flash {
  0%, 100% { background: transparent; }
  20% { background: rgba(255, 140, 0, 0.35); box-shadow: inset 0 0 20px rgba(255, 140, 0, 0.2); }
  60% { background: rgba(255, 140, 0, 0.18); }
}

.msg.msg-flash {
  animation: msg-flash 2s ease-out;
}

.rctx-user {
  color: var(--text-secondary);
  font-weight: 600;
}

.rctx-body {
  color: var(--text-muted);
}
.rctx-body img.emote {
  height: 1.2em;
  vertical-align: middle;
  margin: -2px 1px;
}

.msg .un {
  cursor: pointer;
}

.msg .un:hover {
  text-decoration: underline;
}

.msg .un {
  font-weight: 700;
  margin-right: 1px;
}

.msg .un::after {
  content: ':';
  color: var(--text-secondary);
  font-weight: 400;
}

.msg .tx {
  color: var(--text-primary);
}
.msg .tx a {
  color: #e8b84b;
  text-decoration: none;
  word-break: break-all;
}
.msg .tx a:hover { text-decoration: underline; }

.msg .tx img.emote {
  display: inline-block;
  /* Bumped to match Twitch vanilla (~28px chat emotes) — 1.75em on a 13px
     base only got to ~23px which read visibly smaller than vanilla. */
  height: 2em;
  /* Minimum width placeholder so the inline flow reserves space before the
     image loads — without this the text flows through the empty slot and
     reflows (1-pixel-row vibration) when the image pops in. Natural width
     still takes over once the image is decoded. */
  min-width: 2em;
  vertical-align: middle;
  margin: -3px 1px;
  object-fit: contain;
}
/* OG global Twitch face emotes (:), :D, :O, ;), B), <3, …) ship at a
   tiny native resolution. Default emote sizing scales them up and they
   look blurry + visually too big vs vanilla chat. Render closer to
   their native size. */
.msg .tx img.emote.emote-tiny {
  height: 1.25em;
  min-width: auto;
}
body.layout-medium .msg .tx img.emote.emote-tiny { height: 1.4em; }
body.layout-large  .msg .tx img.emote.emote-tiny { height: 1.55em; }

/* /me (ACTION) messages — italic text in username color */
.msg.action .tx { font-style: italic; }

/* Click-to-play audio easter egg (StreamElements Bulgarians) */
.msg.msg-audio { cursor: pointer; position: relative; }
.msg.msg-audio:hover {
  box-shadow: inset 2px 0 0 rgba(255, 140, 0, 0.55);
}
.msg.msg-audio.playing {
  box-shadow: inset 2px 0 0 #ff8c00, 0 0 18px -6px rgba(255, 140, 0, 0.5);
  background: rgba(255, 140, 0, 0.06);
}
.msg.msg-audio::after {
  content: '\25b6';
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: rgba(255, 140, 0, 0.55);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.msg.msg-audio:hover::after { opacity: 1; }
.msg.msg-audio.playing::after {
  content: '\23f8';
  color: #ff8c00;
  opacity: 1;
}

.emote-stack {
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  margin: -3px 1px;
}
.emote-stack img.emote {
  grid-area: 1 / 1;
  margin: 0;
}

.msg.superchat {
  background: rgba(255, 214, 0, 0.08);
  border-left: 2px solid #ffd600;
  padding-left: 8px;
}

/* Hidden platform messages (filters) */
.msg.hide-platform {
  display: none;
}

/* System message */
.sys {
  padding: 3px 10px;
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
  text-align: center;
}

/* Scroll button */
#btn-scroll {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gradient);
  color: #000;
  border: none;
  padding: 5px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), var(--accent-glow);
  z-index: 10;
}

#btn-scroll:hover { filter: brightness(1.1); }
#btn-scroll.hidden { display: none; }

/* Tooltip for status */
.st[title] {
  cursor: default;
}

/* Pinned message banner */
/* Pinned message — Twitch-style banner with expandable body.
   Collapsed: just shows header row with who pinned + chevron.
   Expanded: shows full message text + author footer. */
#pinned-banner {
  display: block;
  padding: 0;
  background: var(--bg-secondary, #1a1a23);
  border-bottom: 1px solid rgba(230, 161, 26, 0.25);
  box-shadow: 0 0 10px rgba(230, 161, 26, 0.08);
  flex-shrink: 0;
  font-size: 12px;
}
#pinned-banner.hidden,
#pinned-banner.dismissed { display: none; }

.pin-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: default;
}
.pin-head-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  color: #e6a11a;
  flex-shrink: 0;
}
.pin-head-text {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text-muted, #9999a5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}
.pin-head-user {
  color: #e6a11a;
  font-weight: 700;
}
.pin-btn {
  flex-shrink: 0;
  display: inline-flex;
  width: 24px;
  height: 24px;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted, #9a9aa6);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s ease, color 0.12s ease;
}
.pin-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
#pinned-banner .pin-chev { transition: transform 0.18s ease; }
#pinned-banner.collapsed .pin-chev { transform: rotate(-90deg); transform-origin: 12px 12px; }

.pin-body {
  padding: 2px 12px 10px 40px;
  overflow: hidden;
  max-height: 400px;
  transition: max-height 0.18s ease, padding 0.18s ease, opacity 0.12s ease;
}
#pinned-banner.collapsed .pin-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}
.pin-body-text {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--text, #e6e6ea);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.pin-body-text a {
  color: #e6a11a;
  text-decoration: underline;
  text-decoration-color: rgba(230, 161, 26, 0.4);
}
.pin-body-text a:hover { text-decoration-color: #e6a11a; }
.pin-body-text img.emote {
  height: 1.6em;
  vertical-align: middle;
  margin: -2px 2px;
}
.pin-body-foot {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted, #9a9aa6);
}
.pin-author {
  font-weight: 700;
}
.pin-author-meta {
  font-size: 11px;
}

/* Unread messages separator */
.unread-sep {
  display: flex;
  align-items: center;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  margin: 4px 0;
}

.unread-sep::before,
.unread-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.5;
  margin: 0 8px;
}

/* ---- Lazy scroll-up hydration spinner ----
   Shown at the top of the chat while _hydrateOlderMessages prepends an
   older batch (150 msgs). Lives inside #chat so it contributes to the
   scrollHeight delta we use to restore the user's reading position. */
.hydrate-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 12px;
  margin: 4px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: linear-gradient(135deg, rgba(255, 140, 0, 0.08), rgba(255, 140, 0, 0.02));
  border: 1px solid rgba(255, 140, 0, 0.22);
  border-radius: 10px;
  box-shadow: 0 0 18px rgba(255, 140, 0, 0.08);
  animation: hs-pulse 1.2s ease-in-out infinite;
}
.hydrate-spinner .hs-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 140, 0, 0.25);
  border-top-color: var(--accent);
  animation: hs-spin 0.8s linear infinite;
  flex: 0 0 auto;
}
.hydrate-spinner .hs-label {
  white-space: nowrap;
}
@keyframes hs-spin {
  to { transform: rotate(360deg); }
}
@keyframes hs-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(255, 140, 0, 0.08); }
  50%      { box-shadow: 0 0 26px rgba(255, 140, 0, 0.22); }
}

/* ---- Twitch credits mirror (footer pills above input) ---- */
#tw-credits {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-top: 1px solid var(--border, #2a2a35);
  background: var(--bg-secondary, #1a1a23);
  font-size: 12px;
  color: var(--text, #e4e4ea);
  flex-wrap: wrap;
}
#tw-credits.hidden { display: none; }

/* Highlights banner background tunes to the accent of its single
   featured card (raid avatar sample, etc.). Fallback = the fixed
   cyan/purple gradient defined earlier. */
#highlights-banner.has-accent {
  background: linear-gradient(
    135deg,
    rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.22),
    rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.07)
  );
  border-bottom-color: rgba(var(--hl-accent-r), var(--hl-accent-g), var(--hl-accent-b), 0.5);
}
.tc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tc-pill.hidden { display: none; }
.tc-bits svg { color: #ffd93d; }
.tc-points-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.tc-points-icon:not(.has-icon)::before {
  content: '\25C6'; /* ◆ fallback when channel icon URL hasn't arrived yet */
  display: block;
  text-align: center;
  font-size: 12px;
  color: #b78cff;
}
.tc-points { color: #ffd9c2; }
.tc-bits   { color: #ffeaa1; }
/* Claim bonus — solid green like Twitch's own button, pulsing to draw
   attention when bonus is ready. White text for legibility on the
   dark-bg side panel. */
.tc-claim {
  background: linear-gradient(90deg, #00db84, #00b870);
  color: #fff !important;
  font-weight: 700;
  padding: 4px 12px;
  box-shadow: 0 0 10px rgba(0, 219, 132, 0.45);
  animation: tc-claim-pulse 1.6s ease-in-out infinite;
  white-space: nowrap;
}
.tc-claim svg { color: #fff; flex-shrink: 0; }
.tc-claim-label {
  display: inline-block;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}
.tc-claim:hover {
  background: linear-gradient(90deg, #15e89a, #02c47b);
  box-shadow: 0 0 14px rgba(0, 219, 132, 0.7);
}
@keyframes tc-claim-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(0, 219, 132, 0.32); }
  50%      { box-shadow: 0 0 14px rgba(0, 219, 132, 0.7); }
}
/* "+N" horizontal flash — slides from just right of the rightmost
   visible pill further right, fading. Stays inline with the credits
   row so it's readable, never overlaps the claim-bonus button
   (anchor logic in _flashPointsDelta picks the rightmost pill). */
#tw-credits { position: relative; }
.tc-points-flash {
  position: absolute;
  pointer-events: none;
  font-weight: 800;
  font-size: 13px;
  color: #00db84;
  text-shadow: 0 0 6px rgba(0, 219, 132, 0.6), 0 0 2px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  /* translateY(-50%) keeps the flash vertically centered on the row
     given that we set `top` to the anchor's vertical midpoint. */
  transform-origin: left center;
  animation: tc-points-slide 1.5s cubic-bezier(0.2, 0.6, 0.2, 1) forwards;
}
@keyframes tc-points-slide {
  0%   { opacity: 0;   transform: translate(-8px, -50%)  scale(0.85); }
  15%  { opacity: 1;   transform: translate(0,    -50%)  scale(1.08); }
  70%  { opacity: 1;   transform: translate(22px, -50%)  scale(1); }
  100% { opacity: 0;   transform: translate(40px, -50%)  scale(0.95); }
}

/* ---- Input Area ---- */

#input-area {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#active-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 3px;
  color: #fff;
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}
#active-badge.tw { background: var(--tw); }
#active-badge.yt { background: var(--yt); }
#active-badge.ki { background: var(--ki); color: #000; }

#msg-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
  resize: none;
  overflow-y: auto;
  max-height: 250px;
  line-height: 1.4;
}

#msg-input:focus { border-color: var(--accent); }
#msg-input:disabled { opacity: 0.4; }

#btn-send {
  background: var(--accent-gradient);
  color: #000;
  border: none;
  width: 32px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--accent-glow);
}

#btn-send:hover { filter: brightness(1.1); }
#btn-send:disabled { opacity: 0.4; cursor: default; }

/* ---- Emote Autocomplete Preview ---- */

/* ---- Reply Indicator ---- */

#reply-indicator {
  position: absolute;
  bottom: 100%;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  z-index: 19;
}

#reply-indicator.hidden { display: none; }

.ri-label {
  color: var(--text-muted);
}

.ri-user {
  color: var(--text-primary);
  font-weight: 600;
}

.ri-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.ri-close:hover {
  color: var(--text-primary);
}

/* ---- Emote Suggest List ---- */

#emote-suggest {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.45);
  z-index: 20;
  overflow: hidden;
}

#emote-suggest.hidden { display: none; }

/* Fulltext toggle row at the top of the suggest panel — opt-in switch
   from "starts with" matching to "contains" matching. */
.es-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  user-select: none;
}
.es-toggle input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.es-toggle:hover { color: var(--text-primary); }

/* ---- Emote preview card (hover/click) ---- */
.emote-preview {
  position: fixed;
  z-index: 1000;
  min-width: 140px;
  max-width: 220px;
  padding: 10px 10px 8px;
  background: linear-gradient(180deg, rgba(22, 22, 28, 0.98), rgba(14, 14, 18, 0.98));
  border: 1px solid rgba(255, 140, 0, 0.35);
  border-radius: 8px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.7),
    0 0 18px rgba(255, 140, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  /* Subtle entrance — JS doesn't toggle, but matches overall polish */
  animation: ep-pop 0.16s ease-out;
}
.emote-preview.hidden { display: none; }
@keyframes ep-pop {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.emote-preview .ep-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 4px;
}
.emote-preview .ep-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

.emote-preview .ep-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  word-break: break-word;
  max-width: 100%;
}
.emote-preview .ep-source {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 140, 0, 0.18);
  color: var(--accent);
  white-space: nowrap;
}
.emote-preview .ep-src-7tv     { background: rgba(45, 175, 250, 0.18); color: #58c1ff; }
.emote-preview .ep-src-bttv    { background: rgba(216, 27, 96, 0.18); color: #ff6f9b; }
.emote-preview .ep-src-ffz     { background: rgba(38, 132, 255, 0.18); color: #6aa8ff; }
.emote-preview .ep-src-twitch  { background: rgba(145, 70, 255, 0.18); color: #b18cff; }
.emote-preview .ep-src-kick    { background: rgba(83, 252, 24, 0.18); color: #87f04a; }

.emote-preview .ep-detail {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.emote-preview .ep-hint,
.emote-preview .ep-loading {
  font-style: italic;
  opacity: 0.65;
}
.emote-preview .ep-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  line-height: 1.4;
}
.emote-preview .ep-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.6;
}
.emote-preview .ep-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
}
.emote-preview .ep-avatar-blank {
  background: rgba(255, 255, 255, 0.08);
}
.emote-preview .ep-owner {
  color: var(--text-primary);
  font-weight: 600;
}
.emote-preview .ep-extlink {
  color: var(--accent);
  font-size: 10px;
  text-decoration: none;
  padding-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 2px;
  transition: color 0.12s;
}
.emote-preview .ep-extlink:hover {
  color: #ffe28a;
  text-shadow: 0 0 6px rgba(255, 200, 0, 0.35);
}

/* Click-pinned mode is visually slightly stronger: thicker accent border */
.emote-preview.pinned {
  border-color: rgba(255, 140, 0, 0.65);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.75),
    0 0 22px rgba(255, 140, 0, 0.28);
}

.es-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  min-width: 0;
}

.es-item:last-of-type { border-bottom: none; }

.es-item:hover { background: var(--bg-hover); }

.es-item.selected {
  background: rgba(255, 140, 0, 0.15);
}

.es-item img {
  height: 28px;
  width: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.es-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.es-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}

.es-name-inner {
  display: inline-block;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 100%;
  overflow: hidden;
  vertical-align: bottom;
}

/* Animace scroll - jen když je položka SELECTED a text overflowuje */
.es-item.selected.overflowing .es-name-inner {
  max-width: none;
  overflow: visible;
  animation: es-scroll 6s linear 0.4s infinite;
}

@keyframes es-scroll {
  0%, 12% { transform: translateX(0); }
  50%, 62% { transform: translateX(var(--scroll-dist, 0)); }
  100% { transform: translateX(0); }
}

.es-item.selected .es-name {
  font-weight: 700;
  color: var(--accent);
}

.es-src {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.6;
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}

.es-counter {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  padding: 3px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
