/* Symail Apple-inspired design system — final presentation layer */
:root {
  color-scheme: light dark;
  --system-bg: #f5f5f7;
  --system-bg-elevated: #ffffff;
  --system-bg-secondary: #f0f1f2;
  --system-bg-tertiary: #e7e9ea;
  --system-sidebar: rgba(246, 248, 247, 0.86);
  --system-toolbar: rgba(255, 255, 255, 0.78);
  --system-label: #1d1d1f;
  --system-label-secondary: #5e6461;
  --system-label-tertiary: #7c827f;
  --system-separator: rgba(35, 45, 39, 0.13);
  --system-separator-strong: rgba(35, 45, 39, 0.22);
  --system-green: #096b4b;
  --system-green-strong: #04553a;
  --system-green-soft: #e3f3ec;
  --system-pink: #d92f70;
  --system-pink-soft: #fde8f0;
  --system-red: #c9342c;
  --system-orange: #b56316;
  --focus-ring: rgba(10, 107, 75, 0.28);
  --surface-shadow: 0 1px 2px rgba(18, 25, 21, 0.06), 0 12px 34px rgba(18, 25, 21, 0.07);
  --floating-shadow: 0 18px 60px rgba(18, 25, 21, 0.16);
  --radius-control: 10px;
  --radius-card: 18px;
  --radius-window: 22px;

  /* Backwards-compatible semantic mapping */
  --bg: var(--system-bg);
  --surface: var(--system-bg-elevated);
  --surface-strong: var(--system-bg-secondary);
  --ink: var(--system-label);
  --muted: var(--system-label-secondary);
  --line: var(--system-separator);
  --accent: var(--system-green);
  --accent-strong: var(--system-green-strong);
  --accent-soft: var(--system-green-soft);
  --rose: var(--system-pink);
  --rose-strong: #a91d55;
  --rose-soft: var(--system-pink-soft);
  --danger: var(--system-red);
  --warning: var(--system-orange);
  --shadow: var(--surface-shadow);
}

@media (prefers-color-scheme: dark) {
  :root {
    --system-bg: #111412;
    --system-bg-elevated: #1b1f1c;
    --system-bg-secondary: #232824;
    --system-bg-tertiary: #2d332f;
    --system-sidebar: rgba(24, 29, 26, 0.9);
    --system-toolbar: rgba(27, 31, 28, 0.82);
    --system-label: #f3f5f3;
    --system-label-secondary: #b4bbb6;
    --system-label-tertiary: #858d88;
    --system-separator: rgba(225, 235, 228, 0.13);
    --system-separator-strong: rgba(225, 235, 228, 0.22);
    --system-green: #53c99b;
    --system-green-strong: #78d8b3;
    --system-green-soft: rgba(43, 152, 109, 0.2);
    --system-pink: #ff649c;
    --system-pink-soft: rgba(217, 47, 112, 0.2);
    --system-red: #ff6b63;
    --system-orange: #f0a450;
    --focus-ring: rgba(83, 201, 155, 0.34);
    --surface-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 14px 38px rgba(0, 0, 0, 0.24);
    --floating-shadow: 0 20px 70px rgba(0, 0, 0, 0.46);
  }
}

html {
  min-width: 320px;
  background: var(--system-bg);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--system-bg);
  color: var(--system-label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  color: inherit;
  font-family: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

::selection {
  background: rgba(10, 107, 75, 0.2);
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  border-radius: 10px;
  background: var(--system-label);
  color: var(--system-bg-elevated);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.button-icon,
.nav-icon,
.search-icon {
  width: 19px;
  height: 19px;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon {
  width: 18px;
  height: 18px;
}

/* Authentication */
.auth-view {
  position: relative;
  min-height: 100dvh;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 450px);
  gap: clamp(48px, 8vw, 112px);
  align-items: center;
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 84px);
  background: transparent;
}

.auth-view::before,
.auth-view::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.17;
  pointer-events: none;
}

.auth-view::before {
  top: -180px;
  right: -80px;
  background: var(--system-pink);
}

