/* ============================================================
   وحدة البريد — نظام تصميم فاتح احترافي.
   لا يمسّ styles.css ولا tasks.css ولا shell.css.
   لا وضع داكن قسريًا: الوحدة فاتحة دائمًا وبتباين مقروء.
   ============================================================ */

.mail {
  --m-radius: 14px;
  --m-radius-sm: 10px;

  /* رمادي دافئ فاتح جدًا للخلفية، وبطاقات بيضاء */
  --m-bg: var(--bg);
  --m-surface: var(--surface);
  --m-surface-2: var(--surface-2);

  --m-line: var(--line);
  --m-line-soft: var(--line-soft);

  --m-ink: var(--ink);
  --m-ink-2: var(--ink-2);
  --m-ink-3: var(--muted);

  --m-brand: var(--brand);
  --m-brand-soft: var(--brand-soft);
  --m-brand-line: var(--brand-line);
  --m-brand-ink: var(--brand-ink);

  --m-warn: var(--warn);
  --m-warn-soft: var(--warn-soft);
  --m-warn-line: var(--warn-line);

  --m-shadow-xs: 0 1px 2px rgba(22, 33, 29, 0.04);
  --m-shadow-sm: 0 1px 3px rgba(22, 33, 29, 0.05), 0 4px 12px rgba(22, 33, 29, 0.04);
  --m-ease: cubic-bezier(0.22, 1, 0.36, 1);

  display: grid;
  grid-template-columns: 232px minmax(320px, 420px) minmax(440px, 1fr);
  height: calc(100vh - var(--topbar-h, 64px));
  background: var(--bg-sunken);
  color: var(--m-ink);
  overflow: hidden;
}

/* ==================== العمود الأول (يمين): المجلدات ==================== */

.m-folders {
  border-inline-end: 1px solid var(--m-line);
  background: var(--m-bg);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-width: 0;
}

.m-folders-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--m-ink-3);
  padding: 0 12px 10px;
}

.m-folder {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: var(--m-radius-sm);
  font: inherit;
  font-size: 0.92rem;
  color: var(--m-ink-2);
  cursor: pointer;
  text-align: start;
  width: 100%;
  transition: background 0.15s var(--m-ease), color 0.15s var(--m-ease);
}
.m-folder:hover { background: var(--surface-hover); color: var(--m-ink); }
.m-folder.active {
  background: var(--m-brand-soft);
  color: var(--m-brand-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--m-brand-line);
}
.m-folder-icon { width: 18px; text-align: center; flex: 0 0 auto; }
.m-folder-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-folder-count {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--m-ink-3);
  flex: 0 0 auto;
}
.m-folder.active .m-folder-count { color: var(--m-brand); }

/* ==================== العمود الثاني: القائمة ==================== */

.m-list {
  border-inline-end: 1px solid var(--m-line);
  background: var(--m-surface);
  box-shadow: 1px 0 0 var(--line-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.m-list-head {
  padding: 17px 18px 13px;
  border-bottom: 1px solid var(--m-line-soft);
  flex: 0 0 auto;
}
.m-list-title { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; }
.m-list-sub { font-size: 0.8rem; color: var(--m-ink-3); margin-top: 3px; }

/* تمرير مستقلّ للعمود الأوسط */
.m-list-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
  padding: 8px;
  min-height: 0;
}

.m-card {
  display: block;
  width: 100%;
  text-align: start;
  border: 1px solid transparent;
  background: none;
  border-radius: var(--m-radius);
  padding: 12px 13px;
  margin-bottom: 3px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.14s var(--m-ease), border-color 0.14s var(--m-ease);
}
.m-card:hover { background: var(--m-surface-2); border-color: var(--m-line); }
.m-card:focus-visible { outline: 2px solid var(--m-brand); outline-offset: -2px; }
.m-card.selected {
  background: var(--m-brand-soft);
  border-color: var(--m-brand-line);
  box-shadow: inset 3px 0 0 var(--brand);
}
/* Unread is carried by weight AND a brand edge — colour alone is not enough
   for a row scanned in a fraction of a second. */
.m-card.unread { box-shadow: inset 3px 0 0 var(--brand-line); }
.m-card.unread.selected { box-shadow: inset 3px 0 0 var(--brand); }

.m-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }

.m-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-inverse);
}

.m-card-who { flex: 1; min-width: 0; }
.m-card-name {
  font-size: 0.89rem;
  font-weight: 550;
  color: var(--m-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-card.unread .m-card-name { font-weight: 700; }
.m-card-date { font-size: 0.73rem; color: var(--m-ink-3); white-space: nowrap; flex: 0 0 auto; }

.m-card-subject {
  font-size: 0.87rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--m-ink);
}
.m-card.unread .m-card-subject { font-weight: 650; }
.m-card-subject .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.m-card-preview {
  font-size: 0.81rem;
  color: var(--m-ink-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.m-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--m-brand); flex: 0 0 auto; }

.m-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--m-surface-2);
  border: 1px solid var(--m-line);
  color: var(--m-ink-2);
  flex: 0 0 auto;
  white-space: nowrap;
}
.m-chip.ai { background: var(--m-brand-soft); border-color: var(--m-brand-line); color: var(--m-brand-ink); }

