/* Mobile refinements for recipes, plant discovery and guild workflows.
   Every layout override is deliberately scoped to phone-sized or compact
   coarse-pointer viewports so the existing desktop workspaces stay intact. */

[data-mobile-disclosure-toggle],
[data-mobile-canvas-toggle],
[data-mobile-sheet-close],
.mobile-sheet-backdrop,
details[data-mobile-details] > summary {
    display: none;
}

@media (max-width: 767.98px),
       (hover: none) and (pointer: coarse) and (max-height: 520px) {
    :root {
        --mobile-content-gap: 12px;
        --mobile-content-target: 44px;
        --mobile-content-sheet-max: min(78dvh, 640px);
    }

    body.mobile-content-sheet-open { overflow: hidden; }

    :is(
        .recipe-library-page,
        .recipe-form-page,
        .recipe-detail-page,
        .public-recipe-page,
        .recipe-wizard-page,
        .recipe-workspace-page,
        .plant-library-page,
        .plant-search-page,
        .plant-record-page,
        .guild-explorer-page
    ) {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
        overflow-x: clip;
    }

    :is(
        .recipe-library-page,
        .recipe-form-page,
        .recipe-detail-page,
        .public-recipe-page,
        .recipe-wizard-page,
        .recipe-workspace-page,
        .plant-library-page,
        .plant-search-page,
        .plant-record-page,
        .guild-explorer-page
    ) :is(button, .btn, a.btn, summary, .form-check-label) {
        min-height: var(--mobile-content-target);
    }

    :is(
        .recipe-library-page,
        .recipe-form-page,
        .recipe-detail-page,
        .public-recipe-page,
        .recipe-wizard-page,
        .recipe-workspace-page,
        .plant-library-page,
        .plant-search-page,
        .plant-record-page,
        .guild-explorer-page,
        .sharing-modal,
        .guild-wizard-modal,
        #plantGuildModal,
        #pdfExportModal,
        #plantDetailsModal
    ) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea, .form-control, .form-select, .ts-control) {
        font-size: 16px !important;
    }

    :is(
        .recipe-library-page,
        .recipe-form-page,
        .public-recipe-page,
        .plant-search-page
    ) .app-page-hero-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    :is(
        .recipe-library-page,
        .recipe-form-page,
        .public-recipe-page,
        .plant-search-page
    ) .app-page-hero-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Native progressive disclosure. Panels remain visible if JavaScript fails. */
    [data-mobile-disclosure-toggle]:not([hidden]) {
        display: inline-flex;
        min-width: 0;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    [data-mobile-disclosure-panel][hidden] { display: none !important; }

    details[data-mobile-details] > summary {
        display: flex;
        min-height: var(--mobile-content-target);
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
        border-top: 1px solid var(--app-page-line);
        color: var(--app-page-green-dark);
        cursor: pointer;
        font-size: .78rem;
        font-weight: 720;
        list-style: none;
    }

    details[data-mobile-details] > summary::-webkit-details-marker { display: none; }
    details[data-mobile-details] > summary::after {
        content: '\F282';
        font-family: 'bootstrap-icons';
        transition: transform .18s ease;
    }
    details[data-mobile-details][open] > summary::after { transform: rotate(180deg); }

    .mobile-plant-facts > .plant-details { padding-top: 12px; }
    .mobile-plant-facts > .plant-details > [class*="col-"] {
        width: 100%;
        flex: 0 0 100%;
    }

    /* Diagram guard: vertical page scrolling wins until interaction is explicit. */
    [data-mobile-canvas-guard] { position: relative; }
    [data-mobile-canvas-toggle]:not([hidden]) {
        position: absolute;
        top: 64px;
        right: 10px;
        z-index: 8;
        display: inline-flex;
        min-height: var(--mobile-content-target);
        align-items: center;
        gap: 7px;
        padding: 8px 11px;
        border: 1px solid var(--app-page-line);
        border-radius: 10px;
        background: color-mix(in srgb, var(--app-page-surface) 94%, transparent);
        color: var(--app-page-green-dark);
        box-shadow: 0 8px 22px rgba(18, 55, 34, .14);
        backdrop-filter: blur(10px);
        font-size: .72rem;
        font-weight: 720;
    }
    [data-mobile-canvas-guard].is-mobile-canvas-interacting [data-mobile-canvas-toggle] {
        border-color: var(--app-page-green);
        background: var(--app-page-green);
        color: #fff;
    }
    [data-mobile-canvas-guard] [data-mobile-canvas-surface] {
        touch-action: pan-y pinch-zoom !important;
    }
    [data-mobile-canvas-guard].is-mobile-canvas-interacting [data-mobile-canvas-surface] {
        touch-action: none !important;
    }

    /* Accessible mobile detail sheet used by the Guild Explorer. */
    [data-mobile-sheet] > [data-mobile-sheet-close]:not([hidden]) {
        position: sticky;
        top: 0;
        z-index: 2;
        display: flex;
        width: 100%;
        min-height: 48px;
        align-items: center;
        justify-content: center;
        gap: 7px;
        margin: -1rem -1rem 12px;
        width: calc(100% + 2rem);
        border: 0;
        border-bottom: 1px solid var(--app-page-line);
        border-radius: 0;
        background: var(--app-page-surface);
        color: var(--app-page-green-dark);
        font-size: .76rem;
        font-weight: 720;
    }
    .mobile-sheet-backdrop:not([hidden]) {
        position: fixed;
        inset: 0;
        z-index: 1075;
        display: block;
        background: rgba(9, 24, 15, .48);
        backdrop-filter: blur(2px);
    }
    [data-mobile-sheet] {
        position: fixed !important;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1080;
        max-height: var(--mobile-content-sheet-max) !important;
        margin: 0 !important;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)) !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -24px 60px rgba(9, 24, 15, .24) !important;
        transform: translateY(calc(100% + 24px));
        visibility: hidden;
        transition: transform .2s ease, visibility 0s linear .2s;
    }
    [data-mobile-sheet].is-mobile-open {
        visibility: visible;
        transform: translateY(0);
        transition-delay: 0s;
    }

    /* Recipe overview and sharing. */
    .recipe-library-page .recipe-library-hero { padding: 24px 18px; }
    .recipe-library-page .recipe-library-toolbar { gap: 10px; padding-inline: 0; }
    .recipe-library-page .recipe-library-toolbar > *,
    .recipe-library-page .recipe-library-toolbar > .d-flex { width: 100%; }
    .recipe-library-page .recipe-library-toolbar > .d-flex { justify-content: space-between; }
    .recipe-library-page .recipe-view-toggle { display: none !important; }
    .recipe-library-page .recipe-card-main { padding: 20px 18px; }
    .recipe-library-page .recipe-card-main > p { margin-bottom: 16px; }
    .recipe-library-page .recipe-card-footer {
        align-items: flex-start;
        padding: 12px 12px 12px 18px;
        flex-direction: column;
    }
    .recipe-library-page .recipe-card-actions { width: 100%; gap: 6px; }
    .recipe-library-page .recipe-card-actions :is(a, button) {
        min-width: var(--mobile-content-target);
        height: var(--mobile-content-target);
        flex: 1 1 0;
    }
    .recipe-library-page .recipe-share-action { font-size: .72rem; }
    .recipe-library-page .recipe-frozen-section,
    .recipe-library-page .recipe-empty-state { padding: 22px 18px; }
    .recipe-library-page .recipe-upgrade-note .btn { width: 100%; }

    .sharing-modal .modal-dialog,
    .recipe-detail-page + .modal .modal-dialog,
    #shareRecipeModal .modal-dialog,
    #cultivarDetailsModal .modal-dialog {
        width: auto;
        height: calc(100dvh - 12px);
        max-width: none;
        margin: 6px;
    }
    .sharing-modal .modal-content,
    #shareRecipeModal .modal-content,
    #cultivarDetailsModal .modal-content { max-height: 100%; border-radius: 16px; }
    .sharing-modal .sharing-form-section { padding: 13px; }
    .sharing-modal :is(button, .btn, .sharing-switch) { min-height: var(--mobile-content-target); }
    .sharing-modal .recipe-existing-share > div:last-child { align-items: stretch; flex-direction: column; }
    .sharing-modal .recipe-existing-share .btn { width: 100%; justify-content: center; }
    .sharing-modal .modal-footer {
        align-items: stretch;
        padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
        flex-direction: column-reverse;
    }
    .sharing-modal .modal-footer .btn { width: 100%; }

    /* Recipe create/edit. */
    .recipe-form-page .recipe-form-hero { padding: 24px 18px; }
    .recipe-form-page .recipe-form-main { padding: 18px 16px; }
    .recipe-form-page .recipe-form-section-heading { padding-bottom: 16px; }
    .recipe-form-page .recipe-share-buttons .btn { min-height: var(--mobile-content-target); }
    .recipe-form-page .recipe-share-option { min-height: 54px; }
    .recipe-form-page .recipe-share-status.is-error { color: var(--bs-danger-text-emphasis, #842029); }
    .recipe-form-page .recipe-form-actions {
        position: sticky;
        bottom: 0;
        z-index: 4;
        margin: 26px -16px -18px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--app-page-line);
        background: color-mix(in srgb, var(--app-page-surface) 94%, transparent);
        box-shadow: 0 -10px 24px rgba(18, 55, 34, .07);
        backdrop-filter: blur(12px);
    }

    /* Recipe detail workspace. */
    .recipe-detail-page .recipe-header { padding: 22px 16px; }
    .recipe-detail-page .recipe-title,
    .recipe-detail-page .recipe-description { overflow-wrap: anywhere; }
    .recipe-detail-page .recipe-menu { margin-inline: -5px; padding: 5px; scrollbar-width: none; }
    .recipe-detail-page .recipe-menu::-webkit-scrollbar { display: none; }
    .recipe-detail-page .recipe-menu .nav { flex-wrap: nowrap; }
    .recipe-detail-page .recipe-menu .nav-link { min-height: var(--mobile-content-target); padding: 9px 11px; scroll-snap-align: start; }
    .recipe-detail-page .recipe-detail-content > .alert { align-items: flex-start !important; flex-direction: column; }
    .recipe-detail-page .recipe-detail-content > .alert .btn,
    .recipe-detail-page .recipe-detail-content > .alert .alert-link { width: 100%; margin-left: 0 !important; }
    .recipe-detail-page .plant-card .card-body { padding: 17px 15px; }
    .recipe-detail-page .remove-plant-from-recipe {
        width: var(--mobile-content-target) !important;
        height: var(--mobile-content-target) !important;
        flex-basis: var(--mobile-content-target) !important;
    }
    .recipe-detail-page .plant-card .card-footer .btn { min-height: 48px; }
    .recipe-detail-page .cultivar-list .form-check { min-height: var(--mobile-content-target); }
    .recipe-detail-page .cultivar-list .form-check-input { width: 1.25rem; height: 1.25rem; }
    .recipe-detail-page .action-buttons .btn { width: 100%; margin: 0; justify-content: center; }
    #shareRecipeModal .input-group { align-items: stretch; flex-direction: column; }
    #shareRecipeModal .input-group > * { width: 100%; min-height: var(--mobile-content-target); border-radius: 9px !important; }
    #shareRecipeModal .input-group > * + * { margin-top: 7px; }
    #shareRecipeModal .modal-footer { align-items: stretch; flex-direction: column-reverse; }
    #shareRecipeModal .modal-footer .btn { width: 100%; }

    /* Public recipe library and AI wizard. */
    .public-recipe-page .public-recipe-toolbar { align-items: stretch; flex-direction: column; }
    .public-recipe-page .public-recipe-search,
    .public-recipe-page .public-filter-toggle { width: 100%; }
    .public-recipe-page .public-filter-tag,
    .public-recipe-page [data-filter-value] { min-height: var(--mobile-content-target); }
    .public-recipe-page .public-filter-heading { align-items: flex-start; flex-direction: column; }
    .public-recipe-page .public-filter-heading button { min-height: var(--mobile-content-target); }
    .public-recipe-page .public-recipe-card-actions { align-items: stretch; flex-direction: column; }
    .public-recipe-page .public-recipe-card-actions .btn { width: 100%; }

    .recipe-wizard-page .recipe-wizard-shell { overflow: visible; }
    .recipe-wizard-page .recipe-wizard-shell-header { align-items: flex-start; flex-direction: column; }
    .recipe-wizard-page .recipe-wizard-stepper { position: sticky; top: var(--topbar-height); z-index: 3; }
    .recipe-wizard-page .wizard-navigation {
        position: sticky;
        bottom: 0;
        z-index: 4;
        margin-inline: -16px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--app-page-surface) 95%, transparent);
        box-shadow: 0 -10px 24px rgba(18, 55, 34, .08);
        backdrop-filter: blur(12px);
    }
    .recipe-wizard-page .wizard-navigation .btn { min-height: 48px; }

    /* Plant catalogue. */
    .plant-library-page .plant-library-search { margin-bottom: 14px !important; }
    .plant-library-page .plant-library-heading .d-flex > .d-flex { width: 100%; }
    .plant-library-page .plant-library-heading .d-flex > .d-flex .btn { flex: 1; }
    .plant-library-page .search-info { display: flex !important; align-items: flex-start; flex-direction: column; }
    .plant-library-page #plantResultCount { display: block; }
    .plant-library-page .layer-nav-sticky {
        top: calc(var(--topbar-height) + env(safe-area-inset-top)) !important;
        padding-block: 6px !important;
    }
    .plant-library-page .layer-nav-link { min-height: var(--mobile-content-target); padding: 9px 12px; }
    .plant-library-page .plant-link { min-height: 104px; }
    .plant-library-page .plant-scientific-name { font-size: .95rem; }
    .plant-library-page .plant-common-name { font-size: .8rem; }
    .common-name-language-selector :is(.btn, .form-select) { min-height: var(--mobile-content-target) !important; font-size: 16px !important; }

    /* Advanced plant search and recipe workbench. */
    .plant-search-page .plant-search-hero { padding: 24px 18px; }
    .plant-search-page .plant-filter-panel > .card-header { align-items: flex-start; padding: 15px 16px; }
    .plant-search-page .mobile-filter-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
    .plant-search-page [data-mobile-disclosure-toggle] { padding: 8px 10px; border: 1px solid var(--app-page-line); border-radius: 9px; background: var(--app-page-surface); color: var(--app-page-green-dark); font-size: .72rem; font-weight: 700; }
    .plant-search-page .filter-reset { min-height: var(--mobile-content-target); padding: 8px; }
    .plant-search-page .plant-filter-panel > .card-body { padding: 16px; }
    .plant-search-page .search-form .row { --bs-gutter-x: 0; }
    .plant-search-page .search-form [class*="col-md-"] { padding-inline: 0; }
    .plant-search-page .search-form .btn-success { min-height: 48px; }
    .plant-search-page .recipe-workbench,
    .plant-search-page .recipe-workbench.sticky { position: static; top: auto; }
    .plant-search-page .recipe-workbench > .card-body { padding: 16px; }
    .plant-search-page .recipe-workbench .input-group { display: grid; grid-template-columns: 1fr; gap: 8px; }
    .plant-search-page .recipe-workbench .input-group > * { width: 100%; border-radius: 9px !important; }
    .plant-search-page .recipe-workbench .btn-group {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }
    .plant-search-page .recipe-workbench .btn-group .btn { min-width: 0; margin: 0; padding-inline: 5px; border-radius: 9px !important; }
    .plant-search-page #activeRecipeContext > .d-flex { width: 100%; }
    .plant-search-page #activeRecipeContext .btn { flex: 1; }
    .plant-search-page .plant-search-results-header { align-items: flex-start; margin-top: 30px; }
    .plant-search-page .plant-card > .card-body { padding: 16px 14px; }
    .plant-search-page .card-layer-bar > .d-flex { align-items: flex-start !important; gap: 8px; flex-wrap: wrap; }
    .plant-search-page .recipe-toggle-label { min-height: var(--mobile-content-target); display: inline-flex; align-items: center; }
    .plant-search-page .plant-card .card-footer .btn { min-height: 48px; }
    .plant-search-page .cultivar-badge { display: inline-flex; min-height: 36px; align-items: center; padding: 7px 9px; }
    .plant-search-page .modal-dialog,
    .plant-search-page #plantGuildModal .modal-dialog {
        width: auto;
        height: calc(100dvh - 12px);
        max-width: none;
        margin: 6px;
    }
    .plant-search-page .modal-content { max-height: 100%; border-radius: 16px; }
    #plantGuildModal .modal-body { overflow-y: auto; overscroll-behavior: contain; }
    #plantGuildModal .plant-guild-canvas { height: min(44dvh, 380px); min-height: 290px; }
    #plantGuildModal .plant-guild-info { min-height: 0; max-height: none; padding: 1rem; }
    #plantGuildModal [data-mobile-canvas-toggle] { top: 10px; }

    /* Guild Explorer. */
    .guild-explorer-page { padding-inline: 12px; }
    .guild-explorer-page .guild-explorer-hero { gap: 1rem; padding: 20px 16px; border-radius: 17px; }
    .guild-explorer-page .guild-explorer-hero h1 { font-size: clamp(1.8rem, 10vw, 2.35rem); }
    .guild-explorer-page .guild-wizard-launch { width: 100%; min-height: 52px; justify-content: flex-start; }
    .guild-explorer-page .guild-hero-stats { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
    .guild-explorer-page .guild-hero-stats span { min-width: 0; padding: .55rem .25rem; }
    .guild-explorer-page .guild-explorer-controls { padding: .65rem; }
    .guild-explorer-page .guild-mobile-filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .guild-explorer-page .guild-mobile-filter-heading > span { color: var(--guild-ink); font-size: .82rem; font-weight: 720; }
    .guild-explorer-page [data-mobile-disclosure-toggle] { padding: 8px 11px; border: 1px solid #d6e2d8; border-radius: 10px; background: #fff; color: #24633b; font-size: .72rem; font-weight: 700; }
    .guild-explorer-page .guild-mobile-filter-panel { padding-top: .7rem; }
    .guild-explorer-page .guild-control-row > * { min-height: var(--mobile-content-target); }
    .guild-explorer-page .guild-search-control input,
    .guild-explorer-page .guild-select-control select { min-height: var(--mobile-content-target); }
    .guild-explorer-page .guild-check-control span { min-height: var(--mobile-content-target); }
    .guild-explorer-page .guild-main-terrain summary { min-height: var(--mobile-content-target); }
    .guild-explorer-page .guild-main-terrain-grid { grid-template-columns: 1fr; }
    .guild-explorer-page .guild-main-terrain-grid .form-select,
    .guild-explorer-page .guild-main-terrain-check { min-height: var(--mobile-content-target); }
    .guild-explorer-page .guild-layer-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 5px; scroll-snap-type: x proximity; scrollbar-width: none; }
    .guild-explorer-page .guild-layer-filters::-webkit-scrollbar { display: none; }
    .guild-explorer-page .guild-layer-chip { min-height: var(--mobile-content-target); flex: 0 0 auto; scroll-snap-align: start; }
    .guild-explorer-page .guild-discovery-item { min-height: var(--mobile-content-target); }
    .guild-explorer-page .guild-canvas-toolbar { align-items: flex-start; gap: 8px; flex-direction: column; }
    .guild-explorer-page .guild-canvas-toolbar > .d-flex { width: 100%; justify-content: space-between; }
    .guild-explorer-page .guild-canvas-toolbar .btn { min-width: var(--mobile-content-target); min-height: var(--mobile-content-target); }
    .guild-explorer-page .guild-explorer-canvas { height: min(50dvh, 420px); min-height: 330px; }
    .guild-explorer-page [data-mobile-canvas-toggle] { top: 62px; }
    .guild-explorer-page .guild-explorer-sidebar { display: flex; flex-direction: column; }
    .guild-explorer-page .guild-recipe-builder { order: 1; }
    .guild-explorer-page .guild-selection-card { order: 2; }
    .guild-explorer-page .guild-selection-item button { min-width: var(--mobile-content-target); min-height: var(--mobile-content-target); }

    .guild-wizard-modal .modal-dialog {
        width: 100%;
        height: 100dvh;
        max-width: none;
        margin: 0;
    }
    .guild-wizard-modal .modal-content { height: 100%; max-height: 100%; border-radius: 0; }
    .guild-wizard-modal .modal-header { flex: 0 0 auto; padding-top: calc(.85rem + env(safe-area-inset-top)); }
    .guild-wizard-modal .guild-wizard-progress { position: sticky; top: 0; z-index: 3; padding: .65rem .55rem; }
    .guild-wizard-modal .guild-wizard-progress strong { width: 29px; height: 29px; }
    .guild-wizard-modal #guildWizardBody { min-height: 0; padding: 1rem; overflow-y: auto; overscroll-behavior: contain; }
    .guild-wizard-modal .guild-wizard-option { min-height: 88px; }
    .guild-wizard-modal .guild-wizard-footer { position: sticky; bottom: 0; z-index: 3; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
    .guild-wizard-modal .guild-wizard-footer > div { width: 100%; margin-left: 0 !important; }
    .guild-wizard-modal .guild-wizard-footer .btn { min-height: 48px; flex: 1; }

    /* Recipe guild list becomes a readable card list on phones. */
    .recipe-guilds-page .recipe-guild-index > summary { padding: 12px 14px; }
    .recipe-guilds-page .recipe-guild-index .sidebar-header { display: none; }
    .recipe-guilds-page .recipe-guild-index .sidebar-content { padding: 8px; }
    .recipe-guilds-page .plant-nav-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
    .recipe-guilds-page .plant-nav-list li { flex: 0 0 min(78vw, 280px); margin: 0; }
    .recipe-guilds-page .plant-nav-link { min-height: 52px; }
    .recipe-guilds-page .plant-guild-card .card-header,
    .recipe-guilds-page .plant-guild-card .card-body { padding: 14px; }
    .recipe-guilds-page .plant-title-clickable { min-height: var(--mobile-content-target); padding: 4px 0; border: 0; background: transparent; text-align: left; }
    .recipe-guilds-page .table-responsive { overflow: visible; }
    .recipe-guilds-page table,
    .recipe-guilds-page tbody,
    .recipe-guilds-page tr,
    .recipe-guilds-page td { display: block; width: 100%; }
    .recipe-guilds-page thead { display: none; }
    .recipe-guilds-page .guild-row { margin-bottom: 10px; padding: 12px; border: 1px solid var(--app-page-line); border-radius: 11px; background: var(--app-page-canvas); }
    .recipe-guilds-page .guild-row:last-child { margin-bottom: 0; }
    .recipe-guilds-page .guild-row td { display: grid; grid-template-columns: minmax(86px, 30%) minmax(0, 1fr); gap: 10px; padding: 8px 0; border: 0; text-align: left; }
    .recipe-guilds-page .guild-row td::before { content: attr(data-label); color: var(--app-page-muted); font-size: .68rem; font-weight: 720; text-transform: uppercase; }
    .recipe-guilds-page .guild-row .action-cell { align-items: center; }
    .recipe-guilds-page .guild-row .action-cell .btn { width: 100%; min-height: var(--mobile-content-target); }

    /* Full recipe guild diagram and plant-detail diagrams. */
    .recipe-diagram-page .diagram-hero { padding: 18px 15px; }
    .recipe-diagram-page .diagram-actions { width: 100%; }
    .recipe-diagram-page .diagram-actions .btn { flex: 1; }
    .recipe-diagram-page .diagram-tip { font-size: .75rem; }
    .recipe-diagram-page #guild-canvas-container { min-height: 0; height: min(50dvh, 420px); }
    .recipe-diagram-page [data-mobile-canvas-toggle] { top: 10px; }
    .recipe-diagram-page .info-panel { width: 100%; max-height: none; }
    .recipe-diagram-page .info-panel-content { max-height: none; }
    #pdfExportModal :is(button, .btn, .form-check-label),
    #plantDetailsModal :is(button, .btn) { min-height: var(--mobile-content-target); }
    #pdfExportModal .modal-dialog,
    #plantDetailsModal .modal-dialog { max-width: none; margin: 0; }
    #pdfExportModal .modal-footer { align-items: stretch; flex-direction: column-reverse; padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
    #pdfExportModal .modal-footer .btn { width: 100%; }

    .plant-record-page .detail-item { grid-template-columns: 1fr; gap: 4px; }

    .toast-container {
        right: 8px !important;
        bottom: calc(8px + env(safe-area-inset-bottom)) !important;
        left: 8px !important;
        padding: 0 !important;
    }
    .toast-container .toast { width: 100%; }
}

@media (hover: none) and (pointer: coarse) and (max-height: 520px) {
    .guild-explorer-page .guild-explorer-hero p,
    .recipe-diagram-page .diagram-tip span { display: none; }
    .guild-explorer-page .guild-explorer-canvas,
    .recipe-diagram-page #guild-canvas-container,
    #plantGuildModal .plant-guild-canvas { height: min(62dvh, 270px); min-height: 230px; }
    .guild-wizard-modal .modal-header { padding-block: .55rem; }
    .guild-wizard-modal .guild-wizard-eyebrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    :is(
        .recipe-library-page,
        .recipe-form-page,
        .recipe-detail-page,
        .public-recipe-page,
        .recipe-wizard-page,
        .recipe-workspace-page,
        .plant-library-page,
        .plant-search-page,
        .plant-record-page,
        .guild-explorer-page,
        [data-mobile-sheet]
    ) *,
    :is(
        .recipe-library-page,
        .recipe-form-page,
        .recipe-detail-page,
        .public-recipe-page,
        .recipe-wizard-page,
        .recipe-workspace-page,
        .plant-library-page,
        .plant-search-page,
        .plant-record-page,
        .guild-explorer-page,
        [data-mobile-sheet]
    ) *::before,
    :is(
        .recipe-library-page,
        .recipe-form-page,
        .recipe-detail-page,
        .public-recipe-page,
        .recipe-wizard-page,
        .recipe-workspace-page,
        .plant-library-page,
        .plant-search-page,
        .plant-record-page,
        .guild-explorer-page,
        [data-mobile-sheet]
    ) *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
