/* Full browser shell: the legacy CEP layout remains scoped to the extension build. */
html,
body.xiake-web-mode {
  width: 100%;
  height: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body.xiake-web-mode {
  color: #e7eeee;
  background: #070c0e;
}

html body.xiake-web-mode.records-page-open .app-shell {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-width: 320px;
  min-height: 0;
  margin: 0;
  padding: clamp(6px, 1vw, 14px);
  overflow: hidden;
}

html body.xiake-web-mode.records-page-open .toolbar {
  /* Keep header popovers above the 12100-level generated-image viewer. */
  position: relative;
  z-index: 12200 !important;
  min-width: 0;
  min-height: 54px;
  margin: 0;
  padding: 0 4px 8px;
}

html body.xiake-web-mode.records-page-open .toolbar-left {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 1.5vw, 20px);
  width: 100%;
  min-width: 0;
}

/* Center the project selector against the whole toolbar, not its grid column.
   The selector is absolutely positioned, so assigning it a grid column adds the
   column offset to its 50% offset and moves it noticeably to the right. */
@media (min-width: 761px) {
  html body.xiake-web-mode.records-page-open .toolbar-left { position: static; }
  html body.xiake-web-mode.records-page-open #projectSelectorBtn {
    position: absolute !important;
    inset: 50% auto auto 50% !important;
    transform: translate(-50%, -50%) !important;
    grid-column: auto;
    justify-self: auto;
    width: auto !important;
    max-width: min(40vw, 360px);
  }
  html body.xiake-web-mode.records-page-open #chooseFolderBtn { grid-column: auto; }
}

html body.xiake-web-mode.records-page-open .brand-account-wrap { grid-column: 1; justify-self: start; }
html body.xiake-web-mode.records-page-open #projectSelectorBtn {
  grid-column: 2;
  justify-self: center;
  width: min(100%, 360px);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html body.xiake-web-mode.records-page-open #chooseFolderBtn { grid-column: 3; justify-self: end; }
html body.xiake-web-mode.records-page-open #recordsBackBtn { grid-column: 4; }

html body.xiake-web-mode.records-page-open .records-modal {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  height: auto !important;
  min-width: 0;
  min-height: 0 !important;
  max-height: none;
  overflow: hidden;
  border-radius: 10px;
  overscroll-behavior: contain;
}

html body.xiake-web-mode.records-page-open .records-modal-head { display: none !important; }

