:root {
  color-scheme: dark;
  --bg: #313338;
  --surface: #2b2d31;
  --surface-raised: #383a40;
  --surface-soft: #404249;
  --border: #1e1f22;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #23a55a;
  --private: #eb459e;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-raised: #f6f7fb;
  --surface-soft: #e7eaf2;
  --border: #d7dce8;
  --text: #1e1f22;
  --muted: #667085;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #1a9c58;
  --private: #c73682;
  --shadow: 0 16px 45px rgba(31, 41, 55, 0.12);
}

body {
  background: var(--bg);
  color: var(--text);
}

.chat-app {
  background:
    radial-gradient(circle at top left, rgba(88, 101, 242, 0.22), transparent 28rem),
    linear-gradient(180deg, var(--bg), var(--bg));
  color: var(--text);
}

.chat-shell {
  max-width: 1440px;
  margin-inline: auto;
}

.chat-header,
.chat-toolbar,
.composer {
  border-color: var(--border);
}

.chat-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
}

.chat-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-toolbar,
.composer {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.composer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.chat-scroll {
  background: var(--surface-raised);
  scrollbar-width: thin;
  scrollbar-color: var(--surface-soft) var(--surface-raised);
}

.message-bubble {
  overflow-wrap: anywhere;
}

.message-image {
  max-height: 18rem;
  object-fit: contain;
}

.action-button,
.mode-button,
.small-button,
.send-button,
.icon-button {
  border-radius: 6px;
  font-weight: 700;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.action-button,
.mode-button,
.small-button {
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
}

.action-button {
  padding: 0.6rem 0.9rem;
  font-size: 0.875rem;
}

.mode-button,
.small-button {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.mode-button.is-active,
.small-button,
.send-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.action-button:hover,
.mode-button:hover,
.icon-button:hover {
  background: var(--surface-soft);
}

.mode-button.is-active:hover,
.small-button:hover,
.send-button:hover {
  background: var(--accent-hover);
}

.icon-button {
  display: inline-flex;
  width: 2.75rem;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.send-button {
  min-height: 2.75rem;
  padding: 0 1rem;
}

.mode-select,
.message-input,
.popover-input {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text);
}

.mode-select:focus,
.message-input:focus,
.popover-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
}

.composer-bar {
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 0.35rem;
}

.composer-popover {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  left: 0;
  z-index: 10;
  width: min(30rem, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 0.75rem;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.25rem;
}

.emoji-option {
  aspect-ratio: 1;
  border-radius: 6px;
  font-size: 1.25rem;
  line-height: 1;
}

.emoji-option:hover {
  background: var(--surface-soft);
}

.gif-results {
  display: grid;
  max-height: 18rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.gif-option {
  aspect-ratio: 1.35;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
}

.gif-option:hover,
.gif-option:focus {
  border-color: var(--accent);
  outline: none;
}

.gif-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-pill {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
}

button.user-pill {
  width: 100%;
  color: var(--text);
  text-align: left;
}

button.user-pill:hover,
button.user-pill.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-raised));
}

.status-dot {
  background: var(--success);
}

.bubble-own {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.bubble-public {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.bubble-private {
  border-color: color-mix(in srgb, var(--private) 45%, var(--border));
  background: color-mix(in srgb, var(--private) 16%, var(--surface));
  color: var(--text);
}

@media (max-width: 640px) {
  .send-button {
    width: 2.75rem;
    overflow: hidden;
    color: transparent;
  }

  .send-button::before {
    content: '→';
    color: white;
    font-size: 1.2rem;
  }
}
