:root {
  /* Versta Studio — Signature Espresso Dark */
  --shell: #130E0C;
  --surface: #1B1512;
  --surface-2: #221B17;
  --surface-hover: rgba(244, 239, 234, 0.048);
  --surface-unread: rgba(191, 176, 247, 0.055);
  --surface-selected: rgba(191, 176, 247, 0.14);
  --search-bg: #231C18;
  --search-focus: #2C231E;
  --line: rgba(244, 239, 234, 0.075);
  --line-strong: rgba(244, 239, 234, 0.14);
  --primary: #BFB0F7;
  --primary-deep: #A590EE;
  --primary-ink: #171126;
  --primary-soft: rgba(191, 176, 247, 0.14);
  --star: #E5A967;
  --emerald: #34D399;
  --danger: #F87171;
  --text: #F4EFEA;
  --text-2: #C4BAB2;
  --muted: #8E837B;
  --dim: #695F58;
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.56);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  /* Versta Studio — Warm Porcelain Light */
  --shell: #F5F0EB;
  --surface: #FFFFFF;
  --surface-2: #F7F3EF;
  --surface-hover: rgba(27, 20, 17, 0.036);
  --surface-unread: rgba(89, 67, 158, 0.04);
  --surface-selected: rgba(89, 67, 158, 0.11);
  --search-bg: #EAE3DC;
  --search-focus: #FFFFFF;
  --line: rgba(27, 20, 17, 0.08);
  --line-strong: rgba(27, 20, 17, 0.15);
  --primary: #59439E;
  --primary-deep: #4A3688;
  --primary-ink: #FFFFFF;
  --primary-soft: rgba(89, 67, 158, 0.11);
  --star: #D97706;
  --emerald: #059669;
  --danger: #DC2626;
  --text: #1B1411;
  --text-2: #4A403B;
  --muted: #766B64;
  --dim: #9C918A;
  --shadow-pop: 0 16px 42px rgba(27, 20, 17, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--shell);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; color: inherit; }
svg { display: block; flex-shrink: 0; }

.app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--shell);
}

/* ================= TOP HEADER ================= */
.top-header {
  height: 64px;
  padding: 0 18px 0 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.brand-cluster {
  width: 224px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}
.logo-img.sm { width: 26px; height: 26px; border-radius: 7px; }
.logo-img.xl { width: 56px; height: 56px; border-radius: 16px; }

.brand-name {
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ico-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}
.ico-btn:hover { background: var(--surface-hover); color: var(--text); }
.ico-btn.sm { width: 32px; height: 32px; }

/* Search Capsule (Gmail) */
.search-wrap {
  flex: 1;
  max-width: 680px;
  position: relative;
}

.search-pill {
  height: 44px;
  background: var(--search-bg);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 8px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s var(--ease);
}
.search-pill:focus-within {
  background: var(--search-focus);
  border-color: var(--line-strong);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
}
.search-pill input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
}
.search-pill input::placeholder { color: var(--muted); }

.mobile-menu-trigger { display: none; }
.mobile-av-trigger { display: none; }

.filter-pop {
  position: absolute;
  top: 52px;
  right: 0;
  width: 248px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow-pop);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 60;
}
.filter-pop.open { display: flex; }
.f-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-radius: 10px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
}
.f-opt:hover { background: var(--surface-hover); color: var(--text); }
.f-opt.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* Right Header Cluster */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.avatar-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.16s ease;
}
.avatar-trigger:hover { border-color: var(--line-strong); }

.av {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.av.lg { width: 42px; height: 42px; font-size: 15px; }
.av.row { width: 40px; height: 40px; font-size: 13.5px; border-radius: 13px; }
.av.list-av { width: 30px; height: 30px; font-size: 11px; border-radius: 9px; }

.av img.brand-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #FFFFFF;
  padding: 4px;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(27, 20, 17, 0.08);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.av img.brand-img.loaded { opacity: 1; }

.av-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  max-width: 145px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Collapsed Account Popover */
.acc-popover {
  position: absolute;
  top: 48px;
  right: 0;
  width: 304px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-pop);
  padding: 10px;
  display: none;
  flex-direction: column;
  gap: 3px;
  z-index: 80;
}
.acc-popover.open { display: flex; }

.acc-pop-head {
  padding: 8px 10px 11px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 4px;
}
.acc-pop-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-pop-email { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.acc-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}
.acc-opt:hover { background: var(--surface-hover); }
.acc-opt.active { background: var(--primary-soft); }
.acc-opt-info { flex: 1; min-width: 0; }
.acc-opt-mail { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-opt-sub { font-size: 11px; color: var(--muted); }
.acc-divider { height: 1px; background: var(--line); margin: 4px 6px; }
.acc-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  border: none;
  background: transparent;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
}
.acc-action:hover { background: var(--surface-hover); color: var(--text); }
.acc-action.danger { color: var(--danger); }

