/* Wardrobe surfaces are opaque: transparent artwork sits on a solid preview. */
body[data-route="editor"] {
  --ink: #283e32;
  --muted: #526656;
  --line: #c7d2c3;
  --paper: #fbfaf4;
  background: #e8ede3;
}

body[data-route="editor"]::before { display:none; }
body[data-route="editor"] .app-frame,
body[data-route="editor"] .editor-view,
body[data-route="editor"] .editor-header { background:#e8ede3; }
body[data-route="editor"] .editor-layout,
body[data-route="editor"] .preview-panel { background:#e2e8dc; }
body[data-route="editor"] .character-stage {
  background:#dce4d5;
  border-radius:20px;
}
body[data-route="editor"] .character-stage::before,
body[data-route="editor"] .character-stage::after { display:none; }
body[data-route="editor"] .character-stage.is-night { background:#27344b; }
body[data-route="editor"] .character-stage.is-night #editorCanvas { filter:brightness(.95); }
body[data-route="editor"] .tool-panel,
body[data-route="editor"] .panel-scroll,
body[data-route="editor"] .panel-command-bar,
body[data-route="editor"] .catalog-heading,
body[data-route="editor"] .tabs,
body[data-route="editor"] .category-row,
body[data-route="editor"] .outfit-toolbar { background:#fbfaf4; color:#283e32; }
body[data-route="editor"] .edit-dock,
body[data-route="editor"] .dock-heading,
body[data-route="editor"] .feature-card,
body[data-route="editor"] .layer-row { background:#f0f3e9; color:#283e32; }
body[data-route="editor"] .wardrobe-stage-actions button,
body[data-route="editor"] .preview-actions button,
body[data-route="editor"] .layer-quick-button,
body[data-route="editor"] .back-button,
body[data-route="editor"] .canvas-candidates,
body[data-route="editor"] .canvas-interaction-hint,
body[data-route="editor"] .item-card,
body[data-route="editor"] .outfit-card,
body[data-route="editor"] .outfit-slot { background:#fffef9; color:#2f4937; backdrop-filter:none; }
body[data-route="editor"] .wardrobe-stage-actions button.active,
body[data-route="editor"] .layer-quick-button.active,
body[data-route="editor"] .outfit-actions button:first-child { background:#506d56; color:#fff; }
body[data-route="editor"] .item-card.selected { background:#dce9d3; border-color:#59774e; }
body[data-route="editor"] .item-thumbnail,
body[data-route="editor"] .layer-thumbnail,
body[data-route="editor"] .outfit-preview { background:#dce4d5; background-image:none; }
body[data-route="editor"] .wardrobe-stage-actions button,
body[data-route="editor"] .panel-selection b,
body[data-route="editor"] .layer-quick-button,
body[data-route="editor"] .item-card b,
body[data-route="editor"] .outfit-actions button { font-size:12px; }
body[data-route="editor"] .panel-selection small,
body[data-route="editor"] .control-title,
body[data-route="editor"] .item-card small,
body[data-route="editor"] .canvas-interaction-hint { color:#526656; font-size:10px; }
body[data-route="editor"] .tabs button,
body[data-route="editor"] .category-row button { color:#405c45; font-size:13px; }
body[data-route="editor"] .tabs button[aria-selected="true"],
body[data-route="editor"] .category-row button[aria-selected="true"] { background:#dce9d3; color:#203c26; }
body[data-route="editor"] dialog { color:#283e32; background:#fbfaf4; }
body[data-route="editor"] .meme-accessory-preview { background:#dce4d5; }
@media (max-width:520px) {
  body[data-route="editor"] .character-stage { border-radius:0; }
  body[data-route="editor"] .editor-title h2 { color:#344e36; }
}

body[data-route="editor"] .editor-title h2 { color:#344e36; }
body[data-route="editor"] .outfit-card-preview { background:#dce4d5; background-image:none; }
body[data-route="editor"] .outfit-card-copy small,
body[data-route="editor"] .outfit-card-copy time { color:#526656; }
body[data-route="editor"] .outfit-card-actions { display:flex; flex-wrap:wrap; background:#fffef9; }
body[data-route="editor"] .outfit-card-actions button { flex:1 1 45px; min-height:36px; color:#36523c; background:#fffef9; font-size:12px; }
body[data-route="editor"] .outfit-card-actions button[data-outfit-action="overwrite"] { color:#fff; background:#506d56; }
body[data-route="editor"] .outfit-toolbar { flex-wrap:wrap; }
body[data-route="editor"] .background-control { display:none; }
body[data-route="editor"] #partImportMannequin { padding:12px; border:1px solid var(--line); border-radius:12px; margin:12px 0; background:#f0f3e9; }
body[data-route="editor"] #partImportMannequin img { display:block; max-width:160px; width:100%; height:auto; margin:12px auto; background:#dce4d5; }
body[data-route="editor"] .import-sheet { padding:12px 0; border-top:1px solid var(--line); display:grid; gap:10px; }
body[data-route="editor"] .import-sheet canvas { width:min(170px,100%); height:auto; justify-self:center; background:#dce4d5; border:1px solid #a5b59f; border-radius:8px; }
body[data-route="editor"] .import-sheet input { max-width:100%; width:100%; font-size:12px; color:#283e32; }
body[data-route="editor"] .import-sheet button,
body[data-route="editor"] #importOutfitFile,
body[data-route="editor"] #partImportReferenceDownload { min-height:40px; padding:8px 12px; border:1px solid var(--line); border-radius:10px; color:#2f4937; background:#e6eddd; cursor:pointer; }
body[data-route="editor"] .part-import-row span { flex:1; min-width:0; overflow-wrap:anywhere; }
body[data-route="editor"] .part-import-row button { flex:none; }
body[data-route="editor"] #outfitToolbar button { font-size:11px; }
body[data-route="editor"] #editorView .panel-command-actions .layer-quick-button { background:#fffef9; border:1px solid #bacab2; color:#2f4937; padding:5px 8px; min-height:32px; }
body[data-route="editor"] #editorView .panel-command-actions .layer-quick-button.active { background:#506d56; color:#fff; }
body[data-route="editor"] #editorView .panel-command-actions .layer-quick-button b { font-size:10px; background:#506d56; }
body[data-route="editor"] #editorView .panel-selection b { color:#2f4937; }
body[data-route="editor"] #editDock .control-title { font-size:12px; color:#40583f; }
body[data-route="editor"] #editDock .feature-card { color:#2f4937; }
body[data-route="editor"] .item-thumbnail,
body[data-route="editor"] .layer-thumbnail,
body[data-route="editor"] .outfit-card-preview { background:#bcc8b5; }
body[data-route="editor"] .outfit-card .outfit-delete { position:absolute; top:7px; right:7px; z-index:2; width:30px; height:30px; min-height:30px; border:1px solid #a4b29b; border-radius:50%; color:#36523c; background:#f5f8ed; font-size:20px; cursor:pointer; }
body[data-route="editor"] .outfit-card time { display:none; }
body[data-route="editor"] .outfit-new-slot { background:#e3eadc; color:#2f4937; }
body[data-route="editor"] .outfit-card-actions button { flex-basis:55px; }
body[data-route="editor"] .outfit-card .outfit-delete { z-index:5; }
body[data-route="editor"] .outfit-current-badge { pointer-events:none; right:44px; }
body[data-route="editor"] #resetPartColor { margin-left:auto; padding:4px 8px; border:1px solid #bacab2; border-radius:8px; color:#36523c; background:#fffef9; font-size:11px; min-height:28px; cursor:pointer; }
body[data-route="editor"] .site-header { display:none; }
@media (max-width:850px) {
  body[data-route="editor"] #editorView { position:fixed; inset:0; z-index:20; min-height:0; }
}
body[data-route="editor"] .outfit-card-copy b { font-family:inherit; font-size:14px; font-weight:600; }
body[data-route="editor"] .outfit-card-copy small,
body[data-route="editor"] .outfit-new-slot > small { font-size:11px; color:#435b45; }
@media (max-width:520px) and (max-height:620px) {
  body[data-route="editor"] .color-section { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); column-gap:8px; }
  body[data-route="editor"] .color-section .control-title,
  body[data-route="editor"] .color-section .swatches { grid-column:1 / -1; }
  body[data-route="editor"] .color-section .free-color { grid-column:1; grid-row:3; min-width:0; margin-top:8px; }
  body[data-route="editor"] .color-section .free-color button { min-width:0; padding-right:5px; }
  body[data-route="editor"] .color-section .saved-colors { grid-column:2; grid-row:3; min-width:0; min-height:29px; align-items:center; margin-top:8px; }
}
.wardrobe-select-wrap { display:block; min-width:0; width:100%; }
.wardrobe-select-button { display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; min-height:44px; padding:9px 12px; border:1px solid #b8c7b0; border-radius:10px; color:#2f4937; background:#fffef9; font:inherit; text-align:left; cursor:pointer; }
.wardrobe-select-button::after { content:'⌄'; flex:none; color:#506d56; }
.wardrobe-select-dialog { box-sizing:border-box; width:min(400px,calc(100vw - 24px)); max-height:min(640px,calc(100dvh - 24px)); padding:16px; overflow:hidden; border:1px solid #b8c7b0; border-radius:20px; color:#283e32; background:#fbfaf4; }
.wardrobe-select-dialog[open] { display:flex; flex-direction:column; gap:12px; }
.wardrobe-select-dialog::backdrop { background:#cbd6c8; backdrop-filter:none; -webkit-backdrop-filter:none; }
.wardrobe-select-dialog header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.wardrobe-select-dialog h3 { margin:0; font-size:18px; }
.wardrobe-select-dialog header button { width:40px; height:40px; border:0; border-radius:10px; color:#36523c; background:#e6eddd; font-size:24px; cursor:pointer; }
.wardrobe-select-dialog input { box-sizing:border-box; width:100%; min-height:44px; padding:10px; border:1px solid #b8c7b0; border-radius:10px; color:#283e32; background:#fffef9; font:inherit; }
.wardrobe-choice-list { min-height:0; overflow:auto; overscroll-behavior:contain; display:grid; gap:6px; }
.wardrobe-choice-list button { display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; min-height:44px; padding:10px 12px; border:1px solid #d0dac8; border-radius:10px; color:#2f4937; background:#fffef9; font:inherit; text-align:left; cursor:pointer; }
.wardrobe-choice-list button[aria-selected="true"] { background:#dce9d3; border-color:#759568; }
@media (max-width:520px) {
  body[data-route="editor"] #catalogGrid.outfit-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body[data-route="editor"] .outfit-card-actions button { flex:1 1 40px; }
  body[data-route="editor"] .canvas-interaction-hint { display:none; }
}
body[data-route="editor"] .outfit-card-preview canvas { opacity:1; transition:none; }

/*
 * Android 2.175 catalogue colours read from the live wardrobe iframe.
 * The saved-outfit tiles use a warm sage paper (#f1f2e9), while the add-slot
 * tile is slightly lighter (#edf1e4). Part cards are nearly white, and only
 * the active part changes to the original pale green selected state.
 */
body[data-route="editor"] #catalogGrid .item-card:not(.outfit-card):not(.outfit-new-slot) {
  border-color: #e4e8dc;
  background: #fffef8;
  box-shadow: none;
}

body[data-route="editor"] #catalogGrid .item-card.selected:not(.outfit-card):not(.outfit-new-slot) {
  border-color: #aabc96;
  background: #eaf0e1;
  box-shadow: none;
}

body[data-route="editor"] .outfit-card,
body[data-route="editor"] .outfit-card-load,
body[data-route="editor"] .outfit-card-preview,
body[data-route="editor"] .outfit-card-copy {
  background: #f1f2e9;
  background-image: none;
  box-shadow: none;
}

body[data-route="editor"] .outfit-card-load {
  border-color: #e0e5d7;
}

body[data-route="editor"] .outfit-card.is-current,
body[data-route="editor"] .outfit-card.is-current .outfit-card-load,
body[data-route="editor"] .outfit-card.is-current .outfit-card-preview,
body[data-route="editor"] .outfit-card.is-current .outfit-card-copy {
  background: #eaf0e1;
}

body[data-route="editor"] .outfit-card.is-current .outfit-card-load {
  border-color: #aabc96;
}

body[data-route="editor"] .outfit-new-slot {
  border-color: #e4e8dc;
  background: #edf1e4;
  color: #8da083;
}
body[data-route="editor"] #partImportDialog { font-size:13px; }
body[data-route="editor"] #partImportDialog .part-import-field { font-size:13px; }
body[data-route="editor"] #partImportDialog .part-import-field > span { font-size:12px; color:#36523c; }
body[data-route="editor"] #partImportDialog input,
body[data-route="editor"] #partImportDialog .wardrobe-select-button { font-size:13px; }
body[data-route="editor"] #partImportDialog .part-import-note,
body[data-route="editor"] #partImportDialog .part-import-status { font-size:12px; line-height:1.7; color:#36523c; }
body[data-route="editor"] #categoryEyebrow { font-size:12px; letter-spacing:0; color:#435b45; }

/* Final 2.175 mobile type scale and controls. These selectors intentionally
   follow the historical overrides above so the measured source styles win. */
@media (max-width: 850px) {
  body[data-route="editor"] .editor-title h2 {
    color: #83957c;
    font-size: 20px;
    font-weight: 700;
  }

  body[data-route="editor"] .panel-selection b {
    color: #7e9077;
    font-size: 11px;
    font-weight: 500;
  }

  body[data-route="editor"] .tabs button {
    color: #a2ae94;
    font-size: 12px;
    font-weight: 600;
  }

  body[data-route="editor"] .tabs button[aria-selected="true"] {
    color: #849971;
    background: #e3ebd9;
  }

  body[data-route="editor"] .category-row button {
    color: #a9b29f;
    font-size: 11px;
  }

  body[data-route="editor"] .category-row button[aria-selected="true"] {
    color: #8fa577;
    background: #f8f8f1;
  }

  body[data-route="editor"] .outfit-card-copy b {
    color: #7a8d70;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
  }

  body[data-route="editor"] .outfit-card-copy small {
    color: #a5ad9a;
    font-size: 9px;
    line-height: 1.6;
  }

  body[data-route="editor"] .outfit-card .outfit-delete {
    width: 28px;
    height: 28px;
    min-height: 28px;
    border: 0;
    color: #7d8f78;
    background: #e0e7d8;
    font-size: 21px;
  }
}

/* User readability pass: the original 2.175 palette is intentionally soft,
   but this prototype must remain legible on a 320px phone. Artwork alpha is
   kept, while every text-bearing UI surface below is opaque. */
body[data-route="editor"] .touch-feedback,
body[data-route="editor"] .touch-feedback[data-state="panel"],
body[data-route="editor"] .touch-feedback[data-state="color"],
body[data-route="editor"] .touch-feedback[data-state="layer"],
body[data-route="editor"] .touch-feedback[data-state="scroll"],
body[data-route="editor"] .touch-feedback[data-state="success"],
body[data-route="editor"] .touch-feedback[data-state="canceled"] {
  color: #253c2d !important;
  background: #f8faf4 !important;
  border-color: #9cab94 !important;
  box-shadow: 0 5px 16px rgb(48 66 52 / 24%) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body[data-route="editor"] .touch-feedback[data-state="color"] {
  background: #fcf8fa !important;
  border-color: #b5a1ad !important;
}

body[data-route="editor"] .touch-feedback[data-state="layer"] {
  background: #fbf8f2 !important;
  border-color: #b3a28f !important;
}

body[data-route="editor"] .touch-feedback[data-state="success"] {
  background: #f3f9f1 !important;
  border-color: #91ad91 !important;
}

body[data-route="editor"] .touch-feedback[data-state="canceled"] {
  background: #fcf5f5 !important;
  border-color: #bba0a5 !important;
}

body[data-route="editor"] .touch-feedback-copy b {
  color: #253c2d !important;
  font-size: 12px !important;
  line-height: 1.25;
}

body[data-route="editor"] .touch-feedback-copy small {
  color: #405747 !important;
  font-size: 10px !important;
  line-height: 1.35;
}

body[data-route="editor"] .touch-feedback button {
  color: #324a38 !important;
  background: #eef3e9 !important;
  border-color: #9cab94 !important;
  font-size: 11px !important;
}

body[data-route="editor"] .touch-feedback #touchFeedbackUndo {
  color: #fff !important;
  background: #49684f !important;
  border-color: #49684f !important;
}

body[data-route="editor"] .editor-title h2 {
  color: #2f4937 !important;
}

body[data-route="editor"] .panel-selection b,
body[data-route="editor"] .panel-command-actions .layer-quick-button,
body[data-route="editor"] .panel-command-actions .history-group button,
body[data-route="editor"] .closet-scroll-note,
body[data-route="editor"] .item-card b,
body[data-route="editor"] .item-card small {
  color: #344e39 !important;
}

body[data-route="editor"] .panel-selection small,
body[data-route="editor"] .control-title {
  color: #455d49 !important;
}

body[data-route="editor"] .tabs button,
body[data-route="editor"] .category-row button {
  color: #405842 !important;
  background: #f2f5ed !important;
}

body[data-route="editor"] .tabs button.active {
  color: #243d2c !important;
  background: #dce8d4 !important;
}

body[data-route="editor"] .category-row button.active {
  color: #243d2c !important;
  background: #edf3e8 !important;
  border-bottom-color: #58775b !important;
}

body[data-route="editor"] .outfit-card,
body[data-route="editor"] .outfit-card-load,
body[data-route="editor"] .outfit-card-preview,
body[data-route="editor"] .outfit-card-copy,
body[data-route="editor"] .outfit-card-actions,
body[data-route="editor"] .outfit-card-actions button,
body[data-route="editor"] .outfit-new-slot {
  opacity: 1 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body[data-route="editor"] .outfit-card-copy b {
  color: #2d4935 !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
}

body[data-route="editor"] .outfit-card-copy small,
body[data-route="editor"] .outfit-new-slot > small {
  color: #415a45 !important;
  font-size: 10px !important;
  line-height: 1.45 !important;
}

body[data-route="editor"] .outfit-card-actions {
  background: #f8f8f1 !important;
}

body[data-route="editor"] .outfit-card-actions button {
  color: #314b37 !important;
  background: #fffef9 !important;
  border-color: #afbea9 !important;
}

body[data-route="editor"] .outfit-card-actions button:first-child {
  color: #314b37 !important;
  background: #fffef9 !important;
}

body[data-route="editor"] .outfit-card .outfit-delete {
  color: #2d4734 !important;
  background: #e2eadb !important;
  border: 1px solid #a8b9a2 !important;
}

body[data-route="editor"] .item-thumbnail,
body[data-route="editor"] .layer-thumbnail,
body[data-route="editor"] .outfit-card-preview {
  background-image: none !important;
}

@media (max-width: 850px) {
  body[data-route="editor"] .tabs button {
    color: #405842 !important;
    font-size: 12.5px !important;
  }

  body[data-route="editor"] .tabs button.active {
    color: #243d2c !important;
  }

  body[data-route="editor"] .category-row button {
    color: #405842 !important;
    font-size: 12px !important;
  }

  body[data-route="editor"] .panel-selection b {
    color: #344e39 !important;
    font-size: 12px !important;
  }

  body[data-route="editor"] .outfit-card-copy b {
    color: #2d4935 !important;
    font-size: 13px !important;
  }

  body[data-route="editor"] .outfit-card-copy small {
    color: #415a45 !important;
    font-size: 10px !important;
  }

  body[data-route="editor"] .outfit-card-actions button {
    color: #314b37 !important;
    background: #fffef9 !important;
  }

  body[data-route="editor"] .outfit-card-actions button:first-child {
    color: #314b37 !important;
    background: #fffef9 !important;
  }

  body[data-route="editor"] .touch-feedback {
    min-height: 48px;
    padding: 5px 6px 5px 10px;
  }
}

/*
 * Android 2.175 outfit-grid runtime geometry at the 412 CSS-pixel phone
 * viewport:
 * - 2px horizontal catalogue padding and a 9px column gap
 * - 180.17px cards
 * - 148.24px card face with 5px top/5px side/8px bottom inset
 * - 36px slot action row, so a save-mode slot is 189.24px high
 *
 * Keep the user's stronger text contrast and opaque fills, while preserving
 * the original geometry rather than letting the web grid stretch the cards.
 */
@media (max-width: 850px) {
  body[data-route="editor"] .catalog-grid.outfit-grid {
    grid-template-columns: repeat(2, minmax(0, 180px));
    gap: 9px;
    padding: 0 2px 5px;
  }

  body[data-route="editor"] .outfit-card {
    width: auto;
    max-width: 180px;
    gap: 5px;
  }

  body[data-route="editor"] .outfit-card.is-current .outfit-card-load,
  body[data-route="editor"] .outfit-card.is-current .outfit-card-preview,
  body[data-route="editor"] .outfit-card.is-current .outfit-card-copy {
    background: #eaf0e1 !important;
  }

  body[data-route="editor"] .outfit-card.is-current .outfit-card-load {
    border-color: #aabc96;
    box-shadow: none;
  }

  body[data-route="editor"] .outfit-card-load {
    box-sizing: border-box;
    width: 100%;
    height: 148px;
    min-height: 148px;
    padding: 5px 5px 8px;
    gap: 0;
  }

  body[data-route="editor"] .outfit-card-preview {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    min-height: 0;
  }

  body[data-route="editor"] .outfit-card-copy {
    flex: 0 0 32px;
    box-sizing: border-box;
    width: 100%;
    min-height: 32px;
    padding: 0;
  }

  body[data-route="editor"] .outfit-new-slot {
    box-sizing: border-box;
    width: 100%;
    max-width: 180px;
    height: 135px;
    min-height: 135px;
  }

  body[data-route="editor"] .panel-command-actions .history-group {
    gap: 6px;
  }

  body[data-route="editor"] .panel-command-actions .history-group button {
    display: inline-flex;
    width: auto;
    min-width: 0;
    height: 30px;
    min-height: 30px;
    padding: 0 4px;
    gap: 3px;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    color: #53684c;
    background: #f3f6ee !important;
    font-size: 11px;
  }

  body[data-route="editor"] .panel-command-actions .history-group button svg {
    width: 14px;
    height: 14px;
    flex: none;
  }

  body[data-route="editor"] .panel-command-actions .history-group button span {
    display: inline;
    font-size: 11px;
    line-height: 1;
  }
}

/*
 * Wardrobe text is always painted on its own solid surface. Artwork may keep
 * transparency, but labels, notes, badges and dialog regions never depend on
 * the colour behind them for legibility.
 */
body[data-route="editor"] .closet-scroll-note,
body[data-route="editor"] .closet-note,
body[data-route="editor"] .panel-selection,
body[data-route="editor"] .catalog-heading,
body[data-route="editor"] .closet-note-row,
body[data-route="editor"] #adjustCurrentPart,
body[data-route="editor"] .outfit-toolbar,
body[data-route="editor"] .outfit-card-load,
body[data-route="editor"] .outfit-card-preview,
body[data-route="editor"] .outfit-card-copy,
body[data-route="editor"] .outfit-card-actions,
body[data-route="editor"] .outfit-card-actions button,
body[data-route="editor"] .outfit-current-badge,
body[data-route="editor"] .outfit-new-slot,
body[data-route="editor"] .outfit-dialog,
body[data-route="editor"] .outfit-dialog > form,
body[data-route="editor"] .outfit-dialog > div,
body[data-route="editor"] .outfit-dialog header,
body[data-route="editor"] .outfit-dialog-body,
body[data-route="editor"] .outfit-dialog footer,
body[data-route="editor"] .outfit-import-layout,
body[data-route="editor"] .outfit-import-preview,
body[data-route="editor"] .outfit-import-copy {
  background-image: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body[data-route="editor"] .closet-scroll-note,
body[data-route="editor"] .closet-note,
body[data-route="editor"] .panel-selection,
body[data-route="editor"] .catalog-heading,
body[data-route="editor"] .closet-note-row,
body[data-route="editor"] #adjustCurrentPart,
body[data-route="editor"] .outfit-toolbar,
body[data-route="editor"] .outfit-dialog,
body[data-route="editor"] .outfit-dialog > form,
body[data-route="editor"] .outfit-dialog > div,
body[data-route="editor"] .outfit-dialog header,
body[data-route="editor"] .outfit-dialog-body,
body[data-route="editor"] .outfit-import-layout,
body[data-route="editor"] .outfit-import-copy {
  background-color: #fbfaf4 !important;
}

body[data-route="editor"] .outfit-card-load,
body[data-route="editor"] .outfit-card-preview,
body[data-route="editor"] .outfit-card-copy {
  background-color: #f1f2e9 !important;
}

body[data-route="editor"] .outfit-card.is-current .outfit-card-load,
body[data-route="editor"] .outfit-card.is-current .outfit-card-preview,
body[data-route="editor"] .outfit-card.is-current .outfit-card-copy {
  background-color: #eaf0e1 !important;
}

body[data-route="editor"] .outfit-card-actions {
  background-color: #f8f8f1 !important;
}

body[data-route="editor"] .outfit-card-actions button,
body[data-route="editor"] .outfit-new-slot {
  background-color: #fffef9 !important;
}

body[data-route="editor"] .outfit-current-badge {
  color: #fffef9 !important;
  background-color: #506d56 !important;
}

body[data-route="editor"] .outfit-dialog footer {
  background-color: #f4f5ef !important;
}

body[data-route="editor"] .outfit-import-preview {
  background-color: #e5ebe2 !important;
}

body[data-route="editor"] .closet-note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  color: #344e39;
}

body[data-route="editor"] .closet-note-row .closet-scroll-note {
  flex: 1 1 auto;
  min-width: 0;
}

body[data-route="editor"] #adjustCurrentPart {
  flex: none;
  min-height: 30px;
  margin: 0;
  padding: 6px 11px;
  border: 1px solid #a8b9a2;
  border-radius: 10px;
  color: #2d4935;
  background: #eef3e9 !important;
  font: 600 11px/1.2 "YuzuPop", "Noto Sans SC", sans-serif;
  letter-spacing: 0;
  cursor: pointer;
}

body[data-route="editor"] #adjustCurrentPart:active {
  background: #dce8d7 !important;
}

body[data-route="editor"] #adjustCurrentPart[aria-expanded="true"] {
  color: #fffef9;
  background: #506d56 !important;
  border-color: #506d56;
}

@media (min-width: 851px) {
  body[data-route="editor"] .closet-note-row {
    display: none;
  }
}

@media (max-width: 850px) {
  body[data-route="editor"] .closet-note-row {
    min-height: 30px;
    margin: 0;
  }

  body[data-route="editor"] .closet-note-row .closet-scroll-note {
    padding-bottom: 0;
  }

  body[data-route="editor"] #adjustCurrentPart {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 10.5px;
  }
}

/*
 * Android 2.175 live wardrobe geometry:
 * - the Android shell owns the 62.76px title bar and has no in-page back key
 * - stage and panel are opaque #ecefe7 and #f8f8f1
 * - 412px-class phones use two 180px outfit columns with a 9px gap
 * - every unselected card face is #f1f2e9; only the worn card is green
 *
 * The larger heading and darker text from the readability pass stay in place.
 */
@media (max-width: 850px) {
  body[data-route="editor"] .editor-header {
    grid-template-columns: minmax(0, 1fr) auto;
    background: #f6f5ef !important;
  }

  body[data-route="editor"] .editor-header .back-button {
    display: none !important;
  }

  body[data-route="editor"] .editor-title {
    min-width: 0;
  }

  body[data-route="editor"] .character-stage {
    background: #ecefe7 !important;
  }

  body[data-route="editor"] .tool-panel,
  body[data-route="editor"] .panel-scroll {
    background: #f8f8f1 !important;
  }

  body[data-route="editor"] .catalog-grid.outfit-grid {
    grid-template-columns: repeat(2, minmax(0, 180px));
    justify-content: start;
  }

  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card:not(.is-current),
  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card:not(.is-current) .outfit-card-load,
  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card:not(.is-current) .outfit-card-preview,
  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card:not(.is-current) .outfit-card-copy {
    background: #f1f2e9 !important;
  }

  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card.is-current,
  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card.is-current .outfit-card-load,
  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card.is-current .outfit-card-preview,
  body[data-route="editor"] .catalog-grid.outfit-grid .outfit-card.is-current .outfit-card-copy {
    background: #eaf0e1 !important;
  }

  body[data-route="editor"] .outfit-card-preview::before {
    display: none !important;
  }
}

@media (max-width: 402px) {
  body[data-route="editor"] .catalog-grid.outfit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/*
 * Wardrobe dialogs use a solid backdrop as well. The user asked that text
 * surfaces never depend on a translucent layer; only character artwork keeps
 * its own alpha channel. This also removes the browser-dependent blur path
 * from Android WebView.
 */
body[data-route="editor"] .outfit-dialog::backdrop,
body[data-route="editor"] .part-import-dialog::backdrop,
body[data-route="editor"] .color-picker-dialog::backdrop,
body[data-route="editor"] .saved-color-delete-dialog::backdrop,
body[data-route="editor"] .wardrobe-select-dialog::backdrop {
  background: #cbd6c8 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/*
 * Final wardrobe chrome parity and readability.
 *
 * The original 2.175 phone shell paints the title directly on the opaque
 * #f6f5ef header. A separate #ecefe7 title slab makes the prototype look
 * translucent even though the colour itself has alpha 1. Keep the stronger
 * descriptive text from the readability pass, but reproduce the original
 * single header surface. The save/completion button also keeps one pale fill
 * in both modes; only its label changes.
 */
@media (max-width: 850px) {
  body[data-route="editor"] .editor-header {
    color: #52694f;
    background: #f6f5ef !important;
    background-image: none !important;
    opacity: 1 !important;
  }

  body[data-route="editor"] .editor-title {
    color: #52694f;
    background: #f6f5ef !important;
    background-image: none !important;
    opacity: 1 !important;
  }

  body[data-route="editor"] .editor-title h2 {
    color: #384f3c !important;
  }

  body[data-route="editor"] .done-button,
  body[data-route="editor"] .done-button:is(:hover, :focus-visible, :active) {
    color: #263e31 !important;
    background: #9db4a7 !important;
    background-image: none !important;
    opacity: 1 !important;
  }

  body[data-route="editor"] #wardrobeSave,
  body[data-route="editor"] #wardrobeSave.active,
  body[data-route="editor"] #wardrobeSave:is(:hover, :focus-visible, :active) {
    color: #3f5947 !important;
    background: #f7f8f0 !important;
    border-color: #d5dfd1 !important;
    opacity: 1 !important;
  }

  body[data-route="editor"] .panel-command-bar,
  body[data-route="editor"] .panel-scroll,
  body[data-route="editor"] .tabs,
  body[data-route="editor"] .category-row,
  body[data-route="editor"] .closet-note-row {
    background-color: #f8f8f1 !important;
    background-image: none !important;
    opacity: 1 !important;
  }

  body[data-route="editor"] .tabs button,
  body[data-route="editor"] .category-row button {
    background-color: transparent !important;
    background-image: none !important;
    opacity: 1 !important;
  }

  body[data-route="editor"] .tabs button.active {
    background-color: #dce8d4 !important;
    box-shadow: none !important;
  }

  body[data-route="editor"] .category-row button.active {
    background-color: transparent !important;
    border-bottom: 2px solid #aebf9e !important;
  }
}

/*
 * 2.175 phone wardrobe geometry.
 *
 * These values come from the original same-viewport DOM at 412 x 842 CSS px:
 * a 16 px shell title, five equal 73.6 px category tabs, a 52 px day/night
 * control, and a 51.5 x 33 px save-mode control. The source art keeps its own
 * alpha, while every control surface remains painted with an opaque fill.
 */
@media (max-width: 850px) {
  body[data-route="editor"] .editor-title h2 {
    width: max-content;
    font-size: 16px !important;
    line-height: 1.45 !important;
  }

  body[data-route="editor"] .tabs {
    gap: 3px !important;
  }

  body[data-route="editor"] .tabs button {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    padding: 7px 2px !important;
    color: #5f6e58 !important;
    background: transparent !important;
    font-size: clamp(11.5px, 2.9vw, 12px) !important;
  }

  body[data-route="editor"] .tabs button.active {
    color: #48633f !important;
    background: #e3ebd9 !important;
  }

  body[data-route="editor"] .outfit-card-preview canvas {
    right: auto;
    bottom: 0;
    left: 50%;
    width: auto;
    max-width: 100%;
    height: 100%;
    aspect-ratio: 230 / 240;
    transform: translateX(-50%);
  }

  body[data-route="editor"] .wardrobe-stage-actions button,
  body[data-route="editor"] .wardrobe-stage-actions button:not(.active) {
    color: #8c9b80 !important;
    border-color: #d8dfd0 !important;
    background: #f5f6ed !important;
    background-image: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
  }

  body[data-route="editor"] .wardrobe-stage-actions button svg {
    display: none !important;
  }

  body[data-route="editor"] #wardrobeClear svg {
    display: block !important;
  }

  body[data-route="editor"] #wardrobeTurn,
  body[data-route="editor"] #wardrobeMirror {
    min-height: 30px;
    padding: 6px 8px;
    font-size: 10px !important;
  }

  body[data-route="editor"] #wardrobeTurn span::before {
    content: "↻ ";
  }

  body[data-route="editor"] #wardrobeMirror span::before {
    content: "⇄ ";
  }

  body[data-route="editor"] #wardrobeNight span::before {
    content: "☾ ";
  }

  body[data-route="editor"] #wardrobeMirror {
    top: 90.5px;
  }

  body[data-route="editor"] #wardrobeFreeImport {
    min-height: 33px;
    padding: 7px 13px;
    font-size: 12px !important;
  }

  body[data-route="editor"] #wardrobeNight {
    padding: 6px 10px;
    font-size: 11px !important;
  }

  body[data-route="editor"] #wardrobeSave,
  body[data-route="editor"] #wardrobeSave:not(.active) {
    top: 50px;
    min-height: 33px;
    padding: 7px 13px;
    font-size: 12px !important;
  }

  body[data-route="editor"] #wardrobeSave.active,
  body[data-route="editor"] #wardrobeSave.active:is(:hover, :focus-visible, :active) {
    color: #5c7b70 !important;
    border-color: #cfddd2 !important;
    background: #dce8de !important;
  }

  body[data-route="editor"] #wardrobeShare {
    top: 112px;
    min-height: 35px;
    padding: 8px 14px;
    border-radius: 12px;
    color: #7b8d73 !important;
    background: #f6f8ee !important;
    font-size: 12px !important;
  }
}

/*
 * Yuzu 2.175 landscape wardrobe.
 *
 * The Android build does not rotate the portrait editor into a wider desktop
 * layout. It keeps the same 440px wardrobe card, centres it in the landscape
 * WebView, and gives the room plus collection sheet their own internal
 * scrollers. Keep this block last: wardrobe.css overrides several generic
 * mobile rules from styles.css.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="editor"] {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background:
      linear-gradient(rgb(238 242 235 / 18%), rgb(238 242 235 / 18%)),
      #c4cdc2;
  }

  body[data-route="editor"]::before {
    display: none !important;
  }

  body[data-route="editor"] .app-frame {
    width: min(100%, 440px);
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    background: transparent;
  }

  body[data-route="editor"] main {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  body[data-route="editor"] .site-header {
    display: none !important;
  }

  body[data-route="editor"] #editorView {
    position: fixed;
    top: 22px;
    left: 50%;
    z-index: 20;
    display: block;
    width: 440px;
    height: 320px;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgb(220 221 209 / 75%);
    border-radius: 23px;
    background: #f6f5ef !important;
    box-shadow: 0 22px 70px rgb(45 57 48 / 20%);
    transform: translateX(-50%);
  }

  body[data-route="editor"] .editor-header {
    display: grid;
    width: 100%;
    height: 57px;
    min-height: 57px;
    margin: 0;
    padding: 9px 16px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 0;
    border-bottom: 1px solid #d9dfd4;
    border-radius: 0;
    background: #f6f5ef !important;
  }

  body[data-route="editor"] .editor-header .back-button,
  body[data-route="editor"] .editor-title p,
  body[data-route="editor"] .editor-status,
  body[data-route="editor"] .editor-actions .text-button {
    display: none !important;
  }

  body[data-route="editor"] .editor-title {
    display: block;
    min-width: 0;
    background: transparent !important;
  }

  body[data-route="editor"] .editor-title h2 {
    width: auto;
    color: #7b9078 !important;
    font-family: "YuzuPop", "Microsoft YaHei", sans-serif;
    font-size: 16px !important;
    font-weight: 700;
    line-height: 1.4 !important;
    white-space: nowrap;
  }

  body[data-route="editor"] .editor-actions {
    display: block;
    margin: 0;
  }

  body[data-route="editor"] .done-button {
    min-width: 64px;
    min-height: 38px;
    height: 38px;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    color: #4b6354 !important;
    background: #9db4a7 !important;
    font-size: 11px;
  }

  body[data-route="editor"] .editor-layout {
    display: grid;
    width: 100%;
    height: calc(100% - 57px);
    min-height: 0;
    margin: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 125px minmax(0, 1fr);
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #f8f8f1 !important;
    box-shadow: none;
  }

  body[data-route="editor"] .preview-panel {
    position: relative;
    display: block;
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #ecefe7 !important;
  }

  body[data-route="editor"] .preview-toolbar {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: block;
    min-height: 0;
    pointer-events: none;
  }

  body[data-route="editor"] .preview-toolbar > div:first-child,
  body[data-route="editor"] .preview-actions,
  body[data-route="editor"] .preview-footer {
    display: none !important;
  }

  body[data-route="editor"] .character-stage {
    position: absolute;
    inset: 0;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: #ecefe7 !important;
  }

  body[data-route="editor"] .wardrobe-room {
    inset: 0;
  }

  body[data-route="editor"] .wardrobe-room svg {
    width: 100%;
    height: 100%;
  }

  body[data-route="editor"] #editorCanvas {
    top: -15px;
    right: 50%;
    bottom: auto;
    left: auto;
    width: 168px;
    height: 158px;
    transform: translateX(50%);
  }

  body[data-route="editor"] .wardrobe-stage-actions {
    inset: 0;
    display: block;
    pointer-events: none;
  }

  body[data-route="editor"] .wardrobe-stage-actions button,
  body[data-route="editor"] .wardrobe-stage-actions button:not(.active) {
    position: absolute;
    width: auto;
    min-width: 0;
    min-height: 28px;
    padding: 4px 9px;
    gap: 4px;
    border: 1px solid #d9dfd0;
    border-radius: 11px;
    color: #8c9b80 !important;
    background: #f5f6ed !important;
    box-shadow: none !important;
    font-size: 10px !important;
    line-height: 1;
    white-space: nowrap;
    pointer-events: auto;
  }

  body[data-route="editor"] .wardrobe-stage-actions button svg {
    display: none !important;
  }

  body[data-route="editor"] #wardrobeClear {
    top: 8px;
    left: 8px;
    display: grid;
    width: 31px;
    height: 31px;
    padding: 0;
    place-items: center;
  }

  body[data-route="editor"] #wardrobeClear svg {
    display: block !important;
    width: 17px;
    height: 17px;
  }

  body[data-route="editor"] #wardrobeTurn {
    top: 46px;
    left: 8px;
  }

  body[data-route="editor"] #wardrobeMirror {
    top: 81px;
    left: 8px;
  }

  body[data-route="editor"] #wardrobeFreeImport {
    bottom: 8px;
    left: 8px;
  }

  body[data-route="editor"] #wardrobeNight {
    top: 8px;
    right: 8px;
  }

  body[data-route="editor"] #wardrobeSave {
    top: 44px;
    right: 8px;
  }

  body[data-route="editor"] #wardrobeShare {
    top: 80px;
    right: 8px;
  }

  body[data-route="editor"] #wardrobeOutfitImport {
    top: 116px;
    right: 8px;
  }

  body[data-route="editor"] .canvas-interaction-hint {
    display: none;
  }

  body[data-route="editor"] .canvas-candidates {
    right: 8px;
    bottom: 8px;
    left: 8px;
    max-height: calc(100% - 16px);
    overflow: auto;
  }

  body[data-route="editor"] .tool-panel {
    display: grid;
    min-width: 0;
    min-height: 0;
    grid-template-rows: 33px minmax(0, 1fr) auto;
    overflow: hidden;
    border: 0;
    border-top: 1px solid #d9dfd2;
    border-radius: 18px 18px 0 0;
    background: #f8f8f1 !important;
  }

  body[data-route="editor"] .panel-command-bar {
    min-height: 33px;
    height: 33px;
    padding: 4px 12px;
    gap: 7px;
    overflow: hidden;
    border: 0;
    background: #f8f8f1 !important;
  }

  body[data-route="editor"] .panel-selection {
    min-width: 0;
    gap: 4px;
  }

  body[data-route="editor"] .panel-selection small {
    display: none;
  }

  body[data-route="editor"] .panel-selection b {
    max-width: 115px;
    color: #7f9278 !important;
    font-size: 10px;
  }

  body[data-route="editor"] .panel-command-actions {
    min-width: 0;
    gap: 3px;
  }

  body[data-route="editor"] .panel-command-actions .layer-quick-button,
  body[data-route="editor"] .panel-command-actions .history-group button {
    min-height: 25px;
    height: 25px;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 9px;
  }

  body[data-route="editor"] .panel-command-actions .layer-quick-button svg,
  body[data-route="editor"] .panel-command-actions .history-group button svg {
    width: 13px;
    height: 13px;
  }

  body[data-route="editor"] .panel-command-actions .layer-quick-button b {
    min-width: 14px;
    padding: 0 3px;
    font-size: 7px;
  }

  body[data-route="editor"] .panel-command-actions .history-group button span {
    display: none;
  }

  body[data-route="editor"] .panel-scroll {
    min-height: 0;
    padding: 0 12px 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    background: #f8f8f1 !important;
  }

  body[data-route="editor"] .tabs {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    min-height: 31px;
    padding: 0 0 3px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    border: 0;
    border-radius: 0;
    background: #f8f8f1 !important;
  }

  body[data-route="editor"] .tabs button {
    min-height: 28px;
    padding: 3px 2px;
    border-radius: 9px;
    font-size: 10px !important;
  }

  body[data-route="editor"] .category-row {
    position: sticky;
    top: 31px;
    z-index: 29;
    min-height: 27px;
    padding: 3px 0 4px;
    gap: 5px;
    background: #f8f8f1 !important;
  }

  body[data-route="editor"] .category-row button {
    min-height: 22px;
    padding: 0 8px;
    font-size: 9px !important;
  }

  body[data-route="editor"] .closet-note-row {
    min-height: 18px;
    margin: 0;
    padding: 0 0 2px;
  }

  body[data-route="editor"] .closet-scroll-note,
  body[data-route="editor"] .closet-note {
    font-size: 8px !important;
  }

  body[data-route="editor"] .catalog-heading {
    display: none !important;
  }

  body[data-route="editor"] .catalog-grid {
    gap: 7px;
    padding-bottom: 4px;
  }

  body[data-route="editor"] .catalog-grid.outfit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  body[data-route="editor"] .item-card {
    min-height: 82px;
    padding: 5px;
    border-radius: 10px;
  }

  body[data-route="editor"] .item-thumbnail {
    aspect-ratio: 2 / 1;
  }

  body[data-route="editor"] .outfit-card-preview {
    height: 58px;
  }

  body[data-route="editor"] .outfit-card-copy {
    min-height: 23px;
    padding-bottom: 4px;
  }

  body[data-route="editor"] .outfit-card-copy b {
    font-size: 10px !important;
  }

  body[data-route="editor"] .outfit-card-actions {
    gap: 4px;
  }

  body[data-route="editor"] .outfit-card-actions button {
    min-height: 27px;
    font-size: 9px;
  }

  body[data-route="editor"] .edit-dock {
    max-height: 108px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  body[data-route="editor"] .dock-heading {
    min-height: 29px;
    padding: 4px 12px;
  }

  body[data-route="editor"] .dock-heading small {
    display: none;
  }

  body[data-route="editor"] .dock-heading b {
    font-size: 11px;
  }

  body[data-route="editor"] .dock-collapse {
    min-height: 24px;
    font-size: 8px;
  }

  body[data-route="editor"] .dock-body {
    padding: 0 12px 8px;
    gap: 8px;
  }

  body[data-route="editor"] .control-title {
    margin-bottom: 4px;
    font-size: 8px;
  }

  body[data-route="editor"] .swatches {
    gap: 5px;
  }

  body[data-route="editor"] .swatch,
  body[data-route="editor"] .saved-color-swatch {
    width: 21px;
    height: 21px;
  }

  body[data-route="editor"] .touch-feedback {
    right: 4px;
    left: 4px;
    min-height: 29px;
  }

  body[data-route="editor"] .toast {
    bottom: 12px;
  }

  body[data-route="editor"] dialog {
    max-height: calc(100dvh - 16px);
  }
}

/*
 * 2.175 landscape face tracking. The original page keeps the same central
 * 420px control stack used by the companion room, with the character and room
 * scenery filling the remaining width.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="live"] {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: #f5f2ec;
  }

  body[data-route="live"]::before,
  body[data-route="live"] .site-header {
    display: none !important;
  }

  body[data-route="live"] .app-frame {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #f5f2ec;
  }

  body[data-route="live"] main {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  #liveView {
    position: fixed;
    inset: 0;
    z-index: 15000;
    display: block;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: #687d70;
    background: #f5f2ec;
    font-family: "YuzuPop", "Microsoft YaHei", sans-serif;
  }

  #liveView .live-header {
    position: absolute;
    top: 12px;
    right: 20px;
    left: 20px;
    z-index: 40;
    display: flex;
    width: auto;
    height: 48px;
    min-height: 48px;
    margin: 0;
    padding: 0;
    align-items: center;
    border: 0;
    pointer-events: none;
  }

  #liveView .live-header .mode-heading {
    order: -1;
    min-width: 0;
    margin: 0;
  }

  #liveView .live-header .mode-heading p,
  #liveView .live-header .mode-save-state {
    display: none !important;
  }

  #liveView .live-header .mode-heading h2 {
    margin: 0;
    color: #6d7f86;
    font: 700 23px/1.45 "YuzuPop", "Microsoft YaHei", sans-serif;
  }

  #liveView .live-header .live-close-button {
    position: relative;
    order: 2;
    display: grid;
    width: 40px;
    height: 48px;
    min-width: 40px;
    margin: 0 0 0 auto;
    padding: 8px;
    border: 0;
    border-radius: 50%;
    place-items: center;
    color: #8a9380;
    background: #e8e9df;
    pointer-events: auto;
  }

  #liveView .live-header .live-close-button svg {
    width: 22px;
    height: 22px;
  }

  #liveView .live-layout {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    overflow: hidden;
  }

  #liveView .live-stage-card {
    position: absolute;
    inset: 0;
    display: block;
    width: auto;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  #liveView .live-stage-topline,
  #liveView .live-panel {
    display: none !important;
  }

  #liveView .live-mode-caption {
    position: absolute;
    top: 76px;
    right: 20px;
    left: 20px;
    z-index: 14;
    display: block;
    margin: 0;
    color: #839189;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
  }

  #liveView .live-reset-button {
    position: absolute;
    top: 124px;
    left: 20px;
    z-index: 16;
    display: grid;
    width: 39px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    place-items: center;
    color: #576e64;
    background: #e3e9e4;
    font-size: 19px;
  }

  #liveView .live-room-scenery {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    overflow: hidden;
    background: #f5f2ec;
    pointer-events: none;
  }

  #liveView .live-room-window {
    position: absolute;
    top: 88px;
    left: 82px;
    width: 150px;
    height: 160px;
    overflow: hidden;
    border: 8px solid #fffdf7;
    border-bottom: 0;
    border-radius: 78px 78px 0 0;
    background: #dbe7e6;
  }

  #liveView .live-room-window::before,
  #liveView .live-room-window::after {
    position: absolute;
    background: #fffdf7;
    content: "";
  }

  #liveView .live-room-window::before {
    top: 0;
    bottom: 0;
    left: calc(50% - 2px);
    width: 5px;
  }

  #liveView .live-room-window::after {
    top: calc(55% - 2px);
    right: 0;
    left: 0;
    height: 5px;
  }

  #liveView .live-room-shelf {
    position: absolute;
    top: 168px;
    right: 10%;
    width: 150px;
    height: 7px;
    background: #c8b9a7;
  }

  #liveView .live-room-shelf::before {
    position: absolute;
    right: 15%;
    bottom: 5px;
    width: 34px;
    height: 45px;
    border-radius: 3px 3px 9px 9px;
    background:
      linear-gradient(90deg, transparent 0 28%, #dcc1c5 28% 72%, transparent 72%),
      linear-gradient(#aebfa6, #aebfa6) 50% 0 / 18px 22px no-repeat;
    content: "";
  }

  #liveView .live-room-shelf::after {
    position: absolute;
    right: 54%;
    bottom: 5px;
    width: 42px;
    height: 25px;
    border-radius: 4px;
    background: linear-gradient(155deg, #c6d4d8, #9db1b5);
    content: "";
  }

  #liveView .live-room-art {
    position: absolute;
    top: 89px;
    right: 18%;
    width: 54px;
    height: 54px;
  }

  #liveView .live-stage {
    --live-scale: 1;
    position: absolute;
    top: 22px;
    left: 50%;
    z-index: 5;
    width: 340px;
    height: 245px;
    min-height: 0;
    overflow: visible;
    border-radius: 0;
    background: transparent;
    transform: translateX(-50%);
  }

  #liveView .live-stage::before,
  #liveView .live-stage::after,
  #liveView .live-stage-orbit,
  #liveView .live-stage-spark,
  #liveView .live-camera-note,
  #liveView .live-expression-chip {
    display: none;
  }

  #liveView #liveCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  #liveView .live-stage-toolbar {
    position: absolute;
    top: 99px;
    right: 20px;
    bottom: auto;
    z-index: 24;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
  }

  #liveView .live-stage-card.controls-collapsed .live-stage-toolbar {
    top: 99px;
    bottom: auto;
  }

  #liveView .live-stage-toolbar button {
    min-height: 32px;
    padding: 6px 13px;
    border: 1px solid #dce2d8;
    border-radius: 12px;
    color: #82958b;
    background: #fffdf4;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  #liveView #liveFilterOpen {
    color: #7f9287;
    background: #edf0e9;
  }

  #liveView .live-controls {
    position: absolute;
    top: 145px;
    right: auto;
    bottom: auto;
    left: calc(50% - 210px);
    z-index: 20;
    display: grid;
    width: 420px;
    max-width: none;
    margin: 0;
    padding: 7px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    border-radius: 18px 18px 0 0;
    background: transparent;
  }

  #liveView .live-stage-card.controls-collapsed .live-controls {
    display: none;
  }

  #liveView .live-controls button {
    position: relative;
    min-width: 0;
    min-height: 41px;
    padding: 8px 10px;
    border: 1px solid #dce3d9;
    border-radius: 16px;
    color: #718995;
    background: #dce8ed;
    font: 13px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  #liveView .live-controls button b {
    font-size: 13px;
    font-weight: 400;
  }

  #liveView .live-controls button small,
  #liveView .live-control-icon {
    display: none;
  }

  #liveView .live-controls .live-camera-toggle {
    order: 1;
    display: block;
    grid-column: 1 / -1;
    min-height: 41px;
  }

  #liveView .live-controls .live-camera-toggle.active {
    color: #718995;
    border-color: #dce3d9;
    background: #dce8ed;
  }

  #liveView #liveCalibrate {
    display: none;
  }

  #liveView #liveBackgroundOpen {
    order: 2;
    color: #9a7a89;
    background: #f0dfe3;
  }

  #liveView #liveSettingsToggle {
    order: 3;
    color: #8b8197;
    background: #e6e3ed;
  }

  #liveView #liveScreenToggle {
    order: 4;
    display: block;
    color: #788e9b;
    background: #dde8ed;
  }

  #liveView #liveCameraPreviewToggle {
    order: 5;
    color: #84907c;
    background: #eeeee5;
  }

  #liveView .live-mobile-size {
    order: 6;
    display: grid;
    min-height: 32px;
    padding: 2px 4px;
    grid-column: 1 / -1;
    grid-template-columns: auto minmax(0, 1fr) 42px;
    gap: 12px;
    align-items: center;
    color: #81938c;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  #liveView .live-mobile-size input {
    width: 100%;
    min-width: 0;
    accent-color: #a0b8c1;
  }

  #liveView .live-mobile-size output {
    text-align: right;
  }

  #liveView .live-mobile-help {
    order: 7;
    display: block;
    min-height: 18px;
    margin: 0;
    grid-column: 1 / -1;
    color: #87918a;
    font: 10px/17.6px "Microsoft YaHei", "PingFang SC", sans-serif;
    text-align: center;
  }

  #liveView .live-filter-panel {
    position: fixed;
    top: 50%;
    bottom: auto;
    left: 50%;
    z-index: 90;
    display: block;
    width: 420px;
    max-height: calc(100dvh - 16px);
    padding: 12px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid #dce3d8;
    border-radius: 18px;
    color: #7a8f84;
    background: #faf8f1;
    font: 12px/1.35 "YuzuPop", "Microsoft YaHei", sans-serif;
    transform: translate(-50%, -50%);
  }

  #liveView .live-filter-panel[hidden] {
    display: none !important;
  }

  #liveView .live-filter-panel header {
    display: flex;
    margin: 0 0 7px;
    align-items: center;
    justify-content: space-between;
  }

  #liveView .live-filter-panel h3 {
    margin: 0;
    font-size: 16px;
  }

  #liveView .live-filter-panel header button {
    min-width: 28px;
    min-height: 30px;
    padding: 0 6px;
    border: 0;
    color: inherit;
    background: transparent;
    font-size: 20px;
  }

  #liveView .live-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 14px;
  }

  #liveView .live-filter-grid label {
    display: grid;
    min-width: 0;
    grid-template-columns: 1fr auto;
    gap: 2px;
    align-items: center;
  }

  #liveView .live-filter-grid output {
    color: #98a397;
    font-size: 10px;
  }

  #liveView .live-filter-grid input {
    width: 100%;
    height: 22px;
    min-width: 0;
    margin: 0;
    grid-column: 1 / -1;
    accent-color: #9cad99;
  }

  #liveView .live-filter-panel footer {
    display: flex;
    margin-top: 5px;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
  }

  #liveView .live-filter-panel footer span {
    color: #a1aa9b;
    font-size: 9px;
  }

  #liveView .live-filter-panel footer button {
    min-height: 29px;
    padding: 6px 10px;
    border: 1px solid #dce3d8;
    border-radius: 10px;
    color: #7d927f;
    background: #e8eee4;
  }

  #liveSettingsDialog.live-setting-dialog,
  #liveView .live-background-dialog {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/*
 * 2.175 landscape companion room. This page expands to the full WebView;
 * only settings and the wardrobe use a centred card. The measured original
 * positions are 20px side insets, a 420px central control stack, and a 364px
 * fixed viewport with no page scrolling.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="pet"] {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: #f5f2ec;
  }

  body[data-route="pet"]::before,
  body[data-route="pet"] .site-header {
    display: none !important;
  }

  body[data-route="pet"] .app-frame {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #f5f2ec;
  }

  body[data-route="pet"] main {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  #petView {
    position: fixed;
    inset: 0;
    z-index: 15000;
    display: block;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    color: #53675b;
    background: #f5f2ec;
    font-family: "YuzuPop", "Microsoft YaHei", sans-serif;
  }

  #petView .mode-header {
    position: absolute;
    top: 12px;
    right: 20px;
    left: 20px;
    z-index: 40;
    display: flex;
    width: auto;
    height: 48px;
    min-height: 48px;
    margin: 0;
    padding: 0;
    align-items: center;
    border: 0;
  }

  #petView .mode-heading {
    order: -1;
    display: block;
    min-width: 0;
    margin: 0;
    padding: 0;
  }

  #petView .mode-heading p,
  #petView .mode-save-state {
    display: none !important;
  }

  #petView .mode-heading h2 {
    margin: 0;
    color: #6d7f86;
    font: 700 23px/1.45 "YuzuPop", "Microsoft YaHei", sans-serif;
  }

  #petView .mode-header .back-button {
    order: 2;
    display: grid;
    width: 40px;
    height: 48px;
    min-width: 40px;
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: 50%;
    place-items: center;
    color: #829087;
    background: #e8e9df;
  }

  #petView .mode-header .back-button svg {
    display: none;
  }

  #petView .mode-header .back-button::before {
    content: "×";
    font: 20px/1 "YuzuPop", sans-serif;
  }

  .pet-mobile-top-actions,
  .pet-mobile-reset,
  .pet-original-scenery,
  .pet-mobile-toolbox,
  .pet-mobile-help {
    display: block;
  }

  .pet-mobile-top-actions {
    position: absolute;
    top: 76px;
    left: 20px;
    z-index: 35;
    display: flex;
    gap: 8px;
  }

  .pet-mobile-top-actions button {
    display: inline-flex;
    gap: 5px;
    min-height: 41px;
    padding: 8px 13px;
    align-items: center;
    border: 1px solid #d9dfd5;
    border-radius: 15px;
    color: #53675b;
    background: #ecefe7;
    font: 13px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  .pet-mobile-top-actions svg {
    width: 17px;
    height: 17px;
  }

  .pet-mobile-reset {
    position: absolute;
    top: 124px;
    left: 20px;
    z-index: 35;
    display: grid;
    width: 39px;
    height: 37px;
    padding: 0;
    border: 0;
    border-radius: 16px;
    place-items: center;
    color: #576e64;
    background: #e3e9e4;
    font: 19px/1 "YuzuPop", sans-serif;
  }

  #petView .pet-layout {
    position: absolute;
    inset: 0;
    display: block;
    min-height: 0;
  }

  #petView .pet-room {
    position: absolute;
    inset: 0;
    min-height: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    touch-action: none;
  }

  #petView .pet-room::after,
  #petView .pet-room-sky,
  #petView .pet-drag-handle {
    display: none;
  }

  .pet-original-scenery {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    background: #f5f2ec;
    pointer-events: none;
  }

  .pet-original-window {
    position: absolute;
    top: 88px;
    left: 82px;
    width: 150px;
    height: 160px;
    border: 8px solid #fffdf7;
    border-bottom: 0;
    border-radius: 78px 78px 0 0;
    background:
      linear-gradient(90deg, transparent calc(50% - 4px), #fff calc(50% - 4px) calc(50% + 4px), transparent calc(50% + 4px)),
      linear-gradient(transparent 55%, #fff 55% calc(55% + 7px), transparent calc(55% + 7px)),
      #dbe7e6;
  }

  .pet-original-wall-art {
    position: absolute;
    top: 89px;
    right: 18%;
    width: 54px;
    height: 54px;
  }

  .pet-original-shelf {
    position: absolute;
    top: 168px;
    right: 10%;
    width: 150px;
    height: 7px;
    background: #c8b9a7;
  }

  .pet-original-shelf-art {
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
  }

  #petView .pet-instances {
    inset: 0;
    z-index: 3;
  }

  #petView .pet-instances > .pet-instance {
    top: 91px;
    right: auto;
    bottom: auto;
    left: calc(50% - 85px);
    width: 170px;
    height: 245px;
  }

  #petView .pet-instance:nth-child(2),
  #petView .pet-instance:nth-child(3),
  #petView .pet-instance:nth-child(4),
  #petView .pet-instance:nth-child(5),
  #petView .pet-instance:nth-child(6) {
    display: none;
  }

  .pet-mobile-toolbox {
    position: absolute;
    top: 96px;
    right: auto;
    bottom: auto;
    left: calc(50% - 210px);
    z-index: 25;
    display: block;
    width: 420px;
  }

  .pet-mobile-controls-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: auto;
    min-height: 32px;
    padding: 6px 12px;
    border: 1px solid #dce2d8;
    border-radius: 12px;
    color: #82958b;
    background: #fffdf4;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  .pet-mobile-control-grid {
    display: grid;
    width: 420px;
    margin-top: 39px;
    padding: 7px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    border-radius: 18px 18px 0 0;
    background: transparent;
  }

  .pet-mobile-control-grid button {
    min-height: 41px;
    padding: 8px 12px;
    border: 1px solid #dce3d9;
    border-radius: 16px;
    color: #576e64;
    background: #e3e9e4;
    font: 13px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  .pet-mobile-control-grid button:nth-child(2) {
    color: #9a7a89;
    background: #f0dfe3;
  }

  .pet-mobile-control-grid button:nth-child(4) {
    color: #788e9b;
    background: #dde8ed;
  }

  .pet-mobile-control-grid button.active {
    border-color: #a9beb0;
    background: #d5e4d8;
  }

  #petView.pet-mobile-controls-collapsed .pet-mobile-control-grid {
    display: none;
  }

  #petView .pet-panel {
    position: absolute;
    top: 235px;
    right: auto;
    bottom: auto;
    left: calc(50% - 210px);
    z-index: 30;
    display: block;
    width: 420px;
    height: 105px;
    min-height: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  #petView .pet-panel-scroll {
    display: grid;
    height: auto;
    padding: 0;
    gap: 4px;
    overflow: visible;
  }

  #petView .panel-section-heading,
  #petView .pet-actions,
  #petView .pet-count-actions,
  #petView .pet-control-group,
  #petView .field-card,
  #petView .pet-tip {
    display: none !important;
  }

  #petView .pet-panel-scroll > .pet-outfit-picker,
  #petView .pet-panel-scroll > .pet-size-control,
  #petView .pet-panel-scroll > .pet-mobile-help {
    display: grid;
  }

  #petView .pet-outfit-picker {
    width: 406px;
    min-height: 44px;
    margin: 0 7px;
    padding: 0;
    grid-template-columns: 59px minmax(0, 1fr);
    gap: 0 7px;
    align-items: center;
    border: 0;
    background: transparent;
  }

  #petView .pet-outfit-picker > span {
    font-size: 0;
  }

  #petView .pet-outfit-picker > span::before {
    color: #6d8076;
    content: "当前桌宠";
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  #petView .pet-outfit-picker > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 6px;
  }

  #petView .pet-outfit-picker select,
  #petView .pet-outfit-picker button {
    height: 36px;
    min-height: 36px;
    border: 1px solid #dce3d9;
    border-radius: 10px;
    color: #7c9285;
    background: #fffdf5;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  #petView .pet-outfit-picker button {
    padding: 0;
    font-size: 0;
  }

  #petView .pet-outfit-picker button::before {
    display: grid;
    width: 100%;
    height: 100%;
    content: "+";
    font: 23px/1 sans-serif;
    place-items: center;
  }

  #petView .pet-outfit-picker small {
    display: none;
  }

  #petView .pet-size-control {
    display: grid;
    width: 406px;
    min-height: 32px;
    max-height: 32px;
    margin: 0 7px;
    padding: 2px 4px;
    grid-template-columns: 59px minmax(0, 1fr) 43px;
    gap: 7px;
    align-items: center;
    border: 0;
    background: transparent;
  }

  #petView .pet-size-control > span {
    display: block;
    overflow: hidden;
    color: #7a8b81;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #petView .pet-size-control input {
    width: 100%;
    min-width: 0;
    accent-color: #a0b8c1;
  }

  #petView .pet-size-control output {
    color: #7a8b81;
    font-size: 11px;
    text-align: right;
  }

  #petView .pet-mobile-help {
    display: block;
    width: 406px;
    min-height: 18px;
    margin: 0 7px;
    color: #87918a;
    font: 10px/17.6px "Microsoft YaHei", "PingFang SC", sans-serif;
    text-align: center;
  }
}

/*
 * Android 2.175 landscape meme layout. The original keeps a 30px page inset,
 * a full-width square preview and the settings below it in the same scrolling
 * document. It deliberately does not turn the workbench into the desktop
 * two-column layout.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="meme"] {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: #f6f5ef;
  }

  body[data-route="meme"]::before,
  body[data-route="meme"] .site-header {
    display: none !important;
  }

  body[data-route="meme"] .app-frame {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #f6f5ef;
  }

  body[data-route="meme"] main {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  #memeView {
    inset: 0;
    width: 100%;
    height: 100dvh;
    padding: 16px 30px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  #memeView .meme-header {
    width: 100%;
    margin-bottom: 18px;
  }

  #memeView .meme-deadline,
  #memeView .meme-native-controls {
    box-sizing: border-box;
  }
}

/*
 * Android 2.175 landscape merge game. The game occupies the same 440px
 * central column as the home screen, with the live stage behind a compact
 * board and the two primary actions fixed to the lower edge.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="game"] {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background:
      linear-gradient(rgb(238 242 235 / 22%), rgb(238 242 235 / 22%)),
      #cbd5ca;
  }

  body[data-route="game"]::before,
  body[data-route="game"] .site-header {
    display: none !important;
  }

  body[data-route="game"] .app-frame {
    width: min(100%, 440px);
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    background: #f6f5ef;
  }

  body[data-route="game"] main {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  body[data-route="game"] #gameView {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #f6f5ef;
  }

  body[data-route="game"] .game-view .mode-header {
    height: 56px;
    min-height: 56px;
    padding: 8px 12px;
  }

  body[data-route="game"] .game-view .game-mobile-hud {
    display: grid;
  }

  body[data-route="game"] .game-view .mode-heading,
  body[data-route="game"] .game-view .mode-segmented {
    display: none;
  }

  body[data-route="game"] .game-view .game-mobile-route {
    display: flex;
  }

  body[data-route="game"] .game-view .game-mobile-goal {
    display: block;
  }

  body[data-route="game"] .game-view .game-layout {
    position: relative;
    display: block;
    width: 100%;
    height: calc(100dvh - 114px);
    min-height: 0;
    margin: 0;
    overflow: hidden;
  }

  body[data-route="game"] .game-view .game-character-card {
    position: absolute;
    inset: 0 0 50px;
    display: block;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #f6f5ef;
  }

  body[data-route="game"] .game-view .game-character-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 0;
  }

  body[data-route="game"] .game-view .game-stage-audience {
    display: none;
  }

  body[data-route="game"] .game-view #gameCanvas {
    right: 19%;
    bottom: -36%;
    width: 62%;
    height: 150%;
  }

  body[data-route="game"] .game-view .game-board-card {
    position: absolute;
    top: -1px;
    bottom: 48px;
    left: 50%;
    z-index: 6;
    display: block;
    width: 202px;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: translateX(-50%);
  }

  body[data-route="game"] .game-view .game-stage-strip,
  body[data-route="game"] .game-view .game-hud,
  body[data-route="game"] .game-view .game-help {
    display: none;
  }

  body[data-route="game"] .game-view .game-board-wrap {
    display: grid;
    width: 100%;
    height: 100%;
    padding: 0;
    place-items: center;
  }

  body[data-route="game"] .game-view .game-board {
    width: 188px;
    max-width: 188px;
    height: 188px;
    max-height: 188px;
    padding: 5px;
    gap: 4px;
    border-width: 1px;
    border-radius: 17px;
    background: #ecefe7;
    box-shadow: inset 0 0 0 3px #fffdf7;
  }

  body[data-route="game"] .game-view .game-actions {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 7;
    display: grid;
    width: 100%;
    height: 48px;
    margin: 0;
    padding: 0 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    background: transparent;
  }

  body[data-route="game"] .game-view .game-actions > button:not(#gameFeed):not(#gameMobilePulse) {
    display: none;
  }

  body[data-route="game"] .game-view #gameFeed,
  body[data-route="game"] .game-view #gameMobilePulse {
    display: flex;
    min-height: 48px;
    border-radius: 13px;
  }

  body[data-route="game"] .game-view #gameFeed {
    color: #53675b;
    background: #c7dcd0;
  }

  body[data-route="game"] .game-view #gameMobilePulse {
    color: #53675b;
    background: #ead9df;
  }

  body[data-route="game"] .game-view .game-result {
    max-width: 220px;
  }

  body[data-route="game"] .chapter-picker {
    width: min(100%, 440px);
    height: 100dvh;
    max-height: 100dvh;
    padding: 16px 22px;
  }
}

/*
 * The action stage is an extension kept for the future hardware workflow.
 * It uses the same 440px landscape shell so it cannot push the Android
 * WebView into a horizontal page scroll.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="studio"] {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background:
      linear-gradient(rgb(238 242 235 / 22%), rgb(238 242 235 / 22%)),
      #cbd5ca;
  }

  body[data-route="studio"]::before,
  body[data-route="studio"] .site-header {
    display: none !important;
  }

  body[data-route="studio"] .app-frame {
    width: min(100%, 440px);
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    background: #f6f5ef;
  }

  body[data-route="studio"] main,
  body[data-route="studio"] #studioView {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  body[data-route="studio"] #studioView {
    display: grid;
    padding: 0;
    grid-template-rows: 58px minmax(0, 1fr);
    overflow: hidden;
    background: #f6f5ef;
  }

  body[data-route="studio"] .mode-header {
    min-height: 58px;
    margin: 0;
    padding: 8px 14px;
  }

  body[data-route="studio"] .mode-heading p,
  body[data-route="studio"] .mode-save-state,
  body[data-route="studio"] .mode-segmented {
    display: none;
  }

  body[data-route="studio"] .mode-heading h2 {
    font: 700 19px/1.3 "YuzuPop", "Microsoft YaHei", sans-serif;
  }

  body[data-route="studio"] .studio-layout {
    display: block;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0 12px 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body[data-route="studio"] .studio-stage-card {
    min-height: 250px;
    padding: 9px;
    border-radius: 18px;
  }

  body[data-route="studio"] .studio-stage {
    min-height: 160px;
  }

  body[data-route="studio"] .studio-panel {
    margin-top: 10px;
    border-radius: 18px;
  }
}

/* Keep the semantic landscape wrappers transparent on portrait/large layouts. */
.yu-home-character-pane,
.yu-home-operation-pane {
  display: contents;
}

body[data-route="home"] {
  --home-header-height: 76px;
}

body[data-route="home"] .app-frame {
  padding-bottom: 0;
}

body[data-route="home"] .yu-home {
  min-height: calc(100dvh - var(--home-header-height));
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  justify-content: center;
}

@media (max-width: 850px) {
  body[data-route="home"] { --home-header-height: 58px; }
}

@media (max-width: 520px) {
  body[data-route="home"] { --home-header-height: 0px; }
}

@media (max-width: 520px) and (min-height: 621px) {
  body[data-route="home"] .yu-home {
    padding-top: clamp(60px, calc(50dvh - 307px), 114.143px);
    justify-content: flex-start;
  }
}

/*
 * Container-driven landscape workspace.
 *
 * The app UI is used in a wide, short WebView. Keeping a portrait-sized
 * centre column wastes most of the screen, so character-heavy modes switch to
 * a stable two-column workspace: character and visual preview on the left,
 * controls and scrolling lists on the right. Page scrolling stays disabled;
 * each control column owns its vertical scroll.
 */
@media (orientation: landscape) and (min-aspect-ratio: 4 / 3) {
  body[data-route="home"] {
    --landscape-gutter: clamp(8px, 1.8vmin, 18px);
    --landscape-pane-gap: clamp(10px, 2vmin, 24px);
    --landscape-controls-share: clamp(46%, 49%, 52%);
  }

  /*
   * Home uses the full landscape canvas as well: identity and character stay
   * in the left half while actions and status occupy the right half.
   */
  body[data-route="home"] .site-header {
    display: none;
  }

  body[data-route="home"] .app-frame {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #f8f7f1;
  }

  body[data-route="home"] main,
  body[data-route="home"] #homeView {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  body[data-route="home"] .yu-home {
    display: grid;
    width: 100%;
    max-width: 1480px;
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    padding:
      clamp(6px, 1.6vmin, 14px)
      clamp(18px, 4vw, 46px)
      clamp(8px, 2vmin, 18px);
    box-sizing: border-box;
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    column-gap: var(--landscape-pane-gap);
    align-items: stretch;
    justify-items: stretch;
    overflow: hidden;
  }

  body[data-route="home"] .yu-home-topline {
    position: relative;
    inset: auto;
    display: flex;
    width: 100%;
    height: auto;
    min-height: clamp(28px, 7vmin, 42px);
    grid-column: 1 / -1;
    grid-row: 1;
  }

  body[data-route="home"] .yu-home-character-pane,
  body[data-route="home"] .yu-home-operation-pane {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
  }

  body[data-route="home"] .yu-home-character-pane {
    height: 100%;
    grid-column: 1;
    grid-row: 2;
    gap: 0;
    align-items: center;
    justify-content: center;
  }

  body[data-route="home"] .yu-home-operation-pane {
    display: flex;
    height: 100%;
    grid-column: 2;
    grid-row: 2;
    flex-direction: column;
    gap: clamp(8px, 1.5vmin, 16px);
    align-items: stretch;
    justify-content: center;
  }

  body[data-route="home"] .yu-home-heading {
    position: relative;
    inset: auto;
    width: 100%;
    height: clamp(72px, 22vmin, 104px);
    min-height: 0;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  body[data-route="home"] .yu-home-heading p {
    display: none;
  }

  body[data-route="home"] .yu-home-heading > span {
    font-size: 11px;
    line-height: 1.5;
  }

  body[data-route="home"] .yu-home-heading h1 {
    justify-content: center;
    font-size: clamp(34px, 5.2vw, 48px);
  }

  body[data-route="home"] .yu-home-stage {
    position: relative;
    inset: auto;
    container-type: inline-size;
    width: 100%;
    height: clamp(120px, 52dvh, 360px);
    min-height: 0;
    flex: 0 1 auto;
  }

  body[data-route="home"] .yu-home-stage #homeCanvas {
    top: 48%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: clamp(100px, min(36cqw, 32dvh), 220px);
    height: auto;
    aspect-ratio: 61 / 73;
    transform: translate(-50%, -50%);
  }

  body[data-route="home"] .yu-home-stage .hanger-button {
    left: 50%;
  }

  body[data-route="home"] .yu-home-actions {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 116px;
    align-self: center;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 52px 48px;
    column-gap: 12px;
    row-gap: 8px;
    transform: none;
  }

  body[data-route="home"] .yu-main-action {
    height: 52px;
    min-height: 52px;
    font-size: 18px;
  }

  body[data-route="home"] .yu-secondary-actions {
    gap: 10px;
  }

  body[data-route="home"] .yu-secondary-actions button {
    min-height: 48px;
    height: 48px;
    font-size: 14px;
  }

  body[data-route="home"] .yu-home-achievements {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 42px;
    align-self: start;
    text-align: center;
  }

  body[data-route="home"] .yu-home-language-note {
    position: relative;
    inset: auto;
    width: 100%;
    margin: 0;
    grid-column: 1 / -1;
    grid-row: 3;
    align-self: center;
    text-align: center;
  }

  body[data-route="home"] .yu-decor-star {
    top: 17%;
    left: 6%;
  }

  body[data-route="home"] .yu-decor-gift.left {
    top: 16%;
    right: 6%;
    left: auto;
  }

  body[data-route="home"] .yu-decor-gift.right {
    top: 68%;
    right: 6%;
    left: auto;
  }

}

@media (orientation: landscape) and (min-aspect-ratio: 4 / 3) {
  :root {
    --landscape-gutter: clamp(8px, 1.8vmin, 18px);
    --landscape-pane-gap: clamp(10px, 2vmin, 24px);
    --landscape-controls-share: clamp(46%, 49%, 52%);
  }

  body[data-route="editor"],
  body[data-route="meme"],
  body[data-route="game"],
  body[data-route="live"],
  body[data-route="pet"],
  body[data-route="studio"] {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    overflow: clip;
    background: #edf1eb;
  }

  body[data-route="editor"] .site-header,
  body[data-route="meme"] .site-header,
  body[data-route="game"] .site-header,
  body[data-route="live"] .site-header,
  body[data-route="pet"] .site-header,
  body[data-route="studio"] .site-header {
    display: none;
  }

  body[data-route="editor"] .app-frame,
  body[data-route="meme"] .app-frame,
  body[data-route="game"] .app-frame,
  body[data-route="live"] .app-frame,
  body[data-route="pet"] .app-frame,
  body[data-route="studio"] .app-frame {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: clip;
    background: #f6f5ef;
  }

  /* Wardrobe: full-width editor, preview left and tools right. */
  body[data-route="editor"] #editorView {
    inset: 0;
    display: flex;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    flex-direction: column;
    overflow: clip;
    border: 0;
    border-radius: 0;
    background: #f6f5ef !important;
    box-shadow: none;
    transform: none;
  }

  body[data-route="editor"] .editor-header {
    width: 100%;
    max-width: none;
    margin: 0;
    flex: 0 0 52px;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    padding: 7px 16px;
    box-sizing: border-box;
    border-bottom: 1px solid #d9dfd4;
  }

  body[data-route="editor"] .editor-layout {
    width: 100%;
    max-width: none;
    height: 0;
    min-height: 0;
    margin: 0;
    flex: 1 1 0;
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
    grid-template-rows: minmax(0, 1fr);
    column-gap: var(--landscape-gutter);
    overflow: clip;
  }

  body[data-route="editor"] .preview-panel {
    position: relative;
    display: grid;
    container-type: inline-size;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-right: 1px solid #d9dfd2;
  }

  body[data-route="editor"] #editorCanvas {
    top: 50%;
    right: auto;
    left: 50%;
    width: min(76cqw, 56dvh, 440px);
    height: auto;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
  }

  body[data-route="editor"] .tool-panel {
    border-top: 0;
    border-left: 0;
    border-radius: 0;
  }

  body[data-route="editor"] .panel-scroll {
    padding-right: 14px;
    padding-left: 14px;
  }

  body[data-route="editor"] .edit-dock {
    max-height: min(34dvh, 280px);
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  body[data-route="editor"] #wardrobeClear {
    top: 10px;
    left: 10px;
  }

  body[data-route="editor"] #wardrobeTurn {
    top: 48px;
    left: 10px;
  }

  body[data-route="editor"] #wardrobeMirror {
    top: 84px;
    left: 10px;
  }

  body[data-route="editor"] #wardrobeFreeImport {
    bottom: 10px;
    left: 10px;
  }

  body[data-route="editor"] #wardrobeNight {
    top: 10px;
    right: 10px;
  }

  body[data-route="editor"] #wardrobeSave {
    top: 48px;
    right: 10px;
  }

  body[data-route="editor"] #wardrobeShare {
    top: 84px;
    right: 10px;
  }

  /* Meme: preview left, controls in a dedicated scrolling panel. */
  body[data-route="meme"] #memeView {
    position: fixed;
    inset: 0;
    display: grid;
    width: 100%;
    height: 100dvh;
    padding: 8px 14px 12px;
    grid-template-rows: 50px minmax(0, 1fr);
    overflow: hidden;
  }

  body[data-route="meme"] #memeView .meme-header {
    height: 50px;
    min-height: 50px;
    margin: 0;
  }

  body[data-route="meme"] #memeView .mode-heading h2 {
    font-size: 22px;
  }

  body[data-route="meme"] #memeView .back-button {
    width: 39px;
    height: 39px;
    min-height: 39px;
  }

  body[data-route="meme"] #memeView .meme-layout {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  body[data-route="meme"] #memeView .meme-stage-card {
    display: grid;
    container-type: size;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    gap: var(--landscape-gutter);
    overflow: hidden;
    border: 0;
    background: transparent;
  }

  body[data-route="meme"] #memeView .meme-stage-topline,
  body[data-route="meme"] #memeView .meme-stage-controls,
  body[data-route="meme"] #memeView .meme-export-actions,
  body[data-route="meme"] #memeView .meme-panel,
  body[data-route="meme"] #memeView .meme-accessory-open {
    display: none;
  }

  body[data-route="meme"] #memeView .meme-stage-frame {
    grid-column: 1;
    grid-row: 1;
    align-self: stretch;
    justify-self: center;
    width: min(100%, 100cqh, 420px);
    height: auto;
    min-height: 0;
    aspect-ratio: 1;
    border-radius: 22px;
  }

  body[data-route="meme"] #memeView .meme-native-controls {
    display: grid;
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 20px;
    background: #ecefe7;
  }

  body[data-route="meme"] #memeView .meme-native-controls label,
  body[data-route="meme"] #memeView .meme-native-controls button,
  body[data-route="meme"] #memeView .meme-native-controls select {
    min-height: 36px;
  }

  /* Merge game: character stage left, board and primary actions right. */
  body[data-route="game"] .game-view .game-stage-strip,
  body[data-route="game"] .game-view .game-hud,
  body[data-route="game"] .game-view .game-help,
  body[data-route="game"] .game-view .game-character-side,
  body[data-route="game"] .game-view .game-actions > button:not(#gameFeed):not(#gameMobilePulse) {
    display: none;
  }

  body[data-route="game"] .game-view .game-character-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  body[data-route="game"] #gameView {
    display: flex;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  body[data-route="game"] .game-view .mode-header {
    flex: 0 0 56px;
    height: 56px;
    min-height: 56px;
    max-height: 56px;
    padding: 8px 12px;
    box-sizing: border-box;
  }

  body[data-route="game"] .game-view .game-mobile-hud {
    display: grid;
  }

  body[data-route="game"] .game-view .mode-heading,
  body[data-route="game"] .game-view .mode-segmented {
    display: none;
  }

  body[data-route="game"] .game-view .game-mobile-route {
    display: flex;
    flex: 0 0 32px;
  }

  body[data-route="game"] .game-view .game-mobile-goal {
    display: block;
    flex: 0 0 26px;
  }

  body[data-route="game"] .game-view .game-mobile-goal[hidden] {
    display: none !important;
  }

  body[data-route="game"] .game-view .game-layout {
    flex: 1 1 auto;
    display: grid;
    width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0 var(--landscape-gutter) var(--landscape-gutter);
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--landscape-gutter);
    overflow: hidden;
  }

  body[data-route="game"] .game-view .game-character-card {
    position: relative;
    inset: auto;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #dce2d8;
    border-radius: 18px;
    background: #fbfaef;
  }

  body[data-route="game"] .game-view #gameCanvas {
    right: 4%;
    bottom: -20%;
    width: 92%;
    height: 122%;
  }

  body[data-route="game"] .game-view .game-board-card {
    position: relative;
    inset: auto;
    z-index: 1;
    display: grid;
    container-type: size;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 6px;
    grid-template-rows: minmax(0, 1fr) 48px;
    overflow: hidden;
    border: 1px solid #dce2d8;
    border-radius: 18px;
    background: #fbfaf5;
    transform: none;
  }

  body[data-route="game"] .game-view .game-board-wrap {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: 0;
    container-type: size;
    padding: 0;
    place-items: center;
  }

  body[data-route="game"] .game-view .game-board {
    width: min(320px, 100cqw, 100cqh);
    height: min(320px, 100cqw, 100cqh);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
  }

  body[data-route="game"] .game-view .game-actions {
    position: static;
    display: grid;
    width: 100%;
    height: 48px;
    padding: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    background: transparent;
  }

  body[data-route="game"] .game-view .game-actions > #gameFeed,
  body[data-route="game"] .game-view .game-actions > #gameMobilePulse {
    display: flex;
    min-height: 44px;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  /* Face tracking: live character left, filters and controls right. */
  body[data-route="live"] #liveView {
    position: fixed;
    inset: 0;
    display: grid;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: 52px minmax(0, 1fr);
    overflow: hidden;
  }

  body[data-route="live"] #liveView .live-header {
    position: relative;
    inset: auto;
    z-index: 3;
    display: flex;
    width: 100%;
    height: 52px;
    min-height: 52px;
    padding: 6px var(--landscape-gutter);
    box-sizing: border-box;
    grid-row: 1;
    border-bottom: 1px solid #dce2d8;
    pointer-events: auto;
  }

  body[data-route="live"] #liveView .live-header .mode-heading h2 {
    font-size: clamp(19px, 2.2vw, 26px);
  }

  body[data-route="live"] #liveView .live-layout {
    position: relative;
    inset: auto;
    display: grid;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: var(--landscape-gutter);
    box-sizing: border-box;
    grid-row: 2;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }

  body[data-route="live"] #liveView .live-stage-card {
    position: relative;
    inset: auto;
    display: grid;
    container-type: inline-size;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--landscape-gutter);
    overflow: hidden;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  body[data-route="live"] #liveView .live-panel {
    display: none;
  }

  body[data-route="live"] #liveView .live-stage {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    grid-column: 1;
    grid-row: 1;
    border-radius: 18px;
    transform: none;
  }

  body[data-route="live"] #liveView .live-stage-toolbar {
    position: absolute;
    top: 10px;
    right: calc(50% + var(--landscape-gutter));
  }

  body[data-route="live"] #liveView .live-controls {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    padding: 8px;
    box-sizing: border-box;
    grid-column: 2;
    grid-row: 1;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid #dce2d8;
    border-radius: 18px;
    background: #f8f7f1;
  }

  body[data-route="live"] #liveView .live-controls .live-camera-toggle {
    min-height: 40px;
  }

  body[data-route="live"] #liveView .live-mobile-size {
    min-height: 30px;
  }

  body[data-route="live"] #liveView .live-mobile-help {
    min-height: 16px;
  }

  body[data-route="live"] #liveView .live-room-window {
    top: 24%;
    left: 14%;
    width: min(34cqw, 150px);
    height: 54%;
  }

  body[data-route="live"] #liveView .live-room-shelf {
    top: 62%;
    right: 58%;
    width: min(34cqw, 150px);
  }

  body[data-route="live"] #liveView .live-room-scenery {
    right: calc(50% + var(--landscape-gutter));
    width: auto;
  }

  body[data-route="live"] #liveView .live-mode-caption {
    left: 4%;
    width: 46%;
    text-align: left;
  }

  body[data-route="live"] #liveView .live-reset-button {
    left: 14px;
  }

  /* Companion room: character left, actions and outfit controls right. */
  body[data-route="pet"] #petView {
    position: fixed;
    inset: 0;
    display: grid;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 0;
    grid-template-rows: 52px minmax(0, 1fr);
    overflow: hidden;
  }

  body[data-route="pet"] #petView > .mode-header {
    position: relative;
    inset: auto;
    display: flex;
    width: 100%;
    height: 52px;
    min-height: 52px;
    padding: 6px var(--landscape-gutter);
    box-sizing: border-box;
    grid-row: 1;
    border-bottom: 1px solid #dce2d8;
  }

  body[data-route="pet"] #petView > .mode-header .mode-heading p,
  body[data-route="pet"] #petView > .mode-header .mode-save-state {
    display: none;
  }

  body[data-route="pet"] #petView > .mode-header h2 {
    margin: 0;
    font-size: 20px;
  }

  body[data-route="pet"] #petView > .mode-header .back-button {
    position: absolute;
    inset: 6px 8px auto auto;
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #e9ebe1;
    color: #7f9189;
  }

  body[data-route="pet"] #petView > .mode-header .back-button svg {
    display: none;
  }

  body[data-route="pet"] #petView > .mode-header .back-button::before {
    content: "×";
    font: 20px/1 sans-serif;
  }

  body[data-route="pet"] #petView .pet-layout {
    display: grid;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: var(--landscape-gutter);
    box-sizing: border-box;
    grid-row: 2;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--landscape-gutter);
    overflow: hidden;
  }

  body[data-route="pet"] #petView .pet-room {
    position: relative;
    inset: auto;
    container-type: inline-size;
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-column: 1;
    grid-row: 1;
    border: 1px solid #dce2d8;
    border-radius: 18px;
  }

  body[data-route="pet"] #petView .pet-instances {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body[data-route="pet"] .pet-mobile-top-actions {
    position: absolute;
    top: 58px;
    right: calc(var(--landscape-gutter) + 10px);
    left: auto;
    z-index: 35;
    display: flex;
    gap: 8px;
  }

  body[data-route="pet"] .pet-mobile-top-actions button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 40px;
    padding: 8px 13px;
    border: 1px solid #d9dfd5;
    border-radius: 16px;
    color: #576e64;
    background: #edf0e8;
    font: 13px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="pet"] .pet-mobile-top-actions svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
  }

  body[data-route="pet"] .pet-mobile-reset {
    position: absolute;
    inset: auto auto 12px 12px;
    z-index: 24;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 5px;
    border: 0;
    border-radius: 16px;
    color: #576e64;
    background: #e3e9e4;
  }

  body[data-route="pet"] .pet-mobile-toolbox {
    position: relative;
    inset: auto;
    width: 100%;
    min-width: 0;
  }

  body[data-route="pet"] #petView .pet-panel-scroll > .pet-mobile-toolbox {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  body[data-route="pet"] .pet-mobile-controls-toggle {
    position: relative;
    inset: auto;
    align-self: flex-end;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid #dce2d8;
    border-radius: 12px;
    color: #82958b;
    background: #fffdf4;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="pet"] .pet-mobile-control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    margin-top: 0;
    padding: 7px;
    box-sizing: border-box;
    border: 1px solid #dce2d8;
    border-radius: 18px;
    background: #f8f7f1;
  }

  body[data-route="pet"] .pet-mobile-control-grid button {
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid #dce3d9;
    border-radius: 16px;
    color: #576e64;
    background: #e3e9e4;
    font: 13px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="pet"] .pet-mobile-control-grid button:nth-child(2) {
    color: #9a7a89;
    background: #f0dfe3;
  }

  body[data-route="pet"] .pet-mobile-control-grid button:nth-child(4) {
    color: #788e9b;
    background: #dde8ed;
  }

  body[data-route="pet"] .pet-mobile-control-grid button.active {
    border-color: #a9beb0;
    background: #d5e4d8;
  }

  body[data-route="pet"] #petView.pet-mobile-controls-collapsed .pet-mobile-control-grid {
    display: none;
  }

  body[data-route="pet"] #petView .pet-panel {
    position: relative;
    inset: auto;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    grid-column: 2;
    grid-row: 1;
    overflow-x: hidden;
    overflow-y: hidden;
    border: 1px solid #dce2d8;
    border-radius: 18px;
    background: #f8f7f1;
  }

  body[data-route="pet"] #petView .pet-panel .mode-panel-scroll {
    height: calc(100% - 48px);
    min-height: 0;
    margin-top: 48px;
    padding: 8px;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    align-content: start;
    grid-auto-rows: max-content;
  }

  body[data-route="pet"] #petView .pet-panel-scroll > :not(.pet-mobile-toolbox):not(.pet-outfit-picker):not(.pet-size-control):not(.pet-mobile-help):not(dialog[open]) {
    display: none;
  }

  body[data-route="pet"] #petView .pet-mobile-help {
    display: block;
    min-height: 18px;
    margin: 0;
    color: #87918a;
    font: 11px/18px "Microsoft YaHei", "PingFang SC", sans-serif;
    text-align: center;
  }

  body[data-route="pet"] #petView .pet-outfit-picker,
  body[data-route="pet"] #petView .pet-size-control,
  body[data-route="pet"] #petView .pet-mobile-help {
    width: 100%;
    margin-right: 0;
    margin-left: 0;
  }

  body[data-route="pet"] #petView .pet-outfit-picker {
    display: grid;
    grid-template-columns: minmax(59px, max-content) minmax(0, 1fr);
    gap: 7px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    align-items: center;
  }

  body[data-route="pet"] #petView .pet-outfit-picker > span {
    font-size: 0;
  }

  body[data-route="pet"] #petView .pet-outfit-picker > span::before {
    content: "当前桌宠";
    color: #6d8076;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
    white-space: nowrap;
  }

  body[data-route="pet"] #petView .pet-outfit-picker > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 6px;
  }

  body[data-route="pet"] #petView .pet-outfit-picker select,
  body[data-route="pet"] #petView .pet-outfit-picker button {
    min-height: 36px;
    height: 36px;
    border: 1px solid #dce3d9;
    border-radius: 10px;
    color: #7c9285;
    background: #fffdf5;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="pet"] #petView .pet-outfit-picker button {
    padding: 0;
    font-size: 0;
  }

  body[data-route="pet"] #petView .pet-outfit-picker button::before {
    content: "+";
    display: grid;
    height: 100%;
    place-items: center;
    font: 23px/1 sans-serif;
  }

  body[data-route="pet"] #petView .pet-outfit-picker small {
    display: none;
  }

  body[data-route="pet"] #petView .pet-size-control {
    display: grid;
    grid-template-columns:
      minmax(59px, max-content)
      minmax(0, 1fr)
      minmax(43px, max-content);
    gap: 7px;
    align-items: center;
    min-height: 32px;
    max-height: 32px;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    color: #7a8b81;
    font: 11px/1 "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="pet"] #petView .pet-size-control input {
    width: 100%;
    min-width: 0;
    accent-color: #a0b8c1;
  }

  body[data-route="pet"] #petView .pet-size-control > span,
  body[data-route="pet"] #petView .pet-size-control output {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }

  body[data-route="pet"] #petView .pet-size-control output {
    font-size: 11px;
    text-align: right;
  }

  body[data-route="pet"] #petView .pet-instances > .pet-instance {
    display: block;
    top: 3%;
    right: auto;
    bottom: auto;
    left: calc((100% - min(48cqw, 210px)) / 2);
    width: min(48cqw, 210px);
    height: 82%;
    transform: none;
  }

  body[data-route="pet"] #petView .pet-instances > .pet-instance.dragging {
    transform: scale(1.03);
  }

  body[data-route="pet"] .pet-original-room-window {
    left: 12%;
    width: min(36cqw, 150px);
  }

  body[data-route="pet"] .pet-original-shelf {
    top: 58%;
    right: 14%;
    width: min(36cqw, 150px);
  }

  /* Action stage: full-width stage left and motion/export panel right. */
  body[data-route="studio"] #studioView {
    display: flex;
    width: 100%;
    height: 100dvh;
    padding: 0;
    flex-direction: column;
    overflow: hidden;
  }

  body[data-route="studio"] .mode-header {
    flex: 0 0 52px;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    padding: 6px 14px;
    box-sizing: border-box;
    overflow: hidden;
  }

  body[data-route="studio"] .studio-layout {
    flex: 1 1 auto;
    display: grid;
    width: 100%;
    height: auto;
    max-height: none;
    min-height: 0;
    padding: 0 var(--landscape-gutter) var(--landscape-gutter);
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--landscape-gutter);
    overflow: hidden;
  }

  body[data-route="studio"] .studio-stage-card {
    min-height: 0;
    margin: 0;
    overflow: hidden;
  }

  body[data-route="studio"] .studio-stage {
    min-height: 0;
  }

  body[data-route="studio"] .studio-panel {
    min-height: 0;
    margin: 0;
    overflow: hidden;
  }

  body[data-route="studio"] .mode-panel-scroll {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/*
 * A short landscape stage card cannot fit five desktop transport columns.
 * Stack only the progress control on a second row; the two sliders retain
 * flexible widths so neither the range inputs nor their outputs are clipped.
 */
@media (orientation: landscape) and (min-aspect-ratio: 4 / 3) and (max-width: 900px) and (max-height: 500px) {
  body[data-route="studio"] .stage-transport {
    grid-template-columns: auto auto minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    padding: 8px 0 0;
  }

  body[data-route="studio"] .stage-transport .stage-progress-control {
    grid-column: 1 / -1;
  }

  body[data-route="studio"] .transport-main {
    min-width: 72px;
    min-height: 39px;
    padding-inline: 9px;
  }

  body[data-route="studio"] .stage-transport > button {
    min-width: 39px;
    min-height: 39px;
  }

  body[data-route="studio"] .stage-speed {
    min-width: 0;
  }

  body[data-route="studio"] .stage-speed > span {
    min-width: 0;
    gap: 4px;
  }

  body[data-route="studio"] .stage-speed input {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* Touch audit: keep history labels from wrapping inside icon-sized buttons. */
@media (pointer: coarse) {
  body[data-route="editor"] #editorView .history-group button span {
    display: none;
  }
  body[data-route="editor"] #editorView .history-group button {
    flex: 0 0 36px;
    width: 36px;
    min-width: 36px;
    white-space: nowrap;
  }
  body[data-route="editor"] #editorView :is(#dockCollapse, #adjustToggle, #layerEditorToggle, #resetLayerOrder, #resetPartColor, #freeColorOpen) {
    min-height: 36px;
    box-sizing: border-box;
  }
}

