/* Auth */
.auth {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  display: flex;
  padding: 1rem;
  background: var(--color-background);
}

.auth-form {
  width: 100%;
  max-width: 22.5rem;
  margin: auto;
  text-align: center;
}

.auth-logo {
  display: grid;
  place-items: center;
  width: 8.75rem;
  height: 8.75rem;
  margin: 0 auto 1.75rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
}

.auth-logo svg {
  width: 5rem;
  height: 5rem;
}

.auth-form h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 500;
}

.auth-subtitle {
  margin: 0 0 1.75rem;
  font-size: 0.9375rem;
  line-height: 1.3;
  color: var(--color-text-secondary);
}

.input-group {
  position: relative;
  margin-bottom: 1.125rem;
  text-align: left;
}

.input-group input {
  width: 100%;
  height: 3.375rem;
  padding: 0 0.9375rem;
  border: 1px solid var(--color-borders);
  border-radius: 0.75rem;
  outline: 0;
  font: inherit;
  color: var(--color-text);
  background: var(--color-background);
}

.input-group input:focus {
  border: 2px solid var(--color-primary);
  padding: 0 0.875rem;
  outline: 0;
}

.input-group label {
  position: absolute;
  top: 1.0625rem;
  left: 0.75rem;
  padding: 0 0.25rem;
  color: var(--color-text-secondary);
  background: var(--color-background);
  pointer-events: none;
  transform-origin: left center;
  transition: transform 0.15s ease, color 0.15s ease;
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
  transform: scale(0.75) translateY(-2.05rem);
}

.input-group input:focus + label {
  color: var(--color-primary);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin: 0 0 1.25rem 0.75rem;
  text-align: left;
  cursor: pointer;
}

.checkbox input {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--color-primary);
}

.form-error {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--color-error);
}

.button {
  display: block;
  width: 100%;
  height: 3rem;
  margin-bottom: 0.5rem;
  border-radius: 1.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.button.primary {
  background: var(--color-primary);
  color: #fff;
}

.button.primary:disabled {
  opacity: 0.6;
}

.button.text {
  color: var(--color-primary);
}

/* Shell */
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat-flag {
  flex: none;
  width: 1rem;
  height: 1rem;
  color: var(--color-text-secondary);
}

.connection {
  flex: none;
  padding: 0.25rem;
  text-align: center;
  font-size: 0.875rem;
  background: var(--color-background-secondary);
  color: var(--color-text-secondary);
}

.list-heading {
  padding: 0.75rem 0.5rem 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.chat-ticks {
  flex: none;
  padding-right: 0.2em;
  font-size: 0.75rem;
  letter-spacing: -0.2em;
  color: var(--color-online);
}

.chat-item.active .chat-ticks,
.chat-item.active .chat-preview.typing {
  color: #fff;
}

.chat-preview.typing {
  color: var(--color-primary);
}

.danger {
  color: var(--color-error);
}

.context-menu {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  min-width: 10rem;
}

/* The media viewer's ⋮ menu has to sit above the viewer itself. */
.context-menu.over-viewer {
  z-index: 60;
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-default);
  background: rgb(0 0 0 / 85%);
  color: #fff;
  font-size: 0.9375rem;
}

/* Messages */
#conversation {
  position: relative;
}

.service-message {
  align-self: center;
  max-width: 85%;
  margin: 0.25rem 0;
  padding: 0.125rem 0.625rem;
  border-radius: 0.75rem;
  background: rgb(0 0 0 / 30%);
  color: #fff;
  font-size: 0.875rem;
  text-align: center;
}

.bubble {
  font-size: var(--message-text-size, 1rem);
}

.bubble.highlight {
  outline: 2px solid var(--color-primary);
}

.sender-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.forwarded {
  font-size: 0.875rem;
  color: var(--color-primary);
}

.bubble.out .forwarded,
.bubble.out .link {
  color: var(--color-meta-own);
}

.quote {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0.125rem 0 0.25rem;
  padding: 0.125rem 0.5rem;
  border-left: 3px solid var(--color-primary);
  border-radius: 0.25rem;
  background: rgb(0 0 0 / 5%);
  text-align: left;
}

.quote-name,
.quote-text {
  display: block;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-name {
  font-weight: 500;
  color: var(--color-primary);
}

.link {
  color: var(--color-primary);
}

.file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 12rem;
  padding: 0.25rem 0;
  text-align: left;
}

.file-icon {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--color-primary);
}

.file-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.file-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.file-size {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.lightbox {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgb(0 0 0 / 85%);
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
}

.drop-hint {
  position: absolute;
  z-index: 5;
  inset: 4rem 1rem 1rem;
  display: grid;
  place-items: center;
  border: 2px dashed var(--color-primary);
  border-radius: var(--border-radius-default);
  background: var(--color-background);
  color: var(--color-primary);
  font-weight: 500;
}

.gif-frame {
  position: relative;
  overflow: hidden;
  background: var(--color-background-secondary);
}

.bubble-media {
  max-width: 100%;
  min-width: 8rem;
  min-height: 8rem;
  margin: 0.125rem 0 0.25rem;
  border-radius: 0.625rem;
}

.gif-frame[data-full] {
  cursor: zoom-in;
}

.gif-frame[data-video] {
  cursor: pointer;
}

.media-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin: -1.5rem 0 0 -1.5rem;
  border-radius: 50%;
  background: rgb(0 0 0 / 50%);
  color: #fff;
  pointer-events: none;
}

