/* Phone layout, shared by every page (linked last in <head>, so it overrides each page's own styles on small
   screens only). Tuned for iPhone 16 Pro (402 pt wide, Dynamic Island, home bar); desktop is unchanged. */

html { -webkit-text-size-adjust: 100%; }

@media (max-width: 700px) {
  body {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
             max(24px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)) !important;
    font-size: 14px;
  }
  h1 { font-size: 19px !important; }
  .brand-name { font-size: 28px !important; }

  /* tabs: one swipeable row instead of three wrapped rows */
  .tab-nav {
    flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    margin: 10px -12px 14px !important; padding: 0 12px;
  }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-link { flex: none; white-space: nowrap; padding: 9px 12px !important; }

  /* iOS Safari zooms into any field under 16px when tapped -- keep fields at 16px */
  input, select, textarea { font-size: 16px !important; }
  button, .action-btn, .tab-link { min-height: 40px; }
  label.field { min-width: 0 !important; }

  section { border-radius: 12px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  #gate .box { width: min(340px, 100%) !important; box-sizing: border-box; }

  /* tables become stacked cards: "Label ........ value" per cell (labels filled in by mobile.js) */
  /* no scroll-inside-scroll on a phone: boxes grow with their cards and the page scrolls */
  #openWrap { max-height: none !important; overflow-y: visible !important; }

  table.m-cards, table.m-cards tbody { display: block; width: 100% !important; }
  table.m-cards thead { display: none; }
  table.m-cards tr {
    display: block; margin: 10px; padding: 6px 12px; border: 1px solid var(--border, #2a2e37);
    border-radius: 10px; background: var(--bg, transparent);
  }
  /* label floats left, the cell's own content (text, pills, buttons, notes) flows right-aligned beside/below it */
  table.m-cards td {
    display: flow-root; padding: 5px 0 !important; border: none !important; white-space: normal !important;
    text-align: right !important; overflow-wrap: break-word; min-width: 0;
  }
  table.m-cards td::before {
    content: attr(data-label); float: left; max-width: 45%; margin-right: 12px; text-align: left;
    color: var(--muted, #9aa2b1); font-size: 12px; font-weight: 600; line-height: 1.8;
  }
  table.m-cards .pill, table.m-cards .badge, table.m-cards .ip { white-space: nowrap; }
  table.m-cards td[data-label=""]::before, table.m-cards td.m-span::before { display: none; }
  table.m-cards td.m-span { display: block; text-align: left !important; }
  table.m-cards td:empty { display: none; }
  table.m-cards td > button, table.m-cards td .action-btn { margin: 2px 0 2px 6px; }
}
