/* AYK Universal Experience — Phase 2 / daily workspaces.
   Mobile adaptation is component-scoped; never change persisted data, links,
   gallery crop choices, form actions or the desktop layout. */

:where(body .page-shell) :where(.ayk-collection-overview, .collection-browser,
    .ayk-plant-workspace, .chat-shell) {min-inline-size:0;max-inline-size:100%}

/* Compact collection: long Latin cultivar names must not push controls
   off-screen in Arabic RTL or English LTR contexts. */
body .page-shell .ayk-collection-overview .collection-top,
body .page-shell .collection-browser .collection-browser-heading {
  min-inline-size:0;
  max-inline-size:100%;
}
body .page-shell .ayk-collection-overview .ayk-collection-tools .button {
  min-inline-size:0;max-inline-size:100%;
  white-space:normal;overflow-wrap:anywhere;
}
body .page-shell .collection-browser .collection-browser-controls
  :where(input,select,button) {min-inline-size:0;max-inline-size:100%}

/* Private passports: the founder-only quick actions are real interactive
   controls, and must remain visible even with long corm/plant names. */
body .page-shell .ayk-plant-workspace .passport-showcase,
body .page-shell .ayk-plant-workspace .passport-showcase-copy,
body .page-shell .ayk-plant-workspace .passport-hero-actions,
body .page-shell .ayk-plant-workspace .passport-identity,
body .page-shell .ayk-plant-workspace .ayk-passport-manage {
  min-inline-size:0;max-inline-size:100%;
}
body .page-shell .ayk-plant-workspace .passport-identity :where(code,strong),
body .page-shell .ayk-plant-workspace .passport-showcase h1,
body .page-shell .ayk-plant-workspace .ayk-quick-store :where(summary,small) {
  overflow-wrap:anywhere;
}

/* Inbox and chat: keep the contact, specimen identity, bubbles, and composer
   within the viewport. Keep user messages in their existing alignment. */
body .page-shell .chat-shell,
body .page-shell .chat-shell :where(.chat-head,.chat-inbox-item,.chat-product,
      .chat-compose,.chat-thread,.ayk-chat-preview) {
  min-inline-size:0;max-inline-size:100%;
}
body .page-shell .chat-inbox-item>div,
body .page-shell .chat-product>div {min-inline-size:0;flex:1 1 0}
body .page-shell .chat-shell
 :where(.chat-subtitle,.ayk-inbox-thread,.chat-inbox-item strong,.chat-product strong) {
  overflow-wrap:anywhere;
}
body .page-shell .chat-inbox-item .chat-unread {
  flex:0 0 auto;min-inline-size:24px;min-block-size:24px;
}
body .page-shell [data-chat-thread] .chat-compose textarea {
  min-inline-size:0;max-inline-size:100%;
  flex:1 1 150px;
}
body .page-shell [data-chat-thread] .chat-compose button[type="submit"] {
  flex:0 0 auto;min-block-size:44px;
}
body .page-shell [data-chat-thread] .ayk-chat-attachments {
  flex-wrap:wrap;min-inline-size:0;
}
body .page-shell [data-chat-thread] .ayk-chat-preview img,
body .page-shell [data-chat-thread] .ayk-chat-photo img {
  max-inline-size:100%;
}

/* Inventory page: desktop remains a rich data table; on phones only the
   10-column overview becomes two-column labeled summaries. Detailed
   sold/dead tables still scroll in their own region with no lost fields. */
body .page-shell .inventory {min-inline-size:0;max-inline-size:100%}
body .page-shell .inventory .inv-panel,
body .page-shell .inventory .inventory-cards,
body .page-shell .inventory .inv-nav,
body .page-shell .inventory .controls {min-inline-size:0;max-inline-size:100%}
body .page-shell .inventory .inv-panel :where(h2,summary,label,p) {
  overflow-wrap:anywhere;
}
body .page-shell .inventory .controls>* {min-inline-size:0}
body .page-shell .inventory :where(.inv-nav,.studio-tabs) {
  overscroll-behavior-inline:contain;
  -webkit-overflow-scrolling:touch;
  scroll-snap-type:x proximity;
}
body .page-shell .inventory :where(.inv-nav,.studio-tabs) a {
  scroll-snap-align:start;
}
body .page-shell .inventory .inv-panel .units label {
  overflow-wrap:anywhere;
  line-height:1.6;
}
body .page-shell .inventory .inventory-scroll {
  max-inline-size:100%;
  overscroll-behavior-inline:contain;
  -webkit-overflow-scrolling:touch;
}
body .page-shell .inventory .inventory-mobile-table-hint {display:none}
body .page-shell .inventory table a {overflow-wrap:anywhere}
body .page-shell .inventory .inventory-scroll:focus-visible {
  outline:2px solid #3c674b;outline-offset:2px;
}

