/* iPad (and any large screen): the app laid out the iPadOS way instead of as a stretched phone column.
   - The tab bar (#tabs) becomes a sidebar down the left, with the app's header (wordmark at the top, the household
     and role at the bottom) laid over it. Same buttons and handlers: only CSS moves them.
   - The content fills the rest of the width, up to a readable measure; lists of cards go two across where wide enough.
   - Sheets open as centred form sheets instead of rising from the bottom.
   The height guard keeps a phone on its side (932×430) on the phone layout, and nothing here applies below 768×600.
   Linked last in app.html (after native-ios.css and the page's own <style>), so these rules win over the phone ones
   at equal specificity. */
@media (min-width: 768px) and (min-height: 600px) {
  :root { --side: 264px; --side-in: 16px; --measure: 760px; }

  /* ---------- the sidebar ---------- */
  body.has-tabs nav.tabs {
    top: 0; bottom: 0; right: auto; width: calc(var(--side) + env(safe-area-inset-left));
    /* room for the wordmark above the rows and the household card below them (both from the header, laid over) */
    padding: calc(env(safe-area-inset-top) + 88px) var(--side-in) calc(var(--safe-b) + 128px) calc(var(--side-in) + env(safe-area-inset-left));
    background: var(--surface); border-top: 0; border-right: 1px solid var(--line); overflow-y: auto;
  }
  .native-ios body.has-tabs nav.tabs { background: color-mix(in srgb, var(--surface) 82%, transparent); border-top: 0; border-right: var(--hairline); }
  body.has-tabs #tabsIn { max-width: none; height: auto; margin: 0; display: flex; flex-direction: column; gap: 2px; }
  body.has-tabs #tabsIn > button {
    flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 12px;
    font-size: 17px; font-weight: 600; letter-spacing: 0; color: var(--ink); text-align: left;
  }
  body.has-tabs #tabsIn > button svg { width: 24px; height: 24px; color: var(--plum); }
  body.has-tabs #tabsIn > button:hover { background: var(--bg); }
  body.has-tabs #tabsIn > button[aria-selected="true"] { background: var(--plum-tint); color: var(--plum); font-weight: 700; }
  body.has-tabs #tabsIn .tab-dot { box-shadow: 0 0 0 2px var(--surface); }
  body.has-tabs #tabsIn > button[aria-selected="true"] .tab-dot { box-shadow: 0 0 0 2px var(--plum-tint); }

  /* The app's header, laid over the sidebar: the wordmark at its top, the household card at its bottom. It lets taps
     through to the rows between (pointer-events), and its own links and picker take them back. */
  body.has-tabs #s-app > header.top {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 21; width: calc(var(--side) + env(safe-area-inset-left));
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px;
    margin: 0; min-height: 0; border: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none;
    padding: calc(env(safe-area-inset-top) + 24px) calc(var(--side-in) + 4px) calc(var(--safe-b) + 20px) calc(var(--side-in) + 8px + env(safe-area-inset-left));
    pointer-events: none;
  }
  body.has-tabs #s-app > header.top > * { pointer-events: auto; }
  body.has-tabs #s-app > header.top .wordmark { font-size: 26px; align-self: flex-start; }
  body.has-tabs #s-app > header.top .who {
    margin-top: auto; margin-left: -8px; text-align: left; display: grid; gap: 6px; justify-items: start;
    background: var(--bg); border-radius: 14px; padding: 12px 14px; font-size: 16px; font-weight: 600; color: var(--ink);
  }
  body.has-tabs #s-app > header.top .who > :first-child { width: 100%; overflow-wrap: anywhere; }
  body.has-tabs #s-app > header.top .who select { width: 100%; max-width: none; min-height: 44px; font-weight: 600; }
  body.has-tabs #s-app > header.top .who .tag { margin: 0; }

  /* The status bar strip covers the content only: the sidebar runs up behind the clock, as on iPadOS. */
  body.has-tabs::before { left: calc(var(--side) + env(safe-area-inset-left)); }

  /* ---------- the content ---------- */
  /* Beside the sidebar, a readable column with comfortable margins; no room kept at the bottom for a tab bar. */
  body.has-tabs { padding-bottom: calc(32px + var(--safe-b)); }
  body.has-tabs > .wrap { max-width: none; margin-left: calc(var(--side) + env(safe-area-inset-left)); padding: 0 max(clamp(24px, 4vw, 48px), env(safe-area-inset-right)) 0 clamp(24px, 4vw, 48px); }
  body.has-tabs #s-app { max-width: var(--measure); margin: 0 auto; padding-top: 28px; }
  body.has-tabs .toast { bottom: calc(24px + var(--safe-b)); left: calc(50% + (var(--side) + env(safe-area-inset-left)) / 2); }

  /* ---------- sheets: centred form sheets ---------- */
  dialog.sheet {
    width: calc(100% - 48px); max-width: 580px; max-height: 85vh; margin: auto; border-radius: 24px;
  }
  .native-ios dialog.sheet { border-radius: 14px; }
  dialog.sheet .grabber { display: none; }
  dialog.sheet .sheet-in { padding: 24px 28px 28px; }
  @keyframes ipad-sheet { from { transform: translateY(24px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
  dialog.sheet[open] { animation-name: ipad-sheet; }

  /* ---------- the Log tab: four care tiles across in the wider column ---------- */
  body.has-tabs .care-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* The 13" iPad, either way up: a wider sidebar and measure. */
@media (min-width: 1000px) and (min-height: 600px) {
  :root { --side: 280px; --measure: 880px; }
}

/* Landscape (the 11" and 13" on their sides): room for two cards across at a phone card's width, so lists of cards go
   two by two. Forms and the day's timeline stay one column. Her nannies only when there are two or more, so one card
   keeps the full width. */
@media (min-width: 1180px) and (min-height: 600px) {
  body.has-tabs :is(#mkResults, #nannyCards:has(> :nth-child(2))) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
  body.has-tabs :is(#mkResults, #nannyCards:has(> :nth-child(2))) > * { margin: 0; }
  body.has-tabs #mkResults > :is(.group-label, .empty) { grid-column: 1 / -1; margin: 8px 4px 0; }
  body.has-tabs #mkResults > .group-label:first-child { margin-top: 0; }
}
