@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap");

:root {
  --brand: #3e4095;
  --brand-dark: #2a2c72;
  --brand-deep: #1c1e55;
  --brand-mid: #5254a8;
  --brand-soft: #e4e5f4;
  --brand-selected: #d5d6ef;
  --brand-mist: #f4f4f8;
  --brand-muted: #989b9d;
  --brand-red: #ed3237;
  --brand-red-soft: #fde8e9;
  --background: #f9f9fc;
  --foreground: #2a2a32;
  --white: #fefefe;
  --line: rgba(62, 64, 149, 0.12);
  --shadow: 0 18px 48px rgba(28, 30, 85, 0.12);
  --shadow-soft: 0 8px 24px rgba(28, 30, 85, 0.08);
  --radius: 18px;
  --font: "Outfit", "Segoe UI", sans-serif;
  font-family: var(--font);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
a { color: var(--brand); text-decoration: none; }
button { cursor: pointer; }
::selection { background: rgba(62, 64, 149, 0.18); }

/* ── Shared ─────────────────────────────────────────────── */
.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--brand-muted);
}
.muted { color: var(--brand-muted); }
.btn {
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: var(--white);
  padding: 12px 18px;
  font-weight: 650;
  box-shadow: 0 10px 24px rgba(62, 64, 149, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(62, 64, 149, 0.34);
}
.btn.block { width: 100%; }
.btn.soft {
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: none;
}
.linkish {
  background: none;
  border: 0;
  color: var(--brand);
  padding: 0;
  font-weight: 650;
}
.alert {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert.error {
  background: var(--brand-red-soft);
  color: var(--brand-red);
  border-color: rgba(237, 50, 55, 0.18);
}
.alert.ok {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--line);
}
label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-muted);
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid rgba(152, 155, 157, 0.45);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--foreground);
  background: var(--white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(62, 64, 149, 0.14);
}

/* ── Splash ─────────────────────────────────────────────── */
.splash, .login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.splash {
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(62, 64, 149, 0.16), transparent 60%),
    radial-gradient(circle at 85% 80%, rgba(237, 50, 55, 0.08), transparent 35%),
    linear-gradient(165deg, #ffffff 0%, var(--background) 45%, #eef0f8 100%);
}
.splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(62, 64, 149, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62, 64, 149, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 20%, transparent 75%);
  pointer-events: none;
}
.splash-card, .login-card { position: relative; text-align: center; z-index: 1; }
.logo-frame {
  background: var(--white);
  border-radius: 28px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.logo-frame img { width: 168px; height: 168px; display: block; }
.splash h1, .login-card h1 {
  margin: 6px 0 0;
  color: var(--brand);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-red);
  margin: 18px auto 0;
  box-shadow: 0 0 0 6px rgba(237, 50, 55, 0.12);
  animation: pulse-dot 1.8s ease-in-out infinite;
}

/* ── Login ──────────────────────────────────────────────── */
.login-wrap {
  padding: 32px 16px;
  background:
    radial-gradient(ellipse 60% 45% at 15% 20%, rgba(62, 64, 149, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 85%, rgba(237, 50, 55, 0.1), transparent 50%),
    linear-gradient(160deg, var(--brand-deep) 0%, var(--brand) 42%, #4a4cae 100%);
}
.login-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
}
.login-card {
  width: min(440px, 100%);
  text-align: left;
  background: rgba(254, 254, 254, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 28px;
  padding: 32px;
  box-shadow: 0 30px 80px rgba(18, 20, 60, 0.35);
  backdrop-filter: blur(12px);
  animation: rise 0.55s ease-out both;
}
.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}
.brand-row img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-soft);
}
.login-card .btn.block { margin-top: 6px; border-radius: 14px; }

