/* Employee messages use the same mobile materials as the workbench. */
#staff-im-root :is(.im-list-support, .im-list-results) { display: contents; }

@media (max-width: 760px), (max-width: 1000px) and (max-height: 540px) and (orientation: landscape) {
  body.workspace-unified.mw-enabled.is-im-page .topbar,
  body.workspace-unified.mw-enabled.im-chat-open .mw-bottom-host { display: none; }

  body.workspace-unified.mw-enabled.is-im-page .content {
    height: calc(100dvh - var(--mw-bottom, 76px));
    min-height: 0;
    padding: 0;
  }

  body.workspace-unified.mw-enabled.is-im-page.im-chat-open .content,
  body.workspace-unified.mw-enabled.is-im-page.mw-keyboard-open .content {
    height: var(--pwa-visible-height, 100dvh);
  }

  body.workspace-unified.mw-enabled #staff-im-root {
    --im-frame: var(--pwa-bg, #f1f2f5);
    --im-surface: var(--pwa-surface, #fff);
    --im-soft: var(--im-frame);
    --im-thread: var(--im-frame);
    --im-ink: var(--pwa-ink, #20242b);
    --im-muted: var(--pwa-muted, #59616c);
    --im-subtle: var(--im-muted);
    --im-line: var(--pwa-line, #dfe2e8);
    --im-control: var(--im-line);
    --im-accent: var(--pwa-accent, #216349);
    --im-accent-ink: var(--im-accent);
    --im-active: #e7e9ee;
    --im-accent-soft: #e9ecf1;
    --im-self: #e0e5ee;
    --im-action: var(--pwa-action, #205b44);
    --im-action-ink: var(--pwa-action-ink, #fff);
    --im-contact-card: #e8f4ee;
    --im-contact-line: #c4dfd1;
    --im-contact-sheen: #fff;
    --im-bar: #ffffffed;
    --im-card-shadow: 0 4px 12px #2427350a, inset 0 1px 0 #ffffffbf;
    --im-radius-panel: 23px;
    --im-radius-control: 14px;
    --im-page-gutter: clamp(12px, 4.1vw, 22px);
    --im-start: max(var(--im-page-gutter), env(safe-area-inset-left, 0px));
    --im-end: max(var(--im-page-gutter), env(safe-area-inset-right, 0px));
    background: var(--im-frame);
  }

  html[data-workspace-theme="dark"] body.workspace-unified.mw-enabled #staff-im-root {
    --im-active: #34363d;
    --im-accent-soft: #363941;
    --im-self: #303844;
    --im-action: var(--pwa-action, #acd9bb);
    --im-action-ink: var(--pwa-action-ink, #152d22);
    --im-contact-card: #203630;
    --im-contact-line: #3b6557;
    --im-contact-sheen: #92e9c32b;
    --im-bar: #222428ed;
    --im-card-shadow: inset 0 1px 0 #ffffff0b;
  }

  #staff-im-root .im-list-pane { background: var(--im-frame); }
  #staff-im-root .im-list-head {
    flex-wrap: nowrap;
    padding: calc(15px + env(safe-area-inset-top, 0px)) var(--im-end) 12px var(--im-start);
    gap: 8px;
  }
  #staff-im-root .im-list-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  #staff-im-root .im-list-head h2 {
    font-size: 30px;
    font-weight: 750;
    line-height: 1.12;
    letter-spacing: -.035em;
  }
  #staff-im-root .im-list-head small { margin-block-start: 4px; font-size: 12px; }
  #staff-im-root .im-list-actions { flex: 0 0 auto; width: auto; }
  #staff-im-root button.im-new-chat {
    width: 44px;
    height: 44px;
    border-radius: 15px;
    background: var(--im-action);
    color: var(--im-action-ink);
  }

  #staff-im-root .im-search-field {
    background: var(--im-surface);
    border-color: var(--im-line);
    border-radius: var(--im-radius-control);
    min-height: 44px;
  }
  #staff-im-root .im-list-pane > .im-search-field { margin: 0 var(--im-end) 0 var(--im-start); }
  #staff-im-root .im-search-field:focus-within { border-color: var(--im-accent); }
  #staff-im-root .im-search-field input,
  #staff-im-root .im-composer textarea[data-im-input] { font-size: 16px; }
  #staff-im-root .im-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    margin: 9px var(--im-end) 0 var(--im-start);
    padding: 3px;
    border: 1px solid var(--im-line);
    border-radius: 16px;
    background: var(--pwa-well, var(--im-soft));
    box-shadow: inset 0 1px 2px #171a2509;
  }
  #staff-im-root .im-filters > button {
    min-height: 44px;
    padding: 4px;
    border-radius: 12px;
    font-size: 13px;
    touch-action: manipulation;
  }
  #staff-im-root .im-filters > button.active {
    background: var(--im-surface);
    box-shadow: var(--im-card-shadow);
    color: var(--im-accent-ink);
  }
  #staff-im-root .im-filters > button.active::after { display: none; }

  #staff-im-root .im-list-scroll { padding: 12px var(--im-end) 16px var(--im-start); }
  #staff-im-root .im-list-schedule {
    --tc-ink: #f8f8fc;
    --tc-muted: #cbd0d9;
    --tc-line: #ffffff29;
    --tc-surface: #343740;
    --tc-soft: #ffffff19;
    --tc-accent: #c8e6d3;
    --tc-pale: #40534c;
    margin: 0 0 12px;
    color: var(--tc-ink);
    border: 1px solid #ffffff24;
    border-radius: var(--im-radius-panel);
    background: var(--tc-surface);
    background-image: radial-gradient(ellipse at 10% 0%, #aab9d226, transparent 64%),
      radial-gradient(ellipse at 88% 95%, #7a8cb034, transparent 62%),
      linear-gradient(150deg, #383a45, #2b2d35 76%, #343944);
    box-shadow: 0 9px 22px #171a251f, inset 0 1px 0 #ffffff26;
  }
  #staff-im-root .im-list-schedule > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    min-height: 48px;
    border-radius: var(--im-radius-panel);
    font-size: 14px;
    cursor: pointer;
    list-style: none;
    touch-action: manipulation;
  }
  #staff-im-root .im-list-schedule > summary::-webkit-details-marker { display: none; }
  #staff-im-root .im-list-schedule > summary:focus-visible { outline: 2px solid var(--tc-accent); outline-offset: -3px; }
  #staff-im-root .im-list-schedule > summary:active { background: var(--tc-soft); }
  #staff-im-root .im-list-schedule > summary .im-icon:last-child {
    margin-inline-start: auto;
    width: 16px;
    height: 16px;
    color: var(--tc-muted);
  }
  #staff-im-root .im-list-schedule[open] > summary .im-icon:last-child { transform: rotate(180deg); }
  #staff-im-root #im-task-calendar { margin: 0; }
  #staff-im-root .tc-calendar {
    color: var(--tc-ink);
    margin: 0;
    padding: 0 12px 11px;
    background: transparent;
  }
  #staff-im-root .im-list-schedule .tc-calendar {
    --tc-ink: #f8f8fc;
    --tc-muted: #cbd0d9;
    --tc-line: #ffffff29;
    --tc-surface: #343740;
    --tc-soft: #ffffff19;
    --tc-accent: #c8e6d3;
    --tc-pale: #40534c;
  }
  #staff-im-root .tc-calendar-head { margin-bottom: 4px; }
  #staff-im-root .tc-day { min-height: 54px; gap: 4px; border-radius: 12px; }
  #staff-im-root .tc-month-grid .tc-day { min-height: 44px; }
  #staff-im-root .tc-day:not(.is-selected) { background: #ffffff0d; }
  #staff-im-root .tc-day.is-selected {
    background: #f8f8fc;
    color: #232631;
  }
  #staff-im-root .tc-day.is-selected :is(.tc-week-name, .tc-date-count) { color: #505865; }
  #staff-im-root .tc-day.is-other-month:not(.is-selected) { opacity: .78; }
  #staff-im-root .tc-day.is-today:not(.is-selected) { background: var(--tc-pale); color: var(--tc-accent); }
  #staff-im-root .tc-summary { margin-block-start: 6px; padding-block-start: 4px; }
  #staff-im-root .tc-summary button { border-radius: 9px; }
  #staff-im-root .tc-tasks-head { margin-block-start: 5px; }
  #staff-im-root .tc-refresh { min-height: 44px; }
  #staff-im-root .tc-calendar :is(.tc-error, .tc-task-status.is-overdue, .tc-summary button.has-overdue b) {
    color: #ffb9b7;
  }

  #staff-im-root .im-recent-head,
  #staff-im-root .im-recent {
    border: 1px solid var(--im-contact-line);
    background: var(--im-contact-card);
  }
  #staff-im-root .im-recent-head {
    min-height: 44px;
    margin: 0;
    padding: 0 13px;
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    background-image: radial-gradient(ellipse at 12% -24%, var(--im-contact-sheen), transparent 75%);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--im-contact-sheen) 70%, transparent);
    color: var(--im-ink);
    font-size: 13px;
    font-weight: 650;
  }
  #staff-im-root .im-recent-head > button { min-width: 44px; color: var(--im-muted); }
  #staff-im-root .im-recent {
    justify-content: flex-start;
    gap: clamp(4px, 2vw, 12px);
    margin: 0 0 14px;
    padding: 0 11px 9px;
    border-top: 0;
    border-radius: 0 0 20px 20px;
    background-image: radial-gradient(ellipse at 92% 130%, color-mix(in srgb, var(--im-accent) 14%, transparent), transparent 72%);
  }
  #staff-im-root .im-recent > button { flex: 0 1 54px; max-width: 54px; color: var(--im-ink); }
  #staff-im-root .im-recent .im-avatar { border: 1px solid #24243212; }
  #staff-im-root .im-recent-portrait[data-im-recent-unread]::after { border-color: var(--im-contact-card); }

  #staff-im-root .im-section-label {
    margin: 0 5px 7px;
    color: var(--im-ink);
    font-size: 14px;
    font-weight: 690;
  }
  #staff-im-root [data-im-conversations] {
    overflow: hidden;
    border: 1px solid var(--im-line);
    border-radius: var(--im-radius-panel);
    background: var(--im-surface);
    box-shadow: var(--im-card-shadow);
  }
  #staff-im-root .im-conversation {
    min-height: 68px;
    margin: 0;
    padding: 10px 13px;
    border-radius: 0;
    gap: 10px;
    background: transparent;
    touch-action: manipulation;
  }
  #staff-im-root .im-conversation.active,
  #staff-im-root .im-conversation:active { background: var(--im-active); }
  #staff-im-root .im-conversation:focus-visible { outline-offset: -3px; }
  #staff-im-root .im-conversation:not(:last-child)::after {
    content: "";
    position: absolute;
    inset: auto 12px 0 65px;
    height: 1px;
    background: var(--im-line);
    pointer-events: none;
  }
  #staff-im-root .im-conversation.has-unread { padding-inline-end: 48px; }
  #staff-im-root .im-conversation > .im-unread { inset-block-start: 13px; }
  #staff-im-root .im-conversation-heading { margin-bottom: 4px; }
  #staff-im-root .im-conversation-heading > strong { font-size: 15px; font-weight: 650; }
  #staff-im-root .im-conversation-preview { font-size: 13px; }

  #staff-im-root .im-thread-header {
    min-height: calc(55px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(4px, env(safe-area-inset-left, 0px));
    background: var(--im-bar);
    border-color: var(--im-line);
  }
  #staff-im-root .im-thread-identity { gap: 7px; padding-inline-end: 46px; }
  #staff-im-root .im-thread-identity h2 { margin-bottom: 2px; font-weight: 690; }
  #staff-im-root .im-thread-identity p {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #staff-im-root .im-thread-actions button { border-radius: 15px; color: var(--im-muted); }
  #staff-im-root .im-mobile-back { border-radius: 15px; color: var(--im-accent-ink); }
  #staff-im-root .im-messages {
    min-height: 0;
    padding: 13px var(--im-end) 8px var(--im-start);
  }
  #staff-im-root .im-message { margin-block-end: 14px; }
  #staff-im-root .im-message > .im-avatar { border-radius: 50%; }
  #staff-im-root .im-bubble { border-radius: 5px 17px 17px; line-height: 1.6; }
  #staff-im-root .im-message.is-self .im-bubble { border-radius: 17px 5px 17px 17px; }
  #staff-im-root .im-message-date { margin-block-end: 14px; }
  #staff-im-root .im-quote-action,
  #staff-im-root .im-announcement,
  #staff-im-root .im-file-actions :is(button, a),
  #staff-im-root .im-history-tools button,
  #staff-im-root .im-history-kinds button { min-height: 44px; }

  #staff-im-root .im-composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    column-gap: 8px;
    padding: 3px var(--im-end) calc(5px + env(safe-area-inset-bottom, 0px)) var(--im-start);
    background: var(--im-bar);
    border-color: var(--im-line);
  }
  #staff-im-root .im-composer :is(.im-compose-toolbar, .im-attachment-tray, [data-im-reference-draft]) {
    grid-column: 1 / -1;
  }
  #staff-im-root .im-composer > footer { padding-block-end: 2px; }
  #staff-im-root .im-compose-hint {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  body.mw-keyboard-open #staff-im-root .im-composer { padding-block-end: 5px; }
  #staff-im-root .im-composer textarea[data-im-input] {
    min-height: 48px;
    padding: 9px 12px;
    border: 1px solid var(--im-line);
    border-radius: 15px;
    background: var(--im-surface);
    resize: none;
  }
  #staff-im-root button.im-send { min-height: 44px; border-radius: 14px; }
  #staff-im-root :is(button.im-send, button.im-primary):not(:disabled) {
    color: var(--im-action-ink);
    background: var(--im-action);
  }
  #staff-im-root .im-context {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--im-surface);
  }
  #staff-im-root .im-dialog {
    width: min(520px, calc(100% - 28px));
    max-height: min(83dvh, calc(var(--pwa-visible-height, 100dvh) - 24px));
    border-radius: var(--im-radius-panel);
    background: var(--im-surface);
    border-color: var(--im-line);
  }
  #staff-im-root [data-im-dialog-body] {
    max-height: min(calc(83dvh - 70px), calc(var(--pwa-visible-height, 100dvh) - 94px));
    overscroll-behavior: contain;
  }
  #staff-im-root :is(button, .im-file-actions a) { touch-action: manipulation; }
  #staff-im-root :is(.im-icon-button, .im-filters > button, .im-history-kinds button):active {
    background: var(--im-active);
  }

  /* Override the legacy dark IM panels with the mobile palette. */
  html[data-workspace-theme="dark"] #staff-im-root :is(.im-thread-header, .im-composer) {
    background: var(--im-bar) !important;
    border-color: var(--im-line) !important;
  }
  html[data-workspace-theme="dark"] #staff-im-root :is(.im-search-field, .im-dialog, .im-context) {
    background: var(--im-surface) !important;
    border-color: var(--im-line) !important;
  }

  body.workspace-unified.is-im-page .ea-launcher {
    top: calc(15px + env(safe-area-inset-top, 0px));
    right: calc(60px + max(12px, env(safe-area-inset-right, 0px)));
    bottom: auto;
    width: 44px;
    height: 44px;
    justify-content: center;
  }
  body.workspace-unified.is-im-page .ea-launcher-orbit { width: 44px; height: 44px; }
  body.workspace-unified.im-chat-open .ea-launcher {
    top: calc(5px + env(safe-area-inset-top, 0px));
    right: calc(94px + max(8px, env(safe-area-inset-right, 0px)));
  }
  body.workspace-unified.im-chat-open #staff-im-root .im-messages {
    padding-inline-end: var(--im-end);
  }
}