.gif-frame:not(.failed):not(.loaded) .media-play {
  display: none;
}

.media-play svg {
  width: 1.75rem;
  height: 1.75rem;
  fill: currentcolor;
}

.album {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 9rem;
  gap: 0.125rem;
  width: 20rem;
  max-width: 100%;
  margin: 0.125rem 0 0.25rem;
  overflow: hidden;
  border-radius: 0.625rem;
}

.album-3 > :first-child {
  grid-row: span 2;
}

.album:not(.album-3) > .gif-frame:last-child:nth-child(odd):not(:first-child) {
  grid-column: span 2;
}

.spoiler {
  border-radius: 0.25rem;
  background: var(--color-text-secondary) url("assets/images/spoiler-dots.png");
  color: transparent;
  cursor: pointer;
  user-select: none;
}

.spoiler * {
  visibility: hidden;
}

.spoilers-revealed .spoiler {
  background: rgb(127 127 127 / 18%);
  color: inherit;
  cursor: text;
  user-select: auto;
}

.spoilers-revealed .spoiler * {
  visibility: visible;
}

.code-inline,
.code-block {
  font-family: ui-monospace, "Cascadia Code", Menlo, monospace;
  font-size: 0.9em;
  color: var(--color-primary);
}

.code-block {
  margin: 0.25rem 0;
  padding: 0.375rem 0.5rem;
  overflow-x: auto;
  border-radius: 0.375rem;
  background: rgb(127 127 127 / 14%);
  white-space: pre-wrap;
}

.text-quote {
  margin: 0.25rem 0;
  padding: 0.125rem 0.5rem;
  border-left: 3px solid var(--color-primary);
  border-radius: 0.25rem;
  background: rgb(127 127 127 / 12%);
}

.chat-draft {
  color: var(--color-error);
}

.format-bar {
  position: absolute;
  z-index: 3;
  bottom: 100%;
  left: 50%;
  display: flex;
  gap: 0.125rem;
  transform: translateX(-50%);
  padding: 0.125rem;
  border-radius: 0.75rem;
  background: var(--color-background);
  box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}

.attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.25rem;
  max-height: 22rem;
  overflow-y: auto;
}

.attach-item {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 0.5rem;
  background: var(--color-background-secondary);
}

.attach-item.attach-file {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  aspect-ratio: auto;
  padding: 0.5rem 2.25rem 0.5rem 0.5rem;
}

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

.attach-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0.125rem;
  border-radius: 0.375rem;
  background: rgb(0 0 0 / 60%);
  color: #fff;
}

.attach-caption {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-borders);
  border-radius: 0.75rem;
  outline: 0;
  resize: none;
  background: var(--color-background);
  color: var(--color-text);
  font: inherit;
}

.shared-tabs {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  border-bottom: 1px solid var(--color-borders);
  background: var(--color-background);
}

.shared-tab {
  flex: 1;
  padding: 0.75rem 0.25rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.shared-tab.active {
  box-shadow: inset 0 -2px var(--color-primary);
  color: var(--color-primary);
}

.shared-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
}

.shared-tile {
  aspect-ratio: 1;
}

.shared-row {
  padding: 0.5rem 1rem;
}

.shared-link {
  display: block;
  overflow-wrap: anywhere;
}

.shared-meta {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.lightbox video {
  max-width: 100%;
  max-height: 100%;
  cursor: default;
}

.gif-thumbnail,
.gif-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gif-thumbnail {
  filter: blur(8px);
  transform: scale(1.1);
}

.gif-media {
  opacity: 0;
  transition: opacity 150ms ease-in;
}

.gif-frame.loaded .gif-media {
  opacity: 1;
}

.gif-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border: 2px solid rgb(255 255 255 / 85%);
  border-top-color: transparent;
  border-radius: 50%;
  animation: gif-spin 800ms linear infinite;
}

.gif-frame.loaded .gif-spinner,
.gif-frame.failed .gif-spinner {
  display: none;
}

@keyframes gif-spin {
  to {
    transform: rotate(360deg);
  }
}

.gif-badge {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  padding: 0 0.375rem;
  border-radius: 0.5rem;
  background: rgb(0 0 0 / 45%);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.25rem;
  pointer-events: none;
}

.voice {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 17rem;
  max-width: 100%;
  padding: 0.25rem 0;
}

.voice-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
}

.voice-play svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentcolor;
}

.bubble.out .voice-play {
  background: var(--color-meta-own);
}

.voice-body {
  flex: 1;
  min-width: 0;
}

.voice-bars {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1px;
  width: 100%;
  height: 1.5rem;
  padding: 0;
  cursor: pointer;
}

.voice-bar {
  flex: 1;
  min-width: 0;
  border-radius: 1px;
  background: var(--color-text-secondary);
  opacity: 0.45;
}

.voice-bar.played {
  background: var(--color-primary);
  opacity: 1;
}

.bubble.out .voice-bar {
  background: var(--color-meta-own);
}

.voice-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.bubble.out .voice-info {
  color: var(--color-meta-own);
}

