/* Chatterlace chat — the original unified-chat design, unchanged in layout.
   Every color is a variable; themes (themes/*.css) recolor by overriding the
   :root tokens only. The defaults below are the original dark cockpit look. */
:root {
  --bg: #0a0a0c;
  --bar-bg: #0c0c0f;
  --hair: rgba(255, 255, 255, 0.07);
  --hair-strong: rgba(255, 255, 255, 0.12);
  --text: #f2f2f4;
  --user: #c9c9d2;
  --legend: #8a8a93;
  --faint: #55555f;
  --quiet: #c9c9d0;
  --control-bg: rgba(255, 255, 255, 0.06);
  --control-border: rgba(255, 255, 255, 0.18);
  --control-press: rgba(255, 255, 255, 0.16);
  --gold: #ffc457;
  --gold-wash: rgba(255, 196, 87, 0.07);
  --gold-wash-strong: rgba(255, 196, 87, 0.12);
  --gold-pill: rgba(255, 196, 87, 0.14);
  --menu: #ffba7d;
  --pm: #ec4899;
  --pm-wash: rgba(236, 72, 153, 0.06);
  --pm-pill-bg: rgba(236, 72, 153, 0.25);
  --pm-pill-fg: #ffb3d9;
  --priv: #c084fc;
  --priv-wash: rgba(192, 132, 252, 0.14);
  --priv-text: #e9d5ff;
  --flag: rgba(232, 67, 147, 0.95);
  --rail: rgba(232, 67, 147, 0.85);
  --flag-text: #fff;
  /* Platform badges (canonical CB/SC/CS colors). */
  --cb-bg: #f47321; --cb-fg: #fff;
  --sc-bg: #1fb6c1; --sc-fg: #fff;
  --cs-bg: #e84393; --cs-fg: #fff;
  --mf-bg: #6f9a3b; --mf-fg: #fff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button:focus-visible { outline: 2px solid var(--flag); outline-offset: 2px; }

/* ---- Top header strip ---- */
header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--hair);
  background: var(--bar-bg);
}
.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
#legend-items { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--legend); }
.zoom {
  display: flex; align-items: center; gap: 8px;
  margin-left: 6px; padding-left: 14px;
  border-left: 1px solid var(--hair-strong);
}
.zoom-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  font-size: 18px; font-weight: 700; line-height: 1;
  cursor: pointer; font-family: inherit;
}
.zoom-btn:active { background: var(--control-press); }
#zoom-val { min-width: 46px; text-align: center; font-size: 13px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- Platform badge (box model from the canonical badge system) ---- */
.badge {
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; height: 1.6em; min-width: 1.6em; padding: 0 0.5em; border-radius: 0.4em;
  font-weight: 800; letter-spacing: 0.04em; line-height: 1; white-space: nowrap;
  font-size: 12px;
}
.platform-chaturbate { background: var(--cb-bg); color: var(--cb-fg); }
.platform-stripchat  { background: var(--sc-bg); color: var(--sc-fg); }
.platform-camsoda    { background: var(--cs-bg); color: var(--cs-fg); }
.platform-myfreecams { background: var(--mf-bg); color: var(--mf-fg); }

/* ---- Message list ---- */
#list { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 0 10px; }
#list[hidden] { display: none; }
.row .body .badge, .tm-top .badge { vertical-align: middle; margin-right: 9px; position: relative; top: -0.07em; }
.row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 5px 16px; margin-top: 7px;
  font-size: calc(17px * var(--scale, 1)); line-height: 1.4;
}
.row.cont { padding-top: 0; margin-top: -1px; }
.tdiv { display: flex; align-items: center; gap: 10px; margin: 12px 16px 4px; }
.tdiv::before, .tdiv::after { content: ""; flex: 1; height: 1px; background: var(--hair); }
.tdiv span { font-family: 'Spline Sans Mono', ui-monospace, monospace; font-size: calc(11.5px * var(--scale, 1)); font-weight: 600; color: var(--faint); }
.row .body { flex: 1 1 auto; min-width: 0; word-wrap: break-word; overflow-wrap: anywhere; }
.user { font-weight: 700; color: var(--user); margin-right: 7px; }
.text { color: var(--text); }
.vp-msgline { display: block; margin-top: 1px; }

