/* Outlook-style layout: header bar, command ribbon, folder pane, message list, reading pane.
   Own name and icons; no Microsoft name or logo. */
:root {
  --hdr: #0f6cbd; --hdr-ink: #ffffff; --hdr-field: #ffffff; --hdr-field-ink: #242424;
  --bg: #f0f0f0; --pane: #ffffff; --text: #242424; --muted: #616161; --faint: #8a8a8a;
  --line: #e0e0e0; --hover: #f5f5f5; --press: #e0e0e0; --navsel: #e6e6e6;
  --sel: #cfe4fa; --sel-hover: #bdd8f5;
  --acc: #0f6cbd; --acc-hover: #115ea3; --acc-ink: #ffffff; --link: #115ea3;
  --red: #c50f1f; --warnbg: #fff4ce; --warnink: #835b00;
  --shadow: 0 8px 16px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
  --card-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 2px rgba(0,0,0,.08);
  --font: 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
}
:root[data-theme="dark"] {
  --hdr: #0f548c; --hdr-ink: #ffffff; --hdr-field: #1f1f1f; --hdr-field-ink: #ffffff;
  --bg: #1f1f1f; --pane: #292929; --text: #ffffff; --muted: #adadad; --faint: #8f8f8f;
  --line: #3d3d3d; --hover: #333333; --press: #3d3d3d; --navsel: #3d3d3d;
  --sel: #0c3b5e; --sel-hover: #0e4775;
  --acc: #479ef5; --acc-hover: #62abf5; --acc-ink: #ffffff; --link: #62abf5;
  --red: #dc626d; --warnbg: #463100; --warnink: #f9e2ae;
  --shadow: 0 8px 16px rgba(0,0,0,.5), 0 0 2px rgba(0,0,0,.4);
  --card-shadow: 0 1px 2px rgba(0,0,0,.4);
}
[dir="rtl"] { --font: Tajawal, 'Segoe UI', Tahoma, Arial, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 400 14px/1.43 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; text-align: inherit; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .flip { transform: scaleX(-1); }
.grow { flex: 1; min-width: 0; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--muted); }
.addr { direction: ltr; unicode-bidi: isolate; }
.scroll { overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.av.lg { width: 40px; height: 40px; font-size: 15px; }
.av.sm { width: 20px; height: 20px; font-size: 9px; }

/* ---------- buttons ---------- */
.btn { height: 32px; padding: 0 12px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; white-space: nowrap;
  background: var(--pane); box-shadow: inset 0 0 0 1px var(--line); }
.btn:hover { background: var(--hover); }
.btn.pri { background: var(--acc); color: var(--acc-ink); box-shadow: none; }
[data-theme="dark"] .btn.pri { background: #115ea3; }
.btn.pri:hover { background: var(--acc-hover); }
[data-theme="dark"] .btn.pri:hover { background: #0f6cbd; }
.btn .ic { width: 18px; height: 18px; }
.ghost { height: 32px; padding: 0 8px; border-radius: 4px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text); }
.ghost .ic { color: var(--acc); }
.ghost:hover:not(:disabled) { background: var(--hover); }
.ghost:active:not(:disabled) { background: var(--press); }
.ghost:disabled { color: var(--faint); }
.ghost:disabled .ic { color: var(--faint); }
.iconbtn { width: 32px; height: 32px; border-radius: 4px; display: grid; place-items: center; color: var(--muted); flex: none; }
.iconbtn:hover { background: var(--hover); color: var(--acc); }
.sepv { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex: none; }

/* ---------- web mail ---------- */
#s-mail { height: 100%; display: flex; flex-direction: column; margin: 0 auto; }
#s-mail.narrow { max-width: 900px; box-shadow: 0 0 0 1px var(--line); }
.hdr { height: 48px; flex: none; background: var(--hdr); color: var(--hdr-ink); display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px; }
[dir="rtl"] .hdr { padding: 0 16px 0 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; white-space: nowrap; width: 212px; flex: none; }
.brand .ic { width: 22px; height: 22px; stroke-width: 1.75; }
.hsearch { flex: 1; max-width: 468px; position: relative; margin: 0 auto; }
.hsearch .ic { position: absolute; inset-inline-start: 10px; top: 7px; width: 18px; height: 18px; color: var(--acc); }
.hsearch input { width: 100%; height: 32px; border: 0; outline: 0; border-radius: 4px; padding-inline-start: 36px; padding-inline-end: 10px; background: var(--hdr-field); color: var(--hdr-field-ink); }
.hsearch input::placeholder { color: var(--muted); }
.hsearch input:focus { box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.hright { display: flex; align-items: center; gap: 4px; width: 212px; justify-content: flex-end; flex: none; }
.hbtn { width: 40px; height: 40px; border-radius: 4px; display: grid; place-items: center; color: var(--hdr-ink); }
.hbtn:hover { background: rgba(255,255,255,.14); }
.ribbon { flex: none; margin: 8px 8px 0; height: 44px; background: var(--pane); border-radius: 8px; box-shadow: var(--card-shadow); display: flex; align-items: center; gap: 2px; padding: 0 6px; overflow: hidden; }
.ribbon .btn.pri { margin-inline-end: 4px; }
.narrow .ribbon .ghost span { display: none; }
.body { flex: 1; min-height: 0; display: flex; gap: 8px; padding: 8px; }

.folders { width: 220px; flex: none; display: flex; flex-direction: column; }
.narrow .folders { display: none; }
.narrow.navopen .folders { display: flex; }
.fgroup { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; font-weight: 600; width: 100%; border-radius: 4px; }
.fgroup:hover { background: var(--hover); }
.fgroup .ic { width: 16px; height: 16px; }
.nav { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px; padding-inline-start: 22px; border-radius: 4px; width: 100%; position: relative; }
.nav:hover { background: var(--hover); }
.nav.on { background: var(--navsel); font-weight: 600; }
.nav.on::before { content: ''; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--acc); }
.nav .ic { color: var(--muted); }
.nav.on .ic { color: var(--acc); }
.nav .n { color: var(--acc); font-weight: 600; }
.navs { display: flex; flex-direction: column; gap: 1px; }

.list { width: 380px; flex: none; display: flex; flex-direction: column; background: var(--pane); border-radius: 8px; box-shadow: var(--card-shadow); overflow: hidden; }
.narrow .list { width: 330px; }
.lhead { display: flex; align-items: center; gap: 6px; padding: 10px 12px 0 16px; }
[dir="rtl"] .lhead { padding: 10px 16px 0 12px; }
.lhead h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; min-width: 0; }
.pivot { display: flex; gap: 4px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.pivot button { height: 36px; padding: 0 8px; position: relative; color: var(--muted); }
.pivot button.on { color: var(--text); font-weight: 600; }
.pivot button.on::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 2px; background: var(--acc); }
.lbody { flex: 1; min-height: 0; }
.ghd { display: flex; align-items: center; height: 32px; padding: 0 16px; font-weight: 600; font-size: 12px; color: var(--muted); background: var(--pane); position: sticky; top: 0; z-index: 1; }
.mrow { display: flex; gap: 12px; padding: 10px 14px 10px 16px; width: 100%; position: relative; border-bottom: 1px solid var(--line); align-items: flex-start; }
[dir="rtl"] .mrow { padding: 10px 16px 10px 14px; }
.mrow:hover { background: var(--hover); }
.mrow.on { background: var(--sel); }
.mrow.on:hover { background: var(--sel-hover); }
.mrow.unread::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--acc); }
.mrow .l2 { display: flex; align-items: baseline; gap: 8px; }
.mrow .who { font-size: 14px; }
.mrow .sub { flex: 1; min-width: 0; font-size: 13px; }
.mrow .t { font-size: 12px; color: var(--muted); flex: none; }
.mrow .pre { color: var(--muted); font-size: 13px; }
.mrow.unread .who { font-weight: 600; }
.mrow.unread .sub { font-weight: 600; color: var(--link); }
.mrow.unread .t { font-weight: 600; color: var(--link); }
.mrow .att { width: 14px; height: 14px; color: var(--muted); vertical-align: -2px; }
[dir="rtl"] .mrow .who, [dir="rtl"] .mrow .sub, [dir="rtl"] .mrow .pre { unicode-bidi: plaintext; text-align: right; }
.empty { height: 100%; min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; padding: 24px; }
.empty .ic { width: 48px; height: 48px; stroke-width: 1; color: var(--faint); }
.empty b { color: var(--text); font-size: 16px; font-weight: 600; }

