/* Compact, draggable, Edge-style in-match chat (ui/chatBox.js). */
.chatball {
  position: fixed; z-index: 90;
  width: max(.56rem, 48px); height: max(.56rem, 48px);
  display: grid; place-items: center; padding: 0;
  border: 1px solid rgba(159, 248, 223, .8); border-radius: 50%;
  color: #05241d; background: linear-gradient(145deg, #a9ffe7, #32c79c 55%, #11745f);
  box-shadow: 0 .06rem .22rem rgba(0, 0, 0, .55), 0 0 .22rem rgba(111, 243, 207, .35);
  cursor: grab; touch-action: none; user-select: none; pointer-events: auto;
  transition: filter var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.chatball:hover { filter: brightness(1.1); box-shadow: 0 .08rem .28rem rgba(0, 0, 0, .6), 0 0 .3rem rgba(111, 243, 207, .5); }
.chatball:active { cursor: grabbing; transform: scale(.96); }
.chatball svg { width: 55%; height: 55%; display: block; fill: currentColor; }
.chatball__unread {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
  display: grid; place-items: center; padding: 0 4px; border-radius: 999px;
  background: #ff5c5c; color: #fff; font-size: 10px; font-weight: 900; line-height: 1;
  box-shadow: 0 0 0 2px rgba(5, 14, 12, .9);
}
.chatbox {
  position: fixed; z-index: 80; width: 260px; height: 280px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px);
  display: flex; flex-direction: column; overflow: hidden; color: var(--text-md); pointer-events: auto;
  background: linear-gradient(155deg, rgba(9, 31, 26, .97) 0%, rgba(5, 10, 8, .98) 45%, rgba(8, 26, 21, .98) 100%);
  border: 1px solid rgba(111, 243, 207, .32); border-radius: 10px;
  box-shadow: 0 .18rem .5rem rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .6), 0 0 .35rem rgba(23, 249, 183, .08);
  -webkit-backdrop-filter: blur(10px) saturate(1.15); backdrop-filter: blur(10px) saturate(1.15);
  font-size: max(calc(.12 * var(--t)), 10px);
}
.chatbox.is-collapsed { height: 45px; }

/* 45px header, 16px side padding, everything centred; darker than the body + a weak top highlight. */
.chatbox__head {
  position: relative; flex: none; box-sizing: border-box; height: 45px; min-height: 45px;
  display: flex; align-items: center; padding: 0 16px;
  background: linear-gradient(90deg, rgba(4, 26, 21, .95), rgba(0, 0, 0, .28) 52%, rgba(5, 30, 24, .9));
  border-bottom: 0; cursor: grab; touch-action: none; user-select: none;
}
.chatbox__head::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 1px; background: rgba(255, 255, 255, .07); pointer-events: none;
}
.chatbox__head::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: rgba(64, 224, 160, .18); pointer-events: none;
}
.chatbox__head:active { cursor: grabbing; }

/* P2: one active channel, a 56px tab, a 2px mint underline over a 1px full divider. */
.chatbox__tab {
  position: relative; z-index: 1; flex: none; box-sizing: border-box; min-width: 56px; height: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px;
  border: 0; border-radius: 6px 6px 0 0; background: transparent; color: #d9fff5; font: inherit; font-weight: 800; letter-spacing: .03em;
  text-shadow: 0 0 .14rem rgba(111, 243, 207, .55); cursor: pointer;
}
.chatbox__tab::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px;
  background: #46f0b8; box-shadow: 0 0 .12rem rgba(70, 240, 184, .75);
}
.chatbox__tab.is-inactive { opacity: .6; color: #8fae9f; text-shadow: none; }
.chatbox__tab.is-inactive::after { display: none; }
.chatbox__dot {
  flex: none; width: 6px; height: 6px; border-radius: 50%; background: #6ff3cf;
  box-shadow: 0 0 .1rem rgba(111, 243, 207, .9);
}
.chatbox__title { line-height: 1; font-size: max(calc(.13 * var(--t)), 10px); }
.chatbox__unread {
  flex: none; min-width: 15px; height: 15px; display: inline-grid; place-items: center; padding: 0 4px;
  border-radius: 999px; background: #ff5c5c; color: #fff; font-size: max(calc(.09 * var(--t)), 8px);
  font-weight: 800; line-height: 1;
}
.chatbox__spacer { flex: 1; min-width: 8px; }

/* P1: 28px round controls with a 36px hit area, no default ring; hover/press only. */
.chatbox__ctls { position: relative; z-index: 1; flex: none; display: flex; align-items: center; gap: 16px; }
.chatbox__ctl {
  position: relative; flex: none; width: 28px; height: 28px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, .7); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.chatbox__ctl::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; }
