*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font-ui);
  color: var(--text-primary);
  background: var(--bg-app);
}

button,
input,
textarea {
  font: inherit;
}

/* —— App-themed scrollbars —— */
.chat-list,
.messages,
.modal__list,
.picker__body,
.compose__input,
.picker__strip {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.chat-list::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.modal__list::-webkit-scrollbar,
.picker__body::-webkit-scrollbar,
.compose__input::-webkit-scrollbar,
.picker__strip::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.chat-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track,
.modal__list::-webkit-scrollbar-track,
.picker__body::-webkit-scrollbar-track,
.compose__input::-webkit-scrollbar-track,
.picker__strip::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.modal__list::-webkit-scrollbar-thumb,
.picker__body::-webkit-scrollbar-thumb,
.compose__input::-webkit-scrollbar-thumb,
.picker__strip::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chat-list::-webkit-scrollbar-thumb:hover,
.modal__list::-webkit-scrollbar-thumb:hover,
.picker__body::-webkit-scrollbar-thumb:hover,
.compose__input::-webkit-scrollbar-thumb:hover,
.picker__strip::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

/* Message list floats over the darker chat wallpaper — use a light thumb. */
.messages {
  scrollbar-color: var(--scrollbar-thumb-light) transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb-light);
  background-clip: padding-box;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-light-hover);
  background-clip: padding-box;
}

.app {
  display: flex;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-sidebar);
  box-shadow: var(--shadow-soft);
}

.app[hidden],
.landing[hidden],
.modal[hidden] {
  display: none !important;
}

/* —— Landing —— */
.landing {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 0%, #d7e6f5 0%, transparent 50%),
    var(--bg-app);
}

.landing__card {
  width: min(420px, 100%);
  background: var(--bg-sidebar);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.landing__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.landing__logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 4px 12px rgba(51, 144, 236, 0.35);
  flex-shrink: 0;
}

.landing__title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.landing__sub {
  margin: 0 0 22px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.landing__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.landing__hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-link);
  word-break: break-all;
}

.field__hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Author .field { display:flex } would otherwise override the HTML hidden attribute */
[hidden] {
  display: none !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

.field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__input-wrap {
  position: relative;
  display: flex;
}

.field__input-wrap input {
  flex: 1;
  min-width: 0;
  padding-right: 40px;
}

.field__eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.field__eye:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.field__eye svg {
  width: 20px;
  height: 20px;
  display: block;
}

.field--compact span {
  font-size: 12px;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-primary);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
  padding: 10px 12px;
  transition: filter 0.15s, box-shadow 0.15s;
}

.btn--primary:hover {
  background: var(--accent);
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(51, 144, 236, 0.3);
}

.btn--primary:active {
  filter: brightness(0.97);
  box-shadow: none;
}

.btn--small {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.btn--tiny {
  border-color: transparent;
  background: transparent;
  font-size: 11px;
  padding: 2px 6px;
  color: var(--text-secondary);
}

.btn--tiny:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.btn--danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  font-size: 12px;
  padding: 2px 6px;
}

