/* =====================================================================
   BANGBOWBING OS — CHAT app styles
   Lifted out of os/os.css byte-for-byte by the v3 scene phase (ledger item 33's
   css split, kept under the item 44-47 game frame) so phase-2 app workers edit
   disjoint files. Shell, the shared app kit, the emote/rarity tokens and the
   lightbox stay in os.css; this file owns Chat, its mod tools and the case-pull line.
   Linked from desktop.html AFTER os.css — same cascade order for ties.
   ===================================================================== */

/* ================================================================= chat */
.chat-app {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  height: 100%;
  min-height: 0;
  background: var(--screen);
}
.chat-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #ffe0c9;
  background: rgba(255, 154, 61, 0.14);
  border-bottom: 1px solid rgba(255, 154, 61, 0.36);
}
.msgs {
  overflow: auto;
  min-height: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-wrap: anywhere;
}
.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg .av {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  object-fit: cover;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(160deg, #7a3fe0, #3d1080);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.msg .body { min-width: 0; flex: 1 1 auto; }
.msg .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.msg .uname { font-size: 12px; font-weight: 700; color: var(--aqua-lt); }
.msg .time { margin-left: auto; font-size: 10.5px; color: #949bb5; }
.msg .text { margin-top: 3px; font-size: 13px; line-height: 1.55; color: var(--screen-ink); }
.msg.mention {
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 9px;
  background: rgba(255, 95, 200, 0.15);
  border-left: 3px solid var(--candy);
}
.msg .text .at { color: var(--candy); font-weight: 700; }
.badgeicon { width: 14px; height: 14px; object-fit: contain; }
.badgepill {
  padding: 2px 6px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  color: #12101a;
  background: linear-gradient(180deg, #d3d8e6, #a7afc4);
}
.emote { display: inline-block; height: 24px; width: auto; vertical-align: -6px; }
.sysline {
  font-size: 12px;
  line-height: 1.5;
  color: var(--screen-dim);
  border-left: 2px solid #4a4f74;
  padding-left: 8px;
}
.sysline.err { color: #ffa8bd; border-left-color: #ff5f8a; }
.sysline.note { color: #cfe6ff; border-left-color: var(--aqua-lt); }

.picker-wrap { min-height: 0; }
.picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 5px;
  max-height: 140px;
  overflow: auto;
  padding: 8px;
  background: var(--screen-2);
  border-top: 1px solid var(--screen-rim);
}
.picker[hidden] { display: none; }
.picker-empty { grid-column: 1 / -1; font-size: 11.5px; color: var(--screen-dim); }
.eslot {
  position: relative;
  display: grid;
  place-items: center;
  padding: 5px;
  border-radius: 8px;
  background: linear-gradient(180deg, #32355a, var(--screen-3));
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.eslot img { width: 26px; height: 26px; object-fit: contain; }
.eslot:hover { border-color: var(--candy); }
.eslot.locked img { filter: grayscale(1) brightness(0.55); }
.eslot .lock {
  position: absolute;
  right: 2px;
  bottom: 2px;
  padding: 0 3px;
  border-radius: 4px;
  font-family: var(--font-pixel);
  font-size: 7px;
  color: #2a1500;
  background: var(--tang);
}

/* --- case emotes (hub rarity tiers). A case emote is never "free at LV n":
   it is won from a case and spent when sent, so it wears its rarity instead
   of a level. Every stamp keeps dark ink on a bright plate (>= 7:1). --- */
.eslot.case { border-color: var(--r-col, rgba(255, 255, 255, 0.28)); }
.eslot.case .lock { background: var(--r-col, var(--tang)); color: #17110a; }
.eslot.case::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 9px var(--r-glow, transparent);
  pointer-events: none;
}
.eslot.case.locked img { filter: grayscale(1) brightness(0.5); }
.eslot.r-common { --r-col: #cfd6e6; --r-glow: rgba(207, 214, 230, 0.22); }
.eslot.r-uncommon { --r-col: #7ce7a4; --r-glow: rgba(124, 231, 164, 0.3); }
.eslot.r-rare { --r-col: #74c7ff; --r-glow: rgba(116, 199, 255, 0.34); }
.eslot.r-epic { --r-col: #d3a2ff; --r-glow: rgba(211, 162, 255, 0.36); }
.eslot.r-legendary { --r-col: #ffc861; --r-glow: rgba(255, 200, 97, 0.42); }
.guestbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--screen-dim);
  background: var(--screen-2);
  border-top: 1px solid var(--screen-rim);
}
.chat-input {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--screen-rim);
}
.chat-input .input {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--screen-ink);
  background: #0d0e1a;
  border-color: rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
.chat-input .input::placeholder { color: #949bb5; }
.btn.emo { padding: 8px 12px; }

/* --- mod tools (item 31) --------------------------------------------- */
.modtag.admin { color: #3d0524; background: linear-gradient(180deg, #ffd6f0, var(--candy)); }
.modctl {
  display: flex;
  gap: 5px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.msg.can-mod:hover .modctl,
.msg.can-mod:focus-within .modctl { opacity: 1; }
.modbtn {
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  color: #ffd9e2;
  background: rgba(255, 95, 138, 0.16);
  border: 1px solid rgba(255, 95, 138, 0.5);
}
.modbtn:hover { color: #fff; background: rgba(255, 95, 138, 0.34); }
.modbtn[disabled] { opacity: 0.5; cursor: default; }
/* touch has no hover — on a phone the controls are simply always there */
@media (hover: none), (pointer: coarse) {
  .modctl { opacity: 1; }
}
.msg.is-deleted .text { color: #949bb5; font-style: italic; }
.msg.is-deleted { opacity: 0.75; }

.modpop {
  position: absolute;
  z-index: 40;
  width: 240px;
  max-width: calc(100% - 12px);
  padding: 11px;
  border-radius: 12px;
  background: var(--screen-2);
  border: 1px solid var(--screen-rim);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}
.modpop .field { margin: 7px 0 0; }
.modpop .input { width: 100%; }
.chat-app { position: relative; }

/* --- the chat pull line ---------------------------------------------- */
.pullline {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--screen-ink);
  background: var(--screen-2);
  background: linear-gradient(90deg, color-mix(in srgb, var(--rar) 22%, transparent), transparent 70%);
  border-left: 3px solid var(--rar, var(--rar-epic));
}
.pullline img.emote { height: 30px; }
.pullline b { color: var(--rar, var(--rar-epic)); }

/* =====================================================================
   GAMES — name popover, challenge toasts, rail (ledger items 39-41)
   ===================================================================== */
.chat-app { flex-direction: row; display: flex; }
.chat-app > .chat-main {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}
.msg .uname.nameBtn {
  border: 0; padding: 0; margin: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; color: var(--aqua-lt);
}
.msg .uname.nameBtn:hover, .msg .uname.nameBtn:focus-visible { text-decoration: underline; }
.namepop { display: flex; flex-direction: column; gap: 8px; width: 260px; }
.namepop .field { display: flex; flex-direction: column; gap: 4px; }
.namepop .field select, .namepop .field input { width: 100%; }

.chat-toasts {
  position: absolute; top: 8px; right: 8px; z-index: 45;
  display: flex; flex-direction: column; gap: 6px; width: 240px; max-width: calc(100% - 16px);
  pointer-events: none;
}
.chat-toast {
  pointer-events: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 9px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4;
  color: var(--screen-ink); background: var(--screen-2); border: 1px solid var(--screen-rim);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}
.chat-toast.err { border-color: rgba(255, 95, 138, 0.5); }
.chat-toast .toast-x { align-self: flex-start; border: 0; background: none; color: var(--screen-dim); cursor: pointer; }
.chat-toast.challenge .g-bar { max-width: none; }

/* ---------------------------------------------------------------- rail */
.games-rail {
  flex: 0 0 220px;
  min-width: 0;
  display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--screen-rim);
  background: var(--screen-2);
  overflow: auto;
}
.rail-head, .rail-feed-head {
  padding: 8px 10px 4px; font-family: var(--font-ui); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--screen-dim);
}
.rail-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 6px; }
.rail-tab {
  padding: 3px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600;
  color: var(--screen-dim); background: var(--screen-3); border: 1px solid transparent; cursor: pointer;
}
.rail-tab.on { color: var(--screen-ink); border-color: var(--aqua-lt); }
.rail-tab.live::before { content: '●'; color: #7ce7a4; margin-right: 4px; font-size: 8px; }
.rail-tab.turn { outline: 1px solid var(--tang); }
.rail-board { padding: 8px; display: flex; justify-content: center; }
.rail-cta { padding: 0 8px 8px; display: flex; justify-content: center; }
.rail-feed { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.rail-result { font-size: 11px; color: var(--screen-dim); line-height: 1.4; }

/* stacked at 375px / narrow window per DESIGN-V3 §10 */
@media (max-width: 759px) {
  .chat-app { flex-direction: column; }
  .games-rail { flex: 0 0 auto; max-height: 46%; border-left: 0; border-top: 1px solid var(--screen-rim); }
}

@media (prefers-reduced-motion: reduce) {
  .modctl { transition: none; }
}
