/*
 * CellHood device adaptation layer.
 *
 * The portal keeps one set of routes and one DOM for every device. These rules
 * only change presentation and interaction density, so mobile and tablet users
 * retain the same permissions, forms, audit behavior, and record workflows as
 * desktop users.
 */

/* Grid and flex children must be allowed to shrink around contained scrollers. */
.dashboard-stack > *,
.protocol-library-page > *,
.media-prep-page > *,
.team-page > *,
.batch-record-page > *,
.long-calendar-page > *,
.settings-page > * {
  min-width: 0;
}

.schedule-month-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: #aeb8c6 transparent;
  scrollbar-width: thin;
}

.mobile-rolling-calendar,
.mobile-calendar-range {
  display: none;
}

.settings-mobile-navigation {
  display: none;
}

.settings-nav a.is-current {
  color: var(--ch-primary);
  background: #f0f1fb;
}

.settings-nav a.is-current i {
  color: var(--ch-primary);
}

.schedule-month-scroll:focus-visible,
.calendar-board:focus-visible,
.batch-history-scroll:focus-visible,
.cell-bank-grid-shell:focus-visible,
.experiment-plate-shell:focus-visible {
  outline: 3px solid rgba(30, 107, 105, .28);
  outline-offset: -3px;
}

@media (max-width: 980px) {
  /* Tablet layout: preserve information density while removing rail pressure. */
  .app-content {
    margin-left: 0;
  }

  .dashboard-stack,
  .schedule-page,
  .team-page,
  .cultures-page,
  .protocol-library-page,
  .media-prep-page,
  .batch-record-page,
  .long-calendar-page {
    max-width: 100%;
  }

  .dashboard-stack > *,
  .dashboard-hero,
  .kpi-grid,
  .data-panel {
    width: 100%;
    max-width: 100%;
  }

  .protocol-library-page,
  .protocol-library-grid,
  .protocol-card-list,
  .regimen-card {
    min-width: 0;
  }

  .billing-plan-grid,
  .cell-bank-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .experiment-builder,
  .batch-experiment-list,
  .batch-offspring-list {
    grid-template-columns: 1fr;
  }
}

/*
 * The desktop master table needs more width once its accessibility floor is
 * 14px. Between phone and wide-desktop sizes, retain every field but present
 * each culture as a compact record card instead of crushing table columns.
 * The visual hierarchy deliberately follows the phone cards: identity first,
 * then a short row of operational details.
 */
