/* Hark — chat panel. Everything prefixed with .hark- to avoid clashing with Twitch. */

.hark-root {
  --hark-bg: #ffffff;
  --hark-bg-alt: #f7f7f8;
  --hark-fg: #0e0e10;
  --hark-muted: #53535f;
  --hark-border: rgba(0, 0, 0, 0.1);
  --hark-accent: #18181b;
  --hark-highlight: rgba(235, 4, 0, 0.12);
  --hark-system: #53535f;
  --hark-tooltip-bg: #ffffff;
  --hark-card-bg: #ffffff;
  --hark-highlight-word: rgba(24, 24, 27, 0.08);

  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--hark-bg);
  color: var(--hark-fg);
  font-family: Inter, Roobert, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: var(--hark-font, 13px);
  line-height: var(--hark-lh, 20px);
  overflow: hidden;
  isolation: isolate;
}

.hark-root.hark-dark {
  --hark-bg: #18181b;
  --hark-bg-alt: #1f1f23;
  --hark-fg: #efeff1;
  --hark-muted: #adadb8;
  --hark-border: rgba(255, 255, 255, 0.1);
  --hark-accent: #efeff1;
  --hark-highlight: rgba(235, 4, 0, 0.22);
  --hark-system: #adadb8;
  --hark-tooltip-bg: #0e0e10;
  --hark-card-bg: #1f1f23;
  --hark-highlight-word: rgba(239, 239, 241, 0.1);
}

/* ---------- icons ---------- */
.hark-icon {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
}

.hark-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- header ---------- */
.hark-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 50px;
  /* space on the left for the native collapse-chat button */
  padding: 0 8px 0 48px;
  border-bottom: 1px solid var(--hark-border);
}

.hark-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #f5a623;
}
.hark-dot[data-status="connected"] { background: #00c853; }
.hark-dot[data-status="reconnecting"] { background: #eb0400; }

.hark-title {
  flex: 0 1 auto;
  min-width: 32px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.hark-spacer { flex: 1; min-width: 0; }

.hark-icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--hark-muted);
  font-size: 18px;
  cursor: pointer;
  transition-property: background-color, color, scale;
  transition-duration: 120ms;
}
.hark-icon-btn:hover { background: var(--hark-bg-alt); color: var(--hark-fg); }
.hark-icon-btn:active { scale: 0.96; }
.hark-icon-btn:focus-visible { outline: 2px solid var(--hark-accent); outline-offset: 1px; }
.hark-icon-btn.hark-active,
.hark-icon-btn[aria-pressed="true"] { background: var(--hark-bg-alt); color: var(--hark-accent); }

/* ---------- list ---------- */
.hark-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  overflow-anchor: none; /* scrolling is managed by the panel */
  scrollbar-width: thin;
}
.hark-scroll:focus-visible { outline: 2px solid var(--hark-accent); outline-offset: -2px; }

.hark-list {
  padding: 10px 0;
}

.hark-line {
  padding: 5px 20px;
  overflow-wrap: anywhere;
  word-break: break-word;
  /* Off-screen lines aren't painted (including animated emotes) */
  content-visibility: auto;
  contain-intrinsic-size: auto 30px;
}

.hark-anchor { display: none; }

.hark-hidden,
.hark-nomatch { display: none !important; }

.hark-compact .hark-line { padding: 2px 12px; }
.hark-compact .hark-usernotice-text { padding: 2px 12px; }
.hark-zebra .hark-alt { background: var(--hark-bg-alt); }
.hark-highlight-word,
.hark-highlight-word:hover { background: var(--hark-highlight-word); box-shadow: inset 3px 0 0 var(--hark-accent); }
.hark-line:hover { background: var(--hark-bg-alt); }

