/* ============================================================
   手机端独立覆盖层
   电脑端 / iPad 默认不命中 data-device="phone"，保持原本本地版。
   ============================================================ */

.phone-settings-btn {
  display: none;
}

:root:not([data-device="phone"]) #topbarPeekFab,
:root:not([data-device="phone"]) #mobileSettingsFab,
:root:not([data-device="phone"]) #phoneSettingsBtn,
:root:not([data-device="phone"]) #phoneDrawerSettingsBtn,
:root:not([data-device="phone"]) #phoneFloatingSettingsBtn {
  display: none !important;
}

:root[data-device="phone"] {
  --phone-gap: 8px;
  --phone-pad-x: max(10px, env(safe-area-inset-left, 0px));
  --phone-pad-r: max(10px, env(safe-area-inset-right, 0px));
}

:root[data-device="phone"] body {
  overflow: hidden;
  min-height: 100dvh;
}

:root[data-device="phone"] .app {
  width: 100%;
  min-height: 100dvh;
  grid-template-columns: 1fr;
}

:root[data-device="phone"] .chat {
  grid-column: 1;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

:root[data-device="phone"] .chat-titlebar {
  height: 52px;
  padding-left: var(--phone-pad-x);
  padding-right: var(--phone-pad-r);
  gap: 8px;
}

:root[data-device="phone"] .chat-title {
  font-size: 15px;
}

:root[data-device="phone"] .chat-meta {
  font-size: 11.5px;
}

:root[data-device="phone"] .zoom-ctl {
  display: none;
}

:root[data-device="phone"] .top-actions {
  gap: 4px;
}

:root[data-device="phone"] #drawerToggleBtn,
:root[data-device="phone"] #mobileSettingsFab {
  display: none !important;
}

:root[data-device="phone"] #phoneFloatingSettingsBtn {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 42px;
  min-width: 76px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  background: rgba(28, 28, 28, .72);
  color: #f4f6f4;
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
}

:root[data-device="phone"] #phoneFloatingSettingsBtn svg,
:root[data-device="phone"] #phoneDrawerSettingsBtn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:root[data-device="phone"] .conversations.mobile-open ~ .chat #phoneFloatingSettingsBtn,
:root[data-device="phone"] .chat-topbar.peek ~ #phoneFloatingSettingsBtn {
  opacity: .92;
}

:root[data-device="phone"] #phoneDrawerSettingsBtn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 74px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface-3) 78%, transparent);
  color: var(--jade-ink);
  font-size: 13px;
  font-weight: 750;
}

:root[data-device="phone"] .phone-settings-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  min-width: 70px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--wechat-line) 84%, #fff);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--jade-ink);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(10, 20, 16, .10);
}

:root[data-device="phone"] .phone-settings-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:root[data-device="phone"] .phone-settings-btn:active {
  transform: scale(.96);
}

:root[data-device="phone"] .top-action-btn {
  height: 34px;
  padding: 0 9px;
  font-size: 12px;
}

:root[data-device="phone"] .chat-topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--wechat-panel);
  box-shadow: 0 1px 0 var(--wechat-line);
}

:root[data-device="phone"] .chat-topbar:not(.peek) .chat-toolbar {
  display: none;
}

:root[data-device="phone"] .chat-topbar.peek .chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: min(42dvh, 320px);
  overflow: auto;
  padding: 10px var(--phone-pad-r) 12px var(--phone-pad-x);
  border-bottom: 1px solid var(--wechat-line);
  position: static;
}

:root[data-device="phone"] .chat-tool-sep {
  display: none;
}

:root[data-device="phone"] .chat-tool-btn {
  flex: 1 1 calc(33.333% - 7px);
  justify-content: center;
  min-width: 92px;
  height: 38px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 12.5px;
}

