:root {
  color-scheme: light;
  --keyboard-offset: 0px;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #1e2428;
  --muted: #68757f;
  --line: #dfe5e8;
  --soft: #edf3f2;
  --accent: #167f71;
  --accent-strong: #0f6b5f;
  --danger: #b33a32;
  --bubble-own: #9df29f;
  --bubble-their: #ffffff;
  --shadow: 0 10px 28px rgba(30, 36, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  height: 100vh;
  height: var(--app-height, 100dvh);
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  user-select: none;
}

body.viewer-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.primary {
  background: var(--accent);
  color: #fff;
}

button.primary:not(:disabled):hover {
  background: var(--accent-strong);
}

button.ghost {
  background: #eef2f3;
  color: var(--text);
}

button.danger {
  color: var(--danger);
}

button.small {
  min-height: 32px;
  padding: 0 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

input,
textarea,
select,
[contenteditable]:not([contenteditable="false"]) {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 40px;
  max-height: 120px;
  resize: none;
  padding: 9px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 127, 113, 0.14);
}

.login-page {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(380px, 100%);
}

.login-box {
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-box h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.login-box label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.form-error {
  margin: 0;
  color: var(--danger);
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: 100vh;
  height: var(--app-height, 100dvh);
  min-height: 0;
}

.customer-pane {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.pane-head,
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.pane-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-title-block {
  min-width: 0;
  flex: 1;
}

.back-button {
  display: none;
}

.pane-head h1,
.chat-head h1,
.chat-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.pane-head p,
.chat-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.create-form,
.password-form {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.create-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.pane-actions,
.chat-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pane-actions {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.customer-list {
  overflow: auto;
  padding: 8px;
}

.customer-item {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f8faf9;
  text-align: left;
}

.customer-item.active {
  border-color: rgba(22, 127, 113, 0.38);
  background: var(--soft);
}

.customer-item.unread {
  border-color: rgba(179, 58, 50, 0.42);
  background: #fff7f5;
  box-shadow: inset 3px 0 0 var(--danger);
}

.customer-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.customer-info {
  min-width: 0;
}

.customer-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.customer-name {
  min-width: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.customer-time {
  align-self: start;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.customer-last {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pane,
.customer-chat {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--bg);
}

.customer-chat {
  width: min(820px, 100%);
  height: 100vh;
  height: var(--app-height, 100dvh);
  min-height: 0;
  margin: 0 auto;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--bg);
}

.messages {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  background: #ededed;
  padding: 18px;
  padding-bottom: calc(18px + var(--keyboard-offset));
  scroll-padding-bottom: calc(96px + var(--keyboard-offset));
  -webkit-overflow-scrolling: touch;
}

.messages.empty-state {
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.history-loader {
  display: flex;
  justify-content: center;
  padding: 2px 0 6px;
}

.history-loader button {
  min-height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef2f3;
  color: var(--muted);
  font-size: 13px;
}

.new-message-tip {
  position: sticky;
  right: 18px;
  bottom: 12px;
  align-self: flex-end;
  margin: 0 0 -42px;
  z-index: 8;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(22, 127, 113, 0.94);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.new-message-tip[hidden] {
  display: none;
}

.message-row {
  display: flex;
  width: 100%;
  align-items: flex-end;
  gap: 6px;
}

.message-row.own {
  justify-content: flex-end;
}

.message-row.their {
  justify-content: flex-start;
}

.message-bubble {
  max-width: min(70%, 620px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bubble-their);
  box-shadow: 0 2px 8px rgba(30, 36, 40, 0.04);
  overflow-wrap: anywhere;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  user-select: none;
}

.message-row.own .message-bubble {
  border-color: #c9e8dc;
  background: var(--bubble-own);
}

.message-bubble.image-bubble,
.message-bubble.pending-image-bubble {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.message-content {
  padding: 10px 12px;
  font-size: 18px;
  white-space: pre-wrap;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.image-bubble .message-content,
.pending-image-bubble .message-content {
  padding: 0;
}

.message-content img {
  display: block;
  max-width: min(180px, 39vw);
  max-height: 240px;
  border-radius: 6px;
  object-fit: contain;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  cursor: zoom-in;
  user-select: none;
}

.pending-image {
  position: relative;
  display: inline-block;
}

.pending-audio {
  position: relative;
  display: block;
}

.pending-image img {
  opacity: 0.82;
}

.upload-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.upload-progress {
  --progress-deg: 0deg;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(0, 0, 0, 0.42) 0 48%, transparent 50%),
    conic-gradient(#ffffff var(--progress-deg), rgba(255, 255, 255, 0.34) 0);
}

.upload-retry {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(30, 36, 40, 0.84);
  color: #fff;
}

.upload-retry[hidden],
.upload-progress[hidden] {
  display: none;
}

.upload-failed .pending-image img {
  opacity: 0.64;
}

.upload-failed .pending-audio .voice-message {
  opacity: 0.64;
}

.message-content.voice-content {
  padding: 0;
  white-space: normal;
}

.voice-message {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(28px, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 126px;
  max-width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
}

.voice-message:active {
  background: rgba(30, 36, 40, 0.06);
}

.voice-message.voice-unread::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f04438;
  transform: translateY(-50%);
}

.voice-icon {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.voice-bars {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.voice-bars i {
  display: block;
  width: 3px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.38;
}

.voice-bars i:nth-child(2n) {
  height: 13px;
}

.voice-bars i:nth-child(3n) {
  height: 18px;
}

.voice-message.playing .voice-bars i {
  animation: voicePulse 0.8s ease-in-out infinite;
}

.voice-message.playing .voice-bars i:nth-child(2n) {
  animation-delay: 0.08s;
}

.voice-message.playing .voice-bars i:nth-child(3n) {
  animation-delay: 0.16s;
}

.voice-duration {
  min-width: 24px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

@keyframes voicePulse {
  0%,
  100% {
    transform: scaleY(0.55);
    opacity: 0.32;
  }

  50% {
    transform: scaleY(1);
    opacity: 0.78;
  }
}

.message-meta {
  flex-shrink: 0;
  padding: 0 0 6px;
  color: #a5adb3;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.recalled {
  color: var(--muted);
  font-style: italic;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #f6f6f6;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  transform: translateY(calc(-1 * var(--keyboard-offset)));
}

.composer.no-record {
  grid-template-columns: auto minmax(120px, 1fr) auto;
}

.composer .tool {
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.composer .tool:not(:disabled):hover {
  background: #f5f7f7;
}

.composer .tool:not(:disabled):active {
  background: #a6a6a6;
}

.composer .send {
  background: #00c375;
  color: #fff;
}

.composer .send:not(:disabled):hover {
  background: #00ad68;
}

.composer .record {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.composer .record.recording {
  background: #00c375;
  color: #fff;
}

.record-status {
  min-height: 0;
  height: 0;
  overflow: hidden;
  padding: 0 16px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  flex-shrink: 0;
  transform: translateY(calc(-1 * var(--keyboard-offset)));
}

.record-status:not(:empty) {
  min-height: 24px;
  height: auto;
  padding: 0 16px 6px;
}

.admin-drawer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(30, 36, 40, 0.34);
}

.admin-drawer[hidden] {
  display: none;
}

.admin-drawer-panel {
  width: min(520px, 100%);
  max-height: min(680px, calc(var(--app-height, 100dvh) - 36px));
  overflow: auto;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 20px;
}

.forward-panel {
  display: flex;
  flex-direction: column;
}

.forward-list {
  display: grid;
  gap: 6px;
  overflow: auto;
  padding: 10px;
}

.forward-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.forward-item input {
  width: 18px;
  height: 18px;
}

.forward-item-main {
  min-width: 0;
}

.forward-item-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forward-item-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forward-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.forward-actions > div {
  display: flex;
  gap: 8px;
}

.record-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: 1fr auto auto;
  justify-items: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  pointer-events: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.record-overlay[hidden] {
  display: none;
}

.record-panel {
  align-self: center;
  display: grid;
  width: min(280px, 76vw);
  min-height: 104px;
  place-items: center;
  padding: 24px;
  border-radius: 18px;
  background: #8eea62;
  color: rgba(30, 36, 40, 0.72);
  box-shadow: var(--shadow);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.record-overlay.cancel .record-panel {
  background: #f05b50;
  color: #fff;
}

.record-wave {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.record-wave i {
  display: block;
  width: 4px;
  height: 14px;
  border-radius: 999px;
  background: currentColor;
  animation: recordWave 0.8s ease-in-out infinite;
}

.record-wave i:nth-child(2n) {
  height: 20px;
  animation-delay: 0.06s;
}

.record-wave i:nth-child(3n) {
  height: 28px;
  animation-delay: 0.12s;
}

.record-cancel-target {
  margin-bottom: 24px;
  padding: 14px 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.record-overlay.cancel .record-cancel-target {
  background: rgba(240, 91, 80, 0.88);
  color: #fff;
}

.record-release-target {
  width: min(520px, 100%);
  padding: 22px;
  border-radius: 999px 999px 0 0;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.record-overlay.cancel .record-release-target {
  color: var(--danger);
}

@keyframes recordWave {
  0%,
  100% {
    transform: scaleY(0.48);
  }

  50% {
    transform: scaleY(1);
  }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(30, 36, 40, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
}

.message-menu {
  position: fixed;
  z-index: 50;
  display: grid;
  min-width: 112px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.message-menu[hidden] {
  display: none;
}

.customer-action-menu {
  position: fixed;
  z-index: 55;
  display: grid;
  min-width: 132px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.customer-action-menu[hidden] {
  display: none;
}

.customer-action-menu button {
  border-radius: 0;
  background: #fff;
  text-align: left;
}

.customer-action-menu button:hover {
  background: var(--soft);
}

.image-source-menu {
  position: fixed;
  z-index: 55;
  display: grid;
  min-width: 120px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-source-menu[hidden] {
  display: none;
}

.image-source-menu button,
.image-source-menu .image-source-choice {
  position: relative;
  display: block;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  line-height: 40px;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
}

.image-source-menu button:hover,
.image-source-menu .image-source-choice:hover {
  background: var(--soft);
}

.image-source-menu .image-source-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.message-menu button {
  border-radius: 0;
  background: #fff;
  text-align: left;
}

.message-menu button:hover {
  background: var(--soft);
}

.image-viewer {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.94);
  color: #fff;
  touch-action: none;
}

.image-viewer[hidden] {
  display: none;
}

.image-viewer-stage {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

.image-viewer-track {
  display: flex;
  height: 100%;
  will-change: transform;
  transition: transform 0.22s ease-out;
}

.image-viewer-track.dragging {
  transition: none;
}

.image-viewer-cell {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
}

.image-viewer-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  cursor: grab;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.image-viewer-img:active {
  cursor: grabbing;
}

.image-viewer-canvas {
  position: absolute;
  z-index: 2;
  display: block;
  max-width: none;
  max-height: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.image-viewer-canvas[hidden] {
  display: none;
}

.image-viewer-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  border: 5px solid rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  background-clip: padding-box;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: imageViewerSpin 0.8s linear infinite;
}

.image-viewer-loading[hidden] {
  display: none;
}

@keyframes imageViewerSpin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.pswp__img {
  -webkit-touch-callout: none;
}

.pswp__top-bar,
.pswp__button--arrow {
  display: none !important;
}

.pswp-loading-indicator {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 100002;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.pswp-loading-indicator[hidden] {
  display: none;
}

.pswp-loading-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pswpLoadingSpin 0.8s linear infinite;
}

.pswp-share-button {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(17px, calc(env(safe-area-inset-bottom) - 5px));
  z-index: 100003;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  height: auto;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: #a3a3a3;
  color: #ffffff;
  font: 700 16px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.pswp-share-button:active {
  background: #8f8f8f;
}

.pswp-share-button:disabled {
  opacity: 0.58;
}

@keyframes pswpLoadingSpin {
  to {
    transform: rotate(360deg);
  }
}

.invalid-link {
  display: grid;
  min-height: 100vh;
  place-content: center;
  padding: 24px;
  text-align: center;
}

.invalid-link h1 {
  margin: 0 0 8px;
}

@media (max-width: 780px) {
  .admin-layout {
    grid-template-columns: 1fr;
    height: 100vh;
    height: var(--app-height, 100dvh);
    min-height: 0;
    overflow: hidden;
  }

  .customer-pane {
    height: 100vh;
    height: var(--app-height, 100dvh);
    min-height: 0;
    border-right: 0;
    border-bottom: 0;
  }

  .chat-pane {
    display: none;
    height: 100vh;
    height: var(--app-height, 100dvh);
    min-height: 0;
  }

  body.admin-chat-open .customer-pane {
    display: none;
  }

  body.admin-chat-open .chat-pane {
    display: flex;
  }

  .back-button {
    display: inline-flex;
    align-items: center;
  }

  .chat-head {
    align-items: center;
  }

  .chat-head-actions {
    flex: 0 0 auto;
  }

  .pane-head,
  .chat-head {
    gap: 8px;
    min-height: 40px;
    padding: 4px 10px;
  }

  .pane-head button,
  .chat-head button {
    min-height: 32px;
    padding: 0 9px;
  }

  .customer-head > div,
  .pane-head > div:first-child {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 10px;
  }

  .customer-head h1,
  .pane-head h1 {
    flex: 0 0 auto;
  }

  .customer-head h1,
  .pane-head h1,
  .chat-head h2 {
    font-size: 18px;
  }

  .customer-head p,
  .pane-head p,
  .chat-head p {
    margin: 0;
    line-height: 1.2;
    font-size: 12px;
  }

  .create-form {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .pane-actions,
  .password-form {
    padding: 10px 12px;
  }

  .messages {
    padding: 12px;
    padding-bottom: calc(12px + var(--keyboard-offset));
    scroll-padding-bottom: calc(76px + var(--keyboard-offset));
  }

  .message-bubble {
    max-width: calc(100% - 58px);
  }

  .message-meta {
    padding-bottom: 5px;
    font-size: 11px;
  }

  .composer {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "input input send"
      "image record record";
    align-items: stretch;
    gap: 5px 6px;
    padding: 6px 8px;
  }

  .composer button {
    font-size: 17px;
    min-height: 38px;
    padding: 0 8px;
  }

  .composer #imageBtn,
  .composer .send {
    min-height: 38px;
    padding: 0 14px;
  }

  .composer .send {
    padding: 0 18px;
  }

  .composer.no-record {
    grid-template-columns: auto minmax(80px, 1fr) auto;
    grid-template-areas: "image input send";
  }

  .composer #imageBtn {
    grid-area: image;
  }

  .composer textarea {
    grid-area: input;
    font-size: 17px;
    min-height: 38px;
    padding: 8px 10px;
  }

  .image-source-menu {
    min-width: 148px;
  }

  .image-source-menu button,
  .image-source-menu .image-source-choice {
    min-height: 44px;
    padding: 0 16px;
    font-size: 17px;
    line-height: 44px;
  }

  .composer .record {
    grid-area: record;
  }

  .composer .send {
    grid-area: send;
  }

  .record-status:not(:empty) {
    padding-bottom: 4px;
  }

  .customer-chat {
    width: 100%;
    height: 100vh;
    height: var(--app-height, 100dvh);
    min-height: 0;
    border: 0;
  }

  .admin-drawer {
    align-items: end;
    padding: 10px;
  }

  .admin-drawer-panel {
    max-height: calc(var(--app-height, 100dvh) - 20px);
    border-radius: 10px 10px 0 0;
  }
}

@media (max-width: 420px) {
  body {
    font-size: 14px;
  }

  button {
    min-height: 36px;
    padding: 0 10px;
  }

  .message-content img {
    width: auto;
    max-width: min(168px, 39vw);
  }

  .chat-head-actions {
    justify-content: flex-end;
  }
}