/* Labels remain visible when compact wardrobe mode hides the SVG icons. */
body[data-route="editor"] #editorView .wardrobe-stage-actions button:not(#wardrobeClear) span {
  display: inline;
}

@media (orientation: landscape) and (max-width: 1400px) and (max-height: 800px) {
  body[data-route="meme"] #memeView .meme-native-controls {
    grid-auto-rows: max-content;
    align-content: start;
  }
  body[data-route="meme"] #memeView .meme-native-controls > label {
    height: auto;
    min-height: 68px;
    flex-shrink: 0;
  }
  body[data-route="meme"] #memeView .meme-native-controls > button {
    height: auto;
    min-height: 44px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 850px) {
  body[data-route="editor"] #wardrobeFreeImport[hidden],
  body[data-route="editor"] #wardrobeOutfitImport[hidden] {
    display: none !important;
  }

  body[data-route="editor"] #wardrobeOutfitImport {
    top: auto !important;
    right: auto !important;
    bottom: 12px !important;
    left: 12px !important;
    min-width: 76px;
  }
}

/* In landscape the board is the primary play surface. Status and the character
   share the left rail; the board owns the full height on the right. */
@media (orientation: landscape) and (min-aspect-ratio: 4 / 3) {
  body[data-route="game"] #gameView {
    --game-sidebar-width: clamp(200px, 30vw, 360px);
    position: relative;
    display: block;
  }
  body[data-route="game"] .game-view .mode-header {
    position: absolute;
    z-index: 4;
    top: var(--landscape-gutter);
    left: var(--landscape-gutter);
    width: var(--game-sidebar-width);
    height: 82px;
    min-height: 82px;
    max-height: 82px;
    padding: 0;
    grid-template-columns: 34px minmax(0, 1fr) 34px 34px;
    grid-template-rows: 32px 44px;
    gap: 4px;
  }
  body[data-route="game"] .game-view .game-mobile-hud {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 44px;
    min-height: 0;
    gap: 4px;
  }
  body[data-route="game"] .game-view .game-mobile-hud > div { padding: 3px; min-width: 0; }
  body[data-route="game"] .game-view .game-mobile-hud small { font-size: 10px; line-height: 13px; }
  body[data-route="game"] .game-view .game-mobile-hud b { font-size: 19px; line-height: 22px; }
  body[data-route="game"] .game-view .mode-header > .back-button,
  body[data-route="game"] .game-view .game-mobile-help,
  body[data-route="game"] .game-view .game-mobile-settings {
    grid-row: 1;
    width: 34px;
    height: 32px;
    min-width: 0;
    min-height: 32px;
    padding: 6px;
  }
  body[data-route="game"] .game-view .mode-header > .back-button { grid-column: 1; }
  body[data-route="game"] .game-view .game-mobile-help { grid-column: 3; }
  body[data-route="game"] .game-view .game-mobile-settings { grid-column: 4; }
  body[data-route="game"] .game-view .game-mobile-route {
    position: absolute;
    z-index: 4;
    top: calc(var(--landscape-gutter) + 86px);
    left: var(--landscape-gutter);
    width: var(--game-sidebar-width);
    height: 42px;
    padding: 3px 5px;
    gap: 4px;
    flex-wrap: wrap;
    align-content: center;
    font-size: 10px;
    line-height: 14px;
  }
  body[data-route="game"] .game-view .game-mobile-goal {
    position: absolute;
    z-index: 4;
    top: calc(var(--landscape-gutter) + 130px);
    left: var(--landscape-gutter);
    width: var(--game-sidebar-width);
    height: 30px;
    padding: 2px 4px;
    overflow: hidden;
    font-size: 10px;
    line-height: 13px;
  }
  body[data-route="game"] .game-view .game-layout {
    height: 100%;
    padding: var(--landscape-gutter);
    grid-template-columns: var(--game-sidebar-width) minmax(0, 1fr);
  }
  body[data-route="game"] .game-view .game-character-card {
    height: calc(100% - 164px);
    align-self: end;
  }
  body[data-route="game"] .game-view[data-game-mode="endless"] .game-character-card {
    height: calc(100% - 130px);
  }
  body[data-route="game"] .game-view .game-board-card {
    grid-template-columns: minmax(0, 1fr) clamp(72px, 10vw, 100px);
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
  }
  body[data-route="game"] .game-view .game-board {
    width: min(100cqw, 100cqh);
    height: min(100cqw, 100cqh);
  }
  body[data-route="game"] .game-view .game-actions {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(44px, 1fr));
  }
}