/* ── Mail shell ─────────────────────────────────────────── */
.shell {
  min-height: 100%;
  display: flex;
  background:
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(62, 64, 149, 0.08), transparent 50%),
    radial-gradient(ellipse 40% 35% at 0% 100%, rgba(237, 50, 55, 0.05), transparent 45%),
    linear-gradient(180deg, #f2f3f9 0%, var(--background) 40%, #eef0f7 100%);
}
.sidebar {
  width: 268px;
  padding: 16px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background:
    linear-gradient(185deg, var(--brand-deep) 0%, var(--brand) 55%, #35378a 100%);
  color: rgba(255, 255, 255, 0.88);
  box-shadow: 8px 0 40px rgba(28, 30, 85, 0.18);
  position: relative;
  overflow: hidden;
}
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, black, transparent 85%);
  pointer-events: none;
}
.sidebar > * { position: relative; z-index: 1; }
.side-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px 18px;
}
.side-brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.side-brand strong {
  display: block;
  color: var(--white);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.side-brand span {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.nav-btn, .folder-link {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  padding: 11px 14px;
  margin-bottom: 2px;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.folder-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}
.folder-link.active {
  background: rgba(255, 255, 255, 0.16);
  color: var(--white);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.folder-link .folder-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.folder-link .folder-icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  flex-shrink: 0;
}
.folder-link .unread-pill {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--brand-red);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(237, 50, 55, 0.35);
}
.nav-btn.compose-btn {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
  font-weight: 700;
  justify-content: center;
  gap: 8px;
  border-radius: 16px;
  padding: 14px 16px;
  margin: 2px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}
.nav-btn.compose-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.22);
  filter: none;
}
.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 12px 0;
}
.topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 12px 12px;
}
.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(254, 254, 254, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 16px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search:focus-within {
  border-color: rgba(62, 64, 149, 0.35);
  box-shadow: 0 0 0 4px rgba(62, 64, 149, 0.1), var(--shadow-soft);
}
.search-icon {
  width: 18px;
  height: 18px;
  color: var(--brand-muted);
  flex-shrink: 0;
}
.search input {
  border: 0;
  background: transparent;
  margin: 0;
  padding: 10px 0;
  box-shadow: none;
}
.search input:focus { outline: none; box-shadow: none; }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(62, 64, 149, 0.15);
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: white;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(62, 64, 149, 0.25);
  transition: transform 0.15s ease;
}
.avatar:hover { transform: scale(1.04); }
.account { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: 48px;
  width: 240px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 5;
  padding: 8px;
  animation: rise 0.2s ease-out both;
}
.menu p {
  margin: 0 0 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--brand-muted);
  border-bottom: 1px solid var(--line);
}
.menu button, .menu a {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 12px;
  color: inherit;
  border-radius: 10px;
  font-weight: 550;
}
.menu button:hover, .menu a:hover { background: var(--brand-mist); color: var(--brand); }

.content {
  display: flex;
  gap: 12px;
  padding: 0 12px 0 12px;
  min-height: 0;
  flex: 1;
}
.list, .reader {
  background: rgba(254, 254, 254, 0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: auto;
  min-height: 420px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}
.list {
  width: min(400px, 42%);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.list-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(254, 254, 254, 0.98), rgba(254, 254, 254, 0.92));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.list-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-deep);
  letter-spacing: -0.02em;
}
.list-head .count {
  font-size: 12px;
  font-weight: 650;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 4px 10px;
}
.list-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(62, 64, 149, 0.08);
  font-size: 13px;
  font-weight: 600;
}
.list-pager a {
  color: var(--brand);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
}
.list-pager a:hover { background: var(--brand-mist); }
.list-pager .disabled {
  color: var(--brand-muted);
  opacity: 0.55;
  padding: 6px 10px;
}
.list-pager .pager-status {
  color: var(--brand-muted);
  font-weight: 550;
  font-size: 12px;
}
.reader { flex: 1; position: relative; }