.auth-view::after {
  bottom: -210px;
  left: -110px;
  background: var(--system-green);
}

.brand-panel {
  max-width: 620px;
}

.brand-mark,
.brand-mark.compact {
  display: block;
  object-fit: cover;
  border: 0;
  background: transparent;
  box-shadow: 0 10px 28px rgba(6, 65, 46, 0.18);
}

.brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 0 30px;
  border-radius: 18px;
}

.brand-mark::after,
.brand-mark.compact::after {
  display: none;
}

.brand-parent {
  margin-bottom: 14px;
  color: var(--system-pink);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.auth-view h1 {
  margin: 0 0 16px;
  font-size: clamp(54px, 7vw, 88px);
  font-weight: 720;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.brand-panel .brand-lead {
  max-width: 540px;
  margin: 0 0 28px;
  color: var(--system-label-secondary);
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 450;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.auth-benefits {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  color: var(--system-label-secondary);
  font-size: 14px;
  line-height: 1.45;
  list-style: none;
}

.auth-benefits li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-benefits li > span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--system-green-soft);
  color: var(--system-green-strong);
  font-size: 12px;
  font-weight: 800;
}

.auth-card {
  width: 100%;
  margin: 0;
  padding: 30px;
  border: 1px solid var(--system-separator);
  border-radius: var(--radius-window);
  background: var(--system-toolbar);
  box-shadow: var(--floating-shadow);
  backdrop-filter: blur(28px) saturate(1.2);
  -webkit-backdrop-filter: blur(28px) saturate(1.2);
}

.auth-card-heading {
  margin-bottom: 22px;
}

.auth-card-heading h2 {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.auth-card-heading p {
  margin: 0;
  color: var(--system-label-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.mode-switch {
  gap: 3px;
  margin-bottom: 22px;
  padding: 3px;
  border: 1px solid var(--system-separator);
  border-radius: 12px;
  background: var(--system-bg-secondary);
}

.mode-button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--system-label-secondary);
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

.mode-button.active {
  background: var(--system-bg-elevated);
  color: var(--system-label);
  box-shadow: 0 1px 4px rgba(18, 25, 21, 0.12);
}

.mode-button.active::after {
  display: none;
}

.field {
  margin-bottom: 15px;
}

.field > span {
  margin-bottom: 7px;
  color: var(--system-label-secondary);
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.settings-form input,
.settings-form select,
.settings-form textarea {
  min-height: 44px;
  border: 1px solid var(--system-separator-strong);
  border-radius: var(--radius-control);
  background: var(--system-bg-elevated);
  color: var(--system-label);
  padding: 0 12px;
  box-shadow: 0 1px 1px rgba(18, 25, 21, 0.02);
}

.field textarea,
.settings-form textarea {
  padding-block: 11px;
  line-height: 1.5;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--system-label-tertiary);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--system-green);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

.primary-action,
.primary-action.small,
.secondary-action,
.ghost-action,
.danger-action {
  min-height: 42px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 680;
}

.primary-action,
.primary-action.small {
  border: 1px solid transparent;
  background: var(--system-green-strong);
  color: #fff;
  box-shadow: 0 1px 2px rgba(6, 65, 46, 0.18);
}

.primary-action:hover,
.primary-action.small:hover {
  filter: brightness(1.06);
}

@media (prefers-color-scheme: dark) {
  .primary-action,
  .primary-action.small {
    color: #08251b;
  }
}

.secondary-action {
  border: 1px solid var(--system-separator-strong);
  background: var(--system-bg-elevated);
  color: var(--system-label);
  box-shadow: none;
}

.auth-card > .primary-action {
  width: 100%;
  min-height: 46px;
  margin-top: 2px;
}

.auth-help-action {
  display: block;
  margin: 18px auto 0;
  border: 0;
  background: transparent;
  color: var(--system-green-strong);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.auth-help-action:hover {
  text-decoration: underline;
}

.form-message {
  min-height: 0;
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

/* App shell */
.mail-view,
html.session-restoring #mailView.hidden {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  background: var(--system-bg);
  transition: grid-template-columns 180ms ease;
}

.mail-view.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: auto;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 12px;
  border: 0;
  border-right: 1px solid var(--system-separator);
  background: var(--system-sidebar);
  color: var(--system-label);
  box-shadow: none;
  backdrop-filter: blur(24px) saturate(1.15);
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
  transition: transform 180ms ease, width 180ms ease;
}

.sidebar-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 2px 8px;
  padding: 4px;
  border-bottom: 0;
}

.brand-mark.compact {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 11px;
  box-shadow: 0 5px 14px rgba(6, 65, 46, 0.16);
}

.sidebar-head > div:last-child {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.sidebar-head strong {
  color: var(--system-label);
  font-size: 15px;
  font-weight: 720;
  letter-spacing: -0.015em;
}

.sidebar-head small,
.sidebar-head span {
  overflow: hidden;
  color: var(--system-label-secondary);
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-list {
  display: grid;
  gap: 2px;
  margin: 0;
}

.folder-item {
  position: relative;
  min-height: 42px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--system-label-secondary);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 560;
  text-align: left;
  transition: background-color 120ms ease, color 120ms ease;
}

.folder-item::before {
  display: none !important;
}

.folder-item:hover {
  background: var(--system-bg-secondary);
  color: var(--system-label);
}

.folder-item.active {
  background: var(--system-green-soft);
  color: var(--system-green-strong);
  box-shadow: none;
}

.folder-item.active::after {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--system-green);
}

.folder-item > strong {
  min-width: 22px;
  border-radius: 999px;
  background: transparent;
  color: currentColor;
  font-size: 11px;
  font-weight: 680;
  line-height: 20px;
  text-align: right;
}

.custom-folders {
  margin: 8px 0;
  padding: 0 2px 8px;
  border-bottom: 1px solid var(--system-separator);
}

.sidebar-section-head {
  min-height: 32px;
  color: var(--system-label-tertiary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.icon-button,
.folder-delete-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--system-label-secondary);
}

.icon-button:hover,
.folder-delete-button:hover {
  background: var(--system-bg-tertiary);
}

.folder-create-form input {
  min-height: 38px;
  border: 1px solid var(--system-separator);
  border-radius: 9px;
  background: var(--system-bg-elevated);
  color: var(--system-label);
  padding-inline: 10px;
}

#logoutButton {
  width: 100%;
  min-height: 40px;
  margin-top: auto;
  border: 0;
  background: transparent;
  color: var(--system-label-secondary);
  text-align: left;
}

#logoutButton:hover {
  background: var(--system-bg-secondary);
  color: var(--system-label);
}

