:root {
  --red: #ff0000;
  --blue: #0000fe;
  --ink: #111;
  --bg: #f5f6fa;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(17, 17, 17, 0.09);
  --muted: #6f7380;
  --shadow: 0 22px 60px rgba(36, 43, 72, 0.12);
  --sidebar: 252px;
  --radius: 20px;
}
* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--blue) 48%, var(--muted)) transparent;
}
*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  min-height: 42px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 0, 0, 0.72), rgba(0, 0, 254, 0.72)) padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--red), var(--blue)) padding-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
body {
  overflow-x: hidden;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
.hidden,
[hidden] {
  display: none !important;
}
.glass {
  background: var(--panel);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.65);
}
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -1;
}
.ambient i {
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.12;
  animation: float 18s ease-in-out infinite;
}
.ambient i:nth-child(1) {
  width: 45vw;
  height: 45vw;
  background: var(--red);
  left: -15vw;
  top: -20vw;
}
.ambient i:nth-child(2) {
  width: 40vw;
  height: 40vw;
  background: var(--blue);
  right: -18vw;
  top: 20vh;
  animation-delay: -6s;
}
.ambient i:nth-child(3) {
  width: 30vw;
  height: 30vw;
  background: #906bff;
  left: 35vw;
  bottom: -20vw;
  animation-delay: -12s;
}
@keyframes float {
  50% {
    transform: translate(5vw, 8vh) scale(1.15);
  }
}
.brand-mark {
  width: 52px;
  height: 52px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-weight: 800;
  font-size: 22px;
  box-shadow: inset -8px -8px 0 var(--blue);
  position: relative;
}
.brand-mark:after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--red);
  border-radius: 50%;
  right: 7px;
  top: 7px;
}
.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 16px;
}
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 90px 20px 45px;
}
.auth-brand {
  position: absolute;
  left: 5vw;
  top: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 20px;
}
.auth-card {
  width: min(440px, 100%);
  border-radius: 30px;
  padding: 44px;
  box-shadow: var(--shadow);
}
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--blue);
}
h1 {
  font-size: 44px;
  line-height: 1.05;
  margin: 12px 0;
}
h1 span {
  color: var(--red);
}
.auth-card > p {
  color: var(--muted);
  margin: 0 0 28px;
}
.auth-card label,
.account-form label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 16px;
}
.auth-card input,
.account-form input,
.account-form select,
.account-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  padding: 13px 14px;
  outline: none;
}
.auth-card input:focus,
.account-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 0, 254, 0.08);
}
.primary {
  border: 0;
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 11px;
  font-weight: 700;
}
.primary:hover {
  background: var(--blue);
  transform: translateY(-1px);
}
.primary.full {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.switch-copy {
  text-align: center;
  font-size: 13px !important;
  margin: 20px 0 0 !important;
}
.link-button,
.text-action {
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 700;
}
.form-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}
.auth-foot {
  position: absolute;
  bottom: 24px;
  color: var(--muted);
  font-size: 12px;
}
.topbar {
  height: 72px;
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  border-width: 0 0 1px;
}
.logo {
  width: 208px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
}
.menu-btn {
  display: none;
}
.icon-btn {
  border: 0;
  background: transparent;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
}
.icon-btn:hover {
  background: rgba(17, 17, 17, 0.07);
}
.search {
  height: 48px;
  max-width: 690px;
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(240, 241, 247, 0.7);
  border-radius: 15px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  gap: 10px;
}
.search input {
  border: 0;
  background: none;
  outline: 0;
  flex: 1;
  font-size: 15px;
}
.search button {
  border: 0;
  background: none;
}
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
}
.avatar {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #6f70ff);
  color: #fff;
  font-weight: 700;
}
.account-menu-wrap {
  position: relative;
}
.account-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 12px);
  right: 0;
  width: min(280px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 55px rgba(17, 17, 17, 0.18);
}
.account-menu[hidden] {
  display: none;
}
.account-menu-profile {
  display: grid;
  gap: 3px;
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.account-menu-profile small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 5px;
  padding: 11px 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.account-menu button:hover,
.account-menu button:focus-visible {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.account-menu button.danger {
  color: var(--red);
}
.button-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.notify-btn {
  position: relative;
}
.notify-btn b {
  position: absolute;
  right: 0;
  top: -2px;
  background: var(--red);
  color: #fff;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 17px;
}
.sidebar {
  position: fixed;
  left: 0;
  top: 72px;
  bottom: 0;
  width: var(--sidebar);
  border-width: 0 1px 0 0;
  padding: 20px 14px;
  z-index: 15;
  display: flex;
  flex-direction: column;
}
.compose-main {
  height: 52px;
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 22px;
  margin: 0 5px 20px;
  box-shadow: 0 8px 25px rgba(17, 17, 17, 0.18);
}
.compose-main span {
  font-size: 22px;
}
.compose-main:hover {
  background: var(--red);
  transform: translateY(-2px);
}
nav {
  display: grid;
  gap: 2px;
}
.folder-btn,
.sidebar-bottom button {
  height: 39px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  color: #444;
}
.folder-btn span:nth-child(2) {
  flex: 1;
}
.folder-btn small {
  font-size: 11px;
}
.folder-btn.active {
  background: rgba(255, 0, 0, 0.09);
  color: var(--red);
  font-weight: 700;
}
.folder-btn:hover,
.sidebar-bottom button:hover {
  background: rgba(17, 17, 17, 0.05);
}
.nav-section {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 800;
  margin: 17px 13px 5px;
}
.sidebar-bottom {
  margin-top: auto;
  display: grid;
}
.sidebar-bottom button {
  width: 100%;
}
.storage {
  padding: 18px 13px 4px;
  font-size: 11px;
  color: var(--muted);
}
.storage {
  cursor: pointer;
  border-radius: 10px;
}
.storage:hover,
.storage:focus-visible {
  background: rgba(0, 0, 254, 0.06);
  outline: none;
}
.storage div {
  display: flex;
  justify-content: space-between;
}
.storage progress {
  width: 100%;
  height: 4px;
  margin: 8px 0;
  border: 0;
}
.main {
  margin: 72px 0 0 var(--sidebar);
  min-height: calc(100vh - 72px);
  padding: 14px;
}
.mail-view,
.content-view {
  min-height: calc(100vh - 100px);
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 35px rgba(30, 34, 60, 0.05);
}
.list-head {
  height: 55px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
}
.list-head > div {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination {
  font-size: 12px;
  color: var(--muted);
}
.pagination button {
  border: 0;
  background: none;
  font-size: 20px;
}
.category-tabs {
  height: 57px;
  border-bottom: 1px solid var(--line);
  display: flex;
}
.category-tabs button {
  min-width: 150px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font-weight: 600;
  color: var(--muted);
}
.category-tabs button.active {
  border-color: var(--blue);
  color: var(--blue);
}
.message-row {
  height: 60px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 28px 28px minmax(145px, 200px) minmax(200px, 1fr) 85px;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  cursor: pointer;
  transition: 0.15s;
}
.message-row:hover {
  box-shadow: 0 3px 18px rgba(20, 24, 45, 0.09);
  transform: translateY(-1px);
  position: relative;
  background: #fff;
}
.message-row.unread {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.83);
}
.message-row button {
  border: 0;
  background: none;
  color: #a1a4ad;
}
.message-row .star.active {
  color: #ffb300;
}
.subject-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-line span {
  font-weight: 400;
  color: var(--muted);
}
.message-time {
  text-align: right;
  font-size: 11px;
}
.empty-state {
  text-align: center;
  padding: 12vh 20px;
  color: var(--muted);
}
.empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 25px;
  background: linear-gradient(
    145deg,
    rgba(255, 0, 0, 0.12),
    rgba(0, 0, 254, 0.12)
  );
  display: grid;
  place-items: center;
  font-size: 35px;
  margin: 0 auto 20px;
}
.empty-state h2 {
  color: var(--ink);
  margin-bottom: 5px;
}
.content-view {
  padding: 30px;
}
.content-view h1 {
  font-size: 30px;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 24px 0;
}
.stat {
  padding: 22px;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
}
.stat b {
  font-size: 28px;
  display: block;
  margin-top: 8px;
}
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 25px;
}
.settings-menu {
  display: grid;
  align-content: start;
  gap: 3px;
}
.settings-menu button {
  border: 0;
  background: none;
  padding: 12px;
  text-align: left;
  border-radius: 10px;
}
.settings-menu button.active {
  background: var(--ink);
  color: white;
}
.settings-panel {
  max-width: 820px;
}
.setting-card {
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.setting-card .account-dot {
  width: 43px;
  height: 43px;
  border-radius: 13px;
  background: rgba(0, 0, 254, 0.1);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 800;
}
.setting-card > div:nth-child(2) {
  flex: 1;
}
.setting-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}
.secondary {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  font-weight: 600;
}
.danger {
  color: var(--red);
}
.composer {
  position: fixed;
  z-index: 30;
  right: 24px;
  bottom: 0;
  width: min(560px, calc(100vw - 30px));
  height: 600px;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 20px 70px rgba(14, 18, 45, 0.28);
  overflow: hidden;
  animation: rise 0.25s ease;
}
.composer.minimized {
  height: 52px;
}
.composer-head {
  height: 52px;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.composer-head button {
  border: 0;
  background: none;
  color: #fff;
  font-size: 18px;
}
.composer form {
  height: calc(100% - 52px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.92);
}
.composer form > input,
.address-row {
  height: 44px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
}
.address-row {
  display: flex;
  align-items: center;
}
.address-row input {
  border: 0;
  outline: 0;
  flex: 1;
}
.address-row button {
  border: 0;
  background: none;
  font-size: 12px;
  color: var(--muted);
}
.composer form > input {
  outline: 0;
}
.editor {
  flex: 1;
  padding: 18px;
  outline: 0;
  overflow: auto;
}
.formatbar {
  display: flex;
  border-top: 1px solid var(--line);
  padding: 4px 12px;
}
.formatbar button {
  border: 0;
  background: none;
  width: 34px;
  height: 32px;
}
.compose-foot {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  gap: 12px;
}
.send-group {
  display: flex;
}
.send-group .primary:first-child {
  border-radius: 10px 0 0 10px;
}
.send-group .split {
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0 10px 10px 0;
  padding: 12px;
}
.compose-foot > span {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
}
.trash {
  border: 0;
  background: none;
}
.attachment-list {
  padding: 0 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.attachment-chip {
  font-size: 11px;
  background: #eee;
  padding: 5px 8px;
  border-radius: 7px;
}
@keyframes rise {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
}
.notification-panel {
  position: fixed;
  z-index: 35;
  right: 16px;
  top: 82px;
  bottom: 16px;
  width: min(390px, calc(100vw - 32px));
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  overflow: auto;
}
.panel-head,
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
}
.panel-head h2,
.modal-head h2 {
  margin: 4px 0 8px;
}
.text-action {
  padding: 0;
}
.notification-list {
  margin: 15px 0;
}
.notification-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  padding: 13px 3px;
  border-bottom: 1px solid var(--line);
}
.notification-item.unread:before {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
}
.notification-item i {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(0, 0, 254, 0.1);
  display: grid;
  place-items: center;
  font-style: normal;
}
.notification-item i svg,
.notification-bell {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.notification-item b {
  font-size: 13px;
}
.notification-item p {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0;
}
.notification-permission {
  border-radius: 15px;
  padding: 16px;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 254, 0.08),
    rgba(255, 0, 0, 0.07)
  );
  display: grid;
  gap: 7px;
}
.notification-permission span {
  font-size: 12px;
  color: var(--muted);
}
.modal-wrap {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(11, 12, 18, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  width: min(740px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.grid {
  display: grid;
  gap: 14px;
}
.grid.two {
  grid-template-columns: 1fr 1fr;
}
.server-grid {
  grid-template-columns: 1fr 100px 110px;
  align-items: end;
}
.account-form h3 {
  margin: 8px 0 12px;
}
.account-form .check {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
}
.account-form .check input {
  width: auto;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  gap: 8px;
}
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 13px 18px;
  box-shadow: var(--shadow);
  animation: rise 0.2s ease;
  font-size: 13px;
}
.toast.error {
  background: var(--red);
}
.pwa-install-prompt {
  position: fixed;
  z-index: 120;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(430px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 22px 65px rgba(17, 17, 17, 0.2);
  animation: rise 0.28s ease both;
}
.pwa-install-prompt[hidden] {
  display: none;
}
.pwa-install-prompt img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}
.pwa-install-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.pwa-install-copy b {
  font-size: 15px;
}
.pwa-install-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}
.pwa-install-actions .primary {
  min-height: 40px;
  padding-inline: 17px;
}
.pwa-install-actions .icon-btn {
  width: 38px;
  height: 38px;
}
@media (max-width: 560px) {
  .pwa-install-prompt {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    grid-template-columns: 44px minmax(0, 1fr);
    padding: 12px;
  }
  .pwa-install-prompt img {
    width: 44px;
    height: 44px;
  }
  .pwa-install-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}
body.dark {
  --bg: #0d0e12;
  --ink: #f6f7fa;
  --panel: rgba(24, 25, 31, 0.8);
  --line: rgba(255, 255, 255, 0.09);
  --muted: #a2a4ae;
  color-scheme: dark;
}
.message-body {
  max-width: 920px;
  line-height: 1.65;
  padding: 24px 5px;
  overflow-wrap: anywhere;
}
.message-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}
.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.reader-attachments {
  margin: 8px 0 28px;
  display: grid;
  gap: 12px;
}
.attachment-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.attachment-card img,
.attachment-card iframe,
.file-preview {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border: 0;
  border-radius: 9px;
  background: rgba(0, 0, 254, 0.06);
}
.file-preview {
  display: grid;
  place-items: center;
  color: var(--blue);
  font-weight: 800;
  font-size: 12px;
}
.attachment-card div {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.attachment-card b,
.attachment-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-card small,
.muted {
  color: var(--muted);
}
.send-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: currentColor;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
button.sending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: wait;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.ambient {
  background: radial-gradient(
    circle at 50% 0%,
    rgba(255, 255, 255, 0.95),
    transparent 55%
  );
}
.ambient i {
  filter: blur(42px);
  opacity: 0.09;
  animation: ambientDrift 20s ease-in-out infinite alternate;
}
.ambient i:nth-child(1) {
  background: #ffb4a8;
}
.ambient i:nth-child(2) {
  background: #b9c8ff;
  animation-duration: 25s;
}
.ambient i:nth-child(3) {
  background: #ffe2ad;
  animation-duration: 28s;
}
@keyframes ambientDrift {
  0% {
    transform: translate3d(-2vw, -2vh, 0) scale(0.95);
  }
  50% {
    transform: translate3d(6vw, 5vh, 0) scale(1.1);
  }
  100% {
    transform: translate3d(-3vw, 9vh, 0) scale(1.02);
  }
}
.dark .ambient {
  background: radial-gradient(
    circle at 50% 0%,
    rgba(78, 81, 105, 0.35),
    transparent 58%
  );
}
.dark .ambient i {
  opacity: 0.12;
  filter: blur(55px);
}
.dark .bulk-menu,
.dark .attachment-card,
.dark .profile-form input,
.dark .setting-select,
.dark .bulk-menu select {
  background: rgba(39, 42, 52, 0.98);
  color: #f8f9fc;
}
.dark .subject-line,
.dark .message-sender,
.dark .message-time,
.dark .reader,
.dark .settings-panel,
.dark .settings-menu button {
  color: #f8f9fc;
}
.dark .subject-line span,
.dark .setting-card small,
.dark .message-body,
.dark .attachment-card small {
  color: #c5c8d2;
}
@media (prefers-reduced-motion: reduce) {
  .ambient i,
  .send-spinner {
    animation: none;
  }
}
@media (max-width: 650px) {
  .attachment-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .attachment-card img,
  .attachment-card iframe,
  .file-preview {
    width: 72px;
    height: 58px;
  }
  .attachment-card > a {
    grid-column: 1/3;
    text-align: center;
  }
  .reader-actions .secondary {
    flex: 1;
  }
  .message-body {
    padding: 18px 0;
  }
  .schedule-modal {
    border-radius: 20px 20px 0 0;
  }
}

.mailbox-filter {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.mailbox-filter select,
.compose-from select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.mailbox-filter select {
  width: min(250px, 26vw);
  height: 34px;
  padding: 0 30px 0 10px;
}
.compose-from {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.compose-from select {
  flex: 1;
  height: 34px;
  padding: 0 10px;
}
.mailbox-badge {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 2px;
  padding: 2px 7px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--blue) 20%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 7%, transparent);
  color: var(--blue);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-limit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--blue) 5%, var(--surface));
  font-size: 13px;
}
.account-limit span {
  color: var(--muted);
  font-size: 12px;
}
.signature-content {
  color: var(--muted);
}
.dark .mailbox-filter select,
.dark .compose-from select {
  background: #272a34;
  color: #f8f9fc;
}
@media (max-width: 650px) {
  .mailbox-filter span,
  .pagination {
    display: none;
  }
  .mailbox-filter {
    flex: 1;
    justify-content: flex-end;
    margin-left: 6px;
  }
  .mailbox-filter select {
    width: min(48vw, 190px);
    height: 38px;
    font-size: 13px;
  }
  .message-sender .mailbox-badge {
    display: inline-block;
    max-width: 46%;
    margin: 0 0 0 5px;
    vertical-align: middle;
  }
  .account-limit {
    align-items: flex-start;
    flex-direction: column;
  }
  .compose-from {
    flex: none;
  }
  .compose-from select {
    font-size: 16px;
  }
}
@media (max-width: 480px) {
  html {
    font-size: clamp(13px, 3.7vw, 16px);
  }
  .topbar {
    gap: 5px;
    padding-inline: max(8px, env(safe-area-inset-left))
      max(8px, env(safe-area-inset-right));
  }
  .top-actions {
    min-width: 0;
  }
  .main {
    max-width: 100vw;
  }
  .list-head {
    padding-inline: 8px;
  }
  .category-tabs button {
    min-width: 104px;
  }
  .message-row {
    width: 100%;
    max-width: 100vw;
    grid-template-columns: 24px minmax(0, 1fr) 48px;
    padding-inline: 8px;
  }
  .message-sender,
  .subject-line {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .pagination {
    font-size: 10px;
  }
  .bulk-menu {
    left: 6px;
    right: 6px;
    max-height: min(72dvh, 620px);
    padding: 10px;
  }
  .settings-menu {
    max-width: calc(100vw - 28px);
  }
  .settings-panel h1 {
    font-size: clamp(24px, 8vw, 30px);
  }
  .grid.two,
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .setting-card {
    width: 100%;
    min-width: 0;
  }
  .composer {
    width: 100vw;
    max-width: 100vw;
  }
  .address-row input {
    min-width: 0;
  }
  .formatbar {
    overflow-x: auto;
    scrollbar-width: none;
  }
}

/* Visible animated canvas and final responsive refinements */
.ambient {
  z-index: 0;
  pointer-events: none;
  background-color: var(--bg);
  background-image: radial-gradient(
    circle at 48% -5%,
    rgba(255, 255, 255, 0.98),
    transparent 48%
  );
}
.ambient i {
  opacity: 0.2;
  mix-blend-mode: multiply;
  will-change: transform;
}
.app,
.auth-screen {
  position: relative;
  z-index: 1;
}
.topbar,
.sidebar,
.mail-view,
.content-view {
  background-color: rgba(255, 255, 255, 0.72);
}
.dark .ambient {
  background-color: #20232b;
  background-image: radial-gradient(
    circle at 48% -5%,
    rgba(77, 81, 106, 0.5),
    transparent 52%
  );
}
.dark .ambient i {
  opacity: 0.2;
  mix-blend-mode: screen;
}
.dark .topbar,
.dark .sidebar,
.dark .mail-view,
.dark .content-view {
  background-color: rgba(39, 42, 52, 0.82);
}
.message-row.selected {
  box-shadow: inset 3px 0 0 var(--blue);
}
.message-row.selected:hover {
  background: rgba(0, 0, 254, 0.1);
}
@media (max-width: 650px) {
  :root {
    --radius: 0;
  }
  .topbar {
    height: 60px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand-mark.small {
    width: 36px;
    height: 36px;
  }
  .top-actions .icon-btn {
    width: 34px;
    height: 34px;
  }
  .avatar {
    width: 34px;
    height: 34px;
  }
  .main {
    margin-top: 60px;
    min-height: calc(100dvh - 60px);
  }
  .mail-view,
  .content-view {
    min-height: calc(100dvh - 60px);
    background-color: rgba(255, 255, 255, 0.78);
  }
  .dark .mail-view,
  .dark .content-view {
    background-color: rgba(39, 42, 52, 0.86);
  }
  .list-head {
    position: sticky;
    top: 0;
    z-index: 8;
    background: var(--panel);
    backdrop-filter: blur(22px);
  }
  .category-tabs {
    position: sticky;
    top: 52px;
    z-index: 7;
    height: 52px;
    background: var(--panel);
    backdrop-filter: blur(22px);
    scrollbar-width: none;
  }
  .category-tabs::-webkit-scrollbar {
    display: none;
  }
  .category-tabs button {
    min-width: 112px;
    font-size: 13px;
    padding: 0 10px;
  }
  .message-row {
    height: 72px;
    padding: 7px 10px;
    grid-template-columns: 26px minmax(0, 1fr) 58px;
    grid-template-rows: 27px 29px;
    border-bottom-color: rgba(17, 17, 17, 0.08);
  }
  .message-row > input {
    width: 18px;
    height: 18px;
    margin: 0;
    align-self: center;
  }
  .message-sender {
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .subject-line {
    font-size: 13px;
    line-height: 1.3;
  }
  .subject-line span {
    color: var(--muted);
  }
  .message-time {
    font-size: 10px;
    font-weight: 650;
  }
  .bulk-tools .icon-btn {
    width: 36px;
    height: 36px;
  }
  .pagination {
    max-width: 42%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .bulk-menu {
    box-shadow: 0 -18px 55px rgba(20, 24, 45, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.75);
  }
  .content-view {
    padding: 18px 14px 32px;
  }
  .reader > .setting-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    padding: 14px;
  }
  .reader > .setting-card > .secondary {
    grid-column: 1/3;
    width: 100%;
  }
  .settings-layout {
    gap: 12px;
  }
  .settings-menu {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 4px;
    background: var(--panel);
    border-radius: 12px;
    scrollbar-width: none;
  }
  .settings-menu::-webkit-scrollbar {
    display: none;
  }
  .settings-menu button {
    min-height: 42px;
    padding: 0 14px;
  }
  .settings-panel {
    padding: 2px;
  }
  .setting-card {
    padding: 16px;
    border-radius: 14px;
  }
  .composer {
    top: 60px;
    height: calc(100dvh - 60px);
    border-radius: 18px 18px 0 0;
  }
  .composer-head {
    height: 48px;
  }
  .compose-foot {
    gap: 8px;
  }
  .toast-stack {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .toast {
    text-align: center;
  }
}
.dark .brand-mark,
.dark .primary,
.dark .compose-main {
  background: #fff;
  color: #111;
}
.dark .mail-view,
.dark .content-view,
.dark .message-row.unread,
.dark .message-row:hover,
.dark .setting-card {
  background: rgba(25, 26, 32, 0.78);
}
.dark .search {
  background: rgba(255, 255, 255, 0.06);
}
.dark .composer-head {
  background: #050505;
}
.dark .composer form {
  background: rgba(25, 26, 32, 0.96);
}
.dark .auth-card input,
.dark .account-form input,
.dark .account-form select,
.dark .account-form textarea {
  background: rgba(255, 255, 255, 0.06);
}
@media (max-width: 900px) {
  :root {
    --sidebar: 84px;
  }
  .sidebar .compose-main {
    padding: 0;
    justify-content: center;
  }
  .sidebar .compose-main {
    font-size: 0;
  }
  .sidebar nav span:nth-child(2),
  .sidebar nav small,
  .sidebar-bottom span,
  .storage,
  .nav-section {
    display: none;
  }
  .folder-btn,
  .sidebar-bottom button {
    justify-content: center;
    font-size: 18px;
  }
  .logo {
    width: auto;
  }
  .logo > span:last-child {
    display: none;
  }
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 650px) {
  .topbar {
    height: 64px;
    padding: 0 10px;
    gap: 8px;
  }
  .menu-btn {
    display: grid;
  }
  .top-actions {
    gap: 0;
  }
  .top-actions .icon-btn:first-child {
    display: none;
  }
  .search {
    position: absolute;
    top: 72px;
    left: 12px;
    right: 12px;
    max-width: none;
    box-shadow: var(--shadow);
    display: none;
  }
  .search.open {
    display: flex;
  }
  .sidebar {
    top: 64px;
    width: 270px;
    transform: translateX(-105%);
    transition: 0.25s;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: none;
  }
  .sidebar .compose-main {
    font-size: 15px;
    padding: 0 22px;
    justify-content: flex-start;
  }
  .sidebar nav span:nth-child(2),
  .sidebar nav small,
  .sidebar-bottom span,
  .storage,
  .nav-section {
    display: initial;
  }
  .folder-btn,
  .sidebar-bottom button {
    justify-content: flex-start;
    font-size: 14px;
  }
  .main {
    margin: 64px 0 0;
    padding: 0;
  }
  .mail-view,
  .content-view {
    min-height: calc(100vh - 64px);
    border-radius: 0;
    border: 0;
  }
  .category-tabs {
    overflow: auto;
  }
  .category-tabs button {
    min-width: 120px;
  }
  .message-row {
    height: 76px;
    grid-template-columns: 26px 1fr 60px;
    grid-template-rows: 28px 28px;
  }
  .message-row > input {
    grid-row: 1/3;
  }
  .message-row > .star {
    display: none;
  }
  .message-sender {
    grid-column: 2;
  }
  .subject-line {
    grid-column: 2/4;
  }
  .message-time {
    grid-column: 3;
    grid-row: 1;
  }
  .content-view {
    padding: 20px 15px;
  }
  .settings-layout {
    display: block;
  }
  .settings-menu {
    display: flex;
    overflow: auto;
    margin-bottom: 20px;
  }
  .settings-menu button {
    white-space: nowrap;
  }
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
  .composer {
    right: 0;
    width: 100%;
    height: calc(100vh - 64px);
    border-radius: 16px 16px 0 0;
  }
  .grid.two,
  .server-grid {
    grid-template-columns: 1fr;
  }
  .modal {
    padding: 21px;
  }
  .auth-card {
    padding: 30px 24px;
  }
  .auth-brand {
    left: 20px;
  }
  .scrim {
    display: block;
    position: fixed;
    inset: 64px 0 0;
    z-index: 14;
    background: rgba(0, 0, 0, 0.35);
  }
}
@media (max-width: 420px) {
  .top-actions #themeBtn {
    display: none;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .auth-card h1 {
    font-size: 38px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}

/* Navigation and readability refinements */
.menu-btn {
  display: grid;
}
.sidebar,
.main,
.logo {
  transition:
    width 0.24s ease,
    margin 0.24s ease,
    transform 0.24s ease;
}
.sidebar nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 2px;
}
.sidebar-bottom {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  flex: none;
}
.storage {
  flex: none;
}
.empty-state .secondary {
  color: var(--ink);
  background: #fff;
  border-color: rgba(17, 17, 17, 0.15);
  box-shadow: 0 6px 18px rgba(20, 24, 45, 0.08);
}
.empty-state .secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.bulk-tools {
  position: relative;
}
.bulk-menu {
  position: absolute;
  z-index: 40;
  top: 45px;
  left: 55px;
  width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.96);
}
.bulk-menu[hidden] {
  display: none;
}
.bulk-menu b {
  display: block;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}
.bulk-menu button,
.bulk-menu label {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 10px;
  text-align: left;
  color: var(--ink);
  font: inherit;
}
.bulk-menu button:hover {
  background: rgba(0, 0, 254, 0.07);
}
.bulk-menu button.danger {
  color: var(--red);
}
.bulk-menu label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.bulk-menu select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.message-row.selected {
  background: rgba(0, 0, 254, 0.07);
}
.profile-form {
  display: grid;
  gap: 18px;
}
.profile-form label {
  display: grid;
  gap: 7px;
  font-weight: 600;
}
.profile-form label small {
  font-weight: 400;
  color: var(--muted);
}
.profile-form input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
  font: inherit;
}
.profile-form input:focus {
  outline: 2px solid rgba(0, 0, 254, 0.18);
  border-color: var(--blue);
}
.schedule-modal form {
  display: grid;
  gap: 16px;
}
.schedule-modal label {
  display: grid;
  gap: 8px;
  font-weight: 650;
}
.schedule-modal input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 0 12px;
  color: var(--ink);
}
.forgot-link {
  display: block;
  margin: 12px auto 0;
}
.auth-modal {
  width: min(480px, calc(100vw - 24px));
}
.auth-modal form {
  display: grid;
  gap: 16px;
}
.auth-modal label {
  display: grid;
  gap: 8px;
  font-weight: 650;
}
.auth-modal input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}
.form-status {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}
.content-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.content-heading h1 {
  margin-bottom: 4px;
}
.contact-list {
  display: grid;
  gap: 12px;
}
.contact-card {
  cursor: context-menu;
  user-select: none;
  -webkit-touch-callout: none;
}
.contact-card .contact-more {
  margin-left: auto;
}
.contact-menu {
  position: fixed;
  z-index: 90;
  width: 220px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}