.msg {
  width: 100%;
  display: flex;
  gap: 12px;
  text-align: left;
  border: 0;
  background: transparent;
  border-bottom: 1px solid rgba(62, 64, 149, 0.07);
  padding: 14px 16px;
  color: inherit;
  transition: background 0.14s ease;
  position: relative;
}
.msg:hover { background: rgba(62, 64, 149, 0.04); }
.msg.active {
  background: linear-gradient(90deg, rgba(62, 64, 149, 0.1), rgba(62, 64, 149, 0.04));
  box-shadow: inset 3px 0 0 var(--brand);
}
.msg.unread .who,
.msg.unread .sub { font-weight: 700; color: var(--brand-deep); }
.msg.unread::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(237, 50, 55, 0.15);
}
.msg-body { min-width: 0; flex: 1; }
.msg-top {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.msg .who {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg .sub {
  display: block;
  font-size: 14px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg .snip, .msg time {
  color: var(--brand-muted);
  font-size: 13px;
}
.msg .snip {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg time { margin-left: auto; white-space: nowrap; flex-shrink: 0; font-weight: 550; }
.msg-star {
  color: var(--brand-muted);
  font-size: 15px;
  line-height: 1;
  align-self: center;
}
.msg-star.on { color: #e6a700; }

.badge {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(62, 64, 149, 0.22);
}
.badge.alt {
  background: linear-gradient(145deg, #6b6eaa 0%, #989b9d 100%);
}

.reader-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 249, 252, 0.7);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(10px);
}
.reader-head a,
.reader-head button {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--foreground);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.reader-head a:hover,
.reader-head button:hover {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}
.reader-head .reply-btn {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  margin-left: auto;
}
.reader-head .reply-btn:hover {
  background: var(--brand-dark);
  color: white;
}
.reader article { padding: 28px 32px 48px; animation: rise 0.35s ease-out both; }
.reader h1 {
  font-weight: 700;
  font-size: clamp(22px, 3vw, 30px);
  margin: 0 0 20px;
  letter-spacing: -0.03em;
  color: var(--brand-deep);
  line-height: 1.2;
}
.meta { display: flex; gap: 14px; align-items: flex-start; }
.meta p { margin: 0; }
.reader-body {
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.7;
  margin-top: 22px;
  color: #33343c;
}
.reader-body.reader-html {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.reader-body.reader-html img {
  max-width: 100%;
  height: auto;
}
.reader-body.reader-html table {
  max-width: 100%;
  border-collapse: collapse;
}
.reader-body.reader-html a {
  color: var(--brand);
  text-decoration: underline;
}
.remote-images-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin: 18px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 13px;
  font-weight: 550;
}
.remote-images-bar a {
  color: var(--brand);
  font-weight: 700;
}
.empty {
  height: 100%;
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--brand-muted);
  text-align: center;
  padding: 32px;
}
.empty-panel {
  display: grid;
  gap: 10px;
  justify-items: center;
  max-width: 260px;
}
.empty-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  color: var(--brand);
  margin-bottom: 4px;
}
.empty-panel strong {
  color: var(--brand-deep);
  font-size: 16px;
}

/* ── Compose (existing overlay, refined) ────────────────── */
html.compose-open,
body.compose-open { overflow: hidden; overscroll-behavior: none; }
.compose {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  visibility: hidden;
}
.compose.open {
  pointer-events: auto;
  visibility: visible;
}
.compose-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 70% 85%, rgba(62, 64, 149, 0.22), transparent 55%),
    rgba(22, 24, 48, 0.45);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.compose.open .compose-backdrop { opacity: 1; }
.compose-panel {
  position: absolute;
  z-index: 1;
  right: 20px;
  bottom: 20px;
  width: min(480px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 80px));
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
  border: 1px solid rgba(62, 64, 149, 0.14);
  border-radius: 22px;
  box-shadow:
    0 28px 70px rgba(22, 24, 48, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  overflow: hidden;
  transform: translateY(28px) scale(0.97);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease,
    width 0.25s ease, height 0.25s ease, right 0.25s ease, bottom 0.25s ease;
}
/* Expanded (full) mode: large centred panel */
.compose.is-expanded .compose-panel {
  right: 24px;
  bottom: 24px;
  width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
}
@media (min-width: 1200px) {
  .compose.is-expanded .compose-panel {
    right: calc((100vw - 1100px) / 2);
    width: 1100px;
  }
}
.compose.is-expanded .compose-editor textarea { min-height: 320px; }
/* Scrollable middle section (recipients, message, attachments) */
.compose-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  background: var(--white);
}
.compose-body::-webkit-scrollbar { width: 8px; }
.compose-body::-webkit-scrollbar-thumb { background: rgba(62, 64, 149, 0.25); border-radius: 8px; }
.compose-size-toggle svg {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}
.compose-size-toggle .icon-contract { display: none; }
.compose.is-expanded .compose-size-toggle .icon-expand { display: none; }
.compose.is-expanded .compose-size-toggle .icon-contract { display: block; }
.compose.is-expanded .compose-panel {
  box-shadow:
    0 32px 80px rgba(22, 24, 48, 0.38),
    0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}