.mail-view.sidebar-collapsed .sidebar {
  width: auto;
  padding-inline: 10px;
}

.mail-view.sidebar-collapsed .sidebar-head {
  justify-content: center;
}

.mail-view.sidebar-collapsed .sidebar-head > div:last-child,
.mail-view.sidebar-collapsed .sidebar-section-head > span,
.mail-view.sidebar-collapsed .folder-item > span,
.mail-view.sidebar-collapsed .custom-folder-row .folder-delete-button,
.mail-view.sidebar-collapsed .folder-create-form,
.mail-view.sidebar-collapsed .sidebar-message,
.mail-view.sidebar-collapsed #logoutButton > span {
  display: none;
}

.mail-view.sidebar-collapsed .folder-item {
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0;
}

.mail-view.sidebar-collapsed .folder-item > strong {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--system-green-soft);
  font-size: 9px;
  line-height: 16px;
  text-align: center;
}

.mail-view.sidebar-collapsed #logoutButton {
  width: 42px;
  margin-inline: auto;
  text-align: center;
}

.workspace {
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
  padding: 0;
  background: var(--system-bg);
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0;
  padding: 12px 18px;
  border-bottom: 1px solid transparent;
  background: var(--system-bg);
}

.topbar-title {
  gap: 12px;
}

.sidebar-toggle {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--system-label-secondary);
}

.sidebar-toggle:hover {
  background: var(--system-bg-secondary);
  color: var(--system-label);
}