.voice-speed {
  padding: 0 0.3125rem;
  border-radius: 0.375rem;
  background: rgb(127 127 127 / 20%);
  color: inherit;
  font-size: 0.75rem;
}

/* Composer */
.recording {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 1rem 1rem;
}

.recording .icon-button {
  flex: none;
  color: var(--color-error);
}

.recording-dot {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--color-error);
  transition: transform 80ms linear;
}

.recording-time {
  font-variant-numeric: tabular-nums;
}

.recording-hint {
  flex: 1;
  color: var(--color-text-secondary);
}

.composer-wrap {
  position: relative;
  flex: none;
  width: 100%;
  max-width: 47rem;
  margin: 0 auto;
}

.compose-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 1rem 0.25rem;
  padding: 0.25rem 0.25rem 0.25rem 0.75rem;
  border-radius: 0.75rem;
  background: var(--color-background);
  color: var(--color-primary);
}

.compose-bar > svg {
  flex: none;
}

.compose-bar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
}

#compose-bar-title {
  font-weight: 500;
}

#compose-bar-body {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-secondary);
}

#composer .composer-button {
  align-self: flex-end;
  width: 2.9375rem;
  height: 2.9375rem;
  padding: 0.71875rem;
  background: var(--color-background);
  box-shadow: 0 1px 2px rgb(0 0 0 / 15%);
}

/* Info column */
.info-actions {
  padding: 0 0.5rem 0.5rem;
}

.detail-row {
  display: block;
  width: 100%;
  margin-bottom: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.75rem;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.detail-row.copyable {
  cursor: pointer;
}

.detail-row.copyable:hover {
  background: var(--color-chat-hover);
}

.detail-label {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.detail-value {
  overflow-wrap: anywhere;
}

#right .details {
  padding-bottom: 0;
}

#right .list-heading {
  padding-left: 1rem;
}

.member {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
}

.member-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border-radius: 0.75rem;
  text-align: left;
}

.member-open:hover {
  background: var(--color-chat-hover);
}

.avatar-small {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1rem;
}

.member-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.member-name,
.member-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-name {
  font-weight: 500;
}

.member-status {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgb(0 0 0 / 40%);
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(26rem, 100%);
  max-height: 100%;
  border-radius: 1.5rem;
  background: var(--color-background);
  overflow: hidden;
}

.modal-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: 0.5rem 1rem;
  overflow-y: auto;
}

.modal-text {
  margin: 0;
  padding: 0.5rem 1.25rem 1rem;
  overflow-wrap: anywhere;
}

.modal-text.centered {
  padding: 0 0 1rem;
  text-align: center;
  color: var(--color-text-secondary);
}

.modal-actions {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 1rem 1rem;
}

.modal-button {
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.modal-button:hover {
  background: var(--color-chat-hover);
}

.modal-button.primary {
  color: var(--color-primary);
}

.modal-button.danger {
  color: var(--color-error);
}

.avatar-edit {
  display: grid;
  margin: 0 auto 0.75rem;
  padding: 0;
  color: #fff;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.chips:empty {
  display: none;
}

.chip {
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  background: var(--color-background-secondary);
  font-size: 0.875rem;
}

.picker-results {
  max-height: 16rem;
  overflow-y: auto;
}

/* Wallpaper */
#middle {
  position: relative;
  overflow: hidden;
  background: var(--color-background);
}

#middle::before {
  content: "";
  position: absolute;
  inset: -24px;
  background: var(--wallpaper, var(--color-chat-backdrop));
  filter: blur(var(--wallpaper-blur, 0));
}

#empty-state,
#conversation {
  position: relative;
  z-index: 1;
}

:root[data-animations="off"] *,
:root[data-animations="off"] *::before,
:root[data-animations="off"] *::after {
  transition: none !important;
  animation: none !important;
}

/* Chat folders */
.folders {
  flex: none;
  display: flex;
  gap: 0.25rem;
  padding: 0 0.75rem 0.25rem;
  border-bottom: 1px solid var(--color-borders);
  overflow-x: auto;
}

.folder-tab {
  flex: none;
  padding: 0.5rem 0.75rem;
  border-bottom: 3px solid transparent;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.folder-tab.active {
  border-bottom-color: var(--color-primary);
  color: var(--color-primary);
}

/* Settings panel */
#left {
  position: relative;
}

.settings {
  position: absolute;
  z-index: 15;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-background);
}

.settings .left-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
}

.settings-page {
  flex: 1;
  min-height: 0;
  padding: 0.25rem 0.75rem 1.5rem;
  overflow-y: auto;
}

.settings-page .avatar-edit,
.settings-page .avatar-large {
  display: grid;
}

.settings-heading {
  margin: 1.25rem 0 0.25rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-primary);
}

.settings-nav {
  display: block;
  width: 100%;
  padding: 0.75rem 0.5rem;
  border-radius: 0.75rem;
  text-align: left;
}

.settings-nav:hover {
  background: var(--color-chat-hover);
}

.settings-nav-text {
  display: flex;
  flex-direction: column;
}

