/* The desktop scene keeps its original layout. Compact screens use real flow. */
.mobile-profile-heading,
.mobile-profile-tabs,
.mobile-profile-delete,
.mobile-welcome-copy,
.mobile-welcome-note,
.mobile-button-label,
.mobile-nav,
.mobile-panel {
  display: none;
}

@media (max-width: 1024px) {
  :root {
    color-scheme: light;
    --mobile-nav-height: calc(76px + env(safe-area-inset-bottom, 0px));
    --mobile-card-top: calc(var(--mobile-viewport-top, 0px) + 12px + env(safe-area-inset-top, 0px));
    --mobile-card-height: calc(var(--mobile-viewport-height, 100dvh) - var(--mobile-nav-height) - 24px - env(safe-area-inset-top, 0px));
  }

  body { background: #fff6e9; }
  button, a, input, select, textarea { touch-action: manipulation; }
  button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid #c26a49;
    outline-offset: 3px;
  }

  /* Welcome: keep the original sunlit room and plush companion. */
  #landing, #landing .start-viewport {
    height: auto;
    min-height: 100svh;
    width: 100%;
    background: #fff7ec;
  }
  #landing .start-stage {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-rows: auto minmax(160px, 1fr) 56px 48px;
    gap: 12px;
    width: 100%;
    height: 100svh;
    min-height: 610px;
    padding: calc(32px + env(safe-area-inset-top, 0px)) max(28px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(28px, env(safe-area-inset-left, 0px));
    transform: none !important;
    background: radial-gradient(ellipse at 0 5%, #fffdf8, transparent 70%), #fff4e4;
    isolation: isolate;
  }
  #landing .start-stage::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 25% 0 126px;
    background: url("./assets/start-bg.png") 85% center / auto 100% no-repeat;
    mask-image: linear-gradient(transparent, #000 16%, #000 84%, transparent);
    -webkit-mask-image: linear-gradient(transparent, #000 16%, #000 84%, transparent);
  }
  .mobile-welcome-copy { display: block; color: #795039; }
  .mobile-welcome-brand { font-size: 22px; font-weight: 750; letter-spacing: .14em; }
  .mobile-welcome-brand > span { color: #dfa066; font-size: 20px; }
  .mobile-welcome-copy .mobile-welcome-eyebrow { margin: 30px 0 12px; color: #a77b5e; font-size: 13px; letter-spacing: .15em; }
  .mobile-welcome-copy h1 { margin: 0; color: #6d422e; font-size: clamp(28px, 7.6vw, 40px); line-height: 1.5; font-weight: 700; }
  .mobile-welcome-copy > p:last-child { margin: 14px 0 0; font-size: 13px; line-height: 1.8; }
  .mobile-welcome-note {
    display: block;
    align-self: end;
    justify-self: start;
    max-width: 142px;
    margin-bottom: 24px;
    padding: 10px 12px;
    border: 1px solid #efddc7;
    border-radius: 16px 16px 16px 4px;
    background: rgba(255, 252, 246, .85);
    color: #94684d;
    font-size: 12px;
    box-shadow: 0 8px 24px #a4764420;
  }
  .mobile-welcome-note span { color: #db8770; }
  #landing .start-hotspot {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    border-radius: 19px;
    font-size: 16px;
    font-weight: 650;
  }
  #landing .start-hotspot-primary {
    color: #fff;
    background: linear-gradient(120deg, #f58165, #f5a379);
    box-shadow: 0 10px 24px #de795a30, inset 0 1px #ffffff80;
  }
  #landing .start-hotspot-guide { border: 1px solid #ead6c0; color: #8a6046; background: #fffaf1c9; }
  .mobile-button-label { display: inline; }
  .mobile-button-label > span { margin-left: 18px; }

  /* The chat occupies the available viewport, including when a keyboard opens. */
  #appShell.xhaus-chat-home,
  body.control-open #appShell.xhaus-chat-home {
    top: var(--mobile-viewport-top, 0px) !important;
    bottom: auto !important;
    width: 100% !important;
    height: var(--mobile-viewport-height, 100dvh) !important;
    overflow: hidden !important;
  }
  #appShell.xhaus-chat-home .sample-wrap {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
  }
  #appShell.xhaus-chat-home .sample-board {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px;
    grid-template-rows: 48px minmax(0, 1fr);
    gap: 8px;
    width: 100% !important;
    height: 100% !important;
    padding: calc(6px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) var(--mobile-nav-height) max(12px, env(safe-area-inset-left, 0px));
    margin: 0;
    transform: none !important;
  }
  #appShell.xhaus-chat-home .sample-board > .sidebar,
  #appShell.xhaus-chat-home .sample-board > .runtime-panel.butlers:not(.is-open),
  #appShell.xhaus-chat-home .sample-board > .lower-control-row:not(.is-open) { display: none !important; }
  body.mobile-card-open #appShell.xhaus-chat-home .sample-board { visibility: hidden; }
  #appShell.xhaus-chat-home .sample-board > .top-brand {
    position: static;
    display: flex !important;
    grid-area: 1 / 1;
    align-self: center;
    width: 90px;
    height: 44px;
    gap: 5px;
    padding: 0;
    background: none;
    box-shadow: none;
  }
  #appShell.xhaus-chat-home .brand-mark { width: 25px; height: 25px; border-radius: 9px; }
  #appShell.xhaus-chat-home .brand-copy { font-size: 16px; }
  #appShell.xhaus-chat-home .sample-board > .top-status {
    position: static;
    display: flex !important;
    grid-area: 1 / 1;
    justify-content: flex-end !important;
    align-self: center;
    width: auto !important;
    height: 44px;
    margin-left: 94px;
    gap: 4px;
  }
  #appShell.xhaus-chat-home #xhausStatus,
  #appShell.xhaus-chat-home #openclawStatus {
    width: 8px !important;
    min-width: 8px !important;
    height: 8px !important;
    padding: 0 !important;
    border: 0;
    background: none;
    box-shadow: none;
  }
  #appShell.xhaus-chat-home .top-status .pill-icon,
  #appShell.xhaus-chat-home .butler-pill > span:first-child { display: none; }
  #appShell.xhaus-chat-home .top-status .dot { flex: 0 0 5px; width: 5px; height: 5px; }
  #appShell.xhaus-chat-home .butler-pill {
    flex: 0 1 auto;
    min-width: 0 !important;
    max-width: 160px;
    height: 44px;
    gap: 4px !important;
    padding: 0 5px;
    border: 0;
    background: none;
    box-shadow: none;
    font-size: 12px;
  }
  #appShell.xhaus-chat-home .butler-pill .avatar { flex: 0 0 24px; width: 24px; height: 24px; }
  #appShell.xhaus-chat-home #activeAgentName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #appShell.xhaus-chat-home .sample-board > .top-icons {
    position: static;
    display: flex !important;
    grid-area: 1 / 2;
    align-self: center;
    gap: 2px;
    width: auto;
    height: 44px;
  }
  #appShell.xhaus-chat-home .top-icons .circle { width: 44px; height: 44px; font-size: 17px; box-shadow: none; }
  #appShell.xhaus-chat-home .chat {
    position: relative;
    inset: auto;
    grid-area: 2 / 1 / 3 / -1;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    padding: 18px 12px 12px;
    border-radius: 26px;
  }
  #appShell.xhaus-chat-home .hero { min-height: 70px; padding: 0 66px 14px 6px; }
  #appShell.xhaus-chat-home .hero::after {
    content: "";
    position: absolute;
    top: -12px;
    right: -7px;
    width: 82px;
    height: 82px;
    background: url("./assets/bear-cutout.png") center / contain no-repeat;
    pointer-events: none;
  }
  #appShell.xhaus-chat-home .hero h1 { font-size: clamp(17px, 4.6vw, 25px); line-height: 1.4; overflow-wrap: anywhere; }
  #appShell.xhaus-chat-home .hero p { margin-top: 5px; font-size: 13px; line-height: 1.6; }
  #appShell.xhaus-chat-home .quick {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 2px 10px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #appShell.xhaus-chat-home .quick::-webkit-scrollbar { display: none; }
  #appShell.xhaus-chat-home .chip { flex: 0 0 auto; width: auto; height: 44px; padding: 0 12px; font-size: 12px; }
  #appShell.xhaus-chat-home .visual { min-width: 0; margin: 0 0 10px; border-radius: 18px; }
  #appShell.xhaus-chat-home .orb-wrap { display: grid !important; }
  #appShell.xhaus-chat-home .orb { width: 68px; height: 68px; margin-bottom: 16px; font-size: 26px; }
  #appShell.xhaus-chat-home .orb-title { font-size: 17px; font-weight: 600; }
  #appShell.xhaus-chat-home .orb-subtitle { color: #ae866b; font-size: 13px; }
  #appShell.xhaus-chat-home .messages { inset: 0 !important; padding: 12px 8px !important; overscroll-behavior-y: contain; }
  #appShell.xhaus-chat-home .bubble { max-width: 92%; min-width: 0; padding: 12px; font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
  #appShell.xhaus-chat-home .bubble pre { max-width: 100%; overflow-x: auto; white-space: pre; }
  #appShell.xhaus-chat-home .bubble table { display: block; max-width: 100%; overflow-x: auto; }
  #appShell.xhaus-chat-home .bubble img { max-width: 100%; height: auto; }
  #appShell.xhaus-chat-home .composer {
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    grid-template-rows: 44px auto !important;
    min-height: 0 !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 8px !important;
    border-radius: 20px;
  }
  #appShell.xhaus-chat-home .composer #messageInput { height: 44px !important; font-size: 16px; }
  #appShell.xhaus-chat-home .composer .plus,
  #appShell.xhaus-chat-home .composer .send-button { width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; }
  #appShell.xhaus-chat-home .composer .tools { height: 44px !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 48px; gap: 6px !important; }
  #appShell.xhaus-chat-home .composer .model-picker-prefix { display: none; }
  #appShell.xhaus-chat-home .composer #modelSelect,
  #appShell.xhaus-chat-home .composer #guiModelSelect { height: 44px; font-size: 16px; padding-left: 7px; padding-right: 22px; background-position: right 7px center; }
  #appShell.xhaus-chat-home .composer .gui-model-picker { padding-left: 0; }
  #appShell.xhaus-chat-home .composer .gui-task-button { height: 44px; padding: 0 6px; font-size: 0; }
  #appShell.xhaus-chat-home .composer .gui-task-button::after { content: "GUI"; font-size: 12px; }
  #appShell.xhaus-chat-home .composer.mobile-tools-collapsed { grid-template-rows: 44px !important; }
  #appShell.xhaus-chat-home .composer.mobile-tools-collapsed .tools { display: none !important; }

  #appShell.xhaus-chat-home > .mobile-nav {
    position: absolute;
    z-index: 80;
    inset: auto max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: var(--mobile-nav-height);
    gap: 4px;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(#fff7edee, #fff4e6);
    border-radius: 22px 22px 0 0;
  }
  #appShell.xhaus-chat-home .mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 52px;
    padding: 5px 2px;
    border: 0;
    border-radius: 17px;
    background: transparent;
    color: #94715b;
    font-size: 12px;
  }
  #appShell.xhaus-chat-home .mobile-nav button > span { font-size: 23px; line-height: 25px; }
  #appShell.xhaus-chat-home .mobile-nav button[aria-current="page"] { color: #a44f39; background: #ffe4d4; box-shadow: inset 0 1px #fff9f0; font-weight: 700; }

  /* Every destination is a scrollable paper card above the navigation. */
  body.control-open #appShell.xhaus-chat-home > #controlBackdrop { display: none !important; }
  body.control-open #appShell.xhaus-chat-home > .runtime-panel.is-open,
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open {
    top: 0 !important;
    height: 100% !important;
    overflow: visible !important;
    border: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    pointer-events: none;
  }
  body.control-open #appShell.xhaus-chat-home > .runtime-panel.is-open > .activate-card,
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open > .control-card,
  #mobilePanel {
    top: var(--mobile-card-top) !important;
    left: max(12px, env(safe-area-inset-left, 0px)) !important;
    right: max(12px, env(safe-area-inset-right, 0px)) !important;
    bottom: auto !important;
    width: auto !important;
    height: var(--mobile-card-height) !important;
    max-height: none !important;
    min-height: 0 !important;
    padding: 16px !important;
    border: 1px solid #e9cdb266 !important;
    border-radius: 25px !important;
    background: linear-gradient(155deg, #fffdf7, #fff1df) !important;
    color: #795039;
    box-shadow: 0 12px 40px #8a542323 !important;
    transform: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    pointer-events: auto;
  }
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active] > .control-card { display: block !important; overflow-y: auto !important; }
  body.control-open #appShell.xhaus-chat-home > .runtime-panel.is-open > .activate-card { display: block !important; }
  body.control-open #appShell.xhaus-chat-home .note::before,
  body.control-open #appShell.xhaus-chat-home .note::after { display: none !important; }
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="skill"] > .memory-card,
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .skill-card { display: none !important; }
  body.control-open #appShell.xhaus-chat-home > :is(.runtime-panel, .lower-control-row).is-open .panel-head {
    position: sticky;
    top: -16px;
    z-index: 5;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    min-height: 56px !important;
    margin: -16px -16px 16px !important;
    padding: 6px 16px !important;
    background: #fff9ef;
    border-bottom: 1px solid #eddcc5;
  }
  body.control-open #appShell.xhaus-chat-home > :is(.runtime-panel, .lower-control-row).is-open .drawer-close {
    width: auto !important;
    height: 44px !important;
    min-width: 72px !important;
    padding: 0 10px;
    border-radius: 12px !important;
    color: #8a593c !important;
    font-size: 14px !important;
  }
  body.control-open #appShell.xhaus-chat-home .is-open .panel-actions { flex: 0 0 auto; }
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .panel-actions > [data-open-control] { display: none; }
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .persona-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .persona-choice-wrap,
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .persona-choice { height: 190px !important; min-width: 0 !important; }
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .persona-card-img { max-width: 100% !important; }
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .butler-meta { display: flex !important; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .butler-meta .ellipsis { flex: 1 0 100%; white-space: normal; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open .doc-title,
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open textarea { font-size: 16px !important; margin-bottom: 12px !important; }
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active] > .control-card > textarea { height: 144px !important; min-height: 120px !important; max-height: none !important; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open .wide-action { min-height: 44px !important; height: auto !important; margin: 8px 0 16px; font-size: 14px; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open .force-toggle { min-height: 44px !important; margin-right: 10px; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open .memory-expand-source,
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active] > .control-card .doc-list { display: block; height: auto !important; max-height: none !important; overflow: visible !important; }
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .memory-card > .memory-expand-source,
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .memory-card .memory-list,
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .memory-card .satellite-report-panel,
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .memory-card .satellite-changes { height: auto !important; overflow: visible !important; }
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .memory-card.satellite-view {
    display: block !important;
    min-height: 0 !important;
  }
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .memory-card.satellite-view > .memory-expand-source { min-height: 0 !important; display: block !important; }
  body.control-open #appShell.xhaus-chat-home > .lower-control-row.is-open[data-active="memory"] > .memory-card.satellite-view > :is(.doc-title, textarea, .wide-action) { display: none !important; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open .managed-item,
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-item {
    grid-template-columns: minmax(0, 1fr) 44px 44px 44px !important;
    min-height: 64px !important;
    height: auto !important;
    gap: 4px !important;
    margin-top: 8px;
    padding: 8px !important;
  }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-icon { display: none !important; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-edit,
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-delete { width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; padding: 0 !important; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-switch {
    position: relative;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
  }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-switch::before {
    content: "";
    position: absolute;
    width: 34px;
    height: 20px;
    top: 12px;
    left: 5px;
    border-radius: 999px;
    background: #d8c3ac;
  }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-switch.is-active::before { background: #f58e75; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-switch::after {
    top: 16px !important;
    left: 9px !important;
    width: 12px !important;
    height: 12px !important;
    min-width: 12px !important;
    transform: none !important;
    background: #fff !important;
  }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-switch.is-active::after { transform: translateX(12px) !important; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open[data-active] .control-card .managed-placeholder { grid-template-columns: minmax(0, 1fr) auto !important; }
  body.control-open #appShell.xhaus-chat-home .lower-control-row.is-open .tab { min-height: 44px; padding: 8px; font-size: 13px; }
  #appShell.xhaus-chat-home .satellite-report-panel { min-width: 0 !important; padding: 12px !important; }
  #appShell.xhaus-chat-home .satellite-report-head { flex-wrap: wrap; gap: 8px !important; }
  #appShell.xhaus-chat-home .satellite-report-head > button { flex: 1 1 auto; min-height: 44px !important; white-space: normal; }

  #mobilePanel { position: fixed; z-index: 11000; display: flex; flex-direction: column; padding: 0 !important; font-family: var(--sample-font); }
  #mobilePanel[hidden], #mobilePanel [hidden] { display: none !important; }
  .mobile-panel-head { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 16px; border-bottom: 1px solid #eddcc5; }
  .mobile-panel-head button { min-height: 44px; padding: 0 8px; border: 0; border-radius: 12px; background: #f9ebd9; color: #8a593c; font-size: 13px; }
  .mobile-panel-head h2 { flex: 1; margin: 0; font-size: 17px; }
  .mobile-panel-head > span { color: #df997d; }
  .mobile-panel-content { flex: 1; min-height: 0; padding: 20px 16px; overflow-y: auto; overscroll-behavior-y: contain; }
  .mobile-panel-intro { margin: 0 0 18px; color: #9c765d; font-size: 14px; }
  .mobile-more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mobile-more-grid button { display: grid; justify-items: start; gap: 9px; padding: 18px 14px; border: 1px solid #e9d3b7; border-radius: 20px; background: linear-gradient(145deg, #fffdf8, #f9e8d0); color: #7c523b; text-align: left; box-shadow: inset 0 1px #fff; }
  .mobile-more-grid button > span { font-size: 25px; color: #c2855e; }
  .mobile-more-grid strong { font-size: 15px; }
  .mobile-more-grid small { color: #9e795f; font-size: 12px; line-height: 1.6; }
  .mobile-card-form { display: grid; gap: 14px; }
  .mobile-card-form label { font-size: 15px; font-weight: 650; }
  .mobile-card-form input { width: 100%; min-height: 48px; padding: 12px; border: 1px solid #d9b896; border-radius: 14px; background: #fffcf7; color: #795039; font-size: 16px; }
  .mobile-card-form p { margin: 0; color: #98745b; font-size: 13px; line-height: 1.8; }
  .mobile-primary { min-height: 48px; padding: 10px 16px; border: 0; border-radius: 15px; background: linear-gradient(120deg, #ee8d6e, #f5ae80); color: #fff; font-weight: 700; }
  .mobile-primary:disabled { opacity: .6; }
  .mobile-identity-code { display: block; padding: 18px; border: 1px dashed #dcb993; border-radius: 16px; background: #f8e9d5; color: #785035; font-size: 23px; letter-spacing: .08em; overflow-wrap: anywhere; user-select: all; }
  #mobilePanel .history-panel { position: static; max-height: none; padding: 0; border: 0; background: none; box-shadow: none; }
  #mobilePanel .history-item { min-width: 0; margin-bottom: 10px; padding: 10px; border: 1px solid #ead2b8; border-radius: 16px; background: #fffaf2; }
  #mobilePanel .history-item button { min-height: 44px; color: #875c42; }

  #fusionCanvas.fusion-canvas {
    top: var(--mobile-card-top) !important;
    left: max(12px, env(safe-area-inset-left, 0px)) !important;
    right: max(12px, env(safe-area-inset-right, 0px)) !important;
    bottom: auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: var(--mobile-card-height) !important;
    max-height: none !important;
    z-index: 11000 !important;
    background: linear-gradient(155deg, #fffdf7, #fff1df) !important;
  }
  #fusionCanvas .fusion-canvas-header { gap: 8px; padding: 12px 14px; }
  #fusionCanvas .fusion-canvas-actions { flex-shrink: 0; }
  #fusionCanvas .fusion-icon-button { width: auto; min-width: 72px; height: 44px; padding: 0 10px; font-size: 14px; }
  #fusionCanvas .fusion-zoom-label { display: none; }
  #fusionCanvas .fusion-graph { padding: 12px; overscroll-behavior: contain; }
  #fusionCanvas .fusion-workflow-card { min-width: 0; overflow-wrap: anywhere; }

  /* Nested editors and reports retain their own back button above the card. */
  body > .detail-overlay {
    top: var(--mobile-viewport-top, 0px) !important;
    height: var(--mobile-viewport-height, 100dvh) !important;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 10px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body > .detail-overlay .detail-modal,
  body > .detail-overlay .editor-modal {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 22px !important;
  }
  body > .detail-overlay .detail-head { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  body > .detail-overlay .detail-head h2 { font-size: 18px; overflow-wrap: anywhere; }
  body > .detail-overlay .detail-head .eyebrow { display: none; }
  body > .detail-overlay .detail-head button { min-height: 44px; padding: 8px 12px; }
  body > .detail-overlay .editor-actions { flex-wrap: wrap; gap: 6px; }
  body > .detail-overlay input,
  body > .detail-overlay textarea { font-size: 16px !important; }
  /* A document and its appearance settings share one sheet, without competing
     for height. The textarea remains mounted so tab changes retain the draft. */
  body > .detail-overlay .is-profile-editor .detail-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
  }
  body > .detail-overlay .is-profile-editor .detail-head > div:first-child { grid-area: 1 / 2; min-width: 0; }
  body > .detail-overlay .is-profile-editor .editor-actions { display: contents; }
  body > .detail-overlay .is-profile-editor #editorTitle,
  body > .detail-overlay .is-profile-editor #deleteEditorBtn { display: none; }
  body > .detail-overlay .is-profile-editor #closeEditorBtn { grid-area: 1 / 1; padding: 8px; }
  body > .detail-overlay .is-profile-editor #saveEditorBtn { grid-area: 1 / 3; padding: 8px 12px; }
  .is-profile-editor .mobile-profile-heading { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .mobile-profile-heading strong { font-size: 13px; color: #65442f; }
  .mobile-profile-heading span { font-size: 11px; color: #92745e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .is-profile-editor .mobile-profile-tabs { display: flex; flex: 0 0 auto; gap: 6px; padding: 8px 12px; border-bottom: 1px solid #eddfcf; background: #fff9ef; }
  .mobile-profile-tabs button { flex: 1; min-height: 44px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #876a55; font: inherit; font-size: 14px; cursor: pointer; }
  .mobile-profile-tabs button[aria-pressed="true"] { background: #f4e3ce; border-color: #e8cfb1; color: #62432f; font-weight: 700; }
  .mobile-profile-tabs button:focus-visible { outline: 2px solid #b68151; outline-offset: 2px; }
  body > .detail-overlay .is-profile-editor[data-mobile-profile-tab="content"] .profile-avatar-panel,
  body > .detail-overlay .is-profile-editor[data-mobile-profile-tab="appearance"] .editor-textarea { display: none !important; }
  body > .detail-overlay .editor-modal.is-profile-editor .profile-avatar-panel {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    align-content: start;
    overscroll-behavior: contain;
    scroll-padding: 16px;
    padding: 16px !important;
  }
  body > .detail-overlay .is-profile-editor .editor-textarea { padding: 16px !important; line-height: 1.75; overscroll-behavior: contain; }
  .is-profile-editor .mobile-profile-delete:not([hidden]) { display: block; justify-self: start; min-height: 44px; margin-top: 12px; }
  body.mobile-keyboard-open > .detail-overlay .is-profile-editor[data-mobile-profile-tab="content"] .mobile-profile-tabs { display: none; }
  body.mobile-keyboard-open > #editorOverlay { padding-top: calc(4px + env(safe-area-inset-top, 0px)) !important; padding-bottom: 4px !important; }
  body > .detail-overlay .profile-copy-grid { grid-template-columns: 1fr; }
  body > .detail-overlay .satellite-report-overlay-body { min-width: 0; padding: 14px; }
  body > .detail-overlay .satellite-change-card { grid-template-columns: minmax(0, 1fr) !important; }
  body > .detail-overlay .satellite-report-overlay-actions { flex-wrap: wrap; }
  .toast { max-width: calc(100vw - 32px); bottom: calc(var(--mobile-nav-height) + 12px); white-space: normal; overflow-wrap: anywhere; text-align: center; }

  body.mobile-keyboard-open:not(.mobile-card-open) { --mobile-nav-height: 8px; }
  body.mobile-keyboard-open:not(.mobile-card-open) #appShell.xhaus-chat-home > .mobile-nav { display: none; }
  body.mobile-keyboard-open #appShell.xhaus-chat-home .hero,
  body.mobile-keyboard-open #appShell.xhaus-chat-home .quick { display: none; }
  body.mobile-keyboard-open #appShell.xhaus-chat-home .chat { grid-template-rows: minmax(0, 1fr) auto; padding-top: 10px; }
}

@media (max-width: 1024px) and (max-height: 650px) {
  #landing .start-stage { min-height: 540px; padding-top: 20px; gap: 8px; grid-template-rows: auto minmax(120px, 1fr) 50px 44px; }
  .mobile-welcome-copy .mobile-welcome-eyebrow { margin-top: 18px; }
  .mobile-welcome-copy h1 { font-size: 27px; }
  .mobile-welcome-note { margin-bottom: 0; }
  #appShell.xhaus-chat-home .hero { min-height: 0; padding-bottom: 8px; }
  #appShell.xhaus-chat-home .hero p { display: none; }
  #appShell.xhaus-chat-home .quick { padding-bottom: 6px; }
}

@media (max-width: 1024px) and (orientation: landscape) {
  #landing .start-stage { min-height: 360px; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 50px 44px; padding: 24px max(24px, env(safe-area-inset-right, 0px)) 20px max(24px, env(safe-area-inset-left, 0px)); }
  #landing .start-stage::before { inset: 0 0 0 45%; background-position: 90% center; mask-image: linear-gradient(90deg, transparent, #000 15%); }
  .mobile-welcome-copy { grid-area: 1 / 1; }
  .mobile-welcome-copy h1 { font-size: 25px; line-height: 1.4; }
  .mobile-welcome-copy .mobile-welcome-eyebrow { margin: 12px 0 6px; }
  .mobile-welcome-copy > p:last-child { margin-top: 8px; }
  .mobile-welcome-note { display: none; }
  #landing .start-hotspot-primary { grid-area: 2 / 1; }
  #landing .start-hotspot-guide { grid-area: 3 / 1; }
  #appShell.xhaus-chat-home .hero,
  #appShell.xhaus-chat-home .quick { display: none; }
  #appShell.xhaus-chat-home .chat { grid-template-rows: minmax(0, 1fr) auto; padding-top: 10px; }
  body.control-open #appShell.xhaus-chat-home .runtime-panel.is-open .persona-choices { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (max-width: 1024px) and (prefers-reduced-motion: reduce) {
  #appShell.xhaus-chat-home .sample-dust,
  #appShell.xhaus-chat-home .orb { animation: none; }
  #fusionCanvas { transition: none; }
}
