/* Responsive messaging workspaces. This file loads after the existing page
   styles so the legacy fixed-width columns never crop a narrower viewport. */
.seed-shell.mobile-workspace {
  width: 100%;
  min-width: 0;
  grid-template-columns: 200px 300px minmax(0, 1fr) 300px;
}
.mobile-workspace > *, .mobile-workspace .internal-workspace > * { min-width: 0; }
.mobile-workspace .avatar { flex-shrink: 0; }
.mobile-workspace .chat-contact-heading { display: flex; align-items: center; gap: 11px; min-width: 0; }
.mobile-workspace .chat-contact-copy { min-width: 0; }
.mobile-workspace .chat-contact-copy strong { display: block; overflow-wrap: anywhere; }
.mobile-workspace .chat-contact-copy span { overflow-wrap: anywhere; }
.mobile-workspace .chat-header { flex-wrap: wrap; }
.mobile-workspace .chat-actions { align-items: center; flex-wrap: wrap; }
.mobile-workspace .chat-actions > * { max-width: 100%; }
.mobile-workspace .chat-actions a, .mobile-workspace .chat-actions button { white-space: normal; }
.mobile-workspace .messages-list { min-width: 0; }
.mobile-workspace .bubble { min-width: 0; overflow-wrap: anywhere; }
/* A definite preferred width prevents audio-only bubbles from shrinking to the overflow menu. */
.mobile-workspace .message-audio { width: 340px; min-width: 0; max-width: 100%; }
.mobile-workspace .contact-panel, .mobile-workspace .seed-nav { overflow-wrap: anywhere; }
.mobile-workspace .contact-panel dt { flex-shrink: 0; }
.mobile-workspace .contact-panel dd { min-width: 0; }
.mobile-workspace .contact-panel fieldset { min-width: 0; }
.mobile-workspace .contact-panel input, .mobile-workspace .contact-panel select,
.mobile-workspace .contact-panel textarea { min-width: 0; max-width: 100%; }
.mobile-workspace .nav-footer > div:not(.avatar) { min-width: 0; }
.mobile-workspace .workspace-icon-button,
.mobile-workspace .workspace-text-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  min-width: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #3155b5;
  background: #f5f7ff;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
}
.mobile-workspace .workspace-icon-button { padding: 10px; }
.mobile-workspace .workspace-icon-button svg,
.mobile-workspace .workspace-text-button svg,
.mobile-workspace .workspace-inbox-filters > summary svg { width: 20px; height: 20px; flex: 0 0 auto; }
.mobile-workspace .workspace-icon-button:focus-visible,
.mobile-workspace .workspace-text-button:focus-visible,
.mobile-workspace .workspace-inbox-filters > summary:focus-visible { outline: 3px solid #7f9bff; outline-offset: 2px; }
.mobile-workspace .workspace-menu-button,
.mobile-workspace .workspace-back-button,
.mobile-workspace .workspace-contact-button,
.mobile-workspace .workspace-resume-button,
.mobile-workspace .workspace-chat-home,
.mobile-workspace .workspace-drawer-header,
.mobile-workspace .workspace-inbox-filters > summary { display: none; }
.mobile-workspace .workspace-backdrop { display: none; }
.mobile-workspace .workspace-header-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mobile-workspace .workspace-inbox-filters { margin: 0; }
.mobile-workspace.internal-page { min-height: 0; height: 100vh; height: 100dvh; }
.mobile-workspace .internal-sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mobile-workspace .internal-sidebar-heading h2 { margin: 0; font-size: 13px; }
.mobile-workspace .internal-chat-heading { min-width: 0; }
.mobile-workspace .internal-chat-heading h2 { overflow-wrap: anywhere; }
.mobile-workspace .internal-chat-header > span:last-child { flex: 0 0 auto; }

@media (min-width: 1200px) and (max-width: 1399px) {
  .seed-shell.mobile-workspace { grid-template-columns: 170px 270px minmax(0, 1fr) 280px; }
  .mobile-workspace .seed-nav { padding-inline: 10px; }
  .mobile-workspace .chat-header { padding: 16px; }
  .mobile-workspace .chat-actions { flex-basis: 100%; margin-left: 0; }
  .mobile-workspace .messages-list { padding-inline: 20px; }
  .mobile-workspace .bubble { max-width: 88%; }
  .mobile-workspace .contact-panel { padding-inline: 14px; }
  .mobile-workspace .nav-footer { flex-wrap: wrap; }
  .mobile-workspace .nav-footer > form { margin-left: 48px; }
}

@media (max-width: 1199px) {
  .seed-shell.mobile-workspace.is-workspace-ready {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .mobile-workspace.internal-page.is-workspace-ready {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }
  .mobile-workspace.is-workspace-ready {
    position: absolute;
    top: var(--workspace-viewport-top, 0px);
    right: 0;
    left: 0;
    height: 100vh;
    height: var(--workspace-viewport-height, 100dvh);
    max-height: var(--workspace-viewport-height, 100dvh);
    min-height: 0;
  }
  .mobile-workspace.is-workspace-ready .workspace-menu-button,
  .mobile-workspace.is-workspace-ready .workspace-contact-button { display: inline-flex; }
  .mobile-workspace.is-workspace-ready > .seed-nav,
  .mobile-workspace.is-workspace-ready > .contact-panel {
    display: none;
    position: absolute;
    top: 0;
    height: var(--workspace-viewport-height, 100dvh);
    max-height: var(--workspace-viewport-height, 100dvh);
    z-index: 1201;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 10px 45px #17203330;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-workspace.is-workspace-ready > .seed-nav {
    left: 0;
    width: min(320px, calc(100% - 36px));
    align-items: stretch;
    padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .mobile-workspace.is-workspace-ready > .contact-panel {
    right: 0;
    width: min(380px, 100%);
    padding: max(14px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
    padding-right: max(20px, env(safe-area-inset-right));
  }
  .mobile-workspace.is-workspace-ready[data-workspace-drawer="navigation"] > .seed-nav { display: flex; }
  .mobile-workspace.is-workspace-ready[data-workspace-drawer="contact"] > .contact-panel { display: block; }
  .mobile-workspace.is-workspace-ready .workspace-drawer-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 5;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: calc(-1 * max(14px, env(safe-area-inset-top)));
    margin-bottom: 16px;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
  }
  .mobile-workspace .workspace-drawer-header h2 { margin: 0; font-size: 17px; }
  .mobile-workspace.is-workspace-ready .seed-nav .brand { padding: 0 8px 20px; }
  .mobile-workspace.is-workspace-ready .seed-nav .brand > div:last-child,
  .mobile-workspace.is-workspace-ready .seed-nav .nav-footer > div:last-child { display: block; }
  .mobile-workspace.is-workspace-ready .seed-nav .nav-item { display: flex; min-height: 44px; align-items: center; gap: 10px; }
  .mobile-workspace.is-workspace-ready .nav-footer { flex-wrap: wrap; padding-top: 20px; }
  .mobile-workspace.is-workspace-ready .nav-footer > form { margin-left: auto; }
  .mobile-workspace.is-workspace-ready .signout-button { min-height: 44px; padding: 10px 12px; }
  .mobile-workspace.is-workspace-ready .workspace-backdrop:not([hidden]) {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 1200;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: #17203366;
    cursor: pointer;
    touch-action: none;
  }
  .mobile-workspace .chat-contact-heading { flex: 1; }
  .mobile-workspace .chat-actions { flex-basis: 100%; margin-left: 0; }
  .mobile-workspace .chat-actions a,
  .mobile-workspace .chat-actions button { display: inline-flex; align-items: center; min-height: 44px; padding: 9px 10px; font-size: 12px; }
  .mobile-workspace .messages-list { padding: 22px 20px; }
  .mobile-workspace .bubble { max-width: 88%; }
  .mobile-workspace .conversation-list { overscroll-behavior: contain; }
  .mobile-workspace .contact-panel button,
  .mobile-workspace .contact-panel input[type="submit"] { min-height: 44px; }
  .mobile-workspace .contact-panel .context-menu-trigger { min-width: 44px; }
  .mobile-workspace .composer-input, .mobile-workspace .internal-composer textarea,
  .mobile-workspace .contact-panel input:not([type="checkbox"]),
  .mobile-workspace .contact-panel select, .mobile-workspace .contact-panel textarea,
  .mobile-workspace .inbox-filter-form input, .mobile-workspace .inbox-filter-form select,
  .mobile-workspace .reply-picker input, .mobile-workspace .reply-picker select { font-size: 16px; }
  .mobile-workspace .reply-picker { max-height: min(85dvh, calc(var(--workspace-viewport-height, 100dvh) - 24px)); }
  .mobile-workspace .reply-picker-list { max-height: min(50dvh, calc(var(--workspace-viewport-height, 100dvh) - 220px)); }

  /* Without JS, show the same working links and forms in a scrollable stack. */
  .seed-shell.mobile-workspace:not(.is-workspace-ready) {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
  }
  .mobile-workspace:not(.is-workspace-ready) > .seed-nav { align-items: stretch; }
  .mobile-workspace:not(.is-workspace-ready) .seed-nav .nav-item { display: flex; }
  .mobile-workspace:not(.is-workspace-ready) .seed-nav .brand > div:last-child,
  .mobile-workspace:not(.is-workspace-ready) .seed-nav .nav-footer > div:last-child { display: block; }
  .mobile-workspace:not(.is-workspace-ready) > .chat-panel { height: 75dvh; min-height: 360px; }
  .mobile-workspace:not(.is-workspace-ready) > .contact-panel { display: block; }
}

@media (max-width: 760px) {
  .seed-shell.mobile-workspace.is-workspace-ready { grid-template-columns: minmax(0, 1fr); }
  .mobile-workspace.is-workspace-ready > .conversation-list,
  .mobile-workspace.is-workspace-ready > .chat-panel {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    border: 0;
  }
  .mobile-workspace.is-workspace-ready[data-workspace-pane="chat"] > .conversation-list,
  .mobile-workspace.is-workspace-ready[data-workspace-pane="list"] > .chat-panel,
  .mobile-workspace.is-workspace-ready[data-workspace-pane="chat"] .internal-sidebar,
  .mobile-workspace.is-workspace-ready[data-workspace-pane="list"] .internal-chat {
    visibility: hidden;
    pointer-events: none;
  }
  .mobile-workspace.is-workspace-ready .workspace-back-button,
  .mobile-workspace.is-workspace-ready[data-workspace-can-resume="true"] .workspace-resume-button,
  .mobile-workspace.is-workspace-ready .workspace-chat-home { display: inline-flex; }
  .mobile-workspace .panel-header { min-height: 76px; padding: max(12px, env(safe-area-inset-top)) 14px 12px; gap: 10px; }
  .mobile-workspace .panel-header h1 { font-size: 22px; }
  .mobile-workspace .panel-header .secondary-link { display: inline-flex; align-items: center; min-height: 44px; }
  .mobile-workspace .workspace-resume-button { padding-inline: 10px; font-size: 12px; }
  .mobile-workspace .inbox-live-tools { padding: 10px 14px; }
  .mobile-workspace .inbox-live-tools button { min-height: 40px; }
  .mobile-workspace.is-workspace-ready .workspace-inbox-filters > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 16px;
    color: #465a7c;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
  }
  .mobile-workspace .workspace-inbox-filters > summary::-webkit-details-marker { display: none; }
  .mobile-workspace .workspace-inbox-filters > summary::after { content: "+"; margin-left: auto; font-size: 20px; font-weight: 400; }
  .mobile-workspace .workspace-inbox-filters[open] > summary::after { content: "−"; }
  .mobile-workspace .workspace-inbox-filters .inbox-filter-form { margin: 0; padding: 12px 14px; }
  .mobile-workspace .workspace-inbox-filters .inbox-filter-form input,
  .mobile-workspace .workspace-inbox-filters .inbox-filter-form select,
  .mobile-workspace .workspace-inbox-filters .inbox-filter-form button { min-height: 44px; }
  .mobile-workspace .conversation { padding: 15px 16px; }
  .mobile-workspace .conversation.active { padding-left: 13px; }
  .mobile-workspace .chat-header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 0;
    padding: max(10px, env(safe-area-inset-top)) 10px 8px;
  }
  .mobile-workspace.is-workspace-ready .chat-header .workspace-menu-button { display: none; }
  .mobile-workspace .chat-header .workspace-back-button { grid-column: 1; grid-row: 1; }
  .mobile-workspace .chat-header .chat-contact-heading { grid-column: 2; grid-row: 1; gap: 8px; }
  .mobile-workspace .chat-header .workspace-contact-button { grid-column: 3; grid-row: 1; padding-inline: 9px; }
  .mobile-workspace .chat-header .avatar { width: 34px; height: 34px; font-size: 13px; }
  .mobile-workspace .chat-contact-copy strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-workspace .chat-contact-copy span { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-workspace .chat-actions { grid-column: 1 / -1; grid-row: 2; gap: 6px; }
  .mobile-workspace .chat-actions:empty { display: none; }
  .mobile-workspace .chat-actions .message-delete { opacity: 1; color: #9c4550; }
  .mobile-workspace .chat-actions .translation-settings-link { margin: 0; }
  .mobile-workspace .messages-list { gap: 6px; padding: 18px 12px; }
  .mobile-workspace .day-label { margin-bottom: 14px; }
  .mobile-workspace .bubble { max-width: 90%; padding: 10px 12px 8px; }
  .mobile-workspace .bubble p { font-size: 15px; }
  .mobile-workspace .message-image, .mobile-workspace .message-video { max-height: 340px; max-width: 100%; }
  .mobile-workspace .reply-composer {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
    gap: 6px;
    max-height: min(60dvh, calc(var(--workspace-viewport-height, 100dvh) * .52));
  }
  .mobile-workspace .composer-main { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }
  .mobile-workspace .composer-tools { gap: 0; }
  .mobile-workspace .composer-tools button, .mobile-workspace .attach-button { width: 40px; height: 44px; padding: 0; }
  .mobile-workspace .composer-input { min-height: 48px; max-height: min(120px, 25dvh); padding: 11px 10px; }
  .mobile-workspace .send-button { min-height: 44px; padding: 11px 12px; font-size: 14px; }
  .mobile-workspace .reply-picker-open { min-height: 40px; }
  .mobile-workspace .reply-composer-bar { gap: 6px; }
  .mobile-workspace .reply-composer-bar > span { font-size: 10px; }
  .mobile-workspace .composer-closed { padding: 14px; line-height: 1.5; }
  .mobile-workspace .contact-panel .contact-hero { padding-bottom: 16px; }
  .mobile-workspace .contact-panel .detail-card { padding-top: 20px; }
  .mobile-workspace .contact-panel .contact-hero h2 { overflow-wrap: anywhere; }
  .mobile-workspace.workspace-keyboard-open .reply-composer,
  .mobile-workspace.workspace-keyboard-open .internal-composer { padding-bottom: 8px; }

  .mobile-workspace.internal-page { padding: 0; }
  .mobile-workspace.internal-page.is-workspace-ready {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .mobile-workspace .internal-page-header {
    flex-wrap: wrap;
    padding: max(14px, env(safe-area-inset-top)) 16px 12px;
    gap: 10px;
    margin: 0;
    background: white;
    border-bottom: 1px solid var(--line);
  }
  .mobile-workspace .internal-page-header h1 { font-size: 21px; }
  .mobile-workspace .internal-page-header .mentor-admin-actions { width: 100%; gap: 18px; }
  .mobile-workspace .internal-page-header a { display: inline-flex; align-items: center; min-height: 44px; }
  .mobile-workspace.is-workspace-ready[data-workspace-pane="chat"] .internal-page-header { display: none; }
  .mobile-workspace .internal-workspace { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); border: 0; border-radius: 0; }
  .mobile-workspace.is-workspace-ready .internal-sidebar,
  .mobile-workspace.is-workspace-ready .internal-chat,
  .mobile-workspace.is-workspace-ready .internal-welcome { grid-column: 1; grid-row: 1; }
  .mobile-workspace.is-workspace-ready .internal-sidebar { display: block; border: 0; }
  .mobile-workspace .internal-welcome { display: none; }
  .mobile-workspace .internal-sidebar-heading { padding: 14px 16px 10px; }
  .mobile-workspace .internal-chat-header { flex-wrap: nowrap; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 10px 10px; }
  .mobile-workspace .internal-chat-header .internal-back { flex-basis: auto; margin: 0; }
  .mobile-workspace .internal-chat-header .avatar { width: 34px; height: 34px; }
  .mobile-workspace .internal-chat-heading { flex: 1; }
  .mobile-workspace .internal-chat-heading h2 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-workspace .internal-chat-heading p { font-size: 10px; }
  .mobile-workspace .internal-chat-header > span:last-child { margin-left: 0; }
  .mobile-workspace .internal-chat-header .context-menu-trigger { width: 36px; min-height: 44px; }
  .mobile-workspace .internal-timeline { padding: 16px 12px; }
  .mobile-workspace .internal-composer { gap: 8px; padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .mobile-workspace .internal-chat-status { margin: 6px 12px 0; }
  .mobile-workspace .internal-composer textarea { min-height: 48px; max-height: min(160px, 30dvh); font-size: 16px; }
  .mobile-workspace .internal-message-delete { min-height: 36px; display: inline-flex; align-items: center; }
  .mobile-workspace:not(.is-workspace-ready) .internal-back { display: inline-flex; }
}

@media (max-width: 380px) {
  .mobile-workspace .chat-header .chat-contact-heading > .avatar { display: none; }
  .mobile-workspace .internal-chat-header > .avatar { display: none; }
  .mobile-workspace .workspace-chat-home { padding-inline: 8px; font-size: 12px; }
}

@media (max-width: 760px) and (max-height: 520px) {
  .mobile-workspace .chat-contact-copy [data-live-mentor] { display: none; }
  .mobile-workspace .chat-actions { gap: 4px; }
  .mobile-workspace .chat-actions a, .mobile-workspace .chat-actions button { min-height: 38px; padding-block: 7px; }
  .mobile-workspace .reply-composer-bar > span { display: none; }
  .mobile-workspace .messages-list { padding-block: 10px; }
}


/* Keep the contact details control beside the conversation actions. */
.mobile-workspace .chat-header .chat-actions {
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
}
.mobile-workspace .chat-header .chat-actions > * { min-width: 0; }
@media (max-width: 760px) {
  .mobile-workspace .chat-header { grid-template-columns: 44px minmax(0, 1fr); }
  .mobile-workspace .chat-header .chat-actions { width: 100%; gap: 5px; }
  .mobile-workspace .chat-header .chat-actions > * { flex: 1 1 auto; }
  .mobile-workspace .chat-header .chat-actions > form { display: flex; }
  .mobile-workspace .chat-header .chat-actions a,
  .mobile-workspace .chat-header .chat-actions button {
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    height: 44px;
    padding: 6px;
    font-size: 11.5px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .mobile-workspace .chat-header .chat-actions > form > button { width: 100%; }
}