.settings-nav-sub {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.settings-link {
  flex: none;
  padding: 0.5rem;
  border-radius: 0.5rem;
  color: var(--color-primary);
}

.settings-link.danger {
  color: var(--color-error);
}

.settings-page > .settings-link {
  display: block;
  margin: 0 auto 1rem;
}

.settings-note {
  padding: 1rem 0.5rem;
  color: var(--color-text-secondary);
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.625rem 0.5rem;
  border-radius: 0.75rem;
  cursor: pointer;
}

.setting-row:hover {
  background: var(--color-chat-hover);
}

.setting-row input {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--color-primary);
}

.setting-label {
  flex: 1;
  min-width: 0;
}

.setting-select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-borders);
  border-radius: 0.5rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-background);
}

.setting-row input.color-input,
.color-input {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
}

.swatch {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
}

.swatch-default {
  background: linear-gradient(135deg, #3390ec 50%, #8774e1 50%);
}

.swatch.selected {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.wallpaper-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.375rem;
  margin-top: 0.75rem;
}

.wallpaper-tile {
  aspect-ratio: 3 / 4;
  padding: 0;
  border-radius: 0.5rem;
}

.wallpaper-tile.selected {
  outline: 3px solid var(--color-primary);
  outline-offset: 1px;
}

.session-text {
  flex: 1;
  padding: 0.5rem;
}

/* Chat tools */
.chat-search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-borders);
}

#chat-search-input {
  flex: 1;
  min-width: 0;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 1.125rem;
  outline: 0;
  font: inherit;
  color: var(--color-text);
  background: var(--color-background-secondary);
}

#chat-search-count {
  flex: none;
  padding: 0 0.25rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.pinned-bar {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 0.5rem 0 0.75rem;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-borders);
}

.pinned-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: 0.25rem 0;
  padding: 0 0 0 0.625rem;
  border-left: 3px solid var(--color-primary);
  text-align: left;
}

.pinned-marks {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: stretch;
  margin: 0.375rem 0;
}

.pinned-marks:not([hidden]) + .pinned-open {
  border-left: 0;
  padding-left: 0.5rem;
}

.pinned-mark {
  flex: 1;
  width: 3px;
  border-radius: 2px;
  background: var(--color-primary);
  opacity: 0.35;
}

.pinned-mark.active {
  opacity: 1;
}

.pinned-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-primary);
}

.pinned-text {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.to-latest {
  position: absolute;
  z-index: 4;
  right: 1.5rem;
  bottom: 5.5rem;
  display: grid;
  place-items: center;
  width: 2.9375rem;
  height: 2.9375rem;
  border-radius: 50%;
  background: var(--color-background);
  color: var(--color-text-secondary);
  box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}

.mention-badge {
  margin-right: 0.25rem;
}

.mention-list {
  position: absolute;
  z-index: 3;
  right: 1rem;
  bottom: 100%;
  left: 1rem;
  max-height: 16rem;
  overflow-y: auto;
  border-radius: 0.75rem;
  background: var(--color-background);
  box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}

.archive-row {
  width: 100%;
  padding: 0.625rem 1rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  text-align: left;
}

.archive-row:hover {
  background: var(--color-chat-hover);
}

.poll-question {
  padding-top: 0.125rem;
  font-weight: 500;
}

.poll {
  min-width: 15rem;
}

.poll-kind,
.poll-total {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.poll-total {
  text-align: center;
}

.poll-option {
  position: relative;
  display: flex;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0 0.5rem;
  text-align: left;
}

.poll-percent {
  flex: none;
  min-width: 2.25rem;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.poll-option.mine .poll-percent {
  color: var(--color-primary);
  font-weight: 500;
}

.poll-bar {
  position: absolute;
  bottom: 0.125rem;
  left: 0;
  height: 0.1875rem;
  border-radius: 0.125rem;
  background: var(--color-primary);
}

.poll-fields {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.5rem 0;
}

.poll-field {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-borders);
  border-radius: 0.5rem;
  outline: 0;
  background: var(--color-background);
  color: var(--color-text);
  font: inherit;
}

.scheduled-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
}

.scheduled-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.scheduled-when {
  font-size: 0.8125rem;
  color: var(--color-primary);
}

.invite-link {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--color-background-secondary);
  overflow-wrap: anywhere;
  user-select: text;
}

.to-latest-badge {
  position: absolute;
  top: -0.5rem;
  left: 50%;
  min-width: 1.375rem;
  padding: 0 0.375rem;
  border-radius: 0.75rem;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.375rem;
  text-align: center;
  transform: translateX(-50%);
}

.unread-divider {
  margin: 0.5rem -1rem;
  padding: 0.25rem;
  background: var(--color-background);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  opacity: 0.9;
}

.select-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 1rem 1rem;
  padding: 0.25rem;
  border-radius: 1rem;
  background: var(--color-background);
  box-shadow: 0 1px 2px rgb(0 0 0 / 15%);
}

.select-count {
  flex: 1;
  font-weight: 500;
}

.select-bar .button {
  width: auto;
  padding: 0.5rem 0.75rem;
}

.select-bar .danger {
  color: var(--color-error);
}

.select-bar .button:disabled {
  opacity: 0.4;
}

.bubble.selected {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.voice-unplayed {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--color-primary);
}

.link-preview {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 0.375rem;
  padding: 0.25rem 0.5rem;
  border-left: 3px solid var(--color-primary);
  border-radius: 0.25rem;
  background: rgb(127 127 127 / 12%);
  font-size: 0.875rem;
  text-align: left;
}