/* ==================== العمود الثالث: القراءة ==================== */

/* تمرير مستقلّ — لا يحرّك الصفحة ولا القائمة */
.m-read {
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  min-width: 0;
  padding: var(--s-6) var(--s-6) 72px;
  scroll-behavior: smooth;
}
/* Long Arabic prose is unreadable across a wide pane; this is the measure. */
.m-read-inner { max-width: 860px; margin: 0 auto; }

.m-panel {
  background: var(--m-surface);
  border: 1px solid var(--m-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--s-4);
  overflow: hidden;
}

/* رأس الرسالة */
.m-head { padding: 22px 26px 18px; }
.m-head-subject {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.015em;
  margin-bottom: 16px;
  color: var(--m-ink);
}
.m-head-row { display: flex; align-items: flex-start; gap: 13px; }
.m-head .m-avatar { width: 42px; height: 42px; font-size: 0.95rem; }
.m-head-who { flex: 1; min-width: 0; }
.m-head-name { font-weight: 650; font-size: 0.96rem; }
.m-head-mail { font-size: 0.83rem; color: var(--m-ink-2); word-break: break-all; direction: ltr; text-align: start; }
.m-head-date { font-size: 0.79rem; color: var(--m-ink-3); white-space: nowrap; }
.m-head-to { font-size: 0.82rem; color: var(--m-ink-2); margin-top: 5px; }
.m-head-to b { color: var(--m-ink); font-weight: 550; }

.m-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--m-line-soft);
}
.m-attach {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--m-line);
  border-radius: var(--m-radius-sm);
  background: var(--m-surface-2);
  font-size: 0.82rem;
  color: var(--m-ink);
  text-decoration: none;
  transition: border-color 0.14s var(--m-ease), background 0.14s var(--m-ease);
}
.m-attach:hover { border-color: var(--m-brand-line); background: var(--m-brand-soft); }
.m-attach small { color: var(--m-ink-3); }

/* شريط الإجراءات — مدمج */
.m-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 11px 26px;
  border-top: 1px solid var(--m-line-soft);
  background: var(--m-surface-2);
}
.m-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--m-line);
  border-radius: 9px;
  background: var(--m-surface);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--m-ink);
  cursor: pointer;
  transition: all 0.13s var(--m-ease);
}
.m-act:hover:not(:disabled) {
  border-color: var(--m-brand-line);
  color: var(--m-brand-ink);
  background: var(--m-brand-soft);
}
.m-act:disabled { opacity: 0.45; cursor: default; }
.m-act-icon { font-size: 0.9rem; line-height: 1; }

/* رؤوس الأقسام */
.m-sec-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 26px;
  border-bottom: 1px solid var(--m-line-soft);
  background: var(--m-surface);
}
.m-sec-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--m-brand-soft);
  border: 1px solid var(--m-brand-line);
  font-size: 0.85rem;
  flex: 0 0 auto;
}
.m-sec-title { font-weight: 650; font-size: 0.9rem; flex: 1; }

.m-copy, .m-close {
  border: 1px solid var(--m-line);
  background: var(--m-surface);
  border-radius: 8px;
  padding: 4px 10px;
  font: inherit;
  font-size: 0.75rem;
  color: var(--m-ink-2);
  cursor: pointer;
  transition: all 0.13s var(--m-ease);
  flex: 0 0 auto;
}
.m-copy:hover, .m-close:hover { border-color: var(--m-brand-line); color: var(--m-brand-ink); background: var(--m-brand-soft); }
.m-copy.done { background: var(--m-brand-soft); color: var(--m-brand-ink); border-color: var(--m-brand-line); }
.m-close { padding: 4px 9px; }

/* جسم الرسالة — الطباعة */
.m-body {
  padding: 20px 26px 24px;
  font-size: 0.96rem;
  line-height: 1.95;
  color: var(--m-ink);
  max-width: 78ch;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.m-body p { margin: 0 0 1.05em; }
.m-body p:last-child { margin-bottom: 0; }
.m-body ul, .m-body ol { margin: 0 0 1.05em; padding-inline-start: 22px; }
.m-body li { margin-bottom: 0.45em; }
.m-body a { color: var(--m-brand); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.m-body a:hover { color: var(--m-brand-ink); }
.m-body table { border-collapse: collapse; margin: 0 0 1.05em; font-size: 0.9rem; }
.m-body td, .m-body th { border: 1px solid var(--m-line); padding: 7px 11px; text-align: start; }
.m-body th { background: var(--m-surface-2); font-weight: 650; }
.m-table-wrap { overflow-x: auto; }

/* مقاطع إنجليزية داخل محتوى عربي */
.m-ltr { direction: ltr; text-align: left; }

/* بطاقة الترجمة */
.m-body.tr { background: var(--m-brand-soft); max-width: none; color: var(--m-ink); }

/* ==================== المحادثة السابقة ==================== */

.m-thread-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 12px 26px;
  border: none;
  border-top: 1px solid var(--m-line-soft);
  background: var(--m-surface-2);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 550;
  color: var(--m-ink-2);
  cursor: pointer;
  text-align: start;
  transition: background 0.14s var(--m-ease);
}
.m-thread-toggle:hover { background: var(--surface-hover); color: var(--m-ink); }
.m-caret { transition: transform 0.2s var(--m-ease); display: inline-block; font-size: 0.7rem; }
.m-thread-toggle.open .m-caret { transform: rotate(180deg); }
.m-thread-actions { margin-inline-start: auto; display: flex; gap: 6px; }

.m-thread { animation: mFade 0.2s var(--m-ease); }
@keyframes mFade { from { opacity: 0; } to { opacity: 1; } }

.m-reply {
  padding: 16px 26px;
  border-top: 1px solid var(--m-line-soft);
  background: var(--m-surface);
}
.m-reply-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 9px;
  font-size: 0.82rem;
}
.m-reply-from { font-weight: 650; color: var(--m-ink); }
.m-reply-date { color: var(--m-ink-3); }
.m-reply-n {
  font-size: 0.7rem; font-weight: 700; color: var(--m-ink-3);
  background: var(--m-line-soft); border-radius: 999px; padding: 1px 8px;
}
.m-reply-body {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--m-ink-2);
  white-space: pre-wrap;
  max-width: 78ch;
  border-inline-start: 2px solid var(--m-line);
  padding-inline-start: 14px;
}