.sidebar__status {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.sidebar__invite {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.invite-row {
  display: flex;
  gap: 6px;
}

.invite-row input {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sidebar__actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.chat-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-header__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.chat-header__menu-wrap {
  position: relative;
}

.chat-header__menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 184px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bubble {
  position: relative;
}

.bubble__delete {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}

.bubble:hover .bubble__delete {
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal__panel {
  margin: 0;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.modal__title {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.modal__list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 6px 4px;
  cursor: pointer;
}

/* —— Sidebar —— */
.sidebar {
  position: relative;
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.sidebar__top {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-height);
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar__badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: 6px;
}

.sidebar__title {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: default;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: inherit;
  text-align: left;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__title.is-editable {
  cursor: pointer;
}

.sidebar__title.is-editable:hover {
  color: var(--accent);
}

.sidebar__hint {
  margin: 0 12px 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* —— Sidebar top bar / hamburger —— */
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn:active {
  background: var(--bg-active);
}

.icon-btn.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar__titlewrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* —— Hamburger dropdown —— */
.sidebar__menu {
  position: absolute;
  top: calc(var(--header-height) - 2px);
  left: 8px;
  min-width: 224px;
  max-width: min(300px, calc(100vw - 24px));
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-item {
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-primary);
}

.menu-item:hover {
  background: var(--bg-hover);
}

.menu-item:active {
  background: var(--bg-active);
}

.menu-item:disabled {
  opacity: 0.45;
  cursor: default;
  background: transparent;
}

.menu-item--danger {
  color: var(--danger);
}

.sidebar__menu .sidebar__invite {
  padding: 8px 10px;
  border: 0;
}

/* —— Sidebar search —— */
.sidebar__search {
  position: relative;
  padding: 8px 12px;
}

.sidebar__search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.sidebar__search input {
  width: 100%;
  border: 0;
  background: var(--bg-hover);
  border-radius: 18px;
  padding: 8px 12px 8px 34px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}

.sidebar__search input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* —— Resize handle —— */
.sidebar__resize {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -3px;
  width: 6px;
  cursor: col-resize;
  z-index: 6;
}

.sidebar__resize::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: transparent;
  transition: background 0.12s;
}

.sidebar__resize:hover::after {
  background: var(--accent);
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.chat-list__empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.chat-list li {
  position: relative;
}

.chat-list__item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.chat-list__item:hover {
  background: var(--bg-hover);
}

.chat-list__item:active {
  background: var(--bg-active);
}

.chat-list__item.is-active {
  background: var(--bg-active);
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 17px;
  color: var(--text-on-accent);
  background: var(--accent);
  user-select: none;
}

.avatar--g0 { background: var(--name-0); }
.avatar--g1 { background: var(--name-1); }
.avatar--g2 { background: var(--name-2); }
.avatar--g3 { background: var(--name-3); }
.avatar--g4 { background: var(--name-4); }

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

.chat-list__row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-list__name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list__nameicons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.chat-list__icon {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
}

.chat-list__icon--pin {
  color: var(--text-secondary);
}

.chat-list__time {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: auto;
}

.chat-list__preview {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.chat-list__kind {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: right;
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--unread);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.chat-list__item.is-pinned {
  background: var(--bg-pinned, rgba(0, 0, 0, 0.03));
}

.chat-list__item.is-pinned:hover {
  background: var(--bg-hover);
}

.chat-list__item.is-active,
.chat-list__item.is-pinned.is-active {
  background: var(--bg-active);
}

.chat-list__item--offline {
  opacity: 0.72;
}

.chat-list__sep {
  list-style: none;
  height: 0;
  margin: 10px 14px 8px;
  border: 0;
  border-top: 1px solid var(--border);
  pointer-events: none;
}

.chat-list__item--public {
  opacity: 0.85;
}

.chat-list__item--public .chat-list__preview {
  display: none;
}

.chat-list__item--offline .chat-list__name {
  color: var(--text-secondary);
}

.chat-list__item.is-muted .chat-list__name,
.chat-list__item.is-muted .chat-list__preview {
  color: var(--text-secondary);
}

.chat-list__item.is-muted .unread-badge {
  background: var(--text-secondary);
  opacity: 0.7;
}

/* —— Main —— */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  position: relative;
}

.main::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(circle at 20% 30%, var(--bg-chat-pattern) 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 60%, var(--bg-chat-pattern) 0 1px, transparent 1.5px);
  background-size: 48px 48px;
}

.main > * {
  position: relative;
  z-index: 1;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}

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

.chat-header__title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.messages-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12% 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.jump-fab {
  position: absolute;
  right: 18px;
  bottom: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--bg-header);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
}

.jump-fab[hidden] {
  display: none !important;
}

.compose-wrap {
  position: relative;
  background: var(--bg-compose);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.reply-bar,
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.reply-bar[hidden],
.edit-bar[hidden] {
  display: none !important;
}

.reply-bar__name {
  font-weight: 600;
  color: var(--accent);
}

.reply-bar__text {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}

.bubble__quote {
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 13px;
}

.bubble__quote-name {
  font-weight: 600;
  color: var(--accent);
}

.bubble__quote-text {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble__edited {
  font-style: italic;
  margin-right: 4px;
}

.checks {
  display: inline-flex;
  margin-left: 2px;
  color: var(--bubble-meta);
}

.bubble--out .checks {
  color: var(--bubble-out-meta);
}

.checks--double {
  color: #4fae4e !important;
}

.spoiler {
  background: #242f3d;
  color: transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.spoiler.is-revealed {
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  user-select: text;
}

.msg-code {
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(0, 0, 0, 0.06);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 0.92em;
}

.msg-link {
  color: var(--text-link);
}

.system-msg {
  align-self: center;
  max-width: 80%;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 10px;
  border-radius: 10px;
  margin: 4px 0;
}

.date-sep {
  align-self: center;
  display: flex;
  justify-content: center;
  margin: 10px 0 8px;
  pointer-events: none;
}

.date-sep__pill {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.28);
  padding: 4px 12px;
  border-radius: 12px;
  backdrop-filter: blur(2px);
}

.message-row {
  display: flex;
  align-items: flex-end;
  max-width: min(520px, 100%);
}

.message-row--out {
  align-self: flex-end;
}

.message-row--in {
  align-self: flex-start;
}

/* extra breathing room only after the last bubble of a run */
.message-row--run-end {
  margin-bottom: 6px;
}

.message-row__avatar {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  margin-right: 7px;
  font-size: 12px;
  align-self: flex-end;
}

.message-row__avatar--spacer {
  background: transparent;
}

.bubble {
  position: relative;
  padding: 8px 10px 4px;
  border-radius: var(--radius-bubble);
  box-shadow: var(--shadow-soft);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* Stacked (non-tail) bubbles keep a smaller radius on the tail side so a run
   reads as one connected column; the tail bubble gets the sharp corner + flare. */
.bubble--in {
  background: var(--bubble-in);
  border-bottom-left-radius: 6px;
}

.bubble--out {
  background: var(--bubble-out);
  border-bottom-right-radius: 6px;
}

.bubble--in.bubble--tail {
  border-bottom-left-radius: 3px;
}

.bubble--out.bubble--tail {
  border-bottom-right-radius: 3px;
}

.bubble--in.bubble--tail::before {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 0;
  width: 11px;
  height: 15px;
  background: var(--bubble-in);
  clip-path: path("M11 0 C 11 8 8 14 0 15 C 5 12 8 9 8 0 Z");
  pointer-events: none;
}

.bubble--out.bubble--tail::before {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 0;
  width: 11px;
  height: 15px;
  background: var(--bubble-out);
  clip-path: path("M0 0 C 0 8 3 14 11 15 C 6 12 3 9 3 0 Z");
  pointer-events: none;
}

.bubble__name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

/* Verified tripcode handle shown next to a person's name. */
.trip-badge {
  margin-left: 5px;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-link);
  letter-spacing: 0.02em;
  white-space: nowrap;
  user-select: none;
}

.bubble__name--c0 { color: var(--name-0); }
.bubble__name--c1 { color: var(--name-1); }
.bubble__name--c2 { color: var(--name-2); }
.bubble__name--c3 { color: var(--name-3); }
.bubble__name--c4 { color: var(--name-4); }

.bubble__text {
  font-size: 14.5px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.bubble__meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--bubble-meta);
}

.bubble--out .bubble__meta {
  color: var(--bubble-out-meta);
}

.compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: var(--compose-min-height);
  padding: 8px 12px;
  background: transparent;
  border-top: 0;
}

.compose__input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-input);
  outline: none;
}

.compose__input:focus {
  border-color: var(--accent);
}

.compose__emoji {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 22px;
  flex-shrink: 0;
}

.compose__emoji:hover,
.compose__emoji.is-active {
  color: var(--accent);
}

.compose__send {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-on-accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.twemoji {
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.2em;
  margin: 0 0.03em;
  object-fit: contain;
}

.picker {
  position: absolute;
  bottom: calc(100% - 4px);
  right: 8px;
  z-index: 40;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
  max-height: 384px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.picker[hidden] {
  display: none !important;
}

.picker__header {
  border-bottom: 1px solid var(--border);
}

.picker__tabs {
  display: flex;
  gap: 2px;
  padding: 4px 8px 0;
}

.picker__tab {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 2px solid transparent;
}

.picker__tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.picker__search-wrap {
  padding: 6px 8px;
}

.picker__search {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  background: var(--bg-hover);
  color: var(--text-primary);
  outline: none;
}

.picker__search:focus {
  border-color: var(--accent);
  background: #fff;
}

.picker__body {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 6px 4px;
  min-height: 200px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.picker__section {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 8px 4px 2px;
}

.picker__empty {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 12px 4px;
}

.picker__emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
}

.picker__emoji {
  border: 0;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
}

.picker__emoji .twemoji {
  width: 26px;
  height: 26px;
  vertical-align: middle;
  margin: 0;
}

.picker__emoji:hover {
  background: var(--bg-hover);
}

.picker__catnav {
  display: flex;
  gap: 0;
  padding: 3px 6px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  align-items: center;
  scrollbar-width: none;
}

.picker__catnav::-webkit-scrollbar {
  display: none;
}

.picker__catnav-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0.55;
  transition: opacity 0.12s ease;
}

.picker__catnav-btn .twemoji {
  width: 20px;
  height: 20px;
  margin: 0;
}

.picker__catnav-btn:hover {
  opacity: 1;
  background: var(--bg-hover);
}

.picker__catnav-btn.is-active {
  opacity: 1;
  background: var(--accent-soft);
}

.picker__pack-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.picker__sticker-grid {
  display: grid;
  /* minmax(0,1fr): allow cells to shrink below intrinsic sticker width */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.picker__sticker {
  border: 0;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  border-radius: 8px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.picker__sticker:hover {
  background: var(--bg-hover);
}

.picker__sticker img {
  user-select: none;
  -webkit-user-drag: none;
}

.sticker-preview {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.sticker-preview__card {
  background: var(--bg-sidebar, #fff);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.sticker-preview__card img {
  display: block;
  width: 240px;
  height: 240px;
  max-width: 70vw;
  max-height: 70vw;
  object-fit: contain;
}

.picker__sticker img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 64px;
  height: auto;
  object-fit: contain;
}

.picker__strip {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  align-items: center;
}

.picker__strip-btn {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--bg-hover);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  font-size: 14px;
}

.picker__strip-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.picker__strip-btn.is-active {
  border-color: var(--accent);
}

.picker__strip-add {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
  font-weight: 600;
}

.bubble--sticker {
  background: transparent !important;
  box-shadow: none !important;
  padding: 2px;
  /* Stickers have no filled bubble — kill the Telegram-style corner tail. */
  border-radius: 0 !important;
}

.bubble--sticker.bubble--tail::before {
  display: none;
}

/* Names sit on the chat wallpaper — bump contrast vs soft bubble colors. */
.bubble--sticker .bubble__name {
  text-shadow:
    0 0 3px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

.bubble--sticker .bubble__name--c0 { color: #ff8b96; }
.bubble--sticker .bubble__name--c1 { color: #7ec4ff; }
.bubble--sticker .bubble__name--c2 { color: #6eefb0; }
.bubble--sticker .bubble__name--c3 { color: #ffc45c; }
.bubble--sticker .bubble__name--c4 { color: #c4a6ff; }

.bubble--sticker .trip-badge {
  color: #d6ebff;
  text-shadow:
    0 0 3px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

/* Meta sits on the wallpaper, so the light bubble-green is unreadable. */
.bubble--sticker .bubble__meta,
.bubble--sticker .checks,
.bubble--sticker .checks--double {
  color: rgba(0, 0, 0, 0.55) !important;
}

.bubble__sticker {
  line-height: 0;
}

.bubble__sticker--clickable {
  cursor: pointer;
}

.sticker-modal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.sticker-modal-cell {
  border: 0;
  background: transparent;
  padding: 6px;
  cursor: pointer;
  border-radius: 10px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.sticker-modal-cell:hover {
  background: var(--bg-hover);
}

.sticker-modal-cell img {
  max-width: 100%;
  max-height: 84px;
  object-fit: contain;
}

.modal__note {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 10px 2px 0;
}

.modal__radios {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.modal__radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.modal__radio input {
  accent-color: var(--accent);
}

.sticker-img {
  max-width: 160px;
  max-height: 160px;
  object-fit: contain;
  display: block;
}

.sticker-fallback {
  font-size: 64px;
  line-height: 1;
}

.compose__attach {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.compose__attach:hover {
  color: var(--accent);
}

.attach-pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.attach-pending__thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.attach-pending__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-pending__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}

.attach-pending__thumb:hover .attach-pending__remove,
.attach-pending__remove:focus-visible {
  opacity: 1;
}

.attach-pending__remove:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Touch devices have no hover: keep the remove control visible. */
@media (hover: none) {
  .attach-pending__remove {
    opacity: 1;
  }
}

.attach-pending__clear {
  margin-left: auto;
  align-self: center;
}

.upload-status {
  margin: 0;
  padding: 4px 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.bubble__photo,
.bubble__album {
  display: grid;
  gap: 2px;
  max-width: 280px;
  border-radius: 10px;
  overflow: hidden;
}

.bubble__album {
  grid-template-columns: repeat(2, 1fr);
}

.bubble__album:has(> :nth-child(3)) {
  grid-template-columns: repeat(3, 1fr);
}

.media-img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  background: rgba(0, 0, 0, 0.06);
}

.bubble__photo .media-img {
  max-height: 320px;
  object-fit: contain;
  background: transparent;
}

.media-placeholder {
  min-height: 80px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  font-size: 20px;
}

.bubble__video {
  max-width: 280px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.media-video {
  width: 100%;
  max-height: 320px;
  display: block;
  background: #000;
}

.bubble__audio {
  max-width: 300px;
  min-width: 240px;
  border-radius: 10px;
}

.media-audio {
  display: none;
}

.audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
}

.audio-player__btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-player__btn:hover {
  filter: brightness(1.05);
}

.audio-player__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audio-player__seek {
  --seek: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--seek),
    rgba(0, 0, 0, 0.16) var(--seek),
    rgba(0, 0, 0, 0.16) 100%
  );
  cursor: pointer;
  outline: none;
}

.audio-player__seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.audio-player__seek::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
}

.audio-player__times {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.audio-download {
  min-height: 100px;
}

.bubble__file {
  max-width: 280px;
  min-width: 200px;
}

.file-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.file-doc:hover {
  background: rgba(0, 0, 0, 0.1);
}

.file-doc--loading {
  cursor: default;
  opacity: 0.75;
}

.file-doc__icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #2c3e50;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.file-doc__icon::before {
  content: "FILE";
}

.file-doc__icon--doc {
  background: #c0392b;
}
.file-doc__icon--doc::before {
  content: "DOC";
}

.file-doc__icon--sheet {
  background: #27ae60;
}
.file-doc__icon--sheet::before {
  content: "XLS";
}

.file-doc__icon--archive {
  background: #8e44ad;
}
.file-doc__icon--archive::before {
  content: "ZIP";
}

.file-doc__icon--text {
  background: #2980b9;
}
.file-doc__icon--text::before {
  content: "TXT";
}

.file-doc__icon--unknown {
  background: #4a5568;
}

.file-doc__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.file-doc__name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-doc__size {
  font-size: 11px;
  opacity: 0.7;
}

.file-download {
  min-height: 100px;
  gap: 8px;
}

.file-download__name {
  font-size: 12px;
  opacity: 0.85;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-download {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 140px;
  min-width: 180px;
  border: 0;
  background: linear-gradient(160deg, #2a2a2a, #111);
  color: #fff;
  cursor: pointer;
  padding: 20px 16px;
  font: inherit;
}

.video-download:hover {
  background: linear-gradient(160deg, #333, #161616);
}

.video-download--thumb {
  background-color: #111;
  background-size: cover;
  background-position: center;
  position: relative;
}

.video-download--thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.video-download--thumb > * {
  position: relative;
  z-index: 1;
}

.video-download--thumb:hover {
  filter: brightness(1.05);
}

.video-download__icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-size: 16px;
  padding-left: 2px;
}

.video-download__label {
  font-size: 14px;
  font-weight: 600;
}

.video-download__size {
  font-size: 12px;
  opacity: 0.75;
}

.attach-pending__thumb--video,
.attach-pending__thumb--audio,
.attach-pending__thumb--file {
  display: grid;
  place-items: center;
  background: #1a1a1a;
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 4px;
  line-height: 1.2;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.88);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  object-fit: contain;
  cursor: default;
}

.lightbox__nav,
.lightbox__close {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.12s ease;
}

.lightbox__nav:hover,
.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
}

.lightbox__nav--prev {
  left: 16px;
}

.lightbox__nav--next {
  right: 16px;
}

.lightbox__nav[hidden] {
  display: none;
}

.lightbox__close {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
}

.lightbox__counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  font-weight: 600;
  cursor: default;
}

.lightbox__counter[hidden] {
  display: none;
}

.compose__send:disabled {
  opacity: 0.45;
  cursor: default;
}

.empty {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--text-on-accent);
  text-align: center;
  padding: 24px;
}

.empty__card {
  background: rgba(0, 0, 0, 0.25);
  padding: 16px 20px;
  border-radius: 12px;
  max-width: 320px;
}

.boot-banner {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 20;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  max-width: 360px;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.boot-banner--ok {
  background: rgba(53, 160, 110, 0.92);
}

.boot-banner--err {
  background: rgba(229, 57, 53, 0.95);
}

.boot-banner__actions {
  display: inline-flex;
  gap: 6px;
}

.boot-banner__btn {
  appearance: none;
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: #1a1a1a;
}

.boot-banner__btn--ghost {
  background: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.bubble__forward {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
  margin-bottom: 4px;
}

.bubble__reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 2px 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.reaction-chip .twemoji {
  width: 15px;
  height: 15px;
  margin: 0;
  vertical-align: middle;
}

.reaction-chip__count {
  font-weight: 600;
}

.reaction-chip.is-mine {
  background: rgba(53, 120, 200, 0.18);
}

.msg-context-menu {
  position: fixed;
  z-index: 1000;
  width: max-content;
  max-width: calc(100vw - 16px);
  background: var(--bg-sidebar, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ctx-reactions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
}

.ctx-reaction-btn {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition:
    transform 0.08s ease,
    background 0.12s ease;
}

.ctx-reaction-btn .twemoji {
  width: 26px;
  height: 26px;
  margin: 0;
  vertical-align: middle;
  display: block;
}

.ctx-reaction-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.18);
}

.ctx-reaction-more {
  font-size: 20px;
  color: var(--text-secondary);
}

.ctx-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 32px);
  justify-content: center;
  gap: 2px;
  width: 296px;
  max-width: calc(100vw - 28px);
  max-height: 232px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.ctx-emoji-grid::-webkit-scrollbar {
  width: 8px;
}

.ctx-emoji-grid::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 8px;
  background-clip: padding-box;
  border: 2px solid transparent;
}

.ctx-emoji-grid::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
  border: 2px solid transparent;
}

.ctx-emoji {
  width: 32px;
  height: 32px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  border-radius: 8px;
}

.ctx-emoji .twemoji {
  width: 24px;
  height: 24px;
  margin: 0;
  vertical-align: middle;
}

.ctx-emoji:hover {
  background: var(--bg-hover);
}

.ctx-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.ctx-actions:first-child {
  border-top: 0;
  padding-top: 0;
}

.ctx-actions .menu-item {
  padding: 6px 12px;
}

@media (max-width: 720px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: none;
    flex: 1;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .main {
    display: none;
    flex: 1;
    min-height: 0;
  }

  .app.app--chat-open .sidebar {
    display: none;
  }

  .app.app--chat-open .main {
    display: flex;
  }

  .chat-header__back {
    display: inline-grid !important;
  }

  .messages {
    padding: 12px 10px 16px;
  }

  .sidebar__resize {
    display: none;
  }
}

@media (min-width: 721px) {
  .chat-header__back {
    display: none !important;
  }

  /* —— Collapsed icon rail —— */
  .app--rail .sidebar {
    width: var(--sidebar-rail-width);
  }

  .app--rail .sidebar__top {
    flex-direction: column;
    height: auto;
    padding: 6px 0;
    gap: 4px;
  }

  .app--rail .sidebar__titlewrap,
  .app--rail .sidebar__search,
  .app--rail .sidebar__status,
  .app--rail .sidebar__hint,
  .app--rail .sidebar__resize {
    display: none !important;
  }

  .app--rail .chat-list__item {
    position: relative;
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 6px 0;
    gap: 0;
  }

  .app--rail .chat-list__main,
  .app--rail .chat-list__kind {
    display: none !important;
  }

  .app--rail .chat-list__right {
    position: absolute;
    top: 2px;
    right: 12px;
    flex-direction: row;
  }
}
