/* Side menu: Always open (default) / Collapsed / Auto.
   Settings › General › Side menu → localStorage inbox_sidebar_mode →
   <html data-sidebar="collapsed|auto">; .sb-peek on <html> while the full
   menu floats open over the email list. Desktop only (≥768px). Nothing here
   applies without data-sidebar, so Always open is today's layout untouched. */

@media (min-width: 768px) {
  html[data-sidebar] main.layout { --side-w: 64px; }

  html[data-sidebar] #sideNav {
    position: relative; z-index: 45; width: 64px; overflow: hidden;   /* no white-space:nowrap here — it lines the Assistant rows (inline buttons) up on one line */
    transition: width .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease;
  }
  html[data-sidebar].sb-peek #sideNav {
    width: 260px; z-index: 60;
    box-shadow: 12px 0 32px -12px rgba(15,23,42,.28);
  }
  .dark html[data-sidebar].sb-peek #sideNav, html.dark[data-sidebar].sb-peek #sideNav { box-shadow: 12px 0 32px -12px rgba(0,0,0,.6); }

  /* ---------- the icon strip (collapsed, not peeking) ---------- */
  html[data-sidebar]:not(.sb-peek) #sideNav .px-3 { padding-left: 8px !important; padding-right: 8px !important; }
  /* Compose: the pen sits at the same spot strip or open (strip centre = 12px gutter + 40px/2 = 32px;
     open = 12 + 1 border + 11 pad + 16/2 = 32px) and the label is clipped + faded, so opening never
     reflows the button mid-slide (it used to wrap "New message" round the pen at 64px wide). */
  html[data-sidebar] #composeBtn { justify-content: flex-start; gap: .5rem; height: 44px; padding: 0 0 0 11px; white-space: nowrap; overflow: hidden; }
  html[data-sidebar] #composeBtn i { font-size: 1rem; width: 16px; text-align: center; flex-shrink: 0; }
  html[data-sidebar] #composeBtn .compose-label { transition: opacity .15s ease .06s; }
  html[data-sidebar]:not(.sb-peek) #composeBtn .compose-label { opacity: 0; transition: none; }
  html[data-sidebar]:not(.sb-peek) #sideNav .sb-folders-label { visibility: hidden; height: 4px; margin: 0; overflow: hidden; }

  /* Assistant folders: heading off, the coloured squares stay (unless folded) */
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-virtual { padding: 0; }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-vf-head { display: none; }
  /* folded Assistant folders stay folded in the strip */
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-virtual.is-collapsed { display: none; }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-vf-inner > .space-y-1 { padding: 0 !important; }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-btn { position: relative; padding: 0 !important; height: 44px; display: grid; place-items: center; }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-btn > span { display: contents; }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-btn > span > span:not(.folder-badge):not(.nr-folder-badge) { display: contents; }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-btn .truncate { display: none; }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-chip { margin: 0; width: 22px; height: 22px; font-size: .72rem; border-radius: 6px; }

  /* Folders: icon only, subfolders hidden, counts as a small bubble */
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder] {
    position: relative; padding: 0 !important; height: 44px; display: grid; place-items: center;
  }
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder]:not([style*="(0px"]):not([style*="+ 0px"]) { display: none; }   /* subfolders (indent > 0; Chrome writes calc(0px + .75rem)) */
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder] > span,
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder] > span > span:not(.folder-badge) { display: contents; }   /* never the count bubble */
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder] .folder-chev,
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder] .truncate { display: none; }
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder] i { margin: 0 !important; font-size: 1.05rem; }

  html[data-sidebar]:not(.sb-peek) #sideNav .folder-badge,
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-badge {
    position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px;
    font-size: 10px; line-height: 16px; margin: 0 !important; pointer-events: none;
  }
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-badge:not(.hidden) { background: var(--surface); }

  /* Footer: version pill swaps for the toggle in the strip */
  html[data-sidebar]:not(.sb-peek) #aboutPill { display: none; }
}

/* Toggle / pin button (built by js/sidebar-rail.src.js) */
.sb-toggle {
  display: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text-muted); cursor: pointer; place-items: center; flex-shrink: 0;
}
.sb-toggle:hover { background: var(--surface-2); color: var(--text); }
.sb-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (min-width: 768px) { .sb-toggle { display: inline-grid; } }
.sb-foot { display: flex; align-items: center; justify-content: center; gap: 6px; }
html[data-sidebar].sb-peek .sb-foot { justify-content: space-between; }

