/* Kolton Mail — custom app shell. Same token system as kolton.net,
   kolton.consulting, and the marketplace theme. */

:root{
  --ocean-900:#071a26; --ocean-800:#0a2333; --ocean-700:#0e2e42; --ocean-600:#123a53;
  --teal-500:#17a898; --teal-400:#3ec4b2; --teal-300:#8adfd2;
  --sea-600:#0f8577; --sea-700:#0b6a60;
  --sand-100:#f8f4ec; --sand-200:#efe8d9;
  --ink-900:#0c1720; --ink-700:#2b3a45; --ink-500:#55666f; --ink-400:#7d8b93;
  --line:#e6e4dc; --paper:#ffffff;

  --bg:var(--sand-100); --panel:var(--paper); --text:var(--ink-900); --muted:var(--ink-500);
  --border:var(--line); --primary:var(--teal-500); --accent:var(--sea-600);
  --hover:#faf7f1; --selected-bg:#e8f6f3; --danger:#c0392b;

  --font-display:"Space Grotesk",system-ui,sans-serif;
  --font-serif:"Fraunces",Georgia,serif;
  --font-body:"Inter",system-ui,-apple-system,sans-serif;
  --radius:12px; --radius-lg:20px; --radius-xl:26px;
  /* Tighter blur + a close, defined layer under each one instead of one
     big diffuse spread -- reads as a crisp edge, not a soft glow. */
  --shadow-sm:0 1px 2px rgba(12,23,32,.07),0 2px 6px rgba(12,23,32,.05);
  --shadow-md:0 2px 8px rgba(12,23,32,.06),0 10px 24px rgba(12,23,32,.10);
  --shadow-lg:0 4px 12px rgba(7,26,38,.10),0 20px 44px rgba(7,26,38,.16);
  --ease:cubic-bezier(.22,.61,.36,1);
}

html[data-theme="dark"]{
  --bg:var(--ocean-900); --panel:var(--ocean-800); --text:#ffffff; --muted:#8fa6b1;
  --border:var(--ocean-600); --hover:var(--ocean-700); --selected-bg:var(--ocean-700);
  --shadow-sm:0 1px 2px rgba(0,0,0,.3),0 2px 6px rgba(0,0,0,.2);
  --shadow-md:0 2px 10px rgba(0,0,0,.3),0 12px 28px rgba(0,0,0,.32);
  --shadow-lg:0 4px 16px rgba(0,0,0,.35),0 24px 50px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark){
  html:not([data-theme="light"]){
    --bg:var(--ocean-900); --panel:var(--ocean-800); --text:#ffffff; --muted:#8fa6b1;
    --border:var(--ocean-600); --hover:var(--ocean-700); --selected-bg:var(--ocean-700);
    --shadow-sm:0 1px 2px rgba(0,0,0,.3),0 2px 6px rgba(0,0,0,.2);
    --shadow-md:0 2px 10px rgba(0,0,0,.3),0 12px 28px rgba(0,0,0,.32);
    --shadow-lg:0 4px 16px rgba(0,0,0,.35),0 24px 50px rgba(0,0,0,.4);
  }
}

*{box-sizing:border-box}
/* The native [hidden] attribute is how every view/panel in this app is
   shown/hidden from JS. Author-stylesheet display rules (even class-level
   ones like .readpane__content{display:flex}) normally beat the browser's
   own low-priority [hidden]{display:none} default, which would silently
   leave a "hidden" element visible. Force it unconditionally instead. */
[hidden]{display:none!important}
html,body{height:100%;margin:0}
body{
  font-family:var(--font-body); background:var(--bg); color:var(--text);
  -webkit-font-smoothing:antialiased; overflow:hidden;
}
.view{height:100vh}
.view[hidden]{display:none!important}
button{font-family:inherit;cursor:pointer}
input,textarea{font-family:inherit}
::selection{background:color-mix(in srgb, var(--teal-500) 25%, transparent)}

/* Was hardcoded to the default teal's rgb() triplet, so it never moved
   when a different accent color was chosen -- same class of bug as the
   avatar colors and ::selection before they were fixed to derive from
   the active palette. scrollbar-color covers Firefox, which doesn't
   support the ::-webkit-scrollbar-* pseudo-elements at all. */
*{scrollbar-color:color-mix(in srgb, var(--teal-500) 45%, transparent) transparent}
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--teal-500) 35%, transparent);border-radius:4px}
::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb, var(--teal-500) 55%, transparent)}