.chatbox__ctl svg {
  width: 16px; height: 16px; display: block; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.chatbox__ctl:hover, .chatbox__ctl:active {
  color: #b9ffe9; background: rgba(90, 255, 190, .08); box-shadow: inset 0 0 0 1px rgba(120, 255, 200, .55);
}

/* Body */
.chatbox__body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 6px 8px; display: flex; flex-direction: column; gap: 6px;
  background: radial-gradient(ellipse at 50% 0%, rgba(111, 243, 207, .07), transparent 65%);
  scrollbar-width: thin; scrollbar-color: rgba(23, 249, 183, .3) transparent;
}
.chatbox__body::-webkit-scrollbar { width: 5px; }
.chatbox__body::-webkit-scrollbar-thumb { background: rgba(23, 249, 183, .28); border-radius: 99px; }
.chatbox__msg { display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; border-radius: 6px; background: rgba(255, 255, 255, .025); border-left: 2px solid transparent; }
.chatbox__msg.is-own { background: rgba(23, 249, 183, .07); border-left-color: var(--mint-500); }
.chatbox__meta { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.chatbox__name { color: var(--text-hi); font-size: max(calc(.11 * var(--t)), 9px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatbox__msg.is-own .chatbox__name { color: var(--mint-400); }
.chatbox__time { margin-left: auto; color: var(--text-dim); font-size: max(calc(.09 * var(--t)), 7px); }
.chatbox__text { color: var(--text-hi); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chatbox__empty { margin: auto; color: var(--text-dim); font-size: max(calc(.11 * var(--t)), 8px); }

/* Composer */
.chatbox__form { flex: none; display: flex; align-items: center; gap: 3px; padding: 3px 6px; border-top: 1px solid rgba(255, 255, 255, .08); background: rgba(0, 0, 0, .3); }
.chatbox__input {
  flex: 1; min-width: 0; height: .34rem; padding: 0 4px; color: var(--text-hi); background: rgba(8, 11, 10, .85);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 4px; outline: none; font: inherit; font-size: max(calc(.1 * var(--t)), 9px);
}
.chatbox__input:focus { border-color: var(--mint-500); box-shadow: 0 0 0 1px rgba(23, 249, 183, .35); }
.chatbox__input::placeholder { color: var(--text-dim); }
.chatbox__send {
  flex: none; height: .34rem; padding: 0 7px; color: #05241d;
  background: linear-gradient(180deg, #8ff8dc, #27b892); border: 1px solid rgba(159, 248, 223, .75);
  border-radius: 4px; font: inherit; font-size: max(calc(.1 * var(--t)), 9px); font-weight: 800; cursor: pointer;
}
.chatbox__send:disabled { opacity: .45; cursor: default; }
.chatbox__readonly { flex: none; margin: 0; padding: 6px 8px; color: var(--text-dim); font-size: max(calc(.11 * var(--t)), 8px); border-top: 1px solid rgba(255, 255, 255, .08); }

/* Closed pill */
.chatbox__toggle {
  position: fixed; right: 1rem; bottom: 4.2rem; z-index: 80; display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px; color: #05241d; background: linear-gradient(135deg, #8ff8dc, #27b892 55%, #14745e);
  border: 1px solid rgba(159, 248, 223, .75); border-radius: 999px;
  box-shadow: 0 .06rem .24rem rgba(0, 0, 0, .45), 0 0 .2rem rgba(111, 243, 207, .25);
  font: inherit; font-weight: 800; cursor: pointer; pointer-events: auto;
}
.chatbox__toggle:hover { filter: brightness(1.08); }
