/* Allow user-entered names, notes and labels to wrap in flex and grid layouts. */
#app-content, #onboarding, #account-gate {
  overflow-wrap: anywhere;
}

.field, .field-row > *, .live-form > *, .profile-settings > *, .sheet-head > div,
.today-layout > *, .supp-grid > *, .profile-summary > *, .right-column > * {
  min-inline-size: 0;
}

input, select, textarea {
  min-inline-size: 0;
  max-inline-size: 100%;
  box-sizing: border-box;
}

.field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-row.three { grid-template-columns: minmax(0, 1.1fr) minmax(0, .8fr) minmax(0, 1fr); }
.sidebar { overflow-y: auto; }
.schedule-bar { flex-wrap: wrap; gap: 8px; }
.date-control { margin-inline-start: auto; }
.sheet-actions, .notification-buttons { flex-wrap: wrap; }
.sheet-actions button, .notification-buttons button { white-space: normal; }
#sheet { overscroll-behavior: contain; }
#sheet .sheet-inner { min-inline-size: 0; }
body:has(#sheet[open]) { overflow-y: hidden; }

@media (pointer: fine) {
  html { scrollbar-gutter: stable; }
}

@media (min-width: 651px) and (max-width: 1000px) and (orientation: landscape) {
  .sidebar { padding-inline-start: max(14px, env(safe-area-inset-left)); }
  #main, .topbar { padding-inline-end: max(28px, env(safe-area-inset-right)); }
}

@media (max-width: 1000px), (any-pointer: coarse) {
  /* iOS zooms to small editable text when it receives focus. */
  :is(#sheet, #main, #onboarding, #account-gate) :is(input:not([type="checkbox"], [type="radio"], [type="range"]), select, textarea) {
    font-size: max(16px, 1em);
  }
}

@media (max-width: 650px) {
  #main, .topbar {
    padding-inline-start: max(20px, env(safe-area-inset-left));
    padding-inline-end: max(20px, env(safe-area-inset-right));
  }
  .mobile-nav {
    left: max(9px, env(safe-area-inset-left));
    right: max(9px, env(safe-area-inset-right));
  }
  #sheet {
    inset-inline: 0;
    margin-inline: auto;
    max-inline-size: 100%;
  }
  #sheet .sheet-inner {
    padding-inline-start: max(22px, env(safe-area-inset-left));
    padding-inline-end: max(22px, env(safe-area-inset-right));
    padding-bottom: max(25px, env(safe-area-inset-bottom));
  }
  .sheet-actions { padding-bottom: 0; }
  .page-heading { flex-wrap: wrap; }
  .page-heading > :is(.primary, .secondary) { margin-top: 0; }
  .week-strip { gap: clamp(3px, 1.5vw, 9px); }
  .week-day .mini-ring { max-width: 100%; height: auto; aspect-ratio: 1; }
}

@media (max-width: 370px) {
  .field-row, .field-row.three { grid-template-columns: minmax(0, 1fr); }
}

/* Keep all five log fields together, including when a sidebar limits the table width. */
.table-wrap { container: dose-history / inline-size; }
.table-wrap table { white-space: normal; }
.history-label { display: none; }
@container dose-history (max-width: 680px) {
  .table-wrap table, .table-wrap tbody { display: block; }
  .table-wrap thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .table-wrap tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "compound status" "when when" "dose dose" "author author";
    padding: 14px 18px;
    gap: 5px 12px;
    border-top: 1px solid var(--border);
  }
  .table-wrap td { min-width: 0; padding: 0; border: 0; }
  .history-compound { grid-area: compound; font-weight: 600; }
  .history-date { grid-area: when; }
  .history-dose { grid-area: dose; }
  .history-status { grid-area: status; }
  .history-author { grid-area: author; }
  .history-label { display: inline; color: var(--muted); }
  .quick-entry-label { font-weight: 400; }
}

.history-query,.history-pages,.install-tip{display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:14px 18px}
.history-query .field{flex:1 1 135px;min-width:0;margin:0}
.history-pages,.install-tip{justify-content:space-between}
.history-author .small-link{display:block;min-height:44px}
.history-pages span{font-size:.88rem}
.dose-more,.quick-card-actions button,.history-pages button,.install-tip .icon-button{min-width:44px;min-height:44px}
.install-tip .icon-button{flex-shrink:0}
[hidden],#sync-area [hidden]{display:none!important}
@media(max-width:700px){
 .home-heading{padding-block:4px;margin-bottom:12px}.home-heading .subtitle{display:none}
 .dose-meta,.dose-status{font-size:.82rem}.mobile-nav .nav-link span{font-size:.73rem}
 .counts{font-size:.74rem;overflow-wrap:anywhere;max-width:12em}
 .table-wrap tbody tr{grid-template-columns:minmax(0,1fr) minmax(0,auto)}
}

.lab-actions{display:flex;flex-wrap:wrap;gap:8px}
[data-preview] img{width:100%;max-width:100%;border:0}
.lab-spark{display:block;width:100%;height:auto}