/* Phone game stage and board share the available height above system gestures. */
@media (max-width: 900px) and (orientation: portrait) {
  body[data-route="game"] #gameView {
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body[data-route="game"] .game-view .game-layout {
    position: relative;
    height: auto;
    min-height: 0;
    flex: 1 1 0;
    display: grid;
    grid-template-rows: clamp(210px, 29.34dvh, 248px) minmax(0, 1fr);
  }
  body[data-route="game"] .game-view .game-character-card,
  body[data-route="game"] .game-view .game-character-stage {
    height: 100%;
    min-height: 0;
  }
  body[data-route="game"] .game-view .game-character-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 34px;
    gap: 0;
  }
  body[data-route="game"] .game-view .game-stage-audience {
    display: block;
    min-height: 34px;
    height: 34px;
    grid-row: 2;
  }
  body[data-route="game"] .game-view .game-board-card {
    position: static;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #f6f5ef;
    box-shadow: none;
  }
  body[data-route="game"] .game-view .game-board-wrap {
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
  }
  body[data-route="game"] .game-view .game-board {
    width: auto;
    height: 100%;
    max-width: 100%;
    aspect-ratio: 1;
  }
  body[data-route="game"] .game-view .game-actions {
    position: static;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0 4px max(24px, env(safe-area-inset-bottom));
  }
  body[data-route="game"] .game-view .game-actions > button {
    min-height: 44px;
  }
}
@media (max-width: 900px) and (orientation: portrait) and (max-height: 650px) {
  body[data-route="game"] .game-view .game-layout {
    grid-template-rows: 130px minmax(0, 1fr);
    row-gap: 2px;
  }
  body[data-route="game"] .game-view .game-character-card {
    grid-template-rows: minmax(0, 1fr);
  }
  body[data-route="game"] .game-view .game-stage-audience {
    display: none;
  }
  body[data-route="game"] .game-view .game-board-card {
    display: flex;
    flex-direction: column;
    row-gap: 4px;
  }
  body[data-route="game"] .game-view .game-board-wrap {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
  }
  body[data-route="game"] .game-view .game-actions {
    flex: 0 0 auto;
    padding: 4px 4px max(8px, env(safe-area-inset-bottom));
  }
}
@media (max-width: 900px) and (orientation: portrait) and (min-height: 651px) {
  body[data-route="game"] .game-view .game-layout {
    grid-template-rows: clamp(210px, 29.34dvh, 248px) minmax(0, 1fr);
  }
  body[data-route="game"] .game-view .game-board-card {
    display: flex;
    flex-direction: column;
  }
  body[data-route="game"] .game-view .game-board-wrap {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
  }
  body[data-route="game"] .game-view .game-actions { flex: 0 0 auto; }
}
@media (max-width: 900px) and (orientation: portrait) {
  body[data-route="game"] .game-view .game-board-wrap { container-type: size; }
  body[data-route="game"] .game-view .game-board {
    flex: none;
    width: min(100cqw, 100cqh);
    height: min(100cqw, 100cqh);
    box-sizing: border-box;
  }
}

