/* Stage 1: desktop mail-shell geometry only.  Rules are confined to the
 * authenticated three-pane mail workspace; Login, Compose and other tasks
 * retain upstream Elastic geometry. */
@media (min-width: 1200px) {
  body.task-mail.action-none {
    --neima-blue: #2147bd;
    --neima-ink: #14203a;
    --neima-muted: #6e7890;
    --neima-line: #e6eaf1;
    --neima-sidebar: #f8faff;
  }

  body.task-mail.action-none #layout-menu {
    display: none;
  }

  body.task-mail.action-none #layout {
    height: calc(100vh - 60px);
    margin-top: 60px;
    background: #fff;
  }

  body.task-mail.action-none #neima-global-header {
    position: fixed;
    z-index: 35;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    align-items: center;
    height: 60px;
    box-sizing: border-box;
    background: #fff;
    border-bottom: 1px solid var(--neima-line);
    color: var(--neima-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-none #neima-global-header .neima-brand {
    display: flex;
    align-items: center;
    width: 216px;
    height: 100%;
    box-sizing: border-box;
    padding: 0 20px;
    background: var(--neima-ink);
    border-right: 1px solid var(--neima-line);
  }

  body.task-mail.action-none #neima-official-logo {
    display: block;
    width: 108px;
    max-height: 30px;
    object-fit: contain;
    object-position: left center;
  }

  body.task-mail.action-none #mailsearchform {
    position: fixed;
    z-index: 42;
    top: 12px;
    left: 50%;
    width: 480px;
    height: 36px;
    box-sizing: border-box;
    margin: 0;
    padding: 0 14px 0 38px;
    transform: translateX(-50%);
    border: 1px solid #e2e7ef;
    border-radius: 5px;
    background: #f6f8fc;
    box-shadow: none;
    color: var(--neima-ink);
    font: 400 14px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }
  body.task-mail.action-none #mailsearchform::placeholder { color: transparent; }

  body.task-mail.action-none #neima-search-icon {
    position: fixed;
    z-index: 43;
    top: 16px;
    left: calc(50% - 228px);
    color: var(--neima-muted);
    font: 22px/22px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    pointer-events: none;
  }

  body.task-mail.action-none #neima-search-placeholder {
    position: fixed;
    z-index: 43;
    top: 21px;
    left: calc(50% - 202px);
    color: var(--neima-muted);
    font: 400 14px/18px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    pointer-events: none;
  }
  body.task-mail.action-none:has(#mailsearchform:not(:placeholder-shown)) #neima-search-placeholder { display: none; }

  body.task-mail.action-none #neima-profile {
    position: fixed;
    z-index: 44;
    top: 10px;
    right: 18px;
    color: var(--neima-ink);
  }

  body.task-mail.action-none #neima-profile summary {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 0 4px;
    cursor: pointer;
    list-style: none;
    font: 600 13px/18px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-none #neima-profile summary::-webkit-details-marker { display: none; }
  body.task-mail.action-none .neima-avatar {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: var(--neima-ink);
    color: #fff;
    font-size: 12px;
  }
  body.task-mail.action-none .neima-profile-chevron { color: var(--neima-muted); font-size: 16px; }
  body.task-mail.action-none .neima-profile-menu {
    position: absolute;
    top: 46px;
    right: 0;
    min-width: 164px;
    padding: 6px;
    border: 1px solid var(--neima-line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(20, 32, 58, .10);
  }
  body.task-mail.action-none .neima-profile-menu a {
    display: block;
    padding: 8px 10px;
    border-radius: 4px;
    color: var(--neima-ink);
    font: 500 13px/18px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-decoration: none;
  }
  body.task-mail.action-none .neima-profile-menu a:hover { background: #f0f4fb; }

  body.task-mail.action-none #layout-sidebar {
    flex: 0 0 216px;
    width: 216px;
    min-width: 0;
    max-width: none;
    background: var(--neima-sidebar);
    border-right: 1px solid var(--neima-line);
  }

  body.task-mail.action-none #layout-list {
    flex: 0 0 400px;
    width: 400px;
    min-width: 0;
    max-width: none;
  }

  body.task-mail.action-none #layout-content {
    flex: 1 1 0;
    min-width: 0;
    background: #fff;
  }

  body.task-mail.action-none #layout-list {
    background: #fff;
    border-right-color: var(--neima-line);
  }

  body.task-mail.action-none #layout-list > .header,
  body.task-mail.action-none #layout-content > .header {
    background: #fff;
    border-bottom: 1px solid var(--neima-line);
    box-shadow: none;
  }

  body.task-mail.action-none #layout-list,
  body.task-mail.action-none #layout-content,
  body.task-mail.action-none #layout-list .header,
  body.task-mail.action-none #layout-content > .header {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--neima-ink);
  }

  body.task-mail.action-none #layout-list .header .button,
  body.task-mail.action-none #layout-content > .header .button {
    opacity: .82;
  }

  body.task-mail.action-none #layout-list .header .button:hover,
  body.task-mail.action-none #layout-content > .header .button:hover {
    opacity: 1;
    background: #f4f7fb;
  }

  body.task-mail.action-none #messagelist-content,
  body.task-mail.action-none #layout-content .iframe-wrapper {
    background: #fff;
  }

  body.task-mail.action-none #messagelist td {
    color: var(--neima-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-none #messagelist tr.selected td {
    background: #eef3ff;
  }

  body.task-mail.action-none #layout-content .iframe-wrapper:has(iframe[src*="watermark"]) {
    background: #fff;
  }

  body.task-mail.action-none #layout-content .iframe-wrapper:has(iframe[src*="watermark"]) iframe {
    visibility: hidden;
  }

  body.task-mail.action-none #neima-empty-state {
    position: fixed;
    z-index: 8;
    top: 60px;
    right: 0;
    bottom: 0;
    left: 616px;
    display: grid;
    place-items: center;
    padding: 0 24px;
    pointer-events: none;
    color: var(--neima-muted);
    background: transparent;
    font: 400 15px/22px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-align: center;
  }

  body.task-mail.action-none:has(#messagelist tr.selected) #neima-empty-state {
    display: none;
  }

  body.task-mail.action-none #layout-sidebar > .header {
    display: none;
  }

  body.task-mail.action-none #folderlist-content {
    padding: 68px 10px 20px;
  }

  body.task-mail.action-none #mailboxlist {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  body.task-mail.action-none #mailboxlist > .inbox { order: 1; }
  body.task-mail.action-none #mailboxlist > .sent { order: 2; }
  body.task-mail.action-none #mailboxlist > .drafts { order: 3; }
  body.task-mail.action-none #mailboxlist > .archive { order: 4; }
  body.task-mail.action-none #mailboxlist > .junk { order: 6; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--neima-line); }
  body.task-mail.action-none #mailboxlist > .trash { order: 7; }

  body.task-mail.action-none #mailboxlist > li > a {
    min-height: 38px;
    padding: 8px 10px;
    border: 0;
    border-radius: 5px;
    color: var(--neima-ink);
    font: 500 14px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-none #mailboxlist > li.selected > a {
    background: #eaf0ff;
    color: var(--neima-ink);
    font-weight: 650;
  }

  body.task-mail.action-none #mailboxlist > li > a:hover {
    background: #f0f4fb;
  }

  body.task-mail.action-none #folderlist-content::after {
    content: "ПАПКИ";
    display: block;
    margin: 22px 10px 0;
    color: var(--neima-muted);
    font: 700 10px/14px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: .08em;
  }

  body.task-mail.action-none #neima-sidebar-actions {
    position: fixed;
    z-index: 40;
    top: 72px;
    left: 12px;
    width: 192px;
  }

  body.task-mail.action-none #neima-sidebar-actions .neima-compose {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 42px;
    box-sizing: border-box;
    padding: 0 14px;
    overflow: hidden;
    border: 1px solid var(--neima-blue);
    border-radius: 5px;
    background: var(--neima-blue);
    color: #fff;
    box-shadow: none;
    font: 650 14px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-decoration: none;
    white-space: nowrap;
  }

  body.task-mail.action-none #neima-sidebar-actions .neima-compose .inner::before {
    content: "+ ";
    font-size: 18px;
    font-weight: 400;
  }

  /* Stage 3: Informative Message List B.  This uses only the message-list
   * fields emitted by upstream Roundcube (from/to, date, subject, flags).
   * It deliberately does not manufacture a body preview: core does not put
   * one in this list's DOM. */
  body.task-mail.action-none #messagelist-content {
    overflow-x: hidden;
  }

  body.task-mail.action-none #messagelist,
  body.task-mail.action-none #messagelist > tbody {
    display: block;
    width: 100%;
  }

  body.task-mail.action-none #messagelist > thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message {
    position: relative;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) 24px;
    align-items: stretch;
    width: 100%;
    height: 66px;
    box-sizing: border-box;
    padding: 8px 10px 7px 8px;
    border: 0;
    border-bottom: 1px solid #edf0f5;
    background: #fff;
    color: var(--neima-ink);
    cursor: pointer;
    transition: background-color .12s ease;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message:hover {
    background: #f6f8fc;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message.selected,
  body.task-mail.action-none #messagelist > tbody > tr.message.focused.selected {
    background: #eaf0ff;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td {
    min-width: 0;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.selection {
    display: grid;
    grid-column: 1;
    place-items: center start;
    padding-top: 2px;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.selection input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--neima-blue);
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.subject {
    display: grid;
    grid-column: 2;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 20px 20px;
    align-content: start;
    min-width: 0;
    padding-right: 6px;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message .fromto {
    display: block;
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
    color: var(--neima-ink);
    font: 500 14px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message .fromto .adr,
  body.task-mail.action-none #messagelist > tbody > tr.message .fromto .rcmContactAddress {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message .date {
    display: block;
    grid-column: 2;
    grid-row: 1;
    max-width: 92px;
    overflow: hidden;
    color: var(--neima-muted);
    font: 500 12px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message .size {
    display: none;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.subject > .subject {
    display: flex;
    grid-column: 1 / span 2;
    grid-row: 2;
    align-items: center;
    min-width: 0;
    overflow: hidden;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.subject > .subject a {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: #4e5a70;
    font: 400 13px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.subject > .subject a > span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.flags {
    display: grid;
    grid-column: 3;
    grid-template-rows: 20px 20px;
    align-content: start;
    justify-items: center;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.flags .flag {
    display: none;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.flags .attachment {
    display: grid;
    grid-row: 2;
    width: 16px;
    height: 20px;
    place-items: center;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message > td.flags .attachment > span {
    display: block;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message.unread::after,
  body.task-mail.action-none #messagelist > tbody > tr.message:has(.msgicon.unread)::after {
    position: absolute;
    top: 29px;
    left: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neima-blue);
    content: "";
  }

  body.task-mail.action-none #messagelist > tbody > tr.message.unread .fromto,
  body.task-mail.action-none #messagelist > tbody > tr.message:has(.msgicon.unread) .fromto {
    font-weight: 700;
  }

  body.task-mail.action-none #messagelist > tbody > tr.message.unread > td.subject > .subject a,
  body.task-mail.action-none #messagelist > tbody > tr.message:has(.msgicon.unread) > td.subject > .subject a {
    color: var(--neima-ink);
    font-weight: 650;
  }
}

/* RC1 Reading Pane and native Compose.  These selectors deliberately target
 * only authenticated mail actions; Elastic continues to own login/settings
 * and all message rendering behavior. */
@media (min-width: 1200px) {
  body.task-mail.action-show,
  body.task-mail.action-compose {
    --neima-blue: #2147bd;
    --neima-ink: #14203a;
    --neima-muted: #6e7890;
    --neima-line: #e6eaf1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-show #layout-content {
    background: #fff;
  }

  body.task-mail.action-show #message-header {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 42px 22px;
    border-bottom: 1px solid var(--neima-line);
  }

  body.task-mail.action-show #message-header .subject {
    margin: 0 0 22px;
    color: var(--neima-ink);
    font: 650 24px/32px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-show #message-header .header {
    align-items: flex-start;
  }

  body.task-mail.action-show #message-header .contactphoto {
    width: 36px;
    height: 36px;
    margin-right: 12px;
    border-radius: 50%;
    background: #eaf0ff;
  }

  body.task-mail.action-show #message-header .header-content {
    color: var(--neima-ink);
    font: 400 14px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-show #message-header .header-headers,
  body.task-mail.action-show #message-header .header-links {
    color: var(--neima-muted);
    font-size: 13px;
  }

  body.task-mail.action-show #message-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 26px 42px 48px;
  }

  body.task-mail.action-show #message-content .leftcol {
    margin: 0 0 20px;
  }

  body.task-mail.action-show #message-content .attachmentslist {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  body.task-mail.action-show #message-content .rightcol {
    max-width: 760px;
    color: #26334d;
    font: 400 15px/24px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-show #messagetoolbar,
  body.task-mail.action-none #layout-content > .header #toolbar-menu {
    display: flex;
    gap: 2px;
    align-items: center;
  }

  body.task-mail.action-none #layout-content > .header #toolbar-menu > li:nth-child(n+8) {
    display: none;
  }

  body.task-mail.action-none #layout-content > .header #toolbar-menu .button,
  body.task-mail.action-none #layout-content > .header #toolbar-menu a {
    border-radius: 5px;
    color: var(--neima-ink);
  }

  body.task-mail.action-compose #layout-menu {
    display: none;
  }

  body.task-mail.action-compose #layout {
    min-height: 100vh;
    background: #f6f8fc;
  }

  body.task-mail.action-compose #layout-sidebar {
    flex: 0 0 272px;
    width: 272px;
    background: #fff;
    border-right: 1px solid var(--neima-line);
  }

  body.task-mail.action-compose #layout-content {
    min-width: 0;
    background: #fff;
  }

  body.task-mail.action-compose #layout-content > .header {
    min-height: 60px;
    padding: 0 24px;
    border-bottom: 1px solid var(--neima-line);
    background: #fff;
  }

  body.task-mail.action-compose #layout-content > .header .header-title {
    color: var(--neima-ink);
    font: 650 18px/24px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-compose #compose-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 32px 42px 36px;
    background: #fff;
  }

  body.task-mail.action-compose #compose-headers {
    padding: 0 0 16px;
    border-bottom: 1px solid var(--neima-line);
  }

  body.task-mail.action-compose #compose-headers .form-group {
    margin-bottom: 12px;
  }

  body.task-mail.action-compose #compose-headers .col-form-label {
    color: var(--neima-muted);
    font: 600 13px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-compose #compose-headers input,
  body.task-mail.action-compose #compose-headers textarea,
  body.task-mail.action-compose #composebody {
    border-color: #dfe5ee;
    box-shadow: none;
    color: var(--neima-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  body.task-mail.action-compose #composebodycontainer {
    margin-top: 18px;
  }

  body.task-mail.action-compose #composebody {
    min-height: 360px;
    padding: 18px;
    line-height: 1.55;
  }

  body.task-mail.action-compose #compose-attachments {
    padding: 22px 18px;
  }

  body.task-mail.action-compose #compose-attachments .attach {
    width: 100%;
    border-color: #dfe5ee;
    background: #fff;
    color: var(--neima-ink);
  }

  body.task-mail.action-compose .formbuttons {
    display: flex;
    align-items: center;
    min-height: 64px;
    margin-top: 16px;
  }

  body.task-mail.action-compose .formbuttons .send {
    min-width: 148px;
    border-color: var(--neima-blue);
    border-radius: 5px;
    background: var(--neima-blue);
    font-weight: 650;
  }
}