.bubble.out .link-preview {
  border-left-color: var(--color-meta-own);
}

.link-preview-site {
  color: var(--color-primary);
  font-weight: 500;
}

.bubble.out .link-preview-site {
  color: var(--color-meta-own);
}

.link-preview-title {
  font-weight: 500;
}

.link-preview-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.blocked-bar {
  margin: 0 1rem 1rem;
  border-radius: 1.5rem;
  background: var(--color-background);
}

.blocked-bar .button {
  margin: 0;
}

.emoji-panel {
  display: flex;
  flex-direction: column;
  margin: 0 1rem 0.25rem;
  overflow: hidden;
  border-radius: 1rem;
  background: var(--color-background);
  box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr));
  height: 14rem;
  padding: 0.5rem;
  overflow-y: auto;
}

.gif-pane {
  display: flex;
  flex-direction: column;
  height: 20rem;
}

.gif-search {
  flex: none;
  margin: 0.5rem 0.5rem 0.25rem;
  padding: 0.375rem 0.75rem;
  border: 0;
  border-radius: 1rem;
  outline: 0;
  background: var(--color-background-secondary);
  color: var(--color-text);
  font: inherit;
}

.gif-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 0.125rem;
  padding: 0 0.5rem 0.25rem;
  overflow-y: auto;
}

.gif-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--color-background-secondary);
}

.gif-send,
.gif-send .gif-frame {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
}

.gif-unsave {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0.125rem;
  border-radius: 0.25rem;
  background: rgb(0 0 0 / 60%);
  color: #fff;
  opacity: 0;
  transition: opacity 150ms ease-in-out;
}

.gif-tile:hover .gif-unsave,
.gif-unsave:focus-visible {
  opacity: 0.8;
}

.gif-add {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--color-background-secondary);
  color: var(--color-primary);
}

.gif-more {
  grid-column: 1 / -1;
  height: 1px;
}

.gif-picking {
  opacity: 0.5;
  pointer-events: none;
}

.gif-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.5rem;
  color: var(--color-text-secondary);
  text-align: center;
}

.panel-tabs {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-top: 1px solid var(--color-borders);
}

.panel-tab {
  padding: 0.125rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.panel-tab.active {
  background: var(--color-chat-hover);
  color: var(--color-primary);
}

.emoji-button {
  height: 2.25rem;
  padding: 0;
  border-radius: 0.5rem;
  font-size: 1.375rem;
}

.emoji-button:hover {
  background: var(--color-chat-hover);
}

.sender-name {
  display: block;
  padding: 0;
  text-align: left;
}

.meta-pin {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.25rem;
  vertical-align: -1px;
}

.reactions {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.reaction {
  padding: 0.0625rem 0.5rem;
  border-radius: 0.875rem;
  background: rgb(0 0 0 / 7%);
  font-size: 0.875rem;
}

.reaction.mine {
  background: var(--color-primary);
  color: #fff;
}

.quick-reactions {
  display: flex;
  gap: 0.125rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-borders);
  margin-bottom: 0.25rem;
}

.quick-reaction {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.125rem;
}

.quick-reaction:hover,
.quick-reaction.mine {
  background: var(--color-chat-hover);
}

.avatar svg {
  width: 55%;
  height: 55%;
}


/* Stories */
.stories {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  flex-shrink: 0;
}

.story-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 3.75rem;
  flex-shrink: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text);
  cursor: pointer;
}

.story-chip .avatar {
  box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-borders);
}

.story-chip.unseen .avatar {
  box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-primary);
}

.story-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 92%);
  color: #fff;
}

.story-bars {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  display: flex;
  gap: 0.25rem;
  width: min(26rem, calc(100% - 2rem));
  transform: translateX(-50%);
}

.story-bar {
  flex: 1;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: rgb(255 255 255 / 30%);
}

.story-fill {
  display: block;
  height: 100%;
  background: #fff;
}

.story-header {
  position: absolute;
  top: 1.25rem;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: min(26rem, calc(100% - 2rem));
  transform: translateX(-50%);
}

.story-author {
  flex: 1;
  font-weight: 500;
}

.story-close {
  border: 0;
  background: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

.story-media {
  max-width: min(26rem, 100%);
  max-height: 100%;
  object-fit: contain;
}

.story-side {
  position: absolute;
  top: 4rem;
  bottom: 6rem;
  width: 45%;
  border: 0;
  background: none;
  cursor: pointer;
}

.story-previous {
  left: 0;
}

.story-next {
  right: 0;
}

.story-footer {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: min(26rem, calc(100% - 2rem));
  transform: translateX(-50%);
}

.story-caption {
  width: 100%;
  margin: 0;
  text-align: center;
}

/* Lock screen */
.lock {
  position: fixed;
  inset: 0;
  z-index: 60;
}

/* Media viewer */
.lightbox-count {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: #fff;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 3rem;
  height: 3rem;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 40%);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

/* Stickers */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr));
  gap: 0.25rem;
}

