/* Installed app (PWA) = phone layout only. In a normal browser tab nothing here applies. */
@media (display-mode: standalone) {
  html { max-width: 480px; margin: 0 auto; min-height: 100%; transform: translateZ(0); /* fixed bars stay inside the column */
         box-shadow: 0 0 0 1px var(--border, rgba(128,128,128,.2)); }
  html, body { overscroll-behavior-y: none; }
  /* auth pages: never show the desktop side panel */
  .auth-aside { display: none !important; }
  .auth-shell { grid-template-columns: minmax(0, 1fr) !important; }
  .auth-main { padding: 28px 20px 32px; }
  .theme-toggle-floating { right: 12px; }
}
@media (display-mode: standalone) and (min-width: 481px) { body { background: var(--bg-primary); } }

/* Phone layout forced in the installed app (same rules as the 900px breakpoint) */
/* from css/dashboard.css */
@media (display-mode: standalone) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    box-shadow: none;
    visibility: hidden;      /* off-screen menu must not take keyboard focus */
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), visibility 0.3s;
  }
  .sidebar.open {
    visibility: visible;
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close { display: block; }
  .topbar { display: flex; }
  .main-content {
    margin-left: 0;
    padding: 80px 16px 24px;
  }
  .view-header { flex-direction: column; align-items: stretch; }
  .view-header .btn { width: 100%; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
/* from css/modern.css */
@media (display-mode: standalone) {
  body { display: block; }
  .main-content {
    margin-left: 0; max-width: 100%;
    padding: calc(68px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(92px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  /* Top bar: compact, app-like */
  .topbar { display: flex; height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); border-bottom: 1px solid var(--border); }
  .topbar-title { font-size: 17px; letter-spacing: -.02em; }
  .sidebar-toggle { display: none; }                         /* the bottom bar's "More" opens the menu */
  .topbar #topAddBtn { display: none; }                      /* replaced by the floating + button */
  .topbar::before { content: ""; width: 34px; height: 34px; border-radius: 10px; background: var(--grad-accent) center / 18px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
  .topbar { justify-content: flex-start; gap: 10px; }
  .topbar-title { flex: 1; }

  /* Menu drawer */
  .sidebar { width: min(300px, 86vw); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .sidebar-overlay { backdrop-filter: blur(3px); }

  /* Bottom tab bar */
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 450;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: var(--glass); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
    border-top: 1px solid var(--border); box-shadow: 0 -8px 28px -14px rgba(0,0,0,.5);
  }
  .bn-item {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .01em;
    color: var(--text-muted); text-decoration: none; border-radius: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: color .2s, transform .15s var(--ease-out);
  }
  .bn-item:active { transform: scale(.92); }
  .bn-item svg { transition: transform .25s var(--ease-out); }
  .bn-item.active { color: var(--accent-text); }
  .bn-item.active svg { transform: translateY(-2px) scale(1.08); }
  .bn-item.active::before { content: ""; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--grad-accent); }

  /* Floating "new reminder" button, above the tab bar */
  .fab {
    position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 440;
    width: 56px; height: 56px; border-radius: 18px; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff;
    background: var(--grad-accent); box-shadow: 0 12px 28px -8px var(--accent); transition: transform .2s var(--ease-out);
  }
  .fab:active { transform: scale(.9); }

  /* Toasts sit above the tab bar, full width */
  .toast-container { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); max-width: none; }

  /* Headers & titles */
  .view-header { gap: 14px; margin-bottom: 20px; }
  .view-title { font-size: 26px; }
  .view-header .btn { min-height: 46px; }
  .card { border-radius: 16px; }
  .card-header { padding: 16px 16px 10px; }

  /* Bigger touch targets, no iOS zoom-on-focus */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; min-height: 46px; }
  .card-toolbar { flex-wrap: wrap; gap: 8px; }
  .card-toolbar > * { flex: 1 1 140px; min-width: 0; }

  /* Today checklist, recent rows */
  .recent-row { padding: 14px 16px; }
  .check-row { padding: 6px 16px; }

  /* Calendar: edge-to-edge, thumb-friendly */
  .cal-layout { gap: 14px; }
  .cal-grid { gap: 5px; padding: 8px 12px 14px; }
  .cal-day-card { position: static; }
  .cal-cell.day:hover { transform: none; box-shadow: none; }
  .cal-legend { padding: 4px 16px 8px; font-size: 11px; }
  .cal-sum, .cal-day-prog { padding-left: 16px; padding-right: 16px; }
}
