:root {
  color-scheme: light;
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", "EmojiSymbols", sans-serif;
  --bg: #e7eef5;
  --surface: #ffffff;
  --surface-muted: #f4f7fa;
  --chat-bg: #f7fbff;
  --text: #17212b;
  --muted: #707f8f;
  --border: #dce5ee;
  --primary: #2aabee;
  --primary-strong: #168acd;
  --primary-soft: #e6f5ff;
  --incoming: #ffffff;
  --outgoing: #dff5d2;
  --outgoing-text: #17212b;
  --focus: 0 0 0 3px rgba(42, 171, 238, 0.24);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1720;
  --surface: #17212b;
  --surface-muted: #202b36;
  --chat-bg: #0f1b25;
  --text: #ecf3f8;
  --muted: #93a4b5;
  --border: #283747;
  --primary: #2aabee;
  --primary-strong: #5ec5ff;
  --primary-soft: #17364a;
  --incoming: #1d2a36;
  --outgoing: #234b38;
  --outgoing-text: #eef8f1;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: var(--primary-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 40;
  transform: translateY(-80px);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-body {
  min-height: 100%;
  overflow: auto;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--chat-bg) 82%, white) 0%, var(--bg) 100%);
}

.auth-panel {
  display: grid;
  gap: 18px;
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 32, 0.16);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
}

.auth-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
}

.auth-header {
  display: grid;
  gap: 6px;
}

.auth-header h1 {
  font-size: 24px;
  line-height: 1.15;
}

.auth-header p,
.auth-switch {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: 0;
  background: var(--surface-muted);
  color: var(--text);
}

.auth-field input:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.auth-alert,
.field-error {
  color: #c92f2f;
}

.auth-alert {
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, #d84d4d 12%, var(--surface));
  font-size: 13px;
  font-weight: 600;
}

.field-error {
  font-size: 12px;
  line-height: 1.35;
}

.auth-submit {
  width: 100%;
}

.auth-switch {
  text-align: center;
}

.step-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 2px 0 4px;
}

.step-dot {
  width: 28px;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  transition: width 220ms ease, background 220ms ease;
}

.step-dot.active {
  width: 42px;
  background: var(--primary);
}

.auth-step {
  display: grid;
  gap: 12px;
  animation: authStepIn 260ms ease both;
}

.auth-step[hidden] {
  display: none;
}

.step-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 14px;
  background: var(--surface-muted);
}

.step-heading div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.step-heading small {
  color: var(--muted);
  font-size: 13px;
}

.step-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.step-actions .primary-action:only-child,
.step-actions .secondary-action[hidden] + .primary-action {
  grid-column: 1 / -1;
}

.step-actions button[hidden] {
  display: none;
}

@keyframes authStepIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--surface);
}

.chat-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.list-header,
.conversation-header,
.chat-row,
.header-actions,
.composer {
  display: flex;
  align-items: center;
}

.list-header {
  gap: 8px;
  min-height: 56px;
  padding: 6px 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition: background 160ms ease, color 160ms ease;
}

.icon-button:hover {
  background: var(--surface-muted);
  color: var(--primary-strong);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin: 0 12px 10px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
}

.search-box input,
.composer-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.folder-tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.folder-tabs::-webkit-scrollbar {
  display: none;
}

.folder-tabs button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease;
}

