/* The phone layout of the signed-in screens. Every rule sits inside the one media query, so a window 900px wide or
   more never reads this file's rules and the laptop site stays as it is. Loaded last (index.html), and each selector
   starts from an id, so it wins over the laptop rule it replaces without !important. */
@media (max-width: 899px) {
  /* Type. Tailwind sizes are in rem, so 15px at the root takes them down about 6%. Sizes written in px (11px labels,
     the bottom tabs) do not move, so small text gets no smaller. */
  html { font-size: 15px; }
  body { font-size: 13.5px; }
  html #page h1, html #page:is([data-module="core"], [data-module="benefits"]) h1 { font-size: 20px; line-height: 1.25; }
  #page .hx-lead { font-size: 17px; }
  #page .hx-kpi .num { font-size: 30px; }
  #page .text-4xl { font-size: 28px; line-height: 1.15; }
  #page .text-3xl { font-size: 24px; line-height: 1.2; }
  #page .hx-tile b { font-size: 22px; }
  #page .hx-due b { font-size: 24px; }
  #page .hx-count b { font-size: 19px; }
  #page .att-state { font-size: 21px; }
  html #page .lvm .bal b { font-size: 22px; }
  html #page:is([data-module="core"], [data-module="benefits"]) .kpi .v { font-size: 19px; }

  /* Top bar: one row. The bottom tabs carry Menu, so the menu button is dropped while they show. */
  #topbar > div { height: 56px; flex-wrap: nowrap; gap: 8px; row-gap: 0; padding: 0 12px; }
  html[data-tabs="1"] #topbar .sn-burger { display: none; }
  #topbar .sn-toplogo > span:last-child { font-size: 16px; }
  #topbar [data-id="user"] { padding: 0; }
  #topbar [data-id="user"] > svg { display: none; }

  /* Search is a round button until it has focus, then it covers the row. */
  #topbar .max-w-sm { order: 0; flex: 0 0 40px; min-width: 0; max-width: 40px; margin-left: auto; transition: none; }
  #topbar .max-w-sm > svg { left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
  #topbar .max-w-sm input { padding: 0; color: transparent; background: #fff; cursor: pointer; }
  #topbar .max-w-sm input::placeholder { color: transparent; }
  #topbar .max-w-sm:focus-within { position: absolute; z-index: 5; left: 12px; right: 12px; top: 8px; max-width: none; }
  #topbar .max-w-sm:focus-within > svg { left: 14px; transform: translateY(-50%); }
  #topbar .max-w-sm:focus-within input { padding: 0 12px 0 40px; color: #0F172A; font-size: 16px; cursor: text; }
  #topbar .max-w-sm:focus-within input::placeholder { color: #94A3B8; }

  /* The two menus hang from the bar, not from their button, so both edges stay on the screen. */
  #topbar [data-menu] { position: static; }
  #topbar [data-menu] > .absolute.top-full { left: 12px; right: 12px; width: auto; margin-top: 6px; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); }

  /* Home: number tiles stay side by side, and the six lifecycle steps take two rows of three. */
  #page .grid-cols-2:has(> :is(.hx-kpi, .hx-tile)) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #page .grid-cols-3:has(> .hx-count) { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #page .hx-kpi { padding: 14px; }
  #page .hx-kpi .lab { font-size: 12.5px; }
  #page .hx-track { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 16px; }
  #page .hx-track li + li::before { display: none; }

  /* Attendance, Today: the drawn phone is a plain card on a real phone. */
  #page .att-today > .shrink-0 { width: 100%; max-width: none; border: 1px solid #E4E1FB; border-radius: 20px; box-shadow: 0 10px 30px -22px rgba(55, 48, 163, .45); }
  #page .att-today > .shrink-0 > .h-6 { display: none; }
  #page .att-today > .shrink-0 > div:last-child { padding-top: 16px; }
  #page .att-today > .shrink-0 > div:last-child > div:first-child { justify-content: flex-end; }
  #page .att-today > .shrink-0 > div:last-child > div:first-child > span { display: none; }

  /* My leave: balances two to a row, so each label has room. */
  html #page .lvm .grid:has(> .bal) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  /* Approvals and the other Core pages: count tiles two to a row. */
  html #page:is([data-module="core"], [data-module="benefits"]) .grid.g6:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  /* Ask Tabby: no taller than the space between the top of the screen and its button. */
  #fab-root .pop { height: min(520px, calc(100vh - 164px)); height: min(520px, calc(100dvh - 164px - env(safe-area-inset-top, 0px))); max-height: none; }

  /* Messages drop from the top, clear of the Ask Tabby button and the tabs. */
  #toasts { top: calc(64px + env(safe-area-inset-top, 0px)); bottom: auto; left: 12px; right: 12px; }

  /* Menu. An area's pages open under its row (kernel: railList), so the list of areas stays in view and nothing floats
     over the page. The area being read is plain bold text. Only the page on screen is filled. */
  #sidenav { width: min(86vw, 340px) !important; }
  html[data-rail="open"] #sidenav .sn-label { max-width: none; }
  #sidenav .sn-head { justify-content: space-between; }
  #sidenav .sn-close { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #E2E8F0; border-radius: 50%; background: #fff; color: #475569; cursor: pointer; }
  #sidenav .sn-close svg { width: 18px; height: 18px; }
  #sidenav .sn-find { position: relative; flex: none; padding: 0 12px 8px; }
  #sidenav .sn-find svg { position: absolute; left: 26px; top: 13px; width: 16px; height: 16px; color: #94A3B8; pointer-events: none; }
  #sidenav .sn-find input { width: 100%; height: 42px; padding: 0 12px 0 38px; border: 1px solid #E2E8F0; border-radius: 12px; background: #F8FAFC; color: #0F172A; font: inherit; font-size: 16px; outline: none; }
  #sidenav .sn-find input:focus { border-color: #5B4CF0; background: #fff; box-shadow: 0 0 0 4px rgba(91, 76, 240, .1); }
  #sidenav .sn-found { display: none; }
  #sidenav.is-finding .sn-found { display: block; }
  #sidenav.is-finding .sn-list { display: none; }
  #sidenav .sn-none { padding: 18px 12px; font-size: 13px; color: #64748B; }
  #sidenav .sn-item { height: 48px; }
  #sidenav .sn-chev { flex: none; width: 16px; height: 16px; margin-left: 2px; color: #94A3B8; transition: transform .2s; }
  #sidenav .sn-item.is-on .sn-chev { color: #fff; }
  #sidenav .sn-item[aria-expanded="true"] { background: transparent; color: #0F172A; font-weight: 600; }
  #sidenav .sn-item[aria-expanded="true"] .sn-ic { color: #6F63F0; }
  #sidenav .sn-item[aria-expanded="true"] .sn-img { filter: none; }
  #sidenav .sn-item[aria-expanded="true"] .sn-count { background: #E0E7FF; color: #4338CA; }
  #sidenav .sn-item[aria-expanded="true"] .sn-chev { color: #5B4CF0; transform: rotate(180deg); }
  #sidenav .sn-sub { margin: 2px 0 10px 24px; padding-left: 8px; border-left: 2px solid #ECEAFE; }
  #sidenav .sn-sub-h { padding: 10px 12px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #94A3B8; }
  #sidenav :is(.sn-sub, .sn-found) button { min-height: 42px; white-space: normal; font-size: 14px; }
  @media (prefers-reduced-motion: reduce) { #sidenav .sn-chev { transition: none; } }
}