.reader { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rscroll { flex: 1; min-height: 0; padding-inline-end: 2px; }
.rsubj { display: flex; align-items: center; gap: 8px; padding: 6px 4px 10px; }
.rsubj h2 { margin: 0; flex: 1; font-size: 20px; font-weight: 600; line-height: 1.3; unicode-bidi: plaintext; }
[dir="rtl"] .rsubj h2 { text-align: right; }
.mcard { background: var(--pane); border-radius: 8px; box-shadow: var(--card-shadow); padding: 16px 20px 24px; }
.mtop { display: flex; gap: 12px; align-items: flex-start; }
.mtop .who b { font-weight: 600; font-size: 14px; unicode-bidi: plaintext; }
.mtop .who .addr { color: var(--muted); font-size: 13px; }
.recips { margin-top: 2px; font-size: 13px; color: var(--muted); }
.recips .k { color: var(--muted); }
.mtools { display: flex; align-items: center; gap: 0; flex: none; }
.mtools .iconbtn { color: var(--acc); }
.mdate { font-size: 12px; color: var(--muted); text-align: end; margin-top: 2px; white-space: nowrap; }
.mbody { margin: 20px 0 0; padding-inline-start: 52px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; unicode-bidi: plaintext; max-width: 820px; }
.quote { margin-top: 16px; padding-inline-start: 12px; border-inline-start: 2px solid var(--line); color: var(--muted); white-space: pre-wrap; unicode-bidi: plaintext; font-size: 13px; }
.quote .qh { font-weight: 600; margin-bottom: 4px; white-space: normal; unicode-bidi: plaintext; }
.mbody .quote { margin-inline-start: 0; }
.atts { margin-top: 16px; padding-inline-start: 52px; display: flex; gap: 8px; flex-wrap: wrap; }
.attile { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line); min-width: 260px; background: var(--pane); }
.attile:hover { background: var(--hover); }
.attile .ic { width: 28px; height: 28px; color: var(--acc); stroke-width: 1.25; }
.attile b { display: block; font-weight: 600; font-size: 13px; }
.attile small { color: var(--muted); font-size: 12px; }
.mbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 4px; background: var(--warnbg); color: var(--text); margin-bottom: 12px; font-size: 13px; }
.mbar > .ic { color: var(--warnink); }
.mbar .link { color: var(--link); font-weight: 600; }
.mbar .link:hover { text-decoration: underline; }

