/* 手机端美洽风格后台 */
:root {
  --mob-primary: #15c292;
  --mob-primary-light: #e8f9f6;
  --mob-bg: #f0f2f5;
  --mob-card: #fff;
  --mob-text: #1f2329;
  --mob-muted: #8b9298;
  --mob-border: #e8eaed;
  --mob-nav-h: 56px;
  --mob-safe-b: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 768px) {
  body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
  body.login-mode { overflow: auto; }

  .login-wrap {
    margin: 48px 16px;
    max-width: none;
    border-radius: 16px;
  }

  .mq-icon-nav { display: none !important; }

  .mq-admin-shell {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-bottom: calc(var(--mob-nav-h) + var(--mob-safe-b));
    background: var(--mob-bg);
  }

  .mq-content { flex: 1; min-height: 0; background: var(--mob-bg); display: flex; flex-direction: column; overflow: hidden; }

  /* 底部导航 */
  .mq-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--mob-nav-h) + var(--mob-safe-b));
    padding-bottom: var(--mob-safe-b);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--mob-border);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .06);
  }
  .mq-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--mob-muted);
    font-size: 11px;
    font-weight: 500;
    position: relative;
    padding-top: 6px;
    transition: color .2s;
  }
  .mq-bottom-nav a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 28px;
    height: 3px;
    background: var(--mob-primary);
    border-radius: 0 0 3px 3px;
    transition: transform .2s;
  }
  .mq-bottom-nav a.active { color: var(--mob-primary); }
  .mq-bottom-nav a.active::before { transform: translateX(-50%) scaleX(1); }
  .mq-bottom-nav a .mq-nav-icon {
    font-size: 24px;
    line-height: 1;
    filter: grayscale(0.3);
    transition: filter .2s, transform .2s;
  }
  .mq-bottom-nav a.active .mq-nav-icon {
    filter: none;
    transform: scale(1.05);
  }
  .mq-bottom-nav a.admin-only { display: none; }
  body.is-admin .mq-bottom-nav a.admin-only { display: flex; }
  .mq-bottom-nav .mq-nav-badge {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 10px;
    min-width: 17px;
    height: 17px;
    line-height: 17px;
    padding: 0 5px;
    background: linear-gradient(135deg, #ff6b6b, #ff4d4f);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 9px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(255, 77, 79, .4);
  }

  body.mode-workbench .main-inner { display: none !important; }
  body.mode-mobile-panel .wb-panel { display: none !important; }

  /* 手机子页面互斥：我的 / 管理页 二选一 */
  body.mode-mobile-panel .main-inner,
  body.mode-mobile-panel #panel-mine { display: none !important; }

  body.mobile-view-mine #panel-mine.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--mob-nav-h) + 16px);
  }
  body.mobile-view-mine .main-inner { display: none !important; }

  body.mobile-view-admin .main-inner {
    display: block !important;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--mob-nav-h) + 8px);
  }
  body.mobile-view-admin #panel-mine { display: none !important; }

  .mob-sub-header {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--mob-border);
    flex-shrink: 0;
  }
  body.mobile-view-admin .mob-sub-header { display: flex; }
  .mob-sub-header__back {
    width: 36px;
    height: 36px;
    border: none;
    background: #f0f2f5;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    color: var(--mob-text);
    cursor: pointer;
  }
  .mob-sub-header__title {
    font-size: 17px;
    font-weight: 600;
    color: var(--mob-text);
  }

  .wb-panel { flex-direction: column; position: relative; background: var(--mob-bg); }

  .wb-conv {
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 2;
    background: var(--mob-bg);
    border-right: none;
  }

  .wb-conv__head--mob {
    background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
    padding: 16px 16px 12px !important;
    border-bottom: none;
    box-shadow: 0 1px 0 var(--mob-border);
  }
  .wb-conv__head--mob h3 {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: var(--mob-text) !important;
    margin: 0 !important;
  }
  .wb-conv__queue {
    margin: 6px 0 0;
    font-size: 12px;
    color: #ff7875;
    font-weight: 500;
    display: none;
  }

  .wb-conv__tabs {
    margin: 12px 16px;
    padding: 4px;
    background: #e8eaed;
    border-radius: 10px;
    border-bottom: none !important;
  }
  .wb-conv__tabs button {
    border-radius: 8px !important;
    border-bottom: none !important;
    margin-bottom: 0 !important;
    font-weight: 500;
    color: var(--mob-muted);
    padding: 10px 8px !important;
  }
  .wb-conv__tabs button.active {
    background: #fff !important;
    color: var(--mob-primary) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  }

  .wb-conv__list { padding: 0 12px 12px; }

  .wb-conv__item {
    margin-bottom: 8px;
    border-radius: 12px;
    border: 1px solid transparent;
    border-left: none !important;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
    padding: 14px 12px !important;
  }
  .wb-conv__item:active { transform: scale(0.99); }
  .wb-conv__item.active {
    background: var(--mob-primary-light) !important;
    border-color: rgba(21, 194, 146, .35) !important;
    box-shadow: 0 2px 12px rgba(21, 194, 146, .15);
  }
  .wb-conv__av {
    width: 44px !important;
    height: 44px !important;
    font-size: 16px !important;
    background: linear-gradient(135deg, #e6f7ff, #bae7ff) !important;
  }
  .wb-conv__name { font-size: 15px !important; font-weight: 600 !important; }
  .wb-conv__preview { font-size: 13px !important; margin-top: 6px !important; }
  .wb-badge {
    font-size: 11px;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    border-radius: 10px;
  }

  .wb-conv__empty {
    list-style: none;
    text-align: center;
    padding: 60px 24px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: default;
  }
  .wb-conv__empty-icon {
    font-size: 48px;
    opacity: 0.35;
    margin-bottom: 12px;
  }
  .wb-conv__empty p {
    font-size: 16px;
    color: var(--mob-text);
    font-weight: 500;
    margin-bottom: 6px;
  }
  .wb-conv__empty span {
    font-size: 13px;
    color: var(--mob-muted);
  }

  .wb-chat {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    background: #f5f6f8;
  }
  .wb-panel.chat-open .wb-chat {
    transform: translateX(0);
    z-index: 3;
    box-shadow: -4px 0 24px rgba(0, 0, 0, .1);
  }
  .wb-panel.chat-open .wb-conv {
    transform: translateX(-20%);
    opacity: 0.5;
    pointer-events: none;
  }

  .wb-side { display: none !important; }
  .wb-menu-btn { display: none !important; }

  .wb-back-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 4px;
    padding: 0;
    border: none;
    background: #f0f2f5;
    border-radius: 50%;
    font-size: 22px;
    font-weight: 300;
    color: var(--mob-text);
    cursor: pointer;
    line-height: 1;
  }

  .wb-chat__head {
    padding: 10px 12px !important;
    background: #fff;
    box-shadow: 0 1px 0 var(--mob-border);
  }
  .wb-chat__title { font-size: 16px !important; }
  .wb-chat__actions button {
    padding: 6px 12px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
  }
  .wb-compose-wrap {
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .04);
  }

  /* 我的 */
  .mq-mobile-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--mob-bg);
    -webkit-overflow-scrolling: touch;
  }

  .mob-profile {
    background: linear-gradient(135deg, #15c292 0%, #36cfc9 50%, #69c0ff 100%);
    padding: 24px 20px 32px;
    color: #fff;
    flex-shrink: 0;
  }
  .mob-profile__row { display: flex; align-items: center; gap: 16px; }
  .mob-profile__av {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .3);
    border: 3px solid rgba(255, 255, 255, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    color: #fff;
  }
  .mob-profile__av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .mob-profile__av:active { opacity: .85; }
  .mob-profile__hint {
    font-size: 12px;
    opacity: .85;
    margin-top: 6px;
  }
  .mob-profile__name { font-size: 20px; font-weight: 700; }
  .mob-profile__status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: .95;
    margin-top: 6px;
    background: rgba(255, 255, 255, .2);
    padding: 4px 10px;
    border-radius: 12px;
  }
  .mob-profile__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b7eb8f;
    box-shadow: 0 0 6px #b7eb8f;
  }

  .mob-menu {
    margin: 0 16px 24px;
    background: var(--mob-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .08);
    flex-shrink: 0;
  }
  .mob-menu a.admin-only { display: none; }
  body.is-admin .mob-menu a.admin-only { display: flex; }

  .mob-menu a, .mob-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 18px;
    border: none;
    background: #fff;
    border-bottom: 1px solid #f5f6f7;
    font-size: 15px;
    color: var(--mob-text);
    text-decoration: none;
    cursor: pointer;
    text-align: left;
  }
  .mob-menu a:active, .mob-menu button:active { background: #fafafa; }
  .mob-menu a:last-child, .mob-menu button:last-child { border-bottom: none; }
  .mob-menu .mob-menu__arrow { color: #d9d9d9; font-size: 20px; font-weight: 300; }
  .mob-menu__section {
    padding: 10px 18px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--mob-muted);
    background: #f5f6f7;
    border-bottom: 1px solid #f0f0f0;
    letter-spacing: 0.02em;
  }
  .mob-menu__section.admin-only { display: none; }
  body.is-admin .mob-menu__section.admin-only { display: block; }
  .mob-menu__logout { color: #ff4d4f !important; font-weight: 500; }

  .mob-rating { display: none; margin-bottom: 8px; }
  .mob-rating__summary {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 14px;
  }
  .mob-rating__avg { font-size: 28px; font-weight: 700; color: var(--mob-primary); line-height: 1.1; }
  .mob-rating__avg--sub { color: #666; font-size: 22px; }
  .mob-rating__hint { font-size: 12px; color: var(--mob-muted); margin-top: 4px; }
  .mob-rating__count { font-size: 12px; color: var(--mob-muted); margin-left: auto; }
  .mob-rating__row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
  }
  .mob-rating__row > span:first-child { width: 28px; flex-shrink: 0; color: var(--mob-muted); }
  .mob-rating__track {
    flex: 1;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
  }
  .mob-rating__fill {
    height: 100%;
    background: linear-gradient(90deg, #69c0ff, var(--mob-primary));
    border-radius: 4px;
  }
  .mob-rating__n { width: 24px; text-align: right; font-size: 12px; color: var(--mob-muted); }

  .desktop-dashboard { display: none !important; }
  .mobile-dashboard { display: block !important; }

  .main-inner {
    padding: 0 !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--mob-bg);
  }
  .main-inner > .panel.active {
    padding: 12px 16px 24px;
  }
  body.mobile-view-admin .main-inner > .panel.active > h2:first-child {
    display: none;
  }
  body.mobile-view-admin .mob-history-wrap > h2 { display: none; }
  .main-inner > .panel.active > h2 {
    margin: 0 0 12px;
    font-size: 17px;
  }
  .main-inner .form-box { max-width: none; border-radius: 12px; margin-bottom: 16px; }

  #panel-mine { flex: 1; min-height: 0; }

  .mobile-dashboard { display: none; padding-bottom: 20px; }

  .mob-dash-header {
    background: var(--mob-card);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  .mob-dash-header__user { display: flex; align-items: center; gap: 12px; }
  .mob-dash-header__av {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--mob-primary-light);
    color: var(--mob-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
  }
  .mob-dash-header__av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .mob-dash-header__name { font-size: 16px; font-weight: 600; }
  .mob-dash-header__online { font-size: 12px; color: #52c41a; margin-top: 2px; }

  .mob-scope-toggle {
    display: flex;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 3px;
  }
  .mob-scope-toggle button {
    border: none;
    background: transparent;
    padding: 7px 16px;
    font-size: 13px;
    border-radius: 18px;
    color: #666;
    cursor: pointer;
  }
  .mob-scope-toggle button.active {
    background: #fff;
    color: var(--mob-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    font-weight: 500;
  }

  .mob-date-bar {
    background: var(--mob-card);
    padding: 12px 16px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
  }
  .mob-date-bar label { font-size: 14px; color: var(--mob-muted); font-weight: 500; }
  .mob-date-bar input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--mob-border);
    border-radius: 10px;
    font-size: 14px;
    background: #fafbfc;
  }

  .mob-section {
    background: var(--mob-card);
    margin: 0 16px 12px;
    border-radius: 16px;
    padding: 16px 14px 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .04);
  }
  .mob-section__title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--mob-text);
  }

  .mob-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .mob-metric {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 10px;
    border-radius: 12px;
    background: #fafbfc;
    border: 1px solid #f0f0f0;
  }
  .mob-metric__icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
  }
  .mob-metric__icon--blue { background: #e6f7ff; }
  .mob-metric__icon--green { background: #f6ffed; }
  .mob-metric__icon--orange { background: #fff7e6; }
  .mob-metric__icon--purple { background: #f9f0ff; }
  .mob-metric__val { font-size: 22px; font-weight: 700; color: var(--mob-text); line-height: 1.2; }
  .mob-metric__label { font-size: 12px; color: var(--mob-muted); margin-top: 4px; }

  .mob-trend {
    margin: 0 16px 16px;
    background: var(--mob-card);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .04);
  }
  .mob-trend__title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
  .mob-trend__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12px;
    color: var(--mob-muted);
    margin-bottom: 14px;
  }
  .mob-trend__legend span { display: flex; align-items: center; gap: 6px; }
  .mob-trend__dot { width: 8px; height: 8px; border-radius: 50%; }
  .mob-trend__chart {
    height: 140px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 4px 0;
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
    border-radius: 10px;
  }
  .mob-trend__bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .mob-trend__bar {
    width: 100%;
    max-width: 24px;
    border-radius: 6px 6px 0 0;
    min-height: 6px;
  }
  .mob-trend__bar--conv { background: linear-gradient(180deg, #52c41a, #95de64); }
  .mob-trend__bar--vis { background: linear-gradient(180deg, #1890ff, #69c0ff); }
  .mob-trend__label { font-size: 10px; color: #bbb; }

  .mob-history-wrap { padding: 12px 16px; }
  .mob-history-wrap h2 { display: none; }

  /* 管理页：工具栏、表格、说明文字 */
  body.mobile-view-admin .main-inner > .panel.active > p {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 12px;
  }
  body.mobile-view-admin .main-inner .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }
  body.mobile-view-admin .main-inner .toolbar .btn,
  body.mobile-view-admin .main-inner .toolbar .btn-primary {
    width: 100%;
    justify-content: center;
  }
  body.mobile-view-admin .main-inner .toolbar input,
  body.mobile-view-admin .main-inner .toolbar select,
  body.mobile-view-admin .main-inner .toolbar a.btn {
    max-width: none !important;
    width: 100%;
  }
  body.mobile-view-admin .main-inner table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
    border-radius: 12px;
    background: var(--mob-card);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .04);
  }
  body.mobile-view-admin .main-inner table thead,
  body.mobile-view-admin .main-inner table tbody {
    display: table;
    min-width: 520px;
  }
  body.mobile-view-admin .main-inner table th,
  body.mobile-view-admin .main-inner table td {
    padding: 10px 8px;
    white-space: nowrap;
  }
  body.mobile-view-admin .main-inner table .btn {
    padding: 4px 8px;
    font-size: 12px;
    margin: 2px 0;
  }
  body.mobile-view-admin .main-inner .pager {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
  }
  body.mobile-view-admin .main-inner .pager .btn { flex: 1; min-width: 100px; }
  body.mobile-view-admin #panel-auto hr {
    margin: 20px 0;
  }
  body.mobile-view-admin #panel-auto h3 {
    font-size: 16px;
    margin: 0 0 8px;
  }
  body.mobile-view-admin #panel-settings .form-box label {
    font-size: 14px;
  }
  body.mobile-view-admin #panel-settings .form-box input,
  body.mobile-view-admin #panel-settings .form-box textarea,
  body.mobile-view-admin #panel-settings .form-box select {
    font-size: 16px;
  }
  body.mobile-view-admin #panel-settings .form-box .btn {
    width: 100%;
    margin-bottom: 8px;
  }
  body.mobile-view-admin #panel-telegram .form-box .btn {
    width: 100%;
    margin-bottom: 8px;
  }

  .mob-history-wrap .toolbar { flex-direction: column; gap: 10px; }
  .mob-history-wrap .toolbar input,
  .mob-history-wrap .toolbar select,
  .mob-history-wrap .toolbar .btn { max-width: none !important; width: 100%; }
  .mob-history-wrap table {
    display: block;
    overflow-x: auto;
    font-size: 13px;
    border-radius: 12px;
  }

  /* 弹窗全屏底部抽屉 */
  .modal.show {
    align-items: flex-end;
    padding: 0;
  }
  .modal__box {
    width: 100% !important;
    max-width: none !important;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px calc(16px + var(--mob-safe-b));
  }
  .modal__box--wide { max-width: none !important; }
  .modal__actions {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .modal__actions .btn {
    width: 100%;
    margin: 0;
  }
  .modal h3 { font-size: 17px; margin: 0 0 8px; }

  #panel-dashboard.panel.active .mobile-dashboard { display: block; }
  #panel-dashboard.panel.active .desktop-dashboard { display: none !important; }
  #panel-dashboard.panel.active #ratingStats { display: none; }

  body:not(.mode-workbench) .wb-panel { display: none !important; }
}