@media (max-width: 760px) {
  /* Collection two-column tools remain legible and tappable at 320px. */
  body .page-shell .ayk-collection-overview .ayk-collection-tools {
    flex-wrap:wrap;gap:8px;
  }
  body .page-shell .ayk-collection-overview .ayk-collection-tools .button {
    flex:1 1 120px;
    min-block-size:44px;
    font-size:clamp(11px,3vw,13px);
    line-height:1.35;
    padding:9px 7px;
  }
  body .page-shell .collection-browser .collection-browser-heading {
    align-items:flex-start;
    flex-wrap:wrap;
  }
  body .page-shell .collection-browser .collection-browser-heading > div {
    flex:1 1 180px;
  }
  body .page-shell .collection-browser .collection-browser-heading > .outline-button {
    flex:0 1 auto;max-inline-size:100%;
    white-space:normal;text-align:center;
  }
  body .page-shell .collection-browser .collection-browser-controls
   .collection-filter-panel {min-inline-size:0;max-inline-size:100%}
  body .page-shell .collection-browser .collection-view-switch {
    flex:0 0 auto;
  }
  body .page-shell .collection-browser .collection-entry {
    min-inline-size:0;
  }

  /* Keep passport actions useful without forcing a large horizontal pane. */
  body .page-shell .ayk-plant-workspace .passport-hero-actions {
    display:flex;flex-wrap:wrap;align-items:stretch;
    gap:8px;
  }
  body .page-shell .ayk-plant-workspace .passport-hero-actions > * {
    min-inline-size:0;max-inline-size:100%;
  }
  body .page-shell .ayk-plant-workspace .ayk-quick-store
    :where(input,button,select) {max-inline-size:100%}

  /* Tighter mobile inbox; multiline names no longer shrink unread markers. */
  body .page-shell .chat-shell .chat-inbox-item {
    gap:9px;padding:13px 14px;
    align-items:center;
  }
  body .page-shell .chat-shell .chat-product {
    min-inline-size:0;
  }
  body .page-shell [data-chat-thread] .chat-thread {
    min-block-size:180px;
    max-block-size:min(55svh,560px);
    overflow-y:auto;
    overscroll-behavior:contain;
  }
  @supports (height: 100dvh) {
    body .page-shell [data-chat-thread] .chat-thread {
      max-block-size:min(55dvh,560px);
    }
  }
  body .page-shell [data-chat-thread] .chat-compose {
    display:flex;flex-wrap:wrap;gap:8px;
    align-items:end;
  }
  body .page-shell [data-chat-thread] .chat-compose textarea {
    flex:1 1 160px;
  }
  body .page-shell [data-chat-thread] .chat-compose button[type="submit"] {
    min-block-size:48px;
  }
  body .page-shell [data-chat-thread] .chat-bubble {
    max-inline-size:88%;
  }
  body .page-shell [data-chat-thread] .ayk-chat-preview img {
    inline-size:80px;block-size:80px;
    object-fit:contain;
  }

  /* Grouped stock overview: every metric is labeled in a compact 2-column
     card. The original desktop table remains semantic and unchanged. */
  body .page-shell .inventory .inventory-mobile-table-hint {
    display:block;
    color:#647569;font-size:12px;line-height:1.55;
    margin:8px 0 12px;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll {
    overflow:visible;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll table,
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll tbody {
    display:block;inline-size:100%;min-inline-size:0;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll thead {
    position:absolute;inline-size:1px;block-size:1px;
    padding:0;margin:-1px;overflow:hidden;
    clip-path:inset(50%);white-space:nowrap;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll tr {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:0 10px;
    padding:12px 13px;
    margin-block:0 9px;
    border:1px solid #dfe5dc;
    background:#fffefa;
    border-radius:11px;
    min-inline-size:0;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll tr[hidden] {
    display:none!important;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll td {
    display:block;
    min-inline-size:0;
    padding:7px 0;
    margin:0;
    border-bottom:1px solid #eef0eb;
    font-size:13px;
    line-height:1.45;
    overflow-wrap:anywhere;
    text-align:start;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll td:first-child {
    grid-column:1/-1;
    font-weight:650;font-size:15px;
    padding-block-start:0;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll td[colspan] {
    grid-column:1/-1;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll td[data-label]::before {
    content:attr(data-label);
    display:block;
    font-size:11px;font-weight:500;line-height:1.5;
    color:#69786d;margin-bottom:3px;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll td:first-child::before {
    font-size:10px;
  }
  body .page-shell .inventory .inv-panel :where(button,summary) {
    min-block-size:44px;
  }
  body .page-shell .inventory .controls {
    display:flex;flex-wrap:wrap;
    gap:9px;
  }
  body .page-shell .inventory .controls label {
    flex:1 1 148px;min-inline-size:0;max-inline-size:100%;
  }
  body .page-shell .inventory .controls input:not([type="checkbox"]),
  body .page-shell .inventory .controls select {
    inline-size:100%;
    max-inline-size:100%;
    box-sizing:border-box;
  }
  body .page-shell .inventory .controls button {
    min-block-size:44px;
  }
  body .page-shell .inventory .units label {
    display:flex;
    align-items:flex-start;
    gap:7px;
    padding:10px 3px;
    border-bottom:1px solid #eff1ec;
  }
  body .page-shell .inventory .units input[type="checkbox"] {
    flex:0 0 auto;
    inline-size:18px;block-size:18px;
    margin:3px 0;
  }
  body .page-shell .inventory #inventory-search {
    inline-size:100%;
    min-block-size:44px;
    margin-block:8px;
    font-size:16px;
  }
}

@media (max-width: 380px) {
  body .page-shell .ayk-plant-workspace .passport-hero-actions details {
    min-width:0!important;
  }
  body .page-shell .chat-shell .chat-head,
  body .page-shell .chat-shell .chat-thread {
    padding-inline:12px;
  }
  body .page-shell .inventory #inventory-groups .inventory-summary-scroll tr {
    gap:0 7px;padding-inline:10px;
  }
}