/* التوقيع والتفاصيل */
.m-sig-toggle {
  display: block;
  width: 100%;
  padding: 10px 26px;
  border: none;
  border-top: 1px dashed var(--m-line);
  background: none;
  font: inherit;
  font-size: 0.8rem;
  color: var(--m-ink-3);
  cursor: pointer;
  text-align: start;
}
.m-sig-toggle:hover { color: var(--m-brand-ink); background: var(--m-surface-2); }
.m-sig {
  padding: 4px 26px 20px;
  font-size: 0.84rem;
  line-height: 1.75;
  color: var(--m-ink-3);
  white-space: pre-wrap;
  max-width: 78ch;
}

/* ==================== بطاقات المخرجات ==================== */

.m-ai { padding: 18px 26px 22px; }
.m-ai p { margin: 0 0 12px; line-height: 1.85; }
.m-ai p:last-child { margin-bottom: 0; }

.m-ai-group + .m-ai-group { margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--m-line-soft); }
.m-ai-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em;
  color: var(--m-ink-3); margin-bottom: 9px;
}
.m-ai ul { margin: 0; padding-inline-start: 20px; }
.m-ai li { margin-bottom: 7px; line-height: 1.75; }
.m-ai li:last-child { margin-bottom: 0; }

.m-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.m-pill {
  padding: 4px 11px; border-radius: 999px;
  background: var(--m-surface-2); border: 1px solid var(--m-line); font-size: 0.82rem;
}

/* المهام المستخرَجة */
.m-task { display: flex; align-items: flex-start; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--m-line-soft); }
.m-task:last-child { border-bottom: none; }
.m-task input[type='checkbox'] { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--m-brand); flex: 0 0 auto; }
.m-task-main { flex: 1; min-width: 0; }
.m-task-text { line-height: 1.65; margin-bottom: 7px; }
.m-task.done .m-task-text { text-decoration: line-through; opacity: 0.5; }
.m-task-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.m-mini {
  border: 1px solid var(--m-line); background: var(--m-surface);
  border-radius: 7px; padding: 3px 9px; font: inherit; font-size: 0.75rem;
  color: var(--m-ink-2); cursor: pointer; transition: all 0.13s var(--m-ease);
}
.m-mini:hover:not(:disabled) { border-color: var(--m-brand-line); color: var(--m-brand-ink); background: var(--m-brand-soft); }
.m-mini:disabled { opacity: 0.5; cursor: default; }
.m-mini.ok { background: var(--m-brand-soft); color: var(--m-brand-ink); border-color: var(--m-brand-line); }

/* مُنشئ الرد */
.m-field { display: flex; align-items: baseline; gap: 12px; padding: 11px 26px; border-bottom: 1px solid var(--m-line-soft); }
.m-field-label { font-size: 0.79rem; color: var(--m-ink-3); width: 56px; flex: 0 0 auto; }
.m-field-value { font-size: 0.89rem; flex: 1; min-width: 0; word-break: break-word; }
.m-compose-body {
  padding: 18px 26px;
  font-size: 0.95rem;
  line-height: 1.9;
  min-height: 140px;
  max-width: 78ch;
  white-space: pre-wrap;
  border: none;
  outline: none;
  color: var(--m-ink);
}
.m-compose-body:focus { background: var(--surface); }
.m-signature { padding: 13px 26px 16px; font-size: 0.84rem; color: var(--m-ink-3); line-height: 1.7; border-top: 1px solid var(--m-line-soft); white-space: pre-wrap; }
.m-compose-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 26px; background: var(--m-surface-2); border-top: 1px solid var(--m-line-soft);
}
.m-primary {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; background: var(--m-brand); color: var(--ink-inverse);
  border-radius: 9px; padding: 8px 15px; font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: filter 0.13s var(--m-ease);
}
.m-primary:hover { filter: brightness(1.07); }
.m-note { font-size: 0.77rem; color: var(--m-ink-3); margin-inline-start: auto; }

