/* Salfa Mail — modern Gmail-style UI. System fonts only, no monospace. */
[hidden] { display: none !important; }
:root {
  --green: #0E5B43;
  --green-dark: #0a4634;
  --green-tint: #e3efe9;
  --gold: #C9A227;
  --bg: #f6f8f6;
  --surface: #ffffff;
  --read-bg: #f2f5f3;
  --ink: #1c2420;
  --ink-soft: #5c6a63;
  --line: #e2e8e4;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(20, 40, 32, .08), 0 8px 24px rgba(20, 40, 32, .08);
  --shadow-lg: 0 4px 8px rgba(20, 40, 32, .10), 0 16px 40px rgba(20, 40, 32, .16);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 6px; }
svg { width: 22px; height: 22px; flex: none; }

/* ---------------- buttons ---------------- */
.btn-primary {
  background: var(--green); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 26px; font-weight: 600; font-size: 15px;
  box-shadow: 0 1px 3px rgba(14, 91, 67, .35);
  transition: background .15s ease, transform .05s ease;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-block { width: 100%; padding: 13px 26px; font-size: 16px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-soft);
}
.icon-btn:hover { background: rgba(14, 91, 67, .08); color: var(--ink); }
.icon-btn.light { color: #dfe9e4; width: 32px; height: 32px; font-size: 15px; }
.icon-btn.light:hover { background: rgba(255,255,255,.14); color: #fff; }
.tool-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 16px; font-size: 14px; font-weight: 500;
}
.tool-btn:hover:not(:disabled) { background: var(--green-tint); border-color: transparent; }
.tool-btn:disabled { opacity: .45; cursor: default; }
.tool-btn.danger:hover:not(:disabled) { background: #fbeae9; color: var(--danger); }

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #eef5f0 0%, #f6f8f6 45%, #e9f1ec 100%);
}
.login-card {
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 40px 36px 30px; width: 100%; max-width: 400px; text-align: center;
}
.login-logo { width: 72px; height: 72px; }
.login-title { margin: 14px 0 2px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.login-sub { margin: 0 0 26px; color: var(--ink-soft); font-size: 15px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 0 0 6px 4px; }
.field input {
  width: 100%; padding: 13px 16px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; background: #fbfcfb; transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(14, 91, 67, .15); background: #fff; }
.login-error { color: var(--danger); font-size: 14px; margin: 0 0 12px; text-align: left; }
.login-note { color: var(--ink-soft); font-size: 13px; margin: 18px 0 0; }

/* ---------------- app shell ---------------- */
.app { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: var(--bg); position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 38px; height: 38px; }
.brand-name { font-size: 21px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.search-pill {
  flex: 1; max-width: 680px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  background: #e9efeb; border-radius: 999px; padding: 0 18px; height: 48px;
  transition: background .15s ease, box-shadow .15s ease;
}
.search-pill:focus-within { background: #fff; box-shadow: var(--shadow); }
.search-pill svg { color: var(--ink-soft); width: 20px; height: 20px; }
.search-pill input { flex: 1; border: 0; background: transparent; font-size: 16px; outline: none; min-width: 0; }
.avatar-wrap { position: relative; margin-left: auto; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--green); color: #fff;
  font-size: 17px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.avatar.sm { width: 42px; height: 42px; font-size: 18px; cursor: default; }
.avatar-menu {
  position: absolute; right: 0; top: calc(100% + 10px); background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px; min-width: 240px; z-index: 60;
}
.avatar-email { font-size: 14px; font-weight: 600; padding: 4px 8px 12px; word-break: break-all; }
.menu-item {
  width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 500;
}
.menu-item:hover { background: var(--green-tint); border-color: transparent; }

.main { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---------------- sidebar ---------------- */
.sidebar { width: 248px; flex: none; padding: 8px 12px 16px; overflow-y: auto; }
.compose-btn {
  display: inline-flex; align-items: center; gap: 10px; border: 0; border-radius: 18px;
  background: var(--surface); color: var(--green-dark); font-weight: 600; font-size: 15px;
  padding: 16px 24px; margin: 6px 0 18px 2px; box-shadow: var(--shadow);
  transition: box-shadow .15s ease, background .15s ease;
}
.compose-btn:hover { background: var(--green-tint); box-shadow: var(--shadow-lg); }
.compose-btn svg { width: 20px; height: 20px; }
.folders { display: flex; flex-direction: column; gap: 2px; }
.folder {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent;
  padding: 9px 14px 9px 18px; border-radius: 0 999px 999px 0; font-size: 15px; color: var(--ink);
  text-align: left;
}
.folder svg { width: 20px; height: 20px; color: var(--ink-soft); }
.folder:hover { background: rgba(14, 91, 67, .07); }
.folder.active { background: var(--green-tint); font-weight: 700; }
.folder.active svg { color: var(--green); }
.folder .fname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-pill {
  background: var(--green); color: #fff; font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 1px 8px; min-width: 24px; text-align: center;
}
.unread-pill::before { content: none; }
.scrim { position: fixed; inset: 0; background: rgba(18, 30, 24, .4); z-index: 40; }

/* ---------------- message list ---------------- */
.list-pane {
  width: 400px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-radius: 20px 20px 0 0; margin: 4px 6px 0 0;
  box-shadow: 0 0 0 1px rgba(20, 40, 32, .04); overflow: hidden; position: relative;
}
.list-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); flex: none;
}
.list-count { margin-left: auto; font-size: 13px; color: var(--ink-soft); }
.email-list { overflow-y: auto; flex: 1; }
.email-row {
  display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #edf1ee;
  cursor: pointer; position: relative; align-items: flex-start;
}
.email-row:hover { box-shadow: inset 0 0 0 1px var(--line); z-index: 1; }
.email-row.read { background: var(--read-bg); }
.email-row.selected { background: var(--green-tint); }
.email-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 10px; accent-color: var(--green); flex: none; }
.row-avatar { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: center; flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-line1 { display: flex; align-items: baseline; gap: 8px; }
.row-from { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-date { margin-left: auto; font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; flex: none; }
.row-subject { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row-snippet { font-size: 13.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.email-row.unread .row-from, .email-row.unread .row-subject { font-weight: 700; }
.email-row.unread .row-date { color: var(--green); font-weight: 700; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; align-self: center; }
.row-icons { display: flex; align-items: center; gap: 2px; flex: none; }
.star-btn { border: 0; background: transparent; padding: 4px; border-radius: 50%; color: #b9c4bd; display: inline-flex; }
.star-btn:hover { background: rgba(14, 91, 67, .08); }
.star-btn svg { width: 19px; height: 19px; }
.star-btn.on { color: var(--gold); }
.clip-ic { color: #9fb0a6; display: inline-flex; }
.clip-ic svg { width: 17px; height: 17px; }
.empty-state, .read-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--ink-soft); font-size: 15px; padding: 30px; text-align: center;
}
.empty-logo { width: 54px; height: 54px; opacity: .35; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.6); z-index: 5; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--green-tint); border-top-color: var(--green);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-more { border: 0; background: transparent; color: var(--green); font-weight: 600; padding: 14px; font-size: 14.5px; }
.load-more:hover { background: var(--green-tint); }

/* ---------------- reading pane ---------------- */
.read-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 4px 10px 24px 4px; }
.read-card {
  background: var(--surface); border-radius: 20px; box-shadow: 0 0 0 1px rgba(20, 40, 32, .04);
  padding: 26px 30px 30px; max-width: 880px; margin: 4px auto 0;
}
.read-top { display: flex; align-items: flex-start; gap: 8px; }
.read-subject { font-size: 23px; font-weight: 600; margin: 2px 0 18px; letter-spacing: -.01em; flex: 1; }
.read-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.read-who { flex: 1; min-width: 0; }
.read-from { font-size: 15.5px; font-weight: 600; }
.read-to { font-size: 13.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.read-date { font-size: 13.5px; color: var(--ink-soft); white-space: nowrap; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fbfcfb;
  border-radius: 12px; padding: 9px 14px; font-size: 14px; font-weight: 500; color: var(--ink);
}
.att-chip:hover { background: var(--green-tint); border-color: transparent; }
.att-chip svg { width: 18px; height: 18px; color: var(--green); }
.att-chip .att-size { color: var(--ink-soft); font-weight: 400; font-size: 12.5px; }
#showImagesBtn { margin-bottom: 14px; }
.mail-body { font-size: 15.5px; line-height: 1.55; word-wrap: break-word; overflow-x: auto; }
.mail-body img { max-width: 100%; height: auto; }
.mail-body img.blocked-img { background: #eef2ef; min-width: 40px; min-height: 24px; }
.mail-body pre.body-text { white-space: pre-wrap; font-family: inherit; font-size: 15.5px; margin: 0; }
.read-actions { margin-top: 26px; display: flex; gap: 10px; }

/* ---------------- compose ---------------- */
.compose-card {
  position: fixed; right: 22px; bottom: 0; width: min(520px, calc(100vw - 20px)); z-index: 80;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: min(640px, 92dvh);
}
.compose-head {
  background: #24352d; color: #f2f6f3; font-weight: 600; font-size: 14.5px;
  padding: 11px 10px 11px 18px; border-radius: 18px 18px 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.compose-body { padding: 4px 18px; overflow-y: auto; }
.compose-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.compose-row input { flex: 1; border: 0; outline: none; padding: 12px 2px; font-size: 15px; background: transparent; min-width: 0; }
.cc-toggle { border: 0; background: transparent; color: var(--ink-soft); font-size: 14px; padding: 6px 4px; }
.cc-toggle:hover { color: var(--green); }
.compose-text { width: 100%; border: 0; outline: none; resize: none; min-height: 240px; padding: 14px 2px; font-size: 15.5px; line-height: 1.5; }
.compose-foot { display: flex; align-items: center; gap: 14px; padding: 12px 18px 16px; }
.compose-error { color: var(--danger); font-size: 14px; }

/* ---------------- toast / fab ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 120;
  background: #24352d; color: #f2f6f3; padding: 12px 22px; border-radius: 12px;
  font-size: 14.5px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 40px); text-align: center;
}
.fab {
  position: fixed; right: 18px; bottom: 22px; z-index: 70; width: 58px; height: 58px;
  border-radius: 50%; border: 0; background: var(--green); color: #fff;
  display: none; align-items: center; justify-content: center; box-shadow: var(--shadow-lg);
}
.fab svg { width: 24px; height: 24px; }

.only-mobile { display: none !important; }

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  .list-pane { width: 350px; }
}
@media (max-width: 900px) {
  .only-mobile { display: inline-flex !important; }
  .fab.only-mobile { display: flex !important; }
  .brand-name { display: none; }
  .brand-logo { display: none; }
  .brand { gap: 0; }
  .topbar { gap: 8px; padding: 8px 10px; }
  .search-pill { height: 44px; padding: 0 12px; margin: 0; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; background: var(--bg);
    width: 272px; transform: translateX(-105%); transition: transform .2s ease; padding-top: 18px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { position: relative; }
  .list-pane { width: 100%; margin: 4px 0 0; border-radius: 20px 20px 0 0; }
  .read-pane {
    position: fixed; inset: 0; z-index: 45; background: var(--bg); padding: 10px;
    transform: translateX(100%); transition: transform .2s ease; overflow-y: auto;
  }
  .read-pane.open { transform: translateX(0); }
  .read-card { margin-top: 0; padding: 18px; border-radius: 18px; }
  .compose-card { right: 0; left: 0; width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .compose-head { border-radius: 0; }
  .compose-text { min-height: 40dvh; }
  .email-row input[type="checkbox"] { display: block; }
}