.topbar h2 {
  margin: 0;
  color: var(--system-label);
  font-size: clamp(22px, 2vw, 30px);
  font-weight: 710;
  letter-spacing: -0.035em;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--system-label-secondary);
  font-size: 11px;
  line-height: 1.35;
}

.topbar-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.topbar-actions .primary-action.small,
.topbar-actions .secondary-action {
  width: auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  white-space: nowrap;
}

.topbar-connect {
  background: transparent;
}

.sync-status {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--system-label-secondary);
  padding-inline: 8px;
  font-size: 11px;
  font-weight: 620;
}

.mail-content {
  width: calc(100% - 24px);
  height: calc(100dvh - 90px);
  min-height: 440px;
  margin: 0 12px 12px;
  overflow: hidden;
  border: 1px solid var(--system-separator);
  border-radius: var(--radius-card);
  background: var(--system-bg-elevated);
  box-shadow: var(--surface-shadow);
}

.inbox-panel,
.reader-panel {
  background: var(--system-bg-elevated);
}

.message-filter-bar {
  min-height: 66px;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 210px) auto;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--system-separator);
  background: var(--system-toolbar);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
}

.search-control {
  position: relative;
  min-width: 0;
}

.search-control > span {
  display: none;
}

.search-icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 13px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--system-label-tertiary);
  pointer-events: none;
}

#messageSearch,
#accountFilter,
.message-filter-bar select {
  height: 42px;
  min-height: 42px;
  border: 1px solid var(--system-separator);
  border-radius: 12px;
  background: var(--system-bg-secondary);
  color: var(--system-label);
  font-size: 13px;
}

#messageSearch {
  padding: 0 38px 0 42px;
}

#messageSearch:focus {
  border-color: var(--system-green);
  background: var(--system-bg-elevated);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

.filter-toggle-button,
.clear-filter-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--system-separator);
  border-radius: 11px;
  background: var(--system-bg-elevated);
  color: var(--system-label-secondary);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 650;
}

.filter-toggle-button.active {
  border-color: transparent;
  background: var(--system-green-soft);
  color: var(--system-green-strong);
}

.advanced-filter-row {
  min-height: 54px;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--system-separator);
  background: var(--system-bg-secondary);
}

.advanced-filter-row > label:not(.compact-toggle) {
  color: var(--system-label-secondary);
}

.advanced-filter-row input[type="date"],
.advanced-filter-row select {
  min-height: 36px;
  border-color: var(--system-separator);
  border-radius: 9px;
  background: var(--system-bg-elevated);
  color: var(--system-label);
}

.bulk-toolbar {
  min-height: 48px;
  gap: 3px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--system-separator);
  background: var(--system-bg-elevated);
}

.select-all-control,
.toolbar-icon-button,
.bulk-toolbar .toolbar-icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
}

.toolbar-icon-button,
.bulk-toolbar .toolbar-icon-button {
  color: var(--system-label-secondary);
}

.toolbar-icon-button:hover,
.toolbar-icon-button:focus-visible {
  background: var(--system-bg-secondary);
  color: var(--system-label);
}

.toolbar-separator {
  background: var(--system-separator);
}

.toolbar-icon-button[data-tooltip]::after {
  background: var(--system-label);
  color: var(--system-bg-elevated);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.16);
}

#selectionCount {
  color: var(--system-label-secondary);
  font-size: 11px;
}

.message-list {
  background: var(--system-bg-elevated);
  scrollbar-color: var(--system-bg-tertiary) transparent;
}

.message-item {
  grid-template-columns: 58px minmax(0, 1fr);
  min-height: 55px;
  padding: 0 15px 0 8px;
  border-bottom: 1px solid var(--system-separator);
  background: var(--system-bg-elevated);
  box-shadow: none;
  transition: background-color 100ms ease, box-shadow 100ms ease;
}

.message-item:hover {
  z-index: 1;
  background: var(--system-bg-secondary);
  box-shadow: inset 0 1px 0 var(--system-separator), inset 0 -1px 0 var(--system-separator);
}

.message-item.unread {
  background: color-mix(in srgb, var(--system-green-soft) 45%, var(--system-bg-elevated));
}