/* شبكة بيانات */
.m-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px; padding: 17px 26px; border-bottom: 1px solid var(--m-line-soft);
}
.m-meta-k { font-size: 0.71rem; color: var(--m-ink-3); letter-spacing: 0.04em; margin-bottom: 4px; }
.m-meta-v { font-size: 0.89rem; font-weight: 600; }
.m-status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--m-brand-soft); border: 1px solid var(--m-brand-line);
  color: var(--m-brand-ink); font-size: 0.79rem; font-weight: 600;
}

/* ==================== الحالات ==================== */

.m-empty {
  display: grid; place-items: center; align-content: center;
  min-height: 320px; height: 100%;
  text-align: center; color: var(--m-ink-3); padding: 40px;
}
.m-empty-icon { font-size: 2.4rem; margin-bottom: 14px; opacity: 0.4; }
.m-empty-title { font-size: 1rem; font-weight: 600; color: var(--m-ink-2); margin-bottom: 6px; }
.m-empty-sub { font-size: 0.85rem; max-width: 320px; line-height: 1.7; }

.m-error {
  background: var(--m-warn-soft); border: 1px solid var(--m-warn-line);
  color: var(--m-warn); border-radius: var(--m-radius-sm);
  padding: 13px 15px; font-size: 0.86rem; line-height: 1.6; margin: 18px 26px;
}