@media (min-width: 769px) {
  .mq-bottom-nav { display: none !important; }
  .mq-mobile-panel { display: none !important; }
  .mobile-dashboard { display: none !important; }
  .wb-back-btn { display: none !important; }
  .mq-admin-shell { padding-bottom: 0 !important; }
  .wb-conv__queue { display: none !important; }
  .wb-conv__head--mob h3 { font-size: 15px !important; }
  .wb-conv__head--mob .wb-conv__queue {
    display: inline !important;
    margin-left: 8px;
    font-size: 12px;
    color: #999;
  }
}

/* ===== IOS_MOBILE_INPUT_STABLE_START ===== */

/*
 * iPhone / 手机后台输入稳定补丁
 * 只处理 UI：
 * 1. 防止输入框聚焦自动放大
 * 2. 防止聊天输入区横向溢出
 * 3. 保证发送按钮始终留在屏幕内
 */
@media (max-width: 768px) {

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  /*
   * iOS Safari / WebView：
   * input / textarea 小于 16px 时聚焦会自动放大。
   */
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  textarea,
  select {
    font-size: 16px !important;
  }

  /* 工作台整体禁止横向撑宽 */
  .mq-admin-shell,
  .mq-content,
  .wb-panel,
  .wb-chat,
  .wb-compose-wrap,
  .wb-compose,
  .wb-compose .mq-footer-compose,
  .wb-compose .mq-compose {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .wb-panel,
  .wb-chat,
  .wb-compose-wrap,
  .wb-compose,
  .wb-compose .mq-footer-compose,
  .wb-compose .mq-compose {
    width: 100% !important;
  }

  /*
   * 聊天输入框：
   * width:0 + flex 让 textarea 只占剩余空间，
   * 不会把发送按钮挤出屏幕。
   */
  .wb-compose .mq-input {
    flex: 1 1 0% !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;

    font-size: 16px !important;
    line-height: 1.45 !important;

    box-sizing: border-box !important;
  }

  /* 输入框外层允许真正收缩 */
  .wb-compose .mq-compose {
    flex-wrap: nowrap !important;
    gap: 8px !important;
    padding-left: 12px !important;
    padding-right: 8px !important;
  }

  /* 手机发送按钮稍微收紧，但不改点击逻辑 */
  .wb-compose .mq-send--wb {
    flex: 0 0 auto !important;
    min-width: 64px !important;
    max-width: 72px !important;
    height: 40px !important;
    padding: 0 14px !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  /* 顶部备注输入也禁止 iPhone 自动放大 */
  .wb-chat__note-input {
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
  }

  .wb-chat__head-main,
  .wb-chat__meta {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* 备注编辑框 */
  .wb-notes-card__input,
  .wb-notes__input {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
  }

  /* 管理页 / 弹窗里的内联 min-width 防止撑出手机屏幕 */
  .modal input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  .modal textarea,
  .modal select,
  .form-box input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  .form-box textarea,
  .form-box select {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .auto-link-row {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .auto-link-row input {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* 底部导航固定在可视宽度内 */
  .mq-bottom-nav {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .mq-bottom-nav a {
    min-width: 0 !important;
  }
}

/* ===== IOS_MOBILE_INPUT_STABLE_END ===== */

/* ===== IOS_MOBILE_HEADER_FIT_V2_START ===== */

@media (max-width: 768px) {

  /*
   * 手机聊天 Header V2
   *
   * 保留：
   * - 返回按钮
   * - 访客名称
   * - 地区/IP 标识
   * - 备注输入框
   * - 转接 / 结束
   *
   * 只通过 flex 收缩解决横向溢出。
   */

  .wb-chat__head {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;

    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;

    padding: 8px 8px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /*
   * Header 第一个子区域：
   * 返回按钮 + 访客信息
   */
  .wb-chat__head > div:first-child {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;

    display: flex !important;
    align-items: center !important;
    gap: 6px !important;

    overflow: hidden !important;
  }

  .wb-back-btn {
    flex: 0 0 36px !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    margin-right: 0 !important;
  }

  /*
   * 恢复访客名称 + 地区/备注。
   * 重点：不再使用 width:0 隐藏整个 head-main。
   */
  .wb-chat__head-main {
    flex: 1 1 auto !important;

    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;

    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;

    overflow: visible !important;
  }

  .wb-chat__title {
    display: block !important;

    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;

    font-size: 15px !important;
    line-height: 20px !important;
  }

  /*
   * 有会话时才显示 meta。
   * 不覆盖原来的 hidden 状态。
   */
  .wb-chat__meta[hidden] {
    display: none !important;
  }

  .wb-chat__meta:not([hidden]) {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;

    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    overflow: visible !important;
  }

  /* 地区 / IP 小标签恢复显示 */
  .wb-chat__region {
    display: inline-block !important;

    flex: 0 1 auto !important;
    min-width: 0 !important;
    max-width: 58px !important;

    padding: 1px 5px !important;

    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;

    font-size: 12px !important;
  }

  /* 备注输入框保留，并使用剩余空间 */
  .wb-chat__note-input {
    display: block !important;

    flex: 1 1 80px !important;

    width: auto !important;
    min-width: 56px !important;
    max-width: 100% !important;

    height: 28px !important;
    padding: 0 6px !important;

    font-size: 16px !important;
    box-sizing: border-box !important;
  }

  /*
   * 保存状态提示本身不是备注框，
   * 手机上隐藏它以节省横向空间。
   */
  .wb-chat__note-hint {
    display: none !important;
  }

  /*
   * 转接 / 结束固定留在右侧，
   * 但不再抢占过多空间。
   */
  .wb-chat__actions {
    flex: 0 0 86px !important;

    width: 86px !important;
    min-width: 86px !important;
    max-width: 86px !important;

    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 4px !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: visible !important;
  }

  .wb-chat__actions button {
    flex: 0 0 41px !important;

    width: 41px !important;
    min-width: 41px !important;
    max-width: 41px !important;

    height: 34px !important;

    padding: 0 2px !important;
    margin: 0 !important;

    font-size: 12px !important;
    line-height: 32px !important;

    white-space: nowrap !important;
    box-sizing: border-box !important;
  }
}

/* 更窄屏幕只轻微缩按钮，不隐藏访客资料 */
@media (max-width: 360px) {

  .wb-chat__actions {
    flex-basis: 78px !important;
    width: 78px !important;
    min-width: 78px !important;
    max-width: 78px !important;
    gap: 2px !important;
  }

  .wb-chat__actions button {
    flex-basis: 38px !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    font-size: 11px !important;
  }

  .wb-chat__region {
    max-width: 46px !important;
  }

  .wb-chat__note-input {
    min-width: 48px !important;
  }
}

/* ===== IOS_MOBILE_HEADER_FIT_V2_END ===== */

/* ===== MOBILE_CHAT_RESUME_SMOOTH_CSS_START ===== */

@media (max-width: 768px) {

  /*
   * Safari 自动恢复会话：
   * 不播放列表 -> 聊天的滑入动画。
   */
  .wb-panel.chat-restoring .wb-chat {
    transform: translateX(0) !important;
    transition: none !important;
    z-index: 3 !important;
  }

  .wb-panel.chat-restoring .wb-conv {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: none !important;
  }

  /*
   * 消息还没完成初始定位以前，
   * 不把正文和输入框暴露给用户。
   */
  .wb-panel.chat-restoring .wb-chat__body,
  .wb-panel.chat-restoring .wb-compose-wrap {
    visibility: hidden !important;
  }

  /*
   * 用稳定的浅色层盖住聊天主体，
   * 避免出现列表闪一下或聊天从顶部跳到底部。
   */
  .wb-panel.chat-restoring .wb-chat::after {
    content: "正在恢复会话…";

    position: absolute;

    left: 0;
    right: 0;
    top: 54px;
    bottom: 0;

    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f5f6f8;

    color: #a0a6ad;
    font-size: 13px;

    pointer-events: none;
  }
}


/* ===== MOBILE_SEAMLESS_RESUME_V9_CSS ===== */

@media (max-width: 768px) {

  /*
   * 已经有离开前的聊天快照时：
   * 仍保持 chat-restoring，
   * 所以已读/恢复逻辑完全不变；
   *
   * 但视觉上直接显示旧聊天，
   * 不再显示“正在恢复会话…”遮罩。
   */
  .wb-panel.chat-restoring.chat-snapshot-ready
  .wb-chat__body,

  .wb-panel.chat-restoring.chat-snapshot-ready
  .wb-compose-wrap {
    visibility: visible !important;
  }

  .wb-panel.chat-restoring.chat-snapshot-ready
  .wb-chat::after {
    display: none !important;
    content: none !important;
  }
}

/* ===== MOBILE_SEAMLESS_RESUME_V9_CSS_END ===== */

/* ===== MOBILE_CHAT_RESUME_SMOOTH_CSS_END ===== */
