/* SpaceGram 2.8 — Worlds.
   Every theme is its own material, not a recolour: its own type, shapes of the
   messages, borders, textures and the way the open chat is marked. Loaded
   after sky.css; each block is keyed on its theme only.
   B  = a text or media bubble (stickers and video circles stay bare). */

/* ════════════ Day — a paper star atlas ════════════
   Cream paper, serif type, ink rules between rows, square notes, a double rule
   under the header, the logo as an ink stamp. */

[data-theme="light"] {
  --font-sans: Georgia, "Noto Serif", "Times New Roman", serif;
  --bg-root: #e9e2d2;
  --sidebar-bg: #f6f1e6;
  --surface: #fbf8f1;
  --surface-2: #ece5d6;
  --input-bg: #fbf8f1;
  --text: #1f1a14;
  --text-2: #463c31;
  --muted: #6b5f50;
  --faint: #998b78;
  --accent: #1f4e8c;
  --accent-strong: #163c6e;
  --accent-contrast: #ffffff;
  --accent-ink: #1f4e8c;
  --active: #ebe3d1;
  --chat-bg: #efe7d6;
  --chat-bg-2: #e7dcc5;
  --bubble-in: #fffdf7;
  --bubble-out: #1f4e8c;
  --pattern-color: #4a3a22;
  --pattern-opacity: 0.16;
  --border: rgba(60, 42, 20, 0.2);
  --sidebar-border: rgba(60, 42, 20, 0.22);
  --logo-bg: transparent;
  --logo-fg: #1f4e8c;
  --row-radius: 0px;
  --avatar-radius: 50%;
  --bubble-radius: 3px;
  --bubble-tail: 3px;
  --sky-deep: #13233d;
  --sky-mid: #1f3557;
}

[data-theme="light"] .sidebar {
  background-image: repeating-linear-gradient(180deg, transparent 0 27px, rgba(60, 42, 20, 0.045) 27px 28px);
  border-right: 3px double rgba(60, 42, 20, 0.35);
}

[data-theme="light"] .logo {
  border: 1.5px solid #1f4e8c;
  border-radius: 50%;
}

[data-theme="light"] .brand-name {
  font-family: Georgia, "Noto Serif", serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
}

[data-theme="light"] .search {
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(60, 42, 20, 0.45);
  border-radius: 0;
}

[data-theme="light"] .game-invite {
  border: 1px dashed rgba(60, 42, 20, 0.45);
  border-radius: 0;
}

[data-theme="light"] .chat-list {
  padding: 0;
}

[data-theme="light"] .chat-item {
  border-radius: 0;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(60, 42, 20, 0.14);
}

[data-theme="light"] .chat-item.is-active::before {
  left: 0;
  width: 3px;
  height: 100%;
  top: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #1f4e8c;
}

[data-theme="light"] .chat-item-name {
  font-size: 16px;
  font-weight: 700;
}

[data-theme="light"] .avatar:not(.has-photo):not(.avatar-saved) {
  background-color: #efe7d6 !important;
  color: #1f4e8c !important;
  border: 1px solid rgba(31, 26, 20, 0.4);
  font-family: Georgia, serif;
  font-weight: 700;
}

[data-theme="light"] .chat-header {
  background: #f6f1e6;
  border-bottom: 3px double rgba(60, 42, 20, 0.45);
}

[data-theme="light"] #chat-title {
  font-family: Georgia, "Noto Serif", serif;
  font-size: 20px;
  font-weight: 700;
}

[data-theme="light"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px solid rgba(31, 26, 20, 0.3);
  box-shadow: 3px 3px 0 rgba(60, 42, 20, 0.1);
  font-size: 15.5px;
}

[data-theme="light"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  border-color: #163c6e;
}

[data-theme="light"] .day-chip {
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(60, 42, 20, 0.4);
  border-bottom: 1px solid rgba(60, 42, 20, 0.4);
  border-radius: 0;
  padding: 2px 16px;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: #463c31;
}

[data-theme="light"] .composer {
  border-radius: 3px;
  border: 1px solid rgba(31, 26, 20, 0.45);
  box-shadow: 3px 3px 0 rgba(60, 42, 20, 0.1);
}

[data-theme="light"] .send-btn,
[data-theme="light"] .icon-btn-accent {
  border-radius: 50%;
}

[data-theme="light"] .unread-badge {
  border-radius: 50%;
  font-family: Georgia, serif;
}

/* ════════════ Black — a green phosphor terminal ════════════ */

[data-theme="black"] {
  --font-sans: Consolas, "Cascadia Mono", "Roboto Mono", "DejaVu Sans Mono", "Courier New", monospace;
  --bg-root: #000000;
  --sidebar-bg: #010702;
  --surface: #020d05;
  --surface-2: #062210;
  --input-bg: #020d05;
  --text: #5cff8f;
  --text-2: #3fd774;
  --muted: #2fae5c;
  --faint: #1f7a40;
  --accent: #5cff8f;
  --accent-strong: #8dffb0;
  --accent-contrast: #001a08;
  --accent-ink: #5cff8f;
  --active: #5cff8f;
  --hover: rgba(92, 255, 143, 0.08);
  --chat-bg: #000000;
  --chat-bg-2: #010a03;
  --bubble-in: #000000;
  --bubble-in-text: #5cff8f;
  --bubble-out: #062a12;
  --bubble-out-text: #8dffb0;
  --time-in: rgba(92, 255, 143, 0.6);
  --time-out: rgba(141, 255, 176, 0.7);
  --pattern-color: #5cff8f;
  --pattern-opacity: 0.08;
  --border: rgba(92, 255, 143, 0.35);
  --sidebar-border: rgba(92, 255, 143, 0.35);
  --logo-bg: #000000;
  --logo-fg: #5cff8f;
  --row-radius: 0px;
  --avatar-radius: 0px;
  --bubble-radius: 0px;
  --bubble-tail: 0px;
  --av-ink-base: #5cff8f;
  --sky-deep: #000000;
  --sky-mid: #021a09;
}

[data-theme="black"] body {
  text-shadow: 0 0 6px rgba(92, 255, 143, 0.35);
}

[data-theme="black"] :is(.logo, .search, .game-invite, .composer, .send-btn, .icon-btn, .icon-btn-accent, .unread-badge, .profile-coins, .chat-item-streak, .streak-chip, .day-chip, .modal, #theme-popover) {
  border-radius: 0 !important;
}

[data-theme="black"] .logo {
  border: 1px solid #5cff8f;
}

[data-theme="black"] .brand-name {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0;
}

[data-theme="black"] .brand-name::after {
  content: "_";
  animation: sg-term-blink 1.1s steps(1) infinite;
}

@keyframes sg-term-blink {
  50% {
    opacity: 0;
  }
}

[data-theme="black"] .search {
  background: transparent;
  border: 1px solid rgba(92, 255, 143, 0.5);
}

[data-theme="black"] .game-invite {
  border: 1px dashed rgba(92, 255, 143, 0.6);
}

[data-theme="black"] .chat-item {
  border-radius: 0;
}

[data-theme="black"] .chat-item-name::before {
  content: "> ";
  color: var(--muted);
}

/* the open chat is drawn inverted, like a terminal selection */
[data-theme="black"] .chat-item.is-active,
[data-theme="black"] .chat-item.is-active:hover {
  background: #5cff8f;
  text-shadow: none;
}

[data-theme="black"] .chat-item.is-active::before {
  display: none;
}

[data-theme="black"] .chat-item.is-active :is(.chat-item-name, .chat-item-time, .chat-item-preview, .chat-item-preview .you, .chat-item-kind, .chat-item-streak) {
  color: #001a08 !important;
}

[data-theme="black"] .chat-item.is-active .chat-item-name::before {
  color: #001a08;
}

[data-theme="black"] .avatar:not(.has-photo):not(.avatar-saved) {
  background-color: transparent !important;
  color: #5cff8f !important;
  border: 1px solid rgba(92, 255, 143, 0.6);
}

[data-theme="black"] .chat-item.is-active .avatar:not(.has-photo):not(.avatar-saved) {
  color: #001a08 !important;
  border-color: #001a08;
}