/* ================= WORKSPACE ================= */
.main-body {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 0 14px 14px 0;
}

.left-rail {
  width: 238px;
  flex-shrink: 0;
  padding: 4px 12px 10px 12px;
  display: flex;
  flex-direction: column;
  transition: width 0.22s var(--ease);
}
.left-rail.collapsed { width: 72px; padding: 4px 10px 10px; }
.left-rail.collapsed .nav-text,
.left-rail.collapsed .nav-cnt,
.left-rail.collapsed .nav-sec,
.left-rail.collapsed .quota-wrap { display: none; }
.left-rail.collapsed .compose-btn { width: 50px; min-width: 50px; padding: 0; justify-content: center; }
.left-rail.collapsed .nav-item { justify-content: center; padding: 0; width: 44px; height: 44px; margin: 0 auto; }

.compose-btn {
  height: 48px;
  width: fit-content;
  min-width: 148px;
  padding: 0 20px;
  margin: 2px 0 14px 2px;
  border: none;
  border-radius: 16px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(158, 136, 234, 0.24);
  transition: transform 0.16s var(--ease), box-shadow 0.18s ease;
}
.compose-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(158, 136, 234, 0.34); }

.nav-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-cnt { margin-left: auto; font-size: 12px; font-weight: 700; }

.nav-sec {
  padding: 16px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.label-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--primary); }

.quota-wrap {
  padding: 12px 14px 2px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.quota-track { height: 4px; border-radius: 999px; background: var(--line-strong); overflow: hidden; margin-bottom: 6px; }
.quota-bar { height: 100%; width: 4%; border-radius: 999px; background: var(--primary); transition: width 0.3s ease; }
.quota-txt { font-size: 11px; color: var(--muted); }

/* ================= MAIN MAIL SHEET ================= */
.mail-sheet {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-toolbar {
  height: 48px;
  padding: 0 14px 0 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chk {
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1.6px solid var(--dim);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.14s ease;
  flex-shrink: 0;
}
.chk:hover { border-color: var(--text-2); }
.chk.checked { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

.tb-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.layout-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--shell);
  border: 1px solid var(--line);
}
.layout-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.layout-toggle button.active { background: var(--surface-2); color: var(--text); }

.danger-pill-btn {
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
  color: var(--danger);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
}
.danger-pill-btn:hover { background: rgba(248, 113, 113, 0.18); }

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

.mail-list {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

.sheet-content.split .mail-list {
  width: 390px;
  flex: none;
  border-right: 1px solid var(--line);
}

/* Gmail Row */
.g-row {
  height: 52px;
  padding: 0 16px 0 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.g-row:hover { background: var(--surface-hover); }
.g-row.unread { background: var(--surface-unread); }
.g-row.unread:hover { background: var(--surface-hover); }
.g-row.selected { background: var(--surface-selected); }

.star-ico {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 999px;
}
.star-ico:hover { background: var(--surface-hover); color: var(--text-2); }
.star-ico.on { color: var(--star); }

.g-sender {
  width: 176px;
  flex-shrink: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-row.unread .g-sender { font-weight: 700; color: var(--text); }

.g-mid {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-subj { color: var(--text-2); font-weight: 500; }
.g-row.unread .g-subj { color: var(--text); font-weight: 700; }
.g-snip { color: var(--muted); font-weight: 400; }

.g-att { color: var(--muted); flex-shrink: 0; }
.g-time {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  min-width: 54px;
  text-align: right;
  flex-shrink: 0;
}
.g-row.unread .g-time { color: var(--text); font-weight: 700; }

.g-hover-acts { display: none; align-items: center; gap: 2px; flex-shrink: 0; }
.g-row:hover .g-time { display: none; }
.g-row:hover .g-hover-acts { display: flex; }

/* Split-mode row */
.sheet-content.split .g-row {
  height: auto;
  padding: 12px 14px;
  align-items: flex-start;
}
.sheet-content.split .g-sender { width: auto; }
.sheet-content.split .g-mid { white-space: normal; }
.sheet-content.split .g-hover-acts { display: none !important; }
.sheet-content.split .g-row:hover .g-time { display: block; }

/* Reader Pane */
.mail-reader {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 24px 32px 44px;
  display: none;
  flex-direction: column;
  gap: 18px;
}
.sheet-content.reading-full .mail-list { display: none; }
.sheet-content.reading-full .mail-reader { display: flex; }
.sheet-content.split .mail-reader { display: flex; padding: 20px 26px 36px; }

.r-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.r-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.r-folder-tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.t-msg {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}
.t-msg:last-of-type { border-bottom: none; padding-bottom: 4px; }
.t-msg.collapsed {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface-2);
}
.t-msg.collapsed:hover { border-color: var(--line-strong); }

.t-head { display: flex; align-items: center; gap: 12px; }
.t-meta { flex: 1; min-width: 0; }
.t-from { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.t-addr { font-size: 12.5px; font-weight: 400; color: var(--muted); word-break: break-all; }
.t-sub { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.t-date { font-size: 12px; color: var(--muted); flex-shrink: 0; }

.t-body-wrap {
  margin: 16px 0 0 50px;
}

.plain-body {
  font-size: 14.5px;
  line-height: 1.68;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 74ch;
}
.plain-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.plain-body blockquote {
  border-left: 2.5px solid var(--line-strong);
  padding-left: 12px;
  margin: 6px 0;
  color: var(--muted);
}

.html-frame-wrap {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #FFFFFF;
}
.html-frame-wrap.themed {
  background: transparent;
  border-color: transparent;
}
.email-iframe {
  width: 100%;
  min-height: 140px;
  border: none;
  display: block;
}

.att-row {
  margin: 14px 0 0 50px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: border-color 0.15s ease;
  max-width: 100%;
}
.att-chip:hover { border-color: var(--primary); }
.att-chip-name { font-size: 12.5px; font-weight: 600; word-break: break-all; }
.att-chip-size { font-size: 11px; color: var(--muted); }

.reply-actions {
  margin: 6px 0 0 50px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.outline-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-2);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.outline-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--muted); }

.primary-btn {
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.primary-btn:disabled { opacity: 0.55; cursor: default; }

.inline-reply-box {
  margin: 10px 0 0 50px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-2);
  padding: 14px 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
}
.inline-reply-box.open { display: flex; }
.inline-reply-box textarea {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  resize: vertical;
  font-size: 13.5px;
  line-height: 1.55;
  min-height: 88px;
}

/* Floating Compose (Gmail bottom-right) */
.compose-float {
  position: fixed;
  right: 24px;
  bottom: 0;
  width: 510px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-pop);
  display: none;
  flex-direction: column;
  z-index: 90;
  overflow: hidden;
}
.compose-float.open { display: flex; }

.cf-head {
  height: 44px;
  padding: 0 10px 0 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
}
.cf-from-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.cf-from-row select {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text);
}
.cf-from-row option { background: var(--surface); color: var(--text); }

.cf-field {
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
}
.cf-body {
  border: none;
  background: transparent;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  min-height: 200px;
  max-height: 44vh;
  outline: none;
  resize: vertical;
}
.cf-att-list {
  padding: 0 16px 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cf-att-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 12px;
}
.cf-foot {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Auth & Modals */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 6, 0.68);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 20px;
}
.modal-bg.open { display: flex; }

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.m-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
}
.m-input:focus { border-color: var(--primary); }
.err-box {
  display: none;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.14);
  color: var(--danger);
  font-size: 12.5px;
}

