/* Module-specific mobile geometry, loaded after legacy theme/layout rules. */
@media (min-width: 761px) and (max-width: 980px) and (min-height: 501px) {
    .app-shell .workspace-header { display: block; }
    .app-shell .header-title { display: none; }
    .app-shell .header-tools { width: 100%; min-width: 0; flex-wrap: wrap; }
    .app-shell .search-control { min-width: 0; flex: 1 1 140px; }
    .app-shell .header-home-button { display: none; }
    .settings-main { min-width: 0; padding: 16px; }
    .settings-grid { display: block; }
    .settings-nav { position: static; display: flex; overflow-x: auto; margin: 0 0 16px; }
    .settings-nav button { flex: 0 0 auto; min-height: 44px; }
    .model-use-card { flex-wrap: wrap; }
    .model-usage-panel { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px), (max-width: 980px) and (max-height: 500px) {
    :root { --mobile-nav-height: calc(64px + env(safe-area-inset-bottom, 0px)); }
    :root.mobile-keyboard-open { --mobile-nav-height: 0px; }
    body { min-width: 0; }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail {
        position: fixed; z-index: 60; inset: auto 0 0; top: auto;
        width: 100%; min-width: 0; height: var(--mobile-nav-height); min-height: 0;
        display: flex; flex-direction: row; align-items: center; justify-content: space-around;
        gap: 0; padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
        border-right: 0; border-top: 1px solid var(--line, var(--zy-border, #e1e5e4));
        background: var(--surface, var(--zy-surface, #fff)); overflow: visible; box-shadow: none;
    }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail .brand-mark { display: none; }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail :is(.rail-link, .rail-btn) {
        position: relative; display: grid; flex: 1 1 0; width: auto; height: 52px; min-width: 0;
        grid-template-rows: 24px 16px; align-content: center; place-items: center; gap: 2px;
        padding: 0; border-radius: 6px; font-size: 11px;
    }
    .laiya-product-rail :is(.rail-link, .rail-btn) svg { width: 21px; height: 21px; }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail :is(.rail-link, .rail-btn) span {
        position: static; display: block; min-width: 0; max-width: 100%; padding: 0;
        background: transparent; color: inherit; font-size: 11px; line-height: 16px;
        opacity: 1; visibility: visible; transform: none; white-space: nowrap;
    }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail .account-anchor { display: flex; flex: 1 1 0; justify-content: center; margin: 0; }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail :is(.account-button, .avatar-button) { width: 44px; height: 44px; padding: 0; }
    .laiya-product-rail :is(.account-button, .avatar-button) > span { width: 34px; height: 34px; }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail :is(.rail-link, .rail-btn).active::before { display: none; }
    :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail .account-popover { position: fixed; left: 12px; right: 12px; bottom: calc(var(--mobile-nav-height) + 8px); top: auto; width: auto; max-width: none; max-height: calc(var(--mobile-viewport-height, 100dvh) - var(--mobile-nav-height) - 24px); overflow-y: auto; }
    .laiya-product-rail .account-popover::before, .laiya-product-rail .account-popover::after { display: none; }
    .mobile-keyboard-open :is(.app-shell, .settings-shell, .zy-shell) .laiya-product-rail { display: none; }
    :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), textarea, select, [contenteditable="true"]) { font-size: 16px; }
    :is(.modal-overlay, .laiya-profile-overlay) { padding: 12px; }
    :is(.modal-card, .laiya-profile-modal) { max-height: calc(var(--mobile-viewport-height, 100dvh) - 24px); border-radius: 8px; }
    dialog { max-width: calc(100vw - 24px); max-height: calc(var(--mobile-viewport-height, 100dvh) - 24px); }
    :is(.app-shell, .settings-shell, .zy-shell) :is(.icon-button, .mini-icon-button, .popover-action) { min-height: 44px; min-width: 44px; }

    .app-shell { display: block; min-height: 100dvh; }
    .app-shell .workspace { min-width: 0; min-height: calc(100dvh - var(--mobile-nav-height)); padding-bottom: var(--mobile-nav-height); }
    .app-shell .workspace-header { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px; align-items: center; padding: 8px 12px; }
    .app-shell .header-title { min-width: 0; align-self: start; }
    .app-shell .mobile-menu-button { display: grid; width: 44px; height: 44px; }
    .app-shell .header-tools { display: grid; width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr) 44px; gap: 4px; }
    .app-shell .search-control { height: 44px; width: 100%; min-width: 0; border-radius: 6px; }
    .app-shell .search-control { grid-column: 1; grid-row: 1; }
    .app-shell #viewToggle { grid-column: 2; grid-row: 1; }
    .app-shell .search-control input { min-width: 0; width: 100%; font-size: 16px; }
    .app-shell .header-home-button { display: none; }
    .app-shell .select-control { display: flex; grid-column: 1 / -1; grid-row: 2; width: max-content; max-width: 100%; height: 40px; min-height: 40px; border: 0; background: transparent; }
    .app-shell .select-control select { font-size: 14px; }
    .app-shell .sidebar { position: fixed; z-index: 65; inset: var(--mobile-viewport-top, 0px) auto auto 0; height: var(--mobile-viewport-height, 100dvh); width: min(320px, calc(100vw - 40px)); transform: translateX(-105%); overflow-y: auto; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    body.sidebar-open .app-shell .sidebar { transform: none; }
    .sidebar-scrim { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 64; display: block; }
    .sidebar-scrim[hidden] { display: none; }
    .app-shell .sidebar-close { display: grid !important; }
    .app-shell .empty-state { min-height: min(480px, calc(var(--mobile-viewport-height, 100dvh) - 180px)); padding: 32px 8px; }
    .app-shell .empty-visual { width: 64px; height: 64px; border-radius: 8px; box-shadow: none; }
    .app-shell .empty-state h3 { font-size: 20px; }
    .app-shell .empty-state p { font-size: 14px; line-height: 1.6; }
    .app-shell .empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
    .app-shell .file-card { border-radius: 8px; }

    .settings-shell { display: block; }
    .settings-main { min-width: 0; padding: 16px 12px calc(var(--mobile-nav-height) + 16px); }
    .settings-grid { display: block; }
    .settings-nav { position: static; display: flex; flex-wrap: nowrap; overflow-x: auto; margin-bottom: 16px; gap: 0; }
    .settings-nav button { min-height: 44px; padding: 0 10px; font-size: 13px; flex: 0 0 auto; }
    .settings-card { min-width: 0; padding: 14px; border-radius: 8px; }
    .model-use-card { flex-direction: column; align-items: stretch; }
    .default-model-picker, .default-model-chip, .default-model-menu { max-width: 100%; min-width: 0; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .provider-model-header { display: none; }
    .provider-model-row { grid-template-columns: minmax(0, 1fr) 44px; padding-block: 8px; border-bottom: 1px solid var(--line, #e1e5e4); }
    .provider-model-row > input { grid-column: 1; height: 44px; font-size: 16px; }
    .provider-model-row > button { grid-column: 2; grid-row: 1 / span 2; width: 44px; height: 44px; }
    .capability-checks { grid-column: 1 / -1; border: 0; padding: 0; }
    .capability-checks label { min-height: 44px; }
    .models-heading, .provider-form-actions { flex-wrap: wrap; gap: 8px; }
    .models-heading > div, .provider-form-actions > div { min-width: 0; flex-wrap: wrap; }
    .provider-form-actions button, .model-tabs button { min-height: 44px; }
    .usage-range-tabs { flex-wrap: wrap; }
    .usage-summary-grid { grid-template-columns: minmax(0, 1fr); }
    .model-usage-panel { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .usage-model-row { grid-template-columns: 5px minmax(0, 1fr) auto; gap: 8px; font-size: 12px; }
    .usage-model-row span:nth-last-child(-n+2) { grid-column: 2 / -1; }
    .usage-custom-range { flex-wrap: wrap; }

    .zy-shell, .zy-shell.explorer-collapsed { display: block; }
    .zy-main { height: var(--mobile-viewport-height, 100dvh); padding-bottom: var(--mobile-nav-height); min-width: 0; }
    .zy-explorer { left: 0; top: var(--mobile-viewport-top, 0px); height: var(--mobile-viewport-height, 100dvh); width: min(320px, calc(100vw - 40px)); z-index: 65; }
    .explorer-launcher { top: 12px; left: 12px; width: 44px; height: 44px; }
    .browser-view { padding: 16px 12px 24px; }
    .base-overview { min-height: 68px; padding-left: 52px; gap: 12px; }
    .base-overview-avatar { width: 40px; height: 40px; border-radius: 6px; }
    .base-overview h1 { font-size: 20px; }
    .content-pathbar { min-width: 0; gap: 0; }
    .content-path-controls { flex-shrink: 0; }
    .content-pathbar .breadcrumb { display: flex; flex: 1; min-width: 0; overflow-x: auto; }
    .content-pathbar .breadcrumb button { max-width: 100px; }
    #browserForwardButton { display: none; }
    .content-toolbar { flex-shrink: 0; gap: 0; }
    .content-collection .document-card, .content-collection .folder-card { grid-template-columns: 28px minmax(0, 1fr) 44px; gap: 8px; }
    .content-collection :is(.document-card, .folder-card) time, .content-row-kind, .content-row-size { display: none; }
    .content-collection :is(.document-card, .folder-card) .card-menu { grid-column: 3; width: 44px; height: 44px; opacity: 1; }
    .document-header { display: grid; grid-template-columns: 44px minmax(0, 1fr); padding: 8px 12px; gap: 4px; }
    .document-header .document-identity { min-width: 0; }
    .document-title-input { max-width: 100%; min-width: 0; font-size: 16px; }
    .document-header-actions { grid-column: 1 / -1; display: flex; width: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; gap: 0; padding-bottom: 2px; }
    .document-header-actions > * { flex-shrink: 0; }
    .document-header-actions .mode-switch button { min-height: 44px; }
    .document-header-actions .save-status { display: none; }
    .document-header-actions #askDocumentButton:not([hidden]) { display: inline-flex; width: 44px; height: 44px; padding: 0; justify-content: center; }
    .document-header-actions #askDocumentButton span { display: none; }
    .document-workspace { height: 100%; padding-bottom: 0; }
    .document-stage.assistant-open .document-assistant-panel { bottom: 0; }
    .document-assistant-input, .document-assistant-composer textarea { font-size: 16px; }
    .markdown-reader, .markdown-preview { padding: 20px 16px; overflow-wrap: anywhere; }
    .markdown-reader table, .markdown-preview table { display: block; max-width: 100%; overflow-x: auto; }
    .split-editor { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr); }
    .document-font-control, .document-zoom-controls { display: none; }
    .zy-dialog footer { flex-wrap: wrap; gap: 8px; }
    .zy-dialog footer button, .command-actions button { min-height: 44px; }
    .zy-dialog .dialog-body { min-width: 0; }
    .zy-dialog input, .zy-dialog textarea, .zy-dialog select { font-size: 16px; }
}
@media (max-width: 360px) {
    .settings-nav button { padding-inline: 6px; }
    .content-pathbar .breadcrumb { display: none; }
}
@media (max-width: 760px) and (pointer: fine) {
    .toolbar-topbar { grid-template-columns: minmax(0, 1fr); height: auto; gap: 4px; }
    .toolbar { height: 154px; grid-template-rows: 96px 58px; }
    .document-nav { min-height: 44px; }
    .ribbon-tabs { position: absolute; top: 48px; left: 8px; }
    .persistent-view-tools { position: absolute; right: 8px; top: 8px; max-width: 50%; overflow-x: auto; }
    .canvas-container { top: 154px; }
}
@media (pointer: coarse) {
    body.touch-canvas-capable .mobile-canvas-toolbar { grid-template-columns: repeat(7, minmax(0, 1fr)); border-radius: 8px; }
    body.touch-canvas-capable .mobile-canvas-toolbar button { min-width: 0; }
    body.touch-canvas-capable .toolbar-topbar { grid-template-columns: minmax(80px, 1fr) auto 44px; }
    body.touch-canvas-capable .ribbon-tab { min-width: 40px; padding-inline: 4px; }
    body.touch-canvas-capable .document-copy strong { max-width: 100%; }
    body.touch-canvas-capable .properties-panel { max-height: calc(var(--mobile-viewport-height, 100dvh) - 150px); border-radius: 8px; }
    body.touch-canvas-capable .tool-drawer { max-height: calc(var(--mobile-viewport-height, 100dvh) - 138px); }
    body.touch-canvas-capable :is(.property-group input:not([type="color"]), .property-group textarea, .property-group select) { font-size: 16px; }
}