.contact-menu[hidden] {
  display: none;
}
.contact-menu b {
  display: block;
  padding: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-menu button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  padding: 10px;
}
.contact-menu button:hover {
  background: rgba(0, 0, 254, 0.07);
}
.contact-menu button.danger {
  color: var(--red);
}
.dark .contact-menu {
  background: rgba(39, 42, 52, 0.98);
  color: #fff;
}
.cache-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 30px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.cache-actions > div {
  flex: 1;
  display: grid;
  gap: 4px;
}
@media (max-width: 650px) {
  .content-heading {
    align-items: stretch;
    flex-direction: column;
  }
  .content-heading > .secondary {
    width: 100%;
  }
  .contact-menu {
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    border-radius: 18px;
  }
  .contact-menu button {
    min-height: 48px;
  }
  .cache-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .cache-actions button {
    width: 100%;
  }
}
.password-control {
  position: relative;
  display: block;
  width: 100%;
}
.password-control > input {
  width: 100%;
  padding-right: 66px !important;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 52px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--blue);
  font: 600 12px/1 inherit;
  cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible {
  background: rgba(0, 0, 254, 0.08);
  outline: none;
}
.password-toggle:focus-visible {
  box-shadow: 0 0 0 2px rgba(0, 0, 254, 0.2);
}
@media (min-width: 651px) and (max-width: 1024px) {
  :root {
    --sidebar: 210px;
  }
  .topbar {
    padding: 0 16px;
  }
  .logo {
    width: 170px;
  }
  .search {
    max-width: 520px;
  }
  .main {
    padding: 10px;
  }
  .category-tabs button {
    min-width: 125px;
    flex: 1;
  }
  .message-row {
    grid-template-columns:
      28px 28px minmax(120px, 165px) minmax(170px, 1fr)
      65px;
  }
  .notification-panel {
    width: min(390px, 45vw);
  }
  .settings-layout {
    grid-template-columns: 190px 1fr;
  }
  .server-grid {
    grid-template-columns: 1fr 90px 110px;
  }
}
@media (max-width: 650px) {
  body {
    overflow-x: hidden;
  }
  .topbar .logo {
    width: auto;
  }
  .logo > span:last-child {
    display: none;
  }
  .search {
    top: 64px;
    z-index: 30;
  }
  .main {
    width: 100%;
    overflow-x: hidden;
  }
  .list-head {
    height: 52px;
    padding: 0 10px;
  }
  .pagination button {
    display: none;
  }
  .category-tabs {
    scroll-snap-type: x mandatory;
  }
  .category-tabs button {
    scroll-snap-align: start;
  }
  .message-list {
    overflow-x: hidden;
  }
  .message-row {
    padding: 6px 10px;
    gap: 6px;
    grid-template-columns: 24px minmax(0, 1fr) 54px;
  }
  .message-sender,
  .subject-line {
    min-width: 0;
  }
  .subject-line span {
    display: inline;
  }
  .bulk-menu {
    position: fixed;
    z-index: 120;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    top: auto;
    width: auto;
    max-height: calc(100dvh - 88px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 22px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 24px 80px rgba(17, 17, 17, 0.3);
  }
  .bulk-menu button {
    min-height: 50px;
    font-size: 15px;
  }
  .bulk-menu label {
    padding-block: 12px;
  }
  .bulk-menu select {
    min-height: 46px;
    font-size: 16px;
  }
  .account-menu {
    position: fixed;
    z-index: 140;
    top: calc(58px + env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    border-radius: 20px;
  }
  .account-menu button {
    min-height: 50px;
    font-size: 15px;
  }
  .sidebar {
    scrollbar-gutter: stable;
  }
  .sidebar nav {
    overscroll-behavior: contain;
  }
  .notification-panel {
    position: fixed;
    inset: 64px 0 0;
    width: auto;
    max-width: none;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .content-view {
    overflow-wrap: anywhere;
  }
  .reader h1 {
    font-size: 24px;
  }
  .setting-card {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .setting-card > div:nth-child(2) {
    min-width: 0;
    flex: 1;
  }
  .settings-panel h1 {
    font-size: 27px;
  }
  .modal-wrap {
    padding: 8px;
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-height: 92dvh;
    overflow: auto;
    border-radius: 20px 20px 0 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .composer {
    height: calc(100dvh - 64px);
    max-height: none;
  }
  .composer form {
    height: calc(100% - 46px);
    display: flex;
    flex-direction: column;
  }
  .composer .editor {
    flex: 1;
    min-height: 120px;
    overflow: auto;
  }
  .compose-foot {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .auth-card {
    width: calc(100% - 20px);
    max-height: 90dvh;
    overflow: auto;
  }
  .empty-state {
    padding: 10vh 18px;
  }
}
body.sidebar-collapsed {
  --sidebar: 84px;
}
body.sidebar-collapsed .sidebar .compose-main {
  padding: 0;
  justify-content: center;
  font-size: 0;
}
body.sidebar-collapsed .sidebar nav span:nth-child(2),
body.sidebar-collapsed .sidebar nav small,
body.sidebar-collapsed .sidebar-bottom span,
body.sidebar-collapsed .storage,
body.sidebar-collapsed .nav-section {
  display: none;
}
body.sidebar-collapsed .folder-btn,
body.sidebar-collapsed .sidebar-bottom button {
  justify-content: center;
  font-size: 18px;
}
body.sidebar-collapsed .logo {
  width: 208px;
}
body.dark {
  --bg: #20232b;
  --ink: #f8f9fc;
  --panel: rgba(43, 46, 57, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --muted: #c5c8d2;
}
.dark .sidebar,
.dark .topbar {
  background: rgba(39, 42, 52, 0.94);
}
.dark .mail-view,
.dark .content-view,
.dark .message-row.unread,
.dark .message-row:hover,
.dark .setting-card {
  background: rgba(48, 51, 63, 0.92);
}
.dark .folder-btn,
.dark .sidebar-bottom button {
  color: #d9dbe3;
}
.dark .folder-btn.active {
  color: #ff6767;
  background: rgba(255, 80, 80, 0.14);
}
.dark .empty-state .secondary {
  background: #fff;
  color: #17181d;
}
.dark .category-tabs button {
  color: #c9ccd5;
}
.dark .category-tabs button.active {
  color: #8585ff;
}
@media (max-width: 650px) {
  body.sidebar-collapsed {
    --sidebar: 270px;
  }
  body.sidebar-collapsed .sidebar .compose-main {
    font-size: 15px;
    padding: 0 22px;
    justify-content: flex-start;
  }
  body.sidebar-collapsed .sidebar nav span:nth-child(2),
  body.sidebar-collapsed .sidebar nav small,
  body.sidebar-collapsed .sidebar-bottom span,
  body.sidebar-collapsed .storage,
  body.sidebar-collapsed .nav-section {
    display: initial;
  }
  body.sidebar-collapsed .folder-btn,
  body.sidebar-collapsed .sidebar-bottom button {
    justify-content: flex-start;
    font-size: 14px;
  }
}

.settings-stack {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}
.settings-stack .setting-card {
  margin: 0;
  min-height: 76px;
}
.setting-select {
  min-width: 180px;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  outline: none;
}
.toggle {
  position: relative;
  display: inline-block !important;
  width: 46px;
  height: 26px;
  margin: 0 !important;
  flex: none;
}
.toggle input {
  opacity: 0;
  width: 0 !important;
  height: 0;
}
.toggle span {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #c8cad2;
  transition: 0.2s;
}
.toggle span:before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: 0.2s;
}
.toggle input:checked + span {
  background: var(--blue);
}
.toggle input:checked + span:before {
  transform: translateX(20px);
}
.status-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 7px 10px;
  border-radius: 20px;
  background: #eef0f4;
}
.status-pill.success {
  color: #087b47;
  background: #e3f7ed;
}
.status-pill.warning {
  color: #9a5a00;
  background: #fff0d5;
}
.shortcut-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
}
kbd {
  display: inline-grid;
  place-items: center;
  width: max-content;
  min-width: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 7px;
  background: var(--panel);
  font: 600 12px inherit;
}
.about-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
  border-radius: 18px;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 254, 0.08),
    rgba(255, 0, 0, 0.06)
  );
  margin-bottom: 12px;
}
.about-card img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 17px;
}
.about-card h2,
.about-card p {
  margin: 2px 0;
}
.about-card p {
  color: var(--muted);
}
body[data-font-size="small"] {
  font-size: 14px;
}
body[data-font-size="large"] {
  font-size: 18px;
}
body[data-density="compact"] .message-row {
  height: 48px;
}
body[data-density="relaxed"] .message-row {
  height: 72px;
}
.dark .shortcut-grid {
  background: rgba(255, 255, 255, 0.04);
}
.dark .setting-select {
  background: #30333e;
}
.dark .status-pill.success {
  background: #173d31;
  color: #79e1b4;
}
.dark .status-pill.warning {
  background: #4b381b;
  color: #ffd17c;
}
.panel-actions {
  display: flex;
  gap: 14px;
}
.notification-item {
  width: 100%;
  border-width: 0 0 1px;
  background: transparent;
  text-align: left;
  color: inherit;
}
.notification-item span {
  min-width: 0;
}
@media (max-width: 650px) {
  .settings-stack .setting-card {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .setting-select {
    width: 100%;
  }
  .shortcut-grid {
    grid-template-columns: 72px 1fr;
  }
}

/* Mobile message actions are portalled to body to avoid clipped positioning. */
.mobile-action-head,
.action-sheet-scrim {
  display: none;
}
@media (max-width: 650px) {
  body > .bulk-menu {
    position: fixed;
    z-index: 201;
    inset: auto max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: min(82dvh, 680px);
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(17, 17, 17, 0.32);
  }
  body > .bulk-menu[hidden] {
    display: none;
  }
  .action-sheet-scrim:not([hidden]) {
    display: block;
    position: fixed;
    z-index: 200;
    inset: 0;
    background: rgba(17, 17, 17, 0.42);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }
  body.action-sheet-open {
    overflow: hidden;
  }
  .mobile-action-head {
    position: sticky;
    z-index: 2;
    top: -12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -12px -12px 6px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(18px);
  }
  .mobile-action-head > div {
    display: grid;
    gap: 2px;
  }
  .mobile-action-head small {
    color: var(--blue);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
  }
  .mobile-action-head b {
    padding: 0;
    color: var(--ink);
    font-size: 15px;
  }
  body > .bulk-menu button {
    min-height: 50px;
    font-size: 15px;
  }
  body > .bulk-menu select {
    min-height: 46px;
    font-size: 16px;
  }
}

/* Message identity and user-label layout */
.message-row {
  min-height: 68px;
  height: auto;
  padding-block: 7px;
}
.message-sender {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}
.sender-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-sender .mailbox-badge {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 1px 6px;
  overflow: hidden;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subject-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.subject-line .subject-title {
  flex: none;
  max-width: 45%;
  overflow: hidden;
  color: var(--ink);
  font-weight: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subject-line .message-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-labels {
  display: inline-flex !important;
  flex: none;
  gap: 4px;
}
.subject-line .message-label {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}
.subject-line .message-label.work {
  background: rgba(0, 0, 254, 0.1);
  color: var(--blue);
}
.subject-line .message-label.personal {
  background: rgba(255, 0, 0, 0.1);
  color: var(--red);
}
@media (max-width: 650px) {
  .message-row {
    min-height: 78px;
    grid-template-rows: 32px 30px;
  }
  .message-sender {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .sender-name {
    flex: 1;
  }
  .message-sender .mailbox-badge {
    flex: 0 1 43%;
    max-width: 43%;
  }
  .subject-line .subject-title {
    max-width: 42%;
  }
  .subject-line .message-preview {
    display: block;
  }
  .subject-line .message-label {
    padding-inline: 5px;
    font-size: 8px;
  }
}

/* Constrain third-party email HTML without flattening its table design. */
.reader,
.message-body {
  min-width: 0;
  max-width: 100%;
}
.message-body {
  width: 100%;
  overflow-x: hidden;
}
.message-body table {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-inline: auto !important;
  table-layout: auto;
}
.message-body tbody,
.message-body thead,
.message-body tfoot,
.message-body tr,
.message-body td,
.message-body th {
  max-width: 100% !important;
  min-width: 0 !important;
}
.message-body td,
.message-body th {
  overflow-wrap: anywhere;
  word-break: normal;
}
.message-body img,
.message-body video,
.message-body iframe {
  max-width: 100% !important;
  height: auto !important;
}
.message-body div,
.message-body section {
  max-width: 100% !important;
}
.mail-empty {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: min(62vh, 560px);
  padding: 50px 22px;
}
.mail-empty > p {
  max-width: 540px;
  margin: 8px auto 20px;
  line-height: 1.65;
}
.empty-visual {
  position: relative;
  width: 94px;
  height: 94px;
  margin-bottom: 20px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 0, 254, 0.1);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(255, 0, 0, 0.1), rgba(0, 0, 254, 0.14));
  box-shadow: 0 18px 55px rgba(0, 0, 254, 0.1);
}
.empty-visual span {
  position: relative;
  z-index: 2;
  color: var(--blue);
  font-size: 34px;
}
.empty-visual i {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.75;
  animation: emptyOrbit 5s linear infinite;
}
.empty-visual i:nth-of-type(2) {
  background: var(--blue);
  animation-delay: -2.5s;
}
@keyframes emptyOrbit {
  from {
    transform: rotate(0deg) translateX(58px) rotate(0deg) scale(0.75);
  }
  to {
    transform: rotate(360deg) translateX(58px) rotate(-360deg) scale(0.75);
  }
}
.empty-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
@media (max-width: 650px) {
  .message-body {
    width: 100%;
    padding: 14px 0;
    font-size: 14px;
  }
  .message-body table {
    border-spacing: 0 !important;
  }
  .message-body td,
  .message-body th {
    padding-right: min(12px, 3vw) !important;
    padding-left: min(12px, 3vw) !important;
  }
  .message-body img {
    object-fit: contain;
  }
  .mail-empty {
    min-height: calc(100dvh - 220px);
    padding: 42px 18px;
  }
  .empty-visual {
    width: 82px;
    height: 82px;
    border-radius: 26px;
  }
  .empty-actions {
    width: 100%;
  }
  .empty-actions button {
    flex: 1 1 150px;
    min-height: 46px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .empty-visual i {
    animation: none;
  }
}