/* English words are wider than the three Chinese title glyphs. Reserve room
   for the leaf instead of allowing the title to widen the WebView viewport. */
@media (max-width: 900px) {
  html[lang="en"] .yu-home-heading h1 {
    max-width: calc(100% - 26px);
    flex-wrap: wrap;
    font-size: clamp(32px, 10vw, 52px);
  }
}

/* Settings own a fixed scrollable surface; the scene behind them must not
   enlarge the document or trigger WebView fit-to-content scaling on rotation. */
body[data-route="settings"],
body[data-route="settings"] .app-frame {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

/* Android 2.175 outfit slot dialogs: compact, opaque forms. */
#outfitNameDialog[data-mode="rename"], #outfitDeleteDialog {
  box-sizing: border-box;
  width: min(330px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 22px;
  overflow: auto;
  border: 1px solid #dce4d7;
  border-radius: 20px;
  background: #faf9f2;
  color: #738577;
  font: 13px "Segoe UI", "Microsoft YaHei", sans-serif;
}
#outfitDeleteDialog { width: min(300px, calc(100vw - 24px)); }
#outfitNameDialog[data-mode="rename"] > form, #outfitDeleteDialog > div {
  display: block;
  max-height: none;
  background: transparent;
}
#outfitNameDialog[data-mode="rename"] header {
  padding: 0;
  margin: 0 0 12px;
  border: 0;
  background: transparent;
}
#outfitNameDialog[data-mode="rename"] header h2 {
  margin: 0;
  color: inherit;
  font: 15px "Segoe UI", "Microsoft YaHei", sans-serif;
}
#outfitNameDialog[data-mode="rename"] :is(header small, header > button, .outfit-field > span, .outfit-field > small, #outfitNameHelp),
#outfitDeleteDialog header { display: none; }
#outfitNameDialog[data-mode="rename"] .outfit-dialog-body, #outfitDeleteDialog .outfit-dialog-body {
  padding: 0;
  background: transparent;
  overflow: visible;
}
#outfitNameDialog[data-mode="rename"] #outfitNameInput {
  box-sizing: border-box;
  width: 100%;
  padding: 12px;
  border: 1px solid #d9dfd2;
  border-radius: 12px;
  background: white;
  color: #657564;
  font: inherit;
}
#outfitNameDialog[data-mode="rename"] footer, #outfitDeleteDialog footer {
  display: flex;
  gap: 9px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
}
#outfitNameDialog[data-mode="rename"] footer button, #outfitDeleteDialog footer button {
  flex: 1;
  min-height: 38px;
  border-radius: 12px;
  font: inherit;
}
#outfitDeleteDialog .outfit-dialog-body > p { margin: 0; color: inherit; font: inherit; line-height: 1.7; }
#outfitDeleteDialog #outfitDeleteConfirm { background: #e9dce1; color: #947984; }