.compose.open .compose-panel {
  transform: none;
  opacity: 1;
}
.compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, var(--brand) 0%, #4f51ad 55%, #35378a 100%);
  color: white;
  flex-shrink: 0;
  position: relative;
}
.compose-head::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
}
.compose-head-copy { min-width: 0; }
.compose-kicker {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-bottom: 2px;
}
.compose-head strong {
  display: block;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compose-head-actions { display: flex; gap: 4px; flex-shrink: 0; }
.compose-icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.compose-icon-btn:hover { background: rgba(255, 255, 255, 0.22); }
.modal header {
  background: linear-gradient(135deg, var(--brand), var(--brand-mid));
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  flex-shrink: 0;
}
.modal header button {
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  color: white;
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 10px;
}
.compose-recipients {
  flex-shrink: 0;
  border-bottom: 1px solid var(--brand-soft);
  background: var(--white);
}
.compose-field-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-muted);
  min-width: 28px;
}
.compose-check {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--brand-mist);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.compose-check input { width: auto; margin: 0; accent-color: var(--brand); }
.compose-copy-toggles {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.compose-cc-toggle {
  border: 1px solid transparent;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
}
.compose-cc-toggle:hover,
.compose-cc-toggle.is-active {
  background: var(--brand-soft);
  border-color: rgba(62, 64, 149, 0.12);
}
.compose-external { padding: 8px 16px 4px; }
.compose-external input {
  width: 100%;
  margin: 0;
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--brand-soft);
  border-radius: 10px;
  background: var(--brand-mist);
}
.compose-hint {
  margin: 2px 16px 6px;
  font-size: 12px;
  color: var(--brand-muted);
}
.compose-editor {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--white);
}
.compose-signature-preview,
.compose-signature-empty {
  flex-shrink: 0;
  margin: 0 18px 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(62, 64, 149, 0.22);
  background: linear-gradient(180deg, rgba(244, 244, 248, 0.65), rgba(228, 229, 244, 0.45));
}
.compose-signature-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.compose-signature-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-muted);
}
.compose-signature-text {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--foreground);
}
.compose-signature-image {
  display: block;
  max-width: min(280px, 100%);
  max-height: 120px;
  width: auto;
  height: auto;
  margin-top: 10px;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 4px 14px rgba(28, 30, 85, 0.08);
}
.signature-modal-body { display: grid; gap: 4px; }
.signature-enable {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px !important;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--brand-mist);
  color: var(--foreground);
  font-weight: 650;
}
.signature-enable input { width: auto; margin: 0; accent-color: var(--brand); }
.signature-image-field { margin-top: 8px; }
.signature-image-label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--brand-muted);
}
.signature-current {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--brand-mist);
  border: 1px solid var(--line);
}
.signature-current img {
  max-width: min(320px, 100%);
  max-height: 140px;
  width: auto;
  height: auto;
  border-radius: 8px;
  background: var(--white);
}
.signature-remove {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  color: var(--brand-red);
  font-weight: 650;
}
.signature-remove input { width: auto; margin: 0; }
.signature-upload {
  display: inline-flex !important;
  margin: 0 !important;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.signature-upload input { display: none; }
.signature-live-preview {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.signature-live-preview img {
  max-width: min(280px, 100%);
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.compose-editor input[name="subject"] {
  flex-shrink: 0;
  border: 0;
  border-bottom: 1px solid var(--brand-soft);
  border-radius: 0;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 650;
  background: transparent;
  box-shadow: none;
}
.compose-editor input[name="subject"]:focus,
.compose-editor textarea:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--brand-soft);
}
.compose-editor textarea {
  flex: 1 0 auto;
  min-height: 240px;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 16px 18px 20px;
  line-height: 1.65;
  font-size: 15px;
  background: transparent;
  box-shadow: none;
}
.compose-attachments {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px dashed rgba(62, 64, 149, 0.22);
  background: linear-gradient(180deg, rgba(244, 244, 248, 0.55), rgba(244, 244, 248, 0.95));
  transition: background 0.15s ease, border-color 0.15s ease;
}
.compose-attachments.is-dragover {
  background: var(--brand-soft);
  border-top-style: solid;
  border-color: var(--brand);
}
.compose-attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.compose-attach-limit { font-size: 12px; }
.compose-attachments label.file-picker {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.compose-attachments label.file-picker:hover {
  box-shadow: 0 6px 16px rgba(62, 64, 149, 0.12);
  transform: translateY(-1px);
}
.compose-attachments label.file-picker.is-full { opacity: 0.5; pointer-events: none; }
.compose-attachments label.file-picker input { display: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.attachment-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--brand-soft);
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(22, 24, 48, 0.04);
}
.attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  font-weight: 600;
}
.attachment-chip-size { color: var(--brand-muted); white-space: nowrap; font-size: 12px; }
.attachment-chip-remove {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--brand-mist);
  color: var(--brand-muted);
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.attachment-chip-remove:hover { background: #fdecec; color: var(--brand-red); }
.attachment-chip.is-forwarded {
  background: linear-gradient(180deg, #f7f7fc, var(--brand-soft));
  border-color: rgba(62, 64, 149, 0.22);
}
.attachment-chip-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  background: rgba(254, 254, 254, 0.85);
  border-radius: 999px;
  padding: 2px 6px;
}
.forward-attachment-list { margin-top: 8px; }
.attachment-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-preview .chip { background: var(--white); border: 1px solid var(--brand-soft); }
.to-row, .cc-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--brand-soft);
  flex-wrap: wrap;
}
.to-row input, .cc-tools input { margin: 0; border: 0; padding: 6px 0; box-shadow: none; }
.cc-tools strong { color: var(--brand); font-size: 13px; }
.cc-tools input {
  flex: 1;
  min-width: 140px;
  border: 1px solid var(--brand-soft) !important;
  border-radius: 999px !important;
  padding: 7px 12px !important;
  background: var(--brand-mist);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chip {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.chip button { border: 0; background: none; }
.cc-list {
  max-height: 180px;
  overflow: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0 0 6px;
  list-style: none;
}
.cc-list label {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 8px 16px;
  color: var(--foreground);
  border-radius: 12px;
  transition: background 0.12s ease;
}
.cc-list label:hover { background: var(--brand-mist); }
.cc-list label:has(input:checked) { background: var(--brand-selected); }
.cc-list .who small { color: var(--brand-muted); }
.cc-list input[type="checkbox"] { accent-color: var(--brand); width: auto; margin: 0; }
.compose-foot, .modal footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--brand-soft);
  background: var(--white);
}
.compose-send {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  padding: 12px 18px;
}
.compose-discard { color: var(--brand-muted); font-weight: 600; }
.compose-discard:hover { color: var(--brand-red); }
.message-attachments {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.message-attachments a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--brand-mist);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}
.message-attachments small { color: var(--brand-muted); font-weight: 400; }
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(22, 24, 48, 0.45);
  backdrop-filter: blur(5px);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.open { display: flex; }