.sticker-tile {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 0.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: var(--color-text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.sticker-tile:hover {
  background: var(--color-background-secondary);
}

.sticker-tile img {
  max-width: 100%;
  max-height: 100%;
}

#sticker-pane {
  overflow-y: auto;
}

.sticker-message {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.sticker-message img {
  display: block;
  max-width: 12rem;
  max-height: 12rem;
}

.bubble.bare {
  background: none;
  box-shadow: none;
}

/* Special messages */
.dice {
  position: relative;
  font-size: 4rem;
  line-height: 1.1;
}

.dice-value {
  position: absolute;
  right: -0.25rem;
  bottom: 0;
  min-width: 1.5rem;
  border-radius: 0.75rem;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.5rem;
  text-align: center;
}

.contact-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.todo {
  min-width: 14rem;
  padding: 0 0.5rem 0.25rem;
}

.todo-item {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  opacity: 0.7;
}

.audio-file {
  display: grid;
  gap: 0.25rem;
  padding: 0.5rem;
}

.audio-file audio {
  width: 16rem;
  max-width: 100%;
}

.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.modal-textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-borders);
  border-radius: 0.5rem;
  background: none;
  color: inherit;
  font: inherit;
  resize: vertical;
}

.status-emoji {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-borders);
  border-radius: 0.5rem;
  background: none;
  color: inherit;
  cursor: pointer;
}

.status-emoji.selected {
  border-color: var(--color-primary);
}

.quick-reactions {
  flex-wrap: wrap;
}

#topics {
  flex-shrink: 0;
}

/* Comments */
.comments-button {
  display: block;
  width: 100%;
  padding: 0.375rem 0.625rem;
  border: 0;
  border-top: 1px solid var(--color-borders);
  background: none;
  color: var(--color-primary);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.comments {
  max-height: 22rem;
  margin-bottom: 1rem;
  overflow-y: auto;
}

.comment {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.375rem 0;
}

.comment .member-text {
  flex: 1;
  min-width: 0;
}

.comment-text {
  overflow-wrap: anywhere;
}

/* View-once media */
.view-once {
  display: block;
  width: 100%;
  min-width: 11rem;
  padding: 1rem;
  border: 1px dashed currentcolor;
  border-radius: 0.75rem;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.view-once:disabled {
  cursor: default;
  opacity: 0.7;
}

.folder-row {
  display: flex;
  align-items: center;
}

.folder-row .settings-nav {
  flex: 1;
  min-width: 0;
}

/* Long press opens our menu, so the system one mustn't appear over it. */
.bubble,
.chat-item {
  -webkit-touch-callout: none;
}

/* Media viewer bars, after Telegram's MediaViewer: sender and date, actions, caption */
.lightbox-top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(rgb(0 0 0 / 55%), transparent);
  cursor: default;
}

.lightbox-sender {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.lightbox-sender:hover {
  background: rgb(255 255 255 / 10%);
}

.lightbox-sender .avatar {
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
}

.lightbox-sender-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lightbox-name {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-date {
  font-size: 0.875rem;
  opacity: 0.7;
}

.lightbox-top .lightbox-count {
  position: static;
  margin: 0 auto;
}

.lightbox-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.lightbox-action {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.lightbox-action[hidden] {
  display: none;
}

.lightbox-action:hover {
  background: rgb(255 255 255 / 12%);
}

.lightbox-action svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}

.lightbox-caption {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  max-height: 30vh;
  margin: 0;
  padding: 1.5rem max(1rem, calc(50% - 20rem)) 1.25rem;
  overflow-y: auto;
  background: linear-gradient(transparent, rgb(0 0 0 / 65%) 35%);
  color: #fff;
  text-align: center;
  white-space: pre-wrap;
  cursor: default;
}

/* Data and Storage: media waiting for a tap */
.media-download {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.625rem 0.75rem;
  border: 0;
  border-radius: 1.5rem;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  font-size: 0.75rem;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.media-download svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}

.gif-frame.manual .gif-spinner {
  display: none;
}

.setting-slider {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}

.setting-slider-head {
  display: flex;
  justify-content: space-between;
}

.setting-value {
  color: var(--color-primary);
}

.range-slider {
  width: 100%;
  accent-color: var(--color-primary);
}

/* Profile photo history (Telegram's ProfileInfo) */
.profile-photos {
  position: relative;
  margin: -1rem -1rem 0.75rem;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--color-background-secondary);
}

.profile-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-marks {
  position: absolute;
  inset: 0.5rem 0.5rem auto;
  z-index: 1;
  display: flex;
  gap: 0.25rem;
}

.profile-photo-mark {
  flex: 1;
  height: 2px;
  border-radius: 1px;
  background: rgb(255 255 255 / 40%);
}

.profile-photo-mark.active {
  background: #fff;
}

.profile-photo-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  border: 0;
  background: none;
  cursor: pointer;
}

.profile-photo-nav.previous {
  left: 0;
}

.profile-photo-nav.next {
  right: 0;
}

/* Members tab (tg_members.png): one rounded card, online in the accent colour, the admin title as a pill on the right. */
.members-card {
  padding: 0.25rem 0;
}

/* Sizes from Telegram Web's .ListItem.chat-item-clickable (capture/data_files). */
.members-card .member-open {
  padding: 0.5625rem 0.75rem;
}

.members-card .member-status {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.members-card .avatar-small {
  width: 2.75rem;
  height: 2.75rem;
}

.member-text {
  flex: 1;
}

.member-status.online {
  color: var(--color-primary);
}

.member-badge {
  flex: none;
  max-width: 45%;
  margin-inline-start: auto;
  padding: 0.125rem 0.5rem;
  overflow: hidden;
  border-radius: 0.5rem;
  background: rgb(79 174 78 / 18%);
  color: var(--color-online);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-badge.owner {
  background: rgb(var(--color-primary-rgb) / 22%);
  color: var(--color-primary);
}

/* Sticker search (global, as in Telegram). */
.sticker-search {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--color-borders);
  border-radius: 1.25rem;
  background: var(--color-background-secondary);
  color: var(--color-text);
  font: inherit;
}

.sticker-found-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.5rem 0 0.25rem;
}

.sticker-found-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticker-install {
  flex: none;
  width: auto;
  padding: 0.25rem 0.875rem;
}

/* Statistics. */
.stats-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.stats-tile {
  display: flex;
  flex-direction: column;
  padding: 0.625rem 0.75rem;
  border-radius: 0.75rem;
  background: var(--color-background-secondary);
}

.stats-tile strong {
  font-size: 1.25rem;
}

.stats-tile span,
.stats-post-meta {
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
}

.stats-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--color-borders);
}