/*
 * Large landscape workbench: keep the original square meme stage instead of
 * stretching it to the full grid height. The accessory replacement entry is
 * a desktop extension and lives below the right-hand native controls.
 */
@media (orientation: landscape) and (min-width: 1000px) and (min-height: 700px) {
  body[data-route="meme"] #memeView .meme-stage-card {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  body[data-route="meme"] #memeView .meme-stage-frame {
    grid-row: 1 / span 2;
    align-self: center;
    justify-self: center;
  }

  body[data-route="meme"] #memeView .meme-accessory-open {
    display: block;
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    min-height: 44px;
    margin: 10px 0 0;
  }
}

/*
 * Yousongwu 2.175 shares one backdrop model between the companion room and
 * 2D tracking. The three visible surfaces use the exact stored kind/colour or
 * imported image; only the room kind reveals the furniture layer.
 */
#petView .pet-original-scenery[data-pet-background="solid"],
#liveView .live-room-scenery[data-pet-background="solid"] {
  background: var(--pet-solid, #f7f3ed) !important;
}

#petView .pet-original-scenery[data-pet-background="green"],
#liveView .live-room-scenery[data-pet-background="green"] {
  background: #00ff00 !important;
}

#petView .pet-original-scenery[data-pet-background="transparent"],
#liveView .live-room-scenery[data-pet-background="transparent"] {
  background-color: #fff !important;
  background-image:
    conic-gradient(#e3e5e5 25%, #fff 0 50%, #e3e5e5 0 75%, #fff 0) !important;
  background-size: 24px 24px !important;
}

