/* Reader controls stay outside sender-authored HTML and use workspace colors. */
html body.ev-workspace .ev-reader-toolbar {
  display:flex; flex:0 0 auto; align-items:center; gap:8px;
  position:relative; z-index:5; min-height:58px; padding:6px 18px;
  border-bottom:1px solid var(--ev-border); background:var(--ev-surface); color:var(--ev-text);
}
html body.ev-workspace .ev-reader-control {
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  min-width:44px; min-height:44px; padding:8px 10px; border:1px solid transparent;
  border-radius:9px; background:transparent; color:var(--ev-text); font:inherit;
  font-size:13px; line-height:20px; text-decoration:none; cursor:pointer; white-space:nowrap;
}
html body.ev-workspace .ev-reader-control:hover { background:var(--ev-raised); }
html body.ev-workspace .ev-reader-control.disabled { opacity:.4; cursor:default; }
html body.ev-workspace .ev-reader-control.disabled:hover { background:transparent; }
.ev-reader-back { display:none!important; }
.ev-reader-navigation { display:flex; align-items:center; margin-left:auto; }
html body.ev-workspace .ev-reader-prev,html body.ev-workspace .ev-reader-next { font-size:0; gap:0; padding:8px; }
.ev-reader-prev::before,.ev-reader-next::before { font-family:inherit!important; font-size:24px!important; line-height:24px!important; }
.ev-reader-prev::before { content:'‹'; }
.ev-reader-next::before { content:'›'; }
html body.ev-workspace .ev-reader-aa { border-color:var(--ev-control); }
.ev-reader-aa-symbol { font-weight:700; font-size:17px; }
html body.ev-workspace .ev-reader-settings {
  position:absolute; top:calc(100% + 6px); right:12px; width:304px; max-width:calc(100vw - 24px);
  padding:16px; border:1px solid var(--ev-control); border-radius:14px;
  background:var(--ev-surface); color:var(--ev-text); box-shadow:var(--ev-shadow);
}
.ev-reader-settings[hidden] { display:none!important; }
.ev-reader-setting-heading { display:flex; align-items:center; justify-content:space-between; margin:-6px -6px 10px 0; }
html body.ev-workspace .ev-reader-settings button {
  min-height:44px; border:1px solid var(--ev-control); border-radius:8px;
  font:inherit; font-size:13px; background:var(--ev-raised); color:var(--ev-text); cursor:pointer;
}
html body.ev-workspace .ev-reader-settings .ev-reader-settings-close { min-width:44px; border:0; background:transparent; font-size:24px; }
.ev-reader-scales { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:5px; }
.ev-reader-mode-heading { display:block; margin:18px 0 10px; }
.ev-reader-modes { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
html body.ev-workspace .ev-reader-settings button[aria-pressed=true] { background:var(--ev-soft); color:var(--ev-brand-strong); border-color:var(--ev-brand); font-weight:650; }
html.dark-mode body.ev-workspace .ev-reader-settings button[aria-pressed=true] { color:var(--ev-brand); }
html body.ev-workspace .ev-reader-settings .ev-reader-reset { width:100%; margin-top:16px; background:transparent; color:var(--ev-muted); }
/* One vertical scroll surface: message parts and tables have no height limits. */
html body.ev-workspace #layout-content>.frame-content { min-width:0; min-height:0; height:auto; overflow-x:hidden; overflow-y:auto; }
html body.ev-workspace #message-content,html body.ev-workspace #message-content>.rightcol,html body.ev-workspace #messagebody { min-width:0; max-width:100%; }
html body.ev-workspace #messagebody .message-htmlpart { max-height:none!important; overflow:visible; }
html body.ev-workspace #messagebody .ev-table-scroll {
  display:block; width:100%; max-width:100%; overflow-x:auto; overflow-y:hidden;
  max-height:none; -webkit-overflow-scrolling:touch; scrollbar-width:thin;
}
html body.ev-workspace #messagebody .ev-table-scroll:focus-visible { outline:2px solid var(--ev-brand); outline-offset:3px; }
html body.ev-workspace.ev-reader-fit #messagebody { overflow-wrap:anywhere; }
html body.ev-workspace.ev-reader-fit #messagebody pre { white-space:pre-wrap!important; overflow-wrap:anywhere; word-break:normal; max-width:100%; }
html body.ev-workspace.ev-reader-fit #messagebody .message-htmlpart { min-width:0!important; max-width:100%!important; width:auto!important; }
html body.ev-workspace.ev-reader-fit #messagebody img { max-width:100%!important; height:auto!important; object-fit:contain; }
html body.ev-workspace.ev-reader-fit #messagebody table.ev-layout-table { width:100%!important; max-width:100%!important; table-layout:auto!important; }
html body.ev-workspace.ev-reader-fit #messagebody table.ev-layout-table td { min-width:0!important; overflow-wrap:anywhere; }
html body.ev-workspace.ev-reader-fit #messagebody .ev-fit-container { width:auto!important; max-width:100%!important; min-width:0!important; }
html body.ev-workspace.ev-reader-fit #messagebody .ev-scaled-text { height:auto!important; max-height:none!important; }
html body.ev-workspace.ev-reader-original #messagebody .message-htmlpart { overflow-x:auto; overflow-y:hidden; }
html body.ev-workspace .ev-reader-mobile-actions { display:none; }
html:not(.iframe) body.ev-workspace.action-show .ev-reader-expand { display:none; }
html:not(.iframe) body.ev-workspace.action-show .ev-reader-back { display:inline-flex!important; }
html.iframe body.ev-reader-focused .ev-reader-back { display:inline-flex!important; }
html.iframe body.ev-reader-focused .ev-reader-expand { display:none; }
@media(max-width:768px) {
  html body.ev-workspace.action-show #layout-content>.header,
  html body.ev-workspace.action-preview #layout-content>.header { display:none; }
  html body.ev-workspace .ev-reader-toolbar { min-height:58px; padding:6px 10px; gap:4px; }
  html body.ev-workspace .ev-reader-back { display:inline-flex!important; }
  html body.ev-workspace .ev-reader-expand { display:none; }
  html body.ev-workspace .ev-reader-control { padding:8px; }
  html body.ev-workspace .ev-reader-navigation { gap:0; }
  html body.ev-workspace .ev-reader-aa { gap:5px; }
  html body.ev-workspace #layout-content>.frame-content { padding:22px 16px 30px; }
  html body.ev-workspace #message-header>.subject { font-size:23px; overflow-wrap:anywhere; }
  html body.ev-workspace #messagebody .message-htmlpart { padding:12px; }
  html body.ev-workspace .ev-reader-mobile-actions {
    display:flex; flex:0 0 auto; align-items:center; justify-content:space-between; gap:8px;
    padding:8px 12px max(8px,env(safe-area-inset-bottom));
    border-top:1px solid var(--ev-border); background:var(--ev-surface); color:var(--ev-text);
  }
  html body.ev-workspace .ev-reader-mobile-actions>a,
  html body.ev-workspace .ev-reader-replyall-group>a {
    display:inline-flex; align-items:center; justify-content:center; min-height:44px;
    border:1px solid var(--ev-control); border-radius:9px; padding:8px 12px;
    color:var(--ev-text); font-size:13px; font-weight:600; text-decoration:none; line-height:20px;
  }
  html body.ev-workspace .ev-reader-mobile-actions>a::before { display:none; }
  html body.ev-workspace .ev-reader-mobile-actions>a.ev-mobile-reply { background:var(--ev-brand); color:var(--ev-onbrand); border-color:var(--ev-brand); }
  .ev-reader-replyall-group { display:inline-flex; align-items:stretch; }
  html body.ev-workspace .ev-reader-replyall-group>.ev-mobile-replyall { border-radius:9px 0 0 9px; padding-right:8px; }
  html body.ev-workspace .ev-reader-replyall-group>.ev-reader-replyall-options { border-radius:0 9px 9px 0; min-width:44px; padding:8px; margin-left:-1px; }
  html body.ev-workspace #messagestack { bottom:calc(84px + env(safe-area-inset-bottom)); }
}
@media print {
  .ev-reader-toolbar,.ev-reader-mobile-actions { display:none!important; }
  html body.ev-workspace #messagebody .ev-table-scroll { overflow:visible; }
}
/* Standalone fullscreen reader: a consistent rail, not a clipped wide sidebar.
   Keep native labels/commands; a separate visual hint escapes short-window scrolling. */
