/* Mail client: folders, list, reading pane, compose. */
/* Mail client — browser-style: folders in sidebar, list/read in main pane */
.mail-layout { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.mail-layout--client {
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
.mail-folder-heading {
  margin: 0;
  font-size: calc(13px * var(--text-scale, 1));
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #8b8e98;
}
.mail-disconnect { margin-top: 12px; }

.mail-manage-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  flex: 0 0 auto;
}
.mail-check {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  border: 1.5px solid #c5c9d2;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  position: relative;
}
.mail-check:checked,
.mail-check:indeterminate {
  border-color: var(--accent, #5b6cff);
  background: var(--accent, #5b6cff);
}
.mail-check:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.mail-check:indeterminate::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 7px;
  width: 10px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}
.mail-bubbles {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.mail-bubble {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  color: #2a2d35;
  font: inherit;
  font-size: calc(13px * var(--text-scale, 1));
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(42, 45, 53, 0.08);
}
.mail-bubble:hover { background: #f7f8fa; }
.mail-bubble.is-active {
  background: #e8ebff;
  color: #2f3dbd;
  box-shadow: inset 0 0 0 1px rgba(91, 108, 255, 0.35);
}
.mail-bubble-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a73e8;
  flex: none;
}
.mail-bubble-ico { display: block; flex: none; }
.mail-bubble-sort svg { opacity: .55; }
.mail-manage-action {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: transparent;
  color: #6b7080;
  font: inherit;
  font-size: calc(13px * var(--text-scale, 1));
  cursor: pointer;
}
.mail-manage-action:hover:not(:disabled) { background: #f2f3f7; color: #1a1d26; }
.mail-manage-action:disabled { opacity: .45; cursor: default; }
.mail-manage-action svg { display: block; }
.mail-sort-menu {
  position: fixed;
  z-index: 80;
  min-width: 220px;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e8eaef;
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.16);
}
.mail-sort-item {
  appearance: none;
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: calc(14px * var(--text-scale, 1));
  color: #1a1d26;
  cursor: pointer;
}
.mail-sort-item:hover { background: #f5f6f8; }
.mail-sort-item.is-active { font-weight: 600; }

.mail-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid #e8eaef;
  border-radius: 14px;
  overflow: auto;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.mail-list-empty,
.mail-read,
.mail-empty-settings {
  flex: 1 1 auto;
  min-height: 0;
}
.mail-list-empty {
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e8eaef;
  padding: 28px 16px;
}
.mail-row {
  appearance: none; width: 100%; border: 0; border-bottom: 1px solid #eef0f4;
  background: #fff; border-radius: 0; padding: 10px 14px; text-align: left;
  cursor: pointer; font: inherit; color: inherit;
  display: grid;
  grid-template-columns: 18px 28px minmax(100px, 170px) minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: center;
  box-sizing: border-box;
}
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: #f7f8fa; }
.mail-row.is-unread { background: #fafbfd; }
.mail-row.is-selected { background: #f0f3ff; }
.mail-row.is-unread .mail-row-from,
.mail-row.is-unread .mail-row-subject { font-weight: 700; color: #1a1d26; }
.mail-row-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  flex: none;
  user-select: none;
}
.mail-row-from {
  font-size: calc(13px * var(--text-scale, 1)); color: #1a1d26;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mail-row-main {
  display: flex; min-width: 0; gap: 4px; align-items: baseline;
  font-size: calc(13px * var(--text-scale, 1));
}
.mail-row-subject {
  color: #1a1d26; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 0 1 auto; max-width: 55%;
}
.mail-row-snippet {
  color: #8b8e98; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto; min-width: 0;
}
.mail-row-meta {
  display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  color: #9aa0ab; font-size: calc(12px * var(--text-scale, 1));
  white-space: nowrap;
}
.mail-att-mark { font-size: 12px; opacity: .75; }
.mail-flag-mark { display: inline-flex; align-items: center; }
@media (max-width: 720px) {
  .mail-row {
    grid-template-columns: 18px 28px minmax(0, 1fr) auto;
    grid-template-areas:
      "check av from meta"
      "check av main main";
    gap: 2px 10px;
  }
  .mail-row > .mail-check { grid-area: check; align-self: center; }
  .mail-row-avatar { grid-area: av; align-self: center; }
  .mail-row-from { grid-area: from; }
  .mail-row-main { grid-area: main; }
  .mail-row-meta { grid-area: meta; }
  .mail-row-subject { max-width: none; }
  .mail-bubbles { gap: 4px; }
  .mail-bubble { padding: 5px 9px; font-size: calc(12px * var(--text-scale, 1)); }
}
.mail-connect,
.mail-read:not(.mail-read--dialog) {
  display: flex; flex-direction: column; gap: 12px; max-width: none;
  padding: 14px 16px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e8eaef;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.mail-empty-settings {
  padding: 28px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e8eaef;
}
.mail-connect-form { display: flex; flex-direction: column; gap: 10px; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mail-error { color: #b42318; background: #fef3f2; border-radius: 8px; padding: 10px 12px; font-size: calc(13px * var(--text-scale, 1)); }
.mail-hint { color: #8b8e98; font-size: calc(12px * var(--text-scale, 1)); }
.mail-oauth-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.mail-read-head h3 { margin: 0; font-size: calc(18px * var(--text-scale, 1)); }
.mail-read-from, .mail-read-meta { color: #6b7080; font-size: calc(13px * var(--text-scale, 1)); }
.mail-attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.mail-attachments a { color: var(--accent); font-size: calc(13px * var(--text-scale, 1)); }
.mail-html-frame { width: 100%; min-height: 280px; border: 1px solid #e8eaef; border-radius: 10px; background: #fff; }
.mail-text { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0;
  padding: 12px; border: 1px solid #e8eaef; border-radius: 10px; background: #fff; }

/* Compose — same card language as polls composer */
.mail-compose {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 720px;
  align-self: flex-start;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  box-sizing: border-box;
  padding: 18px 20px 20px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e8eaef;
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.08);
}
.mail-compose.mail-compose--dialog {
  max-width: none;
  align-self: stretch;
  margin: 0;
  flex: 0 1 auto;
  padding: 10px 14px 12px;
  gap: 8px;
  border-radius: 0;
  background: #fff;
  border: 0;
  box-shadow: none;
}
.mail-compose-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.mail-compose-field > span {
  font-size: calc(14px * var(--text-scale, 1));
  font-weight: 700;
  color: #1f2430;
  line-height: 1.25;
}
.mail-compose-field input,
.mail-compose-field select,
.mail-compose-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: calc(15px * var(--text-scale, 1));
  font-weight: 400;
  color: #1a1d26;
  background: #fff;
  line-height: 1.35;
}
.mail-compose-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7080' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.mail-compose-field input::placeholder,
.mail-compose-field textarea::placeholder {
  color: #9aa0ab;
}
.mail-compose-field input:focus,
.mail-compose-field select:focus,
.mail-compose-field textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, #fff);
  outline-offset: 1px;
  border-color: color-mix(in srgb, var(--accent) 40%, #d0d4dc);
}
.mail-compose-field--body {
  flex: 1 1 auto;
  min-height: 0;
}
.mail-compose-field--body textarea {
  resize: vertical;
  min-height: 180px;
  flex: 1 1 auto;
  height: 100%;
}
.mail-compose .mail-actions {
  margin-top: 2px;
  flex: 0 0 auto;
}
.mail-compose-send.btn.primary {
  min-height: 40px;
  padding: 0 18px;
}

.mail-settings-block { margin-top: 20px; }
.mail-settings-subtitle {
  margin: 0 0 10px; font-size: calc(15px * var(--text-scale, 1)); font-weight: 700; color: #1a1d26;
}
.mail-accounts-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.mail-account-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid #e8eaef; border-radius: 12px; padding: 12px 14px; background: #fff;
}
.mail-account-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mail-account-info strong { font-size: calc(14px * var(--text-scale, 1)); }
.mail-account-info span { color: #6b7080; font-size: calc(12px * var(--text-scale, 1)); }
.mail-account-meta { color: #9aa0ab !important; }
.mail-connect-settings .settings-field { margin-bottom: 10px; }
.mail-empty-settings { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.mail-empty-settings p { margin: 0; }

.mail-preset-field { display: flex; flex-direction: column; gap: 6px; }
.mail-preset-picker { position: relative; width: 100%; }
.mail-preset-trigger {
  appearance: none; width: 100%; box-sizing: border-box;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #e4e7ec; border-radius: 10px; background: #fff;
  padding: 10px 12px; font: inherit; color: #1a1d26; cursor: pointer; text-align: left;
}
.mail-preset-trigger:hover { border-color: #d0d4dc; }
.mail-preset-picker.is-open .mail-preset-trigger {
  border-color: color-mix(in srgb, var(--accent) 45%, #d0d4dc);
}
.mail-preset-trigger-icon { display: flex; flex: none; }
.mail-preset-trigger-label { flex: 1; min-width: 0; }
.mail-preset-trigger .chevron {
  width: 10px; height: 10px; flex: none; border-right: 2px solid #8b8e98; border-bottom: 2px solid #8b8e98;
  transform: rotate(45deg); margin-top: -4px; transition: transform .15s ease;
}
.mail-preset-picker.is-open .mail-preset-trigger .chevron { transform: rotate(-135deg); margin-top: 2px; }
.mail-preset-menu {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid #e4e7ec; border-radius: 12px;
  box-shadow: 0 10px 28px rgba(26, 29, 38, .12); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.mail-preset-menu.hidden { display: none; }
.mail-preset-option {
  appearance: none; border: 0; background: transparent; width: 100%;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; font: inherit; color: #1a1d26; text-align: left;
}
.mail-preset-option:hover { background: #f2f4f7; }
.mail-preset-option.is-selected {
  background: var(--accent); color: #fff;
}
.mail-preset-option-label { flex: 1; min-width: 0; }
.mail-preset-check { flex: none; font-weight: 700; }
.mail-provider-icon { display: inline-flex; width: 20px; height: 20px; flex: none; align-items: center; justify-content: center; }
.mail-provider-icon svg,
.mail-provider-icon img { display: block; width: 20px; height: 20px; object-fit: contain; }
.mail-provider-icon--outlook {
  width: 20px; height: 20px; border-radius: 5px; overflow: hidden;
}
.mail-provider-icon--outlook img {
  width: 20px; height: 20px; object-fit: cover;
}
.mail-oauth-btn { display: inline-flex; align-items: center; gap: 8px; }
.mail-oauth-btn .mail-provider-icon { width: 18px; height: 18px; }
.mail-oauth-btn .mail-provider-icon svg,
.mail-oauth-btn .mail-provider-icon img { width: 18px; height: 18px; }
.mail-oauth-btn .mail-provider-icon--outlook {
  width: 18px; height: 18px; border-radius: 4px;
}
.mail-oauth-btn .mail-provider-icon--outlook img {
  width: 18px; height: 18px;
}

.msg-caption { margin-top: 4px; }
.msg-caption:first-child { margin-top: 0; }