:root[data-device="phone"] .messages {
  min-height: 0;
  overflow-y: auto;
  padding: 12px 10px 12px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

:root[data-device="phone"] .msg {
  max-width: 94%;
}

:root[data-device="phone"] .bubble {
  border-radius: 15px;
}

:root[data-device="phone"] .bubble-content {
  font-size: 16px;
  line-height: 1.72;
  word-break: break-word;
}

:root[data-device="phone"] .msg-actions {
  opacity: 1;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

:root[data-device="phone"] .msg-actions::-webkit-scrollbar {
  display: none;
}

:root[data-device="phone"] .msg-action-btn {
  flex: 0 0 auto;
  min-height: 36px;
  min-width: 38px;
  border-radius: 999px;
}

:root[data-device="phone"] .composer {
  position: sticky;
  bottom: 0;
  z-index: 90;
  padding: 8px var(--phone-pad-r) calc(8px + env(safe-area-inset-bottom, 0px)) var(--phone-pad-x);
  border-radius: 16px 16px 0 0;
  background: color-mix(in srgb, var(--wechat-panel) 91%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
  backdrop-filter: blur(14px) saturate(1.12);
  box-shadow: 0 -8px 24px rgba(18, 28, 22, .12);
}

:root[data-device="phone"] .composer-tools {
  min-height: 0;
  gap: 8px;
  overflow: hidden;
}

:root[data-device="phone"] .composer-body,
:root[data-device="phone"] .composer-left,
:root[data-device="phone"] .composer-main {
  width: 100%;
  max-width: none;
}

:root[data-device="phone"] .composer .composer-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  width: 100%;
  max-width: none;
  margin: 0;
}

:root[data-device="phone"] .composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 118px;
  font-size: 16px;
  line-height: 1.45;
  padding: 10px 12px;
  white-space: pre-wrap;
}

:root[data-device="phone"] .composer-tools-toggle {
  display: inline-flex;
}

:root[data-device="phone"] .composer-send-group {
  gap: 6px;
  flex: 0 0 auto;
}

:root[data-device="phone"] .composer-mini {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
}

:root[data-device="phone"] .composer button.primary {
  min-height: 42px;
  min-width: 88px;
  padding: 0 12px;
  border-radius: 14px;
  font-size: 15px;
}

:root[data-device="phone"] .composer:not(.tools-open) .composer-mini {
  display: none;
}

:root[data-device="phone"] .composer.tools-open .composer-mini {
  display: inline-flex;
}

:root[data-device="phone"] .composer:not(.tools-open) .composer-quick,
:root[data-device="phone"] .composer:not(.tools-open) #superComposerBar.sc-bar {
  display: none !important;
}

:root[data-device="phone"] .composer.tools-open .composer-quick,
:root[data-device="phone"] .composer.tools-open #superComposerBar.sc-bar {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

:root[data-device="phone"] .composer.tools-open .composer-quick .quick-btn,
:root[data-device="phone"] .composer.tools-open #superComposerBar .sc-btn {
  min-height: 40px;
  border-radius: 13px;
}

:root[data-device="phone"] .quick-panel {
  right: 0;
  width: min(330px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
}

:root[data-device="phone"] .conversations {
  width: min(84vw, 330px);
}

:root[data-device="phone"] .conversations.mobile-open {
  width: min(86vw, 360px);
}

:root[data-device="phone"] .search-head {
  gap: 8px;
  align-items: center;
}

:root[data-device="phone"] .search-head .search-wrap {
  min-width: 0;
}

:root[data-device="phone"] .conv-list {
  min-height: 44vh;
}

:root[data-device="phone"] .side-empty {
  margin: 28px 14px;
  padding: 22px 14px;
  border: 1px dashed rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.05);
  color: color-mix(in srgb, var(--text) 72%, #fff);
}

:root[data-device="phone"] .side-empty-btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 13px;
}

:root[data-device="phone"] .right-dock {
  position: fixed !important;
  left: 10px !important;
  right: 10px !important;
  bottom: calc(78px + var(--kb-inset, 0px) + env(safe-area-inset-bottom, 0px)) !important;
  width: auto !important;
  max-height: min(32dvh, 230px);
  margin: 0;
  overflow-y: auto;
  z-index: 72;
  pointer-events: none;
}

:root[data-device="phone"] .right-dock > * {
  pointer-events: auto;
}

:root[data-device="phone"] .right-dock #groupBar.group-bar {
  gap: 7px;
  padding: 9px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
  backdrop-filter: blur(14px) saturate(1.12);
}

:root[data-device="phone"] .right-dock #groupBar .group-mode {
  min-height: 34px;
}

:root[data-device="phone"] .right-dock #groupBar .group-go-btn {
  min-height: 40px;
  border-radius: 13px;
}

:root[data-device="phone"] .modal,
:root[data-device="phone"] .float-panel {
  max-width: calc(100vw - 20px);
}

:root[data-device="phone"] .modal-actions {
  gap: 8px;
  flex-wrap: wrap;
}

:root[data-device="phone"] .modal-actions button {
  min-height: 38px;
}

:root[data-device="phone"] #topbarPeekFab {
  display: inline-flex !important;
}