.message-item.selected,
.message-item.selected.unread {
  background: var(--system-green-soft);
  box-shadow: inset 3px 0 0 var(--system-green);
}

.message-item-controls {
  gap: 7px;
}

.message-select {
  width: 16px;
  height: 16px;
  accent-color: var(--system-green);
}

.message-star {
  color: var(--system-label-tertiary);
}

.message-star.active {
  color: #d09518;
}

.message-open {
  grid-template-columns: minmax(150px, 0.23fr) minmax(280px, 1fr) minmax(100px, 0.16fr) 76px;
  gap: 18px;
  min-height: 54px;
}

.message-sender,
.message-subject {
  color: var(--system-label);
  font-size: 13px;
}

.message-preview,
.message-account,
.message-time {
  color: var(--system-label-secondary);
}

.message-account,
.message-time {
  font-size: 11px;
}

.message-item.unread .message-sender,
.message-item.unread .message-subject,
.message-item.unread .message-time {
  font-weight: 720;
}

.load-more-button {
  width: calc(100% - 28px);
  min-height: 40px;
  margin: 12px 14px;
  border: 1px solid var(--system-separator);
  border-radius: 10px;
  background: var(--system-bg-elevated);
  color: var(--system-green-strong);
}

.empty-state {
  margin: 18px;
  border: 1px dashed var(--system-separator-strong);
  border-radius: 14px;
  background: var(--system-bg-secondary);
  color: var(--system-label-secondary);
  text-align: center;
}

/* Reader and composer */
.reader-panel {
  background: var(--system-bg-elevated);
  scrollbar-color: var(--system-bg-tertiary) transparent;
}

.reader-command-bar {
  min-height: 56px;
  gap: 4px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--system-separator);
  background: var(--system-toolbar);
  backdrop-filter: blur(20px) saturate(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
}

.reader-move-control select {
  height: 36px;
  border-color: var(--system-separator);
  border-radius: 9px;
  background: var(--system-bg-elevated);
  color: var(--system-label);
}

.message-detail-head,
.conversation-strip,
.detail-body,
.reader-reply-bar {
  width: min(100%, 1040px);
}

.message-detail-head {
  padding: 34px 46px 24px;
}

.detail-kicker {
  color: var(--system-label-secondary);
  font-size: 11px;
  font-weight: 650;
}

#detailSubject {
  margin: 9px 0 28px;
  color: var(--system-label);
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 710;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.sender-avatar {
  background: var(--system-green-soft);
  color: var(--system-green-strong);
}

#detailSender {
  color: var(--system-label);
  font-size: 14px;
}

#detailMeta,
.detail-sender-row time {
  color: var(--system-label-secondary);
}

.detail-body {
  padding: 32px 46px 48px;
  color: var(--system-label);
  font-size: 15px;
  line-height: 1.65;
}

.html-mail-content {
  background: var(--system-bg-elevated);
}

.conversation-strip {
  border-color: var(--system-separator);
  background: var(--system-bg-secondary);
}

.remote-image-notice,
.quoted-thread-body,
.attachment-chip {
  border-color: var(--system-separator);
  background: var(--system-bg-secondary);
  color: var(--system-label-secondary);
}

.reader-reply-bar {
  gap: 9px;
  padding: 0 46px 56px;
}

.reader-reply-bar .secondary-action {
  min-height: 40px;
  border-radius: 999px;
  padding-inline: 16px;
}

.compose-panel {
  width: min(calc(100% - 40px), 920px);
  min-height: 0;
  margin: 20px auto 36px;
  overflow: hidden;
  border: 1px solid var(--system-separator);
  border-radius: var(--radius-card);
  background: var(--system-bg-elevated);
  box-shadow: var(--surface-shadow);
}

.compose-panel > .panel-heading {
  min-height: 58px;
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--system-separator);
  background: var(--system-toolbar);
}

.compose-panel .panel-heading h3 {
  font-size: 16px;
  font-weight: 680;
}

.compose-form {
  padding: 22px;
}

.compose-form > .field {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0;
  border-bottom: 1px solid var(--system-separator);
}