@media (min-width:769px) {
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu { overflow:visible; z-index:20; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu .ev-brand {
    justify-content:center!important; padding:8px!important; height:64px!important; min-height:64px!important; flex:0 0 auto;
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu .ev-official-logo { width:56px!important; max-width:56px!important; height:auto; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu {
    display:flex!important; flex-direction:column; align-items:center; gap:6px; padding:4px 0; min-height:0; overflow:visible;
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu .action-buttons { width:52px; flex:0 0 auto; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a {
    position:relative; display:flex!important; flex:0 0 auto!important; flex-direction:row!important; align-items:center; justify-content:center; gap:0;
    width:52px!important; max-width:52px!important; height:44px; min-height:44px; padding:0!important; margin:0; border-radius:11px; text-align:center;
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a::before {
    display:block!important; float:none; width:22px; height:22px; font-size:20px; line-height:22px; margin:0!important;
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a:hover { background:var(--ev-raised); color:var(--ev-text); }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a.compose { background:var(--ev-brand); color:var(--ev-onbrand); box-shadow:none; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a.logout { color:var(--ev-danger); }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu .special-buttons {
    position:static!important; flex:0 0 auto; display:flex; flex-direction:column; align-items:center; gap:6px;
    width:52px; height:auto; min-height:0; flex-wrap:nowrap; margin-top:auto; padding:12px 0 4px; border-top:1px solid var(--ev-border);
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu .ev-account {
    position:relative; display:flex!important; flex:0 0 auto; justify-content:center; align-items:center;
    width:52px; height:44px; min-height:44px; padding:0; margin:0; border-radius:11px; cursor:default;
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a .inner,
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu .ev-account-name {
    /* Visually hidden only: native labels remain in the accessibility tree. */
    position:absolute; display:block!important; width:1px; height:1px; min-width:0; padding:0; margin:-1px; border:0;
    clip:rect(0,0,0,0); clip-path:inset(50%); white-space:nowrap; overflow:hidden; pointer-events:none;
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader > .ev-reader-nav-hint {
    position:fixed; max-width:min(320px,calc(100vw - 90px)); padding:7px 11px; border:1px solid var(--ev-border); border-radius:8px;
    background:var(--ev-raised); color:var(--ev-text); box-shadow:var(--ev-shadow); font-size:12px; line-height:20px;
    overflow-wrap:anywhere; pointer-events:none; z-index:200;
  }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader > .ev-reader-nav-hint[hidden] { display:none!important; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a:focus-visible,
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu .ev-account:focus-visible { outline:2px solid var(--ev-brand); outline-offset:2px; }
}
@media (min-width:769px) and (max-height:520px) {
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu .ev-brand { display:none!important; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu { gap:0; padding:0; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu .special-buttons { gap:0; padding:0; border:0; }
}
@media (min-width:769px) and (max-height:380px) {
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu { overflow-y:auto; overflow-x:hidden; padding:6px 0; scrollbar-width:thin; scrollbar-color:var(--ev-border) transparent; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu a,
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu .ev-account { scroll-margin-block:6px; }
  html:not(.iframe) body.ev-workspace.ev-standalone-reader #layout-menu #taskmenu::-webkit-scrollbar { width:6px; }
}
@media print {
  .ev-reader-nav-hint { display:none!important; }
}