html body.xiake-web-mode.records-page-open .records-filters {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: minmax(48px, auto);
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

html body.xiake-web-mode.records-page-open .records-filters::-webkit-scrollbar { display: none; }
html body.xiake-web-mode.records-page-open .record-filter { min-width: 0; min-height: 48px; font-size: clamp(12px, 1.25vw, 16px); }

html body.xiake-web-mode.records-page-open .records-sub-filters {
  grid-column: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

html body.xiake-web-mode.records-page-open #recordsList {
  position: relative;
  grid-column: 1;
  grid-row: 3;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

html body.xiake-web-mode.records-page-open .records-list.is-dialogue-list {
  padding-bottom: max(190px, 25dvh) !important;
}

html body.xiake-web-mode.records-page-open .dialogue-record-main {
  min-width: 0;
  padding-inline: clamp(14px, 4vw, 64px) !important;
  padding-bottom: max(190px, 25dvh) !important;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input {
  z-index: 80 !important;
  left: clamp(8px, 2.3vw, 36px) !important;
  right: clamp(8px, 2.3vw, 36px) !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  box-sizing: border-box;
  width: auto !important;
  max-width: none !important;
  max-height: min(44dvh, 430px);
  overflow: visible;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-content {
  position: relative;
  min-width: 0;
  max-height: min(34dvh, 340px);
  overflow: auto;
  overscroll-behavior: contain;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear-zone {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 8;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  box-sizing: border-box;
  width: 78px;
  height: 38px;
  padding: 3px;
  pointer-events: none;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear-zone.has-content {
  pointer-events: auto;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 52px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid rgba(92, 123, 132, 0.8);
  border-radius: 7px;
  background: rgba(15, 23, 27, 0.94);
  color: #b6c7ca;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, border-color 120ms ease, color 120ms ease;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear[hidden] {
  display: none !important;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear-zone:hover .dialogue-composer-clear:not([hidden]),
html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear-zone:focus-within .dialogue-composer-clear:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear:hover,
html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear:focus-visible {
  border-color: #49cdb6;
  color: #65dfca;
  outline: none;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear > span:first-child {
  font-size: 14px;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-prompt-editor {
  min-width: 0;
  max-height: min(24dvh, 240px);
  overflow-y: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  ime-mode: auto;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-tools {
  flex-wrap: wrap;
  min-width: 0;
  row-gap: 7px;
}

html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-tools > * { min-width: 0; }

/* Keep every settings panel inside the browser viewport and above the composer. */
html body.xiake-web-mode .brand-account-popover {
  z-index: 12201 !important;
  box-sizing: border-box;
  max-width: min(440px, calc(100vw - 20px));
  max-height: min(82dvh, 720px);
  overflow: auto;
  overscroll-behavior: contain;
}

html body.xiake-web-mode .brand-account-wrap.is-dismissed .brand-account-popover {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(-5px) !important;
}

html body.xiake-web-mode #brandDownloadSetting { display: block !important; }

html body.xiake-web-mode .dialogue-overlay-layer {
  z-index: 4000 !important;
}

html body.xiake-web-mode .dialogue-overlay-layer .dialogue-tool-popover {
  z-index: 4001 !important;
  max-width: calc(100vw - 20px);
  max-height: calc(100dvh - 20px) !important;
  overscroll-behavior: contain;
}

html body.xiake-web-mode .dialogue-toolbar-popover,
html body.xiake-web-mode .dialogue-upload-menu,
html body.xiake-web-mode .dialogue-model-preference-menu,
html body.xiake-web-mode .dialogue-agent-menu {
  z-index: 1800 !important;
  max-width: calc(100vw - 20px);
  max-height: min(70dvh, 520px);
  overflow: auto;
  overscroll-behavior: contain;
}

html body.xiake-web-mode #projectModal.project-modal,
html body.xiake-web-mode #assetLibraryModal.asset-library-modal,
html body.xiake-web-mode #assetGeneratorModal,
html body.xiake-web-mode .project-team-modal {
  z-index: 6000 !important;
  box-sizing: border-box;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: auto;
  overscroll-behavior: contain;
}

html body.xiake-web-mode #projectModal.project-modal { padding: 12px !important; }
html body.xiake-web-mode #projectModal .project-panel {
  width: min(760px, calc(100vw - 24px)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100dvh - 24px) !important;
  overflow: hidden;
}
html body.xiake-web-mode #projectModal .project-list { min-height: 0 !important; max-height: min(50dvh, 480px); overflow: auto; }

html body.xiake-web-mode #assetLibraryModal.asset-library-modal { padding: 12px !important; }
html body.xiake-web-mode #assetLibraryModal .asset-library-panel {
  width: min(1120px, calc(100vw - 24px)) !important;
  height: min(860px, calc(100dvh - 24px)) !important;
  max-height: calc(100dvh - 24px) !important;
  overflow: hidden;
}
html body.xiake-web-mode #assetLibraryModal .asset-library-body { min-width: 0; min-height: 0; overflow: auto; }

html body.xiake-web-mode .all-generation-records-modal,
html body.xiake-web-mode .generation-record-viewer {
  z-index: 7000 !important;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

html body.xiake-web-mode .generation-record-viewer-media { min-width: 0; min-height: 0; overflow: auto; }
html body.xiake-web-mode .generation-record-viewer-media img,
html body.xiake-web-mode .generation-record-viewer-media video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

html body.xiake-web-mode .dialogue-result-generated-image,
html body.xiake-web-mode .dialogue-result-generated-video,
html body.xiake-web-mode .record-thumb video,
html body.xiake-web-mode .record-thumb img {
  object-fit: contain;
}

/* Keep dialogue image previews readable without letting a wide result fill the
   entire record column. The media itself keeps its natural aspect ratio. */
html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="image"] {
  box-sizing: border-box;
  width: fit-content !important;
  max-width: min(100%, 1120px) !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  margin-inline: auto !important;
}

html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="image"] > .dialogue-result-generated-image {
  box-sizing: border-box;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: min(56dvh, 620px) !important;
}

/* Match completed video previews to images: preserve the source ratio and bound the player size. */
html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="video"]:not(.has-placeholder) {
  box-sizing: border-box;
  width: fit-content !important;
  max-width: min(100%, 1120px) !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  margin-inline: auto !important;
}

html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="video"] > .dialogue-result-generated-video {
  box-sizing: border-box;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: min(56dvh, 620px) !important;
}

/* Premiere-only controls are omitted at render time; this also guards legacy cards. */
html body.xiake-web-mode [data-dialogue-insert],
html body.xiake-web-mode [data-record-insert],
html body.xiake-web-mode [data-wf-action="export-project"],
html body.xiake-web-mode [data-wf-action="export-timeline"],
html body.xiake-web-mode [data-wf-action="voice-import-project"],
html body.xiake-web-mode [data-wf-action="voice-import-timeline"],
html body.xiake-web-mode [data-import="project"],
html body.xiake-web-mode [data-import="timeline"],
html body.xiake-web-mode [data-upload-source="still"],
html body.xiake-web-mode .chat-dialogue-board {
  display: none !important;
}

html body.xiake-web-mode .record-insert-actions[aria-label="素材操作"],
html body.xiake-web-mode .dialogue-result-insert-actions {
  flex-wrap: wrap;
}

html body.xiake-web-mode .xiake-video-compatibility-fallback [data-premiere-preview] { display: none !important; }

html body.xiake-web-mode :where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid #55d8c2 !important;
  outline-offset: 2px;
}

html body.xiake-web-mode :where(button, input, select, textarea) { min-width: 0; }
html body.xiake-web-mode :where(img, video) { max-width: 100%; }

@media (max-width: 760px) {
  html body.xiake-web-mode.records-page-open .app-shell { padding: 6px; }
  html body.xiake-web-mode.records-page-open .toolbar { min-height: 48px; padding-bottom: 6px; }
  html body.xiake-web-mode.records-page-open .toolbar-left {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
  }
  html body.xiake-web-mode.records-page-open .toolbar-left { position: relative; }
  html body.xiake-web-mode.records-page-open .brand-account-wrap { grid-column: 1; }
  html body.xiake-web-mode.records-page-open #projectSelectorBtn {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    grid-column: 2;
    justify-self: center;
    width: auto !important;
    max-width: 100%;
  }
  html body.xiake-web-mode.records-page-open #chooseFolderBtn { grid-column: 3; }
  html body.xiake-web-mode.records-page-open #recordsBackBtn { grid-column: 3; }
  html body.xiake-web-mode.records-page-open .brand-title { gap: 6px; font-size: 17px; }
  html body.xiake-web-mode.records-page-open .brand-logo { width: 30px; height: 30px; }
  html body.xiake-web-mode.records-page-open #chooseFolderBtn { height: 36px; padding-inline: 10px; }
  html body.xiake-web-mode.records-page-open .records-modal { border-radius: 7px; }
  html body.xiake-web-mode.records-page-open .record-filter { min-height: 44px; padding-inline: 3px; }
  html body.xiake-web-mode.records-page-open .dialogue-record-main { padding-inline: 12px !important; }
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input {
    left: 6px !important;
    right: 6px !important;
    bottom: max(6px, env(safe-area-inset-bottom)) !important;
    max-height: min(48dvh, 390px);
    padding: 9px 10px !important;
  }
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-content { max-height: min(36dvh, 300px); }
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-tools { gap: 5px; padding-top: 7px; }
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-tools button { min-height: 38px !important; padding-inline: 9px !important; }
  html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="image"] {
    max-width: 100% !important;
  }
  html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="image"] > .dialogue-result-generated-image {
    max-height: min(48dvh, 420px) !important;
  }
  html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="video"] {
    max-width: 100% !important;
  }
  html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view .dialogue-result-media[data-record-type="video"] > .dialogue-result-generated-video {
    max-height: min(48dvh, 420px) !important;
  }
  html body.xiake-web-mode.records-page-open .records-list.is-dialogue-list,
  html body.xiake-web-mode.records-page-open .dialogue-record-main { padding-bottom: max(210px, 32dvh) !important; }
  html body.xiake-web-mode #assetLibraryModal .asset-library-panel { height: calc(100dvh - 24px) !important; }
  html body.xiake-web-mode #assetLibraryModal .asset-library-body { grid-template-columns: minmax(0, 1fr) !important; }
  html body.xiake-web-mode #assetLibraryModal .asset-project-list { max-height: 120px; overflow: auto; }
}

