/* Phase 2A: nothing visible changes until JS confirms an installed phone PWA.
   The sentinel also keeps the original navigation if this stylesheet fails. */
:root { --gi-pwa-ui-ready: 1; }
.pwa-ui-shell[hidden], .pwa-header-actions[hidden] { display: none !important; }
.pwa-sheet:not([open]) { display: none; }

/* With disabled or failed menu JS, expose the existing links instead of a dead
   toggle. With working JS this rule never changes the normal browser layout. */
@media (max-width: 900px) {
    html:not(.pwa-mobile-app) .main-nav:not(.is-enhanced) .main-nav-menu { display: flex; flex-direction: column; position: static; max-height: none; overflow: visible; padding: 0; }
    html:not(.pwa-mobile-app) .main-nav:not(.is-enhanced) .mobile-nav-toggle { display: none; }
}

@media (max-width: 1000px) {
    /* The native Android buttons are browser/OS UI. Signal a light surface to
       match the unchanged white bottom bar and its existing safe-area padding.
       Do not opt into viewport-fit=cover or move/resize the app controls. */
    html.pwa-mobile-app { --gi-pwa-nav-height: 80px; scroll-padding-bottom: calc(var(--gi-pwa-nav-height) + 20px); color-scheme: light; color-scheme: only light; background-color: #fff; }
    html.pwa-mobile-app body { padding-bottom: var(--gi-pwa-nav-height); }
    html.pwa-mobile-app .main-nav { display: none; }
    html.pwa-mobile-app .site-header { display: flex; align-items: center; min-height: 64px; padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); gap: 8px; border-bottom: 1px solid var(--gi-line, #d5e6f2); }
    html.pwa-mobile-app .site-home-link { display: flex; align-items: center; min-width: 0; flex: 1 1 auto; gap: 8px; }
    html.pwa-mobile-app .site-header .logo-symbol-img { display: block; flex: 0 0 36px; width: 36px; height: 36px; margin: 0; }
    html.pwa-mobile-app .site-title { font-size: clamp(.85rem, 4vw, 1.15rem); letter-spacing: -.035em; line-height: 1.2; }
    html.pwa-mobile-app .site-branding p, html.pwa-mobile-app .header-utility { display: none; }
    html.pwa-mobile-app .pwa-header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 2px; }
    html.pwa-mobile-app .pwa-header-actions > a, html.pwa-mobile-app .pwa-header-actions > button { display: grid; position: relative; width: 44px; min-height: 44px; place-items: center; padding: 10px; border: 0; border-radius: 12px; color: var(--gi-blue-900, #005a9f); background: transparent; cursor: pointer; }
    html.pwa-mobile-app .pwa-header-actions svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    html.pwa-mobile-app .pwa-hint-count { position: absolute; top: 0; right: 0; min-width: 17px; padding: 2px 4px; border-radius: 12px; color: #fff; background: var(--gi-blue-900, #005a9f); font-size: .625rem; font-weight: 800; text-align: center; }
    html.pwa-mobile-app .pwa-bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; z-index: 100; right: 0; bottom: 0; left: 0; min-height: 76px; padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); border-top: 1px solid var(--gi-line, #d5e6f2); background: #fff; box-shadow: 0 -4px 20px rgba(0, 62, 118, .08); }
    html.pwa-mobile-app .pwa-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 60px; padding: 4px 2px; border: 0; border-radius: 12px; color: var(--gi-muted, #607b94); background: transparent; font: 700 .6875rem/1.2 var(--gi-font-ui, system-ui); text-align: center; text-decoration: none; cursor: pointer; overflow-wrap: anywhere; }
    html.pwa-mobile-app .pwa-icon { display: block; flex: 0 0 auto; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    html.pwa-mobile-app .pwa-nav-item.is-active, html.pwa-mobile-app .pwa-nav-item[aria-expanded="true"] { color: var(--gi-blue-900, #005a9f); background: var(--gi-blue-100, #eaf5fc); }
    html.pwa-mobile-app .pwa-plus-circle { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 13px; color: #fff; background: var(--gi-blue-900, #005a9f); }
    html.pwa-mobile-app .pwa-nav-create { gap: 2px; color: var(--gi-blue-900, #005a9f); }
    html.pwa-mobile-app .pwa-nav-create .pwa-icon { width: 23px; height: 23px; stroke-width: 2; }
    html.pwa-mobile-app .pwa-nav-item:focus-visible, html.pwa-mobile-app .pwa-sheet a:focus-visible, html.pwa-mobile-app .pwa-sheet button:focus-visible, html.pwa-mobile-app .pwa-header-actions > :focus-visible { outline: 3px solid var(--gi-accent, #e7a334); outline-offset: -3px; }
    html.pwa-mobile-app.pwa-editing .pwa-bottom-nav, html.pwa-mobile-app.pwa-external-overlay .pwa-bottom-nav { visibility: hidden; pointer-events: none; }
    html.pwa-mobile-app body.pwa-sheet-open { overflow: hidden; }
    html.pwa-mobile-app .pwa-sheet { position: fixed; inset: auto 8px calc(var(--gi-pwa-nav-height) + 8px); width: calc(100% - 16px); max-width: 520px; max-height: min(78vh, 720px); max-height: min(78dvh, calc(var(--gi-pwa-visual-height, 100dvh) - var(--gi-pwa-nav-height) - 20px)); margin: 0 auto; padding: 0; overflow: hidden; border: 1px solid var(--gi-line, #d5e6f2); border-radius: 22px; color: var(--gi-ink, #0b315c); background: #fff; box-shadow: 0 12px 48px rgba(0, 35, 70, .22); }
    html.pwa-mobile-app .pwa-sheet[open] { display: flex; flex-direction: column; }
    html.pwa-mobile-app .pwa-sheet::backdrop { background: rgba(0, 30, 60, .38); }
    html.pwa-mobile-app .pwa-sheet-handle { flex: 0 0 auto; width: 34px; height: 4px; margin: 10px auto 0; border-radius: 4px; background: #c9dce9; }
    html.pwa-mobile-app .pwa-sheet-heading { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--gi-line, #d5e6f2); }
    html.pwa-mobile-app .pwa-sheet-heading p { margin: 0 0 3px; color: var(--gi-muted, #607b94); font: 600 .75rem/1.3 var(--gi-font-ui, system-ui); }
    html.pwa-mobile-app .pwa-sheet-heading h2 { margin: 0; color: var(--gi-blue-900, #005a9f); font: 800 1.25rem/1.25 var(--gi-font-ui, system-ui); }
    html.pwa-mobile-app .pwa-sheet-close { display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; padding: 10px; border: 0; border-radius: 50%; color: var(--gi-blue-900, #005a9f); background: var(--gi-blue-100, #eaf5fc); cursor: pointer; }
    html.pwa-mobile-app .pwa-sheet-content { min-height: 0; padding: 10px 12px max(16px, env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
    html.pwa-mobile-app .pwa-sheet-intro { margin: 0 4px 10px; color: var(--gi-muted, #607b94); font: .875rem/1.5 var(--gi-font-ui, system-ui); }
    html.pwa-mobile-app .pwa-sheet-links { display: grid; gap: 4px; }
    html.pwa-mobile-app .pwa-sheet-links a { display: grid; grid-template-columns: 40px minmax(0, 1fr) 18px; align-items: center; gap: 10px; min-height: 56px; padding: 10px 8px; border-radius: 12px; color: var(--gi-ink, #0b315c); text-decoration: none; overflow-wrap: anywhere; }
    html.pwa-mobile-app .pwa-sheet-links a:hover, html.pwa-mobile-app .pwa-account-links a:hover { background: var(--gi-blue-050, #f6fbff); }
    html.pwa-mobile-app .pwa-link-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 12px; color: var(--gi-blue-900, #005a9f); background: var(--gi-blue-100, #eaf5fc); }
    html.pwa-mobile-app .pwa-sheet-links a > .pwa-icon { width: 16px; height: 16px; color: var(--gi-muted, #607b94); }
    html.pwa-mobile-app .pwa-sheet-links strong { display: block; font: 700 .9375rem/1.35 var(--gi-font-ui, system-ui); }
    html.pwa-mobile-app .pwa-sheet-links small { display: block; margin-top: 3px; color: var(--gi-muted, #607b94); font: .75rem/1.4 var(--gi-font-ui, system-ui); }
    html.pwa-mobile-app .pwa-sheet-search { display: flex; gap: 6px; margin: 4px 4px 12px; }
    html.pwa-mobile-app .pwa-sheet-search input { width: 100%; min-width: 0; min-height: 48px; padding: 10px; border: 1px solid var(--gi-line, #d5e6f2); border-radius: 10px; font: 1rem var(--gi-font-ui, system-ui); }
    html.pwa-mobile-app .pwa-sheet-search button { min-height: 48px; padding: 10px; border: 0; border-radius: 10px; color: #fff; background: var(--gi-blue-900, #005a9f); font: 700 .875rem var(--gi-font-ui, system-ui); cursor: pointer; }
    html.pwa-mobile-app .pwa-sheet-subtitle { margin: 16px 8px 4px; color: var(--gi-muted, #607b94); font: 700 .75rem var(--gi-font-ui, system-ui); }
    html.pwa-mobile-app .pwa-account-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
    html.pwa-mobile-app .pwa-account-links a { display: flex; align-items: center; min-height: 48px; padding: 10px 8px; border-radius: 10px; color: var(--gi-blue-900, #005a9f); font: 600 .875rem/1.4 var(--gi-font-ui, system-ui); overflow-wrap: anywhere; }
    html.pwa-mobile-app.pwa-editing .pwa-sheet { bottom: calc(var(--gi-pwa-viewport-bottom, 0px) + 8px); max-height: calc(var(--gi-pwa-visual-height, 100dvh) - 20px); }

    /* Reuse the existing homepage shortcuts; the content sections stay intact. */
    html.pwa-mobile-app .home-hero { min-height: 0; }
    html.pwa-mobile-app .home-hero-content { width: auto; margin: 0 16px; padding: 20px 0 24px; }
    html.pwa-mobile-app .home-hero-wordmark { width: 210px; max-width: 72vw; height: 58px; }
    html.pwa-mobile-app .home-hero h2 { margin: 8px 0; font-size: 1.2rem; }
    html.pwa-mobile-app .home-hero-lead { font-size: .9375rem; }
    html.pwa-mobile-app .home-hero-actions, html.pwa-mobile-app .home-hero-mark, html.pwa-mobile-app .home-hero-content > p:not(.home-hero-lead) { display: none; }
    html.pwa-mobile-app .home-shortcuts { grid-template-columns: repeat(4, minmax(0, 1fr)); width: calc(100% - 24px); margin: 12px auto 24px; padding: 0; gap: 6px; overflow: visible; }
    html.pwa-mobile-app .home-shortcuts a { display: none; grid-template-columns: 1fr; grid-template-rows: auto auto; justify-items: center; align-content: center; gap: 7px; min-width: 0; min-height: 88px; padding: 10px 3px; text-align: center; box-shadow: var(--gi-shadow-sm); transform: none; transition: none; }
    html.pwa-mobile-app .home-shortcuts a[href$="/photos.php"] { display: grid; order: 0; }
    html.pwa-mobile-app .home-shortcuts a[href$="/reports.php"] { display: grid; order: 1; }
    html.pwa-mobile-app .home-shortcuts a[href$="/magazin.php"] { display: grid; order: 2; }
    html.pwa-mobile-app .home-shortcuts a[href$="/recipes.php"] { display: grid; order: 3; }
    html.pwa-mobile-app .home-shortcut-icon { grid-row: auto; width: 32px; height: 32px; }
    html.pwa-mobile-app .home-shortcut-icon svg { width: 24px; height: 24px; }
    html.pwa-mobile-app .home-shortcuts strong { font-size: .6875rem; line-height: 1.3; overflow-wrap: anywhere; }
    html.pwa-mobile-app .home-shortcuts small { display: none; }
}