/* compose */
.ccard { background: var(--pane); border-radius: 8px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; height: 100%; }
.cf { display: flex; align-items: center; gap: 6px; min-height: 40px; margin: 0 16px; border-bottom: 1px solid var(--line); position: relative; flex-wrap: wrap; padding: 4px 0; }
.cf .lbl { height: 28px; padding: 0 10px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line); font-weight: 400; flex: none; }
.cf .lbl:hover { background: var(--hover); }
.cf input { flex: 1; min-width: 140px; height: 30px; background: none; border: 0; outline: 0; }
.cf input#csub { font-size: 15px; }
.cf .cclinks { display: flex; gap: 12px; margin-inline-start: auto; }
.cf .cclinks button { color: var(--muted); }
.cf .cclinks button:hover { color: var(--link); text-decoration: underline; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline-start: 3px; padding-inline-end: 4px; border-radius: 13px; background: var(--bg); max-width: 100%; font-size: 13px; unicode-bidi: plaintext; }
.chip button { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.chip button:hover { background: var(--press); color: var(--text); }
.chip button .ic { width: 12px; height: 12px; stroke-width: 2; }
.chip.bad { background: var(--pane); box-shadow: inset 0 0 0 1px var(--red); color: var(--red); padding-inline-start: 10px; text-decoration: underline wavy; text-underline-offset: 3px; }
.suggest { position: absolute; top: calc(100% + 2px); inset-inline-start: 60px; width: 340px; z-index: 5; background: var(--pane); border-radius: 6px; box-shadow: var(--shadow); padding: 4px 0; }
.suggest .srow { display: flex; align-items: center; gap: 10px; padding: 6px 12px; width: 100%; }
.suggest .srow:hover, .suggest .srow.on { background: var(--hover); }
.suggest .srow b { display: block; font-weight: 600; font-size: 13px; }
.suggest .srow small { color: var(--muted); font-size: 12px; }
.cbody { flex: 1; min-height: 0; padding: 12px 16px; display: flex; flex-direction: column; overflow: auto; }
.cbody textarea { flex: none; min-height: 160px; background: none; border: 0; outline: 0; resize: none; font-size: 14px; line-height: 1.55; unicode-bidi: plaintext; }
.cfoot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

/* menus, toast, dialog */
.menu { position: fixed; z-index: 30; min-width: 220px; max-width: 300px; background: var(--pane); border-radius: 6px; box-shadow: var(--shadow); padding: 4px 0; }
.menu .mi { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 12px; width: 100%; }
.menu .mi:hover { background: var(--hover); }
.menu .mi .ic { color: var(--acc); }
.menu .mi.danger .ic { color: var(--muted); }
.menu .sepm { height: 1px; background: var(--line); margin: 4px 0; }
.menu small { display: block; color: var(--muted); font-size: 12px; }
#toast { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 60; background: #2b2b2b; color: #fff; border-radius: 4px; padding: 0 8px 0 16px; min-height: 44px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; max-width: 520px; }
[dir="rtl"] #toast { padding: 0 16px 0 8px; }
#toast .undo { color: #8ac2ff; font-weight: 600; padding: 6px 8px; border-radius: 4px; }
#toast .undo:hover { background: rgba(255,255,255,.1); }
#toast.err { background: var(--red); }
#toast span { padding: 10px 0; }
#dlg { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.4); display: grid; place-items: center; }
#dlg .box { width: 420px; background: var(--pane); border-radius: 8px; box-shadow: var(--shadow); padding: 24px; }
#dlg h3 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
#dlg p { margin: 0 0 24px; }
#dlg .acts { display: flex; gap: 8px; justify-content: flex-end; }

/* sign in */
#s-signin { min-height: 100%; display: grid; place-items: center; background: var(--bg); padding: 24px 12px; }
html:has(#s-signin), body:has(#s-signin) { overflow: auto; }
.sibox { width: 440px; background: var(--pane); border-radius: 8px; box-shadow: var(--shadow); padding: 40px 44px 36px; }
.sibrand { display: flex; align-items: center; gap: 10px; color: var(--acc); font-size: 18px; font-weight: 600; margin-bottom: 24px; }
.sibrand .ic { width: 26px; height: 26px; }
.sibox h1 { margin: 0 0 20px; font-size: 24px; font-weight: 600; }
.sibox .btn.pri { width: 100%; height: 36px; }
.mbpick { display: flex; flex-direction: column; margin: 0 -44px; }
.mbpick button { display: flex; align-items: center; gap: 12px; padding: 12px 44px; width: 100%; }
.mbpick button:hover { background: var(--hover); }
.mbpick b { display: block; font-weight: 600; }
.mbpick small { color: var(--muted); }

#s-mail { position: fixed; inset: 0; }
.btn.wide { width: 100%; height: 36px; }
.mbpick form { margin: 0; }
.mbpick small { display: block; }
.mbpick small + small { font-size: 12px; }
.silang { display: inline-block; margin-top: 22px; color: var(--link); text-decoration: none; font-size: 13px; }
.silang:hover { text-decoration: underline; }
.siout { margin-top: 18px; }
.linkbtn { color: var(--link); font-size: 13px; }
.linkbtn:hover { text-decoration: underline; }
.siflash { padding: 10px 12px; border-radius: 4px; background: var(--warnbg); margin-bottom: 16px; font-size: 13px; }
.siflash.err { background: var(--red); color: #fff; }
.sibox p { line-height: 1.5; }
.sibox .silang + .siout { margin-top: 8px; }
.offline { display: flex; align-items: center; gap: 8px; padding: 6px 12px; margin: 8px 8px 0; border-radius: 6px; background: var(--warnbg); font-size: 13px; flex: none; }
@media (max-width: 760px) {
  .brand span, .hright { display: none; }
  .brand { width: auto; }
  .folders { display: none; }
  .navopen .folders { display: flex; position: fixed; z-index: 20; inset: 48px auto 0 0; width: 240px; background: var(--bg); padding: 8px; box-shadow: var(--shadow); }
  .list { width: 100%; }
  .reader { position: fixed; inset: 48px 0 0 0; z-index: 10; background: var(--bg); padding: 8px; }
  .reader.hide-small { display: none; }
  .ribbon .ghost span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