@media (prefers-reduced-motion: reduce) { html[data-sidebar] #sideNav { transition: none; } }

/* Icon-strip tooltip (name + count), built by js/sidebar-rail.src.js */
.sb-tip {
  position: fixed; z-index: 70; transform: translate(-4px, -50%); opacity: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 10px;
  background: #0f172a; color: #f8fafc; font-size: 13px; font-weight: 500; line-height: 1.2; white-space: nowrap;
  box-shadow: 0 8px 24px -8px rgba(15,23,42,.45); transition: opacity .12s ease, transform .12s ease;
}
.sb-tip::before {
  content: ''; position: absolute; left: -4px; top: 50%; width: 8px; height: 8px; background: inherit;
  transform: translateY(-50%) rotate(45deg); border-radius: 1px;
}
.sb-tip.is-on { opacity: 1; transform: translate(0, -50%); }
.sb-tip-count { font-size: 12px; font-weight: 500; color: #93c5fd; }
.dark .sb-tip { background: #334155; color: #f1f5f9; box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 10px 28px -8px rgba(0,0,0,.7); }
.dark .sb-tip-count { color: #93c5fd; }
@media (prefers-reduced-motion: reduce) { .sb-tip { transition: none; } }

/* Strip shows only the everyday folders; Archive / Spam / Trash stay in the full menu. */
@media (min-width: 768px) {
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder$="Archive" i],
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder$="Junk" i],
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder$="Spam" i],
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder$="Trash" i],
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder*="Deleted" i],
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-btn[data-nr-folder="ignored"] { display: none; }
}

/* Strip = main folders only: Inbox, Drafts, Scheduled, Sent (any server spelling).
   Everything else (your own folders included) is one click / hover away in the full menu. */
@media (min-width: 768px) {
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder]:not([data-folder="INBOX"]):not([data-folder="__drafts__"]):not([data-folder="__scheduled__"]):not([data-folder$="Sent" i]):not([data-folder*="Sent Items" i]):not([data-folder*="Sent Messages" i]) { display: none; }
}

/* Where am I (js/sidebar-rail.src.js markCurrent): the strip keeps the current
   folder on show with an accent bar, and its name sits above the email list. */
.sb-where { display: none; }
@media (min-width: 768px) {
  html[data-sidebar]:not(.sb-peek) #foldersList button[data-folder][data-sb-current],
  html[data-sidebar]:not(.sb-peek) #sideNav .nr-folder-btn[data-sb-current] { display: grid !important; }
  html[data-sidebar]:not(.sb-peek) #sideNav [data-sb-current]::before {
    content: ''; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--accent, #2563eb);
  }
  /* the searchbar is a 3-column grid (index.php); the name takes an extra first column */
  html[data-sidebar] .col-mail .searchbar:has(> .sb-where:not([hidden])) { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  html[data-sidebar] .col-mail .sb-where {
    display: block; max-width: 11rem; padding-left: .25rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: .95rem; font-weight: 600; color: var(--text);
  }
  html[data-sidebar] .col-mail .sb-where[hidden] { display: none; }
}

/* Duo open landscape (html.is-duo.duo-land): the unread / advanced-search buttons moved to the Assistant FAB stack, so the list header is
   [folder name | search | flag] on ONE row. Beats the wide-touch 3-column !important rule (index.php) with its own !important. */
html.is-duo.duo-land[data-sidebar] .col-mail .searchbar:has(> .sb-where) { grid-template-columns: auto minmax(0, 1fr) auto !important; }
html.is-duo.duo-land .col-mail .searchbar > div:empty { display: none; }
html.is-duo.duo-land .col-mail .searchbar > .sb-where { max-width: none; overflow: visible; text-overflow: clip; }

/* Duo open landscape: the list / reader divider (js/shared-ext.src.js colMailResizer, normally only >=1101px) works by touch.
   The list column follows --col-mail-w (default = the wide-touch clamp), the handle is a 28px invisible hit area on the pane edge
   with a slim visible grip; touch-action:none lets the pointer events drag instead of scrolling. */
html.is-duo.duo-land main.layout { grid-template-columns: var(--side-w, 64px) var(--col-mail-w, clamp(300px, 36vw, 360px)) minmax(0, 1fr) !important; }
html.is-duo.duo-land .col-mail-resizer { display: block; width: 28px; right: -14px; touch-action: none; }
html.is-duo.duo-land .col-mail-resizer::after { width: 4px; height: 44px; opacity: .5; }
html.is-duo.duo-land .col-mail-resizer.is-dragging::after { opacity: .9; background: var(--accent, #2563eb); }

/* Side menu on the open-landscape Duo: icon strip that floats over the list, no pin. One smooth overlay transition (width + shadow,
   compositor-friendly), the list column never reflows; touch must not wake the hover-style auto mode. */
.sb-duo-note { display: none; }
html.is-duo.duo-land .sb-duo-note { display: block; }
html.is-duo.duo-land[data-sidebar] #sideNav { position: relative; will-change: width; touch-action: manipulation; }
html.is-duo.duo-land[data-sidebar].sb-peek #sideNav { width: 240px; }