[data-theme="black"] .chat-header {
  background: #000;
  border-bottom: 1px solid rgba(92, 255, 143, 0.5);
}

[data-theme="black"] #chat-title::before {
  content: "~/";
  color: var(--muted);
}

/* scanlines over the whole chat */
[data-theme="black"] .chat-body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
}

[data-theme="black"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px dashed rgba(92, 255, 143, 0.55);
  box-shadow: none;
}

[data-theme="black"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px solid #5cff8f;
}

[data-theme="black"] .day-chip {
  background: #000;
  border: 0;
  color: #5cff8f;
}

[data-theme="black"] .day-chip::before {
  content: "[ ";
}

[data-theme="black"] .day-chip::after {
  content: " ]";
}

[data-theme="black"] .composer {
  border: 1px solid #5cff8f;
  background: #000;
  box-shadow: none;
}

[data-theme="black"] .composer textarea {
  caret-color: #5cff8f;
}

[data-theme="black"] .unread-badge {
  background: transparent;
  color: #5cff8f;
  border: 1px solid #5cff8f;
}

/* ════════════ Midnight — a blueprint ════════════ */

[data-theme="midnight"] {
  --font-sans: "Onest", "Segoe UI", Roboto, sans-serif;
  --font-mono: Consolas, "Cascadia Mono", "Roboto Mono", "Courier New", monospace;
  --bg-root: #072546;
  --sidebar-bg: #0a2c52;
  --surface: #0d3563;
  --surface-2: #11406f;
  --input-bg: #0a2c52;
  --text: #f2f8ff;
  --text-2: #c5daf2;
  --muted: #9dbbe0;
  --faint: #6e93bf;
  --accent: #f2f8ff;
  --accent-strong: #ffffff;
  --accent-contrast: #0a2c52;
  --accent-ink: #f2f8ff;
  --active: rgba(255, 255, 255, 0.07);
  --chat-bg: #0e3e70;
  --chat-bg-2: #0b3562;
  --bubble-in: #0e3e70;
  --bubble-in-text: #f2f8ff;
  --bubble-out: #f2f8ff;
  --bubble-out-text: #0a2c52;
  --time-out: rgba(10, 44, 82, 0.65);
  --pattern-color: #ffffff;
  --pattern-opacity: 0.1;
  --border: rgba(255, 255, 255, 0.4);
  --sidebar-border: rgba(255, 255, 255, 0.35);
  --logo-bg: transparent;
  --logo-fg: #ffffff;
  --row-radius: 0px;
  --avatar-radius: 50%;
  --bubble-radius: 0px;
  --bubble-tail: 0px;
}

[data-theme="midnight"] .chat-body {
  background:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 100px 100px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 100px 100px,
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 20px 20px,
    #0e3e70;
}

[data-theme="midnight"] .sidebar {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 20px 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.45);
}

[data-theme="midnight"] :is(.chat-item-name, #chat-title, .brand-name, .chat-item-time, .day-chip, .msg-meta, .unread-badge) {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

[data-theme="midnight"] :is(.chat-item-name, #chat-title, .brand-name) {
  text-transform: uppercase;
  font-weight: 500;
}

[data-theme="midnight"] .logo {
  border: 1px dashed #fff;
  border-radius: 50%;
}

[data-theme="midnight"] .search,
[data-theme="midnight"] .game-invite {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.55);
  border-radius: 0;
}

[data-theme="midnight"] .chat-item.is-active,
[data-theme="midnight"] .chat-item.is-active:hover {
  outline: 1px dashed rgba(255, 255, 255, 0.8);
  outline-offset: -3px;
}

[data-theme="midnight"] .chat-item.is-active::before {
  display: none;
}

[data-theme="midnight"] .avatar:not(.has-photo):not(.avatar-saved) {
  background-color: transparent !important;
  color: #fff !important;
  border: 1px dashed rgba(255, 255, 255, 0.75);
  font-family: var(--font-mono);
}