#petView .pet-original-scenery[data-pet-background="custom"],
#liveView .live-room-scenery[data-pet-background="custom"] {
  background-color: #f7f3ed !important;
  background-image: var(--pet-custom-background, none) !important;
  background-position: center !important;
  background-size: cover !important;
}

#petView .pet-room[data-pet-background="green"] {
  background: #00ff00 !important;
}

#petView .pet-room[data-pet-background="transparent"] {
  background-color: #fff !important;
  background-image:
    conic-gradient(#e3e5e5 25%, #fff 0 50%, #e3e5e5 0 75%, #fff 0) !important;
  background-size: 24px 24px !important;
}

@media (max-width: 850px) {
  /* 412x842 reference: y=90, height=612.29, matching the original
     .pet-scenery rectangle above the compact controls. */
  #liveView .live-room-scenery {
    inset: 16px 0 140px;
  }

  #liveView .live-room-window {
    top: 10%;
    height: 35%;
  }
}

/*
 * The original 2.175 room positions the footer from a fixed 704.69px top.
 * That remains exact on taller phones, but clips the size control on 360x762
 * displays, especially with enlarged system text. In this constrained band,
 * anchor the footer to the safe-area bottom and keep every row reachable.
 */
@media (max-width: 850px) and (orientation: portrait)
  and (min-height: 701px) and (max-height: 780px) {
  #petView {
    --pet-footer-height: clamp(130px, 80px + 3rem, 152px);
  }

  #petView .pet-mobile-toolbox {
    bottom: calc(var(--pet-footer-height) + 7px);
  }

  #petView .pet-panel {
    top: auto;
    bottom: max(10px, env(safe-area-inset-bottom));
    height: var(--pet-footer-height);
    overflow: hidden;
  }

  #petView .pet-panel-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #petView .pet-outfit-picker {
    grid-template-columns: minmax(68px, max-content) minmax(0, 1fr) 38px;
  }

  #petView .pet-outfit-picker > span::before,
  #petView .pet-size-control > span,
  #petView .pet-size-control output {
    white-space: nowrap;
  }

  #petView .pet-size-control {
    grid-template-columns:
      minmax(68px, max-content)
      minmax(0, 1fr)
      minmax(43px, max-content);
  }

  #petView .pet-size-control > span {
    overflow: visible;
    text-overflow: clip;
  }
}