.hark-historical { opacity: 0.6; }
.hark-first { box-shadow: inset 3px 0 0 #00c853; }
.hark-highlight { background: var(--hark-highlight); }
.hark-highlight:hover { background: var(--hark-highlight); }
.hark-cheer { box-shadow: inset 3px 0 0 var(--hark-accent); }

.hark-ts {
  margin-right: 5px;
  color: var(--hark-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.hark-no-ts .hark-ts { display: none; }

.hark-badges:empty { display: none; }
.hark-no-badges .hark-badges { display: none; }
.hark-badge {
  width: 18px;
  height: 18px;
  margin: 0 3px 2px 0;
  vertical-align: middle;
  border-radius: 3px;
}

.hark-name {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  text-align: inherit;
  cursor: pointer;
}
.hark-name:hover { text-decoration: underline; text-underline-offset: 2px; }
.hark-name:focus-visible { outline: 2px solid var(--hark-accent); outline-offset: 1px; border-radius: 2px; }
.hark-mention,
.hark-reply-name { cursor: pointer; }
.hark-mention:hover,
.hark-reply-name:hover { text-decoration: underline; text-underline-offset: 2px; }

/* 7TV paints: gradient/image clipped to the text */
.hark-paint {
  background-color: currentColor;
  background-size: 100% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hark-paint-url {
  background-size: cover;
  background-position: center;
}
.hark-no-paints .hark-paint {
  background-image: none !important;
  -webkit-text-fill-color: currentColor;
  filter: none !important;
}

/* cheers */
.hark-cheermote {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin: -5px 0;
  gap: 2px;
}
.hark-cheer-amount {
  font-weight: 700;
}

.hark-emote-notice .hark-emote { margin: -5px 2px; }

.hark-action { font-style: italic; }

.hark-reply {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  color: var(--hark-muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}
.hark-reply-icon { font-size: 12px; }
.hark-reply-name { flex: none; font-weight: 600; }
.hark-reply-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.hark-first-icon {
  margin: 0 3px 2px 0;
  color: #00c853;
  font-size: 16px;
  vertical-align: middle;
}

.hark-mention {
  font-weight: 600;
}

.hark-link {
  color: var(--hark-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hark-system {
  color: var(--hark-system);
  font-size: 12px;
}
.hark-sys-icon,
.hark-change-icon {
  margin-right: 6px;
  font-size: 14px;
  vertical-align: -3px;
}
.hark-change-icon { margin-left: -2px; }
.hark-emote-add .hark-change-icon { color: #00c853; }
.hark-emote-remove .hark-change-icon { color: #eb0400; }
.hark-sys-strong { color: var(--hark-fg); font-weight: 600; }
.hark-sys-muted { color: var(--hark-muted); }
.hark-mod-action .hark-sys-icon { color: #eb0400; }

/* history / live separator */
.hark-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  color: var(--hark-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.hark-divider::before,
.hark-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hark-border);
}

.hark-usernotice {
  margin: 4px 0;
  padding: 4px 0;
  box-shadow: inset 4px 0 0 var(--hark-accent);
  background: var(--hark-bg-alt);
}
.hark-usernotice-text {
  padding: 2px 20px;
  font-weight: 600;
}
.hark-usernotice-text .hark-sys-icon { color: var(--hark-accent); }

/* deleted messages */
.hark-deleted .hark-body {
  opacity: 0.5;
  text-decoration: line-through;
}
.hark-hide-deleted .hark-deleted .hark-body { display: none; }
.hark-hide-deleted .hark-deleted::after {
  content: "<mensagem apagada>";
  color: var(--hark-muted);
  font-style: italic;
}

/* ---------- emotes ---------- */
.hark-emote {
  display: inline-grid;
  vertical-align: middle;
  margin: -5px 0;
  line-height: 0;
}

.hark-emote-img {
  grid-area: 1 / 1;
  place-self: center;
  height: var(--hark-emote-h, 28px);
  width: auto;
  max-width: none;
  cursor: default;
}

/* zero-width (7TV/BTTV): stacked on top of the previous emote */
.hark-zw { pointer-events: auto; }

/* BTTV modifiers */
.hark-mod-flip-h .hark-emote-img { transform: scaleX(-1); }
.hark-mod-flip-v .hark-emote-img { transform: scaleY(-1); }
.hark-mod-wide .hark-emote-img { width: calc(var(--hark-emote-h, 28px) * 2); aspect-ratio: auto !important; }
.hark-mod-rotate-l .hark-emote-img { transform: rotate(-90deg); }
.hark-mod-rotate-r .hark-emote-img { transform: rotate(90deg); }
.hark-mod-cursed .hark-emote-img { filter: grayscale(1) brightness(0.7) contrast(2.5); }
.hark-mod-zero-space { margin-left: -4px; }

@media (prefers-reduced-motion: no-preference) {
  .hark-mod-party .hark-emote-img { animation: hark-party 1.2s linear infinite; }
  .hark-mod-shake .hark-emote-img { animation: hark-shake 0.3s linear infinite; }
}
@keyframes hark-party {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}
@keyframes hark-shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -1px 1px; }
  50% { translate: 1px -1px; }
  75% { translate: -1px -1px; }
}

/* ---------- paused chat ---------- */
.hark-paused {
  position: absolute;
  left: 50%;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  translate: -50% 0;
  z-index: 2;
  padding: 6px 12px 6px 10px;
  border: 0;
  border-radius: 999px;
  background: #000000cc;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.hark-paused .hark-icon { font-size: 14px; }
.hark-paused:active { scale: 0.96; }
.hark-paused[hidden] { display: none; }
.hark-paused:focus-visible { outline: 2px solid var(--hark-accent); outline-offset: 2px; }

/* ---------- tooltip ---------- */
.hark-tooltip {
  position: absolute;
  z-index: 3;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--hark-tooltip-bg);
  color: var(--hark-fg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  text-align: center;
  pointer-events: none;
}
.hark-tooltip[hidden] { display: none; }
.hark-tooltip img {
  display: block;
  height: 84px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  margin: 0 auto 6px;
}
.hark-tooltip-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.hark-tooltip-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
  color: var(--hark-muted);
  font-size: 11px;
}
.hark-tooltip-sub .hark-icon { font-size: 12px; }
.hark-tooltip-sub .hark-icon-user { margin-left: 4px; }

/* ---------- native chat under the panel ----------
   While the panel is mounted, the Twitch chat is no longer painted
   (saves layout/paint; React state is kept). */
.chat-shell:has(> .hark-root) > :not(.hark-root),
.stream-chat:has(> .hark-root) > :not(.hark-root) {
  content-visibility: hidden;
}

/* ---------- button in the native chat ---------- */
.hark-toggle {
  position: absolute;
  top: 50%;
  right: 44px;
  translate: 0 -50%;
  z-index: 10;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #18181b;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition-property: background-color, scale;
  transition-duration: 120ms;
}
.hark-toggle:hover { background: #3f3f46; }
/* on Twitch's dark theme the button is light so it stays visible */
.tw-root--theme-dark .hark-toggle { background: #efeff1; color: #18181b; }
.tw-root--theme-dark .hark-toggle:hover { background: #d4d4d8; }
.hark-toggle:active { scale: 0.96; }
.hark-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.hark-toggle .hark-icon { width: 18px; height: 18px; }
.hark-toggle--floating {
  top: 10px;
  right: 10px;
  translate: none;
}

/* ---------- search ---------- */
.hark-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--hark-border);
}
.hark-search[hidden] { display: none; }
.hark-search-icon { color: var(--hark-muted); font-size: 14px; }
.hark-search-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--hark-border);
  border-radius: 4px;
  background: var(--hark-bg-alt);
  color: var(--hark-fg);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.hark-search-input::-webkit-search-cancel-button { display: none; }
.hark-search-input:focus-visible { border-color: var(--hark-accent); box-shadow: 0 0 0 1px var(--hark-accent); }
.hark-search-count {
  min-width: 2ch;
  color: var(--hark-muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- user card ---------- */
.hark-card {
  --hark-card-tint: var(--hark-muted);
  position: absolute;
  top: 56px;
  left: 8px;
  right: 8px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 64px);
  overflow: hidden;
  border-radius: 12px;
  background: var(--hark-card-bg);
  color: var(--hark-fg);
  box-shadow: 0 0 0 1px var(--hark-border), 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -12px rgba(0, 0, 0, 0.55);
  animation: hark-card-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes hark-card-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
/* banner tinted with the user's colour */
.hark-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 64px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--hark-card-tint) 55%, transparent), color-mix(in srgb, var(--hark-card-tint) 12%, transparent));
  opacity: 0.55;
  pointer-events: none;
}

.hark-card-head {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 28px 10px 12px 14px;
}
.hark-card-avatar {
  flex: none;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--hark-bg-alt);
  box-shadow: 0 0 0 3px var(--hark-card-bg);
}
.hark-card-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.hark-card-id { flex: 1; min-width: 0; padding-bottom: 2px; }
.hark-card-name {
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hark-card-name .hark-name { cursor: default; }
.hark-card-name .hark-name:hover { text-decoration: none; }
.hark-card-login { color: var(--hark-muted); font-size: 12px; line-height: 16px; }
.hark-card-badges { display: flex; gap: 2px; margin-top: 4px; line-height: 0; }
.hark-card-badges:empty { display: none; }
.hark-card-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 15px;
}
.hark-card-close:hover { background: rgba(0, 0, 0, 0.45); color: #fff; }

.hark-card-facts {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 2px 14px 12px;
  list-style: none;
  font-size: 12.5px;
  line-height: 16px;
}
.hark-card-fact { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hark-card-fact .hark-icon {
  width: 22px;
  height: 22px;
  padding: 4px;
  box-sizing: border-box;
  border-radius: 6px;
  background: var(--hark-bg-alt);
  color: var(--hark-muted);
  font-size: 14px;
}
.hark-card-muted { color: var(--hark-muted); white-space: nowrap; }
.hark-card-dim { color: var(--hark-muted); }
.hark-card-warn,
.hark-card-warn .hark-icon { color: #eb0400; }
.hark-card-loading { color: var(--hark-muted); }

.hark-card-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0 14px 14px;
}
.hark-card-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: var(--hark-bg-alt);
  box-shadow: inset 0 0 0 1px var(--hark-border);
  color: var(--hark-fg);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition-property: background-color, color, scale;
  transition-duration: 120ms;
}
.hark-card-action .hark-icon { font-size: 14px; }
.hark-card-action:hover { background: var(--hark-border); }
.hark-card-action:active { scale: 0.96; }
.hark-card-action:focus-visible { outline: 2px solid var(--hark-accent); outline-offset: 1px; }
.hark-card-action[aria-pressed="true"] { background: var(--hark-fg); color: var(--hark-bg); box-shadow: none; }
/* narrow panels: icons only */
@container (max-width: 330px) { .hark-card-action span { display: none; } }
.hark-card { container-type: inline-size; }

.hark-card-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 10px 14px 4px;
  border-top: 1px solid var(--hark-border);
  color: var(--hark-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.hark-card-section .hark-icon { font-size: 12px; }
.hark-card-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 8px;
  scrollbar-width: thin;
}
.hark-card .hark-line { padding: 2px 14px; }
.hark-root .hark-card .hark-ts { display: inline; font-variant-numeric: tabular-nums; opacity: 0.8; }
.hark-card-empty { padding: 6px 14px 12px; color: var(--hark-muted); font-size: 12px; }

/* ---------- info popover (read-only notice, status, emotes) ---------- */
.hark-info {
  position: absolute;
  top: 54px;
  right: 8px;
  z-index: 5;
  width: min(260px, calc(100% - 16px));
  padding: 10px 12px 8px;
  border-radius: 8px;
  background: var(--hark-card-bg);
  color: var(--hark-fg);
  font-size: 12px;
  line-height: 18px;
  box-shadow: 0 0 0 1px var(--hark-border), 0 8px 28px rgba(0, 0, 0, 0.45);
}
.hark-info[hidden] { display: none; }

.hark-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}
.hark-info-row > .hark-icon { font-size: 15px; color: var(--hark-muted); }
.hark-info-dot { margin: 0 3.5px; }
.hark-info-muted { color: var(--hark-muted); }

.hark-info-section {
  margin: 8px 0 2px;
  padding-top: 8px;
  border-top: 1px solid var(--hark-border);
  color: var(--hark-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hark-info-provider > .hark-icon { color: var(--hark-fg); }
.hark-info-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hark-info-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hark-info-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 74px;
  justify-content: flex-end;
  color: var(--hark-muted);
  font-size: 11px;
  white-space: nowrap;
}
.hark-info-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00c853;
}
.hark-info-live-polling::before { background: #f5a623; }

.hark-info-foot {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--hark-border);
}
.hark-info-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 28px;
  margin: 0 -6px;
  padding: 0 6px;
  box-sizing: content-box;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--hark-fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.hark-info-settings .hark-icon { font-size: 15px; color: var(--hark-muted); }
.hark-info-settings:hover { background: var(--hark-bg-alt); }
.hark-info-settings:focus-visible { outline: 2px solid var(--hark-accent); outline-offset: -2px; }
