/* ==========================================================================
   Mail Tab Styles (Column 1 FolderTree 300px, Column 2 EmailList 552px,
   Column 3 Reader/Compose 1fr, Bottom Dock 112px, Split RefPane 852px)
   ========================================================================== */

.mail-layout {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* Split-Screen Reference Pane (852px max on ultrawide, balanced flex on 1440px) */
.ref-reader-column {
  flex: 1 1 46%;
  width: auto;
  min-width: 320px;
  max-width: 852px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
}

.ref-reader-sep {
  flex: 0 0 3px;
  background: var(--border-subtle);
}

/* Collapse folder tree when split-screen reference view is active so list + ref + compose fit cleanly */
.mail-layout.has-ref-split .folder-column {
  display: none;
}

.mail-layout.has-ref-split .list-column {
  flex: 0 1 280px;
  width: 280px;
  min-width: 220px;
}

@media (max-width: 1200px) {
  .mail-layout.has-ref-split .list-column {
    display: none;
  }
}

.ref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  flex-shrink: 0;
}

.ref-header-info {
  min-width: 0;
  flex: 1;
}

.ref-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ref-meta {
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.ref-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ref-counter {
  font-size: 12px;
  color: var(--fg-muted);
  margin-right: 4px;
}

.ref-timeline-host {
  height: 112px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-low);
  overflow: hidden;
}

.ref-iframe {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: none;
  background: transparent;
}

.ref-attachments-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-low);
  flex-shrink: 0;
}