/*
 * vivo's floating WeType keyboard occupies the right side of a short
 * landscape display without resizing the WebView width. Keep the compact
 * rename dialog on the unobstructed left side while its input is active so
 * the cancel and save actions remain tappable.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  #outfitNameDialog[data-mode="rename"]:focus-within {
    position: fixed;
    top: 50%;
    right: auto;
    bottom: auto;
    left: max(8px, env(safe-area-inset-left));
    width: min(280px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    margin: 0;
    padding: 18px;
    transform: translateY(-50%);
  }

  #outfitNameDialog[data-mode="rename"]:focus-within footer {
    gap: 7px;
  }

  #outfitNameDialog[data-mode="rename"]:focus-within footer button {
    min-width: 0;
    padding-inline: 8px;
    font-size: 12px;
  }
}

/*
 * Original 2.175 phone catalogue geometry.
 *
 * The catalogue is a scroll viewport, not a strip that may run underneath the
 * edit dock. Keep one complete 80px card row visible whenever the viewport can
 * support it. On short phones the dock yields space and scrolls internally;
 * the user can still reach every control, while clothing cards remain tappable.
 */
@media (max-width: 850px) and (orientation: portrait) {
  body[data-route="editor"] .edit-dock {
    position: relative;
  }

  body[data-route="editor"] #catalogGrid .item-card {
    box-sizing: border-box;
    height: 80px;
    min-height: 80px;
    padding: 4px 3px;
  }

  body[data-route="editor"] #catalogGrid .item-thumbnail {
    height: 52px;
    min-height: 52px;
    margin-bottom: 2px;
    aspect-ratio: auto;
  }

  body[data-route="editor"] #catalogGrid .item-card b {
    font-size: 10px !important;
    line-height: 14px;
  }
}

/*
 * Pixel anchors measured from Android 2.175 at 412x842 after accounting for
 * the original wardrobe iframe's 62.76px shell offset:
 * - category row: 42.95px tall
 * - note row begins 3px below it
 * - catalogue begins 3px below the note row
 * - catalogue cards start 2px inside the grid and are 80px tall
 *
 * Keep the compact 320x568 layout on its existing height-saving path.
 */
@media (max-width: 850px) and (orientation: portrait) and (min-height: 701px) {
  body[data-route="editor"] .category-row {
    height: 43px;
    min-height: 43px;
  }

  body[data-route="editor"] .closet-note-row {
    margin-top: 3px;
  }

  body[data-route="editor"] .catalog-grid {
    grid-template-columns: repeat(4, minmax(0, 87.0833px));
    justify-content: start;
    margin-top: 3px;
    padding: 1px 2px 5px;
  }

  body[data-route="editor"] .catalog-grid.outfit-grid {
    margin-top: 6px;
  }

  body[data-route="editor"] #catalogGrid .item-card {
    padding: 5px 3px;
  }
}

@media (max-width: 850px) and (orientation: portrait) and (min-height: 701px) {
  body[data-route="editor"] .edit-dock {
    max-height: min(245px, calc(100dvh - 539px));
  }
}

@media (max-width: 850px) and (orientation: portrait) and (max-height: 700px) {
  body[data-route="editor"] .editor-layout {
    /* Keep one complete 80px catalogue row above the dock on 360x640-class
       screens without reducing the fixed-size cards or hiding the preview. */
    grid-template-rows: calc(31% - 2px) minmax(0, 1fr);
  }

  body[data-route="editor"] .tool-panel {
    grid-template-rows: 36px minmax(0, 1fr) auto;
  }

  body[data-route="editor"] .panel-command-bar {
    height: 36px;
    min-height: 36px;
    padding: 7px 16px 3px;
  }

  body[data-route="editor"] .panel-scroll {
    padding-bottom: 9px;
  }

  body[data-route="editor"] .tabs button {
    min-height: 33px;
  }

  body[data-route="editor"] .category-row {
    top: 33px;
  }

  body[data-route="editor"] .edit-dock {
    max-height: clamp(90px, calc(100dvh - 473px), 167px);
  }
}

@media (max-width: 520px) and (orientation: portrait) and (max-height: 620px) {
  body[data-route="editor"] .closet-note-row {
    height: 24px;
    min-height: 24px;
  }

  body[data-route="editor"] .closet-note-row .closet-scroll-note {
    display: none;
  }

  body[data-route="editor"] #adjustCurrentPart {
    height: 22px;
    min-height: 22px;
    padding: 2px 7px;
    margin-left: auto;
    font-size: 10px;
  }

  body[data-route="editor"] .dock-heading {
    height: 36px;
    min-height: 36px;
    padding-block: 3px;
  }

  body[data-route="editor"] .color-section {
    grid-template-rows: 24px 30px 30px;
  }

  body[data-route="editor"] .color-section .control-title {
    height: 24px;
    min-height: 24px;
    margin-bottom: 0;
  }

  body[data-route="editor"] #resetPartColor {
    height: 22px;
    min-height: 22px !important;
    padding-block: 1px;
  }

  body[data-route="editor"] .swatches {
    grid-template-rows: 24px;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
  }

  body[data-route="editor"] .saved-color-empty {
    display: none;
  }

  body[data-route="editor"] .free-color,
  body[data-route="editor"] .saved-colors {
    height: 30px;
    min-height: 30px;
    margin-top: 0;
  }

  body[data-route="editor"] #freeColorOpen {
    height: 28px;
    min-height: 28px !important;
  }

  body[data-route="editor"] .edit-dock {
    max-height: clamp(125px, calc(100dvh - 443px), 167px);
  }
}

/*
 * Short landscape keeps the character on the left and the complete first
 * clothing row on the right. The scroll hint duplicates behaviour already
 * communicated by the clipped catalogue edge, so it yields its row to the
 * actual cards. The dock remains a separate short scroll viewport.
 */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="editor"] .closet-note-row {
    display: none !important;
  }

  body[data-route="editor"] .edit-dock {
    max-height: 85px;
  }

  body[data-route="editor"] .dock-heading {
    height: 36px;
    min-height: 36px;
    padding-block: 3px;
  }
}

/*
 * Android 2.175 palette geometry. The original palette is one eight-column,
 * vertically scrolling grid. Free colour and favourites are cells in that
 * grid rather than separate controls below it.
 */
body[data-route="editor"] .color-section > .free-color {
  display: none !important;
}

body[data-route="editor"] #swatches {
  box-sizing: border-box;
  display: grid !important;
  grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
  grid-template-rows: none !important;
  grid-auto-flow: row !important;
  grid-auto-rows: 27px;
  gap: 9px 6px !important;
  justify-items: center;
  align-content: start;
  width: 100%;
  height: 78px;
  max-height: 78px;
  padding: 3px 5px 5px;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  touch-action: pan-y !important;
  scrollbar-width: thin;
  scrollbar-color: #cdd7c3 transparent;
}

body[data-route="editor"] #swatches .swatch,
body[data-route="editor"] #swatches .saved-color-swatch {
  box-sizing: border-box;
  width: 27px !important;
  height: 27px !important;
  min-width: 27px;
  min-height: 27px !important;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  outline: 1px solid #d4d9d2;
  outline-offset: 0;
  box-shadow: none;
  touch-action: manipulation;
}

body[data-route="editor"] #swatches .swatch.selected,
body[data-route="editor"] #swatches .saved-color-swatch.selected {
  outline: 2px solid #627b6b;
  outline-offset: 1px;
  box-shadow: none;
}

body[data-route="editor"] #swatches .swatch.original {
  position: relative;
  background: #fffdf7 !important;
}

body[data-route="editor"] #swatches .swatch.original::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border: 1.4px solid #a4b09f;
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

body[data-route="editor"] #swatches .swatch.original::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 17px;
  height: 1.4px;
  background: #a4b09f;
  content: "";
  transform: translate(-50%, -50%) rotate(-45deg);
}

body[data-route="editor"] #swatches #freeColorOpen {
  display: block;
  grid-column: auto !important;
  grid-row: auto !important;
  overflow: hidden;
  margin: 0 !important;
  min-width: 27px !important;
  min-height: 27px !important;
  border: 3px solid #fff;
  border-radius: 50%;
  background: conic-gradient(#e6b5c2, #dfcba3, #c3d8b4, #b6d5d6, #c3b9dc, #e6b5c2) !important;
  box-shadow: none;
  color: transparent;
  font-size: 0;
}

body[data-route="editor"] #swatches #freeColorOpen > span,
body[data-route="editor"] #swatches #freeColorOpen > b {
  display: none;
}

body[data-route="editor"] #swatches #savedColorSwatches {
  display: contents !important;
  grid-column: auto !important;
  grid-row: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
  overflow: visible;
}

body[data-route="editor"] #swatches .saved-color-empty {
  display: none !important;
}

@media (max-width: 520px) and (max-height: 620px) {
  body[data-route="editor"] .color-section {
    grid-template-rows: 24px 36px !important;
  }

  body[data-route="editor"] #swatches {
    height: 36px;
    max-height: 36px;
    grid-auto-rows: 27px;
  }
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) {
  body[data-route="editor"] .color-section {
    grid-template-rows: 20px 27px !important;
  }

  body[data-route="editor"] .color-section .control-title {
    height: 20px !important;
    min-height: 20px !important;
  }

  body[data-route="editor"] #swatches {
    height: 27px;
    max-height: 27px;
    padding-block: 0;
    grid-auto-rows: 27px;
  }
}

/*
 * Android 2.175 free-colour dialog. The original remains a compact 300px
 * sheet on phones and keeps the controls in one vertical flow. Favourite
 * colours stay in the palette behind the sheet; the dialog itself contains
 * only hue/value, preview, HEX, RGB and the two footer actions.
 */