.mobile-fab { display: none; }
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 65;
}
.drawer-backdrop.open { display: block; }

.empty-state {
  padding: 72px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s var(--ease);
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= SILKY ANIMATIONS & SKELETONS ================= */
@keyframes popIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideUpModal {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes readerEnter {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes rowFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.acc-popover.open, .filter-pop.open {
  animation: popIn 0.2s var(--ease) both;
  transform-origin: top right;
}
.compose-float.open {
  animation: slideUpModal 0.24s var(--ease) both;
}
.modal-bg.open { animation: rowFade 0.16s ease both; }
.modal-bg.open .modal-card { animation: slideUpModal 0.24s var(--ease) both; }
.sheet-content.reading-full .mail-reader { animation: readerEnter 0.24s var(--ease) both; }
.g-row { animation: rowFade 0.18s var(--ease) both; }
.inline-reply-box.open { animation: popIn 0.2s var(--ease) both; }

.skeleton-wrap { padding: 14px 20px; display: flex; flex-direction: column; gap: 14px; }
.skel-line {
  height: 14px; border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.35s infinite linear;
}

/* ================= MOBILE WEB RESPONSIVE ================= */
@media (max-width: 820px) {
  .top-header {
    height: auto;
    padding: 10px 12px 8px;
    gap: 0;
  }
  .brand-cluster, .header-right { display: none; }
  .search-wrap { max-width: none; }
  .search-pill {
    height: 48px;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 0 7px 0 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  }
  .mobile-menu-trigger { display: grid; }
  .mobile-av-trigger { display: flex; border: none; background: transparent; cursor: pointer; padding: 2px; border-radius: 999px; }
  .desktop-search-ico { display: none; }

  .main-body { padding: 0; }
  .left-rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px !important;
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 70;
    padding: 16px 12px;
    transform: translateX(-100%);
    transition: transform 0.24s var(--ease);
  }
  .left-rail.mobile-open { transform: translateX(0); }
  .left-rail .compose-btn { display: none; }

  .mail-sheet {
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--line);
  }
  .layout-toggle { display: none; }

  .g-row {
    height: auto;
    padding: 12px 14px;
    align-items: flex-start;
    gap: 12px;
  }
  .g-row .chk { display: none; }
  .g-row .g-hover-acts { display: none !important; }
  .g-row:hover .g-time { display: block; }
  .g-sender { width: auto; }
  .g-mid { white-space: normal; }

  .mail-reader { padding: 16px 14px 36px; }
  .t-body-wrap, .att-row, .reply-actions, .inline-reply-box { margin-left: 0; }

  .mobile-fab {
    display: inline-flex;
    position: fixed;
    right: 16px;
    bottom: 20px;
    z-index: 50;
    height: 50px;
    padding: 0 18px;
    border: none;
    border-radius: 16px;
    background: var(--primary);
    color: var(--primary-ink);
    font-size: 14px;
    font-weight: 700;
    align-items: center;
    gap: 9px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
    cursor: pointer;
  }
  .compose-float {
    right: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: 92dvh;
    border-radius: 20px 20px 0 0;
  }
  .acc-popover {
    position: fixed;
    top: 66px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: 360px;
    margin-left: auto;
  }
}

/* ================= DENSITY & SNIPPET MODES ================= */
[data-density="compact"] .g-row { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
[data-density="spacious"] .g-row { min-height: 58px; padding-top: 13px; padding-bottom: 13px; }
[data-snip-lines="0"] .g-snip, [data-snip-lines="0"] .m-snip { display: none !important; }
[data-snip-lines="2"] .m-snip { white-space: normal !important; display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ================= FULL 2-PANE SETTINGS MODAL ================= */
.settings-modal {
  width: min(860px, 95vw);
  height: min(640px, 88vh);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  box-shadow: var(--shadow-pop);
  display: flex;
  overflow: hidden;
  animation: popIn 0.22s var(--ease);
}
.set-sidebar {
  width: 238px;
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.set-side-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.set-side-head img { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; }
.set-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.set-tab:hover { background: var(--surface-hover); color: var(--text); }
.set-tab.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.set-ico-tile {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.set-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.set-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px 12px;
  border-bottom: 1px solid var(--line);
}
.set-main-head h3 { font-size: 17px; font-weight: 800; }
.set-scroll { flex: 1; overflow-y: auto; padding: 18px 22px 22px; }
.set-pane { display: none; }
.set-pane.active { display: block; animation: readerEnter 0.18s var(--ease); }
.set-sec-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px 4px;
}
.set-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.set-field-block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.set-field-block:last-child { border-bottom: none; }
.set-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.set-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: none; }
.set-row-txt { flex: 1; min-width: 0; }
.set-row-txt strong { display: block; font-size: 13.5px; font-weight: 700; color: var(--text); }
.set-row-txt span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.seg-ctrl {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.seg-ctrl button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.seg-ctrl button.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(191,176,247,0.28);
}
.v-switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; }
.v-switch input { opacity: 0; width: 0; height: 0; }
.v-switch span {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--line-strong); transition: background 0.18s ease;
}
.v-switch span::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--text); transition: transform 0.18s var(--ease);
}
.v-switch input:checked + span { background: var(--primary); }
.v-switch input:checked + span::after { transform: translateX(18px); background: var(--primary-ink); }
.set-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.created-secret-box {
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(52,211,153,0.12);
  border: 1px solid rgba(52,211,153,0.35);
  color: var(--text);
  font-size: 12.5px;
  margin-bottom: 10px;
  word-break: break-all;
}
.img-blocked-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--surface-hover);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.toast-undo-btn {
  margin-left: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.12);
  color: inherit;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
@media (max-width: 760px) {
  .settings-modal { flex-direction: column; width: 96vw; height: 90dvh; }
  .set-sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; border-right: none; border-bottom: 1px solid var(--line); }
  .set-side-head { display: none; }
  .set-tab { width: auto; white-space: nowrap; padding: 7px 11px; }
}
.privacy-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.shield-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(52, 211, 153, 0.14);
  color: #34D399;
  border: 1px solid rgba(52, 211, 153, 0.28);
}
.unsub-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--line-strong);
  cursor: pointer;
}
.unsub-pill:hover { background: var(--primary-soft); color: var(--primary); }
.g-row.kb-focus { box-shadow: inset 3px 0 0 var(--primary); background: var(--surface-hover); }
.hk-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  font-size: 13px;
  align-items: center;
}
.hk-grid kbd {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
}