.stats-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: var(--color-primary);
}

.stats-post {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--color-borders);
}

.stats-post-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-post-meta {
  flex: none;
}

/* Drag to reorder folders. */
.folder-handle {
  flex: none;
  padding: 0.5rem;
  color: var(--color-text-secondary);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.folder-row.dragging {
  border-radius: 0.5rem;
  background: var(--color-chat-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.folder-row.dragging .folder-handle {
  cursor: grabbing;
}

.folder-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--color-background-secondary);
  word-break: break-all;
}

/* Stories archive. */
.story-archive {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
}

.story-archive .settings-note {
  grid-column: 1 / -1;
}

.story-archive-tile {
  position: relative;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #000;
}

.story-archive-tile img,
.story-archive-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-archive-date {
  position: absolute;
  bottom: 0.25rem;
  left: 0.25rem;
  padding: 0 0.375rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 0.75rem;
}

.story-archive-delete {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

.restrict-duration {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-borders);
  border-radius: 0.5rem;
  background: var(--color-background);
  color: var(--color-text);
  font: inherit;
}

/* Replies inside comments. */
.comment-quote {
  margin: 0.125rem 0;
  text-align: start;
}

.comment-reply {
  flex: none;
  align-self: center;
}

.comment-replying {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-inline-start: 2px solid var(--color-primary);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.comment-replying-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment.highlight {
  animation: comment-flash 1.2s;
}

@keyframes comment-flash {
  from { background: rgb(var(--color-primary-rgb) / 25%); }
}

/* Sticker suggestions over the message box when it holds one emoji. */
.sticker-suggest {
  position: absolute;
  z-index: 3;
  right: 1rem;
  bottom: 100%;
  left: 1rem;
  display: flex;
  gap: 0.25rem;
  padding: 0.375rem;
  overflow-x: auto;
  border-radius: 0.75rem;
  background: var(--color-background);
  box-shadow: 0 1px 4px rgb(0 0 0 / 25%);
}

.sticker-suggest .sticker-tile {
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
}

/* Profile highlights ("Stories" in a user's info). */
.highlights {
  margin: 0 0.75rem 0.75rem;
}

.highlights-strip {
  display: flex;
  gap: 0.375rem;
  padding: 0.25rem 0;
  overflow-x: auto;
}

.highlight-tile {
  flex: none;
  width: 4.5rem;
  aspect-ratio: 9 / 16;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--color-primary);
  border-radius: 0.5rem;
  background: #000;
}

.highlight-tile img,
.highlight-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-backdrop.over-stories {
  z-index: 45;
}

.quick-reaction.story-stealth {
  width: auto;
  padding: 0 0.625rem;
  border-radius: 1rem;
  white-space: nowrap;
}

/* The pinned button lines its text up at the start, so without a width cap the text spans grow to their full length,
   skip the ellipsis and run under the close button and off the screen on phones. */
.pinned-open {
  overflow: hidden;
}

.pinned-label,
.pinned-text {
  max-width: 100%;
}

.pinned-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* .button is full width, which in the search row took the space from the search field. */
#chat-search-date {
  flex: none;
  width: auto;
  height: 2.25rem;
  margin: 0;
  padding: 0 0.5rem;
  text-transform: none;
}

.select-count {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-bar .button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 2.5rem;
  margin: 0;
}

.select-bar .button .icon {
  display: none;
  font-size: 1.5rem;
}

/* Phones: Telegram's selection bar is icons beside the count; four worded buttons don't fit next to it. */
@media (max-width: 600px) {
  .select-bar .button {
    padding: 0.5rem;
  }

  .select-bar .button .icon {
    display: block;
  }

  .select-bar .button span {
    display: none;
  }
}

/* A small picture opened at its natural size was a dot in the middle of the screen; like its bubble, it grows to a
   readable size (keeping its shape) while large photos still shrink to fit. */
.lightbox img {
  min-width: min(100%, 18rem);
  height: auto;
  object-fit: contain;
}

.poll-option {
  align-items: center;
}

.poll-radio {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0 0.25rem 0 0.125rem;
  border: 2px solid var(--color-text-secondary);
  border-radius: 50%;
  opacity: 0.7;
  transition: border-color 0.15s, background-color 0.15s;
}