/* Column 1: Folder Sidebar (300px desktop, scales cleanly below 1320px) */
.folder-column {
  flex: 0 1 clamp(210px, 21vw, 300px);
  width: clamp(210px, 21vw, 300px);
  min-width: 190px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: light-dark(#ffffff, #18181b);
  border-right: 1px solid var(--border-subtle);
  padding: 10px 6px 0 10px;
  gap: 10px;
  min-height: 0;
}

.btn-compose {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.folder-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.folder-item-btn {
  width: 100%;
  height: 38px;
  padding: 0 8px 0 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
  text-align: left;
}

/* Indbakke root: chevron occupies the 16px branch slot before the icon */
.folder-item-btn:has(> .folder-chevron) {
  padding-left: 10px;
}

.folder-item-btn.is-child {
  padding-left: 42px;
  font-size: 13px;
  font-weight: 400;
  color: var(--fg);
}

.folder-item-btn:hover:not(.is-active) {
  background: light-dark(#f1f3f9, #3f3f46);
}

.folder-item-btn.is-active,
.folder-item-btn[aria-current="true"] {
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-weight: 600;
}

.folder-chevron {
  width: 16px;
  height: 16px;
  margin-right: -8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.folder-icon,
.folder-item-btn .folder-icon,
.folder-item-btn.is-active .folder-icon,
.folder-item-btn[aria-current="true"] .folder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.folder-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Count chips (mirror desktop FolderTreeDelegate) */
.folder-badge {
  min-width: 20px;
  height: 18px;
  box-sizing: border-box;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  border-radius: 9px;
  flex-shrink: 0;
  background: light-dark(#e2e8f0, #3f3f46);
  color: light-dark(#1e40af, #f4f4f5);
}

.folder-badge.is-primary {
  background: #2563eb;
  color: #ffffff;
}

.folder-item-btn.is-active .folder-badge,
.folder-item-btn[aria-current="true"] .folder-badge {
  background: light-dark(#1e40af, #ffffff);
  color: light-dark(#ffffff, #18181b);
}

/* Column 2: Email List (552px desktop target, responsive on narrower viewports) */
.list-column {
  flex: 0 1 clamp(300px, 38.4vw, 552px);
  width: clamp(300px, 38.4vw, 552px);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: light-dark(#ffffff, #18181b);
  border-right: 1px solid var(--border-subtle);
  min-width: 260px;
  min-height: 0;
}

.list-header {
  min-height: 56px;
  height: auto;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  flex-shrink: 0;
}

.dynamic-header-search {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.search-box:focus-within {
  border-color: var(--primary);
  background: var(--surface);
}

.search-box .search-icon {
  position: static;
  color: var(--fg-muted);
  display: inline-flex;
  flex-shrink: 0;
}

#mail-search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

#mail-search-input::placeholder {
  color: var(--fg-muted);
}

#mail-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-spinner {
  color: var(--primary);
  display: inline-flex;
  flex-shrink: 0;
}

.btn-clear-search {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.btn-clear-search:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-clear-search:not(:disabled):hover {
  background: var(--pill-hover);
  color: var(--fg);
  border-color: var(--fg-muted);
}

.dynamic-header-actions {
  width: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.act-badge-cancel {
  height: 26px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.act-chip {
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-low);
  color: var(--fg);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.act-chip:hover {
  background: var(--pill-hover);
}

.act-spacer {
  flex: 1;
}

.act-btn {
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.act-btn:hover {
  background: var(--hover);
}

.act-btn.act-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.act-btn.act-danger:hover {
  background: var(--danger-bg);
}

.list-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  gap: 0;
  outline: none;
}

.list-empty-state {
  margin: auto;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--fg-muted);
  text-align: center;
  font-size: 13px;
}

/* 84px Flat Email Rows (mirrors desktop EmailItemDelegate) */
.email-card {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  height: 84px;
  min-height: 84px;
  max-height: 84px;
  flex-shrink: 0;
  padding: 10px 14px 10px 22px;
  border-radius: 0;
  background: light-dark(#ffffff, #18181b);
  border: none;
  border-bottom: 1px solid light-dark(#e2e8f0, #3f3f46);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.08s ease;
}

.email-card.is-deferred {
  content-visibility: auto;
  contain-intrinsic-size: auto 84px;
}

.email-card:hover {
  background: light-dark(#f1f5f9, #27272a);
}

.email-card.is-selected {
  background: light-dark(#dbeafe, #1e3a8a);
  border-bottom-color: light-dark(#bfdbfe, #1e40af);
}

.email-card.is-thread-child {
  margin-left: 0;
  padding-left: 40px;
  height: 84px;
  min-height: 84px;
  max-height: 84px;
}

.thread-tree-guide {
  position: absolute;
  left: 14px;
  top: 0;
  bottom: -1px;
  width: 1px;
  background: light-dark(#2563eb, #3b82f6);
  pointer-events: none;
  z-index: 1;
}

.email-card.is-thread-child-last .thread-tree-guide {
  bottom: auto;
  height: 20px;
}

.thread-tree-guide::after {
  content: "";
  position: absolute;
  top: 19px;
  left: 0;
  width: 11px;
  height: 1px;
  background: light-dark(#2563eb, #3b82f6);
}

.email-card-row1,
.email-card-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.thread-chevron {
  position: absolute;
  left: 2px;
  top: 8px;
  width: 20px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  border-radius: 4px;
}

.thread-chevron:hover {
  background: var(--pill-hover);
  color: var(--fg);
}

.email-card > .unread-dot {
  position: absolute;
  left: 8px;
  top: 16px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3b82f6;
  pointer-events: none;
}

.email-card.is-thread-child > .unread-dot {
  left: 28px;
}

.email-card.is-thread-group.is-unread .thread-chevron {
  left: 1px;
  width: 16px;
}

.email-card.is-thread-group.is-unread > .unread-dot {
  left: 18px;
}

.email-card.is-thread-group.is-unread .email-card-row1 {
  padding-left: 8px;
}

.email-sender {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: light-dark(#475569, #a1a1aa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-card.is-unread .email-sender,
.email-card.is-unread .email-subject {
  font-weight: 700;
  color: light-dark(#0f172a, #f4f4f5);
}

.email-card:hover:not(.is-unread):not(.is-selected) .email-sender,
.email-card:hover:not(.is-unread):not(.is-selected) .email-subject {
  color: light-dark(#334155, #d4d4d8);
}

.email-card.is-selected .email-sender,
.email-card.is-selected .email-subject {
  color: light-dark(#1e40af, #ffffff);
}

.email-row1-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.email-badge-icon {
  display: inline-flex;
  align-items: center;
  color: var(--fg-muted);
}

.email-badge-icon.cal-added {
  color: var(--success);
}

.email-badge-icon.cal-pending {
  color: var(--primary);
}

.email-date {
  font-size: 11.5px;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.email-cat-icon {
  color: var(--fg-muted);
  display: inline-flex;
  flex-shrink: 0;
}

.email-card.is-selected .email-date,
.email-card.is-selected .email-cat-icon,
.email-card.is-selected .email-badge-icon {
  color: light-dark(#3b82f6, #bfdbfe);
}

.email-subject {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: light-dark(#475569, #a1a1aa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-star-btn {
  width: 24px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.55;
}

.email-card:hover .email-star-btn,
.email-star-btn.is-starred {
  opacity: 1;
}

.email-star-btn.is-starred {
  color: light-dark(#2563eb, #60a5fa);
}

.email-card-row3 {
  font-size: 12px;
  font-style: italic;
  color: light-dark(#0284c7, #38bdf8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 0;
}

.email-card.is-selected .email-card-row3 {
  color: light-dark(#1d4ed8, #93c5fd);
}

/* Column 3: Reader & Composer Pane */
.reader-column {
  flex: 1 1 320px;
  min-width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  padding: 0;
  background: var(--surface);
  min-height: 0;
  overflow: hidden;
}

.reader-top-bar {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  flex-shrink: 0;
}

.reader-header-top-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 18px;
}

.reader-header-left {
  flex: 1 1 240px;
  min-width: 0;
}

.reader-subject {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
  word-break: break-word;
}

.reader-sender {
  margin-top: 4px;
  font-size: 13px;
  color: var(--fg);
}

.reader-date {
  margin-top: 2px;
  font-size: 12px;
  color: var(--fg-muted);
}

.reader-header-right {
  flex-shrink: 0;
}

.reader-actions-row,
.compose-actions-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.reader-action-btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.reader-action-btn [data-icon] {
  color: var(--fg-muted);
}

.reader-action-btn:hover {
  background: var(--pill-hover);
  border-color: var(--fg-muted);
}

.reader-action-btn.is-active {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-color: var(--primary);
}

.reader-action-btn.is-active [data-icon] {
  color: var(--on-primary-container);
}

.reader-action-btn.is-danger-text {
  color: var(--danger);
}

.reader-star-btn {
  width: 30px;
  height: 30px;
  padding: 0;
}

.reader-star-btn.is-starred {
  color: #eab308;
  border-color: color-mix(in srgb, #eab308 45%, var(--border));
}

.reader-star-btn.is-starred [data-icon] {
  color: #eab308;
}

/* Reader Content Stack */
.reader-content-stack {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.reader-placeholder,
.reader-loading,
.reader-error {
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--fg-muted);
  font-size: 13.5px;
}

.empty-shell-box,
.reader-error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  max-width: 360px;
}

.empty-shell-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface-low);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
}

.empty-shell-title,
.reader-error-title {
  margin: 4px 0 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}

.empty-shell-desc,
.reader-error-desc {
  margin: 0;
  font-size: 13px;
  color: var(--fg-muted);
}

.reader-iframe-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
}

.reader-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

/* 112px Fixed Bottom Dock (mirrors desktop ReaderBottomDock: margins 10/6/16/6, spacing 12) */
.reader-bottom-dock {
  flex: 0 0 112px;
  height: 112px;
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  padding: 6px 16px 6px 10px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-low);
  overflow: hidden;
}

.bottom-dock-rail {
  flex: 0 0 30px;
  width: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
}

.dock-rail-btn {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  aspect-ratio: 1 / 1;
  padding: 0;
  line-height: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dock-rail-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.dock-rail-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.dock-rail-btn.is-active {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.dock-rail-btn:not(:disabled):not(.is-active):hover {
  background: var(--hover);
  color: var(--fg);
}

.bottom-dock-divider {
  width: 1px;
  height: 80px;
  align-self: center;
  margin: 0;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.bottom-dock-pages {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.dock-page {
  width: 100%;
  height: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0;
}

.dock-attachments-page {
  justify-content: space-between;
  gap: 12px;
}

.att-chips-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  max-height: 92px;
  overflow-y: auto;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.att-chip:hover {
  border-color: var(--primary);
}

.att-chip-size {
  color: var(--fg-muted);
  font-size: 11px;
}

.att-chip-action,
.att-chip-rm {
  color: var(--fg-muted);
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  cursor: pointer;
}

.att-chip-rm:hover {
  color: var(--danger);
}

/* Calendar Hero Card in Dock */
.calendar-hero-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 0;
  background: transparent;
  border: none;
}

.hero-details {
  min-width: 0;
  flex: 1;
}

.hero-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-time {
  font-size: 12px;
  color: var(--primary);
  margin-top: 2px;
  font-weight: 500;
}

.hero-location {
  font-size: 11.5px;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Horizontal Canvas Thread Timeline (104px high) */
.dock-timeline-page {
  padding: 0;
  margin: -4px 0;
  height: calc(100% + 8px);
}

.timeline-scroll-wrap {
  position: relative;
  width: 100%;
  height: 104px;
  overflow: hidden;
}

.timeline-scroller {
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.timeline-canvas {
  display: block;
  height: 104px;
  cursor: pointer;
}

.timeline-fade-left,
.timeline-fade-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  pointer-events: none;
}

.timeline-fade-left {
  left: 0;
  background: linear-gradient(to right, var(--surface-low), transparent);
}

.timeline-fade-right {
  right: 0;
  background: linear-gradient(to left, var(--surface-low), transparent);
}

/* Inline Compose Mode Styles */
.compose-header-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compose-subject-row {
  display: flex;
  align-items: center;
}

.compose-mode-subject {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
}

.compose-subject-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  padding: 4px 2px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--fg);
  background: transparent;
  outline: none;
}

.compose-subject-input:focus {
  border-bottom-color: var(--primary);
}

.compose-recipients-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.compose-recipient-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.compose-field-label {
  width: 34px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.recipient-chip-box {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 30px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-low);
  display: flex;
  align-items: center;
}

.recipient-chip-box:focus-within {
  border-color: var(--primary);
  background: var(--surface);
}

.recipient-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-high);
  color: var(--fg);
}

.recipient-chip.is-cc {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.recipient-chip.is-bcc {
  background: light-dark(#f3e8ff, rgba(147, 51, 234, 0.28));
  color: light-dark(#6b21a8, #e9d5ff);
}

.recipient-chip-rm {
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  display: inline-flex;
  padding: 0;
  cursor: pointer;
}

.recipient-chip-rm:hover {
  opacity: 1;
}

.recipient-text-input {
  flex: 1 1 60px;
  min-width: 60px;
  width: 0;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
}

.recipient-autocomplete {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.recipient-ac-item {
  width: 100%;
  padding: 7px 11px;
  border: none;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.recipient-ac-item:hover,
.recipient-ac-item.is-active {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.recipient-ac-name {
  font-weight: 600;
}

.recipient-ac-email {
  color: var(--fg-muted);
  font-size: 12px;
}

.compose-cc-toggles {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.compose-cc-toggle-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-low);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  cursor: pointer;
}

.compose-cc-toggle-btn:hover {
  color: var(--fg);
  background: var(--pill-hover);
}

.compose-toolbar-slot {
  padding: 6px 18px 8px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-low);
}

.compose-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compose-fmt-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.compose-tb-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.compose-tb-btn:hover {
  background: var(--pill-hover);
  color: var(--fg);
}

.compose-tb-btn.is-active {
  background: var(--primary-container);
  color: var(--primary);
}

.compose-tb-sep {
  width: 1px;
  height: 16px;
  margin: 0 3px;
  background: var(--border);
}

.proofread-actions-pill,
.proofread-send-prompt-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--primary);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 12px;
}

.proofread-count-lbl {
  font-weight: 600;
}

.proofread-pill-btn,
.proofread-prompt-action,
.proofread-prompt-dismiss {
  border: none;
  border-radius: 5px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.proofread-pill-btn.is-accept {
  background: var(--primary);
  color: var(--on-primary);
}

.compose-from-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.compose-from-locked {
  font-size: 12px;
  color: var(--fg-muted);
}

.compose-from-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
}

.btn-send-compose.is-sent {
  background: var(--success) !important;
  border-color: var(--success) !important;
}

.compose-editor-slot {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.compose-editor-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.compose-img-mini-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface-low);
  border-bottom: 1px solid var(--border-subtle);
}

.compose-img-mini-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  padding: 3px 9px;
  cursor: pointer;
}

.compose-img-mini-btn.is-danger {
  color: var(--danger);
}

.compose-rich-editor,
.compose-proofread-review {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
  outline: none;
}

.compose-rich-editor.is-drop-over,
.dock-attachments-page.is-drop-over {
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
}

.compose-inline-img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 6px 0;
  cursor: pointer;
}

.compose-signature-block {
  margin-top: 12px;
  color: var(--fg-muted);
}

.compose-quote-block {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  color: var(--fg-muted);
  font-size: 13px;
}

.compose-blockquote {
  margin: 8px 0 0 0;
  padding-left: 12px;
  border-left: 3px solid var(--border);
}

.proofread-preview-text {
  white-space: pre-wrap;
}

.proofread-mark {
  background: color-mix(in srgb, var(--primary) 26%, transparent);
  color: var(--fg);
  border-bottom: 2px solid var(--primary);
  border-radius: 3px;
  padding: 0 2px;
  cursor: help;
}

.compose-att-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--fg-muted);
  cursor: pointer;
}

/* AI Reply Assistant in 112px Dock */
.compose-ai-assistant {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ai-prompt-row,
.ai-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-prompt-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 12.5px;
}

.ai-ctrl-label {
  font-size: 12px;
  color: var(--fg-muted);
}

.ai-tone-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
}

.ai-len-segmented .seg-btn {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

/* Profile shortcut removed from the title bar (matches desktop) */
#profile-trigger {
  display: none !important;
}

/* ==========================================================================
   Inline compose header - mirrors desktop (mail_tab.py / recipient_input.py)
   Flat layout, no input boxes, 12px/500 recipient bar, 30px action buttons,
   28px flat toolbar buttons, muted plain-text sender selector.
   ========================================================================== */
.reader-top-bar {
  padding: 12px 12px 12px 16px;
  gap: 8px;
}

.reader-header-top-row {
  padding: 0;
  gap: 12px;
  align-items: flex-end;
}

.compose-header-slot {
  gap: 2px;
}

.compose-subject-row {
  min-height: 18px;
}

.compose-mode-subject {
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  color: light-dark(#0f172a, #f4f4f5);
}

.compose-subject-input {
  border: none;
  border-bottom: none;
  padding: 0;
  margin: 0;
  height: 18px;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  color: light-dark(#0f172a, #f4f4f5);
}

.compose-subject-input:focus,
.compose-subject-input:focus-visible {
  border-bottom: none;
  outline: none !important;
  box-shadow: none !important;
}

.compose-recipients-wrap {
  gap: 2px;
  margin-top: 2px;
}

.compose-recipient-row {
  gap: 4px;
  min-height: 20px;
}

.compose-field-label {
  width: auto;
  height: 20px;
  line-height: 20px;
  font-size: 12px;
  font-weight: 500;
  color: light-dark(#475569, #d4d4d8);
}

.recipient-chip-box,
.recipient-chip-box:focus-within {
  min-height: 20px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.recipient-chips-wrap {
  gap: 6px;
}

.recipient-chip {
  height: 20px;
  padding: 0 8px;
  gap: 0;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid light-dark(#cbd5e1, #3f3f46);
  background: light-dark(#f1f5f9, #27272a);
  color: light-dark(#0f172a, #f4f4f5);
  cursor: pointer;
  user-select: none;
}

.recipient-chip:hover {
  background: light-dark(#e2e8f0, #3f3f46);
}

.recipient-chip.is-cc {
  border-color: light-dark(#60a5fa, #3b82f6);
  background: light-dark(#dbeafe, #1e3a8a);
  color: light-dark(#1e40af, #dbeafe);
}

.recipient-chip.is-cc:hover {
  background: light-dark(#bfdbfe, #1d4ed8);
}

.recipient-chip.is-bcc {
  border-color: light-dark(#c084fc, #a855f7);
  background: light-dark(#f3e8ff, #3b0764);
  color: light-dark(#6b21a8, #f3e8ff);
}

.recipient-chip.is-bcc:hover {
  background: light-dark(#e9d5ff, #581c87);
}

.recipient-text-input,
.recipient-text-input:focus,
.recipient-text-input:focus-visible {
  height: 20px;
  padding: 0;
  font-size: 12px;
  font-weight: 500;
  color: light-dark(#0f172a, #f4f4f5);
  outline: none !important;
  box-shadow: none !important;
}

/* Autocomplete popup (mirrors desktop QListWidget#recipientSuggestionPopup) */
.recipient-autocomplete {
  right: auto;
  min-width: 320px;
  max-width: 480px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid light-dark(#cbd5e1, #3f3f46);
  background: light-dark(#ffffff, #27272a);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.recipient-ac-item {
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: light-dark(#0f172a, #f4f4f5);
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.recipient-ac-item:hover,
.recipient-ac-item.is-active {
  background: light-dark(#e2e8f0, #3f3f46);
  color: light-dark(#0f172a, #f4f4f5);
}

.recipient-ac-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: light-dark(#64748b, #94a3b8);
  flex-shrink: 0;
}

.recipient-ac-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Desktop chip context menu & sender account menu */
.ctx-menu.ctx-menu-desktop,
.ctx-menu.ctx-menu-combo {
  padding: 4px;
  min-width: 160px;
  border-radius: 6px;
  border: 1px solid light-dark(#cbd5e1, #3f3f46);
  background: light-dark(#ffffff, #27272a);
  color: light-dark(#0f172a, #f4f4f5);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.ctx-menu.ctx-menu-desktop .ctx-item {
  padding: 6px 14px 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  gap: 8px;
  color: light-dark(#0f172a, #f4f4f5);
}

.ctx-menu.ctx-menu-desktop .ctx-item:hover:not(:disabled),
.ctx-menu.ctx-menu-desktop .ctx-item:focus-visible {
  background: light-dark(#f1f5f9, #3f3f46);
  outline: none;
}

.ctx-menu.ctx-menu-desktop .ctx-sep {
  margin: 4px 6px;
  border-top: 1px solid light-dark(#cbd5e1, #3f3f46);
}

.ctx-menu.ctx-menu-combo {
  min-width: 0;
  width: max-content;
}

.ctx-menu.ctx-menu-combo .ctx-item {
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  color: light-dark(#1e293b, #e4e4e7);
}

.ctx-menu.ctx-menu-combo .ctx-item:hover:not(:disabled),
.ctx-menu.ctx-menu-combo .ctx-item.is-active,
.ctx-menu.ctx-menu-combo .ctx-item:focus-visible {
  background: light-dark(#e2e8f0, #27272a);
  color: light-dark(#1e293b, #e4e4e7);
  outline: none;
}

/* Action buttons (Annuller / Send) - desktop btn_style */
.compose-actions-slot {
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.compose-actions-slot .reader-action-btn {
  height: 30px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid light-dark(#cbd5e1, #3f3f46);
  background: light-dark(#ffffff, #27272a);
  color: light-dark(#334155, #e4e4e7);
  font-size: 12px;
  font-weight: 500;
  gap: 6px;
}

.compose-actions-slot .reader-action-btn:hover {
  background: light-dark(#f1f5f9, #3f3f46);
  border-color: light-dark(#94a3b8, #52525b);
}

.compose-actions-slot .reader-action-btn [data-icon] {
  color: light-dark(#475569, #94a3b8);
}

.compose-actions-slot .btn-send-compose {
  height: 30px;
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: #2563eb;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
}

.compose-actions-slot .btn-send-compose:hover:not(:disabled) {
  background: #1d4ed8;
}

/* Formatting toolbar: transparent, borderless, 28px buttons, 15px icons */
.compose-toolbar-slot {
  padding: 4px 0 0 0;
  border-top: none;
  background: transparent;
}

.compose-toolbar-row {
  gap: 4px;
  flex-wrap: nowrap;
}

.compose-fmt-toolbar {
  gap: 4px;
}

.compose-tb-btn {
  width: 28px;
  height: 28px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: light-dark(#475569, #94a3b8);
}

.compose-tb-btn svg {
  width: 15px;
  height: 15px;
}

.compose-tb-btn:hover {
  background: light-dark(#f1f5f9, #3f3f46);
  border-color: light-dark(#cbd5e1, #3f3f46);
  color: light-dark(#475569, #94a3b8);
}

.compose-tb-btn.is-active {
  background: light-dark(#dbeafe, #1e3a8a);
  border-color: light-dark(#2563eb, #3b82f6);
  color: light-dark(#2563eb, #60a5fa);
}

.compose-tb-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: light-dark(#e2e8f0, #3f3f46);
}

/* Sender: discreet muted plain text, no box, no chevron */
.compose-from-locked {
  font-size: 12px;
  font-weight: 400;
  padding-right: 2px;
  color: light-dark(#878b94, #868688);
}

.compose-from-select,
.compose-from-select:focus,
.compose-from-select:focus-visible {
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: light-dark(#878b94, #868688);
  text-align: right;
  cursor: pointer;
  outline: none !important;
  box-shadow: none !important;
}

.compose-from-select:hover {
  color: light-dark(#878b94, #868688);
}