@media (max-width: 430px) {
  html body.xiake-web-mode.records-page-open #projectSelectorBtn { padding-inline: 7px; font-size: 12px; }
  html body.xiake-web-mode.records-page-open #chooseFolderBtn { padding-inline: 7px; font-size: 11px; }
  html body.xiake-web-mode.records-page-open .brand-title > span:last-child { display: none; }
  html body.xiake-web-mode.records-page-open .records-filters { grid-template-columns: repeat(5, minmax(58px, 1fr)); }
}

@media (max-width: 560px) {
  html body.xiake-web-mode.records-page-open .dialogue-record-top {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 7px !important;
    padding-block: 8px;
  }
  html body.xiake-web-mode.records-page-open .dialogue-record-top h2 {
    justify-self: start;
    margin: 0 !important;
  }
  html body.xiake-web-mode.records-page-open .dialogue-record-tools {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px !important;
    width: 100%;
    overflow: visible !important;
  }
  html body.xiake-web-mode.records-page-open .dialogue-record-tools > button {
    box-sizing: border-box;
    min-width: 0 !important;
    min-height: 38px;
    padding-inline: 5px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-height: 600px) {
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input { max-height: 52dvh; }
  html body.xiake-web-mode .brand-account-popover { max-height: calc(100dvh - 16px); }
}

/* In video mode the prompt box is aspect-ratio constrained and centered.
   Keep its toolbar the same width and center the model label within its button. */
html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view
  .dialogue-bottom-input.is-video-generation-mode .dialogue-input-tools {
  box-sizing: border-box !important;
  width: min(var(--dialogue-composer-resize-width, 100%), var(--dialogue-video-max-width, 100%)) !important;
  max-width: 100% !important;
  justify-self: center !important;
  margin-inline: auto !important;
  justify-content: flex-start !important;
  align-items: center !important;
}

html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view
  .dialogue-bottom-input.is-video-generation-mode .dialogue-input-tools > button,
html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view
  .dialogue-bottom-input.is-video-generation-mode .dialogue-agent-wrap > .dialogue-agent-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1.2 !important;
}