.compose-form > .field > span {
  margin: 0;
}

.compose-form > .field input,
.compose-form > .field select,
.compose-form > .field textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.compose-form > .field textarea {
  min-height: 250px;
  resize: vertical;
}

.compose-form .attachment-picker {
  padding-block: 8px;
}

.compose-footer-controls {
  margin-top: 16px;
}

.compose-submit-row {
  margin-top: 18px;
}

/* Accounts, rules and settings */
.accounts-panel,
.settings-panel {
  width: calc(100% - 32px);
  max-width: 1120px;
  max-height: calc(100dvh - 98px);
  margin: 0 16px 16px;
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--system-separator);
  border-radius: var(--radius-card);
  background: var(--system-bg-elevated);
  box-shadow: var(--surface-shadow);
}

.panel-heading {
  align-items: flex-start;
  margin-bottom: 24px;
}

.panel-heading h3 {
  color: var(--system-label);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.panel-heading p,
.settings-panel > .panel-heading p,
.settings-section > div:first-child p {
  color: var(--system-label-secondary);
}

.secure-pill {
  min-height: 28px;
  border-radius: 999px;
  background: var(--system-green-soft);
  color: var(--system-green-strong);
}

.account-form,
.settings-form {
  border: 1px solid var(--system-separator);
  border-radius: 14px;
  background: var(--system-bg-secondary);
  padding: 20px;
}

.account-item,
.rule-item,
.footer-item,
.asset-item,
.account-footer-item {
  border-color: var(--system-separator);
  border-radius: 13px;
  background: var(--system-bg-elevated);
  box-shadow: none;
}

.settings-section {
  gap: 34px;
  padding: 28px 0;
  border-top-color: var(--system-separator);
}

.folder-mapping-settings,
.condition-builder {
  border-color: var(--system-separator);
  background: var(--system-bg-elevated);
}

.toggle-field {
  color: var(--system-label);
}

.toggle-field input,
.compact-toggle input {
  accent-color: var(--system-green);
}

.delete-button,
.delete-dialog-close {
  border-color: var(--system-separator);
  background: transparent;
  color: var(--system-red);
}

/* Feedback and modal surfaces */
.undo-toast {
  bottom: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: rgba(28, 33, 30, 0.94);
  color: #fff;
  box-shadow: var(--floating-shadow);
  backdrop-filter: blur(18px);
}

.undo-toast button {
  color: #ff8ab4;
}

.destructive-dialog,
.notice-dialog,
.attachment-preview-dialog {
  border: 1px solid var(--system-separator);
  border-radius: var(--radius-card);
  background: var(--system-bg-elevated);
  color: var(--system-label);
  box-shadow: var(--floating-shadow);
}

.destructive-dialog::backdrop,
.notice-dialog::backdrop,
.attachment-preview-dialog::backdrop {
  background: rgba(8, 12, 10, 0.46);
  backdrop-filter: blur(4px);
}

.notice-dialog {
  border-top: 1px solid var(--system-separator);
}

.notice-icon {
  background: var(--system-pink-soft);
  color: var(--system-pink);
}

.session-loading-overlay {
  background: var(--system-bg);
  color: var(--system-label);
}

.session-loading-mark {
  border-radius: 14px;
  background: var(--system-green-strong);
}

@media (max-width: 1100px) {
  .message-open {
    grid-template-columns: minmax(130px, 0.3fr) minmax(220px, 1fr) 72px;
    gap: 12px;
  }

  .message-account {
    display: none;
  }

  .topbar-actions .sync-status {
    display: none;
  }
}

@media (max-width: 900px) {
  .auth-view {
    grid-template-columns: 1fr;
    gap: 34px;
    max-width: 600px;
    padding: 32px 24px 42px;
  }

  .brand-panel {
    text-align: center;
  }

  .brand-mark {
    margin-inline: auto;
  }

  .auth-benefits {
    width: fit-content;
    margin-inline: auto;
    text-align: left;
  }

  .mail-view,
  html.session-restoring #mailView.hidden,
  .mail-view.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(286px, calc(100vw - 54px));
    transform: translateX(0);
    box-shadow: 18px 0 50px rgba(8, 20, 13, 0.2);
  }

  .mail-view.sidebar-collapsed .sidebar {
    width: min(286px, calc(100vw - 54px));
    transform: translateX(-105%);
  }

  .mail-view.sidebar-collapsed .sidebar-head > div:last-child,
  .mail-view.sidebar-collapsed .sidebar-section-head > span,
  .mail-view.sidebar-collapsed .folder-item > span,
  .mail-view.sidebar-collapsed .custom-folder-row .folder-delete-button,
  .mail-view.sidebar-collapsed #logoutButton > span {
    display: initial;
  }

  .mail-view.sidebar-collapsed .folder-item {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    place-items: initial;
    align-items: center;
    padding: 0 10px;
  }

  .mail-view.sidebar-collapsed .folder-item > strong {
    position: static;
    min-width: 22px;
    padding: 0;
    background: transparent;
    font-size: 11px;
    line-height: 20px;
    text-align: right;
  }

  .mail-view.sidebar-collapsed #logoutButton {
    width: 100%;
    margin-inline: 0;
    text-align: left;
  }

  .workspace {
    width: 100%;
  }

  .settings-section {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (max-width: 680px) {
  .auth-view {
    padding-inline: 16px;
  }

  .auth-view h1 {
    font-size: 52px;
  }

  .brand-panel .brand-lead {
    font-size: 19px;
  }

  .auth-benefits {
    font-size: 13px;
  }

  .auth-card {
    padding: 22px;
    border-radius: 18px;
  }

  .topbar {
    min-height: 68px;
    padding: 9px 10px;
  }

  .topbar h2 {
    max-width: 43vw;
    font-size: 20px;
  }

  .topbar p,
  .topbar-connect span {
    display: none;
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-actions .primary-action.small,
  .topbar-actions .secondary-action {
    min-width: 40px;
    min-height: 40px;
    padding: 0 10px;
  }

  .topbar-actions .primary-action.small span {
    display: none;
  }

  .mail-content {
    width: calc(100% - 12px);
    height: calc(100dvh - 74px);
    margin: 0 6px 6px;
    border-radius: 14px;
  }

  .message-filter-bar {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px;
  }

  #accountFilter {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .bulk-toolbar {
    padding-inline: 8px;
  }

  .message-item {
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 70px;
    padding-right: 10px;
  }

  .message-open {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 5px 10px;
    padding: 9px 0;
  }

  .message-subject-line {
    grid-column: 1 / -1;
  }

  .message-preview {
    font-size: 12px;
  }

  .reader-command-bar {
    padding-inline: 8px;
  }

  .reader-move-control select {
    width: 118px;
  }

  .message-detail-head,
  .detail-body {
    padding-inline: 20px;
  }

  .message-detail-head {
    padding-top: 24px;
  }

  #detailSubject {
    font-size: 25px;
  }

  .reader-reply-bar {
    padding-inline: 20px;
  }

  .reader-reply-bar .secondary-action {
    width: 100%;
  }

  .compose-panel {
    width: 100%;
    min-height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .compose-form {
    padding: 14px;
  }

  .compose-form > .field {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .compose-footer-controls,
  .compose-submit-row,
  .form-row,
  .form-row.equal-columns,
  .settings-form .form-row.equal-columns,
  .account-form .form-row,
  .account-form .form-row:has(.field:nth-child(3)) {
    grid-template-columns: 1fr;
  }

  .accounts-panel,
  .settings-panel {
    width: calc(100% - 12px);
    max-height: calc(100dvh - 74px);
    margin: 0 6px 6px;
    padding: 18px;
    border-radius: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .sidebar,
  .auth-card,
  .reader-command-bar,
  .message-filter-bar,
  .undo-toast {
    background: var(--system-bg-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --system-separator: rgba(35, 45, 39, 0.32);
    --system-separator-strong: rgba(35, 45, 39, 0.5);
  }

  .folder-item.active,
  .message-item.selected {
    outline: 2px solid var(--system-green);
    outline-offset: -2px;
  }
}
