/* DiwanMail — design tokens, light and dark. */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #0891b2;
  --accent-2: #0e7490;
  --accent-text: #ffffff;
  --accent-soft: #e0f7fb;
  --accent-softer: #f0fbfd;
  --cta: #f97316;
  --cta-2: #ea580c;
  --chrome-1: #1c2533;
  --chrome-2: #232d3b;
  --chrome-line: rgba(255, 255, 255, .08);
  --chrome-text: #cbd5e1;
  --ok: #157f4a; --ok-soft: #e3f5ea;
  --warn: #a15c00; --warn-soft: #fff3dc;
  --fail: #c62828; --fail-soft: #fde8e8;
  --star: #e8a400;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar: 68px;
  color-scheme: light;
}


* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
kbd { font: 11px var(--mono); padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--text-2); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.inline { display: inline-flex; gap: 6px; flex-wrap: wrap; margin: 0; align-items: center; }
.fail-text { color: var(--fail); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Icons */
.icon { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.icon.tiny { width: 14px; height: 14px; }
.icon.big { width: 40px; height: 40px; color: var(--muted); opacity: .6; }
.icon.huge { width: 64px; height: 64px; color: var(--muted); opacity: .35; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(37, 99, 235, .25); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.danger-text { color: var(--fail); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; flex: none;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { color: var(--fail); background: var(--fail-soft); }
.icon-btn.flip .icon { transform: rotate(180deg); }
.star-btn.on, .msg.flagged .star-btn { color: var(--star); }
.star-btn.on .icon, .msg.flagged .star-btn .icon { fill: var(--star); }

/* Inputs */
input:not([type=checkbox]):not([type=file]):not([type=radio]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 11px; width: 100%; min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 550; }
label.check { flex-direction: row; align-items: flex-start; gap: 9px; font-weight: normal; }
label.check input { margin-top: 3px; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: normal; }

/* Top bar */
.topbar {
  height: var(--topbar); display: flex; align-items: center; gap: 16px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -.01em; min-width: 220px; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; flex: none; }
.logo .icon { width: 18px; height: 18px; }
.logo.big { width: 48px; height: 48px; border-radius: 13px; }
.logo.big .icon { width: 26px; height: 26px; }
.search { flex: 0 1 620px; margin: 0; position: relative; display: flex; align-items: center; }
.search > .icon { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.search input[type=search] { background: var(--surface-2) !important; border-color: transparent !important; border-radius: 999px !important; padding: 9px 44px 9px 40px !important; }
.search input[type=search]:focus { background: var(--surface) !important; border-color: var(--accent) !important; }
.search-hint { position: absolute; right: 14px; pointer-events: none; }
.search:focus-within .search-hint { display: none; }
.compose-btn { display: none; }
.user-chip .avatar { width: 34px; height: 34px; }
.net-status { background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }

/* Avatars */
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none; font-weight: 650; font-size: 14px; color: #fff; user-select: none; }
.avatar.big { width: 44px; height: 44px; font-size: 17px; }
.avatar.c0 { background: #2563eb; } .avatar.c1 { background: #7c3aed; } .avatar.c2 { background: #db2777; } .avatar.c3 { background: #ea580c; }
.avatar.c4 { background: #059669; } .avatar.c5 { background: #0891b2; } .avatar.c6 { background: #4f46e5; } .avatar.c7 { background: #b45309; }

/* Menus */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border-radius: 7px;
  color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; width: 100%;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-panel .icon { color: var(--muted); }
.menu-panel form { margin: 0; }
.menu-user { padding: 8px 10px 10px; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.menu-label { padding: 6px 10px 2px; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Three-pane layout */
.mail-layout { display: grid; grid-template-columns: 240px var(--list-w, minmax(320px, 420px)) 7px 1fr; height: calc(100vh - var(--topbar)); }
.folders { padding: 14px 10px; background: var(--bg); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.compose-big { margin: 0 4px 14px; padding: 11px 16px; border-radius: 14px; justify-content: flex-start; font-size: 14.5px; box-shadow: var(--shadow); }
.folder-list, .folder-links { display: flex; flex-direction: column; gap: 1px; }
.folder-links { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.folder {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 999px;
  color: var(--text-2); font-weight: 550; transition: background .1s;
}
.folder .icon { color: var(--muted); }
.folder:hover { background: var(--surface-3); text-decoration: none; }
.folder.active { background: var(--accent-soft); color: var(--accent); }
.folder.active .icon { color: var(--accent); }
.folder.minor { font-weight: 500; font-size: 13.5px; }
.folder .folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font-size: 12px; font-weight: 700; }
.folder.depth-1 { margin-left: 18px; } .folder.depth-2 { margin-left: 34px; } .folder.depth-3 { margin-left: 50px; }

.list-pane {
  background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column; min-width: 0; position: relative;
}
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 8px 18px; }
.list-title { display: flex; flex-direction: column; min-width: 0; }
.bulk-bar {
  display: flex; align-items: center; gap: 4px; padding: 4px 10px 6px 18px; margin: 0;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 3; min-height: 44px;
}
.check-all { display: flex; align-items: center; margin-right: 6px; }
.bulk-actions { display: flex; gap: 0; align-items: center; transition: opacity .12s; }
.bulk-actions.dim { opacity: .35; pointer-events: none; }
.bulk-count { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-right: 4px; }
.move-to { display: inline-flex; align-items: center; }
.move-to select { width: auto; max-width: 110px; padding: 4px 6px; font-size: 12.5px; border-radius: 6px; }
.empty-btn { margin-left: auto; }

.msg-list { list-style: none; margin: 0; padding: 0; }
.msg {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px 11px 18px; border-bottom: 1px solid var(--border);
  position: relative; cursor: pointer; transition: background .1s, opacity .2s, transform .2s;
}
.msg:hover { background: var(--accent-softer); }
.msg.active { background: var(--accent-soft); }
.msg.active::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.msg.selected { background: var(--accent-soft); }
.msg.leaving { opacity: 0; transform: translateX(-12px); }
.msg-check { display: flex; align-items: center; position: absolute; left: 0; width: 18px; justify-content: center; opacity: 0; }
.msg:hover .msg-check, .msg.selected .msg-check, .msg-list:has(input:checked) .msg-check { opacity: 1; }
.msg-check input { width: 14px; height: 14px; }
.msg-link { flex: 1; min-width: 0; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.msg-link:hover { text-decoration: none; }
.msg-top, .msg-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.msg .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.msg .date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg .subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.msg.unread .who { font-weight: 700; color: var(--text); }
.msg.unread .subject { font-weight: 600; color: var(--text); }
.msg.unread .date { color: var(--accent); font-weight: 600; }
.msg.unread::before { content: ""; position: absolute; left: 6px; top: 50%; margin-top: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.msg:hover.unread::before, .msg.selected.unread::before { display: none; }
.row-tools { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: none; gap: 0; background: var(--surface); border-radius: 9px; box-shadow: var(--shadow); padding: 2px; }
.msg:hover .row-tools { display: flex; }
.row-tools .icon-btn { width: 30px; height: 30px; }
.msg.flagged .row-tools { display: flex; background: transparent; box-shadow: none; }
.msg.flagged .row-tools .icon-btn:not(.star-btn) { display: none; }
.msg.flagged:hover .row-tools { background: var(--surface); box-shadow: var(--shadow); }
.msg.flagged:hover .row-tools .icon-btn { display: inline-grid; }
.msg.flagged .date { margin-right: 26px; }
.empty-list { padding: 60px 16px; text-align: center; color: var(--muted); list-style: none; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; }

/* Loading */
.loading { position: relative; }
.loading > * { opacity: .55; transition: opacity .15s; }
.loading::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; z-index: 5;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat;
  animation: slide 1s linear infinite;
}
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* Banners */
.banner { display: flex; align-items: center; gap: 8px; padding: 9px 18px; font-size: 13px; font-weight: 550; border-bottom: 1px solid var(--border); }
.banner:hover { text-decoration: none; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.danger { background: var(--fail-soft); color: var(--fail); }
.banner.info { background: var(--accent-soft); color: var(--accent-2); }
.banner.inline { border: 0; border-radius: var(--radius-sm); margin-bottom: 14px; padding: 10px 14px; }
.banner.inline a { margin-left: auto; font-weight: 650; }

/* Reading pane */
.read-pane { overflow-y: auto; min-width: 0; background: var(--surface); }
.read-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); padding: 20px; text-align: center; }
.read-empty p { margin: 0; }
.read-toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 4;
}
.tool-group { display: flex; gap: 4px; align-items: center; }
.tool-group.right { margin-left: auto; }
.read-toolbar .back { display: none; }
.read-toolbar .menu-panel { max-height: 60vh; overflow-y: auto; }
.message { padding: 22px 28px 48px; max-width: 1000px; }
.message-subject { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 18px; overflow-wrap: anywhere; line-height: 1.3; }
.sender-card { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.sender-lines { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sender-name { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.recipients summary { cursor: pointer; list-style: none; display: inline-flex; gap: 4px; align-items: center; }
.recipients summary::-webkit-details-marker { display: none; }
.recipients summary::after { content: "▾"; font-size: 10px; }
.recipients dl { display: grid; grid-template-columns: 56px 1fr; gap: 3px 10px; margin: 8px 0 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.recipients dt { color: var(--muted); }
.recipients dd { margin: 0; }
.message-frame { display: block; width: 100%; min-height: 160px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.attachments { margin-top: 22px; }
.attachments h3 { display: flex; align-items: center; gap: 6px; }
.attachments ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.attachments a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.attachments a:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); text-decoration: none; }
.att-icon { font-size: 10px; font-weight: 800; padding: 9px 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); min-width: 40px; text-align: center; overflow: hidden; }
.att-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.quick-reply { display: flex; gap: 8px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }

/* Storage meter */
.storage { margin-top: auto; padding: 16px 12px 4px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.storage-row { display: flex; justify-content: space-between; font-weight: 600; }
.storage .ok { color: var(--ok); } .storage .warn { color: var(--warn); } .storage .fail { color: var(--fail); }
progress.meter { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
progress.meter::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress.meter::-webkit-progress-value { border-radius: 999px; background: var(--accent); }
progress.meter::-moz-progress-bar { border-radius: 999px; background: var(--accent); }
progress.meter.warn::-webkit-progress-value { background: var(--warn); } progress.meter.warn::-moz-progress-bar { background: var(--warn); }
progress.meter.fail::-webkit-progress-value { background: var(--fail); } progress.meter.fail::-moz-progress-bar { background: var(--fail); }

/* Toasts */
.toasts { position: fixed; left: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 48px); }
.toast {
  padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); background: #1f2633; color: #f3f5f9;
  font-weight: 500; animation: toast-in .2s ease-out; transition: opacity .3s, transform .3s; max-width: 460px;
}
.toast.success { border-left: 4px solid #34c77b; }
.toast.error { background: #b42318; color: #fff; }
.toast.info { border-left: 4px solid var(--accent); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* Shortcuts dialog */
.shortcuts { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); display: grid; place-items: center; z-index: 70; padding: 16px; }
.shortcuts-card { width: 100%; max-width: 440px; margin: 0; box-shadow: var(--shadow-lg); }
.shortcuts-card h2 { display: flex; align-items: center; gap: 8px; margin: 0; }
.shortcuts dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 14px 0 0; }
.shortcuts dd { margin: 0; color: var(--text-2); }

/* Cards and generic pages */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form h2 { margin: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 500; }
.flash.error { background: var(--fail-soft); color: var(--fail); }
.flash.success { background: var(--ok-soft); color: var(--ok); }
.flash.info { background: var(--accent-soft); color: var(--accent-2); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 650; line-height: 1; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.page-head { margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }
.crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 550; margin-bottom: 4px; }
.empty-page { max-width: 480px; margin: 80px auto; text-align: center; padding: 0 16px; }
.settings-page, .compose-page { max-width: 900px; margin: 0 auto; padding: 24px 20px 56px; }

/* Login */
body.bare { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; height: auto;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), radial-gradient(900px 500px at 110% 110%, var(--accent-softer), transparent), var(--bg); }
.login-wrap { width: 100%; max-width: 400px; }
.login { display: flex; flex-direction: column; gap: 16px; padding: 32px; margin: 0; box-shadow: var(--shadow-lg); }
.login-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 4px; }
.login-head h1 { font-size: 22px; }
.login-head p { margin: 0; }

/* Compose */
.compose { display: flex; flex-direction: column; gap: 10px; padding: 18px 22px 20px; }
.compose.dropping { outline: 2px dashed var(--accent); outline-offset: 4px; }
.compose.busy { opacity: .85; }
.compose-head { display: flex; align-items: center; gap: 8px; }
.compose-head h1 { font-size: 18px; }
.compose-status { margin-left: auto; }
.from-line { margin: -4px 0 4px 44px; }
.field-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding: 2px 0 6px; }
.field-row label { width: 64px; flex: none; color: var(--muted); font-weight: 550; }
.field-row input { border-color: transparent !important; box-shadow: none !important; padding-left: 4px !important; }
.editor-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 6px; }
.editor-toolbar { display: flex; gap: 2px; flex-wrap: wrap; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.editor-toolbar button { font: inherit; font-size: 13px; padding: 5px 10px; border-radius: 6px; border: 0; background: none; color: var(--text-2); cursor: pointer; }
.editor-toolbar button:hover { background: var(--surface); color: var(--text); }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 4px 4px; }
.editor-source { border: 0 !important; border-radius: 0 !important; font-family: var(--mono) !important; min-height: 300px; }
.editor { min-height: 340px; max-height: 62vh; overflow-y: auto; padding: 16px 18px; background: #fff; color: #1b1f24; outline: none; overflow-wrap: anywhere; font-size: 14.5px; }
.editor blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid #d0d5dd; color: #4b5563; }
.editor img { max-width: 100%; height: auto; }
.attach-area { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kept { list-style: none; padding: 0; margin: 0; width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.att-chip label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.att-chip.new { background: var(--accent-softer); border-color: var(--accent-soft); }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.chip-x:hover { color: var(--fail); }
.file-pick { flex-direction: row; cursor: pointer; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick:focus-within .btn { box-shadow: 0 0 0 3px var(--accent-soft); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.compose-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

/* Recipient autocomplete */
.has-suggest { position: relative; }
.suggest {
  position: absolute; left: 74px; right: 0; top: calc(100% - 2px); z-index: 30; list-style: none; margin: 0; padding: 4px;
  max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.suggest li { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.suggest li span { color: var(--muted); font-size: 12.5px; }
.suggest li.active, .suggest li:hover { background: var(--accent-soft); }

/* Settings, contacts, filters */
.folder-admin { list-style: none; margin: 0 0 14px; padding: 0; }
.folder-admin li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.folder-admin .folder-name { flex: 1; min-width: 140px; }
.folder-admin li.depth-1 { padding-left: 18px; } .folder-admin li.depth-2 { padding-left: 36px; }
.folder-admin .rename input { width: 150px; padding: 4px 8px; font-size: 13px; }
.new-folder { display: flex; gap: 8px; flex-wrap: wrap; }
.new-folder input { flex: 1 1 180px; } .new-folder select { flex: 0 1 200px; }
.settings-list { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.settings-list dt { color: var(--muted); } .settings-list dd { margin: 0; }
.settings-page .storage { padding: 0; margin: 0 0 10px; max-width: 360px; }
.contacts-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; align-items: start; }
.contacts-search { padding: 12px; border-bottom: 1px solid var(--border); margin: 0; }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.contact-list li:last-child { border-bottom: 0; }
.contact-list li.active { background: var(--accent-soft); }
.contact-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.contact-actions { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.card-title-row { display: flex; align-items: center; gap: 10px; }
.card-title-row h2 { margin: 0; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.filter-list { margin: 0 0 18px; padding: 0; list-style: none; counter-reset: f; }
.filter-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; counter-increment: f; }
.filter-list li::before { content: counter(f); color: var(--muted); font-size: 12px; width: 18px; text-align: right; }
.filter-list li.disabled .filter-text { color: var(--muted); text-decoration: line-through; }
.filter-text { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.filter-builder { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); margin: 0; }
.filter-builder h3 { margin: 0; }
.builder-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.builder-row > span { width: 36px; color: var(--muted); font-weight: 600; }
.builder-row select { width: auto; flex: 0 1 auto; }
.builder-row input { flex: 1 1 200px; width: auto; }

/* Responsive */
@media (max-width: 1180px) {
  .mail-layout { grid-template-columns: 210px var(--list-w, minmax(280px, 360px)) 7px 1fr; }
  .brand { min-width: 0; }
}
@media (max-width: 900px) {
  .brand-name, .search-hint { display: none; }
  .compose-btn { display: inline-flex; padding: 8px 10px; }
  .compose-btn span { display: none; }
  .mail-layout { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - var(--topbar)); align-content: start; }
  .folders { flex-direction: row; overflow-x: auto; padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .folder-list, .folder-links { flex-direction: row; }
  .folder-links { margin: 0; padding: 0; border: 0; }
  .folder { white-space: nowrap; padding: 7px 12px; }
  .folder.depth-1, .folder.depth-2, .folder.depth-3 { margin-left: 0; }
  .compose-big, .folders .storage { display: none; }
  .list-pane { border: 0; overflow: visible; }
  .read-pane { display: none; overflow: visible; }
  .pane-resizer { display: none; }
  body.reading .folders, body.reading .list-pane { display: none; }
  body.reading .read-pane { display: block; }
  .read-toolbar .back { display: inline-grid; }
  .read-toolbar { padding: 8px 10px; }
  .tool-group .btn span { display: none; }
  .message { padding: 16px 14px 36px; }
  .row-tools { display: none !important; }
  .msg-check { opacity: 1; position: static; width: auto; }
  .msg.unread::before { left: 3px; }
  .contacts-grid, .two-cols { grid-template-columns: 1fr; }
  .suggest { left: 0; }
  .settings-list { grid-template-columns: 1fr; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
}


/* --- Part of diwanmail.com: website navbar, white panes, cyan primary, orange compose --- */
body { background: #f8fafc; font-size: 14.5px; }
h1 { font-weight: 800; letter-spacing: -.02em; }
.btn { font-weight: 600; border-radius: .5rem; }
.btn.primary { background: #06b6d4; border-color: #06b6d4; }
.btn.primary:hover { background: #0891b2; border-color: #0891b2; }
input:not([type=checkbox]):not([type=radio]), select, textarea { border-color: #ced4da; border-radius: .5rem; }
input:focus, select:focus, textarea:focus { border-color: #06b6d4; box-shadow: 0 0 0 .2rem rgba(6, 182, 212, .2); }
.card { border-radius: 1rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08); }

/* Top bar = the website's navbar */
.topbar { background: var(--chrome-2); border-bottom: 1px solid var(--chrome-line); color: var(--chrome-text); padding: 0 24px; }
.brand { color: #fff; font-size: 1.2rem; letter-spacing: -.02em; min-width: 216px; }
.brand:hover { color: #fff; }
.brand-name b { color: var(--cta); font-weight: 800; }
.brand-icon { flex: none; }
.brand-sub { display: none; }
.search > .icon { color: #94a3b8; }
.search input[type=search] { background: rgba(255, 255, 255, .08) !important; color: #fff !important; }
.search input[type=search]::placeholder { color: #94a3b8; }
.search input[type=search]:focus { background: #fff !important; color: var(--text) !important; border-color: #22d3ee !important; box-shadow: 0 0 0 .2rem rgba(34, 211, 238, .25); }
.search:focus-within > .icon { color: var(--muted); }
.topbar kbd { background: transparent; color: #94a3b8; border-color: rgba(255, 255, 255, .2); }
.top-links { display: flex; align-items: center; gap: 4px; }
.top-links a { color: #cbd5e1; font-weight: 500; font-size: .95rem; padding: .45rem .75rem; border-radius: .5rem; display: inline-flex; align-items: center; gap: .4rem; }
.top-links a:hover, .top-links a.active { color: #fff; background: rgba(255, 255, 255, .06); text-decoration: none; }
.topbar .btn.primary, .btn.primary.compose-big { background: var(--cta); border-color: var(--cta); color: #fff; box-shadow: 0 4px 14px rgba(249, 115, 22, .35); }
.topbar .btn.primary:hover, .btn.primary.compose-big:hover { background: var(--cta-2); border-color: var(--cta-2); color: #fff; }
.user-chip .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .2); }

/* Folder list = the white menu card of Mail Control and the customer portal */
.folders { background: #fff; border-right: 1px solid var(--border); padding: 18px 12px; }
.folders .folder { color: #334155; border-radius: .5rem; }
.folders .folder .icon { color: #94a3b8; }
.folders .folder:hover { background: #f8fafc; color: var(--text); }
.folders .folder:hover .icon { color: #0891b2; }
.folders .folder.active { background: #ecfeff; color: #0891b2; font-weight: 600; box-shadow: none; }
.folders .folder.active .icon { color: #0891b2; }
.folders .folder .count { color: #0891b2; }
.list-pane { background: #fff; }
.read-pane { background: #fff; }
.msg.active::after { background: #06b6d4; }
body.bare { background: linear-gradient(135deg, #1c2533 0%, #232d3b 50%, #2a3647 100%); }
.login { border: 0; border-radius: 1rem; box-shadow: 0 30px 60px -15px rgba(0, 0, 0, .5); }

/* Draggable divider between the message list and the reading pane */
.list-pane { border-right: 0; }
.pane-resizer { position: relative; cursor: col-resize; background: #fff; touch-action: none; z-index: 2; outline: none; }
.pane-resizer::before { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: var(--border); transition: background .15s, width .15s, left .15s; }
.pane-resizer::after { content: ""; position: absolute; top: 50%; left: 1px; width: 5px; height: 36px; margin-top: -18px; border-radius: 999px;
  background: #cbd5e1; opacity: 0; transition: opacity .15s; }
.pane-resizer:hover::before, .pane-resizer:focus-visible::before, body.resizing .pane-resizer::before { left: 2px; width: 3px; background: #06b6d4; }
.pane-resizer:hover::after, .pane-resizer:focus-visible::after { opacity: 1; background: #06b6d4; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
body.resizing iframe { pointer-events: none; }

/* Mail app settings */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0 14px; }
.setup-grid > .setup-box:first-child { grid-column: 1 / -1; }
.setup-grid > .setup-box:first-child .setup-list { grid-template-columns: max-content 1fr max-content 1fr; }
.setup-box { border: 1px solid var(--border); border-radius: .75rem; padding: 14px 16px; background: #f8fafc; min-width: 0; }
.setup-box h3 { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; text-transform: none; letter-spacing: 0; margin: 0 0 10px; }
.setup-box h3 .icon { color: #0891b2; }
.setup-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.setup-list dt { color: var(--muted); }
.setup-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.copy-btn { font: inherit; font-size: 11.5px; font-weight: 600; color: #0891b2; background: #ecfeff; border: 1px solid #a5f3fc; border-radius: 999px;
  padding: 1px 9px; cursor: pointer; margin-left: 4px; }
.copy-btn:hover { background: #cffafe; }
.copy-btn.copied { color: #059669; background: #ecfdf5; border-color: #a7f3d0; }
.setup-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0 6px; }
.setup-sub { margin: 22px 0 10px; }
.howto { border: 1px solid var(--border); border-radius: .5rem; margin-bottom: 8px; background: #fff; }
.howto summary { padding: 11px 14px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: "+"; color: var(--muted); font-weight: 700; }
.howto[open] summary::after { content: "\2212"; }
.howto ol { margin: 0; padding: 0 18px 14px 34px; display: grid; gap: 6px; font-size: 13.5px; }
.setup-notes { margin: 0; padding-left: 20px; display: grid; gap: 7px; font-size: 13.5px; color: var(--text-2); }
@media (max-width: 760px) { .setup-grid { grid-template-columns: 1fr; } .setup-grid > .setup-box:first-child .setup-list { grid-template-columns: max-content 1fr; } }

/* Contacts, Filters, Settings and Setup open on the right of the mail menu */
.side-layout { grid-template-columns: 240px minmax(0, 1fr); }
.page-pane { overflow-y: auto; min-width: 0; background: #f8fafc; border-left: 1px solid var(--border); }
.page-pane .settings-page { margin: 0 auto; }
.folders .folder.minor.active { background: #ecfeff; color: #0891b2; font-weight: 600; }
.folders .folder.minor.active .icon { color: #0891b2; }
@media (max-width: 1180px) { .side-layout { grid-template-columns: 210px minmax(0, 1fr); } }
@media (max-width: 900px) {
  .side-layout { grid-template-columns: 1fr; }
  .page-pane { overflow: visible; border-left: 0; }
}

/* Moving messages: Restore button in Trash, drag and drop onto folders */
.restore-btn { padding: 4px 10px; font-size: 12.5px; gap: 5px; border-color: #a5f3fc; color: #0891b2; background: #ecfeff; }
.restore-btn:hover { background: #cffafe; border-color: #67e8f9; color: #0e7490; }
.restore-btn .icon { width: 15px; height: 15px; }
.msg[draggable="true"] { cursor: default; }
.msg.dragged { opacity: .45; }
body.dragging-mail .folders .folder[data-folder] { outline: 1px dashed transparent; }
.folders .folder.drop-over { background: #ecfeff !important; color: #0891b2 !important; outline: 2px dashed #06b6d4 !important; outline-offset: -2px; }
.drag-ghost { position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 999px; background: #0891b2; color: #fff; font: 600 13px Inter, sans-serif;
  box-shadow: 0 4px 14px rgba(8, 145, 178, .35); }
