/* Mestan Mail — Fluent / Outlook-inspired webmail. */
:root {
  --accent: #0f6cbd;
  --accent-dark: #0c5aa0;
  --topbar: #201f1e;
  --bg: #faf9f8;
  --pane: #ffffff;
  --line: #edebe9;
  --line-strong: #e1dfdd;
  --text: #201f1e;
  --muted: #605e5c;
  --hover: #f3f2f1;
  --sel: #e5f1fb;
  --sel-line: #cfe4fa;
  --unread-dot: #0f6cbd;
  --danger: #a4262c;
  --font: "Segoe UI", -apple-system, system-ui, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font-family: inherit; cursor: pointer; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.btn-link:hover { text-decoration: underline; }

/* Monochrome line icons — inherit text colour via currentColor. */
.ic { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; line-height: 0; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 20px; height: 20px; }

/* ---- Login ---- */
.login-wrap { position: fixed; inset: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, #0f6cbd 0%, #063b6b 100%); }
.login-card { width: 340px; background: #fff; border-radius: 8px; padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3); display: flex; flex-direction: column; }
.login-brand { font-size: 22px; font-weight: 600; }
.login-brand .logo { color: var(--accent); }
.login-sub { color: var(--muted); margin: 4px 0 20px; }
.login-card label { font-size: 12px; font-weight: 600; margin-bottom: 4px; color: #323130; }
.login-card input { padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 4px;
  margin-bottom: 14px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 9px; font-size: 14px; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* ---- App shell ---- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar { height: 48px; background: var(--topbar); color: #fff; display: flex; align-items: center;
  padding: 0 16px; gap: 16px; flex-shrink: 0; }
.brand { font-weight: 600; font-size: 16px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.brand .ic { color: #4aa3e8; }
/* org logo (branding) — replaces the default glyph when set in the admin panel */
.brand-img { display: block; width: auto; }
.brand .brand-img { height: 26px; max-width: 160px; }
.brand-logo.has-logo { width: auto; height: auto; }
.login-brand { display: inline-flex; align-items: center; gap: 8px; }
.login-logo.has-logo { color: inherit; }
.login-brand .brand-img { height: 34px; max-width: 210px; }
.modswitch { display: flex; gap: 2px; }
.mod { background: none; border: none; color: #cfd0d1; font-size: 13px; padding: 6px 12px; border-radius: 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.mod .ic { width: 15px; height: 15px; }
.mod:hover { background: rgba(255,255,255,.1); color: #fff; }
.mod.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.search { flex: 1; max-width: 620px; position: relative; }
.search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: #605e5c; pointer-events: none; }
.search input { width: 100%; height: 32px; border: none; border-radius: 4px; padding: 0 12px 0 34px; font-size: 14px; }
.search input:focus { outline: 2px solid #4aa3e8; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { font-size: 13px; opacity: .95; }
.user .btn-link { color: #cfe4fa; }
.icon-btn { background: none; border: none; color: #cfd0d1; cursor: pointer; padding: 4px; border-radius: 4px; display: inline-flex; }
.icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.icon-btn .ic { width: 18px; height: 18px; }

.cmdbar { height: 44px; background: var(--pane); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 10px; gap: 2px; flex-shrink: 0; }
.cmd { background: none; border: 1px solid transparent; border-radius: 4px; padding: 6px 10px;
  font-size: 13px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.cmd:hover:not(:disabled) { background: var(--hover); }
.cmd:disabled { color: #bcb9b6; cursor: default; }
.cmd-accent:not(:disabled) { color: var(--accent); font-weight: 600; }
.cmdbar .sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 6px; }

.shell { flex: 1; display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.mainpane { display: flex; min-width: 0; min-height: 0; }
.mainpane.pane-right { flex-direction: row; }
.mainpane.pane-right .list-pane { width: 380px; flex-shrink: 0; }
.mainpane.pane-right .reader { flex: 1; }
.mainpane.pane-bottom { flex-direction: column; }
.mainpane.pane-bottom .list-pane { width: auto; height: 42%; border-right: none; border-bottom: 1px solid var(--line); }
.mainpane.pane-bottom .reader { flex: 1; }
.mainpane.pane-hidden .list-pane { width: auto; flex: 1; border-right: none; }
.mainpane.pane-hidden .reader { display: none; }
.mainpane.pane-hidden.reading .list-pane { display: none; }
.mainpane.pane-hidden.reading .reader { display: flex; flex: 1; }
.rd-back { display: none; align-self: flex-start; background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 13px; align-items: center; gap: 5px; padding: 0 0 12px; }
.rd-back .ic { width: 14px; height: 14px; }
.mainpane.pane-hidden.reading .rd-back { display: inline-flex; }

/* Density */
body.compact .msg { padding: 5px 14px 5px 8px; }
body.compact .msg .m-avatar { width: 26px; height: 26px; }
body.compact .msg .m-snippet { display: none; }
body.compact .folder { padding: 5px 10px; }
body.compact .date-group { padding: 6px 14px 3px; }

/* Message preview lines */
.msglist[data-preview="0"] .m-snippet { display: none; }
.msglist[data-preview="2"] .m-snippet { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---- Folders ---- */
.folders { background: var(--pane); border-right: 1px solid var(--line); padding: 8px 6px; overflow-y: auto; }
.folder { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 4px;
  cursor: pointer; font-size: 14px; color: var(--text); }
.folder:hover { background: var(--hover); }
.folder.active { background: var(--sel); color: var(--accent-dark); font-weight: 600; }
.folder .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .f-count { font-size: 12px; color: var(--muted); }
.folder.has-unread .f-count { color: var(--accent); font-weight: 700; }
.folder .f-ico { width: 17px; height: 17px; opacity: .8; }
.folder .f-del { display: none; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1; }
.folder:hover .f-del { display: inline; }
.folder .f-del:hover { color: var(--danger); }
.folder.active .f-ico { opacity: 1; }

/* ---- Message list ---- */
.list-pane { background: var(--pane); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 14px;
  border-bottom: 1px solid var(--line); font-weight: 600; flex-shrink: 0; }
.list-count { font-size: 12px; color: var(--muted); font-weight: 400; }
.list-filters { margin-left: auto; display: flex; gap: 2px; }
.flt { background: none; border: none; font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 10px; border-radius: 4px; cursor: pointer; }
.flt:hover { background: var(--hover); }
.flt.active { color: var(--accent); background: var(--sel); }
.mark-all { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; }
.mark-all .ic { width: 14px; height: 14px; }

/* Selection bar */
.sel-bar { height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid var(--line);
  background: var(--sel); flex-shrink: 0; }
.sel-count { font-weight: 600; font-size: 13px; }
.sel-actions { display: flex; gap: 12px; }
.sel-bar .btn-link { font-size: 13px; }
.sel-clear { margin-left: auto; color: var(--muted); font-weight: 600; }

.msglist { flex: 1; overflow-y: auto; }
.date-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px 4px; }
.msg { display: grid; grid-template-columns: 22px 34px 1fr auto; gap: 8px; padding: 8px 14px 8px 8px;
  border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.msg .m-avatar { width: 32px; height: 32px; font-size: 12px; align-self: center; }
.m-sel { display: grid; place-items: center; }
.m-sel .m-check { display: none; width: 15px; height: 15px; cursor: pointer; margin: 0; }
.msg:hover .m-sel .dot, .msglist.selecting .m-sel .dot { display: none; }
.msg:hover .m-sel .m-check, .msglist.selecting .m-sel .m-check { display: inline-block; }
.msg.checked { background: var(--sel); }
.msg.checked .m-sel .m-check { display: inline-block; }
.msg.checked .m-sel .dot { display: none; }
.msg:hover { background: var(--hover); }
.msg.sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.msg .dot { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.msg.unread .dot { background: var(--unread-dot); }
.msg .m-main { min-width: 0; }
.msg .m-row1 { display: flex; align-items: baseline; gap: 8px; }
.msg .m-from { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.msg.unread .m-from { font-weight: 700; }
.msg .m-date { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.m-failed { color: var(--danger); font-size: 13px; }
.failed-bar { display: flex; align-items: center; gap: 8px; background: #fdecea; color: #a4262c; border: 1px solid #f3c9c6;
  border-radius: 6px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.failed-bar .ic { width: 16px; height: 16px; }
:root.dark .failed-bar { background: #3a2020; color: #f3a6a1; border-color: #6a2f2c; }
/* conversation threads */
.th-chev { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 12px; padding: 0;
  transition: transform .15s; align-self: center; }
.th-chev.open { transform: rotate(90deg); }
.th-count { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--line); border-radius: 9px;
  padding: 0 6px; min-width: 16px; text-align: center; flex-shrink: 0; }
.msg.unread .th-count { background: var(--accent); color: #fff; }
.msg.thread-child { padding-left: 26px; background: color-mix(in srgb, var(--hover) 40%, transparent); }
.msg.thread-child .m-avatar { width: 26px; height: 26px; }
.msg .m-subject { font-size: 13px; color: #323130; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .m-subject { color: var(--accent-dark); font-weight: 600; }
.msg .m-snippet { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .m-icons { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.msg .m-flag.on { color: #c19c00; }
.list-more { text-align: center; padding: 8px; border-top: 1px solid var(--line); }
.empty-note { color: var(--muted); text-align: center; padding: 40px 20px; }

/* New-folder row + move menu */
.new-folder { display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin-top: 6px; border-radius: 4px;
  cursor: pointer; font-size: 13px; color: var(--muted); }
.new-folder:hover { background: var(--hover); color: var(--accent); }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.menu-item:hover { background: var(--sel); }
.menu-item .ic { width: 16px; height: 16px; color: var(--muted); }

/* Settings + event delete */
.set-body { padding: 16px 18px; }
.set-label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 8px; }
.set-sigbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.set-sigbar .btn-link { display: inline-flex; align-items: center; gap: 6px; }
.set-sigbar .ic { width: 15px; height: 15px; }
.set-hint { font-size: 12px; }
#settings .evt-card { width: 680px; max-width: 94vw; }
#sg-toolbar { border: 1px solid var(--line-strong); border-bottom: none; border-radius: 4px 4px 0 0; margin-bottom: 0; }
.set-sig { width: 100%; min-height: 240px; max-height: 52vh; overflow: auto; border: 1px solid var(--line-strong); border-radius: 0 0 4px 4px;
  padding: 10px 12px; font-family: inherit; font-size: 14px; outline: none; }
.set-sig:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.set-sig:empty::before { content: attr(data-placeholder); color: #a19f9d; }
.set-sig img { max-width: 100%; }

/* ---- User menu (topbar) ---- */
.user { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; background: none; border: none; color: #fff; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.user-btn:hover { background: rgba(255,255,255,.12); }
.user-caret { font-size: 10px; opacity: .8; }
.user-menu { position: absolute; top: 46px; right: 0; width: 260px; background: #fff; color: var(--text);
  border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.28); overflow: hidden; z-index: 200; }
.um-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.um-head .avatar { width: 44px; height: 44px; font-size: 16px; }
.um-name { font-weight: 600; font-size: 14px; }
.um-id .muted { font-size: 12px; }
.um-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; text-align: left;
  padding: 11px 16px; font-size: 14px; cursor: pointer; color: var(--text); }
.um-item:hover { background: var(--hover); }
.um-item .ic { width: 16px; height: 16px; color: var(--muted); }
.um-quota { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.um-quota-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.um-quota-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s; }
.um-quota-bar span.q-warn { background: #d19a1e; }
.um-quota-bar span.q-danger { background: var(--danger); }
.um-quota-text { margin-top: 6px; font-size: 11.5px; color: var(--muted); }

/* ---- Settings panel ---- */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 100; }
.settings-card { width: 1008px; max-width: 94vw; height: 600px; max-height: 90vh; background: #fff; border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.settings-head { background: var(--topbar); color: #fff; padding: 12px 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.settings-head .ic { width: 17px; height: 17px; }
.settings-head .cp-x { margin-left: auto; }
.settings-body { flex: 1; display: flex; min-height: 0; }
.settings-nav { width: 210px; flex-shrink: 0; border-right: 1px solid var(--line); padding: 10px 8px; background: var(--bg); overflow-y: auto; }
.snav { display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: none; text-align: left;
  padding: 9px 12px; border-radius: 5px; font-size: 14px; cursor: pointer; color: var(--text); }
.snav:hover { background: var(--hover); }
.snav.active { background: var(--sel); color: var(--accent-dark); font-weight: 600; }
.snav .ic { width: 16px; height: 16px; }
.settings-content { flex: 1; padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; }
.ssec { display: flex; flex-direction: column; min-height: 0; }
.ssec-title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.ssec-hint { font-size: 13px; margin: 0 0 16px; }
.ssec-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; max-width: 420px; }
.fld > span { font-size: 13px; font-weight: 600; color: #323130; }
.fld input, .fld textarea { border: 1px solid var(--line-strong); border-radius: 4px; padding: 8px 10px; font-size: 14px; font-family: inherit; }
.fld input:focus, .fld textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.chk { display: flex; align-items: center; gap: 9px; font-size: 14px; margin-bottom: 16px; cursor: pointer; }

/* Theme swatches */
.theme-swatches { display: flex; flex-wrap: wrap; gap: 14px; }
.swatch { width: 76px; height: 76px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; display: grid;
  place-items: end center; padding-bottom: 6px; color: #fff; font-size: 11px; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.swatch.active { border-color: #201f1e; }
.swatch .chk-mark { font-size: 16px; }

/* Client setup info */
.client-info { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.ci-group { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.ci-group h4 { margin: 0; padding: 8px 12px; background: var(--bg); font-size: 13px; border-bottom: 1px solid var(--line); }
.ci-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; font-size: 13px; border-top: 1px solid var(--line); }
.ci-row:first-of-type { border-top: none; }
.ci-row .ci-k { width: 130px; color: var(--muted); flex-shrink: 0; }
.ci-row .ci-v { font-family: Consolas, monospace; }
.set-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.set-foot .btn-primary { padding: 8px 22px; }
.ee-delete { color: var(--danger); }
.ee-delete:hover { text-decoration: underline; }

/* ---- Reading pane ---- */
.reader { background: var(--pane); display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.reader-empty { margin: auto; color: var(--muted); font-size: 15px; }
.reader-body { padding: 20px 28px; display: flex; flex-direction: column; min-height: 0; }
#rd-subject { font-size: 21px; font-weight: 600; margin: 0 0 14px; line-height: 1.3; }
.rd-meta { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; color: #fff; font-weight: 600;
  display: grid; place-items: center; font-size: 15px; background-size: cover; background-position: center; overflow: hidden; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.rd-from { flex: 1; min-width: 0; line-height: 1.5; }
.rd-date { font-size: 13px; white-space: nowrap; }
.images-bar { background: #fff4ce; border: 1px solid #f2e9b8; border-radius: 4px; padding: 8px 12px;
  margin: 12px 0 0; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.attach-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.attach { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 6px 12px; font-size: 13px; text-decoration: none; color: var(--text); background: var(--bg); }
.attach:hover { border-color: var(--accent); color: var(--accent); }
.attach .ic { width: 15px; height: 15px; color: var(--muted); }
.attach .a-size { color: var(--muted); font-size: 12px; }
.images-bar .ic { width: 15px; height: 15px; color: #8a6d00; }
.reader-frame { border: none; width: 100%; margin-top: 16px; min-height: 80px; background: var(--pane); border-radius: 6px; }

/* Meeting invitation card */
.invite-card { border: 1px solid var(--sel-line); background: var(--sel); border-radius: 8px; padding: 14px 16px; margin-top: 16px; }
.inv-line { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 3px 0; }
.inv-line .ic { width: 16px; height: 16px; color: var(--accent-dark); }
.inv-rsvp { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inv-q { font-size: 13px; color: var(--muted); margin-right: 2px; }
.inv-btn { border: 1px solid var(--line-strong); background: #fff; border-radius: 4px; padding: 7px 16px; font-size: 13px; cursor: pointer; font-weight: 600; }
.inv-btn:hover { filter: brightness(0.97); }
.inv-btn.accept { color: #107c41; border-color: #8fd0a8; }
.inv-btn.decline { color: var(--danger); border-color: #e6a6a9; }
.inv-btn.tentative { color: #8a6d00; border-color: #e6d48a; }
.inv-btn:disabled { opacity: .5; cursor: default; }
.inv-desc { margin-top: 8px; font-size: 14px; white-space: pre-wrap; color: var(--text); }
.inv-status { margin-top: 10px; font-weight: 600; color: var(--accent-dark); }

/* ---- Calendar view ---- */
.calview { flex: 1; display: flex; flex-direction: column; background: var(--pane); min-height: 0; }
.cal-toolbar { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.cal-btn { border: 1px solid var(--line-strong); background: #fff; border-radius: 4px; padding: 6px 14px; font-size: 13px; cursor: pointer; }
.cal-btn:hover { background: var(--hover); }
.cal-nav { border: 1px solid var(--line-strong); background: #fff; border-radius: 4px; width: 30px; height: 30px; font-size: 16px; cursor: pointer; line-height: 1; }
.cal-nav:hover { background: var(--hover); }
.cal-title { font-size: 18px; font-weight: 600; margin-left: 8px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-weekdays div { padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; }
.cal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; min-height: 0; }
.cal-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 6px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.cal-cell.other { background: #fbfbfa; }
.cal-daynum { font-size: 12px; color: var(--muted); align-self: flex-end; }
.cal-cell.today .cal-daynum { background: var(--accent); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-weight: 600; }
.cal-event { background: var(--accent); color: #fff; border-radius: 3px; padding: 1px 6px; font-size: 12px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.allday { background: #107c41; }
.cal-event:hover { filter: brightness(1.1); }
.cal-empty { margin: auto; color: var(--muted); }

/* ---- Event popup ---- */
.evt-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 95; }
.evt-card { width: 420px; max-width: 92vw; background: #fff; border-radius: 8px; box-shadow: 0 16px 48px rgba(0,0,0,.35); overflow: hidden; }
.evt-head { background: var(--accent); color: #fff; padding: 14px 18px; font-size: 17px; font-weight: 600; display: flex; align-items: center; }
.evt-head .cp-x { margin-left: auto; }
.evt-body { padding: 16px 18px; }
.evt-row { display: flex; gap: 10px; padding: 6px 0; font-size: 14px; align-items: flex-start; }
.evt-ico { width: 17px; height: 17px; flex-shrink: 0; color: var(--muted); }
.cal-new { color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.cal-new .ic { width: 15px; height: 15px; }

/* Event editor (reuses .compose-card / .cf-row) */
.compose-head #ee-heading { margin-right: auto; }
.cf-row .ee-date, .cf-row .ee-time { flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 4px 8px; height: 30px; font-size: 14px; font-family: inherit; }
.cf-row .ee-date { width: 155px; }
.cf-row .ee-time { width: 115px; }
.ee-inline { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-left: auto; }
.ee-inline input { width: auto; }

/* ---- Recipient autocomplete ---- */
.ac-dropdown { position: fixed; z-index: 100; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); max-height: 260px; overflow-y: auto; min-width: 260px; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.ac-item:hover, .ac-item.active { background: var(--sel); }
.ac-item .avatar { width: 30px; height: 30px; font-size: 12px; }
.ac-item .ac-name { font-size: 14px; }
.ac-item .ac-email { font-size: 12px; color: var(--muted); }

/* ---- Compose ---- */
.compose-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 90; }
.compose-card { width: 1080px; max-width: 88vw; height: 760px; max-height: 88vh; background: #fff;
  border-radius: 8px; box-shadow: 0 16px 48px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.compose-card.maximized { width: 96vw; height: 94vh; max-width: 96vw; max-height: 94vh; }
.compose-head { background: var(--topbar); color: #fff; padding: 10px 16px; font-weight: 600;
  display: flex; align-items: center; }
.cp-x { margin-left: auto; background: none; border: none; color: #fff; font-size: 15px; cursor: pointer; opacity: .8; }
.cp-x:hover { opacity: 1; }
.compose-fields { padding: 4px 16px; }
.cf-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.cf-row label { width: 60px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.cf-row input { flex: 1; border: none; outline: none; padding: 10px 0; font-size: 14px; font-family: inherit; }
.cf-row .btn-link { flex-shrink: 0; }
.compose-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 5px 10px;
  border-bottom: 1px solid var(--line); background: var(--bg); }
.compose-toolbar .tb-select { height: 28px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: #fff; font-size: 13px; font-family: inherit; padding: 0 4px; cursor: pointer; }
.compose-toolbar .tb-size { width: 84px; }
.tb-btn { min-width: 28px; height: 28px; border: 1px solid transparent; border-radius: 4px; background: none;
  font-size: 14px; color: var(--text); cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; padding: 0 6px; position: relative; }
.tb-btn:hover { background: #e8e6e4; border-color: var(--line-strong); }
.tb-btn.active { background: var(--sel); border-color: var(--sel-line); color: var(--accent-dark); }
.tb-color { overflow: hidden; }
.tb-color input[type=color] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.compose-toolbar .tb-sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 5px; }

.compose-body { flex: 1; padding: 14px 16px; overflow-y: auto; font-size: 14px; line-height: 1.5; outline: none;
  font-family: 'Segoe UI', system-ui, Arial, sans-serif; }
.compose-body:empty::before { content: attr(data-placeholder); color: #a19f9d; }
.compose-body ul, .compose-body ol { margin: 0 0 0 4px; padding-left: 24px; }
.compose-body a { color: var(--accent); }
.compose-attach { padding: 0 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.compose-attach:not(:empty) { padding-bottom: 10px; }
.cp-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 5px 10px; font-size: 13px; }
.cp-chip button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 14px; }
.compose-foot { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); }
.compose-foot .btn-primary { padding: 8px 22px; }
.cp-send { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.compose-head .cp-x { margin-left: 0; }
.compose-head #cp-title { margin-right: auto; }

/* ---- Dialog boxes ---- */
.dlg-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 1000; }
.dlg-card { width: 390px; max-width: 92vw; background: #fff; border-radius: 8px; box-shadow: 0 16px 48px rgba(0,0,0,.35); padding: 20px 22px; }
.dlg-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.dlg-msg { font-size: 14px; color: #323130; line-height: 1.5; white-space: pre-wrap; }
.dlg-input { width: 100%; margin-top: 14px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 4px; font-size: 14px; font-family: inherit; }
.dlg-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.dlg-btn { padding: 8px 18px; border: 1px solid var(--line-strong); background: #fff; border-radius: 4px; font-size: 13px; cursor: pointer; }
.dlg-btn:hover { background: var(--hover); }
.dlg-foot .btn-primary { padding: 8px 18px; }
.dlg-danger { background: var(--danger); }
.dlg-danger:hover { background: #8a1f24; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #323130; color: #fff; padding: 10px 18px; border-radius: 4px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); z-index: 100; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 200px 1fr; }
  .mainpane.pane-right .list-pane { width: 320px; }
}

/* ---- Dark mode ---- */
:root.dark {
  color-scheme: dark;
  --bg: #1b1a19;
  --pane: #292827;
  --line: #3b3a39;
  --line-strong: #494847;
  --text: #f3f2f1;
  --muted: #a19f9d;
  --hover: #3b3a39;
  --topbar: #0d0c0c;
}
:root.dark .compose-card, :root.dark .dlg-card, :root.dark .evt-card, :root.dark .settings-card,
:root.dark .user-menu, :root.dark .ac-dropdown, :root.dark .login-card, :root.dark .cal-btn,
:root.dark .cal-nav, :root.dark .tb-select, :root.dark .dlg-btn { background: var(--pane); color: var(--text); }
:root.dark .m-subject, :root.dark .dlg-msg, :root.dark .fld > span, :root.dark .cf-row input,
:root.dark #cp-subject, :root.dark .set-sig, :root.dark .compose-body, :root.dark .cf-row label,
:root.dark .ee-title, :root.dark .set-label, :root.dark .snav, :root.dark .um-name { color: var(--text); }
:root.dark .swatch.active { border-color: #fff; }
/* Frame the white "sheet" only for rich HTML mail (which must stay light) in dark mode. */
.reader-frame.white-sheet { border: 1px solid var(--line-strong); box-shadow: 0 1px 6px rgba(0,0,0,.4); }
:root.dark .compose-fields input, :root.dark .cf-row input, :root.dark #cp-body,
:root.dark input, :root.dark textarea, :root.dark select { background: var(--pane); color: var(--text); }
:root.dark .msg.sel, :root.dark .msg.checked { color: var(--text); }
:root.dark .cal-cell.other { background: rgba(255,255,255,.03); }
:root.dark .toast { background: #000; }
