/* 手机聊天控件沿用原新建、发送与附件入口，仅调整窄屏布局。 */
.mobile-new-conversation,
.mobile-composer-row,
.mobile-voice-status,
.mobile-answer-read,
.mobile-turn-read {
  display: none;
}
.mobile-voice-panel {
  display: none;
}

dialog.mobile-camera {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  border: 0;
  border-radius: 0;
  background: #080808;
  color: #fff;
  overflow: hidden;
}
.mobile-camera[open] {
  display: flex;
  flex-direction: column;
}
.mobile-camera [hidden] {
  display: none !important;
}
.mobile-camera::backdrop {
  background: #000;
}
.mobile-camera-heading {
  flex-shrink: 0;
  min-height: 64px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.mobile-camera-heading strong {
  flex: 1;
  padding-right: 44px;
  text-align: center;
  font-size: 20px;
}
.mobile-camera button {
  touch-action: manipulation;
}
.mobile-camera .icon-button,
.mobile-camera-gallery,
.mobile-camera-flip {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  padding: 10px;
  border: 0;
  border-radius: 16px;
  background: #222;
}
.mobile-camera-heading .icon-button {
  background: transparent;
}
.mobile-camera .icon {
  width: 28px;
  height: 28px;
  filter: brightness(0) invert(1);
}
.mobile-camera-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.mobile-camera video,
.mobile-camera-preview {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}
.mobile-camera-preview {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}
.mobile-camera-preview img {
  width: 100%;
  height: 100%;
  flex: 0 0 100%;
  object-fit: contain;
  scroll-snap-align: center;
}
.mobile-camera-status {
  min-height: 24px;
  padding: 0 20px;
  margin: 10px 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  color: #dedede;
}
.mobile-camera-controls {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 16px;
  padding: 12px 24px 28px;
}
.mobile-camera-shutter {
  flex: none;
  width: 76px;
  height: 76px;
  padding: 0;
  border: 5px solid #fff;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 4px #080808;
}
.mobile-camera-shutter:disabled {
  opacity: 0.35;
}
.mobile-camera-confirm,
.mobile-camera-fallback {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  padding: 12px 20px 24px;
}
.mobile-camera-confirm button,
.mobile-camera-fallback button {
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid #777;
  border-radius: 24px;
  background: #222;
  color: #fff;
}
.mobile-camera-confirm .primary {
  background: #fff;
  border-color: #fff;
  color: #111;
}
.mobile-camera button:focus-visible {
  outline: 3px solid #a8c6ff;
  outline-offset: 4px;
}

@media (max-width: 760px) {
  .mobile-new-conversation {
    display: inline-flex;
  }
  .topbar #openSidebar,
  .topbar .mobile-new-conversation {
    width: 44px;
    height: 44px;
  }
  .topbar #openSidebar img,
  .topbar .mobile-new-conversation img {
    width: 24px;
    height: 24px;
    opacity: 1;
  }
  #main.home-start {
    min-height: var(--mobile-view-height, 100dvh);
  }
  .home-start #home,
  .home-page.in-chat {
    --composer-bottom: calc(
      8px + env(safe-area-inset-bottom) + var(--mobile-keyboard-offset, 0px)
    );
    padding-inline: 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .home-page.in-chat {
    margin: 0;
    max-width: none;
    min-height: calc(var(--mobile-view-height, 100dvh) - 48px);
  }
  .home-start .mobile-home-greeting {
    font-size: 24px;
    line-height: 1.4;
  }
  .home-page #promptForm {
    padding: 5px 6px;
    margin-bottom: 0;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 2px 10px #0000000b;
  }
  .home-page .composer-resize,
  .home-page .composer-bar,
  .home-page #contextMeter,
  .home-page .conversation-metrics,
  .home-page .composer-feedback-routine {
    display: none;
  }
  .home-page #selectedContext:empty,
  .home-page #selectedContext:has(> .attachment-selected-list:only-child:empty),
  .home-page #referenceChips:empty {
    display: none;
  }
  .mobile-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 0;
    min-width: 0;
  }
  .home-page #prompt {
    flex: 1;
    width: 0;
    min-width: 0;
    min-height: 44px;
    max-height: 154px;
    padding: 10px 4px;
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    resize: none;
    overflow-y: auto;
  }
  .home-page .mobile-composer-row .round-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: transparent;
    color: #111;
  }
  .home-page .mobile-composer-row .round-button img {
    width: 24px;
    height: 24px;
    opacity: 1;
  }
  .home-page .mobile-composer-row .send {
    display: none;
    background: #1f2329;
  }
  .home-page .mobile-composer-row .send:disabled {
    background: #bec2c8;
  }
  .home-page .mobile-has-action #submit {
    display: grid;
  }
  .home-page .mobile-has-action #mobileVoice,
  .home-page .mobile-has-action #addContext {
    display: none;
  }
  .home-page .mobile-composer-row .send img {
    filter: brightness(0) invert(1);
  }
  .home-page .mobile-composer-row .send.stopping img {
    width: 18px;
    height: 18px;
  }
  .home-page #selectedContext:not(:empty),
  .home-page #referenceChips:not(:empty),
  .home-page .composer-badges:has(button:not([hidden])) {
    padding: 8px 8px 2px;
  }
  .home-page .composer-feedback:not(.composer-feedback-routine) {
    margin: 2px 8px 6px;
    padding: 0;
  }
  .mobile-voice-hold {
    display: none;
    flex: 1;
    min-width: 0;
    height: 44px;
    border: 0;
    border-radius: 12px;
    padding: 8px 0;
    background: #f4f4f4;
    color: #222;
    font-size: 16px;
    white-space: nowrap;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .mobile-voice-mode #prompt {
    display: none;
  }
  .mobile-voice-mode .mobile-voice-hold {
    display: block;
  }
  .mobile-voice-hold.is-recording {
    background: #e4e8ff;
    color: #3347ba;
  }
  .mobile-voice-hold.is-cancelling {
    background: #fee8e6;
    color: #a12d25;
  }
  .mobile-voice-status:not(:empty) {
    display: block;
    text-align: center;
    color: #666;
    margin: 6px 8px;
    font-size: 12px;
  }
  .home-page #promptForm.mobile-voice-active {
    z-index: 101;
    border-color: transparent;
    background: #fff;
  }
  .mobile-voice-active #addContext,
  .mobile-voice-active #mobileVoice,
  .mobile-voice-active #mobileCamera {
    display: none;
  }
  .mobile-voice-active .mobile-voice-status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .mobile-voice-panel:not([hidden]) {
    display: flex;
    position: fixed;
    z-index: 100;
    inset: auto 0 0;
    height: min(380px, 65dvh);
    padding: 55px 24px calc(104px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: linear-gradient(#f5f6ff00, #f0f2ff 28%, #e6eaff);
    color: #343f9e;
    pointer-events: none;
  }
  .mobile-voice-panel strong {
    font-size: 23px;
    font-weight: 600;
  }
  .mobile-voice-panel p {
    margin: 0;
    font-size: 14px;
  }
  .mobile-voice-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 48px;
  }
  .mobile-voice-wave i {
    width: 4px;
    height: 16px;
    border-radius: 4px;
    background: currentColor;
    animation: mobile-voice-pulse 0.9s ease-in-out infinite alternate;
  }
  .mobile-voice-wave i:nth-child(3n) {
    height: 34px;
    animation-delay: -0.4s;
  }
  .mobile-voice-wave i:nth-child(3n + 1) {
    height: 24px;
    animation-delay: -0.7s;
  }
  .mobile-voice-panel.is-starting .mobile-voice-wave i {
    animation: none;
    height: 6px;
  }
  .mobile-voice-panel.is-cancelling {
    background: linear-gradient(#fff5f500, #fff0f0 28%, #ffe3e3);
    color: #b43b46;
  }
  .mobile-voice-panel.is-cancelling .mobile-voice-wave {
    opacity: 0.5;
  }
  .mobile-answer-read,
  .mobile-turn-read {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
  }
  .mobile-answer-read img {
    width: 23px;
    height: 23px;
  }
  .mobile-answer-read[hidden],
  .mobile-turn-read[hidden] {
    display: none;
  }
  .home-page .composer-popover {
    left: auto;
    right: 0;
    min-width: min(240px, calc(100vw - 40px));
  }
  .home-page .permission-option {
    min-height: 44px;
    font-size: 14px;
  }
}
@keyframes mobile-voice-pulse {
  from {
    transform: scaleY(0.45);
  }
  to {
    transform: scaleY(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-voice-wave i {
    animation: none;
  }
}