html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view
  .dialogue-bottom-input.is-video-generation-mode #dialoguePrefBtn {
  justify-content: flex-start !important;
  text-align: left !important;
}

/* Pending video cards should preview the selected frame shape without filling
   the conversation viewport. The numeric ratio lets portrait and landscape
   placeholders share the same maximum width and height. */
html body.xiake-web-mode.records-page-open .records-modal.is-dialogue-view
  .dialogue-result-media.has-placeholder[data-record-type="video"] {
  box-sizing: border-box !important;
  width: min(100%, var(--xiake-video-wait-max-width, 782px)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-width: 100% !important;
  aspect-ratio: var(--xiake-generation-aspect, 16 / 9) !important;
  justify-self: center !important;
  margin-inline: auto !important;
}

/* Mobile browser layout. Keep these rules scoped to the standalone web shell so
   the CEP panel keeps its existing dimensions and interactions. */
@media (max-width: 600px) {
  html body.xiake-web-mode {
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
  }

  html body.xiake-web-mode.records-page-open .app-shell {
    min-width: 0;
    padding: 0 !important;
  }

  html body.xiake-web-mode.records-page-open .toolbar {
    min-height: 48px;
    padding: max(4px, env(safe-area-inset-top)) 8px 4px !important;
  }

  html body.xiake-web-mode.records-page-open .toolbar-left {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 4px;
  }

  html body.xiake-web-mode.records-page-open .brand-account-wrap,
  html body.xiake-web-mode.records-page-open #projectSelectorBtn,
  html body.xiake-web-mode.records-page-open #chooseFolderBtn,
  html body.xiake-web-mode.records-page-open #recordsBackBtn {
    min-width: 0 !important;
  }

  html body.xiake-web-mode.records-page-open .brand-account-wrap {
    overflow: hidden;
  }

  html body.xiake-web-mode.records-page-open .brand-title {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body.xiake-web-mode.records-page-open #projectSelectorBtn {
    width: 100% !important;
    max-width: 100% !important;
    padding-inline: 4px !important;
    overflow: hidden;
  }

  html body.xiake-web-mode.records-page-open #projectSelectorBtn .project-selector-label {
    max-width: calc(100% - 18px);
  }

  html body.xiake-web-mode.records-page-open #chooseFolderBtn {
    width: 42px !important;
    min-width: 42px !important;
    height: 36px !important;
    padding: 0 4px !important;
    overflow: hidden;
    font-size: 0 !important;
  }

  html body.xiake-web-mode.records-page-open #chooseFolderBtn::before {
    content: "库";
    font-size: 12px;
  }

  html body.xiake-web-mode.records-page-open .records-modal {
    min-height: 0 !important;
    border-radius: 0 !important;
  }

  html body.xiake-web-mode.records-page-open .records-filters {
    grid-auto-rows: 44px;
    min-height: 44px;
  }

  html body.xiake-web-mode.records-page-open .record-filter {
    min-height: 44px;
    font-size: 12px;
  }

  html body.xiake-web-mode.records-page-open .records-sub-filters {
    min-height: 38px;
    padding: 4px 8px;
    gap: 5px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    white-space: nowrap;
  }

  html body.xiake-web-mode.records-page-open #recordsList {
    scrollbar-gutter: auto;
    touch-action: pan-y;
  }

  html body.xiake-web-mode.records-page-open .dialogue-record-main {
    padding-inline: 8px !important;
  }

  /* The composer stays usable above the mobile keyboard and its controls form
     two compact rows instead of overflowing horizontally. */
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input {
    left: 4px !important;
    right: 4px !important;
    bottom: max(4px, env(safe-area-inset-bottom)) !important;
    max-height: min(52dvh, 390px);
    padding: 7px 8px !important;
    border-radius: 10px !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-content {
    max-height: min(32dvh, 245px);
    border-radius: 8px !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-prompt-editor {
    max-height: min(21dvh, 170px);
    padding-right: 62px !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-tools {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px 42px;
    grid-auto-rows: minmax(40px, auto);
    gap: 5px !important;
    padding-top: 6px;
    margin-left: 0 !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-tools > * {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-agent-wrap {
    grid-column: 1 / span 2;
    grid-row: 1;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-agent-wrap > .dialogue-agent-btn,
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-model-preference-toggle,
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-at-btn,
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input #dialogueSkillsBtn,
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-send {
    min-width: 0 !important;
    min-height: 40px !important;
    padding-inline: 6px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-send {
    grid-column: 4;
    grid-row: 1;
    margin-left: 0 !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input #dialoguePrefBtn,
  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-skill-btn {
    display: none !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-model-preference-wrap {
    display: block !important;
    grid-column: 1 / span 2;
    grid-row: 2;
    min-width: 0 !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-at-btn {
    grid-column: 3;
    grid-row: 2;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input #dialogueSkillsBtn {
    grid-column: 4;
    grid-row: 2;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input.is-video-generation-mode .dialogue-video-tools {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100% !important;
    min-width: 0 !important;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-upload-menu {
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
    bottom: calc(100% + 8px) !important;
    width: min(252px, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: min(58dvh, 460px) !important;
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-composer-clear-zone {
    width: 62px;
    height: 34px;
  }

  /* Media records use a fluid thumbnail column. The old fixed 176/192px
     column leaves too little room for actions on a 320px phone. */
  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item {
    width: calc(100% - 16px) !important;
    grid-template-columns: minmax(96px, 34vw) minmax(0, 1fr) !important;
    gap: 8px !important;
    min-height: 104px !important;
    margin-inline: 8px !important;
    padding: 8px !important;
    border-radius: 10px !important;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item .record-thumb-wrap,
  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item .record-thumb {
    width: 100% !important;
    height: auto !important;
    min-height: 76px !important;
    max-height: 104px;
    aspect-ratio: 16 / 10;
    border-radius: 8px !important;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item[data-record-type="video"] .record-thumb-wrap,
  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item[data-record-type="video"] .record-thumb {
    aspect-ratio: 16 / 9;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item .record-body {
    min-width: 0;
    min-height: 76px !important;
    gap: 5px;
    padding: 0 !important;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item .record-prompt {
    font-size: 12px !important;
    line-height: 1.35;
    -webkit-line-clamp: 3;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item .record-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 4px !important;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item .record-actions > * {
    min-width: 0 !important;
    min-height: 30px !important;
    padding-inline: 4px !important;
    font-size: 10px !important;
  }

  html body.xiake-web-mode.records-page-open .media-records-toolbar {
    min-height: 0;
    flex-wrap: wrap;
    gap: 6px;
    padding: 7px 8px;
  }

  /* The asset library is easier to use with a horizontal project picker and a
     two-column gallery than with a narrow desktop sidebar. */
  html body.xiake-web-mode #assetLibraryModal.asset-library-modal,
  html body.xiake-web-mode #projectModal.project-modal {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)) !important;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-library-panel,
  html body.xiake-web-mode #projectModal .project-panel {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 10px;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-library-head,
  html body.xiake-web-mode #projectModal .project-panel-head {
    min-height: 50px;
    padding-inline: 10px;
    gap: 6px;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-library-head h2,
  html body.xiake-web-mode #projectModal .project-panel-head h2 {
    min-width: 0;
    overflow: hidden;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-library-body {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-project-list {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
    max-height: none !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
  }

  html body.xiake-web-mode #assetLibraryModal .asset-project {
    flex: 0 0 auto;
    min-height: 36px;
    padding-inline: 10px;
    font-size: 12px !important;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-gallery {
    min-height: 0;
    padding: 10px;
    gap: 14px;
    overflow: auto;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  html body.xiake-web-mode #assetLibraryModal .asset-card {
    min-height: 128px;
    padding: 7px;
    gap: 5px;
  }

  /* Keep the project selector usable when the header actions wrap. */
  html body.xiake-web-mode #projectModal .project-panel-head {
    flex-wrap: wrap;
    justify-content: flex-start;
    padding-block: 8px;
  }

  html body.xiake-web-mode #projectModal .project-panel-head h2 {
    flex: 1 1 100%;
    order: 0;
  }

  html body.xiake-web-mode #projectModal .project-panel-head > button {
    min-height: 36px;
    padding-inline: 8px;
    font-size: 11px;
  }

  html body.xiake-web-mode #projectModal .project-list {
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 138px) !important;
    grid-template-columns: 1fr !important;
    grid-auto-rows: auto !important;
    padding: 8px;
  }

  html body.xiake-web-mode #projectModal .project-item {
    height: auto !important;
    min-height: 88px !important;
    grid-template-columns: 82px minmax(0, 1fr) auto !important;
    grid-template-rows: auto !important;
    gap: 8px !important;
    padding: 8px !important;
  }

  html body.xiake-web-mode #projectModal .project-thumb {
    width: 82px !important;
    height: 64px !important;
  }

  /* Storyboard keeps its rich table controls, but allows intentional horizontal
     touch scrolling instead of clipping the last columns. */
  html body.xiake-web-mode.records-page-open .records-list.is-storyboard-list {
    overflow-x: auto;
    touch-action: pan-x pan-y;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-storyboard-list .storyboard-board {
    min-width: 620px;
  }

  html body.xiake-web-mode.records-page-open .storyboard-script-actions {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 8px max(10px, env(safe-area-inset-bottom));
  }

  html body.xiake-web-mode.records-page-open .storyboard-script-actions button {
    min-width: 0;
    flex: 1 1 calc(50% - 6px);
    min-height: 38px;
    padding-inline: 8px;
    font-size: 11px;
  }

  html body.xiake-web-mode .generation-record-viewer-panel,
  html body.xiake-web-mode .all-generation-records-panel {
    width: calc(100vw - 16px) !important;
    max-width: none !important;
    max-height: calc(100dvh - 16px) !important;
    margin: 8px;
  }
}

@media (max-width: 360px) {
  html body.xiake-web-mode.records-page-open .toolbar-left {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
  }

  html body.xiake-web-mode.records-page-open .brand-title {
    font-size: 15px;
  }

  html body.xiake-web-mode.records-page-open .brand-logo {
    width: 27px;
    height: 27px;
  }

  html body.xiake-web-mode.records-page-open .records-filters {
    grid-template-columns: repeat(5, minmax(52px, 1fr));
  }

  html body.xiake-web-mode.records-page-open .dialogue-bottom-input .dialogue-input-tools {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px 38px;
  }

  html body.xiake-web-mode.records-page-open .records-list.is-media-record-list > .record-item {
    grid-template-columns: 92px minmax(0, 1fr) !important;
  }
}
