/* Gozal Messages (2026-10-15) - phone-first, works the same on a dispatcher's monitor. */
:root {
  color-scheme: light;
  --brand: #dd4048;
  --brand-ink: #ffffff;
  --bg: #ffffff;
  --side: #ffffff;
  --side-hover: #f2f3f5;
  --side-active: #fcebea;
  --thread-bg: #eceef2;
  --thread-pattern: rgba(18, 20, 26, 0.06);
  --panel: #ffffff;
  --line: #e4e6ea;
  --text: #14161b;
  --muted: #6b7079;
  --bubble-in: #ffffff;
  --bubble-out: #ffe8e8;
  --bubble-out-bg: linear-gradient(135deg, #fff0f0 0%, #ffe1e2 100%);
  --bubble-out-ink: #1d1f24;
  --link: #0b63c4;
  --seen: #1d8cf8;
  --badge: #dd4048;
  --badge-muted: #a1a6ae;
  --danger: #ce2c31;
  --shadow: 0 1px 2px rgba(16, 18, 24, 0.08);
  --pop-shadow: 0 16px 40px rgba(16, 18, 24, 0.18);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand-ink: #ffffff;
    --bg: #0e0f12;
    --side: #131418;
    --side-hover: #1c1d22;
    --side-active: #2a1517;
    --thread-bg: #0b0c0f;
    --thread-pattern: rgba(255, 255, 255, 0.035);
    --panel: #16171b;
    --line: #25272d;
    --text: #e9eaed;
    --muted: #8e919a;
    --bubble-in: #1e2025;
    --bubble-out: #522430;
    --bubble-out-bg: linear-gradient(135deg, #5a2630 0%, #4a1f28 100%);
    --bubble-out-ink: #fff4f4;
    --link: #7ab8ff;
    --seen: #8fd0ff;
    --badge: #ec5d63;
    --badge-muted: #50535b;
    --danger: #ff8a8d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    --pop-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] {
    color-scheme: dark;
    --brand-ink: #ffffff;
    --bg: #0e0f12;
    --side: #131418;
    --side-hover: #1c1d22;
    --side-active: #2a1517;
    --thread-bg: #0b0c0f;
    --thread-pattern: rgba(255, 255, 255, 0.035);
    --panel: #16171b;
    --line: #25272d;
    --text: #e9eaed;
    --muted: #8e919a;
    --bubble-in: #1e2025;
    --bubble-out: #522430;
    --bubble-out-bg: linear-gradient(135deg, #5a2630 0%, #4a1f28 100%);
    --bubble-out-ink: #fff4f4;
    --link: #7ab8ff;
    --seen: #8fd0ff;
    --badge: #ec5d63;
    --badge-muted: #50535b;
    --danger: #ff8a8d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    --pop-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  }


* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

a {
  color: var(--link);
}

/* ---------------------------------------------------------------- sign in */

.login-screen {
  display: grid;
  position: fixed;
  inset: 0;
  isolation: isolate;
  place-items: center;
  padding: 24px 16px;
  background: #050505;
  overflow: auto;
}

.login-screen::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #050505 url("/gozal-login-bg.png") center / cover no-repeat;
  content: "";
  opacity: 0.2;
}

.login-panel {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  padding: 22px;
  border-left: 5px solid var(--brand);
  background: rgba(255, 255, 255, 0.94);
  color: #111;
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.42);
}

.login-panel h1 {
  margin: 0;
  font-size: 22px;
}

.login-brand {
  display: grid;
  gap: 10px;
}

.text-logo {
  display: grid;
  gap: 2px;
  width: fit-content;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-left: 7px solid var(--brand);
  background: #fff;
  color: #000;
  text-transform: uppercase;
}

.text-logo strong {
  display: flex;
  gap: 12px;
  font-size: 30px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 4px;
}

.text-logo .brand-inc {
  color: var(--brand);
}

.text-logo .brand-tagline {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 5px;
}

.login-panel label {
  display: grid;
  gap: 4px;
  font-weight: 600;
}

.login-panel input {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c9ced4;
  border-radius: 8px;
  background: #fff;
  color: #111;
  font-size: 16px;
}

input.masked-password {
  -webkit-text-security: disc;
  text-security: disc;
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.login-message {
  min-height: 18px;
  margin: 0;
  color: #555;
}

/* ---------------------------------------------------------------- layout */

.chat-shell {
  display: grid;
  grid-template-columns: var(--side-w, minmax(280px, 360px)) 1fr;
  height: 100vh;
  height: 100dvh;
}

body.info-open .chat-shell {
  grid-template-columns: var(--side-w, minmax(280px, 360px)) 1fr minmax(280px, 340px);
}

.chat-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--side);
}

.chat-main {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  background: var(--thread-bg);
}

.chat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

/* ---------------------------------------------------------------- sidebar */

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 6px 14px;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.side-brand strong {
  display: block;
  font-size: 19px;
}

.side-brand small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-logo {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand) url("/chat-icon-192.png?v=3") center / cover;
  flex: none;
}

.side-logo.big {
  width: 72px;
  height: 72px;
  border-radius: 20px;
}

.side-tools {
  display: flex;
  gap: 2px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--side-hover);
  color: var(--text);
}

.icon-btn.small {
  width: 30px;
  height: 30px;
}

.icon-btn.small svg {
  width: 18px;
  height: 18px;
}

.icon-btn.light {
  color: #fff;
}

.side-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px 8px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--side-hover);
  color: var(--muted);
}

.side-search svg {
  width: 18px;
  height: 18px;
}

.side-search input {
  width: 100%;
  min-height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}

.push-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 10px 8px 10px 12px;
  border-radius: 12px;
  background: var(--side-active);
}

