/* iPhone/iPad and standalone web app. No zoom lock, no fixed page height. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
}
.shell > *, .lobby > *, .content, .panel, .world-form > *, .row > * { min-width: 0; }
input, select, textarea { max-width: 100%; }
#toast { bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
dialog { max-height: 85vh; max-height: calc(100dvh - 40px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
@media (max-width: 850px), (pointer: coarse) {
  /* Small form fonts can trigger automatic focus zoom in iPhone Safari. */
  html body input, html body select, html body textarea {
    font-size: 16px !important;
    line-height: 1.4;
  }
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea {
    min-height: 44px;
    min-width: 0;
  }
  button, .btn, summary { min-height: 44px !important; }
  button, .btn { min-width: 44px; touch-action: manipulation; }
  label:has(input[type=checkbox]), label:has(input[type=radio]) {
    min-height: 44px; padding-block: 8px; cursor: pointer;
  }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; flex-shrink: 0; }
}
@media (max-width: 850px) {
  .btn, .nav-group button, .workspace315 .btn, .care-tabs .btn,
  .c3-softkeys .btn, .room .btn, .station-tabs .btn { font-size: 14px !important; }
  .btn { white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: manual; max-width: 100%; }
  .nav-group button, .care-tabs .btn, .ws-subnav .btn { white-space: nowrap; }
  .panel p, .world-task p, .care-plan p, .ws-patient-summary details,
  .workspace315 .ws-next strong, .workspace315 .care-finding,
  .workspace315 .ws-logline, .mission-info p, .track-body p { font-size: 14px; }
  .small, small, .field span, .field small, .workspace315 .ws-metrics span { font-size: 13px; }
  .row { flex-wrap: wrap; }
  .world-form .field, #duty-roster .field { min-width: 0; flex-basis: 100%; }
  .topbar { height: auto; min-height: 58px; padding-block: 12px; flex-wrap: wrap; }
  /* Let controls use another row instead of squeezing their words apart. */
  .duty-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: 10px;
  }
  .duty-tabs .btn { width: 100%; min-width: 0; flex: none; white-space: nowrap; }
  .top-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  .top-actions .top-shortcut[data-page="station"] { flex: 1 0 100%; width: 100%; }
  .top-actions .profile-shortcut { flex: 1 1 120px; min-width: 120px; }
  .top-shortcut > span {
    flex: 1; min-width: 0; max-width: none;
    overflow-wrap: normal; word-break: normal; hyphens: manual;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .top-shortcut small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions .credit { flex: 0 0 auto; white-space: nowrap; padding-left: 0; border: 0; }
  .top-actions > .icon-btn { flex: 0 0 44px; }
  .workspace315 .ws-nav { top: env(safe-area-inset-top, 0px); }
  .workspace315 [data-cockpit-panel] { scroll-margin-top: calc(90px + env(safe-area-inset-top, 0px)); }
  .world-scroll, .history-table { max-width: 100%; overflow-x: auto; }
  .history-table { display: block; }
  .workspace315 .ws-patient-strip select { max-width: 100%; }
}
@media (max-width: 600px) {
  .content { padding: 18px 12px 32px; }
  .panel, .workspace315 .panel { padding: 14px; }
  .workspace315 .ws-next { flex-wrap: wrap; }
  .workspace315 .ws-next .btn { width: 100%; }
  .workspace315 .duty-measures, .c3-settings-grid { grid-template-columns: minmax(0,1fr); }
  .workspace315 .ws-metrics { gap: 6px; }
  .workspace315 .ws-metrics > div { padding: 8px; }
  .c3-vitals strong { font-size: clamp(24px, 7vw, 34px); }
  .c3-vitals .c3-rr { grid-column: 1 / -1; }
  .c3-softkeys { grid-template-columns: minmax(0,1fr); }
  .c3-alerts, .c3-bp-info, .c3-disclaimer { font-size: 13px; }
  .c3-title, .c3-topline { overflow-wrap: anywhere; }
  .world-ecg12 { grid-template-columns: minmax(0,1fr); }
  .vehicle-grid, .station-rooms { grid-template-columns: minmax(0,1fr); }
  .rank-grid, .badge-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .badge strong, .badge small { font-size: 13px; }
  .mission-card, .track-card { display: block; }
  .mission-img, .track-card .track-img { min-height: 0; height: 150px; }
  .filters select, .search, .join-box input { min-width: 0; max-width: 100%; }
  .lobby-form { padding: 24px 18px; }
  .lobby-story { padding: 22px 18px; }
  dialog { padding: 18px; width: calc(100% - 20px); }
}
@media print {
  body { padding: 0; }
  .history-table { display: table; }
}