/* ---- Tips: tiered by amount — visual weight follows the money ---- */
.row.tip-quiet { padding: 3px 16px; font-size: calc(13.5px * var(--scale, 1)); color: var(--quiet); align-items: center; }
.row.tip-quiet .tq-amt { font-family: 'Spline Sans Mono', ui-monospace, monospace; color: var(--gold); font-weight: 700; margin-right: 7px; white-space: nowrap; }
.row.tip-quiet .text { color: var(--quiet); }
.row.tip { background: var(--gold-wash); border-left: 3px solid var(--gold); }
.pill {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; margin-right: 7px; border-radius: 999px;
  background: var(--gold-pill); color: var(--gold);
  font-family: 'Spline Sans Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums;
  font-size: calc(15px * var(--scale, 1)); font-weight: 700; white-space: nowrap; vertical-align: 1px;
}
.row.tip-moment { display: block; padding: 8px 16px; background: var(--gold-wash-strong); border-left: 3px solid var(--gold); }
.tm-top { display: flex; align-items: center; gap: 10px; }
.tm-amt { font-family: 'Spline Sans Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: calc(26px * var(--scale, 1)); font-weight: 700; color: var(--gold); white-space: nowrap; }
.row.tip-moment .tip-menu { font-size: calc(15px * var(--scale, 1)); margin-top: 4px; }
.row.tip-moment .text { display: block; margin-top: 3px; font-size: calc(15px * var(--scale, 1)); }
.tip-menu { display: block; width: 100%; margin-top: 3px; font-size: calc(13px * var(--scale, 1)); font-weight: 700; color: var(--menu); }

/* ---- Private messages ---- */
.row.pmrow { background: var(--pm-wash); border-left: 3px solid var(--pm); }
.pm-pill {
  flex: 0 0 auto; display: inline-flex; align-items: center;
  padding: 2px 9px; margin-right: 7px; border-radius: 999px;
  background: var(--pm-pill-bg); color: var(--pm-pill-fg);
  font-size: calc(12px * var(--scale, 1)); font-weight: 800;
}

/* ---- Notices ---- */
.row.notice .notice-text { font-size: calc(14px * var(--scale, 1)); }
.row.notice.priv { background: var(--priv-wash); border-left: 3px solid var(--priv); }
.row.notice.priv .notice-text { color: var(--priv-text); font-weight: 700; font-size: calc(15px * var(--scale, 1)); }
.smc-icon { margin-right: 2px; }

/* ---- Empty state ---- */
#empty { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 15px; font-style: italic; }
#empty.hidden { display: none; }

/* ---- "You're scrolled up": rail + pill ---- */
#scroll-rail { position: absolute; left: 3px; top: 0; width: 4px; border-radius: 3px;
  background: var(--rail); opacity: 0; transition: opacity .18s; pointer-events: none; z-index: 40; }
#scroll-rail.on { opacity: 1; }
#scroll-flag { position: absolute; left: 50%; transform: translateX(-50%) translateY(8px);
  z-index: 45; display: flex; align-items: center; gap: 8px;
  background: var(--flag); color: var(--flag-text); font-weight: 800;
  font-size: calc(13px * var(--scale, 1)); padding: 8px 16px; border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35); cursor: pointer; border: none;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; font-family: inherit; }
#scroll-flag.on { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#scroll-flag .sf-n { background: rgba(0, 0, 0, 0.22); border-radius: 999px; padding: 1px 8px; }
#scroll-flag .sf-n[hidden] { display: none; }

/* Narrow screens: one header line — badges carry the platforms (names on hover). */
@media (max-width: 520px) {
  header { padding: 8px 12px; }
  .legend, #legend-items { flex-wrap: nowrap; gap: 8px; }
  .legend-name { display: none; }
  .zoom { gap: 6px; margin-left: 2px; padding-left: 10px; }
  .zoom-btn { width: 28px; height: 28px; }
  #zoom-val { min-width: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  #scroll-rail, #scroll-flag { transition: none; }
}