[data-theme="midnight"] .chat-header {
  background: #0a2c52;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}

/* every message is a drawn box with corner ticks */
[data-theme="midnight"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: none;
  background-image:
    linear-gradient(#fff, #fff) 0 0 / 8px 2px no-repeat,
    linear-gradient(#fff, #fff) 0 0 / 2px 8px no-repeat,
    linear-gradient(#fff, #fff) 100% 100% / 8px 2px no-repeat,
    linear-gradient(#fff, #fff) 100% 100% / 2px 8px no-repeat;
}

[data-theme="midnight"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  background-image: none;
}

[data-theme="midnight"] .day-chip {
  background: #0e3e70;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 0;
  color: #fff;
}

[data-theme="midnight"] .day-chip::before {
  content: "├─ ";
}

[data-theme="midnight"] .day-chip::after {
  content: " ─┤";
}

[data-theme="midnight"] .composer {
  border: 1px dashed rgba(255, 255, 255, 0.7);
  border-radius: 0;
  background: #0a2c52;
  box-shadow: none;
}

[data-theme="midnight"] .send-btn,
[data-theme="midnight"] .icon-btn-accent,
[data-theme="midnight"] .unread-badge {
  border-radius: 0;
}

/* ════════════ Yellow — a comic page ════════════
   Halftone dots, thick ink outlines, hard shadows, speech balloons with tails,
   a "POW" burst for the date. */

[data-theme="sunshine"] {
  --bg-root: #ffe14d;
  --sidebar-bg: #fff8d6;
  --surface: #ffffff;
  --surface-2: #fff1a8;
  --input-bg: #ffffff;
  --text: #111111;
  --text-2: #2b2b2b;
  --muted: #555046;
  --accent: #d61f26;
  --accent-strong: #b3151b;
  --accent-contrast: #ffffff;
  --accent-ink: #d61f26;
  --active: #ffe14d;
  --chat-bg: #ffe14d;
  --bubble-in: #ffffff;
  --bubble-in-text: #111111;
  --bubble-out: #d61f26;
  --bubble-out-text: #ffffff;
  --pattern-opacity: 0;
  --border: #111111;
  --sidebar-border: #111111;
  --logo-bg: #d61f26;
  --logo-fg: #ffffff;
  --row-radius: 12px;
  --avatar-radius: 50%;
  --bubble-radius: 20px;
  --bubble-tail: 20px;
}

[data-theme="sunshine"] .chat-body {
  background:
    radial-gradient(circle, rgba(214, 31, 38, 0.28) 1.7px, transparent 2.2px) 0 0 / 12px 12px,
    radial-gradient(circle, rgba(214, 31, 38, 0.16) 1.2px, transparent 1.7px) 6px 6px / 12px 12px,
    #ffe14d;
}

[data-theme="sunshine"] .sidebar {
  border-right: 3px solid #111;
}

[data-theme="sunshine"] :is(.brand-name, #chat-title, .chat-item-name, .game-invite-text strong) {
  font-family: "Unbounded", "Onest", sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.01em;
}

[data-theme="sunshine"] .chat-item-name {
  font-size: 13px;
}

[data-theme="sunshine"] :is(.logo, .search, .game-invite, .composer, .send-btn, .icon-btn-accent) {
  border: 2.5px solid #111;
  box-shadow: 3px 3px 0 #111;
}

[data-theme="sunshine"] .search,
[data-theme="sunshine"] .game-invite {
  background: #fff;
}

[data-theme="sunshine"] .chat-item {
  margin-bottom: 6px;
  border: 2px solid transparent;
}

[data-theme="sunshine"] .chat-item.is-active,
[data-theme="sunshine"] .chat-item.is-active:hover {
  background: #ffe14d;
  border: 2.5px solid #111;
  box-shadow: 4px 4px 0 #111;
  transform: rotate(-0.8deg);
}

[data-theme="sunshine"] .chat-item.is-active::before {
  display: none;
}

[data-theme="sunshine"] .avatar:not(.has-photo):not(.avatar-saved) {
  border: 2px solid #111;
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
}

[data-theme="sunshine"] .chat-header {
  background: #fff8d6;
  border-bottom: 3px solid #111;
}

[data-theme="sunshine"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 2.5px solid #111;
  box-shadow: 4px 4px 0 #111;
  font-weight: 500;
  overflow: visible;
}

/* the tail of the balloon: an ink-edged wedge under the corner */
[data-theme="sunshine"] .msg-row .bubble:not(.has-circle):not(.has-sticker):not(.has-media)::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 18px;
  width: 14px;
  height: 14px;
  background: inherit;
  border-right: 2.5px solid #111;
  border-bottom: 2.5px solid #111;
  transform: skewX(30deg) rotate(45deg);
  z-index: -1;
  pointer-events: none;
}

[data-theme="sunshine"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker):not(.has-media)::after {
  left: auto;
  right: 18px;
  transform: skewX(-30deg) rotate(45deg);
}

[data-theme="sunshine"] .msg-row {
  margin-bottom: 8px;
}

/* the date shouts from a burst */
[data-theme="sunshine"] .day-chip {
  background: #fff;
  color: #111;
  border: 0;
  border-radius: 0;
  padding: 14px 26px;
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  clip-path: polygon(50% 0, 58% 22%, 80% 6%, 74% 30%, 100% 28%, 82% 48%, 100% 66%, 75% 68%, 82% 94%, 60% 78%, 50% 100%, 40% 78%, 18% 94%, 25% 68%, 0 66%, 18% 48%, 0 28%, 26% 30%, 20% 6%, 42% 22%);
}

[data-theme="sunshine"] .composer {
  border-radius: 14px;
}

[data-theme="sunshine"] .send-btn {
  border-radius: 50%;
}

[data-theme="sunshine"] .unread-badge {
  border: 2px solid #111;
}

/* ════════════ Green — a herbarium ════════════
   Kraft paper, stitched seams, luggage-tag rows with a punched hole, notes
   held on with tape. */

[data-theme="forest"] {
  --bg-root: #cdbb94;
  --sidebar-bg: #eadfc6;
  --surface: #f7f0de;
  --surface-2: #e2d4b3;
  --input-bg: #f7f0de;
  --text: #2a2414;
  --text-2: #4b4128;
  --muted: #6a5d3e;
  --accent: #2f5d34;
  --accent-strong: #234628;
  --accent-contrast: #ffffff;
  --accent-ink: #2f5d34;
  --active: #f7f0de;
  --chat-bg: #d9c8a2;
  --chat-bg-2: #cfbb92;
  --bubble-in: #fbf6e8;
  --bubble-in-text: #2a2414;
  --bubble-out: #2f5d34;
  --pattern-color: #2f5d34;
  --pattern-opacity: 0.2;
  --pattern-size: 380px;
  --border: rgba(47, 93, 52, 0.45);
  --sidebar-border: rgba(74, 58, 30, 0.3);
  --logo-bg: #2f5d34;
  --logo-fg: #f7f0de;
  --row-radius: 6px;
  --avatar-radius: 50%;
  --bubble-radius: 4px;
  --bubble-tail: 4px;
}

[data-theme="forest"] .sidebar,
[data-theme="forest"] .chat-header {
  background-image:
    repeating-linear-gradient(115deg, rgba(90, 70, 30, 0.035) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(25deg, rgba(90, 70, 30, 0.03) 0 1px, transparent 1px 9px);
}

[data-theme="forest"] :is(.brand-name, #chat-title, .chat-item-name) {
  font-family: Georgia, "Noto Serif", serif;
  font-weight: 700;
  letter-spacing: 0;
}

[data-theme="forest"] .chat-header {
  border-bottom: 2px dashed rgba(47, 93, 52, 0.55);
}

[data-theme="forest"] .search,
[data-theme="forest"] .game-invite,
[data-theme="forest"] .composer {
  border: 1.5px dashed rgba(47, 93, 52, 0.6);
  box-shadow: none;
}

[data-theme="forest"] .chat-item.is-active,
[data-theme="forest"] .chat-item.is-active:hover {
  background: #f7f0de;
  border: 1.5px dashed rgba(47, 93, 52, 0.7);
  padding-left: 28px;
  clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
}

/* the punched hole of a luggage tag */
[data-theme="forest"] .chat-item.is-active::before {
  left: 8px;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border: 1.5px solid rgba(47, 93, 52, 0.8);
  border-radius: 50%;
  background: #d9c8a2;
}

[data-theme="forest"] .avatar:not(.has-photo):not(.avatar-saved) {
  border: 1.5px dashed rgba(47, 93, 52, 0.6);
}

[data-theme="forest"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  box-shadow: 0 2px 6px rgba(60, 45, 15, 0.18);
  overflow: visible;
}

/* a strip of tape holds every note to the page */
[data-theme="forest"] .msg-row .bubble:not(.has-circle):not(.has-sticker)::after {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 46px;
  height: 14px;
  margin-left: -23px;
  background: rgba(240, 228, 190, 0.78);
  border-left: 1px dashed rgba(120, 100, 60, 0.25);
  border-right: 1px dashed rgba(120, 100, 60, 0.25);
  transform: rotate(-3deg);
  pointer-events: none;
}

[data-theme="forest"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker)::after {
  transform: rotate(4deg);
}

[data-theme="forest"] .msg-row {
  margin-top: 10px;
}

[data-theme="forest"] .day-chip {
  background: #f7f0de;
  border: 1.5px dashed rgba(47, 93, 52, 0.6);
  border-radius: 4px;
  font-family: Georgia, serif;
}

/* ════════════ Blue — Aqua ════════════
   Pinstriped panels, glossy gel buttons and messages like water drops,
   a brushed-metal header. */

[data-theme="ocean"] {
  --bg-root: #dfe7ef;
  --sidebar-bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #e3ebf3;
  --text: #0f1e2e;
  --text-2: #33475c;
  --muted: #56697e;
  --accent: #1468c8;
  --accent-strong: #0d55a8;
  --accent-contrast: #ffffff;
  --accent-ink: #1060bb;
  --active: #d3e4f7;
  --chat-bg: #cfe4f6;
  --chat-bg-2: #a9cdec;
  --bubble-out: #1468c8;
  --border: rgba(40, 70, 100, 0.22);
  --logo-bg: #1468c8;
  --logo-fg: #ffffff;
  --row-radius: 999px;
  --avatar-radius: 50%;
  --bubble-radius: 22px;
  --bubble-tail: 22px;
  --gel: linear-gradient(180deg, #6fb3f5 0%, #2b7fe0 48%, #1468c8 52%, #3d93ec 100%);
}

[data-theme="ocean"] .sidebar {
  background-image: repeating-linear-gradient(180deg, #eef3f8 0 2px, #e6edf4 2px 4px);
}

[data-theme="ocean"] .chat-header {
  background: linear-gradient(180deg, #f6f8fa 0%, #dfe4ea 100%);
  border-bottom: 1px solid #a9b4c0;
}

[data-theme="ocean"] .chat-item.is-active,
[data-theme="ocean"] .chat-item.is-active:hover {
  background: var(--gel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 2px 6px rgba(20, 104, 200, 0.35);
}

[data-theme="ocean"] .chat-item.is-active::before {
  display: none;
}

[data-theme="ocean"] .chat-item.is-active :is(.chat-item-name, .chat-item-time, .chat-item-preview, .chat-item-preview .you, .chat-item-kind) {
  color: #fff !important;
  text-shadow: 0 1px 1px rgba(0, 40, 90, 0.4);
}

[data-theme="ocean"] :is(.send-btn, .icon-btn-accent, .unread-badge, .logo, .game-invite-art) {
  background: var(--gel) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 4px rgba(20, 104, 200, 0.35);
}

[data-theme="ocean"] :is(.send-btn, .icon-btn-accent, .unread-badge, .logo) {
  border-radius: 999px;
}

[data-theme="ocean"] .search,
[data-theme="ocean"] .composer {
  border-radius: 999px;
  background: #fff;
  border: 1px solid #9fb0c2;
  box-shadow: inset 0 2px 3px rgba(0, 30, 60, 0.12);
}

[data-theme="ocean"] .game-invite {
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #e7eef5);
  border: 1px solid #b4c2d0;
}

[data-theme="ocean"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0, rgba(255, 255, 255, 0) 50%);
  border: 1px solid rgba(40, 80, 120, 0.25);
  box-shadow: 0 3px 8px rgba(10, 60, 110, 0.18);
}

[data-theme="ocean"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  background: var(--gel);
  border-color: #0d55a8;
  text-shadow: 0 1px 1px rgba(0, 40, 90, 0.45);
}

[data-theme="ocean"] .day-chip {
  background: linear-gradient(180deg, #ffffff, #dde6ef);
  border: 1px solid #a9b8c8;
  border-radius: 999px;
}

/* ════════════ Red — velvet ════════════
   Deep wine velvet, gold hairlines, serif small caps, an art-deco lattice. */

[data-theme="ruby"] {
  color-scheme: dark;
  --font-sans: Georgia, "Noto Serif", "Times New Roman", serif;
  --bg-root: #1c060b;
  --sidebar-bg: #2a0a12;
  --surface: #350e18;
  --surface-2: #42131f;
  --input-bg: #2a0a12;
  --text: #f6e8d6;
  --text-2: #dcc3a5;
  --muted: #bb9d7c;
  --faint: #8c7055;
  --accent: #d6a84c;
  --accent-strong: #e8bf6a;
  --accent-contrast: #2a0a12;
  --accent-ink: #e2b660;
  --active: #46131f;
  --hover: rgba(214, 168, 76, 0.08);
  --chat-bg: #3a0c17;
  --chat-bg-2: #24070d;
  --bubble-in: #46131f;
  --bubble-in-text: #f6e8d6;
  --bubble-out: #d6a84c;
  --bubble-out-text: #2a0a12;
  --time-in: rgba(246, 232, 214, 0.55);
  --time-out: rgba(42, 10, 18, 0.65);
  --pattern-opacity: 0;
  --border: rgba(214, 168, 76, 0.4);
  --sidebar-border: rgba(214, 168, 76, 0.45);
  --logo-bg: transparent;
  --logo-fg: #d6a84c;
  --av-tint: 22%;
  --av-ink: 45%;
  --av-ink-base: #f6e8d6;
  --row-radius: 0px;
  --bubble-radius: 2px;
  --bubble-tail: 2px;
  --sky-deep: #1c060b;
  --sky-mid: #3a0c17;
}

[data-theme="ruby"] .chat-body {
  background:
    repeating-linear-gradient(45deg, rgba(214, 168, 76, 0.07) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(-45deg, rgba(214, 168, 76, 0.07) 0 1px, transparent 1px 34px),
    radial-gradient(120% 90% at 50% 40%, #44101c 0%, #24070d 100%);
}

[data-theme="ruby"] .sidebar {
  background-image: radial-gradient(140% 100% at 0% 0%, rgba(255, 255, 255, 0.04), transparent 60%);
  border-right: 1px solid rgba(214, 168, 76, 0.5);
}

[data-theme="ruby"] :is(.brand-name, #chat-title, .chat-item-name) {
  font-variant: small-caps;
  letter-spacing: 0.05em;
  font-weight: 400;
}

[data-theme="ruby"] .brand-name {
  font-family: Georgia, serif;
  font-size: 22px;
  color: #e2b660;
}

[data-theme="ruby"] .logo {
  border: 1px solid #d6a84c;
  transform: rotate(45deg);
  border-radius: 2px;
}

[data-theme="ruby"] .logo svg {
  transform: rotate(-45deg);
}

[data-theme="ruby"] .chat-header {
  background: #2a0a12;
  border-bottom: 1px solid rgba(214, 168, 76, 0.6);
  box-shadow: 0 3px 0 -2px rgba(214, 168, 76, 0.35);
}

[data-theme="ruby"] .search,
[data-theme="ruby"] .game-invite,
[data-theme="ruby"] .composer {
  border-radius: 0;
  border: 1px solid rgba(214, 168, 76, 0.55);
  background: transparent;
  box-shadow: none;
}

[data-theme="ruby"] .chat-item.is-active,
[data-theme="ruby"] .chat-item.is-active:hover {
  background: linear-gradient(90deg, rgba(214, 168, 76, 0.16), rgba(214, 168, 76, 0.02));
}

[data-theme="ruby"] .chat-item.is-active::before {
  left: 0;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 0;
  border-radius: 0;
  background: #d6a84c;
  transform: rotate(45deg);
}

/* art-deco corners on every message */
[data-theme="ruby"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px solid rgba(214, 168, 76, 0.55);
  outline: 1px solid rgba(214, 168, 76, 0.25);
  outline-offset: 3px;
  box-shadow: none;
}

[data-theme="ruby"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  background: linear-gradient(180deg, #e2b660, #c4953a);
  outline-color: rgba(214, 168, 76, 0.45);
}

[data-theme="ruby"] .day-chip {
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(214, 168, 76, 0.6);
  border-bottom: 1px solid rgba(214, 168, 76, 0.6);
  border-radius: 0;
  color: #e2b660;
  font-variant: small-caps;
  letter-spacing: 0.12em;
}

[data-theme="ruby"] .send-btn,
[data-theme="ruby"] .unread-badge,
[data-theme="ruby"] .icon-btn-accent {
  border-radius: 0;
}

/* ════════════ Gray — a retro desktop ════════════
   The grey windows of the nineties: bevelled panels, a navy title bar,
   tooltip-yellow messages on a teal desktop. */

[data-theme="graphite"] {
  --font-sans: Tahoma, "MS Sans Serif", "Segoe UI", Roboto, sans-serif;
  --bg-root: #008080;
  --sidebar-bg: #c0c0c0;
  --surface: #c0c0c0;
  --surface-2: #ffffff;
  --input-bg: #ffffff;
  --text: #000000;
  --text-2: #1a1a1a;
  --muted: #404040;
  --faint: #6b6b6b;
  --accent: #000080;
  --accent-strong: #0000a8;
  --accent-contrast: #ffffff;
  --accent-ink: #000080;
  --active: #000080;
  --hover: rgba(0, 0, 128, 0.08);
  --chat-bg: #008080;
  --chat-bg-2: #007373;
  --bubble-in: #c0c0c0;
  --bubble-in-text: #000000;
  --bubble-out: #ffffe1;
  --bubble-out-text: #000000;
  --time-in: rgba(0, 0, 0, 0.6);
  --time-out: rgba(0, 0, 0, 0.6);
  --pattern-opacity: 0;
  --border: #808080;
  --sidebar-border: #808080;
  --logo-bg: #c0c0c0;
  --logo-fg: #000080;
  --row-radius: 0px;
  --avatar-radius: 0px;
  --bubble-radius: 0px;
  --bubble-tail: 0px;
  --bevel-out: inset -1px -1px #0a0a0a, inset 1px 1px #ffffff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
  --bevel-in: inset -1px -1px #ffffff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080;
}

[data-theme="graphite"] body {
  font-size: 14px;
}

[data-theme="graphite"] .sidebar {
  box-shadow: var(--bevel-out);
  border: 0;
}

[data-theme="graphite"] .chat-header {
  background: linear-gradient(90deg, #000080, #1084d0);
  border: 0;
  color: #fff;
}

[data-theme="graphite"] .chat-header :is(#chat-title, .chat-head-text, .chat-head-line, .icon-btn, .chat-head-text span) {
  color: #fff !important;
}

[data-theme="graphite"] #chat-title,
[data-theme="graphite"] .brand-name {
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-weight: 700;
  letter-spacing: 0;
}

[data-theme="graphite"] :is(.logo, .icon-btn, .icon-btn-accent, .send-btn, .game-invite, .profile-coins, .unread-badge, .day-chip) {
  border-radius: 0 !important;
  box-shadow: var(--bevel-out) !important;
  background: #c0c0c0 !important;
  color: #000 !important;
  border: 0 !important;
}

[data-theme="graphite"] .chat-header .icon-btn {
  background: #c0c0c0 !important;
  color: #000 !important;
  width: 32px;
  height: 28px;
}

[data-theme="graphite"] .chat-header .icon-btn * {
  color: #000 !important;
}

[data-theme="graphite"] :is(.search, .composer) {
  border-radius: 0;
  background: #fff;
  border: 0;
  box-shadow: var(--bevel-in);
}

[data-theme="graphite"] .composer-wrap {
  background: #c0c0c0;
  box-shadow: var(--bevel-out);
}

[data-theme="graphite"] .chat-item.is-active,
[data-theme="graphite"] .chat-item.is-active:hover {
  background: #000080;
}

[data-theme="graphite"] .chat-item.is-active::before {
  display: none;
}

[data-theme="graphite"] .chat-item.is-active :is(.chat-item-name, .chat-item-time, .chat-item-preview, .chat-item-preview .you, .chat-item-kind) {
  color: #fff !important;
}

[data-theme="graphite"] .avatar:not(.has-photo):not(.avatar-saved) {
  box-shadow: var(--bevel-out);
  background-color: #c0c0c0 !important;
  color: #000080 !important;
}

[data-theme="graphite"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  box-shadow: var(--bevel-out);
  border: 0;
  padding-top: 26px;
}

/* each message is a little window with its own title bar */
[data-theme="graphite"] .msg-row .bubble:not(.has-circle):not(.has-sticker)::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  height: 18px;
  background:
    linear-gradient(#c0c0c0, #c0c0c0) right 3px center / 13px 11px no-repeat,
    linear-gradient(90deg, #808080, #b5b5b5);
  box-shadow: none;
  pointer-events: none;
}

[data-theme="graphite"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker)::before {
  background:
    linear-gradient(#c0c0c0, #c0c0c0) right 3px center / 13px 11px no-repeat,
    linear-gradient(90deg, #000080, #1084d0);
}

[data-theme="graphite"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  background: #ffffe1;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #ffffff, 2px 2px 0 rgba(0, 0, 0, 0.35);
}

[data-theme="graphite"] .day-chip {
  font-size: 12px;
}

/* ════════════ Purple — soft clay ════════════
   Everything is pressed out of the same lavender clay: raised by light and
   shade, the open chat and the fields pressed in. */

[data-theme="violet"] {
  --bg-root: #e6e0f2;
  --sidebar-bg: #e6e0f2;
  --surface: #e6e0f2;
  --surface-2: #e6e0f2;
  --input-bg: #e6e0f2;
  --text: #2a2140;
  --text-2: #4a3f66;
  --muted: #625685;
  --accent: #6f45c4;
  --accent-strong: #5c36ab;
  --accent-contrast: #ffffff;
  --active: #e6e0f2;
  --chat-bg: #e6e0f2;
  --chat-bg-2: #e6e0f2;
  --bubble-in: #e6e0f2;
  --bubble-in-text: #2a2140;
  --bubble-out: #6f45c4;
  --pattern-opacity: 0.06;
  --border: transparent;
  --sidebar-border: transparent;
  --logo-bg: #6f45c4;
  --logo-fg: #ffffff;
  --row-radius: 22px;
  --avatar-radius: 50%;
  --bubble-radius: 24px;
  --bubble-tail: 24px;
  --clay-up: 7px 7px 14px #c4bad9, -7px -7px 14px #ffffff;
  --clay-up-sm: 4px 4px 8px #c4bad9, -4px -4px 8px #ffffff;
  --clay-in: inset 5px 5px 10px #c4bad9, inset -5px -5px 10px #ffffff;
}

[data-theme="violet"] .sidebar {
  border-right: 0;
  box-shadow: 8px 0 18px -10px #c4bad9;
  z-index: 4;
}

[data-theme="violet"] .chat-header {
  background: #e6e0f2;
  border-bottom: 0;
  box-shadow: 0 8px 16px -10px #c4bad9;
}

[data-theme="violet"] :is(.search, .composer) {
  border: 0;
  border-radius: 20px;
  background: #e6e0f2;
  box-shadow: var(--clay-in);
}

[data-theme="violet"] :is(.logo, .icon-btn, .game-invite, .profile-coins, .day-chip) {
  border: 0;
  box-shadow: var(--clay-up-sm);
}

[data-theme="violet"] .icon-btn {
  border-radius: 50%;
  background: #e6e0f2;
}

[data-theme="violet"] .icon-btn-accent,
[data-theme="violet"] .send-btn {
  border-radius: 50%;
  box-shadow: 4px 4px 8px #c4bad9, -4px -4px 8px #ffffff, inset 2px 2px 4px rgba(255, 255, 255, 0.35), inset -2px -2px 4px rgba(0, 0, 0, 0.15);
}

[data-theme="violet"] .game-invite {
  border-radius: 22px;
  background: #e6e0f2;
}

[data-theme="violet"] .chat-item {
  margin-bottom: 6px;
}

[data-theme="violet"] .chat-item.is-active,
[data-theme="violet"] .chat-item.is-active:hover {
  background: #e6e0f2;
  box-shadow: var(--clay-in);
}

[data-theme="violet"] .chat-item.is-active::before {
  display: none;
}

[data-theme="violet"] .avatar {
  box-shadow: var(--clay-up-sm);
}

[data-theme="violet"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  box-shadow: var(--clay-up);
  border: 0;
}

[data-theme="violet"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  box-shadow: 7px 7px 14px #c4bad9, -7px -7px 14px #ffffff, inset 3px 3px 6px rgba(255, 255, 255, 0.3), inset -3px -3px 6px rgba(0, 0, 0, 0.18);
}

[data-theme="violet"] .msg-row {
  margin-bottom: 10px;
}

[data-theme="violet"] .day-chip {
  border-radius: 999px;
  background: #e6e0f2;
}

/* ════════════ Orange — the seventies ════════════
   Sunset stripes, chunky round shapes, cream and brown. */

[data-theme="tangerine"] {
  --bg-root: #f7e6c8;
  --sidebar-bg: #fbefd8;
  --surface: #fff8ea;
  --surface-2: #f3dfbb;
  --input-bg: #fff8ea;
  --text: #3a1d08;
  --text-2: #5c3415;
  --muted: #7a4c26;
  --accent: #c2410c;
  --accent-strong: #9a3412;
  --accent-contrast: #fff8ea;
  --accent-ink: #b33c0b;
  --active: #f7d9a8;
  --chat-bg: #fbefd8;
  --bubble-in: #fff8ea;
  --bubble-in-text: #3a1d08;
  --bubble-out: #c2410c;
  --bubble-out-text: #fff8ea;
  --pattern-opacity: 0;
  --border: #7f3b08;
  --sidebar-border: #7f3b08;
  --logo-bg: #7f3b08;
  --logo-fg: #ffc078;
  --row-radius: 999px;
  --avatar-radius: 50%;
  --bubble-radius: 26px;
  --bubble-tail: 26px;
  --stripes: linear-gradient(180deg, #e8590c 0 25%, #f08c00 25% 50%, #ffc078 50% 75%, #7f3b08 75% 100%);
}

/* a sunset of bands rising from the corner of the chat */
[data-theme="tangerine"] .chat-body {
  background:
    radial-gradient(circle at 100% 100%, #7f3b08 0 120px, #c2410c 120px 190px, #e8590c 190px 260px, #f08c00 260px 330px, #ffc078 330px 400px, transparent 400px),
    #fbefd8;
}

[data-theme="tangerine"] .chat-header {
  background: #fbefd8;
  border-bottom: 0;
  position: relative;
}

[data-theme="tangerine"] .chat-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -16px;
  height: 16px;
  background: var(--stripes);
  pointer-events: none;
}

[data-theme="tangerine"] .sidebar {
  border-right: 0;
  background-image: linear-gradient(90deg, transparent calc(100% - 12px), #e8590c calc(100% - 12px) calc(100% - 8px), #f08c00 calc(100% - 8px) calc(100% - 4px), #7f3b08 calc(100% - 4px));
}

[data-theme="tangerine"] :is(.brand-name, #chat-title, .chat-item-name, .game-invite-text strong) {
  font-family: "Unbounded", "Onest", sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

[data-theme="tangerine"] .chat-item-name {
  font-size: 14px;
}

[data-theme="tangerine"] :is(.search, .composer, .game-invite) {
  border: 2.5px solid #7f3b08;
  border-radius: 999px;
  box-shadow: none;
}

[data-theme="tangerine"] .chat-item.is-active,
[data-theme="tangerine"] .chat-item.is-active:hover {
  background: #f08c00;
  border: 2.5px solid #7f3b08;
}

[data-theme="tangerine"] .chat-item.is-active::before {
  display: none;
}

[data-theme="tangerine"] .chat-item.is-active :is(.chat-item-name, .chat-item-time, .chat-item-preview, .chat-item-preview .you, .chat-item-kind) {
  color: #3a1d08 !important;
}

[data-theme="tangerine"] .avatar:not(.has-photo):not(.avatar-saved) {
  border: 2.5px solid #7f3b08;
}

[data-theme="tangerine"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 2.5px solid #7f3b08;
  box-shadow: 0 4px 0 #7f3b08;
}

[data-theme="tangerine"] .day-chip {
  background: #7f3b08;
  color: #ffc078;
  border: 0;
  border-radius: 999px;
  font-family: "Unbounded", sans-serif;
}

/* ════════════ Pink — stickers ════════════
   Everything is a sticker with a white die-cut edge, a little crooked; the
   date is a strip of washi tape. */

[data-theme="blossom"] {
  --bg-root: #fbd9e6;
  --sidebar-bg: #fdeef4;
  --surface: #ffffff;
  --surface-2: #fde3ed;
  --text: #3b0f24;
  --text-2: #5e2541;
  --muted: #7f4560;
  --accent: #c32a72;
  --accent-strong: #a01f5d;
  --accent-contrast: #ffffff;
  --accent-ink: #b8256a;
  --active: #ffffff;
  --chat-bg: #fbd3e2;
  --chat-bg-2: #f8c1d6;
  --bubble-out: #c32a72;
  --pattern-color: #c32a72;
  --pattern-opacity: 0.14;
  --border: rgba(195, 42, 114, 0.2);
  --logo-bg: #c32a72;
  --logo-fg: #ffffff;
  --row-radius: 18px;
  --avatar-radius: 50%;
  --bubble-radius: 20px;
  --bubble-tail: 20px;
  --sticker: 0 0 0 4px #ffffff, 0 6px 0 3px rgba(120, 20, 60, 0.12), 0 8px 18px rgba(120, 20, 60, 0.18);
}

[data-theme="blossom"] :is(.brand-name, #chat-title, .chat-item-name) {
  font-weight: 700;
}

[data-theme="blossom"] :is(.logo, .icon-btn-accent, .send-btn, .game-invite, .unread-badge) {
  box-shadow: var(--sticker);
  border: 0;
}

[data-theme="blossom"] .logo {
  transform: rotate(-6deg);
}

[data-theme="blossom"] .search {
  border-radius: 999px;
  background: #fff;
  border: 2px dashed rgba(195, 42, 114, 0.35);
}

[data-theme="blossom"] .chat-item.is-active,
[data-theme="blossom"] .chat-item.is-active:hover {
  background: #fff;
  box-shadow: var(--sticker);
  transform: rotate(-1deg);
}

[data-theme="blossom"] .chat-item.is-active::before {
  display: none;
}

[data-theme="blossom"] .avatar {
  box-shadow: 0 0 0 3px #fff, 0 3px 6px rgba(120, 20, 60, 0.2);
}

[data-theme="blossom"] .chat-header {
  background: #fdeef4;
  border-bottom: 2px dashed rgba(195, 42, 114, 0.3);
}

[data-theme="blossom"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  box-shadow: var(--sticker);
  border: 0;
  transform: rotate(-1.2deg);
}

[data-theme="blossom"] .msg-row:nth-child(even) .bubble:not(.has-circle):not(.has-sticker) {
  transform: rotate(1.1deg);
}

[data-theme="blossom"] .msg-row {
  margin: 10px 0;
}

[data-theme="blossom"] .day-chip {
  background: repeating-linear-gradient(45deg, rgba(255, 170, 205, 0.85) 0 6px, rgba(255, 210, 228, 0.85) 6px 12px);
  color: #5e2541;
  border: 0;
  border-radius: 0;
  padding: 6px 22px;
  transform: rotate(-3deg);
  clip-path: polygon(0 10%, 4% 0, 8% 12%, 12% 0, 100% 0, 96% 90%, 100% 100%, 0 100%, 4% 88%);
}

[data-theme="blossom"] .composer {
  border-radius: 999px;
  border: 0;
  box-shadow: var(--sticker);
}

/* ════════════ Teal — under water ════════════
   The chat sinks into a lagoon: light from the surface, sand at the bottom,
   bubbles rising, messages like smooth pebbles. */

[data-theme="lagoon"] {
  --bg-root: #d4efec;
  --sidebar-bg: #e8f7f5;
  --surface: #ffffff;
  --surface-2: #d8f0ed;
  --text: #06302f;
  --text-2: #1d4f4c;
  --muted: #3d6d69;
  --accent: #00796f;
  --accent-strong: #005f57;
  --accent-contrast: #ffffff;
  --accent-ink: #00796f;
  --active: #cbebe7;
  --chat-bg: #0b5a62;
  --bubble-in: rgba(255, 255, 255, 0.9);
  --bubble-in-text: #06302f;
  --bubble-out: #ffb38a;
  --bubble-out-text: #3a1404;
  --time-out: rgba(58, 20, 4, 0.6);
  --pattern-opacity: 0;
  --logo-bg: #00796f;
  --logo-fg: #ffffff;
  --row-radius: 20px;
  --avatar-radius: 50%;
  --bubble-radius: 22px;
  --bubble-tail: 22px;
}

[data-theme="lagoon"] .chat-body {
  background:
    radial-gradient(60% 18% at 30% 0%, rgba(190, 255, 245, 0.35), transparent 70%),
    radial-gradient(40% 14% at 75% 0%, rgba(190, 255, 245, 0.25), transparent 70%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 78%, rgba(234, 214, 160, 0.55) 92%, #e8d39c 100%),
    linear-gradient(180deg, #1a8d92 0%, #0b5a62 55%, #073d45 100%);
}

/* rising bubbles */
[data-theme="lagoon"] .chat-body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.7) 0 1.5px, rgba(255, 255, 255, 0.15) 2px 5px, transparent 5.5px),
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.7) 0 1px, rgba(255, 255, 255, 0.15) 1.5px 3.5px, transparent 4px);
  background-size: 180px 260px, 110px 170px;
  background-position: 20px 0, 70px 40px;
  animation: sg-lagoon-rise 9s linear infinite;
}

@keyframes sg-lagoon-rise {
  to {
    background-position: 20px -260px, 70px -300px;
  }
}

[data-theme="lagoon"] .chat-header {
  background: #e8f7f5;
  border-bottom: 0;
  box-shadow: 0 6px 0 -3px #1a8d92;
}

[data-theme="lagoon"] :is(.search, .composer) {
  border-radius: 999px;
  border: 0;
}

[data-theme="lagoon"] .composer {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 16px rgba(0, 40, 45, 0.35);
}

[data-theme="lagoon"] .chat-item.is-active,
[data-theme="lagoon"] .chat-item.is-active:hover {
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 90, 90, 0.18);
}

[data-theme="lagoon"] .chat-item.is-active::before {
  border-right-color: #ff8a5c;
}

/* pebbles: no two corners alike */
[data-theme="lagoon"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border-radius: 26px 20px 24px 14px;
  box-shadow: 0 6px 14px rgba(0, 30, 35, 0.35);
}

[data-theme="lagoon"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  border-radius: 20px 26px 14px 24px;
}

[data-theme="lagoon"] .day-chip {
  background: rgba(255, 255, 255, 0.85);
  border: 0;
  border-radius: 999px;
}

/* ════════════ Halloween — a gothic night ════════════ */

[data-theme="halloween"] {
  --row-radius: 6px;
  --bubble-radius: 16px;
  --bubble-tail: 3px;
  --gothic: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Noto Serif", serif;
}

[data-theme="halloween"] :is(.brand-name, #chat-title, .chat-item-name, .day-chip) {
  font-family: var(--gothic);
  font-weight: 700;
  letter-spacing: 0.04em;
}

[data-theme="halloween"] .brand-name {
  font-size: 20px;
  color: #f68c36;
}

/* slime dripping from the underside of the header */
[data-theme="halloween"] .chat-header {
  position: relative;
  border-bottom: 0;
  background: #1d1426;
}

[data-theme="halloween"] .chat-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -18px;
  height: 20px;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='20' viewBox='0 0 160 20'%3E%3Cpath d='M0 0h160v4c-6 0-7 3-8 7s-2 7-4 7-3-3-3-7-1-6-6-6-6 2-7 4-1 3-3 3-2-2-3-4-3-3-8-3-8 1-9 6-1 9-4 9-3-4-3-9-2-6-9-6-8 2-9 5-2 4-4 4-3-2-3-5-2-4-8-4-6 1-7 3-1 2-2 2-2-1-2-3-3-3-6-3-7 2-8 6-2 6-4 6-3-3-3-6-1-5-6-5H0Z' fill='%237a2bc0'/%3E%3C/svg%3E") 0 0 / 160px 20px repeat-x;
  z-index: 6;
}

/* a cobweb in the corner of the chat list */
[data-theme="halloween"] .sidebar-header {
  position: relative;
}

[data-theme="halloween"] .sidebar-header::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 90px;
  height: 90px;
  pointer-events: none;
  opacity: 0.35;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 90' fill='none' stroke='%23e9d8ff' stroke-width='1'%3E%3Cpath d='M90 0 20 90M90 0 0 50M90 0 45 90M90 0 0 18M90 0 70 90'/%3E%3Cpath d='M74 0q-2 10 4 14q8 2 12 0M56 0q-4 18 8 28q16 6 26 0M38 0q-6 26 12 42q22 10 40 0M20 0q-8 34 16 56q28 14 54 2'/%3E%3C/svg%3E") no-repeat;
}

[data-theme="halloween"] .chat-item.is-active,
[data-theme="halloween"] .chat-item.is-active:hover {
  background: linear-gradient(90deg, rgba(246, 140, 54, 0.2), rgba(246, 140, 54, 0.03));
}

[data-theme="halloween"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px solid rgba(246, 140, 54, 0.45);
  box-shadow: 0 0 0 3px rgba(122, 43, 192, 0.25);
}

[data-theme="halloween"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  border-color: #ffb067;
}

[data-theme="halloween"] .composer {
  border: 1px solid rgba(246, 140, 54, 0.55);
}

[data-theme="halloween"] .day-chip {
  background: #2a1838;
  color: #f68c36;
  border: 1px solid rgba(246, 140, 54, 0.5);
}

/* ════════════ Autumn — a wool plaid ════════════ */

[data-theme="autumn"] {
  --row-radius: 10px;
  --bubble-radius: 14px;
  --bubble-tail: 14px;
  --plaid:
    repeating-linear-gradient(0deg, rgba(186, 79, 31, 0.13) 0 18px, transparent 18px 36px, rgba(110, 60, 20, 0.12) 36px 42px, transparent 42px 72px),
    repeating-linear-gradient(90deg, rgba(186, 79, 31, 0.13) 0 18px, transparent 18px 36px, rgba(110, 60, 20, 0.12) 36px 42px, transparent 42px 72px),
    repeating-linear-gradient(0deg, rgba(224, 162, 51, 0.16) 0 2px, transparent 2px 72px);
}

[data-theme="autumn"] .sidebar {
  background-image: var(--plaid);
}

[data-theme="autumn"] .chat-header {
  background-color: #fbf3e6;
  background-image: var(--plaid);
  border-bottom: 3px solid #ba4f1f;
}

[data-theme="autumn"] :is(.brand-name, #chat-title, .chat-item-name) {
  font-family: Georgia, "Noto Serif", serif;
  font-weight: 700;
  letter-spacing: 0;
}

[data-theme="autumn"] .chat-item.is-active,
[data-theme="autumn"] .chat-item.is-active:hover {
  background: #fff8ec;
  outline: 2px dashed rgba(186, 79, 31, 0.55);
  outline-offset: -5px;
}

[data-theme="autumn"] .chat-item.is-active::before {
  display: none;
}

/* knitted edges: a stitched seam inside every message */
[data-theme="autumn"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  outline: 2px dashed rgba(186, 79, 31, 0.45);
  outline-offset: -5px;
  padding: 10px 15px 11px;
  box-shadow: 0 3px 0 rgba(110, 60, 20, 0.18);
}

[data-theme="autumn"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  outline-color: rgba(255, 236, 210, 0.7);
}

[data-theme="autumn"] :is(.composer, .search, .game-invite) {
  outline: 2px dashed rgba(186, 79, 31, 0.4);
  outline-offset: -5px;
  border: 0;
}

[data-theme="autumn"] .day-chip {
  background: #ba4f1f;
  color: #fff3e2;
  border: 0;
  outline: 1.5px dashed rgba(255, 236, 210, 0.75);
  outline-offset: -4px;
  padding: 6px 14px;
}

/* ════════════ Winter — ice and snow caps ════════════ */

[data-theme="winter"] {
  --row-radius: 14px;
  --bubble-radius: 16px;
  --bubble-tail: 16px;
  --snowcap: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='16' viewBox='0 0 200 16' preserveAspectRatio='none'%3E%3Cpath d='M0 9C8 2 22 1 34 4s20 1 30-1 22 1 30 4 18 3 28 0 22-4 34-1 18 4 26 2 14-2 18-1v6c-4 2-6 4-8 4s-3-3-6-3-4 5-7 5-3-4-7-4-14 2-24 2-4 3-7 3-4-3-8-3-18 1-28 0-6 4-9 4-4-4-8-4-16 2-26 1S8 14 0 13Z' fill='%23ffffff'/%3E%3C/svg%3E");
}

[data-theme="winter"] .sidebar {
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.8) 0 1px, transparent 1.5px),
    linear-gradient(180deg, #f6fbff 0%, #e2effa 100%);
  background-size: 37px 41px, 53px 47px, 100% 100%;
  border-right: 1px solid #ffffff;
  box-shadow: inset -1px 0 0 #bcd7ee;
}

[data-theme="winter"] .chat-header {
  background: linear-gradient(180deg, #f6fbff, #e6f1fb);
}

[data-theme="winter"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 14px rgba(20, 70, 120, 0.28), inset 0 0 12px rgba(190, 225, 250, 0.6);
  overflow: visible;
  margin-top: 6px;
}

[data-theme="winter"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  background: linear-gradient(180deg, #4b9bd8 0%, #196ea9 100%);
  box-shadow: 0 4px 14px rgba(20, 70, 120, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

/* snow lying on top of every message, the field and the open chat */
[data-theme="winter"] .msg-row .bubble:not(.has-circle):not(.has-sticker)::after,
[data-theme="winter"] .composer::after,
[data-theme="winter"] .chat-item.is-active::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: -11px;
  height: 18px;
  background: var(--snowcap) 0 0 / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 1.5px rgba(30, 80, 130, 0.5));
  pointer-events: none;
}

[data-theme="winter"] .composer {
  position: relative;
  overflow: visible;
  border: 1px solid #ffffff;
  box-shadow: 0 6px 18px rgba(20, 70, 120, 0.3), inset 0 0 14px rgba(190, 225, 250, 0.7);
}

[data-theme="winter"] .chat-item.is-active,
[data-theme="winter"] .chat-item.is-active:hover {
  background: linear-gradient(180deg, #ffffff, #dbecf9);
  box-shadow: 0 3px 10px rgba(20, 70, 120, 0.18);
  margin-top: 6px;
}

[data-theme="winter"] .day-chip {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #ffffff;
  box-shadow: inset 0 0 8px rgba(190, 225, 250, 0.8);
  border-radius: 999px;
}

/* ════════════ Sakura — washi paper and a red seal ════════════ */

[data-theme="sakura"] {
  --row-radius: 2px;
  --bubble-radius: 2px;
  --bubble-tail: 2px;
  --mincho: Georgia, "Noto Serif", "Times New Roman", serif;
  --seal-font: "Yu Mincho", "MS Mincho", "Noto Serif CJK JP", "Noto Sans CJK JP", serif;
}

[data-theme="sakura"] .sidebar,
[data-theme="sakura"] .chat-header {
  background-color: #fcf7f0;
  background-image:
    repeating-linear-gradient(97deg, rgba(160, 120, 100, 0.05) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(13deg, rgba(160, 120, 100, 0.04) 0 1px, transparent 1px 17px);
}

[data-theme="sakura"] :is(.brand-name, #chat-title, .chat-item-name) {
  font-family: var(--mincho);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* an ink brush stroke under the header */
[data-theme="sakura"] .chat-header {
  position: relative;
  border-bottom: 0;
}

[data-theme="sakura"] .chat-header::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -4px;
  height: 8px;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='8' viewBox='0 0 400 8' preserveAspectRatio='none'%3E%3Cpath d='M0 5c40-3 90-4 150-3s120 3 170 1 60-2 80 0v2c-30 1-60 3-110 2S180 6 120 6 30 7 0 7Z' fill='%23231a1a' fill-opacity='.85'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}

/* the open chat carries a red seal */
[data-theme="sakura"] .chat-item.is-active,
[data-theme="sakura"] .chat-item.is-active:hover {
  background: #fff;
  padding-left: 30px;
  box-shadow: 0 1px 0 rgba(35, 26, 26, 0.12);
}

[data-theme="sakura"] .chat-item.is-active::before {
  content: "\685C";
  left: 6px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 0;
  border-radius: 2px;
  background: #c0392b;
  color: #fff;
  font: 600 12px/18px var(--seal-font);
  text-align: center;
  transform: rotate(-6deg);
}

[data-theme="sakura"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 1px solid rgba(35, 26, 26, 0.35);
  box-shadow: 2px 3px 0 rgba(185, 67, 119, 0.15);
  overflow: visible;
}

/* one petal fallen on the corner of each message */
[data-theme="sakura"] .msg-row .bubble:not(.has-circle):not(.has-sticker)::after {
  content: "";
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 19C4 16 3 7 7 3l3 2 3-2c4 4 3 13-3 16Z' fill='%23f39cbf'/%3E%3C/svg%3E") no-repeat;
  transform: rotate(25deg);
}

[data-theme="sakura"] .day-chip {
  background: #fcf7f0;
  color: #c0392b;
  border: 1.5px solid #c0392b;
  border-radius: 2px;
  font-family: var(--mincho);
}

[data-theme="sakura"] .composer,
[data-theme="sakura"] .search {
  border-radius: 2px;
  border: 1px solid rgba(35, 26, 26, 0.35);
}

/* ════════════ Summer — a picnic ════════════ */

[data-theme="summer"] {
  --row-radius: 16px;
  --bubble-radius: 20px;
  --bubble-tail: 6px;
}

[data-theme="summer"] .sidebar {
  background-image:
    linear-gradient(90deg, rgba(44, 130, 64, 0.1) 50%, transparent 50%),
    linear-gradient(rgba(44, 130, 64, 0.1) 50%, transparent 50%);
  background-size: 28px 28px;
}

/* the edge of a scalloped picnic cloth under the header */
[data-theme="summer"] .chat-header {
  position: relative;
  background: #fafdf9;
  border-bottom: 0;
}

[data-theme="summer"] .chat-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -12px;
  height: 12px;
  pointer-events: none;
  background: radial-gradient(circle at 12px 0, #fafdf9 11.5px, transparent 12px) 0 0 / 24px 12px repeat-x;
  filter: drop-shadow(0 2px 0 rgba(44, 130, 64, 0.35));
}

[data-theme="summer"] :is(.brand-name, #chat-title, .chat-item-name) {
  font-weight: 700;
}

[data-theme="summer"] .chat-item.is-active,
[data-theme="summer"] .chat-item.is-active:hover {
  background: #ffffff;
  box-shadow: 0 0 0 2px #2c8240, 0 4px 0 2px rgba(44, 130, 64, 0.25);
}

[data-theme="summer"] .chat-item.is-active::before {
  display: none;
}

[data-theme="summer"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  border: 3px solid #ffffff;
  box-shadow: 0 5px 0 rgba(30, 80, 40, 0.18), 0 8px 18px rgba(30, 80, 40, 0.18);
}

[data-theme="summer"] .composer {
  border-radius: 999px;
  border: 3px solid #fff;
}

[data-theme="summer"] .day-chip {
  background: #e8a11c;
  color: #2a1a00;
  border: 3px solid #fff;
  border-radius: 999px;
  font-weight: 600;
}

/* ════════════ Space — a starship HUD ════════════ */

[data-theme="space"] {
  --font-mono: Consolas, "Cascadia Mono", "Roboto Mono", "Courier New", monospace;
  --row-radius: 0px;
  --bubble-radius: 0px;
  --bubble-tail: 0px;
  --cut: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  --hud: #65cdf3;
}

[data-theme="space"] :is(.brand-name, #chat-title, .chat-item-name, .chat-item-time, .day-chip, .msg-meta, .unread-badge, .profile-username) {
  font-family: var(--font-mono);
}

[data-theme="space"] :is(.brand-name, #chat-title, .chat-item-name, .day-chip) {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

[data-theme="space"] .chat-item-name {
  font-size: 13.5px;
}

[data-theme="space"] .sidebar {
  background-image: repeating-linear-gradient(180deg, rgba(101, 205, 243, 0.035) 0 1px, transparent 1px 4px);
  border-right: 1px solid rgba(101, 205, 243, 0.4);
}

[data-theme="space"] .chat-header {
  border-bottom: 1px solid rgba(101, 205, 243, 0.5);
  background-image: repeating-linear-gradient(90deg, rgba(101, 205, 243, 0.5) 0 1px, transparent 1px 12px);
  background-size: 100% 5px;
  background-position: 0 100%;
  background-repeat: no-repeat;
}

[data-theme="space"] :is(.search, .game-invite, .composer, .send-btn, .icon-btn-accent, .logo) {
  border-radius: 0;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

[data-theme="space"] :is(.search, .game-invite, .composer) {
  border: 1px solid rgba(101, 205, 243, 0.55);
  background-color: rgba(10, 20, 40, 0.8);
}

/* corner brackets: the open chat and every message are locked targets */
[data-theme="space"] .chat-item.is-active,
[data-theme="space"] .chat-item.is-active:hover,
[data-theme="space"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  background-image:
    linear-gradient(var(--hud), var(--hud)), linear-gradient(var(--hud), var(--hud)),
    linear-gradient(var(--hud), var(--hud)), linear-gradient(var(--hud), var(--hud)),
    linear-gradient(var(--hud), var(--hud)), linear-gradient(var(--hud), var(--hud)),
    linear-gradient(var(--hud), var(--hud)), linear-gradient(var(--hud), var(--hud));
  background-size: 10px 1.5px, 1.5px 10px, 10px 1.5px, 1.5px 10px, 10px 1.5px, 1.5px 10px, 10px 1.5px, 1.5px 10px;
  background-position: 0 0, 0 0, 100% 0, 100% 0, 0 100%, 0 100%, 100% 100%, 100% 100%;
  background-repeat: no-repeat;
}

[data-theme="space"] .chat-item.is-active,
[data-theme="space"] .chat-item.is-active:hover {
  background-color: rgba(101, 205, 243, 0.1);
}

[data-theme="space"] .chat-item.is-active::before {
  display: none;
}

[data-theme="space"] .avatar {
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  border-radius: 0 !important;
}

[data-theme="space"] .msg-row .bubble:not(.has-circle):not(.has-sticker) {
  clip-path: var(--cut);
  background-color: rgba(14, 26, 48, 0.92);
  border: 1px solid rgba(101, 205, 243, 0.35);
  box-shadow: none;
}

[data-theme="space"] .msg-row.out .bubble:not(.has-circle):not(.has-sticker) {
  background-color: rgba(101, 205, 243, 0.9);
  --hud: #062033;
}

[data-theme="space"] .day-chip {
  background: rgba(10, 20, 40, 0.9);
  color: var(--hud);
  border: 1px solid rgba(101, 205, 243, 0.55);
  border-radius: 0;
}

[data-theme="space"] .day-chip::before {
  content: "// ";
}

/* ════════════ Moving details obey the switch and the system setting ════════════ */

:root[data-scene-motion="off"] .brand-name::after {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  [data-theme="black"] .brand-name::after,
  [data-theme="lagoon"] .chat-body::after {
    animation: none;
  }
}

[data-theme="graphite"] .chat-header .chat-head-text * {
  color: #ffffff !important;
}