@media (max-width: 600px) {
  body[data-route="editor"] .color-picker-dialog {
    box-sizing: border-box;
    width: min(300px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 20px;
    overflow: hidden;
    border: 1px solid #d9e1d3;
    border-radius: 20px;
    color: #768b7b;
    background: #faf9f2 !important;
    font: 13px "YuzuPop", "Microsoft YaHei", "PingFang SC", sans-serif;
    box-shadow: none;
  }

  body[data-route="editor"] .color-picker-dialog form {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    max-height: calc(100dvh - 74px);
    min-height: 0;
  }

  body[data-route="editor"] .color-picker-dialog header {
    display: flex;
    min-height: 36.57px;
    margin: 12px 0;
    padding: 0;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    border: 0;
    background: #faf9f2 !important;
  }

  body[data-route="editor"] .color-picker-dialog header h2 {
    margin: 0;
    color: #768b7b;
    font: 700 13px/1.4 "YuzuPop", "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="editor"] .color-picker-dialog header > button {
    box-sizing: border-box;
    width: 40.52px;
    height: 36.57px;
    min-height: 36.57px;
    padding: 8px 13px;
    border: 1px solid #dce3d7;
    border-radius: 10px;
    color: #768b7b;
    background: #e9eee3;
    font: 13px/1 "YuzuPop", "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="editor"] .color-picker-body {
    min-height: 0;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #faf9f2 !important;
    touch-action: pan-y;
  }

  body[data-route="editor"] .color-picker-layout {
    display: block;
  }

  body[data-route="editor"] .color-picker-field-wrap {
    display: block;
    margin: 0 0 12px;
  }

  body[data-route="editor"] .color-picker-field {
    width: 100%;
    height: 175px;
    min-height: 175px;
    border-radius: 12px;
  }

  body[data-route="editor"] .color-picker-field i {
    width: 12px;
    height: 12px;
    border-width: 1.9px;
    box-shadow: 0 0 0 1px #687765;
  }

  body[data-route="editor"] #colorPickerHue {
    width: 100%;
    height: 17px;
    margin: 12px 0;
    border: 0;
    border-radius: 20px;
  }

  body[data-route="editor"] #colorPickerHue::-webkit-slider-thumb {
    width: 20px;
    height: 26px;
    border: 2px solid #fff;
    border-radius: 10px;
  }

  body[data-route="editor"] .color-picker-controls {
    display: block;
  }

  body[data-route="editor"] .color-picker-preview {
    box-sizing: border-box;
    display: block;
    width: 100%;
    height: 54px;
    min-height: 54px;
    border: 1px solid #e1e4db;
    border-radius: 13px;
  }

  body[data-route="editor"] .color-picker-hex {
    display: flex;
    min-height: 32.57px;
    margin: 12px 0;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    color: #768b7b;
    font-size: 13px;
  }

  body[data-route="editor"] .color-picker-hex input {
    box-sizing: border-box;
    width: 100px;
    height: 32.57px;
    min-height: 32.57px;
    padding: 6px;
    border: 1px solid #dce3d7;
    border-radius: 8px;
    color: #768b7b;
    background: #fffdf7;
    font: 13px/1 "YuzuPop", "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="editor"] .color-picker-rgb {
    display: block;
  }

  body[data-route="editor"] .color-picker-rgb label {
    display: flex;
    min-height: 20px;
    margin: 12px 0;
    gap: 12px;
    align-items: center;
    color: #768b7b;
    font-size: 13px;
  }

  body[data-route="editor"] .color-picker-rgb input {
    flex: 1;
    min-width: 0;
    width: auto;
    accent-color: #9db4a7;
  }

  body[data-route="editor"] .color-picker-rgb output {
    flex: 0 0 30px;
    color: #768b7b;
    text-align: right;
  }

  body[data-route="editor"] .color-picker-dialog footer {
    display: flex;
    min-height: 36.57px;
    margin: 0 0 12px;
    padding: 0;
    gap: 12px;
    border: 0;
    background: #faf9f2 !important;
  }

  body[data-route="editor"] .color-picker-dialog footer button {
    box-sizing: border-box;
    flex: 1;
    height: 36.57px;
    min-height: 36.57px;
    padding: 8px 13px;
    border: 1px solid #dce3d7;
    border-radius: 10px;
    color: #768b7b;
    background: #e9eee3;
    font: 13px/1 "YuzuPop", "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="editor"] .color-picker-dialog footer button:last-child {
    border-color: #dce3d7;
    color: #768b7b;
    background: #e9eee3;
  }
}

@media (max-width: 600px) and (min-height: 700px) {
  body[data-route="editor"] .color-picker-dialog {
    position: fixed;
    inset: 65px 0 0;
    margin: auto;
  }
}

@media (max-width: 600px) and (max-height: 620px) {
  body[data-route="editor"] .color-picker-dialog {
    padding: 16px;
  }

  body[data-route="editor"] .color-picker-dialog form {
    max-height: calc(100dvh - 66px);
  }

  body[data-route="editor"] .color-picker-dialog header,
  body[data-route="editor"] .color-picker-hex,
  body[data-route="editor"] .color-picker-rgb label,
  body[data-route="editor"] .color-picker-dialog footer {
    margin-block: 8px;
  }

  body[data-route="editor"] .color-picker-field-wrap {
    margin: 0 0 8px;
  }

  body[data-route="editor"] .color-picker-field {
    height: 140px;
    min-height: 140px;
  }
}

/*
 * Android 2.175 wardrobe palette and layer rhythm. Keep the replica's
 * additional quick actions available, but compress them so they do not
 * displace the original pastel controls or turn the colour row into a
 * developer-style HEX readout.
 */
@media (max-width: 850px) and (orientation: portrait) {
  body[data-route="editor"] .panel-selection b {
    color: #7e9077 !important;
  }

  body[data-route="editor"] .editor-title h2 {
    color: #829080 !important;
  }

  body[data-route="editor"] .panel-command-actions .layer-quick-button {
    box-sizing: border-box;
    width: 28px;
    min-width: 28px;
    padding: 4px;
    border: 1px solid #e1e6db;
    border-radius: 9px;
    color: #7e8e7a;
    background: #fffef9 !important;
  }

  body[data-route="editor"] .panel-command-actions .layer-quick-button span,
  body[data-route="editor"] .panel-command-actions .layer-quick-button b {
    display: none;
  }

  body[data-route="editor"] .panel-command-actions .history-group {
    gap: 4px;
  }

  body[data-route="editor"] .panel-command-actions .history-group button {
    box-sizing: border-box;
    display: inline-flex;
    width: auto;
    min-width: 0;
    height: 35.1px;
    min-height: 35.1px;
    padding: 4px 5px;
    gap: 1px;
    border-radius: 11px;
    color: #829278;
    background: transparent;
    font-size: 11px;
    white-space: nowrap;
  }

  body[data-route="editor"] .panel-command-actions .history-group button svg {
    display: none;
  }

  body[data-route="editor"] .panel-command-actions .history-group button span {
    display: inline;
  }

  body[data-route="editor"] #undoButton::before {
    content: "↶";
  }

  body[data-route="editor"] #redoButton {
    border: 1px solid #e8dfeb;
    color: #5e5768;
    background: #fffdfb !important;
  }

  body[data-route="editor"] #redoButton::before {
    content: "↷";
  }

  body[data-route="editor"] .tabs button[aria-selected="true"] {
    color: #849971 !important;
    background: #e3ebd9;
  }

  body[data-route="editor"] .category-row button[aria-selected="true"] {
    color: #8fa577 !important;
    border-color: #8fa577 #8fa577 #b0c19f !important;
  }

  body[data-route="editor"] .closet-scroll-note,
  body[data-route="editor"] .closet-note {
    color: #a3ae98 !important;
    background: #f8f8f1 !important;
    font-size: 10px !important;
    line-height: 15px;
  }

  body[data-route="editor"] #adjustCurrentPart {
    width: auto;
    min-height: 36px;
    padding: 4px 10px;
    border: 0.762px solid #e9e1e9;
    border-radius: 10px;
    color: #7e8d78;
    background: #f7f7ef !important;
    font: 12px/1.2 "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="editor"] .item-card.selected {
    border: 1.143px solid #aabc96;
    color: #7a8d70 !important;
    background: #eaf0e1 !important;
  }

  body[data-route="editor"] .dock-heading {
    position: absolute;
    top: 0;
    right: 16px;
    z-index: 5;
    width: 30px;
    min-height: 30px;
    height: 30px;
    padding: 0;
    pointer-events: none;
  }

  body[data-route="editor"] .dock-heading > div {
    display: none;
  }

  body[data-route="editor"] .dock-heading small {
    display: none;
  }

  body[data-route="editor"] .dock-collapse {
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px !important;
    padding: 0;
    border: 0;
    color: #829278;
    background: transparent;
    pointer-events: auto;
  }

  body[data-route="editor"] .dock-collapse span {
    display: none;
  }

  body[data-route="editor"] .dock-collapse svg {
    width: 16px;
    height: 16px;
    transform: none;
  }

  body[data-route="editor"].dock-is-collapsed .dock-heading,
  body[data-route="editor"] .edit-dock.dock-is-collapsed .dock-heading {
    position: relative;
    top: auto;
    right: auto;
    display: flex;
    width: 100%;
    min-height: 29px;
    height: 29px;
    padding: 4px 16px;
    pointer-events: auto;
  }

  body[data-route="editor"] .edit-dock.dock-is-collapsed .dock-heading > div {
    display: flex;
  }

  body[data-route="editor"] .edit-dock.dock-is-collapsed .dock-heading small {
    display: none;
  }

  body[data-route="editor"] .edit-dock.dock-is-collapsed .dock-heading b {
    display: block;
    color: #7e9271;
    font-size: 11px;
  }

  body[data-route="editor"] .edit-dock.dock-is-collapsed .dock-collapse {
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 29px !important;
    padding: 2px 4px;
    color: #829278;
    font-size: 8px;
  }

  body[data-route="editor"] .edit-dock.dock-is-collapsed .dock-collapse span {
    display: inline;
  }

  body[data-route="editor"] .dock-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 16px 12px;
  }

  body[data-route="editor"] .color-section {
    display: block;
    min-width: 0;
    order: 1;
  }

  body[data-route="editor"] .color-section .control-title {
    height: 30px;
    min-height: 30px;
    margin: 0 0 10px;
    color: #7e9271 !important;
    font: 11px/15.6px "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    padding-right: 30px;
  }

  body[data-route="editor"] #colorLabel {
    min-width: 0;
    overflow: hidden;
    line-height: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-route="editor"] #colorValue {
    flex: none;
    margin-left: auto;
    color: #b2bca7;
    font-size: 9px;
    font-weight: 400;
    line-height: normal;
  }

  body[data-route="editor"] #colorPaletteFold {
    display: none;
  }

  body[data-route="editor"] #swatches {
    margin: 0;
  }

  body[data-route="editor"] .advanced-section {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    order: 2;
  }

  body[data-route="editor"] .adjust-section {
    order: 3;
  }

  body[data-route="editor"] .edit-dock[data-tool-context="adjust"] .adjust-section {
    order: 1;
  }

  body[data-route="editor"] .edit-dock[data-tool-context="adjust"] .dock-heading {
    display: none;
  }

  body[data-route="editor"] .edit-dock[data-tool-context="adjust"] .color-section {
    order: 2;
  }

  body[data-route="editor"] .edit-dock[data-tool-context="adjust"] .advanced-section {
    order: 3;
  }

  body[data-route="editor"] .edit-dock[data-tool-context="layer"] .advanced-section {
    order: 1;
  }

  body[data-route="editor"] .edit-dock[data-tool-context="layer"] .color-section {
    order: 2;
  }

  body[data-route="editor"] .edit-dock[data-tool-context="layer"] .adjust-section {
    order: 3;
  }

  body[data-route="editor"] .advanced-section > .outfit-link-card {
    order: -2;
  }

  body[data-route="editor"] .advanced-section > .primary-layer-editor {
    order: -1;
  }

  body[data-route="editor"] .outfit-link-card {
    padding: 0;
    border: 0;
    background: transparent !important;
  }

  body[data-route="editor"] .palette-secondary-row {
    display: flex;
    min-height: 28px;
    align-items: center;
    gap: 6px;
    padding-top: 4px;
  }

  body[data-route="editor"] .palette-secondary-row .feature-switch-row {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 24px;
    padding: 0;
    color: #94a187;
    background: transparent;
    font-size: 10px;
  }

  body[data-route="editor"] .palette-secondary-row .feature-switch-row b {
    font-size: 10px;
    font-weight: 400;
  }

  body[data-route="editor"] .palette-secondary-row .feature-switch-row small {
    display: none;
  }

  body[data-route="editor"] .outfit-link-card > .feature-switch-row {
    display: none;
  }

  body[data-route="editor"] #resetPartColor {
    flex: none;
    width: 56px;
    min-height: 29px;
    margin: 0;
    padding: 4px 0;
    border: 0;
    color: #a5af99;
    background: transparent;
    border-radius: 10px;
    font: 10px/normal "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="editor"] .primary-layer-editor {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  body[data-route="editor"] .primary-layer-editor .layer-heading {
    height: 29.62px;
    min-height: 29.62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  body[data-route="editor"] .primary-layer-editor .layer-heading > button {
    box-sizing: border-box;
    display: inline-flex;
    width: auto;
    height: 29.62px;
    min-height: 29.62px;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border: 0;
    border-radius: 999px;
    color: #697e65;
    background: #e1e8da;
    font: 11px/normal "YuzuPop", "Microsoft YaHei", "PingFang SC", sans-serif;
  }

  body[data-route="editor"] #resetLayerOrder {
    width: 48px;
    order: 1;
  }

  body[data-route="editor"] #layerEditorToggle {
    width: 62.6px;
    order: 2;
    gap: 4px;
  }

  body[data-route="editor"] #layerEditorToggle b,
  body[data-route="editor"] #layerEditorToggle small {
    display: none;
  }

  body[data-route="editor"] #layerEditorToggle i {
    font-style: normal;
    transition: transform 160ms ease;
  }

  body[data-route="editor"] #layerEditorToggle[aria-expanded="true"] i {
    transform: rotate(180deg);
  }

  body[data-route="editor"] .layer-new-top {
    display: flex;
    width: 100%;
    min-height: 22px;
    margin: 6px 0 0;
    gap: 5px;
    align-items: center;
    color: #82947b;
    font-size: 11px;
  }

  body[data-route="editor"] .layer-new-top small {
    display: none;
  }

  body[data-route="editor"] .layer-content {
    margin-top: 8px;
  }
}

/*
 * Portrait 2.175 spacing audit at the emulator's 412 x 842 CSS viewport.
 *
 * The original categories keep 32px buttons inside a 43px scroll row. The
 * note itself is 30px tall and vertically centred in the 36px note row.
 * The colour title/swatch grid sits 11px lower than the replica's previous
 * footer rhythm, while the sleeve-follow row remains in place. This keeps
 * the layer heading in the original slot without enlarging the dock.
 */
/*
 * Keep the original pale surfaces but raise the three low-contrast labels
 * above the readability threshold. These are deliberate accessibility
 * deviations from 2.175's washed-out text colours and apply at every phone
 * height, including the 320x568 short-screen path.
 */
@media (max-width: 850px) and (orientation: portrait) {
  body[data-route="editor"] .editor-title h2 {
    color: #566c4e !important;
  }

  body[data-route="editor"] .panel-selection b {
    color: #526656 !important;
  }

  body[data-route="editor"] .tabs button {
    background-color: #f8f8f1 !important;
  }

  body[data-route="editor"] .tabs button.active {
    color: #405c45 !important;
    background-color: #e3ebd9 !important;
  }
}

@media (max-width: 850px) and (orientation: portrait) and (min-height: 701px) {
  body[data-route="editor"] .category-row button {
    height: 32px;
    min-height: 32px;
    align-self: flex-start;
  }

  body[data-route="editor"] .category-row {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #a8b99e #f5f5eb;
  }

  body[data-route="editor"] .category-row::-webkit-scrollbar {
    display: block;
    width: 7px;
    height: 5px;
  }

  body[data-route="editor"] .category-row::-webkit-scrollbar-track {
    background: #f5f5eb;
  }

  body[data-route="editor"] .category-row::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background: #a8b99e;
  }

  /*
   * Original 2.175 exposes undo/redo in this row. Outfit and layer access
   * remain available from the 套装 tab and the visible 图层 control below,
   * so the two extra toolbar shortcuts are removed from the phone portrait
   * chrome instead of crowding the original heading rhythm.
   */
  body[data-route="editor"] .panel-command-actions > .layer-quick-button {
    display: none !important;
  }

  body[data-route="editor"] .closet-note-row {
    margin-top: 0;
  }

  body[data-route="editor"] .closet-note-row .closet-scroll-note {
    box-sizing: border-box;
    min-height: 30px;
    padding: 0 1px 9px;
    display: flex;
    align-items: center;
    background-color: #f8f8f1;
  }

  body[data-route="editor"] .catalog-grid {
    margin-top: 0;
  }

  body[data-route="editor"] .color-section {
    padding-top: 11px;
  }

  body[data-route="editor"] .advanced-section {
    padding-top: 0;
  }

  body[data-route="editor"] .palette-secondary-row {
    height: 28px;
    min-height: 28px;
    padding-top: 1px;
  }

  body[data-route="editor"] #resetPartColor {
    transform: translateY(-2px);
  }

  body[data-route="editor"] .primary-layer-editor {
    margin-top: 16px;
  }
}

/*
 * Android 2.175 catalogue fills, read from the live WebView after all older
 * responsive overrides have applied. Saved outfits use warm sage paper; the
 * add-slot is a lighter sage; part cards use near-white paper with a pale
 * green selected state.
 */
body[data-route="editor"] #catalogGrid .item-card:not(.outfit-card):not(.outfit-new-slot) {
  border-color: #e4e8dc !important;
  background: #fffef8 !important;
  box-shadow: none !important;
}

body[data-route="editor"] #catalogGrid .item-card.selected:not(.outfit-card):not(.outfit-new-slot) {
  border-color: #aabc96 !important;
  background: #eaf0e1 !important;
  box-shadow: none !important;
}

body[data-route="editor"] .outfit-card,
body[data-route="editor"] .outfit-card-load,
body[data-route="editor"] .outfit-card-preview,
body[data-route="editor"] .outfit-card-copy {
  border-color: #e0e5d7;
  background: #f1f2e9 !important;
  background-image: none !important;
  box-shadow: none !important;
}

body[data-route="editor"] .outfit-card.is-current,
body[data-route="editor"] .outfit-card.is-current .outfit-card-load,
body[data-route="editor"] .outfit-card.is-current .outfit-card-preview,
body[data-route="editor"] .outfit-card.is-current .outfit-card-copy {
  background: #eaf0e1 !important;
}

body[data-route="editor"] .outfit-card.is-current .outfit-card-load {
  border-color: #aabc96;
}

body[data-route="editor"] .outfit-new-slot {
  border-color: #e4e8dc !important;
  background: #edf1e4 !important;
  color: #8da083;
}

/*
 * White and cream wearable sprites disappear against the previous white
 * catalogue tiles. Keep the card shell light, but give every part thumbnail
 * an opaque sage preview so pale garments remain visible before selection.
 */
body[data-route="editor"] #catalogGrid .item-thumbnail,
body[data-route="editor"] #layerList .layer-thumbnail {
  box-sizing: border-box;
  border: 1px solid #b9c8b2 !important;
  background: #cbd8c4 !important;
  background-image: none !important;
}

body[data-route="editor"] #catalogGrid .item-card.selected .item-thumbnail {
  border-color: #8da382 !important;
  background: #bdcfb4 !important;
}