.poll-radio.multiple {
  border-radius: 0.375rem;
}

.poll-radio.checked {
  border-color: var(--color-primary);
  background: var(--color-primary);
  opacity: 1;
}

/* Telegram's story viewer covers the app completely, and the picture or video fills the story frame. */
.story-viewer {
  background: #000;
}

.story-media {
  width: min(26rem, 100%);
  height: auto;
}

/* Swipe gestures (gestures.js): the browser keeps vertical scrolling, horizontal drags go to the app. */
#messages,
#chat-list {
  touch-action: pan-y;
}

/* Swipe to reply: Telegram's round reply arrow fades in beside the message as it's pulled left. */
.bubble {
  --swipe-pull: 0;
}

.bubble[style*="translateX"]::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -3.25rem;
  width: 2.25rem;
  height: 2.25rem;
  margin-top: -1.125rem;
  border-radius: 50%;
  background: rgb(0 0 0 / 25%) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z'/%3E%3C/svg%3E") center / 1.25rem no-repeat;
  opacity: var(--swipe-pull);
  transform: scale(calc(0.6 + var(--swipe-pull) * 0.4));
  pointer-events: none;
}

.bubble.swipe-ready::after {
  background-color: var(--color-primary);
}


/* The played copy of the waveform, clipped at the playback position (--voice-p, 0…1). */
.voice-bars-played {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  clip-path: inset(0 calc(100% - var(--voice-p, 0) * 100%) 0 0);
  will-change: clip-path;
}

.voice-bars-played .voice-bar {
  background: var(--color-primary);
  opacity: 1;
}

.bubble.out .voice-bars-played .voice-bar {
  background: var(--color-meta-own);
}

/* "Popular GIFs" above the catalogue tiles when nothing is typed. */
.gif-section {
  grid-column: 1 / -1;
  margin: 0.5rem 0.25rem 0.25rem;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Tiles are square (aspect-ratio) and clip their media; in a grid of fixed height Chrome then shrank the rows to a pixel
   and the tiles piled up on each other. Rows sized by their content keep every tile a full square. */
.gif-grid {
  grid-auto-rows: max-content;
}

.gif-grid > .gif-tile,
.gif-grid > .gif-add {
  min-height: 0;
  height: auto;
}

/* Sticker tab, laid out as Telegram Web's (captured 2026-11-09): a strip of 36 px set covers, the scrolling list with
   "Search Stickers" and emoji chips on top, sets as titled sections five stickers to a row, set covers 48 px + name. */
#sticker-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#sticker-pane[hidden] { display: none; }

.sticker-strip {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 4px 6px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--color-borders);
}
.sticker-strip:empty { display: none; }
.sticker-strip::-webkit-scrollbar { display: none; }

.sticker-strip-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 3px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.sticker-strip-button:hover { background: var(--color-background-secondary); }
.sticker-strip-button img { width: 30px; height: 30px; object-fit: contain; }
.sticker-strip-button .icon, .sticker-strip-button svg { width: 24px; height: 24px; font-size: 24px; }

.sticker-scroll {
  flex: 1;
  min-height: 0;
  padding: 0 6px 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sticker-searchbar {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0 4px;
  background: var(--color-background);
}
.sticker-searchbar .sticker-search { flex: 1; margin: 0; }
.sticker-clear { flex: none; width: 28px; height: 28px; }
.sticker-clear[hidden] { display: none; }

.sticker-chips {
  display: flex;
  gap: 2px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sticker-chips::-webkit-scrollbar { display: none; }
.sticker-chip {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 22px;
  line-height: 34px;
  cursor: pointer;
}
.sticker-chip:hover { background: var(--color-background-secondary); }
.sticker-chip.active { background: rgb(var(--color-primary-rgb) / 16%); }

.sticker-section { margin-top: 4px; }
.sticker-section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 29px;
  padding: 4px 4px 2px;
}
.sticker-section-title {
  margin: 0;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sticker-section-credit {
  min-width: 0;
  margin-inline-start: auto;
  overflow: hidden;
  color: var(--color-text-meta, var(--color-text-secondary));
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.7;
}
.sticker-pack-head { align-items: center; }

#sticker-pane .sticker-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 2px;
}
#sticker-pane .sticker-tile { padding: 4px; border-radius: 10px; }
#sticker-pane .sticker-tile img { width: 100%; height: 100%; object-fit: contain; }
.catalog-sticker.busy { opacity: 0.5; }

.sticker-set-row {
  display: flex;
  gap: 2px;
  padding: 2px 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sticker-set-row::-webkit-scrollbar { display: none; }
.sticker-set-cover {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 72px;
  padding: 4px 2px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--color-text);
  cursor: pointer;
}
.sticker-set-cover:hover { background: var(--color-background-secondary); }
.sticker-set-cover-image { display: grid; place-items: center; width: 48px; height: 48px; }
.sticker-set-cover-image img { width: 48px; height: 48px; object-fit: contain; }
.sticker-set-cover-name {
  width: 100%;
  overflow: hidden;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sticker-create {
  display: block;
  margin: 6px auto 2px;
  padding: 4px 12px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--color-primary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
/* The field has its own clear button; the browser's would make two. */
.sticker-search::-webkit-search-cancel-button { display: none; }
