/* A dedicated phone layout over the original Elastic commands and panes. */
.xbm-navigation,
.xbm-compose-files {
  display: none;
}
@media (max-width: 480px) {
  :root {
    --xbm-divider: color-mix(in srgb, var(--xb-line) 45%, var(--xb-surface));
  }
  body.xbm-phone {
    min-width: 320px;
    background: var(--xb-surface);
  }
  .xbm-phone > .xb-topbar {
    display: none;
  }
  html body.xbm-phone #layout {
    height: 100vh;
    height: 100dvh;
    padding: 0;
    gap: 0;
    background: var(--xb-surface) !important;
  }
  html body.xbm-phone.xbm-has-navigation #layout {
    height: calc(100vh - 66px - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - 66px - env(safe-area-inset-bottom, 0px));
  }
  html body.xbm-phone #layout-list,
  html body.xbm-phone #layout-content,
  html body.xbm-phone #layout-sidebar {
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0;
    padding: 0 !important;
    box-shadow: none;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  html body.xbm-phone #layout > :not(.hidden) > .header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    height: 58px;
    min-height: 58px;
    padding: 4px 10px;
    line-height: 44px;
    background: var(--xb-surface) !important;
    border-bottom: 1px solid var(--xbm-divider) !important;
  }
  .xbm-phone #layout .header > .button.icon {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0 !important;
    line-height: 44px;
    border-radius: 12px;
    color: var(--xb-text) !important;
  }
  .xbm-phone #layout .header > .button.icon:before {
    font-size: 19px;
    line-height: 44px;
  }
  .xbm-phone #layout .header > .header-title {
    flex: 1;
    position: static;
    min-width: 0;
    margin: 0 !important;
    padding: 0 5px !important;
    font-size: 17px;
    font-weight: 600;
    text-align: left;
    color: var(--xb-text);
  }
  .xbm-phone #messagelist-header > .header-title,
  .xbm-phone #messagelist-header > .back-sidebar-button,
  .xbm-phone #messagelist-header > .xbw-view-button,
  .xbm-phone .xb-inbox-heading {
    display: none !important;
  }
  .xbm-phone #messagelist-header #xb-folder-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0 5px;
    font-size: 21px;
    line-height: 30px;
    font-weight: 700;
    letter-spacing: -0.6px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .xbm-phone #layout-list > .searchbar {
    margin: 14px 16px 10px;
    min-height: 48px;
    height: 48px;
    border: 1px solid var(--xbm-divider) !important;
    border-radius: 14px;
    background: var(--xb-soft);
  }
  .xbm-phone .searchbar input {
    font-size: 16px;
  }
  .xbm-phone .searchbar .xbw-search-filters {
    height: 40px;
    margin-right: 3px;
    font-size: 11px;
    border: 0;
    background: transparent;
  }
  .xbm-phone .xb-inbox-tabs {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--xbm-divider);
    flex-shrink: 0;
  }
  .xbm-phone .xb-inbox-tabs button {
    flex: 1;
    min-width: 0;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 6px;
    background: transparent;
    color: var(--xb-muted);
    font: 500 11px/20px var(--xb-font);
  }
  .xbm-phone .xb-inbox-tabs button[aria-pressed='true'] {
    color: var(--xb-blue);
    background: var(--xb-selected) !important;
    border-color: color-mix(in srgb, var(--xb-blue) 20%, transparent);
    font-weight: 600;
  }
  .xbm-phone .xb-inbox-tabs span:before {
    font: 900 13px Icons;
    margin-right: 5px;
  }
  .xbm-phone #messagelist {
    border-top: 0;
  }
  .xbm-phone #messagelist td {
    border-bottom: 1px solid var(--xbm-divider) !important;
  }
  .xbm-phone #messagelist td.subject {
    display: block;
    padding: 14px 38px 14px 66px !important;
    min-height: 102px;
    box-shadow: none;
  }
  .xbm-phone #messagelist td.subject:before {
    top: 19px;
    left: 16px;
    height: 36px;
    width: 36px;
    border-radius: 13px;
    font-size: 11px;
    font-weight: 600;
  }
  .xbm-phone #messagelist span.fromto {
    display: block;
    width: calc(100% - 65px);
    padding: 0 !important;
    font-size: 14px;
    line-height: 22px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .xbm-phone #messagelist tr.unread span.fromto,
  .xbm-phone #messagelist tr.unread span.subject {
    font-weight: 700;
  }
  .xbm-phone #messagelist .date {
    position: absolute;
    top: 16px;
    right: 15px;
    font-size: 10px;
    font-weight: 400;
  }
  .xbm-phone #messagelist span.subject {
    display: block;
    font-size: 13px;
    line-height: 21px;
    font-weight: 400;
    color: var(--xb-text);
    margin-top: 0;
  }
  .xbm-phone #messagelist .xb-message-preview {
    display: block;
    font-size: 12px;
    line-height: 20px;
    color: var(--xb-muted);
    font-weight: 400;
  }
  .xb-compact .xbm-phone #messagelist td.subject {
    min-height: 78px;
  }
  .xb-compact .xbm-phone #messagelist .xb-message-preview {
    display: none;
  }
  .xbm-phone #messagelist-content {
    padding-bottom: 72px;
  }
  .xbm-phone #layout-list > .footer {
    min-height: 44px;
    height: 44px;
    background: var(--xb-surface);
    border-color: var(--xbm-divider);
    font-size: 10px;
  }
  .xbm-phone #layout-list > .footer a {
    min-width: 36px;
    min-height: 40px;
  }
  .xbm-phone .xbm-navigation:not([hidden]) {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: calc(66px + env(safe-area-inset-bottom, 0px));
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--xbm-divider);
    background: var(--xb-surface);
    box-shadow: 0 -4px 20px #10294406;
  }
  body.xbm-phone .xbm-navigation button {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    background: transparent !important;
    color: var(--xb-muted) !important;
    font: 500 10px/16px var(--xb-font);
  }
  body.xbm-phone .xbm-navigation button[aria-current='page'] {
    background: var(--xb-selected) !important;
    color: var(--xb-blue) !important;
  }
  .xbm-action:before {
    display: block;
    font: 900 19px/22px Icons;
  }
  .xbm-icon-inbox:before {
    content: '\f01c';
  }
  .xbm-icon-folders:before {
    content: '\f07b';
  }
  .xbm-icon-contacts:before {
    content: '\f0c0';
  }
  .xbm-icon-menu:before {
    content: '\f0c9';
  }
  .xbm-icon-attach:before {
    content: '\f0c6';
  }
  .xbm-icon-options:before {
    content: '\f1de';
  }
  .xbm-phone.xbm-has-navigation .floating-action-buttons {
    bottom: 62px;
    right: 18px;
  }
  .xbm-phone .floating-action-buttons a.compose {
    height: 54px;
    min-width: 54px;
    background: var(--xb-blue) !important;
    color: var(--xb-on-accent) !important;
    border-radius: 18px !important;
    box-shadow: 0 6px 22px #0288d130 !important;
  }
  .xbm-phone .folderlist li a {
    min-height: 48px;
    padding: 12px 40px 12px 52px !important;
    font-size: 14px;
    font-weight: 500;
    border-radius: 12px;
    margin: 2px 10px;
  }
  .xbm-phone .folderlist li a:before {
    left: 16px;
    font-size: 18px;
  }
  .xbm-phone .xb-compose-wrap {
    display: none;
  }
  .xbm-phone .xb-section-label {
    padding: 16px 24px 8px;
  }
  .xbm-phone #folderlist-content {
    padding-bottom: 12px;
  }
  .xbm-phone #layout-menu {
    width: min(300px, calc(100vw - 40px)) !important;
    max-width: calc(100vw - 40px) !important;
  }
  .xbm-phone .ui-dialog {
    position: fixed !important;
    top: 8px !important;
    left: 8px !important;
    width: calc(100vw - 16px) !important;
    height: auto !important;
    max-height: calc(100dvh - 16px) !important;
    overflow: hidden;
    max-width: calc(100vw - 16px) !important;
    border-radius: 18px;
  }
  .xbm-phone .ui-dialog .xbw-grid {
    grid-template-columns: 1fr;
  }
  .xbm-phone .ui-dialog button.btn {
    min-height: 42px;
  }
  .xbm-phone .ui-dialog .ui-dialog-content {
    height: auto !important;
    max-height: calc(100dvh - 140px) !important;
    overflow-y: auto !important;
  }
  .xbm-phone .ui-dialog .xbw-dialog {
    max-height: none;
    overflow: visible;
    padding: 0 4px;
  }
  .xbm-phone .ui-dialog .xbw-field {
    margin: 10px 0;
  }
  .xbm-phone .ui-dialog .ui-dialog-titlebar {
    padding-right: 48px;
  }
  .xbm-phone .ui-dialog .ui-dialog-titlebar-close {
    display: block !important;
    right: 6px;
    top: 8px;
    width: 40px;
    height: 40px;
    margin: 0;
    color: var(--xb-text);
  }
  .xbm-phone .ui-dialog .xbw-field input,
  .xbm-phone .ui-dialog .xbw-field select,
  .xbm-phone .ui-dialog .xbw-field textarea {
    font-size: 16px;
  }
  .xbm-phone #messagestack {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    max-width: calc(100vw - 24px);
  }
  .xbm-phone.xbm-has-navigation #messagestack {
    bottom: calc(116px + env(safe-area-inset-bottom, 0px));
  }
  /* Keep the native rich editor and sending footer, with direct attachment access. */
  .xbm-phone.action-compose #layout-content > .header > .task-menu-button,
  .xbm-phone.action-compose #layout-content > .header > .header-title {
    display: none;
  }
  .xbm-phone.action-compose .xb-compose-title {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .xbm-phone.action-compose .xb-compose-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
  }
  .xbm-phone.action-compose .xb-compose-title > a {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  .xbm-phone.action-compose #compose-content {
    padding: 8px 16px 0;
  }
  .xbm-phone.action-compose #compose-headers .form-group {
    margin: 0;
    padding: 7px 0;
    border-color: var(--xbm-divider);
  }
  .xbm-phone.action-compose #compose-headers .col-2 {
    flex: 0 0 48px;
    max-width: 48px;
    padding: 8px 0;
    font-size: 12px;
    font-weight: 500;
  }
  .xbm-phone.action-compose #compose-headers .col-10 {
    padding: 0;
    min-width: 0;
  }
  .xbm-phone.action-compose #compose-headers input,
  .xbm-phone.action-compose #compose-headers select,
  .xbm-phone.action-compose #compose-headers textarea {
    font-size: 16px;
  }
  .xbm-phone.action-compose #compose-headers .form-control {
    min-height: 42px;
    border-color: var(--xbm-divider);
    border-radius: 10px;
    background-color: var(--xb-surface);
  }
  .xbm-phone.action-compose #compose-headers .recipient-input input {
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
  }
  .xbm-phone.action-compose #compose-headers .recipient-input:focus-within {
    border-color: var(--xb-blue);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--xb-blue) 18%, transparent);
  }
  .xbm-phone.action-compose #compose_to .input-group {
    flex-wrap: wrap;
  }
  .xbm-phone.action-compose #compose_to .recipient-input {
    flex: 1 1 calc(100% - 88px);
    min-width: 90px;
  }
  .xbm-phone.action-compose #compose_to .input-group-append > a {
    min-height: 42px;
    min-width: 36px;
    justify-content: center;
  }
  .xbm-phone.action-compose .xb-recipient-shortcuts {
    flex-basis: 100%;
    justify-content: flex-end;
    padding-top: 2px;
  }
  .xbm-phone.action-compose .xb-recipient-shortcuts button {
    min-width: 44px;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 12px;
  }
  .xbm-phone .xbm-compose-files {
    display: block;
    padding: 10px 0 0;
  }
  .xbm-compose-actions {
    display: flex;
    gap: 8px;
  }
  body.xbm-phone .xbm-compose-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--xbm-divider);
    border-radius: 12px;
    background: var(--xb-soft) !important;
    color: var(--xb-text) !important;
    font: 500 12px var(--xb-font);
  }
  .xbm-compose-actions button:before {
    font-size: 16px;
  }
  .xbm-phone .xbm-compose-files .attachmentslist {
    margin: 10px 0 0;
    padding: 0;
    background: transparent;
  }
  .xbm-phone .xbm-compose-files .attachmentslist:empty {
    display: none;
  }
  .xbm-phone .xbm-compose-files .attachmentslist li {
    min-height: 44px;
    max-width: 100%;
    border-radius: 10px;
    background: var(--xb-soft);
    border: 1px solid var(--xbm-divider);
  }
  .xbm-phone .xb-compose-body-heading {
    padding: 12px 0 8px;
  }
  .xbm-phone .xb-compose-body-heading select {
    min-height: 40px;
    font-size: 13px;
  }
  .xbm-phone.action-compose #composebodycontainer {
    border-radius: 12px;
    border-color: var(--xbm-divider);
  }
  .xbm-phone.action-compose #composebodycontainer .tox-tinymce {
    min-height: 260px !important;
    height: 300px !important;
  }
  .xbm-phone.action-compose #composebody_ifr {
    min-height: 210px !important;
  }
  .xbm-phone.action-compose .tox .tox-toolbar__group {
    padding: 2px 0;
  }
  .xbm-phone.action-compose .tox .tox-tbtn {
    width: 36px;
    height: 38px;
    margin: 0;
  }
  .xbm-phone.action-compose #composebody {
    min-height: 260px;
    font-size: 16px;
  }
  .xbm-phone #layout-content > .footer {
    min-height: 58px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--xb-surface);
    border-top: 1px solid var(--xbm-divider);
  }
  .xbm-phone #layout-content > .footer a {
    min-height: 44px;
    font-size: 12px;
  }
  .xbm-phone #layout-content > .footer a.send,
  .xbm-phone #layout-content > .footer a.reply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 100px;
    height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    background: var(--xb-blue);
    color: var(--xb-on-accent) !important;
    margin: 7px 8px;
  }
  .xbm-phone #layout-content > .footer a.send:before,
  .xbm-phone #layout-content > .footer a.reply:before {
    float: none;
    margin: 0;
    width: auto;
    line-height: 1;
  }
  /* Read content is in an original Roundcube iframe, without the shell class. */
  html.iframe #message-header {
    padding: 22px 18px 14px !important;
  }
  html.iframe #message-header .subject {
    font-size: 22px;
    line-height: 1.4;
    font-weight: 600;
    margin-bottom: 20px;
  }
  html.iframe #message-content {
    padding: 16px 18px !important;
  }
  html.iframe #messagebody .pre {
    font-size: 15px;
    line-height: 1.8;
  }
  html.iframe .xbw-sender-avatar {
    width: 38px;
    min-width: 38px;
    height: 38px;
    border-radius: 13px;
    margin-right: 10px;
  }
  html.iframe .xbw-sender-address {
    font-size: 12px;
  }
  html.iframe #message-header .header-links {
    gap: 8px;
  }
  html.iframe #message-header .header-links a {
    padding: 5px 9px;
    min-height: 34px;
    border-radius: 8px;
    background: var(--xb-soft);
  }
  html.iframe .xbw-quick-reply {
    margin: 22px 0 12px;
    padding: 16px;
    border-color: var(--xbm-divider);
  }
  html.iframe .xbw-quick-reply .btn {
    min-height: 42px;
    font-size: 12px;
  }
}