.modal form {
  width: min(440px, 100%);
  background: white;
  border-radius: 20px;
  border: 1px solid var(--brand-soft);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease-out both;
}
.modal .body { padding: 18px; }

/* ── Admin page ─────────────────────────────────────────── */
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  min-height: 100%;
  background:
    radial-gradient(ellipse 50% 30% at 0% 0%, rgba(62, 64, 149, 0.08), transparent 50%),
    var(--background);
}
.page > p a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
  margin-bottom: 8px;
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}
th, td {
  text-align: left;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
th {
  color: var(--brand-muted);
  background: var(--brand-mist);
  font-weight: 650;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pill {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 650;
}
.pill.off {
  background: var(--brand-red-soft);
  color: var(--brand-red);
}
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: end;
}
.menu-btn {
  display: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  font-size: 18px;
  color: var(--brand);
  box-shadow: var(--shadow-soft);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(22, 24, 48, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.22s ease;
  border: 0;
  padding: 0;
  cursor: pointer;
}
body.sidebar-open { overflow: hidden; }
@media (max-width: 900px) {
  .sidebar-backdrop.show {
    display: block;
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .shell { background: var(--background); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 15;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    width: min(280px, 86vw);
  }
  .sidebar.open { transform: none; }
  .main { padding: 8px; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .list { width: 100%; }
  .reader { display: none; }
  .reader.show { display: block; width: 100%; }
  .list.hide { display: none; }
  .grid { grid-template-columns: 1fr; }
  .compose-panel {
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    height: min(72dvh, calc(100dvh - 24px));
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }
  .compose.is-expanded .compose-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: auto;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .compose-editor textarea { min-height: 120px; }
  .reader article { padding: 20px 18px 36px; }
  .msg.unread::before { left: 4px; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 6px rgba(237, 50, 55, 0.12); }
  50% { transform: scale(1.15); box-shadow: 0 0 0 10px rgba(237, 50, 55, 0.06); }
}
.rise { animation: rise 0.7s ease-out both; }
.rise-late { animation: rise 0.7s ease-out 0.18s both; }