.folder-tabs button.active,
.folder-tabs button:hover {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.chat-section {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.toast-stack {
  display: grid;
  gap: 6px;
  padding: 0 12px 10px;
}

.toast-message {
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.toast-message.success {
  background: color-mix(in srgb, #31b77a 14%, var(--surface));
  color: #16764a;
}

.toast-message.error {
  background: color-mix(in srgb, #d84d4d 12%, var(--surface));
  color: #c92f2f;
}

.empty-list,
.empty-chat-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-list strong,
.empty-chat-state h2 {
  color: var(--text);
}

.empty-list p,
.empty-chat-state p {
  max-width: 320px;
  font-size: 14px;
  line-height: 1.45;
}

.empty-list .primary-action {
  margin-top: 4px;
  padding: 0 16px;
}

.chat-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 140ms ease;
}

.chat-card:hover,
.chat-card.active {
  background: var(--surface-muted);
}

.chat-copy {
  min-width: 0;
}

.chat-row {
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.chat-row strong,
.preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview,
time,
.conversation-person p,
.compact-file small {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #31b77a;
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #2aabee;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.avatar.channel {
  background: #7a8a9a;
}

.avatar.group {
  background: #6b7cff;
}

.avatar.saved {
  background: #44b584;
}

.conversation {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: var(--chat-bg);
}

.conversation-header {
  justify-content: space-between;
  min-height: 56px;
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.conversation-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.conversation-person .avatar {
  width: 40px;
  height: 40px;
}

.header-actions {
  gap: 2px;
}

.mobile-only {
  display: none;
}

.message-stream {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding: 18px clamp(12px, 3vw, 40px);
}

.message-stream.empty-chat {
  display: grid;
  place-items: center;
}

.empty-chat-state.compact {
  justify-self: center;
  align-self: center;
  padding: 18px;
}

.message-stream[hidden],
.composer[hidden] {
  display: none;
}

.channel-wall {
  min-height: 0;
  overflow-y: auto;
  padding: 18px clamp(12px, 4vw, 48px);
}

.channel-wall[hidden] {
  display: none;
}

.channel-wall-inner {
  display: grid;
  gap: 12px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.channel-wall-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 6px;
}

.channel-wall-hero .avatar {
  width: 56px;
  height: 56px;
}

.channel-wall-hero h2 {
  font-size: 20px;
}

.channel-wall-hero p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.channel-compose,
.channel-post {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(10, 30, 50, 0.04);
}

.channel-compose {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
}

.channel-compose:hover {
  background: var(--surface-muted);
}

.channel-compose span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.channel-compose small {
  color: var(--muted);
  font-size: 13px;
}

.channel-post {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.channel-post header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-post header .avatar {
  width: 40px;
  height: 40px;
}

.channel-post header div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.channel-post p {
  max-width: 68ch;
  line-height: 1.5;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.post-actions span,
.post-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
}

.post-actions button:hover {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.date-chip {
  align-self: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.message {
  display: flex;
  max-width: min(680px, 76%);
}

.message.incoming {
  align-self: flex-start;
}

.message.outgoing {
  align-self: flex-end;
}

.bubble {
  display: grid;
  gap: 5px;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--incoming);
  color: var(--text);
  box-shadow: 0 1px 1px rgba(10, 30, 50, 0.06);
}

.outgoing .bubble {
  background: var(--outgoing);
  color: var(--outgoing-text);
}

.bubble p {
  line-height: 1.45;
}

.bubble time {
  justify-self: end;
}

.read-state {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 4px;
  color: color-mix(in srgb, var(--outgoing-text) 62%, transparent);
  font-size: 12px;
  font-weight: 500;
}

.compact-file {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.compact-file > i {
  color: var(--primary);
}

.compact-file span {
  display: grid;
  min-width: 0;
}

.compact-file strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0 0 8px;
}

.typing-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--primary);
  animation: typing 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 120ms;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 240ms;
}

.composer {
  position: relative;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.composer-input-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}

.composer-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}

.composer-input {
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-muted);
}

.emoji-button:hover,
.emoji-button.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.emoji-picker {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(6, 40px);
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 16px 42px rgba(15, 23, 32, 0.18);
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-option {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: transparent;
  font-family: var(--font-emoji);
  font-size: 23px;
  line-height: 1;
}

.emoji-option:hover,
.emoji-option:focus-visible {
  background: var(--surface-muted);
}

.composer-input input,
.bubble p {
  font-family: var(--font-sans), var(--font-emoji);
}

.send-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  transition: background 160ms ease;
}

.send-button:hover {
  background: var(--primary-strong);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 32, 0.46);
}

.modal-backdrop[hidden] {
  display: none;
}

.settings-modal,
.chat-actions-modal,
.channel-modal,
.channel-settings-modal {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  max-height: min(680px, calc(100dvh - 40px));
  overflow-y: auto;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(15, 23, 32, 0.24);
}

.chat-actions-modal {
  width: min(390px, 100%);
}

.channel-modal {
  width: min(460px, 100%);
}

.channel-settings-modal {
  width: min(460px, 100%);
}

.settings-header,
.settings-profile,
.settings-row,
.settings-search,
.chat-actions-header,
.danger-action,
.channel-header,
.channel-settings-header,
.channel-type,
.member-row,
.invite-card,
.channel-footer,
.prefixed-input {
  display: flex;
  align-items: center;
}

.settings-header,
.chat-actions-header,
.channel-header,
.channel-settings-header {
  justify-content: space-between;
  gap: 12px;
}

.channel-settings-section {
  display: grid;
  gap: 4px;
}

.channel-header > div {
  min-width: 0;
  flex: 1;
}

.channel-header p,
.helper-text {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.channel-step {
  display: grid;
  gap: 12px;
}

.channel-step[hidden] {
  display: none;
}

.channel-avatar-editor {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.channel-avatar {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.channel-type {
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.channel-type:hover {
  background: var(--surface-muted);
}

.channel-type.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.channel-type > span:nth-child(2),
.invite-card span,
.member-row > span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.channel-type small,
.invite-card small,
.member-row small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.prefixed-input {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  overflow: hidden;
}

.prefixed-input span {
  padding-left: 12px;
  color: var(--muted);
  font-weight: 600;
}

.prefixed-input input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  padding: 0 12px 0 2px;
  background: transparent;
  color: var(--text);
}

.invite-card {
  gap: 12px;
  min-height: 66px;
  padding: 10px;
  border-radius: 14px;
  background: var(--surface-muted);
}

.invite-card > i {
  color: var(--primary-strong);
}

.channel-member-search {
  margin: 0;
}

.member-row {
  gap: 12px;
  min-height: 62px;
  padding: 8px 10px;
  border-radius: 14px;
}

.member-row:hover {
  background: var(--surface-muted);
}

.member-row input {
  accent-color: var(--primary);
}

.member-row .avatar {
  width: 42px;
  height: 42px;
}

.channel-footer {
  justify-content: flex-end;
  gap: 8px;
}

.channel-footer .secondary-action,
.channel-footer .primary-action {
  min-width: 108px;
}

.chat-actions-header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.danger-panel {
  display: grid;
  gap: 4px;
}

.danger-action {
  gap: 12px;
  width: 100%;
  min-height: 66px;
  padding: 9px 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 160ms ease;
}

.danger-action:hover {
  background: var(--surface-muted);
}

.danger-action > span:nth-child(2) {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.danger-action strong {
  color: #d84d4d;
}

.danger-action small {
  color: var(--muted);
  font-size: 13px;
}

.danger-action.strong strong {
  color: #c92f2f;
}

.danger-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: color-mix(in srgb, #d84d4d 14%, var(--surface));
  color: #d84d4d;
}

.danger-icon.warning {
  background: color-mix(in srgb, #f2a20c 16%, var(--surface));
  color: #b27600;
}

.secondary-action {
  min-height: 44px;
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
}

.secondary-action:hover {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.settings-profile {
  min-width: 0;
  gap: 12px;
}

.settings-profile .avatar {
  width: 52px;
  height: 52px;
}

.settings-profile p,
.settings-row small {
  color: var(--muted);
  font-size: 13px;
}

.settings-search {
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
}

.settings-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.settings-list {
  display: grid;
  gap: 4px;
}

.settings-row-form {
  margin: 0;
}

.settings-list[hidden],
.settings-search[hidden],
.settings-profile[hidden],
.settings-page[hidden] {
  display: none;
}

.settings-row {
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 8px 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 160ms ease;
}

.settings-row:hover {
  background: var(--surface-muted);
}

.settings-row > span:nth-child(2) {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.settings-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.settings-row.danger {
  color: #d84d4d;
}

.settings-row.danger .settings-icon {
  background: color-mix(in srgb, #d84d4d 14%, var(--surface));
  color: #d84d4d;
}

.settings-row.compact {
  min-height: 54px;
  padding: 8px;
}

.settings-page {
  display: grid;
  gap: 12px;
}

.settings-page-header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.settings-page-header h2 {
  font-size: 18px;
}

.settings-back {
  margin-left: -8px;
}

.profile-editor {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}

.profile-avatar {
  width: 76px;
  height: 76px;
  font-size: 22px;
}

.text-action {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--primary-strong);
  font-weight: 600;
}

.text-action:hover {
  background: var(--primary-soft);
}

.field,
.range-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
}

.primary-action {
  min-height: 44px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.primary-action:hover {
  background: var(--primary-strong);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 8px 10px;
  border-radius: 12px;
  background: transparent;
}

.switch-row:hover {
  background: var(--surface-muted);
}

.switch-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.switch-row small {
  color: var(--muted);
  font-size: 13px;
}

.switch-row input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--border);
  transition: background 160ms ease;
}

.switch-row input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 32, 0.22);
  transition: transform 160ms ease;
}

.switch-row input:checked {
  background: var(--primary);
}

.switch-row input:checked::after {
  transform: translateX(18px);
}

.theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
  border: 1px solid transparent;
}

.theme-option.active {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.theme-option span {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid currentColor;
}

.range-field input {
  accent-color: var(--primary);
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.wallpaper {
  min-height: 54px;
  border-radius: 14px;
  background: var(--wallpaper);
  border: 2px solid var(--border);
}

.wallpaper.active {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

@keyframes typing {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .chat-list {
    position: fixed;
    inset: 0;
    z-index: 20;
    transform: translateX(-100%);
    width: min(390px, 100vw);
    transition: transform 220ms ease;
  }

  .chat-list.open {
    transform: translateX(0);
  }

  .conversation {
    height: 100dvh;
  }

  .mobile-only {
    display: grid;
  }

  .conversation-person .avatar {
    display: none;
  }

  .message-stream {
    padding: 14px 10px;
  }

  .message {
    max-width: 90%;
  }

  .header-actions .icon-button:first-child {
    display: none;
  }
}

@media (max-width: 520px) {
  .message {
    max-width: 96%;
  }

  .composer-actions .icon-button:first-child {
    display: none;
  }

  .emoji-picker {
    left: 0;
    right: auto;
    width: min(308px, calc(100vw - 20px));
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .emoji-option {
    width: 100%;
  }

  h2 {
    font-size: 15px;
  }

  .modal-backdrop {
    place-items: center;
    padding: 10px;
  }

  .settings-modal,
  .chat-actions-modal,
  .channel-modal,
  .channel-settings-modal {
    width: 100%;
    max-height: min(680px, calc(100dvh - 20px));
    border-radius: 18px;
  }

  .channel-footer {
    grid-template-columns: 1fr 1fr;
  }

  .channel-footer .secondary-action,
  .channel-footer .primary-action {
    flex: 1;
    min-width: 0;
  }
}