@media (max-width: 760px) and (max-height: 670px) and (orientation: portrait) {
  #staff-im-root .im-list-results + .im-list-support .im-list-schedule { margin-block-start: 14px; }
}

@media (max-width: 1000px) and (max-height: 540px) and (orientation: landscape) {
  body:not(.im-chat-open) #staff-im-root .im-list-pane {
    display: grid;
    grid-template-columns: minmax(150px, .66fr) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  #staff-im-root .im-list-head {
    padding-block: calc(5px + env(safe-area-inset-top, 0px)) 5px;
  }
  #staff-im-root .im-list-head h2 { font-size: 25px; }
  #staff-im-root .im-list-head small { display: none; }
  #staff-im-root .im-list-pane > .im-search-field {
    align-self: center;
    margin-inline: 0 calc(var(--im-end) + 51px);
  }
  #staff-im-root .im-list-pane > .im-search-field input { padding-block: 6px; }
  #staff-im-root .im-filters {
    grid-column: 1 / -1;
    margin-block-start: 3px;
    padding-block: 1px;
  }
  #staff-im-root .im-list-scroll {
    grid-column: 1 / -1;
    padding-block-start: 7px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(208px, .78fr);
    align-content: start;
    align-items: start;
    gap: 14px;
  }
  #staff-im-root :is(.im-list-support, .im-list-results) { display: block; min-width: 0; }
  #staff-im-root .im-section-label { margin-block-end: 4px; }
  #staff-im-root .im-conversation { min-height: 58px; padding-block: 7px; }
  body.workspace-unified.is-im-page:not(.im-chat-open) .ea-launcher {
    top: calc(6px + env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 540px) and (max-height: 540px) and (orientation: landscape) {
  #staff-im-root .im-list-scroll { display: block; }
  #staff-im-root .im-list-results + .im-list-support { margin-block-start: 14px; }
}

@media (max-width: 350px) {
  #staff-im-root .im-list-head { padding-block-end: 8px; }
  #staff-im-root .im-list-head h2 { font-size: 27px; }
  #staff-im-root .im-list-pane > .im-search-field input { padding-block: 6px; }
  #staff-im-root .im-recent { margin-block-end: 9px; padding-block-end: 5px; }
  #staff-im-root .im-recent > button { min-height: 55px; gap: 4px; }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  @media (max-width: 760px), (max-width: 1000px) and (max-height: 540px) and (orientation: landscape) {
    body.workspace-unified.mw-enabled #staff-im-root { --im-bar: var(--im-surface); }
    #staff-im-root :is(.im-list-schedule, .im-recent-head, .im-recent) { background-image: none; box-shadow: none; }
  }
}

@supports (corner-shape: squircle) {
  @media (max-width: 760px), (max-width: 1000px) and (max-height: 540px) and (orientation: landscape) {
    #staff-im-root :is(.im-list-schedule, [data-im-conversations], .im-search-field, .im-new-chat, .im-dialog) {
      corner-shape: squircle;
    }
  }
}