@media (min-width: 761px) and (max-width: 1280px) {
  /*
   * Landscape tablets still have room for two team members per row, but not
   * for the desktop card's identity and both metric tiles side-by-side. Keep
   * the useful two-column directory and give each part its own row instead.
   */
  .team-directory-card {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
  }

  .team-directory-card .team-profile-avatar {
    grid-column: 1;
    grid-row: 1;
  }

  .team-directory-card .team-member-identity {
    min-width: 0;
    grid-column: 2;
    grid-row: 1;
  }

  .team-directory-card .team-member-identity > div {
    flex-wrap: wrap;
  }

  .team-directory-card .team-member-identity h2,
  .team-directory-card .team-member-identity p {
    overflow-wrap: anywhere;
  }

  .team-directory-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-column: 2;
    grid-row: 2;
  }

  .team-directory-stats > span {
    min-width: 0;
  }

  .team-directory-card .team-audit-link {
    grid-column: 2;
    grid-row: 3;
  }

  .culture-table-fit {
    overflow: visible;
  }

  .culture-table,
  .culture-table tbody {
    width: 100%;
    min-width: 0;
    display: block;
  }

  .culture-table thead {
    display: none;
  }

  .culture-table tr.culture-record-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(150px, .8fr) minmax(140px, .72fr);
    align-content: start;
    margin: 0 12px 12px;
    overflow: hidden;
    border: 1px solid #dfe5eb;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(28, 43, 67, .055);
  }

  .culture-table tr.culture-record-row:first-child {
    margin-top: 12px;
  }

  .culture-table tr.culture-record-row > td {
    width: auto !important;
    min-width: 0;
    display: block;
    padding: 12px 14px;
    border-right: 1px solid #edf0f3;
    border-bottom: 0;
    background: transparent;
  }

  .culture-table tr.culture-record-row > .culture-identity-cell {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(112px, .52fr) minmax(150px, .9fr) minmax(260px, 1.45fr) auto;
    align-items: center;
    gap: 8px 18px;
    padding: 13px 15px;
    border-right: 0;
    border-bottom: 1px solid #dfe8e7;
    background: linear-gradient(135deg, #f7fbfa 0%, #f2f7f8 100%);
  }

  .culture-table tr.culture-record-row > .culture-identity-cell::before {
    display: none;
  }

  .culture-table tr.culture-record-row > .culture-identity-cell > * {
    min-width: 0;
  }

  .culture-table tr.culture-record-row > .culture-identity-cell .culture-identity-heading {
    margin: 0;
  }

  .culture-table tr.culture-record-row > .culture-identity-cell .culture-batch-name {
    margin: 0;
    font-size: 16px;
  }

  .culture-table tr.culture-record-row > .culture-identity-cell .culture-identity-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .culture-table tr.culture-record-row > .culture-identity-cell > .culture-owner-label {
    width: fit-content;
    margin: 0;
    padding: 5px 8px;
    border-radius: 5px;
    background: rgba(255, 255, 255, .84);
    white-space: nowrap;
  }

  .culture-table tr.culture-record-row > td:nth-child(2) {
    grid-column: 1 / span 2;
  }

  .culture-table tr.culture-record-row > td:nth-child(3) {
    grid-column: 3;
  }

  .culture-table tr.culture-record-row > .culture-other-cell {
    grid-column: 4;
    border-right: 0;
    background: #fbfcfd;
  }

  .culture-table tr.culture-record-row > td::before {
    display: block;
    margin-bottom: 8px;
    color: #727e90;
    content: attr(data-label);
    font: 650 14px/1.25 "JetBrains Mono", monospace;
    letter-spacing: .025em;
    text-transform: uppercase;
  }

  .culture-table tr.culture-record-row > td > * {
    min-width: 0;
  }

  .culture-protocol-summary {
    grid-template-columns: minmax(112px, 1.28fr) minmax(68px, .58fr) minmax(94px, .9fr);
    gap: 10px;
  }

  .culture-table tr.culture-record-row > td:nth-child(3) .culture-cell-stack {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .culture-table tr.culture-record-row > .culture-other-cell .culture-feed-control,
  .culture-table tr.culture-record-row > .culture-other-cell .culture-feed-actions {
    width: 100%;
  }

  .culture-table tr.culture-record-row > .culture-other-cell .table-feed-button {
    min-height: 36px;
  }
}

@media (max-width: 760px) {
  .team-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .team-summary-grid article {
    min-height: 104px;
    padding: 12px 10px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .team-summary-icon {
    width: 34px;
    height: 34px;
  }

  .team-summary-grid small {
    line-height: 1.25;
  }

  .team-summary-grid strong {
    margin-top: 2px;
  }

  :root {
    --device-edge: 16px;
    --device-touch: 44px;
  }

  html {
    scroll-padding-top: 82px;
  }

  body.app-page {
    overflow-x: hidden;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .site-header {
    inset: 8px 10px auto;
    width: auto;
    height: 60px;
    overflow: visible;
    border: 1px solid rgba(211, 217, 230, .9);
    border-radius: 18px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 10px 30px rgba(22, 31, 53, .09);
  }

  .topbar {
    width: 100%;
    height: 58px;
    max-width: 100%;
    padding: 0 14px;
  }

  .brand {
    min-width: 0;
    gap: 8px;
    font-size: 1.45rem;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .mobile-nav-toggle {
    display: none;
  }

  .topbar-collapse.collapse,
  .topbar-collapse.collapsing,
  .topbar-collapse.show {
    position: static;
    width: auto;
    height: 58px;
    min-width: 0;
    display: flex !important;
    flex: 1;
    align-items: center;
    justify-content: flex-end;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .topbar-collapse .primary-links {
    display: none;
  }

  .topbar-collapse .account-actions {
    min-width: 0;
    flex-wrap: nowrap;
    gap: 2px;
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  .topbar-divider,
  .account-name {
    display: none;
  }

  .account-button {
    padding-inline: 4px 0;
  }

  .account-avatar {
    width: 36px;
    height: 36px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
    color: #26344b;
    font-size: 1.1rem;
  }

  .topbar-collapse {
    max-height: none;
  }

  .primary-links a,
  .account-actions > :is(a, button),
  .account-button,
  .icon-button {
    min-height: var(--device-touch);
  }

  .account-actions {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .global-search-panel,
  .notification-center {
    position: fixed !important;
    left: var(--device-edge) !important;
    right: var(--device-edge) !important;
    width: auto !important;
    max-width: none;
    transform: none !important;
  }

  .global-search-panel,
  .notification-center {
    top: 78px !important;
    max-height: calc(100dvh - 174px);
    overflow-y: auto;
  }

  .app-content {
    padding-top: 88px;
    padding-bottom: 28px;
  }

  .batch-form-actions {
    bottom: calc(82px + max(10px, env(safe-area-inset-bottom)));
  }

  .mobile-bottom-nav {
    --ch-minimum-text-size: 12px;
    position: fixed;
    z-index: 55;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    height: 72px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    padding: 5px 6px;
    border: 1px solid rgba(207, 214, 227, .94);
    border-radius: 18px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 14px 38px rgba(17, 29, 52, .18);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-link {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    padding: 5px 2px;
    color: #747d8d;
    border: 0;
    border-radius: 12px;
    background: transparent;
    font-family: "Inter", sans-serif;
    font-size: 12px;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
  }

  .mobile-bottom-link i {
    font-size: 1.12rem;
    line-height: 1;
  }

  .mobile-bottom-link:hover,
  .mobile-bottom-link:focus-visible,
  .mobile-bottom-link.active {
    color: #241a91;
    background: #f0efff;
  }

  .mobile-bottom-more {
    min-width: 0;
    display: grid;
  }

  .mobile-bottom-more > .mobile-bottom-link {
    width: 100%;
  }

  .mobile-bottom-more .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    min-width: 190px;
    margin-bottom: 10px !important;
    padding: 7px;
    border-color: #dfe3eb;
    border-radius: 12px;
  }

  .mobile-bottom-more .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 9px 11px;
    border-radius: 7px;
    color: #26344b;
    font-size: 14px;
  }

  .mobile-bottom-more .dropdown-item.active {
    color: #241a91;
    background: #f0efff;
  }

  .mobile-bottom-more .mobile-master-link {
    color: #b4233b;
  }

  .app-footer {
    align-items: center;
    flex-flow: row wrap;
    gap: 6px 16px;
    margin-top: 18px;
    margin-bottom: 2px;
    padding: 11px 2px 0;
    font-size: 14px;
    line-height: 1.25;
  }

  .dashboard-stack,
  .protocol-library-page,
  .media-prep-page,
  .schedule-page,
  .team-page,
  .cultures-page,
  .batch-record-page,
  .long-calendar-page {
    width: 100%;
    min-width: 0;
  }

  .dashboard-stack > *,
  .dashboard-hero,
  .hero-actions,
  .kpi-grid,
  .data-panel,
  .protocol-library-page > *,
  .protocol-library-grid,
  .protocol-card-list,
  .regimen-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .dashboard-hero,
  .schedule-hero,
  .cultures-hero,
  .protocol-library-hero,
  .media-prep-hero,
  .team-page-hero,
  .batch-record-hero,
  .long-calendar-hero {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  :is(.dashboard-hero, .schedule-hero, .cultures-hero, .protocol-library-hero, .media-prep-hero, .team-page-hero, .long-calendar-hero) h1 {
    font-size: clamp(2rem, 10vw, 2.5rem);
    line-height: 1.02;
  }

  .hero-actions,
  .batch-record-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .hero-actions > *,
  .batch-record-actions > *,
  .batch-record-actions form,
  .batch-record-actions form > * {
    width: 100%;
    min-width: 0;
  }

  .batch-record-actions > .batch-feed-actions {
    grid-column: 1 / -1;
  }

  /* Mobile has room for the two secondary actions directly. Avoid hiding
     useful record functions behind an additional “More” interaction. */
  .batch-record-actions > .batch-action-menu {
    width: 100%;
    grid-column: 1 / -1;
  }

  .batch-record-actions > .batch-action-menu > .batch-action-menu-toggle {
    display: none !important;
  }

  .batch-action-menu > .dropdown-menu {
    position: static !important;
    inset: auto !important;
    width: 100%;
    min-width: 0;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    transform: none !important;
    border: 0;
    background: transparent;
    box-shadow: none !important;
  }

  .batch-action-menu > .dropdown-menu > li {
    min-width: 0;
    display: flex;
  }

  .batch-record-actions .batch-action-menu .dropdown-item {
    min-height: var(--device-touch);
    justify-content: center;
    border: 1px solid #d4dce6;
    background: #fff;
  }

  .hero-actions :is(a, button),
  .batch-record-actions :is(a, button),
  .settings-primary-button,
  .settings-secondary-button,
  .protocol-panel-action,
  .media-prep-button {
    min-height: var(--device-touch);
    justify-content: center;
  }

  /* The compact legacy breakpoint hides this label for dashboard headers.
     Mobile hero actions have enough room and need the text for clarity. */
  .hero-actions .media-prep-button span {
    display: inline;
  }

  .hero-actions .media-prep-button {
    padding-inline: 14px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .kpi-card {
    min-height: 124px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 14px 32px 14px 12px;
    border-color: #dfe4ec;
    border-radius: 8px;
    box-shadow: 0 5px 16px rgba(18, 39, 65, .045);
  }

  .kpi-card .kpi-icon {
    width: 44px;
    height: 44px;
  }

  .kpi-card-content {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 5px;
    row-gap: 5px;
  }

  .kpi-card small {
    font-size: 16px;
    line-height: 1.25;
    letter-spacing: .075em;
  }

  .kpi-card strong,
  .kpi-card em {
    font-size: 20px;
    line-height: 1;
  }

  .kpi-card.panel-help-compact {
    padding-right: 32px;
  }

  .kpi-card.overdue-kpi:not([hidden]) {
    grid-column: 1 / -1;
    min-height: 92px;
  }

  .data-panel-header {
    min-height: 64px;
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 15px 18px;
  }

  .data-panel-header > div:first-child {
    min-width: 0;
  }

  .data-panel-header h2 {
    font-size: 1.2rem;
  }

  .today-panel-actions,
  .calendar-range,
  .calendar-range-control {
    margin-left: auto;
  }

  .dashboard-report-options,
  .dashboard-report-range-fields {
    grid-template-columns: 1fr;
  }

  .dashboard-report-modal .modal-header,
  .dashboard-report-modal .modal-body,
  .dashboard-report-modal .modal-footer {
    padding-inline: 18px;
  }

  .today-panel-actions .media-prep-button {
    min-width: 0;
    gap: 7px;
    padding-inline: 11px;
  }

  .today-panel-actions .media-prep-button span {
    display: inline;
    white-space: nowrap;
  }

  .today-panel .feed-strip {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 0;
    padding: 0;
    overflow-x: hidden;
    scroll-snap-type: none;
  }

  .calendar-panel .calendar-range-shell,
  .calendar-board-desktop {
    display: none;
  }

  .mobile-calendar-range {
    display: block;
    margin-left: auto;
    color: #4034ad;
    font-family: "JetBrains Mono", monospace;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: .01em;
    white-space: nowrap;
  }

  .mobile-rolling-calendar {
    display: block;
    margin: 0 18px 24px;
    overflow: hidden;
    border: 1px solid #e2e6ee;
    border-radius: 8px;
    background: #fff;
  }

  .mobile-calendar-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 14px 12px;
    border-bottom: 1px solid #e5e9ef;
  }

  .mobile-calendar-tab {
    position: relative;
    min-width: 0;
    min-height: 72px;
    display: grid;
    place-content: center;
    gap: 3px;
    padding: 8px 4px;
    color: #687384;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-family: "Hanken Grotesk", sans-serif;
    font-size: .95rem;
    line-height: 1;
  }

  .mobile-calendar-tab strong {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
  }

  .mobile-calendar-tab i {
    width: 5px;
    height: 5px;
    margin: 3px auto 0;
    border-radius: 50%;
    background: #18a89c;
  }

  .mobile-calendar-tab.is-active {
    color: #fff;
    background: #3226a8;
  }

  .mobile-calendar-tab.is-active i {
    background: #2ed2bf;
  }

  .mobile-calendar-tab:focus-visible {
    outline: 3px solid rgba(57, 73, 196, .28);
    outline-offset: 2px;
  }

  .mobile-calendar-day-panel > h3 {
    margin: 0;
    padding: 13px 14px;
    color: #606b7e;
    border-bottom: 1px solid #e1e6ed;
    background: #f7f9fb;
    font-family: "JetBrains Mono", monospace;
    font-size: .9rem;
    font-weight: 600;
  }

  .mobile-calendar-event-list .calendar-chip {
    min-height: 126px;
    margin: 0;
    padding: 0;
    border-radius: 0;
    border-bottom: 1px solid #e1e6ed;
    box-shadow: none;
  }

  .mobile-calendar-event-list .calendar-chip:last-child {
    border-bottom: 0;
  }

  .mobile-calendar-event-list .calendar-chip-link {
    position: relative;
    min-height: 126px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "identity status"
      "name status"
      "detail status"
      "owner status";
    align-content: center;
    column-gap: 14px;
    padding: 15px 18px 15px 70px;
  }

  .mobile-calendar-event-list .calendar-batch-heading {
    width: auto;
    grid-area: identity;
  }

  .mobile-calendar-event-list .calendar-batch-heading .batch-symbol {
    position: absolute;
    top: 50%;
    left: 22px;
    width: 29px;
    height: 29px;
    transform: translateY(-50%);
  }

  .mobile-calendar-event-list .calendar-chip-name {
    grid-area: name;
    margin: 5px 0 3px;
  }

  .mobile-calendar-event-list .calendar-chip-detail { grid-area: detail; }
  .mobile-calendar-event-list .calendar-chip-owner { grid-area: owner; }
  .mobile-calendar-event-list .calendar-chip-status {
    grid-area: status;
    align-self: center;
    margin: 0 !important;
    text-align: right;
    white-space: nowrap;
  }

  .mobile-calendar-event-list .calendar-chip .dashboard-feed-form {
    top: auto;
    right: 12px;
    bottom: 8px;
  }

  .mobile-calendar-empty {
    min-height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 18px;
    color: #6f7a8b;
    font-size: .875rem;
  }

  .feed-card,
  .feed-card-link {
    min-height: 138px;
  }

  .feed-card {
    border-bottom: 1px solid #e1e6ed;
    border-radius: 0;
    scroll-snap-align: none;
  }

  .feed-card-link {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "identity status"
      "name status"
      "media status"
      "owner status"
      "meta status";
    align-content: center;
    column-gap: 14px;
    padding: 14px 18px 14px 70px;
  }

  .feed-batch-heading {
    width: auto;
    min-height: 18px;
    grid-area: identity;
  }

  .feed-card .feed-batch-heading .batch-symbol {
    position: absolute;
    top: 50%;
    left: 22px;
    width: 28px;
    height: 28px;
    transform: translateY(-50%);
  }

  .feed-card-name {
    grid-area: name;
    margin: 4px 0 2px;
  }

  .feed-card-detail {
    grid-area: media;
  }

  .feed-card-owner {
    grid-area: owner;
  }

  .feed-card-meta {
    grid-area: meta;
  }

  .feed-card time {
    grid-area: status;
    align-self: center;
    margin: 0;
    text-align: right;
    white-space: nowrap;
  }

  .feed-card .dashboard-feed-form {
    top: auto;
    right: 12px;
    bottom: 9px;
  }

  .feed-card :is(.feed-batch-heading strong, .feed-card-detail, .feed-card-owner, .feed-card-meta, time),
  .calendar-chip :is(.calendar-batch-heading strong, .calendar-chip-detail, .calendar-chip-owner, .calendar-chip-status),
  .regimen-card :is(strong, small, p, time),
  .settings-eyebrow,
  .record-table :is(th, td) {
    font-size: .78rem;
  }

  .feed-card-name,
  .calendar-chip-name {
    font-size: .9rem !important;
  }

  .calendar-board,
  .team-calendar-wrap,
  .schedule-week-grid,
  .batch-history-scroll,
  .record-table-wrap,
  .audit-table-wrap,
  .media-batch-table-wrap,
  .cell-bank-grid-shell,
  .experiment-plate-shell,
  .gantt-scroll {
    max-width: 100%;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .calendar-board {
    width: calc(100% - 36px);
  }

  .schedule-page .schedule-month-panel {
    overflow: hidden;
  }

  .schedule-month-scroll {
    width: 100%;
  }

  .schedule-month-weekdays,
  .schedule-month-grid {
    min-width: 700px;
  }

  .schedule-month-day {
    min-height: 94px;
  }

  .gantt-scroll-shell::before,
  .gantt-scroll-shell::after {
    width: 34px;
  }

  .schedule-gantt-shell::before {
    left: 128px;
  }

  .schedule-gantt-shell .gantt-scroll-button.is-left {
    left: 136px;
  }

  .team-combined-gantt-shell::before {
    left: 120px;
  }

  .team-combined-gantt-shell .gantt-scroll-button.is-left {
    left: 128px;
  }

  .gantt-row,
  .gantt-axis-row {
    grid-template-columns: 110px 1fr;
    gap: 10px;
  }

  .schedule-gantt {
    padding-inline: 16px;
  }

  .schedule-gantt-identity {
    padding-inline: 8px;
  }

  .protocol-library-summary,
  .media-prep-summary {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .protocol-library-summary > *,
  .media-prep-summary > * {
    width: 100%;
    min-width: 0;
  }

  .protocol-card-list,
  .protocol-reference-list,
  .media-reference-grid,
  .media-recipe-grid,
  .team-protocol-grid {
    grid-template-columns: 1fr;
  }

  .regimen-card {
    aspect-ratio: auto;
    min-height: 340px;
  }

  .protocol-panel-body,
  .protocol-reference-layout,
  .team-directory-grid,
  .team-protocol-grid {
    padding-inline: 16px;
  }

  .protocol-step-row,
  .protocol-assay-row,
  .protocol-supplement-row,
  .protocol-step-recurrence,
  .offspring-controls,
  .offspring-group > div,
  .experiment-fields,
  .experiment-group > div,
  .assay-readout-fields,
  .cell-bank-picker-controls,
  .cell-bank-modal-fields fieldset,
  .bank-cells-notes,
  .settings-password-grid {
    grid-template-columns: 1fr;
  }

  .protocol-step-row > *,
  .protocol-assay-row > *,
  .protocol-step-recurrence,
  .protocol-step-row > label:nth-of-type(3),
  .protocol-assay-row label:nth-of-type(3) {
    grid-column: auto;
    grid-row: auto;
  }

  .protocol-step-row > button,
  .protocol-assay-row > button,
  .protocol-supplement-row > button {
    width: var(--device-touch);
    height: var(--device-touch);
    justify-self: end;
  }

  .protocol-supplement-row.is-detailed {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .protocol-supplement-row.is-detailed > button { margin-top: -4px; }

  .supplement-value-unit {
    grid-template-columns: minmax(0, 1fr) 108px;
  }

  .media-formulation-explanation { font-size: var(--device-font-small); }

  .media-preparation-volume-summary { grid-template-columns: 1fr; }

  .media-preparation-volume-summary > span {
    border-right: 0;
    border-bottom: 1px solid #d9e2e8;
  }

  .media-preparation-volume-summary > span:last-child { border-bottom: 0; }

  .culture-filters,
  .settings-form-grid,
  .workspace-settings-grid,
  .settings-member-permissions,
  .contact-form-grid,
  .custom-feed-plan-grid,
  .calendar-export-grid,
  .batch-record-grid,
  .batch-record-grid.is-wide,
  .batch-cell-bank-columns,
  .batch-assay-columns,
  .batch-note-board,
  .billing-plan-grid {
    grid-template-columns: 1fr;
  }

  .cell-bank-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Let the dense Cultures workspace use the narrow viewport instead of
     stacking the page, panel, and record gutters. A small safe edge remains. */
  .cultures-page .cultures-table-panel {
    width: calc(100% + 24px);
    margin-inline: -12px;
    border-inline: 0;
    border-radius: 0;
  }

  .cultures-page .culture-filters {
    padding-inline: 8px;
  }

  .cultures-page .culture-table-fit {
    padding-inline: 0;
  }

  .culture-search,
  .settings-field-wide,
  .contact-field.is-wide,
  .contact-consent.is-wide,
  .custom-feed-plan-grid label.is-wide {
    grid-column: auto;
  }

  .calendar-export-grid label.is-wide { grid-column: auto; }
  .calendar-export-actions .btn { width: 100%; justify-content: center; }

  .batch-record-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .batch-record-summary article:nth-child(2n) {
    border-right: 0;
  }

  /* Keep the history heading readable on phones, then place the month
     controller on its own row directly above the scrollable calendar. */
  .batch-record-panel > .batch-history-header {
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: start;
  }

  .batch-history-header > nav {
    width: 100%;
    grid-column: 1 / -1;
    justify-content: center;
    margin-top: 3px;
    padding-top: 10px;
    border-top: 1px solid #edf0f3;
  }

  .batch-camera-layout {
    grid-template-columns: 1fr;
  }

  .batch-camera-stage,
  .batch-camera-stage video,
  .batch-camera-stage > img {
    min-height: 220px;
    max-height: 42dvh;
  }

  .batch-camera-actions,
  .batch-camera-context {
    grid-template-columns: 1fr;
  }

  .batch-offspring-list > a {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .batch-offspring-list > a > :nth-child(3) {
    grid-column: 2;
  }

  .experiment-plate-grid,
  .cell-bank-grid {
    touch-action: pan-x pan-y;
  }

  .settings-layout {
    gap: 14px;
  }

  .settings-nav {
    display: none;
  }

  .settings-mobile-navigation {
    position: sticky;
    z-index: 30;
    top: calc(76px + env(safe-area-inset-top));
    display: grid;
    width: 100%;
    padding: 9px;
    border: 1px solid #dfe4ec;
    border-radius: 10px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 8px 22px rgba(18, 39, 65, .09);
    backdrop-filter: blur(12px);
  }

  .settings-mobile-navigation label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin: 0;
  }

  .settings-mobile-navigation-label {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    padding-left: 5px;
    color: #667085;
    font-weight: 700;
    white-space: nowrap;
  }

  .settings-mobile-navigation-label i {
    color: #178477;
  }

  .settings-mobile-select-shell {
    position: relative;
    min-width: 0;
  }

  .settings-mobile-select-shell select {
    width: 100%;
    min-height: 46px;
    appearance: none;
    padding: 10px 42px 10px 13px;
    border: 1px solid #cfd7e3;
    border-radius: 7px;
    color: #102136;
    background: #f8fafc;
    font: 700 14px "Hanken Grotesk", sans-serif;
  }

  .settings-mobile-select-shell > i {
    position: absolute;
    top: 50%;
    right: 14px;
    color: #667085;
    pointer-events: none;
    transform: translateY(-50%);
  }

  .settings-mobile-select-shell select:focus-visible {
    outline: 3px solid rgba(29, 132, 119, .18);
    outline-offset: 2px;
    border-color: #5b938b;
  }

  .settings-panel,
  .settings-subsection-anchor {
    scroll-margin-top: calc(150px + env(safe-area-inset-top));
  }

  .settings-panel,
  .settings-form,
  .workspace-settings-grid,
  .settings-data-actions {
    min-width: 0;
  }

  .workspace-member-card {
    align-items: start;
  }

  .audit-table-wrap,
  .record-table-wrap {
    overflow-x: auto;
  }

  .modal-dialog {
    width: auto;
    max-width: calc(100vw - 16px);
    min-height: 0;
    margin: 8px;
  }

  .modal-dialog-centered {
    min-height: calc(100% - 16px);
  }

  .modal-content {
    max-height: calc(100dvh - 16px);
    overflow: hidden;
    border-radius: 8px;
  }

  .modal-content > form,
  .modal-content > form > .modal-body {
    min-height: 0;
  }

  .modal-content > form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
  }

  .modal-header,
  .modal-footer {
    flex: 0 0 auto;
    padding: 14px 18px;
  }

  .modal-footer {
    flex-wrap: wrap;
  }

  .modal-footer > :is(button, a),
  .modal-footer > form,
  .modal-footer > form > button {
    min-height: var(--device-touch);
  }

  .app-confirm-dialog,
  .month-day-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  .app-footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
  }

  .app-footer a {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
}

@media (min-width: 761px) {
  .mobile-bottom-nav {
    display: none;
  }
}

@media (max-width: 420px) {
  .kpi-card {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px;
    padding: 12px 26px 12px 10px;
  }

  .kpi-card .kpi-icon {
    width: 36px;
    height: 36px;
  }

  .kpi-card small {
    font-size: 14px;
  }

  .kpi-card strong,
  .kpi-card em {
    font-size: 18px;
  }
}

@media (max-width: 360px) {
  .site-header {
    right: 7px;
    left: 7px;
  }

  .topbar {
    padding-inline: 10px;
  }

  .brand {
    font-size: 1.25rem;
  }

  .brand-logo {
    width: 29px;
    height: 29px;
  }

  .icon-button {
    width: 36px;
  }

  .account-avatar {
    width: 33px;
    height: 33px;
  }

  .mobile-bottom-nav {
    right: 7px;
    left: 7px;
  }

}

@media (max-width: 480px) {
  .app-content {
    padding-inline: 12px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .hero-actions,
  .protocol-library-summary,
  .batch-record-summary {
    grid-template-columns: 1fr;
  }

  .media-prep-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .media-prep-summary > span {
    padding: 9px 8px;
  }

  .batch-record-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .batch-record-summary article {
    border-right: 0;
    border-bottom: 1px solid var(--ch-line);
  }

  .batch-record-summary article:last-child {
    border-bottom: 0;
  }

  .data-panel-header {
    padding-inline: 14px;
  }

  .calendar-board {
    width: calc(100% - 24px);
    margin-inline: 12px;
  }

  .today-panel .feed-strip {
    grid-auto-columns: auto;
    padding: 0;
  }

  .settings-profile-photo,
  .workspace-member-card,
  .team-directory-card,
  .batch-assay-heading {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .workspace-member-card > :not(:first-child):not(:nth-child(2)),
  .team-directory-card > :not(:first-child):not(:nth-child(2)),
  .batch-assay-heading > :last-child {
    grid-column: 2;
  }

  .contact-intro-panel,
  .contact-form-panel,
  .legal-panel {
    padding: 20px 16px;
  }
}

@media (hover: none), (pointer: coarse) {
  button,
  input,
  select,
  textarea,
  .btn,
  .settings-input,
  .form-control,
  .form-select {
    font-size: 16px;
  }

  :is(button, .btn, .settings-primary-button, .settings-secondary-button, .protocol-edit-button, .culture-pagination a) {
    min-height: 44px;
  }

  .feed-action,
  .calendar-chip .dashboard-feed-form,
  .team-feed-form {
    opacity: 1;
    transform: none;
  }

  .calendar-chip:hover,
  .feed-card:hover,
  .protocol-reference-record:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-report-details,
  .dashboard-report-detail-card {
    transition: none;
  }

  .horizontal-strip-shell .feed-strip,
  .gantt-scroll,
  .schedule-month-scroll {
    scroll-behavior: auto;
  }
}