.push-banner > div {
  display: grid;
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.push-banner span {
  color: var(--muted);
}

.conv-list {
  flex: 1;
  margin: 0;
  padding: 0 6px 10px;
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.conv {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  outline: none;
}

.conv:hover,
.conv:focus-visible {
  background: var(--side-hover);
}

.conv.active {
  background: var(--side-active);
}

.conv-body {
  flex: 1;
  min-width: 0;
}

.conv-top,
.conv-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conv-title {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-time {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.conv-preview {
  flex: 1;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv.has-unread .conv-preview {
  color: var(--text);
}

.draft {
  color: var(--danger);
  font-style: normal;
}

.muted-icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--badge);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.badge.muted {
  background: var(--badge-muted);
}

.role-tag {
  flex: none;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--side-hover);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.role-tag.driver {
  background: rgba(29, 140, 248, 0.14);
  color: #1769c2;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .role-tag.driver {
    color: #7cc0ff;
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] .role-tag.driver {
    color: #7cc0ff;
  }


.side-empty {
  margin: 18px;
  color: var(--muted);
  text-align: center;
}

.search-results {
  max-height: 55%;
  padding: 0 6px 10px;
  border-top: 1px solid var(--line);
  overflow-y: auto;
}

.search-results h3,
.people-list h3,
.info-section h3 {
  margin: 12px 10px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.search-hit {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.search-hit:hover {
  background: var(--side-hover);
}

.hit-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.hit-top span,
.hit-body {
  color: var(--muted);
  font-size: 13px;
}

mark {
  border-radius: 3px;
  background: #ffe28a;
  color: #111;
}

/* ---------------------------------------------------------------- avatars */

.avatar {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--av, #55606e);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
  user-select: none;
}

.avatar.driver {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.55);
}

.avatar.group svg,
.avatar.bot svg {
  width: 24px;
  height: 24px;
}

.avatar.bot {
  background: #374151;
}

.avatar.small {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar.small svg {
  width: 18px;
  height: 18px;
}

.avatar.big {
  width: 84px;
  height: 84px;
  font-size: 28px;
}

.avatar.big svg {
  width: 38px;
  height: 38px;
}

.avatar-space {
  width: 32px;
  flex: none;
}

/* ---------------------------------------------------------------- empty state */

.chat-empty {
  display: grid;
  flex: 1;
  place-items: center;
  padding: 24px;
}

.chat-empty-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  max-width: 320px;
  padding: 26px 22px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  color: var(--muted);
  text-align: center;
}

.chat-empty-card h2 {
  margin: 8px 0 0;
  color: var(--text);
}

.chat-empty-card p {
  margin: 0;
}

/* ---------------------------------------------------------------- thread */

.thread {
  position: relative;
  background-color: var(--thread-bg);
  background-image: var(--wp-image, radial-gradient(var(--thread-pattern) 1.2px, transparent 1.2px));
  background-position: center;
  background-size: var(--wp-size, 18px 18px);
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.thread-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 60px;
  padding: 8px 8px 8px 10px;
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  z-index: 2;
}

.back-btn {
  display: none;
}

.thread-title {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 2px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.thread-title .avatar {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.thread-title-text {
  display: grid;
  min-width: 0;
}

.thread-title-text strong,
.thread-title-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-title-text small {
  color: var(--muted);
  font-size: 12px;
}

.thread-scroll {
  flex: 1;
  min-height: 0;
  padding: 10px 0 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: var(--chat-col);
  margin: 0 auto;
  padding: 0 12px;
}

.older-row {
  display: flex;
  justify-content: center;
  padding: 4px 0 8px;
}

.thread-loading,
.thread-hello {
  margin: 30px auto;
  padding: 10px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  color: var(--muted);
  text-align: center;
}

.day-sep,
.system-line {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}

.day-sep span,
.system-line span {
  padding: 3px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.system-line span {
  max-width: 90%;
  font-weight: 500;
  text-align: center;
}

.msg {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 100%;
  margin-top: 6px;
}

.msg.grouped {
  margin-top: 1px;
}

.msg.mine {
  flex-direction: row-reverse;
}

.bubble {
  position: relative;
  font-size: var(--msg-size, 15px);
  max-width: min(78%, 560px);
  min-width: 64px;
  padding: 6px 10px 5px;
  border-radius: var(--radius);
  background: var(--bubble-in);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

.msg.mine .bubble {
  background: var(--bubble-out-bg, var(--bubble-out));
  color: var(--bubble-out-ink);
}

.msg.theirs.tail .bubble {
  border-bottom-left-radius: 5px;
}

.msg.mine.tail .bubble {
  border-bottom-right-radius: 5px;
}

.msg.pending .bubble {
  opacity: 0.8;
}

.msg.failed .bubble {
  box-shadow: 0 0 0 1.5px var(--danger);
}

.msg.flash .bubble {
  animation: flash 1.4s ease;
}

@keyframes flash {
  0%, 60% { box-shadow: 0 0 0 3px #ffcf4a; }
  100% { box-shadow: var(--shadow); }
}

.sender {
  margin-bottom: 1px;
  color: hsl(var(--h, 0) 60% 40%);
  font-size: 13px;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sender {
    color: hsl(var(--h, 0) 70% 70%);
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] .sender {
    color: hsl(var(--h, 0) 70% 70%);
  }


.sender .role-tag {
  margin-left: 4px;
  vertical-align: 1px;
}

.text {
  white-space: pre-wrap;
}

.text a {
  word-break: break-all;
}

.deleted-text {
  color: var(--muted);
  font-style: italic;
}

.meta {
  float: right;
  position: relative;
  top: 6px;
  margin-left: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
}

.meta[data-progress]::before {
  content: attr(data-progress) " · ";
}

.msg.mine .meta {
  color: color-mix(in srgb, var(--bubble-out-ink) 60%, transparent);
}

.tick {
  letter-spacing: -3px;
  padding-right: 3px;
}

.tick.seen {
  color: var(--seen);
}

.msg.mine .tick.seen {
  color: var(--seen);
}

.tick.fail {
  color: var(--danger);
  font-weight: 800;
  letter-spacing: 0;
}

.conv-time .tick {
  font-size: 12px;
}

.retry {
  display: block;
  clear: both;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.msg-more {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s;
}

.msg-more svg {
  width: 18px;
  height: 18px;
}

.msg:hover .msg-more,
.msg-more:focus-visible {
  opacity: 1;
}

@media (pointer: coarse) {
  .msg-more {
    display: none;
  }
}

.quote {
  display: grid;
  width: 100%;
  margin: 2px 0 4px;
  padding: 4px 8px;
  border: 0;
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  background: color-mix(in srgb, var(--brand) 9%, transparent);
  text-align: left;
}

.quote strong {
  color: var(--brand);
  font-size: 13px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .quote strong {
    color: #ff8f8f;
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] .quote strong {
    color: #ff8f8f;
  }


.quote span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* attachments */

.media-grid {
  display: grid;
  gap: 3px;
  margin: 2px -6px 4px;
  overflow: hidden;
  border-radius: 12px;
}

.media-grid.n2,
.media-grid.n4 {
  grid-template-columns: 1fr 1fr;
}

.media-grid.n3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.media-grid .media,
.media-grid video {
  display: block;
  width: 100%;
  max-height: 340px;
  padding: 0;
  border: 0;
  background: #0003;
  object-fit: cover;
}

.media-grid.n2 .media,
.media-grid.n3 .media,
.media-grid.n4 .media {
  aspect-ratio: 1 / 1 !important;
}

.media img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 60px;
  object-fit: cover;
}

.msg.media-only .bubble {
  padding: 3px;
}

.msg.media-only .media-grid {
  margin: 0;
}

.msg.media-only .meta {
  position: absolute;
  right: 10px;
  bottom: 8px;
  top: auto;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff !important;
}

.file-card,
.location-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 4px;
  padding: 8px 10px 8px 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: inherit;
  text-decoration: none;
}

.file-card span:last-child,
.location-card span:last-child {
  display: grid;
  min-width: 0;
}

.file-card strong,
.location-card strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card small,
.location-card small {
  color: var(--muted);
  font-size: 12px;
}

.link-like {
  color: var(--link) !important;
  font-weight: 600;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  flex: none;
}

.loc-pin {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #1f9d55;
  color: #fff;
  flex: none;
}

.voice-card {
  display: grid;
  gap: 2px;
  margin: 2px 0 4px;
}

.voice-card audio {
  width: min(260px, 62vw);
  height: 40px;
}

.voice-card small {
  color: var(--muted);
  font-size: 12px;
}

/* jump to latest, drop hint */

.jump-bottom {
  position: absolute;
  right: 18px;
  bottom: calc(86px + var(--safe-bottom));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  box-shadow: var(--pop-shadow);
  z-index: 3;
}

.jump-count {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 20px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--badge);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.drop-hint {
  position: absolute;
  inset: 70px 16px 90px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--brand);
  border-radius: 20px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  color: var(--brand);
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  z-index: 4;
}

/* ---------------------------------------------------------------- composer */

.composer {
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.composer-row,
.record-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: var(--chat-col);
  margin: 0 auto;
}

.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  outline: none;
  background: var(--bg);
  font-size: 16px; /* 16 px stops iPhone zooming into the box */
  line-height: 1.35;
  resize: none;
}

.composer textarea:focus {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
}

.composer .icon-btn {
  width: 44px;
  height: 44px;
}

.send-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  flex: none;
}

.send-btn:active {
  transform: scale(0.94);
}

.composer-readonly {
  padding: 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 860px);
  margin: 0 auto 6px;
  padding: 4px 4px 4px 10px;
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}

.reply-bar.editing {
  border-left-color: var(--link);
  background: color-mix(in srgb, var(--link) 9%, transparent);
}

.reply-bar-text {
  display: grid;
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.reply-bar-text strong {
  color: var(--brand);
}

.reply-bar.editing .reply-bar-text strong {
  color: var(--link);
}

.reply-bar-text span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-tray {
  display: flex;
  gap: 8px;
  width: min(100%, 860px);
  margin: 0 auto 8px;
  padding-bottom: 2px;
  overflow-x: auto;
}

.tray-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 6px 30px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  flex: none;
}

.tray-item img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.tray-name {
  display: grid;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tray-name small {
  color: var(--muted);
}

.tray-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--side-hover);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.record-bar {
  align-items: center;
  min-height: 44px;
  padding: 0 4px 0 12px;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e5484d;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% { opacity: 0.3; }
}

.rec-label {
  flex: 1;
  color: var(--muted);
}

/* ---------------------------------------------------------------- buttons, popovers */

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.pill-btn.ghost {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.pill-btn.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.pill-btn.danger,
.popover .danger {
  color: var(--danger);
}

.pill-btn:disabled {
  opacity: 0.55;
}

.popover {
  position: fixed;
  z-index: 50;
  display: grid;
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--pop-shadow);
}

.popover button,
.popover a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  text-decoration: none;
}

.popover button:hover,
.popover a:hover,
.popover button:focus-visible,
.popover a:focus-visible {
  background: var(--side-hover);
  outline: none;
}

.popover svg {
  width: 20px;
  height: 20px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 80;
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #1f2937;
  color: #fff;
  box-shadow: var(--pop-shadow);
  font-size: 14px;
  text-align: center;
  transform: translateX(-50%);
}

/* ---------------------------------------------------------------- dialogs */

dialog.sheet {
  width: min(520px, calc(100vw - 24px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--pop-shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.sheet-frame {
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 760px);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 6px 18px;
  font-size: 17px;
}

.sheet-tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 8px;
}

.tab {
  flex: 1;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--side-active);
  color: var(--text);
}

.group-fields {
  display: grid;
  gap: 10px;
  padding: 4px 16px 8px;
}

.field {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.picker-search input,
.info-title-input {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 2px;
  font-size: 14px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--brand);
  flex: none;
}

.check span {
  display: grid;
}

.check small,
.hint {
  color: var(--muted);
  font-size: 12px;
}

.hint {
  margin: 0 2px 6px;
}

.picker-search {
  display: flex;
  gap: 6px;
  padding: 0 16px 6px;
}

.picker-search input {
  flex: 1;
  min-width: 0;
}

.people-list {
  flex: 1;
  min-height: 160px;
  padding: 0 8px 8px;
  overflow-y: auto;
}

.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.person:hover {
  background: var(--side-hover);
}

.person input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

.person .avatar {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.person-name {
  display: grid;
  flex: 1;
  min-width: 0;
}

.person-name strong,
.person-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-name small {
  color: var(--muted);
  font-size: 12px;
}

.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.sheet-status {
  min-height: 0;
  margin: 0 16px 10px;
  color: var(--danger);
  font-size: 14px;
}

.sheet-status:empty {
  display: none;
}

dialog.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.92);
}

dialog.lightbox[open] {
  display: grid;
  place-items: center;
}

.lightbox form {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: 10px;
}

.lightbox img {
  max-width: 100vw;
  max-height: 86dvh;
  object-fit: contain;
}

.lightbox .pill-btn {
  position: absolute;
  bottom: calc(18px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
}

/* ---------------------------------------------------------------- info panel */

.info-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 8px 10px;
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
}

.info-body {
  flex: 1;
  padding-bottom: calc(20px + var(--safe-bottom));
  overflow-y: auto;
}

.info-hero {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 22px 16px 14px;
  text-align: center;
}

.info-hero h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.info-hero small {
  color: var(--muted);
}

.info-title-input {
  width: 100%;
  font-weight: 700;
  text-align: center;
}

.info-section {
  margin: 0 12px 10px;
  padding: 6px 10px;
  border-radius: 14px;
  background: var(--side-hover);
}

.info-section h3 {
  margin: 6px 0;
}

.info-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.member-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.danger-zone {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: transparent;
}

/* ---------------------------------------------------------------- phone layout */

@media (max-width: 760px) {
  .chat-shell,
  body.info-open .chat-shell {
    display: block;
    position: relative;
  }

  .chat-side,
  .chat-main,
  .chat-info {
    position: absolute;
    inset: 0;
  }

  .chat-side {
    border-right: 0;
  }

  .chat-main {
    display: none;
  }

  body.thread-open .chat-main {
    display: flex;
    z-index: 5;
  }

  body.thread-open .chat-side {
    visibility: hidden;
  }

  .chat-info {
    z-index: 6;
    border-left: 0;
  }

  .back-btn {
    display: inline-grid;
  }

  .chat-empty {
    display: none;
  }

  .bubble {
    max-width: 84%;
  }

  .jump-bottom {
    right: 12px;
  }
}

/* ---------------------------------------------------------------- people (admins) */

.people-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  padding: 4px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.people-form .pill-btn {
  align-self: end;
  min-height: 42px;
}

.people-form select,
.admin-person select {
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 15px;
}

.admin-person {
  flex-wrap: wrap;
  cursor: default;
}

.admin-person select {
  min-height: 32px;
  font-size: 13px;
}

@media (max-width: 520px) {
  .people-form {
    grid-template-columns: 1fr;
  }

  .admin-person .person-name {
    flex-basis: calc(100% - 56px);
  }
}

.install-banner img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: none;
}

/* Installed app on a PC: no browser bar, so give the header a little more room. */
@media (display-mode: standalone) and (min-width: 761px) {
  .side-head,
  .thread-head {
    min-height: 64px;
  }
}

/* ================================================================ Gozal Inc. look (phase 3)
   Same language as the trailer board's Gozal style: black bars, a red rule, the heavy
   uppercase GOZAL INC. wordmark. Chats stay light and calm so long threads read easily. */

:root {
  --gz-black: #0c0c0e;
  --gz-black-2: #18191c;
  --gz-red: #dd4048;
  --gz-red-bright: #ec5d63;
  /* Light theme: white bars with the Gozal red rule. Dark theme: black bars. */
  --head-bg: #ffffff;
  --head-ink: #14161b;
  --head-muted: #6b7079;
  --head-hover: rgba(16, 18, 24, 0.06);
  --wp-veil: rgba(240, 242, 246, 0.8);
  --chat-col: min(100%, clamp(760px, 74%, 1180px));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --head-bg: #0c0c0e;
    --head-ink: #ffffff;
    --head-muted: #b9bec6;
    --head-hover: rgba(255, 255, 255, 0.1);
    --wp-veil: rgba(0, 0, 0, 0.12);
  }
}

:root[data-theme="dark"] {
  --head-bg: #0c0c0e;
  --head-ink: #ffffff;
  --head-muted: #b9bec6;
  --head-hover: rgba(255, 255, 255, 0.1);
  --wp-veil: rgba(0, 0, 0, 0.12);
}

.side-head,
.thread-head,
.info-head {
  background: var(--head-bg);
  color: var(--head-ink);
  border-bottom: 2px solid var(--gz-red);
}

.side-head .icon-btn,
.thread-head .icon-btn,
.info-head .icon-btn {
  color: var(--head-muted);
}

.side-head .icon-btn:hover,
.thread-head .icon-btn:hover,
.info-head .icon-btn:hover,
.side-head .icon-btn:focus-visible,
.thread-head .icon-btn:focus-visible {
  background: var(--head-hover);
  color: var(--head-ink);
}

.wordmark {
  display: block;
  font-family: "Arial Black", "Segoe UI Black", Arial, sans-serif;
  font-size: 17px !important;
  font-weight: 900;
  letter-spacing: 2.5px;
  line-height: 1.1;
  text-transform: uppercase;
}

.wordmark em {
  color: var(--gz-red-bright);
  font-style: normal;
}

.side-brand small {
  color: var(--head-muted) !important;
}

.side-brand .product {
  color: var(--head-ink);
  font-weight: 700;
  letter-spacing: 0.4px;
}

.thread-title {
  color: var(--head-ink);
}

.thread-title:hover {
  background: var(--head-hover);
}

.thread-title-text small {
  color: var(--head-muted);
}

.side-logo {
  border-radius: 8px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.conv.active {
  background: var(--side-active);
  box-shadow: inset 4px 0 0 var(--gz-red);
}

.chat-empty-card h2 {
  font-family: "Arial Black", "Segoe UI Black", Arial, sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.badge {
  background: var(--gz-red);
}

/* ---------------------------------------------------------------- safety */

.sos-btn {
  min-width: 52px;
  height: 34px;
  margin-right: 4px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--gz-red-bright);
  color: #fff;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 2px 10px rgba(214, 31, 31, 0.5);
}

.sos-btn:active {
  transform: scale(0.96);
}

.sos-sheet .sheet-head strong {
  color: var(--gz-red-bright);
}

.call-911 {
  display: block;
  margin: 0 16px 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fde8e8;
  color: #a3262c;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
}

.sos-types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 10px;
}

.sos-types label {
  position: relative;
}

.sos-types input {
  position: absolute;
  opacity: 0;
}

.sos-types span {
  display: grid;
  place-items: center;
  min-height: 60px;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.sos-types input:checked + span {
  border-color: var(--gz-red-bright);
  background: color-mix(in srgb, var(--gz-red-bright) 12%, transparent);
}

.sos-types input:focus-visible + span {
  outline: 3px solid var(--link);
}

.sos-note,
.sos-hint {
  margin: 0 16px 8px;
}

.sos-send {
  min-height: 48px;
  padding: 0 26px;
  background: var(--gz-red-bright);
  font-size: 16px;
}

.msg.sos .bubble {
  border: 2px solid var(--gz-red-bright);
  background: #fff1f1;
  color: #2a0a0a;
}

.sos-head {
  margin-bottom: 2px;
  color: var(--gz-red-bright);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
}

.msg.important .bubble {
  box-shadow: inset 4px 0 0 #e8a400, var(--shadow);
}

.important-tag {
  margin-bottom: 2px;
  color: #b07800;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ack-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
}

.ack-btn {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #e8a400;
  color: #1a1200;
  font-weight: 800;
}

.ack-btn.sos-take {
  background: var(--gz-red-bright);
  color: #fff;
}

.ack-count {
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, #e8a400 60%, transparent);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
}

.ack-count.all {
  border-color: #2e9d55;
  color: #1f7a40;
}

.ack-done {
  color: #1f7a40;
  font-size: 13px;
  font-weight: 700;
}

.ack-wait {
  color: var(--gz-red-bright);
  font-size: 13px;
  font-weight: 700;
}

#importantButton[aria-pressed="true"] {
  background: #e8a400;
  color: #1a1200;
}

#importantButton svg {
  stroke-width: 3;
}

.important-bar {
  width: min(100%, 860px);
  margin: 0 auto 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, #e8a400 16%, transparent);
  font-size: 13px;
}

.quick-replies {
  display: flex;
  gap: 6px;
  width: min(100%, 860px);
  margin: 0 auto 8px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-replies button {
  flex: none;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.quick-replies button:active {
  background: var(--side-active);
}

.wait-chip {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, #e8a400 22%, transparent);
  color: #8a5b00;
  font-size: 12px;
  font-weight: 800;
}

.wait-chip.late {
  background: var(--gz-red-bright);
  color: #fff;
}

.conv.emergency .conv-title {
  color: var(--gz-red-bright);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .call-911 {
    background: #3a1414;
    color: #ffc9c9;
  }

  :root:not([data-theme="light"]) .msg.sos .bubble {
    background: #3a1212;
    color: #ffecec;
  }

  :root:not([data-theme="light"]) .important-tag {
    color: #f5c04a;
  }

  :root:not([data-theme="light"]) .ack-done {
    color: #6fd28f;
  }

  :root:not([data-theme="light"]) .wait-chip {
    color: #f5c04a;
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] .call-911 {
    background: #3a1414;
    color: #ffc9c9;
  }

  :root[data-theme="dark"] .msg.sos .bubble {
    background: #3a1212;
    color: #ffecec;
  }

  :root[data-theme="dark"] .important-tag {
    color: #f5c04a;
  }

  :root[data-theme="dark"] .ack-done {
    color: #6fd28f;
  }

  :root[data-theme="dark"] .wait-chip {
    color: #f5c04a;
  }


.avatar.emergency-avatar {
  background: var(--gz-red-bright);
}

.sheet-status.ok {
  color: #1f7a40;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sheet-status.ok {
    color: #6fd28f;
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] .sheet-status.ok {
    color: #6fd28f;
  }


.login-card {
  display: grid;
  gap: 8px;
  margin: 0 16px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--side-hover);
}

.login-card pre {
  margin: 0;
  font: 14px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.login-card .pill-btn {
  justify-self: start;
}

.field small {
  color: var(--muted);
  font-weight: 400;
}

/* ---------------------------------------------------------------- phones: no zoom, no jumping */

/* No double-tap zoom (two quick taps on Send zoomed the page in). Pinch-zoom still works. */
html,
body {
  touch-action: manipulation;
}

/* iPhone zooms into any text box with text under 16 px when you tap it - keep them at 16. */
@media (pointer: coarse) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  .chat-shell {
    position: fixed;
    top: var(--app-top, 0px);
    left: 0;
    right: 0;
    height: var(--app-height, 100dvh);
  }

  html,
  body {
    position: fixed;
    inset: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }
}

.thread-scroll {
  overflow-anchor: none;
}

/* Sending (grey) and sent (✓) are the same glyph and size, so a message never changes
   height the moment the server confirms it. */
.tick {
  display: inline-block;
  min-width: 14px;
  line-height: 1;
}

.tick.wait {
  opacity: 0.45;
}

/* ---------------------------------------------------------------- unread & mentions (Telegram-style) */

/* Unread chats stand out in the list: tint, red bar, bold name and preview. */
.conv.has-unread {
  background: color-mix(in srgb, var(--gz-red) 7%, transparent);
  box-shadow: inset 3px 0 0 var(--gz-red);
}

.conv.has-unread .conv-title,
.conv.has-unread .conv-preview {
  font-weight: 700;
}

.conv.muted-unread {
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  box-shadow: inset 3px 0 0 var(--badge-muted);
}

/* Tagged: a stronger, different colour (blue, like Telegram's @). */
.conv.has-mention {
  background: color-mix(in srgb, #1d8cf8 12%, transparent);
  box-shadow: inset 4px 0 0 #1d8cf8;
}

.badge.mention-badge {
  min-width: 22px;
  background: #1d8cf8;
  font-size: 13px;
  font-weight: 900;
}

/* A new message just landed in this chat. */
.conv.just-in {
  animation: row-in 1.6s ease-out;
}

@keyframes row-in {
  0% { background: color-mix(in srgb, #e8a400 38%, transparent); }
  100% { background: inherit; }
}

/* "New messages" line where your unread part starts. */
.unread-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 6px;
  color: var(--gz-red-bright);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.unread-sep::before,
.unread-sep::after {
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--gz-red-bright) 45%, transparent);
  content: "";
}

/* Messages arriving while you watch glow for a moment. */
.msg.arrived .bubble {
  animation: bubble-in 1.8s ease-out;
}

@keyframes bubble-in {
  0% { box-shadow: 0 0 0 3px color-mix(in srgb, #e8a400 60%, transparent), var(--shadow); }
  100% { box-shadow: var(--shadow); }
}

/* A message that tags you. */
.msg.mentions-me .bubble {
  background: color-mix(in srgb, #1d8cf8 14%, var(--bubble-in));
  box-shadow: inset 4px 0 0 #1d8cf8, var(--shadow);
}

.mention {
  color: var(--link);
  font-weight: 700;
}

.mention.me {
  padding: 0 3px;
  border-radius: 4px;
  background: color-mix(in srgb, #1d8cf8 22%, transparent);
}

/* @ list above the message box */
.mention-list {
  display: grid;
  width: min(100%, 860px);
  max-height: 240px;
  margin: 0 auto 6px;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--pop-shadow);
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.mention-option:hover,
.mention-option.first {
  background: var(--side-hover);
}

.mention-option small {
  color: var(--muted);
}

/* Drivers: faint name watermark over the chat, so any recording shows whose screen it is. */
body.watermarked .thread-scroll {
  background-image: var(--watermark);
  background-size: 360px 200px;
  background-attachment: local;
}

/* Videos: the frame's size is decided before the video loads (its saved shape, or 4:5 for
   older ones); the video only fills it, with black bars if needed. Nothing ever resizes. */
.video-box {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
}

.video-box video,
.media-grid .video-box video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

/* ------------------------------------------------------------------ wake-up calls */

.thread-head .wake-btn {
  color: #f5c04a;
}

.wake-sheet .sheet-head strong {
  color: #b07800;
}

.wake-sheet .hint,
.wake-sheet .field {
  margin: 0 16px 10px;
}

.wake-warn {
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff4d6;
  color: #5c3f00;
}

.wake-send {
  min-height: 48px;
  padding: 0 24px;
  background: #e8a400;
  color: #1a1200;
  font-size: 16px;
}

.msg.wakeup .bubble {
  border: 2px solid #e8a400;
  background: #fff8e6;
  color: #2a1e00;
}

.wake-head {
  margin-bottom: 2px;
  color: #a06c00;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.wake-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.wake-ring {
  font-size: 13px;
  font-weight: 700;
}

.wake-bad {
  color: var(--gz-red-bright);
  font-size: 13px;
  font-weight: 700;
}

.wake-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.ack-btn.wake-ok {
  min-height: 48px;
  padding: 0 28px;
  font-size: 17px;
}

.ack-btn.wake-stop {
  background: var(--gz-black-2);
  color: #fff;
}

.ack-btn.wake-call {
  display: inline-flex;
  align-items: center;
  background: #2e9d55;
  color: #fff;
  text-decoration: none;
}

/* The driver's alarm screen: on top of everything until "I'm awake". */
.wake-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: var(--gz-black);
  color: #fff;
  text-align: center;
  animation: wake-flash 1s steps(1) infinite;
}

.wake-overlay[hidden] {
  display: none;
}

@keyframes wake-flash {
  50% { background: #3a2a00; }
}

@media (prefers-reduced-motion: reduce) {
  .wake-overlay { animation: none; }
  .wake-clock { animation: none; }
}

.wake-clock {
  font-size: 96px;
  line-height: 1;
  animation: wake-shake 0.5s ease-in-out infinite;
}

@keyframes wake-shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

.wake-overlay h2 {
  margin: 0;
  color: #f5c04a;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 3px;
}

.wake-from {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.wake-note {
  max-width: 420px;
  margin: 0;
  color: var(--head-muted);
  font-size: 17px;
  white-space: pre-wrap;
}

.wake-note:empty {
  display: none;
}

.wake-awake {
  width: min(100%, 360px);
  min-height: 72px;
  margin-top: 16px;
  border: 0;
  border-radius: 999px;
  background: #2e9d55;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
}

.wake-awake:disabled {
  opacity: 0.6;
}

body.waking {
  overflow: hidden;
}

/* Phone setup guide */
.setup-body {
  padding: 0 16px 16px;
  overflow-y: auto;
}

.setup-body .sheet-tabs {
  margin: 0 0 12px;
  padding: 0;
}

.setup-office {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 12px;
  background: color-mix(in srgb, #e8a400 12%, transparent);
}

.setup-office .hint {
  margin: 0;
}

.setup-number a {
  color: var(--link);
  font-weight: 700;
}

.setup-steps {
  margin: 0 0 12px;
  padding-left: 22px;
}

.setup-steps li {
  margin-bottom: 10px;
  line-height: 1.45;
}

.setup-admin {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wake-warn {
    background: #3a2c08;
    color: #ffe3a3;
  }

  :root:not([data-theme="light"]) .msg.wakeup .bubble {
    background: #33270a;
    color: #fff3d6;
  }

  :root:not([data-theme="light"]) .wake-head,
  :root:not([data-theme="light"]) .wake-sheet .sheet-head strong {
    color: #f5c04a;
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] .wake-warn {
    background: #3a2c08;
    color: #ffe3a3;
  }

  :root[data-theme="dark"] .msg.wakeup .bubble {
    background: #33270a;
    color: #fff3d6;
  }

  :root[data-theme="dark"] .wake-head,
  :root[data-theme="dark"] .wake-sheet .sheet-head strong {
    color: #f5c04a;
  }


/* ------------------------------------------------------------------ Telegram-style extras */

/* Pinned message bar under the chat header */
.pinned-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.pinned-bar[hidden] {
  display: none;
}

.pinned-open {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  border-left: 3px solid var(--brand);
  background: transparent;
  color: inherit;
  text-align: left;
}

.pinned-open .pin-icon {
  padding-left: 8px;
}

.pinned-text {
  display: grid;
  min-width: 0;
  font-size: 13px;
}

.pinned-text strong {
  color: var(--brand);
}

.pinned-text span {
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Reactions */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
}

.react-chip {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  color: inherit;
  font-size: 14px;
}

.react-chip.mine {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  font-weight: 700;
}

.react-row {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  padding: 4px 6px 6px;
  border-bottom: 1px solid var(--line);
}

.popover .react-row .react-pick {
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
}

.popover .react-row .react-pick.mine {
  background: color-mix(in srgb, var(--brand) 16%, transparent);
}

.fwd-from {
  margin-bottom: 2px;
  color: var(--link);
  font-size: 12px;
}

/* Chat list: pinned / marked unread */
.pin-mark {
  font-size: 12px;
  opacity: 0.7;
}

.badge.marked {
  min-width: 12px;
  width: 12px;
  height: 12px;
  padding: 0;
}

#threadSubtitle.typing {
  color: #6fd28f;
  font-style: italic;
}

/* Chat info: shared media */
.shared-tabs {
  flex-wrap: wrap;
  padding: 0 0 8px;
}

.shared-tabs .tab {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 13px;
}

.shared-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.shared-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #000;
}

.shared-tile img,
.shared-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shared-tile.video span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 22px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.shared-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.shared-row a {
  overflow-wrap: anywhere;
  color: var(--link);
}

.shared-row audio {
  max-width: 100%;
  height: 36px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
}

#forwardList .person.pick {
  cursor: pointer;
}

#forwardList .person.pick input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

#forwardList .person.picked {
  background: var(--side-active);
}

/* Storage & backups (admins) */
.storage-warn {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff4d6;
  color: #5c3f00;
}

.storage-warn p {
  margin: 4px 0;
}

.storage-ok {
  margin: 0 0 12px;
  font-weight: 700;
}

#storageBody h3 {
  margin: 14px 0 6px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.meter span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #2e9d55;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .storage-warn {
    background: #3a2c08;
    color: #ffe3a3;
  }
}

/* the same, when someone picks Dark in the menu */
  :root[data-theme="dark"] .storage-warn {
    background: #3a2c08;
    color: #ffe3a3;
  }


/* Deleted items (admins) */
.deleted-item {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.deleted-item .pill-btn {
  justify-self: start;
}

.deleted-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.deleted-head small,
.deleted-meta {
  color: var(--muted);
  font-size: 12px;
}

.deleted-body {
  padding: 6px 10px;
  border-left: 3px solid var(--line);
  overflow-wrap: anywhere;
}

.deleted-file {
  color: var(--link);
  font-size: 14px;
}

/* ------------------------------------------------------------------ main menu (side panel) */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0);
  transition: background 0.18s ease;
}

.drawer-backdrop.open {
  background: rgba(0, 0, 0, 0.42);
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 61;
  display: flex;
  flex-direction: column;
  width: min(330px, 86vw);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--pop-shadow);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer[hidden],
.drawer-backdrop[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .drawer,
  .drawer-backdrop {
    transition: none;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(22px, env(safe-area-inset-top)) 20px 18px;
  border-bottom: 2px solid var(--gz-red);
  background: var(--head-bg);
  color: var(--head-ink);
}

.drawer-head .avatar {
  width: 54px;
  height: 54px;
  font-size: 20px;
}

.drawer-who {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.drawer-who strong {
  overflow: hidden;
  font-size: 17px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.drawer-who small {
  color: var(--head-muted);
  font-size: 13px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 10px;
}

.drawer-label {
  margin: 14px 20px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 48px;
  padding: 8px 20px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: left;
}

.drawer-item[hidden] {
  display: none;
}

.drawer-item svg {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  color: var(--muted);
}

.drawer-item:hover,
.drawer-item:focus-visible {
  background: var(--side-hover);
  outline: none;
}

.drawer-text {
  display: grid;
  flex: 1;
  min-width: 0;
}

.drawer-text small {
  color: var(--muted);
  font-size: 12px;
}

.drawer-item.danger,
.drawer-item.danger svg {
  color: var(--danger);
}

/* on/off switch */
.switch {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--badge-muted);
  transition: background 0.15s ease;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  content: "";
  transition: transform 0.15s ease;
}

.drawer-item[aria-checked="true"] .switch {
  background: var(--brand);
}

.drawer-item[aria-checked="true"] .switch::after {
  transform: translateX(16px);
}

.drawer-foot {
  margin: 0;
  padding: 12px 20px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------ chat info panel */

.info-hero .avatar.big {
  width: 96px;
  height: 96px;
  font-size: 34px;
}

.info-hero h2 {
  font-size: 21px;
}

.info-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 12px 14px;
}

.info-action {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 74px;
  padding: 10px 8px 8px;
  border: 0;
  border-radius: 14px;
  background: var(--side-hover);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.info-action svg {
  width: 22px;
  height: 22px;
  color: var(--brand);
}

.info-action:hover,
.info-action:focus-visible {
  background: color-mix(in srgb, var(--brand) 12%, var(--side-hover));
  outline: none;
}

.info-card {
  margin: 0 12px 10px;
  padding: 4px 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--side-hover);
}

.info-card .drawer-item {
  padding: 8px 14px;
  text-decoration: none;
}

.info-card .drawer-item:hover,
.info-card .drawer-item:focus-visible {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.info-card .drawer-item.static:hover {
  background: transparent;
}

.info-card .drawer-label {
  margin: 10px 14px 4px;
}

.info-card .member-list {
  padding: 0 14px 4px;
}

.info-card .shared-list {
  padding: 8px 10px 6px;
}

.danger-link {
  color: var(--danger);
}

/* Shared: underlined tabs, like Telegram */
.shared-tabs {
  display: flex;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.shared-tab {
  flex: 1;
  min-height: 42px;
  padding: 0 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.shared-tab[aria-pressed="true"] {
  border-bottom-color: var(--brand);
  color: var(--text);
}

/* The chat name in the header: no white frame after a click */
.thread-title:focus {
  outline: none;
}

.thread-title:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* Thin scrollbars everywhere (Windows showed thick grey bars with arrows) */
* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-button {
  display: none;
}

/* Group name: looks like a title, edits in place */
.info-hero .info-title-input {
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 21px;
}

.info-hero .info-title-input:hover {
  border-color: var(--line);
}

.info-hero .info-title-input:focus {
  border-color: var(--brand);
  background: var(--bg);
  outline: none;
}

/* ------------------------------------------------------------------ appearance */

/* On a picture background, small labels get a soft backing so they stay readable */
body.wallpaper-full .day-sep span,
body.wallpaper-full .system-line span,
body.wallpaper-full .unread-sep span {
  background: rgba(12, 12, 14, 0.62);
  color: #f2f3f5;
  backdrop-filter: blur(6px);
}

.avatar.photo {
  overflow: hidden;
  padding: 0;
}

.avatar.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.appearance-body {
  display: grid;
  gap: 4px;
}

.appearance-body .drawer-label {
  margin: 12px 0 6px;
}

.look-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  background: var(--side-hover);
}

.look-profile .avatar.big {
  width: 72px;
  height: 72px;
  font-size: 26px;
}

.look-profile-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.look-profile-text small {
  color: var(--muted);
  font-size: 12px;
}

.look-profile-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.segmented {
  display: flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--side-hover);
}

.segmented button {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.segmented button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.wallpaper-tile {
  position: relative;
  display: grid;
  place-items: end start;
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 12px;
  background-color: var(--thread-bg);
  background-position: center;
}

.wallpaper-tile span {
  margin: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.wallpaper-tile[aria-pressed="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent);
}

.wallpaper-tile.photo-tile {
  place-items: center;
  border-style: dashed;
  border-color: var(--line);
}

.wallpaper-tile.photo-tile[aria-pressed="true"] {
  border-style: solid;
  border-color: var(--brand);
}

.wallpaper-tile.photo-tile svg {
  width: 28px;
  height: 28px;
  color: var(--muted);
}

.wallpaper-tile.photo-tile span {
  position: absolute;
  bottom: 0;
  left: 0;
}

/* ------------------------------------------------------------------ resizable chat list */

.chat-side {
  position: relative;
}

.side-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  z-index: 5;
  width: 6px;
  cursor: col-resize;
}

.side-resizer:hover,
body.resizing .side-resizer {
  background: color-mix(in srgb, var(--brand) 45%, transparent);
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

@media (max-width: 760px) {
  .side-resizer {
    display: none;
  }
}

/* Very narrow: pictures only, like Telegram Desktop */
@media (min-width: 761px) {
  body.side-compact .side-brand div,
  body.side-compact .side-head .icon-btn:not(#menuButton),
  body.side-compact .side-head .sos-btn,
  body.side-compact .side-search,
  body.side-compact .push-banner,
  body.side-compact .conv-body,
  body.side-compact .side-empty {
    display: none;
  }

  body.side-compact .side-head {
    flex-direction: column;
    gap: 8px;
    padding: 10px 0;
  }

  body.side-compact .conv {
    justify-content: center;
    padding: 8px 0;
  }
}

/* ------------------------------------------------------------------ slimmer message box on PC */
@media (pointer: fine) {
  .composer textarea {
    min-height: 40px;
    padding: 9px 14px;
    font-size: 15px;
    line-height: 1.35;
  }

  .composer {
    padding: 6px 10px;
  }
}

/* ------------------------------------------------------------------ settings (Telegram-style) */

.settings-sheet .sheet-frame {
  max-height: min(88vh, 780px);
}

.settings-sheet .sheet-head {
  gap: 8px;
}

.settings-sheet .sheet-head strong {
  flex: 1;
}

.settings-body {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 12px;
}

.settings-page .segmented,
.settings-page .wallpaper-grid,
.settings-page .look-profile {
  margin: 0 18px;
}

.settings-page .drawer-label {
  margin: 14px 20px 6px;
}

.settings-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 18px 10px;
  padding: 14px;
  border-radius: 14px;
  background: var(--side-hover);
}

.settings-hero .avatar.big {
  width: 64px;
  height: 64px;
  font-size: 24px;
}

.settings-hero .drawer-who small {
  color: var(--muted);
}

.drawer-item .chev,
.drawer-item .value {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

.drawer-item .value {
  color: var(--link);
}

.drawer-item .chev svg {
  width: 18px;
  height: 18px;
}

.drawer-item.static {
  cursor: default;
}

.drawer-item.static:hover {
  background: transparent;
}

.settings-sep {
  height: 1px;
  margin: 8px 20px;
  background: var(--line);
}

.settings-hint {
  margin: 10px 20px 4px;
}

.settings-page .look-profile {
  margin-top: 6px;
  margin-bottom: 6px;
}

.drawer-head[role="button"] {
  cursor: pointer;
}

.drawer-head[role="button"]:hover {
  background: var(--head-hover);
}

/* Light bars: the wake-up clock in a darker amber so it stays visible on white */
.thread-head .wake-btn {
  color: color-mix(in srgb, #e8a400 70%, var(--head-ink));
}

/* Picture backgrounds get a soft veil in the theme's colour, so a night scene sits calmly
   behind a light app (and a light one behind a dark app). */
body.wallpaper-full .thread {
  background-image: linear-gradient(var(--wp-veil), var(--wp-veil)), var(--wp-image);
  background-size: cover;
}

/* ---------------------------------------------------------------- bots */

/* Buttons under a bot's message, as in Telegram: full width, rows of equal parts. */
.bot-buttons {
  display: grid;
  gap: 4px;
  margin: 6px 0 2px;
  min-width: min(260px, 100%);
}

.bot-row {
  display: flex;
  gap: 4px;
}

.bot-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 10%, var(--panel));
  color: var(--brand);
  font: inherit;
  font-size: 0.92em;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-btn:hover {
  background: color-mix(in srgb, var(--brand) 18%, var(--panel));
}

.bot-btn.busy {
  opacity: 0.6;
  pointer-events: none;
}

.bot-btn svg {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thread-hello.bot-hello {
  display: grid;
  justify-items: center;
  gap: 6px;
  max-width: 300px;
  padding: 18px 22px;
  color: var(--text);
}

.thread-hello.bot-hello .avatar {
  width: 64px;
  height: 64px;
}

.thread-hello.bot-hello span {
  color: var(--muted);
}

.thread-hello.bot-hello .pill-btn {
  margin-top: 4px;
  min-width: 140px;
}

.bot-item {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.bot-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bot-item .hint {
  margin: 0;
  overflow-wrap: anywhere;
}

.bot-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.92em;
}

.bot-switch small {
  color: var(--muted);
}

.bot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bot-guide {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.bot-guide summary {
  cursor: pointer;
  font-weight: 600;
}

.bot-guide pre,
#botTokenText {
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--side-hover);
  color: var(--text);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The BotFather page sits inside .setup-body, which has its own padding. */
#botsDialog .setup-body {
  overflow-x: hidden;
}

#botForm {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 4px 0 12px;
}

#botForm .field input {
  width: 100%;
  min-width: 0;
}

#botsDialog .sheet-status,
#botsDialog .login-card {
  margin: 8px 0;
}

#botsDialog .sheet-status {
  color: var(--text);
}

@media (max-width: 520px) {
  #botForm {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bot-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #ff8a8a;
  }

  :root:not([data-theme="light"]) .bot-btn:hover {
    background: rgba(255, 255, 255, 0.14);
  }
}

:root[data-theme="dark"] .bot-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #ff8a8a;
}

:root[data-theme="dark"] .bot-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* A table a bot sends (``` block): fixed-width, scrolls sideways instead of wrapping. */
.text .code-block {
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  font: 12.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
}

.text code {
  padding: 0 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  font: 0.92em ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
}

.bot-item code {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--side-hover);
  font: 12px ui-monospace, Consolas, monospace;
}

/* /commands in a bot's message: tap to send, as in Telegram. */
.cmd-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  cursor: pointer;
}

.cmd-link:hover {
  text-decoration: underline;
}

.text code {
  cursor: copy;
}

/* ================================================================ Telegram Desktop sizes (PC)
   The same measurements as Telegram Desktop at 100%: zooming (Ctrl + wheel, see "interface
   scale") scales everything evenly, and the message column stays at most 728 px wide,
   centred - it never stretches across a wide screen. */
@media (min-width: 761px) {
  :root {
    --chat-col: min(100%, 728px);
    --tg-radius: 12px;
  }

  .chat-shell {
    grid-template-columns: var(--side-w, clamp(260px, 26vw, 360px)) 1fr;
  }

  body.info-open .chat-shell {
    grid-template-columns: var(--side-w, clamp(260px, 26vw, 360px)) 1fr minmax(280px, 330px);
  }

  /* header of the chat list */
  .side-head {
    padding-top: 8px;
    padding-bottom: 4px;
  }

  /* chat list: 62 px rows, 46 px pictures, 14 px text */
  .conv-list {
    padding: 0 6px 6px;
  }

  .conv {
    gap: 10px;
    min-height: 62px;
    padding: 8px 10px;
    border-radius: 10px;
  }

  .conv > .avatar {
    width: 46px;
    height: 46px;
    font-size: 16px;
  }

  .conv-title {
    font-size: 14px;
    font-weight: 600;
  }

  .conv-preview {
    font-size: 14px;
  }

  .conv-time {
    font-size: 12px;
  }

  /* chat header: 54 px, 40 px picture */
  .thread-head {
    min-height: 54px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .thread-head .avatar {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  #threadTitle {
    font-size: 15px;
    font-weight: 600;
  }

  #threadSubtitle {
    font-size: 13px;
  }

  /* messages: 15 px text (Settings > Text size), 12 px corners, at most 480 px wide */
  .message-list {
    padding: 0 16px;
  }

  .bubble {
    max-width: min(85%, 480px);
    padding: 5px 9px 6px;
    border-radius: var(--tg-radius);
    font-size: var(--msg-size, 15px);
    line-height: 1.35;
  }

  .meta {
    font-size: 11.5px;
  }

  .composer-row .bot-menu-btn {
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
  }
}

/* ---------------------------------------------------------------- bots, Telegram-style */

/* "What can this bot do?" in an empty chat with a bot */
.bot-hello-pic {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  object-fit: cover;
}

.thread-hello.bot-hello .bot-hello-text {
  color: var(--text);
  text-align: left;
  white-space: pre-wrap;
}

/* "via @bot" (sent with a bot's inline mode) */
.via-bot {
  margin-bottom: 2px;
  color: var(--link);
  font-size: 0.86em;
}

/* the bot's Menu button, left of the message box */
.bot-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  align-self: center;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 18px;
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.bot-menu-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* the "/" command list and inline results, above the message box */
.cmd-list .cmd-option {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.cmd-list .cmd-option strong {
  color: var(--link);
  font-weight: 500;
}

.cmd-list .cmd-option small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-list {
  max-height: 320px;
  overflow-y: auto;
}

.inline-list .inline-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.inline-list .inline-option img,
.inline-list .inline-dot {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 8px;
  background: var(--side-hover);
  object-fit: cover;
}

.inline-list .inline-option span {
  display: grid;
  min-width: 0;
}

.inline-list .inline-option small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-hint {
  margin: 0;
  padding: 10px 14px;
  color: var(--muted);
}

.bot-about {
  white-space: pre-wrap;
}

.label-note {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Interface scale (CSS zoom on the page): screen-sized parts are divided by the scale, so the
   message box stays at the bottom of the window and dialogs fit, at 75% or at 200%. */
:root[style*="zoom"] .chat-shell {
  height: calc(100dvh * var(--uz, 1));
}

:root[style*="zoom"] dialog.sheet,
:root[style*="zoom"] .sheet-frame {
  max-height: min(calc(86dvh * var(--uz, 1)), 760px);
}

:root[style*="zoom"] .settings-sheet .sheet-frame {
  max-height: min(calc(88dvh * var(--uz, 1)), 780px);
}

:root[style*="zoom"] dialog.lightbox {
  width: calc(100vw * var(--uz, 1));
  max-width: calc(100vw * var(--uz, 1));
  height: calc(100dvh * var(--uz, 1));
  max-height: calc(100dvh * var(--uz, 1));
}

:root[style*="zoom"] .lightbox img {
  max-width: calc(100vw * var(--uz, 1));
  max-height: calc(86dvh * var(--uz, 1));
}

@media (min-width: 761px) {
  :root[style*="zoom"] .chat-shell {
    grid-template-columns: var(--side-w, clamp(260px, calc(26vw * var(--uz, 1)), 360px)) 1fr;
  }

  :root[style*="zoom"] body.info-open .chat-shell {
    grid-template-columns: var(--side-w, clamp(260px, calc(26vw * var(--uz, 1)), 360px)) 1fr minmax(280px, 330px);
  }
}

/* ================================================================ message bar, as in Telegram
   One flat bar across the whole chat: menu / attach on the left, the text in the middle,
   emoji and the mic (tap: voice <-> round video, hold: record) on the right. */
.composer {
  padding: 0 0 var(--safe-bottom);
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.composer-row,
.record-bar {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 8px;
}

.composer-row {
  align-items: flex-end;
  gap: 0;
  min-height: 52px;
}

.composer textarea,
.composer textarea:focus {
  min-height: 52px;
  padding: 16px 8px 15px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.35;
  box-shadow: none;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer-row > .icon-btn {
  width: 44px;
  height: 52px;
  flex: none;
  border-radius: 8px;
  color: var(--muted);
}

.composer-row > .icon-btn:hover {
  color: var(--text);
}

/* send and mic: just the icon, like Telegram (send in Gozal red) */
.composer-row > .send-btn {
  width: 48px;
  height: 52px;
  flex: none;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.composer-row > .send-btn:hover {
  background: var(--side-hover);
  color: var(--text);
}

.composer-row > #sendButton {
  color: var(--brand);
}

.composer-row > .send-btn svg {
  width: 24px;
  height: 24px;
}

#micButton {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#micButton .round-icon,
#micButton[data-mode="round"] .mic-icon {
  display: none;
}

#micButton[data-mode="round"] .round-icon {
  display: block;
}

.composer-row .bot-menu-btn {
  align-self: center;
  height: 32px;
  margin-right: 4px;
  padding: 0 10px;
  font-size: 13px;
}

.composer .mention-list {
  width: min(100% - 16px, 860px);
  margin: 6px auto;
}

/* recording: the bar turns into the timer + Cancel / Send */
.record-bar {
  min-height: 52px;
  align-items: center;
}

.record-bar .rec-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the camera, round, while recording a video message */
.round-preview {
  position: absolute;
  bottom: calc(100% + 16px);
  left: 50%;
  z-index: 5;
  width: min(280px, 70vw);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
}

.round-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* a mirror, like the front camera */
}

.composer {
  position: relative;
}

/* a round video message in the chat */
.round-video {
  position: relative;
  display: block;
  width: min(240px, 60vw);
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: #000;
  cursor: pointer;
}

.round-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.round-video .round-time {
  position: absolute;
  bottom: 14%;
  left: 50%;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 12px;
  transform: translateX(-50%);
}

.round-video .round-time:empty {
  display: none;
}

.round-video .round-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
}

.round-video .round-play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 54%;
  border-width: 9px 0 9px 15px;
  border-style: solid;
  border-color: transparent transparent transparent #fff;
  transform: translate(-50%, -50%);
}

.round-video.playing .round-play {
  display: none;
}

.round-video.playing {
  box-shadow: 0 0 0 3px var(--brand);
}

/* no bubble around a round video message - just the circle and the time */
.msg.round-only .bubble {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.msg.round-only .bubble .meta {
  float: none;
  position: static;
  display: inline-block;
  margin: 4px 0 0;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

/* the emoji panel */
.emoji-panel {
  display: grid;
  grid-template-columns: repeat(9, 36px);
  gap: 2px;
  width: max-content;
  max-height: 260px;
  padding: 8px;
  overflow-y: auto;
}

.emoji-panel[hidden] {
  display: none;
}

.emoji-panel button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.emoji-panel button:hover {
  background: var(--side-hover);
}

/* ---- recording, exactly like Telegram: the circle with a white progress ring, and the bar
   with the timer on the left, Cancel in the middle and a big round Send on the right */
.round-preview {
  overflow: visible;
  width: min(300px, 62vw);
  bottom: calc(100% + 24px);
}

.round-preview video {
  border-radius: 50%;
}

.round-ring {
  position: absolute;
  inset: -7px;
  width: calc(100% + 14px);
  height: calc(100% + 14px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.round-ring circle {
  fill: none;
  stroke: #fff;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.1s linear;
}

.record-bar {
  position: relative;
  gap: 12px;
  padding: 0 8px 0 16px;
}

.rec-time {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.record-bar .rec-label {
  flex: 1;
  color: var(--muted);
  text-align: center;
}

.rec-cancel {
  position: absolute;
  left: 50%;
  padding: 6px 12px;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transform: translateX(-50%);
}

.record-bar.held .rec-cancel {
  display: none;
}

.record-bar:not(.held) .rec-label {
  visibility: hidden;
}

.rec-actions {
  position: relative;
  flex: none;
  margin-left: auto;
}

.rec-send {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: -14px 0 -6px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--brand) 22%, transparent);
  cursor: pointer;
}

.rec-send svg,
.rec-pause svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rec-pause {
  position: absolute;
  bottom: calc(100% + 26px);
  left: 50%;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--pop-shadow);
  cursor: pointer;
  transform: translateX(-50%);
}

.rec-pause[hidden],
.rec-pause .resume-icon,
.record-bar.paused .rec-pause .pause-icon {
  display: none;
}

.record-bar.paused .rec-pause .resume-icon {
  display: block;
  fill: var(--brand);
  stroke: none;
}

.record-bar.paused .rec-dot {
  animation: none;
  opacity: 0.4;
}

/* ---- PC: Telegram Desktop's two layouts (body.chat-wide is set by chat.js from the width
   of the chat area). Normal: the conversation across the full width, theirs on the left,
   yours on the right. Wide (880 px and more): the conversation on the left (up to 820 px),
   every message - yours too - at the left edge with its sender's picture. */
@media (min-width: 761px) {
  .message-list {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 18px;
  }

  .msg .bubble {
    max-width: min(100% - 80px, 480px);
  }

  .msg .avatar.small,
  .msg .avatar-space {
    width: 34px;
    height: 34px;
  }

  .msg .avatar-space {
    height: auto;
  }

  body.chat-wide .message-list {
    width: min(100%, 820px);
    padding: 0 16px 0 12px;
  }

  body.chat-wide .msg.mine {
    flex-direction: row;
  }

  body.chat-wide .msg.mine.tail .bubble {
    border-bottom-right-radius: var(--tg-radius, 12px);
    border-bottom-left-radius: 5px;
  }
}

/* While recording: the scroll-down arrow and message buttons step aside for Pause / Send. */
body.recording .jump-bottom,
body.recording .msg-more {
  display: none !important;
}

.rec-pause {
  z-index: 6;
  bottom: calc(100% + 30px);
}

/* PC: the chat list's header and the chat's header are exactly the same height, so their red
   lines meet in one straight line (also with the Info panel open). */
@media (min-width: 761px) {
  .side-head,
  .thread-head,
  .info-head {
    box-sizing: border-box;
    height: 60px;
    min-height: 60px;
    padding-top: 0;
    padding-bottom: 0;
  }
}

@media (display-mode: standalone) and (min-width: 761px) {
  .side-head,
  .thread-head,
  .info-head {
    height: 64px;
    min-height: 64px;
  }
}

/* ================================================================ chat info, as in Telegram
   PC: a window in the middle of the screen over the dimmed chat (the chat list and the chat
   keep their sizes). Phone: a full page, as before. Flat sections with thin dividers, the
   action tiles under the name, count rows (12 photos, 3 files ...), then the members. */
.info-backdrop {
  display: none;
}

.info-head .info-close {
  display: none;
  margin-left: auto;
}

.info-head strong {
  font-size: 16px;
}

.info-hero {
  padding: 18px 16px 12px;
}

.info-hero.compact {
  padding-bottom: 14px;
}

.info-hero h2 {
  font-size: 19px;
  font-weight: 600;
}

.info-hero .avatar.big {
  width: 84px;
  height: 84px;
  font-size: 30px;
}

.info-actions {
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
}

.info-action {
  flex: 1 1 0;
  min-width: 64px;
  max-width: 110px;
  padding: 9px 6px 7px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  font-size: 12.5px;
  font-weight: 500;
}

.info-action:hover,
.info-action:focus-visible {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}

.chat-info .info-card {
  margin: 0;
  padding: 4px 0;
  border-top: 8px solid color-mix(in srgb, var(--text) 5%, transparent);
  border-radius: 0;
  background: transparent;
}

.chat-info .info-card .drawer-item {
  min-height: 44px;
  padding: 6px 20px;
  gap: 22px;
  font-size: 14.5px;
}

.chat-info .info-card .drawer-item svg {
  width: 22px;
  height: 22px;
  color: var(--muted);
  flex: none;
}

.chat-info .info-card .drawer-item.danger,
.chat-info .info-card .drawer-item.danger svg {
  color: var(--danger);
}

.chat-info .info-card .drawer-label {
  margin: 12px 20px 4px;
}

.members-head {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 44px;
  padding: 2px 10px 2px 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.members-head > svg {
  width: 22px;
  height: 22px;
}

.members-head .icon-btn {
  margin-left: auto;
  color: var(--brand);
}

.members-head .icon-btn svg {
  width: 22px;
  height: 22px;
}

.chat-info .info-card .member-list {
  padding: 0 0 6px;
}

.chat-info .member {
  gap: 14px;
  min-height: 52px;
  padding: 5px 12px 5px 18px;
}

.chat-info .member:hover {
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

.chat-info .member .person-name {
  flex: 1;
  min-width: 0;
}

.chat-info .member .person-name strong {
  font-weight: 600;
}

.chat-info .member .person-name small {
  color: var(--muted);
}

.member-badge {
  color: var(--muted);
  font-size: 13px;
}

.member-remove {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  opacity: 0;
}

.member-remove svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.chat-info .member:hover .member-remove,
.member-remove:focus-visible {
  opacity: 1;
}

.member-remove:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

@media (pointer: coarse) {
  .member-remove {
    opacity: 1;
  }
}

.info-shared {
  padding: 10px 12px 16px;
}

.round-grid .shared-tile {
  border-radius: 50%;
}

@media (min-width: 761px) {
  /* the chat keeps its full width: the info is a window above it, not a third column */
  body.info-open .chat-shell {
    grid-template-columns: var(--side-w, clamp(260px, 26vw, 360px)) 1fr;
  }

  :root[style*="zoom"] body.info-open .chat-shell {
    grid-template-columns: var(--side-w, clamp(260px, calc(26vw * var(--uz, 1)), 360px)) 1fr;
  }

  .info-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.45);
    animation: info-fade 0.15s ease-out;
  }

  .chat-info {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 41;
    width: min(440px, calc(100vw - 40px));
    max-height: min(calc(88dvh * var(--uz, 1)), 760px);
    overflow: hidden;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -50%);
    animation: info-pop 0.16s ease-out;
  }

  .chat-info[hidden] {
    display: none;
  }

  /* a plain window title, no red bar */
  .chat-info .info-head {
    height: 54px;
    min-height: 54px;
    padding: 0 8px 0 20px;
    border-bottom: 0;
    background: var(--panel);
    color: var(--text);
  }

  .chat-info .info-head .icon-btn {
    color: var(--muted);
  }

  .chat-info .info-head .icon-btn:hover,
  .chat-info .info-head .icon-btn:focus-visible {
    background: color-mix(in srgb, var(--text) 7%, transparent);
    color: var(--text);
  }

  .chat-info[data-view="main"] .info-back {
    display: none;
  }

  .chat-info[data-view="sub"] .info-head {
    padding-left: 8px;
  }

  .chat-info .info-close {
    display: inline-grid;
  }

  .chat-info .info-body {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: 8px;
  }

  .chat-info .info-hero {
    padding-top: 4px;
  }

  #infoMoreMenu {
    z-index: 60;
  }
}

@keyframes info-fade {
  from { opacity: 0; }
}

@keyframes info-pop {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); }
}

@media (prefers-reduced-motion: reduce) {
  .info-backdrop:not([hidden]),
  .chat-info {
    animation: none;
  }
}

/* ================================================================ main menu, as in Telegram
   Big picture on top with the name under it, then My Profile, then the rest split by thin
   lines - no coloured header. */
.drawer-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: max(26px, env(safe-area-inset-top)) 22px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.drawer-head .avatar {
  width: 64px;
  height: 64px;
  font-size: 24px;
}

.drawer-who strong {
  font-size: 15px;
  font-weight: 600;
}

.drawer-who small {
  color: var(--brand);
  font-size: 13.5px;
}

.drawer-head[role="button"]:hover {
  background: var(--panel);
}

.drawer-head[role="button"]:hover .drawer-who strong {
  text-decoration: underline;
}

.drawer-body {
  padding-top: 8px;
}

.drawer .drawer-item {
  min-height: 50px;
  gap: 26px;
  padding: 8px 24px;
  font-size: 15px;
}

.drawer-sep {
  height: 0;
  margin: 8px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.drawer .drawer-label {
  margin: 10px 24px 2px;
}

.drawer .drawer-item svg {
  color: color-mix(in srgb, var(--text) 72%, transparent);
}

/* ================================================================ reply / edit bar, as in Telegram
   Flat, on the bar's own background: the arrow (or pencil) on the left under the attach
   button, "Reply to Name" and one line of the message, the cross on the right. */
.composer .reply-bar {
  gap: 0;
  width: 100%;
  max-width: none;
  min-height: 50px;
  margin: 0;
  padding: 4px 6px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.reply-bar-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 24px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reply-bar .edit-icon,
.reply-bar.editing .reply-icon {
  display: none;
}

.reply-bar.editing .edit-icon {
  display: block;
}

.composer .reply-bar-text {
  gap: 1px;
  padding: 2px 0 2px 4px;
  border-left: 0;
  font-size: 14px;
  line-height: 1.3;
}

.composer .reply-bar-text strong {
  color: var(--brand);
  font-weight: 600;
}

.composer .reply-bar-text span {
  color: var(--text);
}

.composer .reply-bar.editing .reply-bar-text strong {
  color: var(--brand);
}

.composer .reply-bar .icon-btn {
  margin-left: 6px;
  color: var(--muted);
}

/* the quote inside a message, in the colour of the person it quotes (like the names) */
.quote[style*="--h"] {
  border-left-color: hsl(var(--h) 60% 45%);
  background: hsl(var(--h) 60% 45% / 0.1);
}

.quote[style*="--h"] strong {
  color: hsl(var(--h) 60% 40%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .quote[style*="--h"] {
    border-left-color: hsl(var(--h) 70% 65%);
    background: hsl(var(--h) 70% 65% / 0.12);
  }

  :root:not([data-theme="light"]) .quote[style*="--h"] strong {
    color: hsl(var(--h) 70% 70%);
  }
}

:root[data-theme="dark"] .quote[style*="--h"] {
  border-left-color: hsl(var(--h) 70% 65%);
  background: hsl(var(--h) 70% 65% / 0.12);
}

:root[data-theme="dark"] .quote[style*="--h"] strong {
  color: hsl(var(--h) 70% 70%);
}

/* chat list: group / channel mark before the name, the sender's name in the preview,
   "Draft:" in red - like Telegram */
.conv-kind {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-right: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conv-sender {
  color: var(--text);
}

.conv.active .conv-sender {
  color: inherit;
}

.draft {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--danger);
}

.draft-reply {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* @username in a message: a link to that person's chat */
button.mention {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.mention:hover {
  text-decoration: underline;
}

button.mention.me {
  padding: 0 3px;
}

/* ================================================================ "Update" bar, like Telegram's
   At the bottom of the chat list when a newer version is out. */
.update-bar {
  flex: 0 0 auto;
  width: 100%;
  min-height: 46px;
  padding: 10px 16px calc(10px + var(--safe-bottom, 0px));
  border: 0;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.update-bar[hidden] {
  display: none;
}

.update-bar:hover,
.update-bar:focus-visible {
  background: color-mix(in srgb, var(--brand) 88%, #000);
  outline: none;
}

/* ================================================================ title bar, like Telegram Desktop
   The installed app draws its own title bar (window-controls-overlay): an empty strip in the
   window's colour with only the minimise / maximise / close buttons - no name, no icon. */
.titlebar {
  display: none;
}

@media (display-mode: window-controls-overlay) {
  .titlebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    height: calc(env(titlebar-area-height, 0px) * var(--uz, 1));
    background: var(--titlebar-bg, #ffffff);
    -webkit-app-region: drag;
    app-region: drag;
  }

  body {
    padding-top: calc(env(titlebar-area-height, 0px) * var(--uz, 1));
  }

  .chat-shell,
  :root[style*="zoom"] .chat-shell {
    height: calc((100dvh - env(titlebar-area-height, 0px)) * var(--uz, 1));
  }

  .drawer,
  .drawer-backdrop,
  .info-backdrop:not([hidden]) {
    top: calc(env(titlebar-area-height, 0px) * var(--uz, 1));
  }

  body.signed-out .titlebar {
    background: #050505;
  }
}

:root {
  --titlebar-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --titlebar-bg: #0c0c0e;
  }
}

:root[data-theme="dark"] {
  --titlebar-bg: #0c0c0e;
}

/* job titles (CEO, Head of Dispatch, Safety ...) */
.role-tag.title-tag {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-title {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.admin-person .title-input {
  width: 150px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.admin-person .title-input:focus {
  border-color: var(--brand);
  outline: none;
}

/* small confirm window (Clear history), like Telegram's */
dialog.confirm-sheet {
  width: min(380px, calc(100vw - 32px));
  border-radius: 12px;
}

.confirm-frame {
  display: grid;
  gap: 8px;
  padding: 20px 22px 12px;
}

.confirm-title {
  font-size: 17px;
}

.confirm-text {
  margin: 4px 0 6px;
  font-size: 14.5px;
}

.confirm-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.confirm-frame .check[hidden] {
  display: none;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.confirm-actions .link-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
}

.confirm-actions .link-btn:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

.confirm-actions .danger {
  color: var(--danger);
}

.people-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.people-form > .field,
.people-form .field input,
.people-form .field select {
  min-width: 0;
  max-width: 100%;
}

.people-form .field > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-person .title-input {
  width: 132px;
}

/* People: name on the first line, the job title / access / buttons under it */
.admin-person .person-name {
  flex: 1 0 calc(100% - 56px);
}

.admin-person .title-input {
  margin-left: 52px;
}

.confirm-actions .link-btn {
  text-decoration: none;
}

.admin-person .title-input {
  width: 170px;
}

/* scheduled messages */
.schedule-sheet textarea,
.schedule-when input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  color-scheme: light dark;
}

.schedule-sheet textarea {
  resize: vertical;
}

.schedule-when {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 8px;
}

.schedule-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.schedule-quick .chip {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.schedule-quick .chip:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.confirm-actions .accent {
  color: var(--brand);
}

.scheduled-btn {
  position: relative;
  color: var(--brand) !important;
}

.scheduled-count {
  position: absolute;
  top: 6px;
  right: 4px;
  min-width: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
}

.scheduled-count:empty {
  display: none;
}

.scheduled-list {
  display: grid;
  gap: 8px;
  padding: 12px 16px 16px;
  overflow-y: auto;
}

.scheduled-item {
  padding: 10px 12px 8px;
  border-radius: 12px;
  background: var(--bubble-out, var(--side-hover));
}

.scheduled-when {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.scheduled-body {
  margin: 4px 0 6px;
  white-space: pre-wrap;
  font-size: 15px;
}

.scheduled-actions {
  display: flex;
  gap: 14px;
}

.scheduled-actions .link-btn {
  font-size: 13px;
  text-decoration: none;
  font-weight: 600;
  color: var(--brand);
}

.scheduled-actions .link-btn.danger {
  color: var(--danger);
}

/* polls, like Telegram's */
.poll {
  display: grid;
  gap: 6px;
  min-width: min(300px, 64vw);
  padding: 2px 0 4px;
}

.poll-question {
  font-weight: 700;
  font-size: calc(var(--msg-size, 15px) + 0.5px);
}

.poll-kind {
  margin-top: -4px;
  color: var(--muted);
  font-size: 12.5px;
}

.poll-options-list {
  display: grid;
  gap: 4px;
}

.poll-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.poll-option:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.poll-dot {
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent);
  border-radius: 50%;
}

.poll-option.multi input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.poll-result {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  column-gap: 6px;
  row-gap: 3px;
  padding: 2px 0;
}

.poll-pct {
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.poll-text {
  font-size: var(--msg-size, 15px);
}

.poll-check {
  color: var(--brand);
  font-weight: 700;
}

.poll-bar {
  grid-column: 2;
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
}

.poll-bar span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: color-mix(in srgb, var(--brand) 55%, var(--muted));
}

.poll-result.mine .poll-bar span {
  background: var(--brand);
}

.poll-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  margin-top: 2px;
}

.poll-act {
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.poll-act.subtle {
  color: var(--muted);
  font-weight: 500;
}

.poll-act:hover {
  text-decoration: underline;
}

.poll-sheet input:not([type="checkbox"]) {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.poll-label {
  margin-top: 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
}

.poll-options {
  display: grid;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
}

/* chat folders (tabs above the list), like Telegram's */
.folder-tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.folder-tabs[hidden] {
  display: none;
}

.folder-tabs::-webkit-scrollbar {
  display: none;
}

.folder-tab {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.folder-tab[aria-selected="true"] {
  border-bottom-color: var(--brand);
  color: var(--brand);
}

.folder-tab:hover {
  color: var(--text);
}

.folder-count {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.folder-tab:not([aria-selected="true"]) .folder-count {
  background: var(--badge-muted, var(--muted));
}

.folder-empty {
  padding: 30px 16px;
  color: var(--muted);
  list-style: none;
  text-align: center;
}

/* Archived chats: one row at the top of the list, and a header inside the archive */
.avatar.archive-avatar,
.avatar.saved {
  display: grid;
  place-items: center;
  background: #6f7b8a;
  color: #fff;
}

.avatar.saved {
  background: linear-gradient(135deg, #ec5d63, #c63b44);
}

.avatar.archive-avatar svg,
.avatar.saved svg {
  width: 52%;
  height: 52%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.archive-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 6px;
  list-style: none;
  font-size: 15px;
}

/* Telegram-style formatting */
.text s {
  opacity: 0.8;
}

.spoiler {
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 55%, transparent);
  color: transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.spoiler.shown {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: inherit;
  cursor: text;
}

button.hashtag {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  cursor: pointer;
}

button.hashtag:hover {
  text-decoration: underline;
}

/* voice speed */
.speed-btn {
  margin-left: 8px;
  padding: 0 6px;
  border: 1px solid color-mix(in srgb, var(--muted) 60%, transparent);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  cursor: pointer;
}

/* search in one chat */
.search-scope {
  position: absolute;
  top: 50%;
  right: 8px;
  max-width: 45%;
  overflow: hidden;
  padding: 2px 8px;
  border: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateY(-50%);
  cursor: pointer;
}

.side-search {
  position: relative;
}

body.search-scoped #searchInput {
  padding-right: 130px;
}

body.search-scoped #searchInput::-webkit-search-cancel-button {
  display: none;
}

/* searching: matching chats first, then the messages, in one scroll (like Telegram) */
body.searching .conv-list {
  flex: 0 1 auto;
  max-height: 45%;
}

body.searching .search-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* selecting messages */
.select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 12px 0 6px;
}

.select-bar[hidden] {
  display: none;
}

.select-bar strong {
  flex: 1;
  font-size: 15px;
}

.select-bar .pill-btn[hidden] {
  display: none;
}

body.selecting .composer-row,
body.selecting .composer .reply-bar,
body.selecting .quick-replies {
  display: none !important;
}

body.selecting .msg {
  position: relative;
  cursor: pointer;
}

body.selecting .msg::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 6px;
  width: 20px;
  height: 20px;
  border: 2px solid color-mix(in srgb, var(--muted) 80%, transparent);
  border-radius: 50%;
  transform: translateY(-50%);
}

body.selecting .message-list {
  padding-left: 30px;
}

.msg.selected {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}

body.selecting .msg.selected::before {
  border-color: var(--brand);
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 14px no-repeat;
}

body.selecting .msg-more {
  display: none;
}

/* several pins: marks on the left of the pinned bar */
.pinned-marks {
  display: grid;
  gap: 2px;
  align-self: stretch;
  margin: 4px 0;
}

.pinned-marks:empty {
  display: none;
}

.pinned-marks i {
  display: block;
  width: 2px;
  min-height: 6px;
  border-radius: 1px;
  background: color-mix(in srgb, var(--brand) 35%, transparent);
}

.pinned-marks i.on {
  background: var(--brand);
}

/* online: a green dot on the picture */
.avatar.is-online {
  position: relative;
  overflow: visible;
}

.avatar.is-online::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--side);
  border-radius: 50%;
  background: #2fbf5a;
}

.avatar.is-online img {
  border-radius: 50%;
}

body.selecting .msg::before {
  left: -26px;
}

.pinned-marks {
  display: flex;
  flex-direction: column;
  height: 32px;
  margin: 0 -4px 0 0;
}

.pinned-marks i {
  flex: 1;
  min-height: 0;
  width: 3px;
}

/* ================================================================ chat list, as in Telegram Desktop
   PC: no big header - the top row is the menu (☰) and the search box; the folders are a
   strip on the left with icons, names and unread counts; "new chat" is a round button at
   the bottom. Phone: the header with the name and tabs, as before. */
.folder-icon {
  display: none;
}

@media (max-width: 760px) {
  .side-head {
    flex-wrap: wrap;
  }

  .side-head .side-search {
    flex-basis: 100%;
    order: 3;
    margin: 6px 0 2px;
  }

  .folder-tab .folder-count {
    margin-left: 2px;
  }
}

@media (min-width: 761px) {
  .chat-side {
    position: relative;
  }

  .side-head {
    gap: 6px;
    padding: 0 12px 0 8px;
  }

  .side-brand {
    display: none;
  }

  .side-tools {
    display: contents;
  }

  #menuButton {
    order: -1;
    flex: none;
  }

  .side-head .side-search {
    flex: 1;
    order: 0;
    min-width: 0;
    height: 40px;
    margin: 0;
  }

  #sosButton {
    order: 1;
  }

  /* new chat: a round button over the bottom of the list */
  #newChatButton {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 4;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  }

  #newChatButton:hover,
  #newChatButton:focus-visible {
    background: color-mix(in srgb, var(--brand) 88%, #000);
    color: #fff;
  }

  #newChatButton svg {
    width: 22px;
    height: 22px;
  }

  body:has(#updateBar:not([hidden])) #newChatButton {
    bottom: 62px;
  }

  /* the folder strip */
  body.has-folders .chat-side {
    padding-left: 76px;
  }

  body.has-folders #menuButton {
    position: absolute;
    top: 10px;
    left: 18px;
    z-index: 3;
  }

  body.has-folders .side-head {
    padding-left: 12px;
  }

  .folder-tabs {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    width: 76px;
    flex-direction: column;
    gap: 2px;
    padding: 62px 0 10px;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: color-mix(in srgb, var(--head-bg) 70%, var(--side));
  }

  .folder-tab {
    position: relative;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 100%;
    min-height: 64px;
    padding: 8px 4px;
    border-bottom: 0;
    border-left: 3px solid transparent;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    white-space: normal;
    text-align: center;
    line-height: 1.15;
  }

  .folder-tab:hover {
    background: color-mix(in srgb, var(--text) 5%, transparent);
  }

  .folder-tab[aria-selected="true"] {
    border-bottom: 0;
    border-left-color: var(--brand);
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--brand);
  }

  .folder-icon {
    display: block;
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .folder-tab .folder-count {
    position: absolute;
    top: 5px;
    right: 12px;
    min-width: 18px;
    padding: 0 5px;
    border: 2px solid color-mix(in srgb, var(--head-bg) 70%, var(--side));
    border-radius: 10px;
    font-size: 10.5px;
    line-height: 15px;
  }

  .folder-tab:not([aria-selected="true"]) .folder-count {
    background: var(--brand);
  }
}

@media (min-width: 761px) {
  /* (the strip takes 76 px - the list itself keeps its width) */
  body.has-folders .chat-shell,
  body.has-folders.info-open .chat-shell {
    grid-template-columns: var(--side-w, clamp(336px, calc(26vw + 76px), 436px)) 1fr;
  }

  :root[style*="zoom"] body.has-folders .chat-shell,
  :root[style*="zoom"] body.has-folders.info-open .chat-shell {
    grid-template-columns: var(--side-w, clamp(336px, calc(26vw * var(--uz, 1) + 76px), 436px)) 1fr;
  }
}

@media (min-width: 761px) {
  /* narrowed to pictures only, like Telegram Desktop: the folder strip stays, the pictures
     carry their unread counts, a magnifier on top opens the full list to search */
  body.side-compact.has-folders .chat-shell,
  body.side-compact.has-folders.info-open .chat-shell,
  :root[style*="zoom"] body.side-compact.has-folders .chat-shell,
  :root[style*="zoom"] body.side-compact.has-folders.info-open .chat-shell {
    grid-template-columns: 152px 1fr;
  }

  body.side-compact .side-head {
    justify-content: center;
    padding: 0;
  }

  body.side-compact.has-folders #menuButton {
    position: absolute;
  }

  body.side-compact .side-head #compactSearch.icon-btn {
    display: inline-grid;
  }

  body.side-compact #newChatButton {
    display: none;
  }

  body.side-compact .conv {
    position: relative;
  }

  body.side-compact .compact-badge {
    display: block;
  }
}

#compactSearch,
.compact-badge {
  display: none;
}

#menuButton:not(:hover):not(:focus-visible) {
  background: transparent;
}

.compact-badge {
  position: absolute;
  right: 10px;
  bottom: 6px;
  min-width: 20px;
  padding: 0 5px;
  border: 2px solid var(--side);
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.compact-badge.muted {
  background: var(--badge-muted, #6b7380);
}

.compact-badge.mention {
  right: auto;
  left: 10px;
}

@media (min-width: 761px) {
  /* one red line under the top row, all the way across - lined up with the chat's header */
  .chat-side > .side-head {
    border-bottom: 2px solid var(--gz-red);
  }

  .folder-tabs::before {
    content: "";
    position: absolute;
    top: 58px;
    left: 0;
    width: 76px;
    height: 2px;
    background: var(--gz-red);
  }
}

/* ================================================================ driver card */
dialog.driver-sheet {
  width: min(640px, calc(100vw - 24px));
}

.driver-body {
  overflow-y: auto;
  padding: 0 16px 12px;
}

.driver-hero {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0 -16px 10px;
  padding: 18px 16px 16px;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--hero, #55606e) 85%, #fff 10%), var(--hero, #55606e));
  color: #fff;
  text-align: center;
}

.driver-hero .avatar.big {
  width: 84px;
  height: 84px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
  font-size: 30px;
}

.driver-hero strong {
  font-size: 19px;
}

.driver-hero small {
  opacity: 0.85;
}

.driver-grid {
  display: grid;
  gap: 4px 12px;
}

.driver-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 8px 0 0;
  padding: 8px 0 4px;
  border: 0;
  border-top: 1px solid var(--line);
}

.driver-section legend {
  padding: 0 6px 0 0;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.driver-section .field,
.driver-grid .field {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.driver-section .field input,
.driver-section .field select,
.driver-grid .field textarea {
  width: 100%;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  color-scheme: light dark;
}

.driver-grid .field.wide {
  margin-top: 6px;
}

.driver-section .field input[readonly],
.driver-grid textarea[readonly],
.driver-section select:disabled {
  border-color: transparent;
  background: transparent;
  padding-left: 0;
  opacity: 1;
}

.driver-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 8px 0;
}

.cdl-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
}

.cdl-slot {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.cdl-thumb {
  width: 150px;
  height: 96px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--side-hover);
  cursor: zoom-in;
}

.cdl-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cdl-empty {
  display: grid;
  place-items: center;
  width: 150px;
  height: 96px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.driver-group-make {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
}

.driver-section .link-btn {
  font-size: 13px;
  text-decoration: none;
  color: var(--brand);
  cursor: pointer;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.expiry {
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
}

.expiry.warn {
  background: rgba(232, 164, 0, 0.18);
  color: #c98a00;
}

.expiry.bad {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}

/* Telegram profile rows: the value, its label under it */
.profile-row {
  display: grid;
  gap: 1px;
  padding: 7px 20px;
  color: var(--text);
  font-size: 14.5px;
  text-decoration: none;
}

a.profile-row:hover {
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.profile-row small {
  color: var(--muted);
  font-size: 12.5px;
}

.driver-card .cdl-photos {
  padding: 4px 20px 6px;
}

.driver-card .drawer-item .drawer-text {
  color: var(--brand);
  font-weight: 600;
}

.info-card .side-empty.small {
  margin: 6px 20px;
  font-size: 13px;
  text-align: left;
}

/* a person's Info: a coloured top, like Telegram's profile */
.chat-info .info-hero.colored {
  margin-bottom: 12px;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--hero, #55606e) 80%, #fff 12%), var(--hero, #55606e));
  color: #fff;
}

.chat-info .info-hero.colored small {
  color: rgba(255, 255, 255, 0.85);
}

.chat-info .info-hero.colored .avatar.big {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

@media (min-width: 761px) {
  .chat-info .info-hero.colored {
    padding-top: 14px;
  }
}

/* the driver part of "Add person" */
.driver-fields {
  grid-column: 1 / -1;
}

.driver-fields[hidden] {
  display: none;
}

.driver-details summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
}

.driver-details summary small {
  color: var(--muted);
  font-weight: 400;
}

.driver-pick select {
  max-width: 50%;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

@media (max-width: 520px) {
  .driver-section {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ================================================================ My Profile, like Telegram's Info */
.me-hero {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 14px 16px 12px;
  text-align: center;
}

.me-photo {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.me-photo .avatar.big {
  width: 120px;
  height: 120px;
  font-size: 40px;
}

.me-camera {
  position: absolute;
  right: -2px;
  bottom: 2px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
}

.me-camera svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.me-photo:hover .me-camera {
  background: color-mix(in srgb, var(--brand) 85%, #000);
}

.me-hero strong {
  margin-top: 8px;
  font-size: 18px;
}

.me-status {
  color: var(--brand);
  font-size: 13.5px;
}

.me-hero .link-btn {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.me-bio {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 0;
  padding: 8px 20px;
  border-top: 8px solid color-mix(in srgb, var(--text) 5%, transparent);
}

.me-bio input {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.me-bio input:focus {
  border-bottom-color: var(--brand);
  outline: none;
}

.me-bio span {
  color: var(--muted);
  font-size: 13px;
}

.me-rows {
  border-top: 8px solid color-mix(in srgb, var(--text) 5%, transparent);
}

.me-row {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 48px;
  padding: 6px 20px;
}

.me-row svg {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.me-label {
  flex: 1;
  font-size: 15px;
}

.me-value {
  overflow: hidden;
  max-width: 55%;
  color: var(--brand);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================ emoji panel, like Telegram's */
.emoji-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  width: min(372px, calc(100vw - 16px));
  height: min(430px, 70vh);
  max-height: none;
  padding: 0;
  overflow: hidden;
}

.emoji-search {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  margin: 10px 10px 4px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--side-hover);
  color: var(--muted);
}

.emoji-search svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.emoji-search input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  outline: none;
}

.emoji-scroll,
.emoji-results {
  flex: 1;
  min-height: 0;
  padding: 0 8px 6px;
  overflow-y: auto;
}

.emoji-scroll[hidden],
.emoji-results[hidden] {
  display: none;
}

.emoji-section h4 {
  margin: 10px 4px 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 1px;
}

.emoji-panel .emoji-grid button {
  width: 100%;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.emoji-panel .emoji-grid button:hover {
  background: var(--side-hover);
}

.emoji-tabs {
  display: flex;
  flex: none;
  justify-content: space-between;
  gap: 2px;
  padding: 4px 6px;
  border-top: 1px solid var(--line);
}

.emoji-panel .emoji-tabs button {
  width: 36px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 19px;
  line-height: 1;
  opacity: 0.55;
  filter: grayscale(0.7);
  cursor: pointer;
}

.emoji-panel .emoji-tabs button[aria-pressed="true"],
.emoji-panel .emoji-tabs button:hover {
  background: var(--side-hover);
  opacity: 1;
  filter: none;
}