.m-skel {
  background: linear-gradient(90deg, var(--m-line-soft) 25%, var(--line) 37%, var(--m-line-soft) 63%);
  background-size: 400% 100%;
  animation: mShimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes mShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.m-skel-line { height: 11px; margin-bottom: 9px; }
.m-skel-card { padding: 12px 13px; margin-bottom: 3px; }
.m-skel-row { display: flex; gap: 10px; align-items: center; margin-bottom: 9px; }
.m-skel-avatar { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; }

.m-spin {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid var(--m-brand); border-top-color: transparent;
  border-radius: 50%; animation: mSpin 0.7s linear infinite; vertical-align: -2px;
}
@keyframes mSpin { to { transform: rotate(360deg); } }

/* ==================== الاستجابة ==================== */

@media (max-width: 1400px) {
  .mail { grid-template-columns: 200px minmax(280px, 360px) minmax(400px, 1fr); }
  .m-read { padding: 20px 22px 60px; }
}

@media (max-width: 1180px) {
  .mail { grid-template-columns: 62px minmax(260px, 330px) minmax(360px, 1fr); }
  .m-folders { padding: 16px 8px; align-items: center; }
  .m-folders-title { display: none; }
  .m-folder { justify-content: center; padding: 10px 0; }
  .m-folder-label, .m-folder-count { display: none; }
}

@media (max-width: 900px) {
  .mail { grid-template-columns: 62px minmax(0, 1fr); }
  .m-list { display: none; }
  .mail.list-mode .m-list { display: flex; }
  .mail.list-mode .m-read { display: none; }
  .m-head, .m-body, .m-ai, .m-toolbar, .m-sec-head, .m-field,
  .m-compose-body, .m-compose-bar, .m-reply, .m-sig, .m-sig-toggle,
  .m-thread-toggle, .m-meta-grid { padding-inline: 18px; }
  .m-error { margin-inline: 18px; }
}

@media (max-width: 640px) {
  .mail { grid-template-columns: minmax(0, 1fr); }
  .m-folders { display: none; }
  .m-read { padding: 12px 12px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .mail *, .mail *::before { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .m-read { scroll-behavior: auto; }
}

/* ==================== المسودات السابقة ==================== */

.m-draft-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 13px 26px;
  border: none;
  border-top: 1px solid var(--m-line-soft);
  background: var(--m-surface);
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition: background 0.14s var(--m-ease);
}
.m-draft-item:hover { background: var(--m-surface-2); }
.m-draft-item.selected {
  background: var(--m-brand-soft);
  box-shadow: inset 3px 0 0 var(--m-brand);
}
.m-draft-item:focus-visible { outline: 2px solid var(--m-brand); outline-offset: -2px; }

.m-draft-main { flex: 1; min-width: 0; }
.m-draft-subject {
  font-size: 0.89rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-draft-preview {
  font-size: 0.81rem;
  color: var(--m-ink-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.m-draft-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex: 0 0 auto;
}
.m-draft-date { font-size: 0.74rem; color: var(--m-ink-3); white-space: nowrap; }

@media (max-width: 900px) {
  .m-draft-item { padding-inline: 18px; }
}

/* ==================== المرفقات ==================== */

.m-att-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  padding: 16px 26px 20px;
}

.m-att-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--m-line);
  border-radius: var(--m-radius-sm);
  background: var(--m-surface);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition: border-color 0.14s var(--m-ease), background 0.14s var(--m-ease),
              transform 0.14s var(--m-ease), box-shadow 0.14s var(--m-ease);
}
.m-att-card:hover {
  border-color: var(--m-brand-line);
  background: var(--m-brand-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.m-att-icon {
  width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: 9px; display: grid; place-items: center;
  background: var(--m-surface); border: 1px solid var(--m-line); font-size: 1.15rem;
}
.m-att-thumb {
  width: 42px; height: 42px; flex: 0 0 auto;
  border-radius: 9px; object-fit: cover;
  border: 1px solid var(--m-line); background: var(--m-surface);
}

.m-att-main { flex: 1; min-width: 0; }
.m-att-name {
  font-size: 0.86rem; font-weight: 600; direction: ltr; text-align: start;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-att-meta { font-size: 0.76rem; color: var(--m-ink-3); margin-top: 2px; }
.m-att-actions { display: flex; gap: 5px; flex: 0 0 auto; }
.m-att-actions .m-mini { text-decoration: none; }

/* ==================== حذف المسودات ==================== */

.m-draft-row { position: relative; display: flex; align-items: stretch; border-top: 1px solid var(--m-line-soft); }
.m-draft-row .m-draft-item { border-top: none; flex: 1; }
.m-draft-del {
  flex: 0 0 auto;
  border: none;
  background: none;
  padding: 0 18px;
  font-size: 0.95rem;
  color: var(--m-ink-3);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.14s var(--m-ease), background 0.14s var(--m-ease);
}
.m-draft-del:hover { opacity: 1; background: var(--m-warn-soft); }
.m-draft-del:disabled { cursor: default; }

.m-confirm {
  position: absolute;
  inset-inline-end: 12px;
  top: calc(100% - 12px);
  z-index: 6;
  background: var(--m-surface);
  border: 1px solid var(--m-line);
  border-radius: var(--m-radius-sm);
  box-shadow: 0 8px 24px rgba(22, 33, 29, 0.12);
  padding: 13px 15px;
  min-width: 232px;
}
.m-confirm-q { font-size: 0.86rem; margin-bottom: 11px; }
.m-confirm-b { display: flex; gap: 7px; }
.m-mini.danger {
  background: var(--m-warn-soft);
  border-color: var(--m-warn-line);
  color: var(--m-warn);
  font-weight: 600;
}
.m-mini.danger:hover { background: var(--m-warn); border-color: var(--m-warn); color: var(--ink-inverse); }

/* ==================== ردود السلسلة القابلة للفتح ==================== */

.m-reply { padding: 0; border-top: 1px solid var(--m-line-soft); }
.m-reply-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 12px 26px;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.82rem;
  color: inherit;
  text-align: start;
  cursor: pointer;
  margin: 0;
  transition: background 0.14s var(--m-ease);
}
.m-reply-head:hover { background: var(--m-surface-2); }
.m-reply-head .m-caret { font-size: 0.65rem; color: var(--m-ink-3); flex: 0 0 auto; }
.m-reply-head.open .m-caret { transform: rotate(180deg); }
.m-reply-peek {
  color: var(--m-ink-3);
  font-size: 0.79rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-reply-body { padding: 0 26px 18px; margin-inline-start: 26px; }

@media (max-width: 900px) {
  .m-att-grid { padding-inline: 18px; grid-template-columns: 1fr; }
  .m-reply-head, .m-reply-body { padding-inline: 18px; }
  .m-reply-peek { display: none; }
}

/* ==================== معاينة المرفقات ==================== */

.m-preview {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(22, 33, 29, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  animation: mFade 0.16s var(--m-ease);
}

.m-preview-box {
  background: var(--m-surface);
  border-radius: var(--m-radius);
  box-shadow: 0 24px 64px rgba(22, 33, 29, 0.28);
  width: min(1040px, 100%);
  height: min(88vh, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.m-preview-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--m-line);
  background: var(--m-surface-2);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.m-preview-meta { flex: 1; min-width: 140px; }
.m-preview-name {
  font-size: 0.92rem; font-weight: 650; direction: ltr; text-align: start;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-preview-sub { font-size: 0.78rem; color: var(--m-ink-3); margin-top: 2px; }
.m-preview-tools { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.m-pv-zoom { font-size: 0.76rem; color: var(--m-ink-2); min-width: 42px; text-align: center; }

.m-preview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg-sunken);
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.m-preview-load {
  margin: auto; color: var(--m-ink-3); font-size: 0.88rem;
  display: flex; align-items: center; gap: 9px;
}

.m-preview-frame { width: 100%; height: 100%; border: none; background: var(--surface); }

.m-preview-imgwrap {
  margin: auto; padding: 24px; display: grid; place-items: center; min-width: 0;
}
.m-preview-img {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(22, 33, 29, 0.16);
  transform-origin: center;
  transition: transform 0.16s var(--m-ease);
  background: var(--surface);
}

.m-preview-text {
  margin: 0;
  padding: 22px 26px;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--m-surface);
  color: var(--m-ink);
  text-align: start;
}

.m-preview-none {
  margin: auto; text-align: center; padding: 40px 24px; color: var(--m-ink-3);
}

/* إشعار مختصر */
.m-toast {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  z-index: 130;
  background: var(--m-ink);
  color: var(--ink-inverse);
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 0.86rem;
  box-shadow: 0 8px 26px rgba(22, 33, 29, 0.26);
  animation: mFade 0.18s var(--m-ease);
  max-width: min(460px, 90vw);
  text-align: center;
}
.m-toast.warn { background: var(--m-warn); }

@media (max-width: 700px) {
  .m-preview { padding: 10px; }
  .m-preview-box { height: 94vh; }
  .m-preview-head { padding: 11px 13px; }
}

/* ==========================================================================
   المجلّدات وشريط الاستيراد
   ========================================================================== */

.m-folders { display: flex; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.m-folder {
  border: 1px solid transparent; background: none; cursor: pointer;
  padding: 4px 10px; border-radius: 7px;
  font: inherit; font-size: 0.79rem; font-weight: 600; color: var(--muted);
  transition: all 0.13s ease;
}
.m-folder:hover { background: var(--surface-hover); color: var(--ink); }
.m-folder.active { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }

.m-sync { margin-top: 4px; }
.m-sync-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 5px 9px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: 0.73rem; color: var(--muted);
}
.m-sync-bar.running { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }
.m-sync-bar.failed { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.m-sync-nums { font-variant-numeric: tabular-nums; }
.m-sync-btn {
  margin-inline-start: auto; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px;
  padding: 3px 9px; font: inherit; font-size: 0.72rem; font-weight: 600;
  color: var(--brand); cursor: pointer; transition: all 0.13s ease;
}
.m-sync-btn:hover { background: var(--brand-soft); border-color: var(--brand-line); }
.m-sync-spin {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  border: 2px solid var(--brand-line); border-top-color: var(--brand);
  animation: mSyncSpin 0.8s linear infinite;
}
@keyframes mSyncSpin { to { transform: rotate(360deg); } }

/* ============================================================================
   البريد — القسم د حرفًا بحرف
   ============================================================================
   ثلاث لوحات بأعراض محدّدة: مجلّدات ١٩٠، قائمة لا تقلّ عن ٣٨٠، ثم القراءة.
   والقراءة هي البطل: عنوان ٢٢، ونصّ بعرض ٨٢٠ لا أكثر. */

.mail { grid-template-columns: 190px minmax(380px, 460px) minmax(440px, 1fr); }

/* الصفوف تلتصق ببعضها: لا حشوة حول القائمة ولا فراغ بينها */
.m-list-scroll { padding: 0; }

/* صفّ الرسالة: ٧٦ ارتفاعًا وحشوة ١٢/١٦، بلا حواف بطاقات */
.m-card {
  min-height: 76px;
  margin-bottom: 0;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  background: var(--surface);
}
.m-card:hover { background: var(--surface-hover); border-color: var(--line); }

/* غير المقروء: أرضية خضراء شاحبة ووزن ٦٠٠ — لا خطّ جانبيّ */
.m-card.unread { background: var(--surface-2); box-shadow: none; }
.m-card.unread .m-card-name,
.m-card.unread .m-card-subject { font-weight: 600; }

/* المحدَّد: أرضية خضراء ناعمة وخطّ يمينيّ أخضر بثلاثة بكسل */
.m-card.selected,
.m-card.unread.selected {
  background: var(--brand-soft);
  border-right: 3px solid var(--brand);
  box-shadow: none;
}

.m-card-name { font-size: var(--fs-body); }
.m-card-subject { font-size: var(--fs-body); color: var(--ink); }
.m-card-preview { font-size: var(--fs-meta); color: var(--ink-2); }
.m-card-date { font-size: var(--fs-meta); color: var(--muted); }

/* رأس القراءة: الموضوع ٢٢ نصف عريض، ثمّ المرسل ثمّ التاريخ */
.m-head-subject {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink);
}
.m-head-name { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.m-head-mail, .m-head-date, .m-head-to { font-size: var(--fs-meta); color: var(--ink-2); }

/* النصّ: مقياس القراءة ٨٢٠ وحشوة ٢٨ وتباعد ١٫٧ */
.m-read-inner { max-width: 820px; margin: 0 auto; }
.m-body {
  max-width: 820px;
  padding: 28px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
}

/* المرفقات بطاقات هادئة: أرضية ٦-فاتحة وحدّ رمادي وحافة ١٠ */
.m-att-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: none;
}
.m-att-card:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.m-att-name { font-size: var(--fs-body); font-weight: 600; unicode-bidi: plaintext; }
.m-att-meta { font-size: var(--fs-meta); color: var(--ink-2); }

/* صفّ الإجراءات: ردّ أساسيّ، ثمّ ترجمة وإنشاء مهمة والمزيد */
.m-strip { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.m-primary {
  height: 40px; padding: 0 var(--s-4);
  background: var(--brand); color: var(--ink-inverse);
  border: 1px solid var(--brand); border-radius: var(--r-sm);
  font-weight: 600; font-size: var(--fs-body); cursor: pointer;
}
.m-primary:hover { background: var(--brand-hover); }
.m-ghost {
  height: 40px; padding: 0 var(--s-3);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-weight: 600; font-size: var(--fs-body); cursor: pointer;
}
.m-ghost:hover { background: var(--surface-hover); }

@media (max-width: 1199px) {
  .mail { grid-template-columns: 190px minmax(320px, 380px) minmax(400px, 1fr); }
  .m-body { padding: 20px; }
}
@media (max-width: 767px) {
  .m-head-subject { font-size: 19px; }
  .m-body { padding: var(--s-4); }
}

/* قائمة «المزيد» — تعلو المحتوى ولا تزيح الصفّ */
.m-more { position: relative; }
.m-more-menu {
  position: absolute; inset-inline-start: 0; top: calc(100% + 6px);
  z-index: 40; min-width: 190px; padding: var(--s-1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.m-more-item {
  display: block; width: 100%; text-align: start;
  height: 38px; padding: 0 var(--s-3);
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--ink); font: 500 var(--fs-body) / 38px var(--font); cursor: pointer;
}
.m-more-item:hover { background: var(--surface-hover); }

/* ============================================================================
   البريد — هوية ضلال: بيج دافئ وأخضر داكن
   ============================================================================
   التخطيط كما هو: المجلّدات والقائمة يمينًا، والرسالة في المساحة الرئيسية.
   ما تغيّر: الرأس صار مضغوطًا، والحدود قلّت، والمحدَّد صار هادئًا لا كتلة
   لونية صارخة. */

/* الأرضية بيج، واللوحات بيضاء فوقها */
.mail { background: var(--bg); }
.m-list { background: var(--surface); border-inline-start: 1px solid var(--line); }
.m-read { background: var(--bg); }

/* ---- ٦: المجلّدات أهدأ ------------------------------------------------- */
/* لا يبدو كل مجلّد زرًّا مستقلًّا: لا حدود ولا أرضيات، إلا المفعَّل. */
.m-folders { background: var(--bg-sunken); border: none; }
.m-folder {
  border: 1px solid transparent;
  background: none;
  color: var(--ink-2);
  font-size: var(--fs-body);
  font-weight: 500;
  border-radius: var(--r-sm);
  padding: 0 var(--s-3);
  height: 38px;
}
.m-folder:hover { background: var(--surface-hover); color: var(--ink); }
/* المفعَّل وحده يحمل الأخضر — فيُعرف من نظرة */
.m-folder.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--ink-inverse);
  font-weight: 600;
}
.m-folder.active .m-folder-count,
.m-folder.active .m-folder-icon { color: var(--ink-inverse); opacity: 0.9; }
.m-folder-count { color: var(--muted); font-size: var(--fs-meta); }

/* ---- ٥: قائمة الرسائل — أقلّ ضجيجًا، وصفوف تُمسح بسرعة ---------------- */
.m-card {
  min-height: 0;                    /* الارتفاع من المحتوى لا من رقم مفروض */
  padding: var(--s-3) var(--s-4);
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  box-shadow: none;
  background: var(--surface);
}
.m-card:hover { background: var(--surface-hover); border-color: var(--line-soft); }

/* غير المقروء: وزن أقوى فقط — لا لون صارخ */
.m-card.unread { background: var(--surface); box-shadow: none; }
.m-card.unread .m-card-name { font-weight: 700; color: var(--ink); }
.m-card.unread .m-card-subject { font-weight: 600; color: var(--ink); }

/* المحدَّد: بيج دافئ هادئ + مؤشّر أخضر صغير. لا كتلة لونية. */
.m-card.selected,
.m-card.unread.selected {
  background: var(--beige-deep);
  border-right: 3px solid var(--brand);
  box-shadow: none;
}
.m-card.selected .m-card-subject { color: var(--ink); }

.m-card-name { font-size: var(--fs-body); color: var(--ink); }
.m-card-subject { font-size: var(--fs-body); color: var(--ink-2); font-weight: 500; }
.m-card-preview { font-size: var(--fs-meta); color: var(--muted); }
.m-card-date { font-size: var(--fs-meta); color: var(--muted); }
/* النقطة الخضراء تكفي دلالةً على غير المقروء */
.m-dot { background: var(--brand); }

/* ---- ٢: رأس الرسالة مضغوط -------------------------------------------- */
/* كان يأكل ارتفاعًا كبيرًا قبل أن يصل القارئ إلى النصّ. */
.m-head { padding: var(--s-4) var(--s-5) var(--s-3); }
.m-head-subject {
  font-size: 19px;
  font-weight: 650;
  line-height: 1.4;
  margin-bottom: var(--s-2);       /* كان ١٦ */
  color: var(--ink);
}
.m-head-row { align-items: center; gap: var(--s-3); }
.m-head .m-avatar { width: 34px; height: 34px; font-size: 0.82rem; }
.m-head-name { font-size: var(--fs-body); font-weight: 600; }
.m-head-mail { font-size: var(--fs-meta); color: var(--ink-2); }
.m-head-to { font-size: var(--fs-meta); color: var(--ink-2); margin-top: 2px; }
.m-head-date { font-size: var(--fs-meta); color: var(--muted); }
.m-strip { margin-top: var(--s-3); padding-top: var(--s-3); }

/* ---- ٢: صفّ الإجراءات — ردّ أخضر، والباقي هادئ، وارتفاع واحد --------- */
.m-toolbar {
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.m-primary, .m-ghost, .m-more > .m-ghost { height: 36px; }
.m-primary {
  background: var(--brand); color: var(--ink-inverse);
  border: 1px solid var(--brand); border-radius: var(--r-sm);
  padding: 0 var(--s-4); font-weight: 600; font-size: var(--fs-body);
}
.m-primary:hover { background: var(--brand-hover); }
.m-ghost {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 var(--s-3); font-weight: 500; font-size: var(--fs-body);
}
.m-ghost:hover { background: var(--surface-hover); color: var(--ink); border-color: var(--line-strong); }

/* ---- اللوحات: حدّ خفيف واحد، بلا ظلال طافية ------------------------- */
.m-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: none;
}
.m-sec-head {
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.m-sec-title { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }

/* ---- ٤: رأس قابل للطيّ للرسالة الأصلية ------------------------------- */
.m-sec-toggle {
  display: flex; align-items: center; gap: var(--s-2);
  flex: 1; min-width: 0;
  background: none; border: 0; padding: 0;
  font: inherit; color: inherit; text-align: start; cursor: pointer;
}
.m-sec-toggle .m-caret { color: var(--brand); font-size: 11px; transition: none; }
.m-sec-toggle:hover .m-sec-title { color: var(--brand); }
.m-sec-toggle.collapsed + .m-copy { opacity: 0.6; }

/* ---- ٣: الترجمة العربية جزءٌ من الرسالة لا بطاقة غريبة عنها --------- */
.m-body.tr {
  background: var(--surface-2);
  border-top: 2px solid var(--brand);
  padding: var(--s-5);
  line-height: 1.85;
}
[data-out="translate"] { border-color: var(--brand-line); }
[data-out="translate"] .m-sec-head { background: var(--brand-soft); border-bottom-color: var(--brand-line); }
[data-out="translate"] .m-sec-title { color: var(--brand); }

/* أزرار «نسخ» و«عرض النص الأصلي» بارتفاع واحد وشكل هادئ */
.m-copy, .m-close {
  height: 30px; padding: 0 var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-badge);
  background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-meta); font-weight: 600; cursor: pointer;
}
.m-copy:hover, .m-close:hover { background: var(--surface-hover); color: var(--ink); }
[data-out="translate"] .m-copy { background: var(--surface); border-color: var(--brand-line); }

/* ---- المرفقات: بطاقات هادئة على البيج ------------------------------- */
.m-att-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: none;
}
.m-att-card:hover { background: var(--surface-hover); border-color: var(--brand-line); transform: none; }

/* ---- ١٣: الانتقال بين القائمة والرسالة على الشاشات الضيّقة ----------- */
/* زرّ الرجوع لا معنى له على سطح المكتب حيث اللوحتان ظاهرتان معًا. */
.m-back { display: none; }

@media (max-width: 900px) {
  .m-back {
    display: inline-flex; align-items: center;
    height: 36px; padding: 0 var(--s-3);
    margin-bottom: var(--s-2);
    background: var(--surface-2); color: var(--brand);
    border: 1px solid var(--line); border-radius: var(--r-sm);
    font: 600 var(--fs-body) / 1 var(--font); cursor: pointer;
  }
  .m-back:hover { background: var(--surface-hover); }
  /* القائمة تملأ العرض حين تكون هي الظاهرة */
  .mail.list-mode .m-list { display: flex; }
  .mail.list-mode .m-read { display: none; }
}

/* الأزرار مريحة للمس على الجوّال */
@media (max-width: 767px) {
  .m-primary, .m-ghost, .m-more > .m-ghost, .m-back { min-height: 44px; }
  .m-copy, .m-close { min-height: 36px; }
  .m-toolbar { padding: var(--s-3) var(--s-4); }
  .m-head { padding: var(--s-3) var(--s-4); }
  .m-sec-head { padding: var(--s-3) var(--s-4); }
}

/* لا فيض أفقيّ من الجداول أو النصوص الطويلة داخل الرسالة */
.m-body { overflow-wrap: anywhere; }
.m-body table { display: block; max-width: 100%; overflow-x: auto; }

/* ---- الإحالة إلى موظّف --------------------------------------------------- */

/* شريط يعلو الرسالة المحالة: من أحالها وبأيّ ملاحظة */
.m-delegated {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2);
  margin-bottom: var(--s-3);
  padding: var(--s-2) var(--s-3);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  border-radius: var(--r-sm);
}
.m-delegated-t { font-size: var(--fs-meta); font-weight: 600; color: var(--brand); }
.m-delegated-n { font-size: var(--fs-meta); color: var(--ink-2); line-height: var(--lh-ar); }

/* نافذة الإحالة */
.m-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: var(--s-4);
  background: rgba(31, 42, 38, 0.35);
}
.m-dialog {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-dialog);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.m-dialog-head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-card); font-weight: 600; color: var(--ink);
}
.m-dialog-body { padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.m-dialog-sub {
  font-size: var(--fs-body); color: var(--ink-2);
  line-height: var(--lh-ar); margin-bottom: var(--s-2);
}
.m-dialog-err {
  padding: var(--s-2) var(--s-3);
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--r-sm); font-size: var(--fs-meta);
}
.m-dialog-actions {
  display: flex; justify-content: flex-start; gap: var(--s-2);
  padding: var(--s-3) var(--s-5) var(--s-4);
  border-top: 1px solid var(--line-soft);
}
@media (max-width: 767px) {
  .m-dialog { width: 100%; }
}