/* ---------- buttons / fields (shared) ---------- */
.btn{
  font-family:var(--font-display); font-weight:600; font-size:.92rem; letter-spacing:.01em;
  padding:.78rem 1.4rem; border-radius:var(--radius); border:1px solid transparent;
  transition:transform .2s var(--ease),background .2s,box-shadow .2s;
}
.btn--primary{background:var(--primary);color:#fff}
.btn--primary:hover{transform:translateY(-1px);background:var(--sea-600)}
.btn--secondary{background:transparent;border-color:var(--border);color:var(--text)}
.btn--secondary:hover{background:var(--hover)}
.btn--danger{background:var(--danger);color:#fff}
.btn--danger:hover{transform:translateY(-1px);filter:brightness(1.08)}
.btn--block{width:100%}
.btn__spinner{display:none;width:.95em;height:.95em;margin-right:.55em;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;vertical-align:-.15em;animation:btn-spin .6s linear infinite}
.btn--secondary .btn__spinner{border-color:var(--border);border-top-color:var(--text)}
.btn.is-loading .btn__spinner{display:inline-block}
.btn.is-loading{cursor:default;opacity:.92}
@keyframes btn-spin{to{transform:rotate(360deg)}}
.icon-btn{
  display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;
  border-radius:10px;border:1px solid var(--border);background:var(--panel);color:var(--muted);
  transition:background .2s,color .2s;
}
.icon-btn:hover{background:var(--hover);color:var(--text)}
.icon-btn.is-active{background:var(--primary);border-color:var(--primary);color:#fff}

/* A visible caption under the icon, for the actions that matter enough
   (flag/archive/move/delete-ish stuff, not "sort" or "refresh") that
   someone shouldn't have to know to hover-and-wait on a tooltip to find
   out what a glyph means -- doubles as the only way to discover it at
   all on a touch device, where hover tooltips never fire. */
.icon-btn--labeled{width:auto;height:auto;min-width:44px;flex-direction:column;gap:2px;padding:.35rem .4rem;font-family:var(--font-display);font-size:.62rem;font-weight:600}
.icon-btn--labeled .icon-btn__label{line-height:1.1;white-space:nowrap}

/* Custom tooltips — icon-only buttons rely on these, since the native
   title="" tooltip is slow (~1s delay in most browsers), small, and easy
   to miss entirely. Driven by data-tooltip so it never fights the native
   one for the same element. */
[data-tooltip]{position:relative}
[data-tooltip]::after{
  content:attr(data-tooltip);position:absolute;bottom:calc(100% + 8px);left:50%;
  transform:translateX(-50%);background:var(--ocean-900);color:#fff;
  font-family:var(--font-display);font-size:.72rem;font-weight:600;
  padding:.4rem .65rem;border-radius:7px;white-space:nowrap;pointer-events:none;
  opacity:0;visibility:hidden;transition:opacity .12s ease .4s,visibility 0s linear .4s;
  z-index:200;box-shadow:var(--shadow-md);
}
[data-tooltip]:hover::after,[data-tooltip]:focus-visible::after{
  opacity:1;visibility:visible;transition-delay:.4s;
}
/* Rail buttons sit flush against the left edge — a centered tooltip
   above/below them would clip off-screen, so point these to the right. */
.rail [data-tooltip]::after{bottom:auto;left:calc(100% + 10px);top:50%;transform:translateY(-50%);border:1px solid rgba(255,255,255,.18)}

.field{display:flex;align-items:center;gap:.6rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--panel);padding:.2rem .2rem .2rem .9rem;margin-bottom:.55rem}
.field:focus-within{border-color:var(--primary);box-shadow:0 0 0 .2rem color-mix(in srgb, var(--primary) 15%, transparent)}
.field__icon{color:var(--muted);display:flex}
.field input{flex:1;border:0;background:transparent;padding:.85rem .9rem .85rem 0;font-size:1rem;color:var(--text);outline:0}
.field input::placeholder{color:var(--muted)}
.field--row{padding:.55rem .9rem;gap:.75rem}
/* Paired fields (New/Confirm password, etc.) side by side instead of
   three full-width rows stacked on top of each other -- same fields,
   noticeably less scroll. */
.field-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:.5rem}
.field-grid-2 .field{margin-bottom:0}
@media (max-width:480px){.field-grid-2{grid-template-columns:1fr}}
.field--row .field__label{font-family:var(--font-display);font-weight:600;font-size:.82rem;color:var(--muted);width:3.2rem;flex:none}
.field--row input{padding:.4rem 0}

/* Show/hide toggle wrapped around every password input in the app --
   typing a password (or a confirmation of one) completely blind, with
   no way to check what you actually typed before submitting, is real
   friction. .pw-field stands in for the bare input as the flex item in
   whatever row it's already in (a .field, a .contact-add-form, or a
   standalone .wizard-input), so it drops in without disturbing that
   row's layout. */
.pw-field{position:relative;display:flex;flex:1;min-width:0}
.pw-eye{position:absolute;right:.3rem;top:50%;transform:translateY(-50%);width:1.9rem;height:1.9rem;border:0;background:transparent;color:var(--muted);display:flex;align-items:center;justify-content:center;border-radius:7px;cursor:pointer;flex:none;padding:0}
.pw-eye:hover{background:var(--hover);color:var(--text)}
.pw-eye svg{pointer-events:none;display:block}
.field .pw-field input,.contact-add-form .pw-field input{padding-right:2.4rem}
.link-warning-card .pw-field{margin-bottom:1.2rem}
.link-warning-card .pw-field .wizard-input{margin-bottom:0;text-align:left;padding-right:2.6rem}
/* Live match feedback under a password + confirm pair, shown/hidden as
   you type instead of only surfacing a mismatch after you hit submit. */
.pw-match-hint{font-size:.8rem;margin:-.5rem 0 .8rem;transition:color .15s}
.pw-match-hint.is-bad{color:var(--danger)}
.pw-match-hint.is-good{color:var(--success,#1f9d6b)}

.muted{color:var(--muted)}
.small{font-size:.82rem}

/* ---------- brand mark (shared) ---------- */
.brand,.rail__brand{display:inline-flex;align-items:center;gap:.55rem;color:var(--text);text-decoration:none}
.brand__palm{color:var(--text)}
.brand__text{font-family:var(--font-serif);font-weight:540;font-size:1.3rem;letter-spacing:-.01em}
.brand__dot{color:var(--teal-500)}
html[data-theme="dark"] .brand__dot{color:var(--teal-400)}
@media (prefers-color-scheme:dark){html:not([data-theme=light]) .brand__dot{color:var(--teal-400)}}
.brand__sub{font-family:var(--font-display);font-weight:600;font-size:.68rem;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);margin-left:.5rem;padding-left:.65rem;border-left:1px solid var(--border)}

/* ---------- login ---------- */
#view-login{position:relative;display:flex;align-items:center;justify-content:center;background:var(--bg);padding:calc(2rem + env(safe-area-inset-top)) 1rem calc(2rem + env(safe-area-inset-bottom));overflow-y:auto;overflow-x:hidden}
#view-login::before,#view-login::after{content:'';position:absolute;inset:0;pointer-events:none;overflow:hidden}
.login-glow{position:absolute;top:20vh;left:50%;width:520px;height:420px;margin-left:-260px;pointer-events:none;background:radial-gradient(circle,color-mix(in srgb, var(--primary) 16%, transparent) 0%,transparent 70%);animation:glow-drift 22s ease-in-out infinite}
html[data-theme="dark"] .login-glow{background:radial-gradient(circle,color-mix(in srgb, var(--teal-400) 22%, transparent) 0%,transparent 70%)}
/* Was bottom:-10vh, deliberately bleeding past the page's own bottom
   edge for a soft decorative effect -- but that's real overflow inside
   #view-login's own overflow-y:auto, which is what was actually making
   the whole login page scrollable (independent of anything about the
   wizard's height -- this alone was enough to do it even on the plain
   login screen). The gradient's already transparent by 70% of its
   radius, so clipping flush with the edge instead of bleeding past it
   loses essentially none of the visible effect. */
.login-glow--2{top:auto;bottom:0;left:auto;right:8vw;width:380px;height:340px;margin-left:0;background:radial-gradient(circle,rgba(200,164,90,.14) 0%,rgba(200,164,90,0) 70%);animation:glow-drift-2 28s ease-in-out infinite}
html[data-theme="dark"] .login-glow--2{background:radial-gradient(circle,rgba(200,164,90,.12) 0%,rgba(200,164,90,0) 70%)}
@keyframes glow-drift{0%,100%{transform:translate(0,0) scale(1)}50%{transform:translate(3vw,4vh) scale(1.08)}}
@keyframes glow-drift-2{0%,100%{transform:translate(0,0) scale(1)}50%{transform:translate(-4vw,-3vh) scale(1.1)}}
@media (prefers-reduced-motion:reduce){.login-glow,.login-glow--2{animation:none}}
.login-wrap{position:relative;z-index:1;display:flex;flex-direction:column;align-items:center;gap:2rem}
.login-wrap--wide{width:100%;max-width:760px}
.login-tagline{margin:-1rem 0 0;color:var(--muted);font-size:.88rem;text-align:center}
.local-strip{display:flex;align-items:center;gap:.4rem;margin:-1.4rem 0 0;border:1px solid var(--border);background:var(--panel);color:var(--muted);font-family:var(--font-display);font-size:.72rem;font-weight:600;letter-spacing:.02em;padding:.35rem .8rem;border-radius:999px;cursor:default;box-shadow:var(--shadow-sm);animation:wizard-in .4s ease}
.local-strip__icon{font-size:.9rem;line-height:1}
.local-strip__temp{color:var(--text)}
.local-strip__place{color:var(--muted)}
.local-strip__place::before{content:'·';margin-right:.4rem;color:var(--border)}
.login-grid{display:flex;align-items:flex-start;justify-content:center;gap:1.25rem;width:100%;flex-wrap:wrap}
.login-card{width:min(340px,100%);background:var(--panel);border:1px solid var(--border);border-radius:var(--radius-xl);padding:1.75rem 1.5rem;box-shadow:var(--shadow-md)}
.login-card .field{margin-bottom:1rem}
.login-card__title{margin:0 0 1.1rem;font-family:var(--font-display);font-size:1rem;font-weight:600;text-align:center}
.login-card--request{display:flex;flex-direction:column;width:min(380px,100%)}
.login-card__hint{margin:0 0 1rem;color:var(--muted);font-size:.82rem;line-height:1.5;text-align:center}
.request-domains{display:flex;flex-wrap:wrap;justify-content:center;gap:.35rem;margin-bottom:1.1rem}
.request-domain-chip{border:1px solid var(--border);background:var(--hover);color:var(--muted);font-family:var(--font-display);font-size:.74rem;font-weight:600;padding:.3rem .65rem;border-radius:999px}

/* Fixed to the viewport rather than sitting in the centered flex stack
   with everything else -- a real footer, not a fourth thing pushing the
   login/wizard content's own height past the screen and forcing the
   whole page to scroll just to fit one extra line of text. */
.security-note{position:fixed;z-index:1;left:1rem;right:1rem;bottom:calc(.9rem + env(safe-area-inset-bottom));max-width:420px;margin:0 auto;color:var(--muted);font-size:.74rem;line-height:1.45;text-align:center;pointer-events:none}
.request-form .field{margin-bottom:.8rem}
.field--column{flex-direction:column;align-items:stretch;gap:.3rem;padding:.6rem .9rem}
.field--column .field__label{width:auto}
.field--column textarea{border:0;background:transparent;padding:0;resize:vertical;min-height:70px;color:var(--text);font-family:var(--font-body);font-size:.9rem;line-height:1.5;outline:0}
.field--address .request-form__at{color:var(--muted);flex:none}
.field--address input{flex:1 1 6rem;min-width:5rem}
.field--address .field__select{flex:1 1 8rem;min-width:0}
.request-form__hp{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}
.request-success{margin:0;color:var(--primary);font-size:.86rem;text-align:center;line-height:1.5}

/* ---------- full-page address-request wizard ---------- */
.request-wizard{width:min(480px,100%);max-height:calc(100vh - 4rem);overflow-y:auto;background:var(--panel);border:1px solid var(--border);border-radius:var(--radius-xl);box-shadow:var(--shadow-lg);padding:1.5rem 1.75rem;display:flex;flex-direction:column;align-items:center;animation:wizard-in .25s ease}
@keyframes wizard-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.wizard-back{align-self:flex-start;display:flex;align-items:center;gap:.35rem;border:0;background:transparent;color:var(--muted);font-family:var(--font-display);font-size:.8rem;font-weight:600;padding:.3rem .2rem;margin-bottom:.6rem}
.wizard-back:hover{color:var(--text)}
.wizard-steps{display:flex;gap:.4rem;margin-bottom:1rem}
.wizard-step{width:2rem;height:4px;border-radius:999px;background:var(--border);transition:background .2s}
.wizard-step.is-active,.wizard-step.is-done{background:var(--primary)}
.wizard-panel{width:100%;display:flex;flex-direction:column;align-items:center;text-align:center;animation:wizard-in .2s ease}
.wizard-panel .field{width:100%;text-align:left}
.wizard-title{margin:0 0 .4rem;font-family:var(--font-display);font-size:1.25rem;font-weight:600;color:var(--text)}
.wizard-subtitle{margin:0 0 1rem;color:var(--muted);font-size:.88rem;line-height:1.5}
.wizard-subtitle strong{color:var(--text)}
.wizard-preview{font-family:var(--font-serif);font-size:1.5rem;color:var(--primary);margin-bottom:1.2rem;word-break:break-all;line-height:1.3}
.wizard-preview__at{color:var(--muted);margin:0 .05em}
.wizard-input{width:100%;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);color:var(--text);font-family:var(--font-body);font-size:1rem;padding:.8rem 1rem;text-align:center;margin-bottom:1.2rem;outline:0}
.wizard-input:focus{border-color:var(--primary)}
.wizard-domain-grid{display:grid;grid-template-columns:1fr 1fr;gap:.5rem;width:100%;margin-bottom:1.5rem}
.wizard-domain-chip{border:1px solid var(--border);background:var(--hover);color:var(--text);font-family:var(--font-body);font-size:.82rem;padding:.6rem .5rem;border-radius:var(--radius);text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.wizard-domain-chip:hover{border-color:var(--primary)}
.wizard-domain-chip.is-active{background:var(--primary);border-color:var(--primary);color:#fff;font-weight:600}
.wizard-panel form,.wizard-nav{width:100%}
.wizard-nav{display:flex;gap:.6rem;margin-top:.4rem}
.wizard-nav .btn{flex:1}

/* ---------- two-factor authentication ---------- */
#totp-off-view .btn,#totp-backup-view .btn{margin-top:.8rem}
/* A QR code needs real light-on-dark contrast to scan reliably, so this
   stays on a fixed white card regardless of app theme -- same reasoning
   as .readpane__body always being white. */
.totp-qr-wrap{display:flex;justify-content:center;padding:1.2rem;background:#ffffff;border:1px solid var(--border);border-radius:var(--radius-xl);margin-bottom:1rem}
.totp-qr-wrap #totp-qr img,.totp-qr-wrap #totp-qr canvas,.totp-qr-wrap #totp-qr table,.totp-qr-wrap #totp-qr svg{display:block;width:180px!important;height:180px!important}
.totp-manual-entry{margin-bottom:1rem}
.totp-manual-entry summary{cursor:pointer;font-size:.82rem;color:var(--muted);margin-bottom:.7rem}
.totp-manual-entry summary:hover{color:var(--text)}

/* Collapsed by default so power-user fields (filter redirect/reject,
   vacation address/date scoping) don't clutter the default view for
   someone who just wants the basic on/off behavior. */
.advanced-options{margin-top:.6rem;border-top:1px solid var(--border);padding-top:.7rem}
.advanced-options summary{cursor:pointer;font-family:var(--font-display);font-size:.82rem;font-weight:600;color:var(--muted);padding:.2rem 0;list-style:none}
.advanced-options summary::-webkit-details-marker{display:none}
.advanced-options summary::before{content:'▸ ';display:inline-block;transition:transform .15s}
.advanced-options[open] summary::before{transform:rotate(90deg)}
.advanced-options summary:hover{color:var(--text)}
.advanced-options[open] summary{margin-bottom:.6rem}
.totp-manual-entry .totp-secret-box{margin-top:.7rem}
.totp-secret-box{display:flex;align-items:center;justify-content:space-between;gap:.6rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--hover);padding:.7rem .9rem;margin-bottom:.7rem}
.totp-secret-box code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.88rem;color:var(--text);letter-spacing:.03em;word-break:break-all}
.settings-section__hint code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.82em;background:var(--hover);color:var(--text);padding:.1em .4em;border-radius:4px}
.totp-otpauth-link{display:block;font-size:.8rem;color:var(--primary);margin-bottom:1rem;text-decoration:none}
.totp-otpauth-link:hover{text-decoration:underline}
.totp-backup-codes{display:grid;grid-template-columns:1fr 1fr;gap:.5rem;margin:.8rem 0}
.totp-backup-codes span{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.85rem;color:var(--text);background:var(--hover);border:1px solid var(--border);border-radius:8px;padding:.5rem;text-align:center}

/* ---------- PGP ---------- */
.pgp-panel{border:1px solid var(--border);border-radius:var(--radius);background:var(--hover);padding:.8rem 1rem;margin:.8rem 0}
.pgp-panel .settings-section__hint{margin:0 0 .6rem}
.pgp-panel textarea{width:100%;min-height:80px;border:1px solid var(--border);border-radius:8px;background:var(--panel);color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.78rem;padding:.6rem;resize:vertical;outline:0}
#pgp-import-key{min-height:90px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.78rem}
.pgp-encrypted-banner{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap;padding:.7rem 1.75rem;background:#f0eaff;border-bottom:1px solid #ddd0fb;color:#5b3fb0;font-size:.85rem;order:2}
html[data-theme="dark"] .pgp-encrypted-banner{background:#241a3d;border-bottom-color:#3a2a5c;color:#c7b3f5}
.pgp-encrypted-banner__btn{border:1px solid currentColor;background:transparent;color:inherit;font-size:.78rem;font-weight:600;padding:.3rem .7rem;border-radius:999px}
.pgp-encrypted-banner__btn:hover{background:rgba(0,0,0,.06)}
html[data-theme="dark"] .pgp-encrypted-banner__btn:hover{background:rgba(255,255,255,.08)}
.wizard-nav .btn{flex:1}
.wizard-panel--success .wizard-success-icon{width:56px;height:56px;border-radius:50%;background:color-mix(in srgb, var(--primary) 14%, transparent);color:var(--primary);display:flex;align-items:center;justify-content:center;margin-bottom:1.2rem}
.login-error{margin:.8rem 0 0;color:var(--danger);font-size:.85rem;text-align:center}

/* ---------- app shell ---------- */
/* Named grid areas (not just implicit column order) so the layout
   preference below can rearrange rail/list/read without needing three
   separate hand-written grid definitions duplicated per breakpoint. */
#view-app{display:grid;grid-template-columns:64px 320px 1fr;grid-template-areas:"rail list read";height:100vh}
.rail{grid-area:rail}
.listpane{grid-area:list}
.readpane{grid-area:read}

/* Reading-pane layout preference (Settings > Layout) — desktop only
   (min-width matches the mobile breakpoint below exactly, so the two
   never fight over #view-app's grid-template-columns; mobile always
   collapses to its own full-screen behavior regardless of this setting,
   which is the only sane behavior on a phone anyway). Default is the
   side-by-side grid above; these two override it. "Stacked" keeps list
   and reading pane both visible, just as rows instead of columns.
   "Full screen" reuses the exact same fixed-overlay mechanism mobile
   uses for the reading pane — same CSS, just opted into at any width
   instead of forced under 900px. */
@media (min-width: 901px){
  #view-app.layout-bottom{grid-template-columns:64px 1fr;grid-template-rows:42% 1fr;grid-template-areas:"rail list" "rail read"}
  #view-app.layout-bottom .listpane{border-right:0;border-bottom:1px solid var(--border)}
  #view-app.layout-off{grid-template-columns:64px 1fr;grid-template-areas:"rail list"}
  #view-app.layout-off .readpane{position:fixed;inset:0 0 0 64px;z-index:20;display:none}
  #view-app.layout-off .readpane.is-open{display:flex}
  #view-app.layout-off .back-btn{display:flex}
  #view-app.layout-off .readpane__header{padding-left:3.1rem}
}
/* min-height:0 for the same reason as .listpane/.readpane above — this
   is also a grid item, and the rail now has enough icons (folders,
   contacts, settings...) that on a short viewport it could otherwise
   grow the whole page past 100vh instead of clipping to its own column. */
.rail{background:var(--ocean-900);display:flex;flex-direction:column;align-items:center;padding:1rem 0;gap:.75rem;min-height:0}
html[data-theme="dark"] .rail{background:#050f16}
@media (prefers-color-scheme:dark){html:not([data-theme=light]) .rail{background:#050f16}}
.rail__brand{color:#fff;margin-bottom:.5rem}
.rail__compose-wrap{display:flex;flex-direction:column;align-items:center;gap:.3rem}
.rail__compose{width:44px;height:44px;border-radius:50%;background:var(--primary);color:#fff;border:0;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 20px color-mix(in srgb, var(--primary) 35%, transparent);transition:transform .2s var(--ease),box-shadow .2s var(--ease)}
.rail__compose:hover{transform:translateY(-2px) scale(1.03)}
.rail__compose-label{font-family:var(--font-display);font-size:.6rem;font-weight:700;color:rgba(255,255,255,.75)}
.rail__folders{display:flex;flex-direction:column;gap:.4rem;width:100%;align-items:center;margin-top:.5rem}
/* .rail is a plain (unpositioned) grid item -- any z-index set on
   something nested inside it stays trapped in the rail's own stacking
   context and still loses to .listpane painting later at the same
   (unelevated) grid level, no matter how high the number. Rather than
   fight that, this menu lives as its own element outside the rail
   entirely (see #rail-more-menu below and openRailMoreMenu in app.js),
   positioned with real fixed screen coordinates computed at open time. */
#rail-more-menu{position:fixed;top:auto;right:auto;bottom:auto;z-index:300}
.folder-btn{width:44px;height:44px;border-radius:12px;border:0;background:transparent;color:rgba(255,255,255,.6);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;font-size:.6rem;font-family:var(--font-display);position:relative;transition:background .2s,color .2s}
/* A long custom folder name (anything past ~2 short words) used to just
   keep wrapping -- 3+ lines, stretching the button past its fixed 44px
   square and throwing off the whole rail's spacing. Clamped to 2 lines
   with an ellipsis instead; the full name is still there in the native
   title tooltip (already set on the button) and in the "More" menu. */
.folder-btn span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;line-height:1.15;word-break:break-word;max-width:100%}
.folder-btn:hover{background:rgba(255,255,255,.08);color:#fff}
.folder-btn.is-active{background:color-mix(in srgb, var(--teal-500) 22%, transparent);color:var(--teal-300)}
.folder-btn__badge{position:absolute;top:2px;right:2px;min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:var(--teal-400);color:var(--ocean-900);font-size:.62rem;font-weight:700;display:flex;align-items:center;justify-content:center}
.rail__spacer{flex:1}
.rail__icon-btn{width:48px;min-height:44px;padding:.3rem 2px;border-radius:10px;border:0;background:transparent;color:rgba(255,255,255,.6);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:.54rem;font-family:var(--font-display);font-weight:600;transition:background .2s,color .2s}
.rail__icon-btn:hover{background:rgba(255,255,255,.08);color:#fff}
.rail__icon-label{line-height:1.1;text-align:center}
@media (max-width:900px){.rail__icon-btn{width:46px}}

/* min-height:0 matters here as much as min-width:0 does: these are
   CSS Grid items (children of #view-app), and a grid item's min-height
   defaults to auto — the size of its own content — not 0. Without this,
   a long message list/email body can grow the whole panel past the
   viewport instead of being clipped to it, pushing everything below it
   (including the reply footer) off-screen with the fix-looking
   flex:1;min-height:0 on the elements further down never getting a
   properly-sized box to constrain against in the first place. */
.listpane{background:var(--panel);border-right:1px solid var(--border);display:flex;flex-direction:column;min-width:0;min-height:0}
.search-bar{display:flex;align-items:center;gap:.55rem;margin:.9rem 1.2rem 0;padding:.55rem .8rem;border:1px solid var(--border);border-radius:999px;background:var(--hover)}
.search-bar__icon{color:var(--muted);flex:none}
.search-bar input{flex:1;min-width:0;border:0;background:transparent;color:var(--text);font-family:var(--font-body);font-size:.88rem;outline:0}
.search-bar input::placeholder{color:var(--muted)}
.search-bar__clear{border:0;background:transparent;color:var(--muted);width:18px;height:18px;border-radius:50%;display:flex;align-items:center;justify-content:center;flex:none}
.search-bar__clear:hover{background:var(--panel);color:var(--text)}
.listpane__header{display:flex;align-items:center;padding:1.1rem 1.2rem;border-bottom:1px solid var(--border)}
.listpane__header h1{margin:0;font-family:var(--font-display);font-size:1.1rem;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.listpane__header-actions{display:flex;align-items:center;gap:.3rem;flex:none;margin-left:auto}
.app-weather{display:flex;align-items:center;gap:.3rem;margin-left:.85rem;padding:.25rem .6rem;border-radius:999px;background:var(--hover);color:var(--muted);font-family:var(--font-display);font-size:.72rem;font-weight:600;flex:none;white-space:nowrap}
@media (max-width:520px){.app-weather{display:none}}

.accent-picker{display:flex;flex-wrap:wrap;gap:.6rem;margin-top:.2rem}
.accent-swatch{width:2.1rem;height:2.1rem;border-radius:50%;border:2px solid transparent;padding:0;cursor:pointer;transition:transform .15s var(--ease),border-color .15s}
.accent-swatch:hover{transform:scale(1.08)}
.accent-swatch.is-active{border-color:var(--text);box-shadow:0 0 0 2px var(--panel),0 0 0 4px var(--text)}
.app-weather #app-weather-temp{color:var(--text)}
.btn-select-mode.is-active{background:var(--selected-bg);color:var(--primary)}
/* Same min-height:auto flex trap as the grid one above — a long,
   paginated message list is exactly the content that would trigger it,
   so this isn't optional even though it "happens" to work without it
   on a short list. */
.message-list{flex:1;min-height:0;overflow-y:auto}
.list-empty{padding:3rem 1.5rem;text-align:center;color:var(--muted)}
.load-more-indicator{margin:.75rem auto 1.25rem;text-align:center;color:var(--muted);font-family:var(--font-display);font-size:.78rem;font-weight:600}
.load-more-indicator[hidden]{display:none}

.bulk-bar{display:flex;align-items:center;justify-content:space-between;padding:.7rem 1.2rem;border-bottom:1px solid var(--border);background:var(--selected-bg)}
.bulk-bar__check{display:flex;align-items:center;gap:.55rem;font-size:.85rem;font-weight:600;color:var(--text)}
.bulk-bar__check input{width:16px;height:16px;accent-color:var(--primary)}
.bulk-bar__actions{display:flex;align-items:center;flex-wrap:wrap;gap:.2rem}
/* Six labeled icon buttons plus Cancel don't fit one row under ~520px --
   they used to just wrap onto a second (sometimes third) row, eating a
   big chunk of the list before you'd even seen a message. Icon-only
   below that width keeps every action in one row; the label still
   exists for screen readers (aria-label) and the data-tooltip. */
@media (max-width:520px){
  .bulk-bar{padding:.6rem .8rem;flex-wrap:wrap;gap:.5rem}
  .bulk-bar__actions .icon-btn--labeled{flex-direction:row;min-width:32px;padding:.4rem}
  .bulk-bar__actions .icon-btn__label{display:none}
  /* Same problem as the bulk bar: icon+label buttons that wrap put
     Reply/Forward/Flag, then Unread/Spam/Archive/Delete/Move, then More
     across 3 full rows before any message content is visible. Icon-only
     packs it down to 1-2 rows. */
  .readpane__actionbar{padding:.6rem .8rem;gap:.35rem}
  .readpane__actionbar .icon-btn--labeled{flex-direction:row;min-width:32px;padding:.4rem}
  .readpane__actionbar .icon-btn__label{display:none}
  /* Each .field__addon is a plain text button with no nowrap, so a
     narrow header wraps it word-by-word ("Add" / "from" / "mail") instead
     of moving the whole label to a new line -- wrap the row as whole
     buttons instead. */
  .compose-card__header{flex-wrap:wrap;row-gap:.4rem}
  .compose-card__header-actions{flex-wrap:wrap;justify-content:flex-end}
  .field__addon{white-space:nowrap}
}
.msg-row__checkbox{width:16px;height:16px;accent-color:var(--primary);margin-top:.35rem;flex:none}

@keyframes msg-row-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
.msg-row{display:flex;align-items:flex-start;gap:.75rem;padding:.9rem 1.2rem;border-bottom:1px solid var(--border);cursor:pointer;position:relative;transition:background .2s var(--ease)}

/* ---------- threaded conversation view ---------- */
.thread-group__header{border-bottom:0}
.thread-group:not(.is-expanded){border-bottom:1px solid var(--border)}
.thread-group.is-expanded{background:var(--hover)}
.thread-group__count{display:inline-flex;align-items:center;justify-content:center;min-width:1.3rem;height:1.3rem;padding:0 .3rem;border-radius:999px;background:var(--border);color:var(--muted);font-family:var(--font-display);font-size:.68rem;font-weight:700;margin-left:.3rem;vertical-align:middle}
.thread-group__chevron{flex:none;align-self:center;color:var(--muted);transition:transform .15s}
.thread-group.is-expanded .thread-group__chevron{transform:rotate(180deg)}
.thread-group__members{border-bottom:1px solid var(--border)}
.thread-group__members .msg-row{padding-left:2.6rem;border-bottom:1px solid var(--border-light,var(--border))}
.thread-group__members .msg-row:last-child{border-bottom:0}
.thread-group__members .avatar{width:1.7rem;height:1.7rem;font-size:.68rem}
.msg-row:hover{background:var(--hover)}
.msg-row.is-selected{background:var(--selected-bg);box-shadow:inset 3px 0 0 var(--primary)}
html[data-theme="dark"] .msg-row.is-selected{box-shadow:inset 3px 0 0 var(--teal-400)}
@media (prefers-color-scheme:dark){html:not([data-theme=light]) .msg-row.is-selected{box-shadow:inset 3px 0 0 var(--teal-400)}}
.msg-row.is-focused{outline:2px solid var(--primary);outline-offset:-2px}
.msg-row__body{flex:1;min-width:0}
.msg-row__top{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem}
.msg-row__from{font-size:.92rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.msg-row.is-unread .msg-row__from,.msg-row.is-unread .msg-row__subject{font-weight:700}
.msg-row__date{font-size:.76rem;color:var(--muted);flex:none}
.msg-row__subject{font-size:.88rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:.1rem}
.msg-row__folder{display:inline-block;margin-left:.5rem;padding:.05rem .45rem;border-radius:999px;background:var(--hover);color:var(--muted);font-size:.68rem;font-weight:600;vertical-align:middle}
.msg-row.is-unread .msg-row__subject{color:var(--text)}
.msg-row__dot{width:8px;height:8px;border-radius:50%;background:var(--primary);flex:none;margin-top:.4rem}
html[data-theme="dark"] .msg-row__dot{background:var(--teal-400)}
@media (prefers-color-scheme:dark){html:not([data-theme=light]) .msg-row__dot{background:var(--teal-400)}}
.msg-row__flag{color:#e0a83a;flex:none}

/* Compact density -- same information, roughly 40% shorter rows, for
   fitting more of the list on screen at once without scrolling. */
.density-compact .msg-row{padding:.5rem 1.2rem;gap:.6rem}
.density-compact .msg-row .avatar{width:1.7rem;height:1.7rem;font-size:.68rem}
.density-compact .msg-row__from{font-size:.85rem}
.density-compact .msg-row__subject{font-size:.8rem;margin-top:0}
.density-compact .msg-row__date{font-size:.72rem}

.avatar{width:2.2rem;height:2.2rem;border-radius:50%;display:flex;align-items:center;justify-content:center;font-family:var(--font-display);font-weight:600;font-size:.85rem;color:#fff;flex:none}
.avatar--lg{width:2.8rem;height:2.8rem;font-size:1.05rem}

.readpane{background:var(--bg);display:flex;flex-direction:column;min-width:0;min-height:0}
.readpane__empty{flex:1;display:flex;align-items:center;justify-content:center;color:var(--muted);font-family:var(--font-display)}
.readpane__error{position:relative;flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;color:var(--muted);padding:2rem}
.readpane__error p{margin:0;font-family:var(--font-display);font-size:1rem;text-align:center;max-width:26rem}
.back-btn--error{position:absolute;top:1.2rem;left:1.1rem}
.readpane__content{flex:1;display:flex;flex-direction:column;min-height:0}
.readpane__header{position:relative;padding:1.5rem 1.75rem 1rem;border-bottom:1px solid var(--border);background:var(--panel);order:0}
.readpane__header h2{margin:0 0 1rem;font-family:var(--font-display);font-size:1.3rem;font-weight:600}
.back-btn{display:none;position:absolute;top:1.2rem;left:1.1rem;width:32px;height:32px;border:0;border-radius:8px;background:transparent;color:var(--text);align-items:center;justify-content:center}
.back-btn:hover{background:var(--hover)}
.readpane__meta{display:flex;align-items:center;gap:.85rem}
.readpane__from{flex:1;min-width:0}
.readpane__from>div:first-child{font-size:.95rem}
.delivery-status{display:flex;align-items:center;gap:.4rem;flex:none;padding:.3rem .7rem;border-radius:999px;background:var(--hover);font-family:var(--font-display);font-size:.76rem;font-weight:600;color:var(--muted)}
.delivery-status span:first-child{width:7px;height:7px;border-radius:50%;background:var(--muted)}
.delivery-status.is-delivered{color:var(--primary)}
.delivery-status.is-delivered span:first-child{background:var(--primary)}
.delivery-status.is-bounced{color:var(--danger)}
.delivery-status.is-bounced span:first-child{background:var(--danger)}
@media (max-width:520px){.delivery-status span:last-child{display:none}}
/* Position is user-configurable (Settings → Layout → "Top"/"Bottom") —
   .readpane__content is the flex column and every child's `order` below
   just needs the actionbar to sort before or after the body/attachments;
   toggling two classes here is simpler and less error-prone than moving
   the actionbar's actual DOM position around on every open. */
.readpane__actionbar{order:1;display:flex;align-items:center;flex-wrap:wrap;gap:.5rem;padding:.85rem 1.75rem;border-bottom:1px solid var(--border);background:var(--panel)}
/* Reply/Forward + the per-message toggles form one left-aligned cluster;
   Move/More (the "organize this message" actions) form a second cluster
   pinned to the right instead of trailing off into empty space on a
   wide reading pane. Scoped to the width where the actionbar actually
   has room to sit on one line -- under 901px it already wraps onto 2+
   rows (see the max-width:900px block below), and an auto margin on a
   wrapped flex item only pushes within whichever row it lands on,
   which split the buttons into a lopsided two-row mess on a phone. */
@media (min-width: 901px){
  .readpane__actionbar .menu-wrap:first-of-type{margin-left:auto}
}
.actions-bottom .readpane__actionbar{order:9;border-bottom:0;border-top:1px solid var(--border)}
.actions-bottom .readpane__attachments{order:8}
.actions-bottom .readpane__body{order:7}
.actions-bottom #rp-images-banner,.actions-bottom #rp-pgp-banner{order:6}
.readpane__actionbar-sep{width:1px;align-self:stretch;background:var(--border);margin:0 .15rem}
/* Message content always renders on a light card regardless of app
   theme (same convention Gmail/Outlook/Roundcube itself use) — arbitrary
   email HTML can't be safely dark-inverted without breaking embedded
   colors/images, and dark-on-dark from the app shell is unreadable. */
.readpane__body{flex:1;min-height:0;width:100%;border:0;background:#ffffff;order:3}
.readpane__attachments{padding:.85rem 1.75rem;display:flex;flex-wrap:wrap;gap:.5rem;order:4}
.images-banner{display:flex;align-items:center;flex-wrap:wrap;gap:.6rem;padding:.7rem 1.75rem;background:#faf3df;border-bottom:1px solid #e6dcb8;color:#6b5a1e;font-size:.85rem;order:2}
html[data-theme="dark"] .images-banner{background:#3a3010;border-bottom-color:#5a4a1a;color:#e6d38a}
.images-banner__btn{border:1px solid currentColor;background:transparent;color:inherit;font-size:.78rem;font-weight:600;padding:.3rem .7rem;border-radius:999px}
.images-banner__btn:hover{background:rgba(0,0,0,.06)}
html[data-theme="dark"] .images-banner__btn:hover{background:rgba(255,255,255,.08)}
.attachment-chip{display:inline-flex;align-items:center;gap:.4rem;padding:.4rem .8rem;border:1px solid var(--border);border-radius:999px;font-size:.82rem;background:var(--panel);text-decoration:none;color:var(--text)}

/* ---------- compose overlay ---------- */
.overlay{position:fixed;inset:0;background:rgba(7,26,38,.45);display:flex;align-items:center;justify-content:center;z-index:50;backdrop-filter:blur(3px)}
.overlay[hidden]{display:none}
.compose-card{width:560px;max-width:92vw;max-height:85vh;background:var(--panel);border:1px solid var(--border);border-radius:var(--radius-xl);box-shadow:var(--shadow-lg);display:flex;flex-direction:column;overflow:hidden}
.link-warning-card{width:420px;max-width:88vw;background:var(--panel);border:1px solid var(--border);border-radius:var(--radius-xl);box-shadow:var(--shadow-lg);padding:1.4rem}
.link-warning-card h3{margin:0 0 .5rem;font-family:var(--font-display);font-size:1.05rem;font-weight:600}
.link-warning-card p{margin:0 0 .5rem;font-size:.85rem;color:var(--muted);line-height:1.5}

.attachment-preview-card{width:min(900px,94vw);height:min(85vh,900px);background:var(--panel);border:1px solid var(--border);border-radius:var(--radius-xl);box-shadow:var(--shadow-lg);display:flex;flex-direction:column;overflow:hidden}
.attachment-preview-card__header{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.9rem 1.1rem;border-bottom:1px solid var(--border);flex:none}
.attachment-preview-card__header span{font-family:var(--font-display);font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.attachment-preview-card__actions{display:flex;align-items:center;gap:.5rem;flex:none}
.attachment-preview-card__body{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;background:var(--bg);overflow:auto}
.attachment-preview-card__body img{max-width:100%;max-height:100%;object-fit:contain}
.attachment-preview-card__body iframe{width:100%;height:100%;border:0}
.attachment-preview-card__body pre{margin:0;padding:1.2rem;white-space:pre-wrap;word-break:break-word;font-size:.85rem;color:var(--text);align-self:flex-start;width:100%}
.link-warning-card__url{word-break:break-all;font-family:var(--font-body);color:var(--text) !important;background:var(--hover);border-radius:8px;padding:.6rem .7rem}
.link-warning-card__actions{display:flex;justify-content:flex-end;gap:.6rem;margin-top:1.1rem}
.dialog-card__input{width:100%;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg);color:var(--text);font-family:var(--font-body);font-size:.92rem;padding:.65rem .8rem;margin:.3rem 0 0;outline:0}
.dialog-card__input:focus{border-color:var(--primary)}
/* This dialog can be opened from INSIDE another already-open overlay
   (e.g. confirming "Add from mail" while Contacts is open) -- both share
   .overlay's z-index:50, and same z-index falls back to DOM order, which
   put whichever overlay happens to come later in the markup on top
   regardless of which one was actually opened last. A dialog must always
   win that fight, so it gets a z-index above every other overlay/menu/
   tooltip in the app, not just the shared default. */
#dialog-overlay{z-index:300}
/* Same reasoning as #dialog-overlay above -- opened from inside the
   already-open Contacts overlay, so it needs to win the stacking fight
   too, not just match the shared .overlay default. */
#contacts-scan-overlay{z-index:300}
.contacts-scan-card{width:560px}
.contacts-scan-selectall{display:flex;align-items:center;gap:.5rem;margin-top:.9rem;padding-bottom:.6rem;border-bottom:1px solid var(--border);font-family:var(--font-display);font-size:.8rem;font-weight:600;color:var(--muted)}
.contacts-scan-list{max-height:320px;overflow-y:auto;display:flex;flex-direction:column;gap:.15rem;margin:.5rem 0 0}
.contacts-scan-row{display:flex;align-items:center;gap:.65rem;padding:.5rem .4rem;border-radius:8px;cursor:pointer}
.contacts-scan-row:hover{background:var(--hover)}
.contacts-scan-row input{flex:none}
.contacts-scan-row__info{min-width:0;flex:1;display:flex;flex-direction:column}
.contacts-scan-row__name{font-size:.86rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.contacts-scan-row__email{font-size:.76rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.compose-card__header{display:flex;align-items:center;justify-content:space-between;padding:1.1rem 1.4rem;border-bottom:1px solid var(--border)}
.compose-card__header h2{margin:0;font-family:var(--font-display);font-size:1.05rem}
.compose-form{padding:1.2rem 1.4rem;display:flex;flex-direction:column;flex:1;min-height:0;overflow-y:auto}
.compose-body{flex:1;min-height:220px;resize:vertical;border:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);padding:.9rem 1rem;font-family:var(--font-body);font-size:.95rem;color:var(--text);background:var(--panel);outline:0;overflow-y:auto}
.compose-body:focus{border-color:var(--primary);box-shadow:0 0 0 .2rem color-mix(in srgb, var(--primary) 15%, transparent)}
[contenteditable].compose-body{white-space:pre-wrap}
[contenteditable].compose-body:empty::before{content:attr(data-placeholder);color:var(--muted);pointer-events:none}
[contenteditable].compose-body blockquote{margin:.5rem 0;padding:0 0 0 .9rem;border-left:3px solid var(--border);color:var(--muted)}
[contenteditable].compose-body a{color:var(--primary)}

.editor-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.25rem;row-gap:.35rem;border:1px solid var(--border);border-bottom:0;border-radius:var(--radius) var(--radius) 0 0;padding:.4rem;background:var(--hover)}
.editor-btn{width:28px;height:28px;border:0;border-radius:6px;background:transparent;color:var(--text);font-family:var(--font-body);font-size:.85rem;display:flex;align-items:center;justify-content:center;flex:none}
.editor-btn:hover{background:var(--panel)}
.editor-sep{width:1px;height:18px;background:var(--border);margin:0 .15rem;flex:none}
.editor-select{border:1px solid var(--border);border-radius:6px;background:var(--panel);color:var(--text);font-family:var(--font-body);font-size:.78rem;padding:.3rem .35rem;max-width:6.5rem;flex:none}
.editor-select--size{max-width:4.5rem}
.editor-color{position:relative;width:24px;height:24px;border-radius:6px;display:flex;align-items:center;justify-content:center;font-family:var(--font-display);font-size:.78rem;font-weight:700;color:var(--text);cursor:pointer;flex:none}
.editor-color:hover{background:var(--panel)}
.editor-color input[type=color]{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;border:0;padding:0}
.editor-toolbar__spacer{flex:1}
.editor-plain-toggle{border:0;background:transparent;color:var(--muted);font-family:var(--font-display);font-size:.72rem;font-weight:600;padding:.3rem .5rem;border-radius:6px}
.editor-plain-toggle:hover{background:var(--panel);color:var(--text)}
.editor-plain-toggle.is-active{color:var(--primary)}
.compose-form__footer{display:flex;align-items:center;flex-wrap:wrap;gap:.6rem;padding-top:1rem}
.compose-error{color:var(--danger);font-size:.85rem}
.field--to{position:relative}
.field__addon{margin-left:.5rem;border:0;background:transparent;color:var(--muted);font-family:var(--font-display);font-size:.78rem;font-weight:600;padding:.3rem .5rem;border-radius:8px;transition:background .2s,color .2s}
.field__addon:hover{background:var(--hover);color:var(--text)}
.field__addon--danger{color:var(--danger)}
.field__addon--danger:hover{background:rgba(192,57,43,.12);color:var(--danger)}
.field__select{flex:1;border:0;background:transparent;color:var(--text);font-family:var(--font-body);font-size:.92rem;outline:0;padding:.2rem 0}
.autocomplete{position:absolute;top:100%;left:0;right:0;margin-top:.3rem;background:var(--panel);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-md);z-index:10;max-height:220px;overflow-y:auto}
.autocomplete[hidden]{display:none}
.autocomplete__item{display:flex;align-items:center;gap:.6rem;padding:.55rem .8rem;cursor:pointer}
.autocomplete__item:hover,.autocomplete__item.is-active{background:var(--hover)}
.autocomplete__item .avatar{width:1.8rem;height:1.8rem;font-size:.7rem}
.autocomplete__name{font-size:.86rem;color:var(--text)}
.autocomplete__email{font-size:.78rem;color:var(--muted)}
.compose-attach-btn{margin-left:0}
.attachment-list{display:flex;flex-wrap:wrap;gap:.5rem;margin:.75rem 0 0}
.attachment-list:empty{margin:0}
.attachment-chip{display:inline-flex;align-items:center;gap:.4rem;padding:.35rem .5rem .35rem .75rem;border:1px solid var(--border);border-radius:999px;font-size:.8rem;background:var(--hover);color:var(--text)}
.attachment-chip__size{color:var(--muted)}
.attachment-chip__remove{border:0;background:transparent;color:var(--muted);width:18px;height:18px;border-radius:50%;display:flex;align-items:center;justify-content:center;line-height:1}
.attachment-chip__remove:hover{background:rgba(192,57,43,.15);color:var(--danger)}

.settings-card{width:760px;max-width:94vw;max-height:90vh}
.settings-form input:disabled{color:var(--muted);background:var(--hover);cursor:not-allowed}
.settings-form__label{font-size:.82rem;font-weight:600;color:var(--muted);margin:.4rem 0 .4rem}
.settings-body{padding:1.1rem 1.4rem;display:flex;flex-direction:column;gap:.85rem;max-height:80vh;overflow-y:auto}
#settings-tabs{flex:none}
.settings-tab-panel{display:flex;flex-direction:column;gap:1.05rem}
.settings-section__head{display:flex;align-items:center;justify-content:space-between;margin-bottom:.3rem}
.settings-section h3{margin:0;font-family:var(--font-display);font-size:.98rem;font-weight:600;letter-spacing:-.01em}
.settings-section__hint{margin:.15rem 0 .55rem;font-size:.8rem;color:var(--muted);line-height:1.45}

/* Every list in Settings (identities, filters, blocked senders,
   templates, scheduled sends, folders, sign-in history...) shared this
   one class as a plain single-column stack, so a folder with 8 filters
   was 8 full-width rows of vertical scroll even though the settings
   card has 760px to work with -- auto-fill instead of a fixed column
   count so it's the CONTAINER's actual width that decides 1 vs 2
   columns (a viewport media query would be wrong here since the modal
   itself is a fixed width regardless of the browser window), collapsing
   to one column on its own once a row can't fit two 260px cards side
   by side. align-items:start so a longer card in one column doesn't
   stretch its shorter neighbor to match. */
.identity-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:.5rem;align-items:start}
.identity-card{display:flex;align-items:center;gap:.7rem;padding:.7rem .9rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--hover);transition:border-color .15s var(--ease),box-shadow .15s var(--ease)}
.identity-card:hover{border-color:color-mix(in srgb, var(--primary) 30%, var(--border));box-shadow:var(--shadow-sm)}

.actionbar-settings-row{display:flex;align-items:center;gap:.5rem;padding:.5rem .2rem;border-bottom:1px solid var(--border)}
.actionbar-settings-row:last-child{border-bottom:0}
.actionbar-settings-row .icon-btn{width:30px;height:30px;flex:none}
.identity-card__info{flex:1;min-width:0}
.identity-card__name{font-size:.9rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
/* A name that opens "everything to or from this person" (search, all
   folders) instead of just sitting there as a label -- same action
   wherever a name shows up like this across the app. */
.identity-card__name--link{border:0;background:transparent;padding:0;font-family:inherit;text-align:left;cursor:pointer;max-width:100%}
.identity-card__name--link:hover{color:var(--primary);text-decoration:underline}
.identity-card__email{font-size:.78rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.identity-card__badge{font-size:.68rem;font-weight:700;color:var(--primary);background:color-mix(in srgb, var(--primary) 14%, transparent);padding:.15rem .5rem;border-radius:999px;flex:none;text-transform:uppercase;letter-spacing:.02em}
.identity-card__edit{border:0;background:transparent;color:var(--muted);width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex:none}
.identity-card__edit:hover{background:var(--panel);color:var(--text)}

.request-card{flex-wrap:wrap;align-items:flex-start}
.request-card__reason{margin:.35rem 0 0;color:var(--text);font-size:.83rem;line-height:1.5;white-space:pre-wrap}
.request-card__actions{display:flex;gap:.4rem;flex:none}
.request-card__status{color:var(--muted);background:var(--panel)}
.request-card__status--approved{color:var(--primary);background:color-mix(in srgb, var(--primary) 14%, transparent)}
.request-card__status--denied{color:var(--danger);background:rgba(192,57,43,.12)}

.contact-add-form{display:flex;gap:.5rem;margin-bottom:1rem}
.contact-add-form input{flex:1;min-width:0;padding:.6rem .8rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--panel);color:var(--text);font-family:var(--font-body);font-size:.88rem}
.contact-add-form input:focus{outline:0;border-color:var(--primary)}
/* Two columns once the settings/contacts card is wide enough to fit them
   without cramping -- a single wide column just left the extra room the
   larger card gained empty down the middle. */
.contact-list{display:grid;grid-template-columns:1fr;gap:.4rem}
@media (min-width:620px){.contact-list{grid-template-columns:1fr 1fr}}
.contact-row{display:flex;align-items:center;gap:.7rem;padding:.6rem .8rem;border-radius:var(--radius);transition:background .15s}
.contact-row.is-selected{background:var(--selected-bg);box-shadow:inset 3px 0 0 var(--primary)}
.contact-row:hover{background:var(--hover)}
.contact-row .avatar{width:2rem;height:2rem;font-size:.78rem}
.contact-row__info{flex:1;min-width:0}
.contact-row__name{font-size:.88rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.contact-row__email{font-size:.78rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.contact-row__delete{border:0;background:transparent;color:var(--muted);width:28px;height:28px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex:none}
.contact-row__delete:hover{background:rgba(192,57,43,.12);color:var(--danger)}
.contact-row__icon{border:0;background:transparent;color:var(--muted);width:28px;height:28px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex:none}
.contact-row__icon:hover{background:var(--hover);color:var(--text)}
.contact-row__info{cursor:pointer}

/* ---------- contact detail panel ---------- */
/* ---------- contacts page (master-detail, not two stacked modals) ---------- */
.contacts-page-card{width:1040px;max-width:96vw;max-height:88vh;display:flex;flex-direction:column}
.contacts-page__body{display:flex;flex:1;min-height:0}
.contacts-page__list{width:320px;flex:none;border-right:1px solid var(--border);padding:1.1rem 1.2rem;overflow-y:auto}
.contacts-page__list .contact-list{display:flex;flex-direction:column;gap:.3rem}
.contacts-page__detail{flex:1;min-width:0;overflow-y:auto;padding:1.3rem 1.6rem}
.contacts-page__placeholder{height:100%;min-height:300px;display:flex;align-items:center;justify-content:center;text-align:center;color:var(--muted);font-size:.9rem;padding:2rem}
@media (max-width:760px){
  .contacts-page__body{flex-direction:column}
  .contacts-page__list{width:100%;border-right:0;border-bottom:1px solid var(--border)}
  /* Stacking list above detail still rendered both at once -- selecting a
     contact left the full list sitting on top of the detail pane, doubling
     the scroll for no reason. Show only one at a time here, same as the
     mail list/reading-pane swap; whichever one is showing gets the full
     height (flex:1) instead of the old fixed 40vh split. */
  .contacts-page__list,.contacts-page__detail{flex:1}
  .contacts-page__body.has-detail .contacts-page__list{display:none}
  .contacts-page__body:not(.has-detail) .contacts-page__detail{display:none}
}
.contact-detail__head{display:flex;align-items:center;gap:1rem}
.avatar--xl{width:3.6rem;height:3.6rem;font-size:1.3rem;flex:none}
.contact-detail__id{flex:1;min-width:0}
.contact-detail__name-input{width:100%;border:0;background:transparent;padding:.15rem 0;font-family:var(--font-display);font-size:1.15rem;font-weight:600;color:var(--text);outline:0;border-radius:6px}
.contact-detail__name-input:hover,.contact-detail__name-input:focus{background:var(--hover);padding:.15rem .4rem;margin:0 0 0 -.4rem}
.contact-detail__email{font-size:.85rem;color:var(--muted);margin-top:.1rem}
.contact-detail__actions{display:flex;align-items:center;gap:.6rem;margin:1.1rem 0 .3rem}
.contact-detail__groups{display:flex;flex-wrap:wrap;gap:.4rem}
.contact-detail__groups .group-chip{cursor:pointer}
.contact-detail__messages{display:flex;flex-direction:column;gap:.3rem}
.contact-msg-row{display:flex;align-items:center;gap:.7rem;padding:.6rem .7rem;border-radius:var(--radius);cursor:pointer;transition:background .15s var(--ease)}
.contact-msg-row:hover{background:var(--hover)}
.contact-msg-row__body{flex:1;min-width:0}
.contact-msg-row__top{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem}
.contact-msg-row__subject{font-size:.86rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.contact-msg-row__date{font-size:.74rem;color:var(--muted);flex:none}
.contact-msg-row__folder{font-size:.74rem;color:var(--muted);margin-top:.1rem;display:flex;align-items:center;gap:.3rem}
.contact-msg-row__dir{font-size:.68rem;font-weight:700;text-transform:uppercase;letter-spacing:.03em;padding:.05rem .4rem;border-radius:999px;background:var(--hover);color:var(--muted);flex:none}

/* Shimmering placeholder rows shown the moment a list starts loading,
   instead of leaving the pane blank until data arrives. */
@keyframes shimmer-sweep{0%{background-position:-200% 0}100%{background-position:200% 0}}
.skeleton-row{border-radius:var(--radius);background:linear-gradient(90deg,var(--hover) 25%,var(--border) 50%,var(--hover) 75%);background-size:200% 100%;animation:shimmer-sweep 1.4s ease-in-out infinite}
.msg-row-skeleton{display:flex;align-items:center;gap:.75rem;padding:.9rem 1.2rem;border-bottom:1px solid var(--border);opacity:0;animation:msg-row-in .3s ease both}
.skeleton-row--avatar{width:2.2rem;height:2.2rem;border-radius:50%;flex:none}
.skeleton-row--lines{flex:1;height:1.6rem}

.compose-card__header-actions{display:flex;align-items:center;gap:.4rem}

.group-chips{display:flex;flex-wrap:wrap;gap:.4rem;margin:.6rem 0 1rem}
.group-chip{border:1px solid var(--border);background:var(--panel);color:var(--muted);font-family:var(--font-display);font-size:.78rem;font-weight:600;padding:.35rem .7rem;border-radius:999px;display:flex;align-items:center;gap:.35rem}
.group-chip:hover{background:var(--hover);color:var(--text)}
.group-chip.is-active{background:var(--primary);color:#fff;border-color:var(--primary)}
.group-chip__count{font-size:.72rem;opacity:.8}

.menu__item--checkbox{display:flex;align-items:center;gap:.5rem;cursor:pointer}
.menu__item--checkbox input{accent-color:var(--primary)}

/* ---------- filter condition rows ---------- */
.flt-condition{display:flex;align-items:center;gap:.4rem;margin-bottom:.5rem}
.flt-condition .flt-cond-field{flex:none;width:6rem}
.flt-condition .flt-cond-op{flex:none;width:7rem}
.flt-condition .flt-cond-value{flex:1;min-width:0;padding:.5rem .6rem;border:1px solid var(--border);border-radius:var(--radius);background:var(--panel);color:var(--text);font-family:var(--font-body);font-size:.85rem}
.flt-cond-remove{flex:none;color:var(--muted)}
.flt-cond-remove:hover{color:var(--danger)}

/* A native-feeling notification card, not a dim pill easy to miss at the
   bottom of the screen -- same top-right corner and card treatment the
   browser's own popups (password managers, permission prompts) use,
   which is exactly the real estate someone's eye already goes to. */
.toast{position:fixed;top:1.25rem;right:1.25rem;left:auto;bottom:auto;transform:none;display:flex;align-items:flex-start;gap:.7rem;background:var(--panel);color:var(--text);border:1px solid var(--border);padding:.9rem 1rem;border-radius:var(--radius-lg);font-size:.9rem;font-weight:500;box-shadow:var(--shadow-lg);z-index:300;max-width:min(360px,calc(100vw - 2rem));text-align:left}
.toast__icon{flex:none;width:1.6rem;height:1.6rem;border-radius:50%;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb, var(--primary) 15%, transparent);color:var(--primary);margin-top:.05rem}
.toast.is-error .toast__icon{background:color-mix(in srgb, var(--danger) 15%, transparent);color:var(--danger)}
.toast__msg{flex:1;min-width:0;line-height:1.4;padding-top:.15rem}
.toast__close{flex:none;border:0;background:transparent;color:var(--muted);width:1.5rem;height:1.5rem;border-radius:7px;display:flex;align-items:center;justify-content:center}
.toast__close:hover{background:var(--hover);color:var(--text)}
.toast[hidden]{display:none}
.toast:not([hidden]){animation:toast-in .35s var(--ease)}
.toast.is-leaving{animation:toast-out .18s ease forwards}
@keyframes toast-in{from{opacity:0;transform:translate(16px,-8px) scale(.94)}to{opacity:1;transform:none}}
@keyframes toast-out{from{opacity:1;transform:none}to{opacity:0;transform:translate(16px,-4px) scale(.96)}}
@media (prefers-reduced-motion:reduce){.toast:not([hidden]),.toast.is-leaving{animation:none}}
.toast.is-error{border-color:color-mix(in srgb, var(--danger) 35%, var(--border))}

/* Undo-send stays in its own bottom-center spot, action-oriented (you
   need to catch it to cancel a send) rather than a passive status
   message, so it doesn't compete with the toast's corner. */
.undo-send-stack{position:fixed;left:50%;bottom:1.5rem;transform:translateX(-50%);z-index:110;display:flex;flex-direction:column-reverse;gap:.5rem;pointer-events:none}
.undo-send-bar{pointer-events:auto;display:flex;align-items:center;gap:.9rem;background:var(--ocean-900);color:#fff;padding:.6rem .7rem .6rem 1.1rem;border-radius:999px;box-shadow:var(--shadow-md);font-size:.85rem;white-space:nowrap;animation:wizard-in .2s ease}
.undo-send-bar__btn{border:1px solid rgba(255,255,255,.3);background:transparent;color:#fff;font-family:var(--font-display);font-weight:600;font-size:.8rem;padding:.35rem .8rem;border-radius:999px;flex:none}
.undo-send-bar__btn:hover{background:rgba(255,255,255,.12)}

/* ---------- dropdown menu (Move to folder / More actions) ---------- */
.menu-wrap{position:relative}
.menu{position:absolute;top:calc(100% + 6px);right:0;min-width:180px;max-height:280px;overflow-y:auto;background:var(--panel);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-lg);z-index:150;padding:.35rem}
/* Toggled on by positionMenu() in app.js whenever there isn't room to
   open downward -- e.g. a trigger near the bottom of a scrollable list
   or modal, which would otherwise clip the menu against that
   container's own scroll boundary instead of showing it. */
.menu.menu--up{top:auto;bottom:calc(100% + 6px)}
/* Opens UPWARD unconditionally instead of the shared .menu default -- this
   one's anchor button lives in the compose footer, near the bottom of
   the card, and it's taller than the other footer menus (hint text +
   a date field + a button, not just a short list), so opening downward
   like the default pushed it below the card entirely, forcing a scroll
   just to reach "Schedule". Growing upward lands it over the message
   body instead, which always has room. */
.schedule-menu{top:auto;bottom:calc(100% + 6px);width:270px;padding:.8rem}
.schedule-menu .dialog-card__input{margin:0}
.menu[hidden]{display:none}
.menu__item{display:block;width:100%;text-align:left;padding:.55rem .7rem;border:0;background:transparent;color:var(--text);font-family:var(--font-body);font-size:.85rem;border-radius:7px}
.menu__item:hover{background:var(--hover)}
.menu__item--danger{color:var(--danger)}
.menu__item--danger:hover{background:rgba(192,57,43,.1)}
.menu__empty{padding:.6rem .7rem;color:var(--muted);font-size:.82rem}

/* ---------- folder gist (readpane empty state) ---------- */
.readpane__empty{display:flex;align-items:flex-start;justify-content:center;padding-top:8vh}
/* max-width was a leftover from when this was just a short centered
   caption (counts + a hint) -- now that it also holds real list content
   (flagged messages, scheduled sends, frequent senders), keeping it
   pinned to 416px meant a 1440px-wide screen left the vast majority of
   the reading pane empty on both sides while those lists stacked
   vertically with room to spare beside them. Wide enough now for the
   three list sections to actually sit as columns instead (see
   .folder-gist__columns below); the header/stats above stay centered
   since those are still just a short caption, not a list. */
.folder-gist{width:100%;max-width:64rem;padding:0 1.5rem;text-align:center}
.folder-gist__columns{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,400px));justify-content:center;gap:1.6rem;margin-top:1.4rem;text-align:left}
.folder-gist h2{margin:0 0 1.4rem;font-family:var(--font-display);font-size:1.4rem;font-weight:600;color:var(--text)}
.folder-gist__stats{display:flex;justify-content:center;gap:2rem;margin-bottom:1.2rem}
.gist-stat{display:flex;flex-direction:column;align-items:center}
.gist-stat__num{font-family:var(--font-display);font-size:1.6rem;font-weight:700;color:var(--primary)}
.gist-stat__label{font-size:.76rem;color:var(--muted);text-transform:uppercase;letter-spacing:.03em;margin-top:.1rem}
.folder-gist__dates{font-size:.84rem;color:var(--muted);margin-bottom:1.4rem;line-height:1.6}
.folder-gist__insight{display:flex;align-items:center;gap:.5rem;font-size:.82rem;color:var(--muted);background:var(--hover);border-radius:999px;padding:.5rem .9rem;margin:-.8rem 0 1.4rem;width:fit-content}
.folder-gist__insight svg{flex:none;color:var(--primary)}
.folder-gist__insight strong{color:var(--text);font-weight:600}
/* One shared top border on the row itself, not per-section -- three
   individual borders looked like a broken shelf whenever fewer than
   three of these were visible at once (usually the case). */
.folder-gist__columns:has(.folder-gist__senders:not([hidden])){border-top:1px solid var(--border);padding-top:1.1rem}
.folder-gist__senders h3{margin:0 0 .7rem;font-family:var(--font-display);font-size:.8rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.03em;text-align:left}
.gist-sender{display:flex;align-items:center;gap:.6rem;padding:.4rem .5rem;margin:0 -.5rem;border-radius:var(--radius);cursor:pointer;transition:background .15s var(--ease)}
.gist-sender:hover{background:var(--hover)}
.gist-sender:hover .gist-sender__name{color:var(--primary)}
.gist-sender .avatar{width:1.8rem;height:1.8rem;font-size:.68rem;flex:none}
.gist-sender__name{flex:1;min-width:0;font-size:.85rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gist-sender__count{font-size:.78rem;color:var(--muted);flex:none}
.folder-gist__hint{color:var(--muted);font-size:.9rem}

/* ---------- settings: layout picker, switches, quota, server info ---------- */
.segmented{display:flex;border:1px solid var(--border);border-radius:999px;padding:.2rem;gap:.2rem}
.segmented__btn{flex:1;border:0;background:transparent;color:var(--muted);font-family:var(--font-display);font-size:.8rem;font-weight:600;padding:.45rem .5rem;border-radius:999px;transition:background .15s var(--ease),color .15s var(--ease),box-shadow .15s var(--ease)}
.segmented__btn:hover{color:var(--text)}
.segmented__btn.is-active{background:var(--primary);color:#fff;box-shadow:0 2px 8px color-mix(in srgb, var(--primary) 40%, transparent)}
.switch-row{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.5rem 0;font-size:.86rem;color:var(--text)}
/* A real sliding pill toggle instead of a native checkbox stretched
   with accent-color -- that approach renders differently (and looks
   pretty rough) across Chrome/Safari/Firefox since it's still
   fundamentally a checkbox wearing a costume, not an actual switch. */
.switch-row input[type=checkbox]{
  appearance:none;-webkit-appearance:none;width:38px;height:22px;flex:none;
  border-radius:999px;background:var(--border);position:relative;cursor:pointer;
  outline:0;transition:background .2s var(--ease);
}
.switch-row input[type=checkbox]::before{
  content:'';position:absolute;top:2px;left:2px;width:18px;height:18px;
  border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.25);
  transition:transform .2s var(--ease);
}
.switch-row input[type=checkbox]:checked{background:var(--primary)}
.switch-row input[type=checkbox]:checked::before{transform:translateX(16px)}
.switch-row input[type=checkbox]:focus-visible{box-shadow:0 0 0 .2rem color-mix(in srgb, var(--primary) 25%, transparent)}
.switch-row--compact{padding:0 0 .9rem;font-size:.82rem;color:var(--muted)}
.quota-bar-wrap{margin-bottom:1rem}
.quota-bar{height:8px;border-radius:999px;background:var(--hover);overflow:hidden;margin-bottom:.4rem}
.quota-bar__fill{height:100%;background:var(--primary);border-radius:999px;transition:width .3s ease}
.quota-bar__fill.is-high{background:var(--danger)}
#mail-settings-tabs{margin-bottom:1rem}
.mail-settings-panel{border:1px solid var(--border);border-radius:var(--radius);padding:1rem 1.1rem;background:var(--hover)}
.mail-settings-panel__heading{margin:0 0 .2rem;font-family:var(--font-display);font-size:.92rem;font-weight:600}
.mail-settings-grid{display:grid;grid-template-columns:auto 1fr auto 1fr;gap:.5rem 1.5rem;font-size:.85rem;margin:0}
.mail-settings-grid dt{color:var(--muted);font-family:var(--font-display);font-weight:600}
.mail-settings-grid dd{margin:0;color:var(--text);font-family:var(--font-body);font-weight:500}

/* auto 1fr auto 1fr (not just auto 1fr) -- grid auto-placement fills
   left to right by default, so this puts two key/description pairs per
   row instead of one, halving an 11-row list down to 6 without
   touching the dt/dd markup pairing at all. */
.shortcuts-grid{display:grid;grid-template-columns:auto 1fr auto 1fr;gap:.7rem 1.5rem;font-size:.88rem;margin-bottom:1rem}
.shortcuts-grid dt{white-space:nowrap}
.shortcuts-grid dd{margin:0;color:var(--muted)}
kbd{display:inline-block;min-width:1.6em;padding:.15rem .45rem;border:1px solid var(--border);border-bottom-width:2px;border-radius:6px;background:var(--hover);color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.8rem;text-align:center}

@media (max-width: 900px){
  #view-app{grid-template-columns:56px 1fr}
  /* The rail track itself was correctly 56px here all along -- the
     labels underneath each icon (\"Compose\", \"Settings\", \"Theme\"...)
     were the actual problem: text that wide has nowhere to go in a
     56px column, so with no overflow handling it just rendered on top
     of the message list next to it instead of wrapping inside its own
     box. Icon-only below this width is the fix, not a wider rail --
     matches how every mobile app tab bar handles the same squeeze. */
  .rail__icon-label,.folder-btn span,.rail__compose-label{display:none}
  .rail__icon-btn,.folder-btn{overflow:hidden}
  .readpane{position:fixed;inset:0 0 0 56px;z-index:20;display:none}
  .readpane.is-open{display:flex}
  .back-btn{display:flex}
  .readpane__header{padding-left:3.1rem}
  .readpane__attachments,.readpane__actionbar,.images-banner{padding-left:1.1rem;padding-right:1.1rem}
  .compose-card{width:100%;max-width:100vw;height:100%;max-height:100vh;border-radius:0}
  .overlay{padding:0}
  .settings-body{max-height:none;flex:1}
  .identity-form.compose-form{height:100%}
  /* The rail keeps growing (folders, contacts, settings...) — on a short
     phone screen in landscape there's not always 56px * N icons of room.
     Scoped to just the folder list (not the whole .rail) so it can
     scroll internally without clipping the fixed icons' tooltips, which
     render outside the rail's own box via `left:calc(100% + 10px)` —
     overflow-y on an ancestor forces overflow-x to clip too per spec,
     and .rail itself was that ancestor before this was narrowed down to
     .rail__folders instead. */
  .rail__folders{overflow-y:auto;scrollbar-width:none;min-height:0}
  .rail__folders::-webkit-scrollbar{display:none}
  .bulk-bar{padding:.6rem .9rem;flex-wrap:wrap;gap:.5rem}
  .bulk-bar__actions{gap:0}
  .contact-add-form{flex-wrap:wrap}
  .contact-add-form input{min-width:120px}
  .autocomplete{max-height:45vh}
  .menu{right:auto;left:0;max-width:calc(100vw - 2rem)}
  .readpane__empty{padding-top:4vh}
}

@media (max-width: 480px){
  .identity-card{flex-wrap:wrap}
  .identity-card__badge{order:3}
  .search-bar{margin:.7rem .9rem 0}
  .listpane__header{padding:.9rem .9rem}
  .folder-gist__stats{gap:1.2rem}
  .gist-stat__num{font-size:1.3rem}
}
