/* Mail — narrow edges + resizable panes (folders | list | read) */
.pill .spacer { flex: 1; margin-right: auto; }

body.mail-body {
  --desktop-inset: 4px;
}

body.mail-body .topbar {
  padding-left: 8px;
  padding-right: 8px;
}

.mail-stage.stage {
  display: grid;
  grid-template-columns: var(--mail-rail, 180px) 5px 1fr;
  width: auto;
  margin: 0 var(--desktop-inset, 4px) 4px;
  height: calc(100vh - 148px);
  min-height: 420px;
  max-height: calc(100vh - 148px);
  overflow: hidden;
  align-items: stretch;
  border-radius: 16px;
}

.mail-stage.rail-collapsed {
  grid-template-columns: 52px 5px 1fr;
}

.mail-stage.rail-collapsed .mail-folders .fname,
.mail-stage.rail-collapsed .mail-folders .fcount,
.mail-stage.rail-collapsed .mail-folders .meta,
.mail-stage.rail-collapsed .mail-folders .folder-sep,
.mail-stage.rail-collapsed .mail-folders .folder.sys {
  display: none;
}

.mail-stage.rail-collapsed .mail-folders .folder {
  justify-content: center;
  padding: 10px 6px;
}

.mail-stage.rail-collapsed .rail-toggle {
  margin: 0 auto;
}

.mail-folders {
  padding: 10px 6px 14px;
  border-right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  overflow: auto;
  min-height: 0;
  min-width: 0;
}

.mail-folders-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin: 0 4px 6px;
}

.mail-folders-head .meta { margin: 0; }

.rail-toggle {
  appearance: none;
  border: 1px solid var(--hairline-strong);
  background: #fff;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-field);
  cursor: pointer;
  font: 600 14px/1 Space Grotesk, sans-serif;
  color: var(--ink);
  flex-shrink: 0;
}

.rail-toggle:hover {
  background: rgba(var(--voltr-rgb), 0.35);
}

.mail-folders .folder {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 7px 8px;
  border-radius: var(--radius-field);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-size: 0.9rem;
}

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

.mail-folders .folder .fcount {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mail-folders .folder .fcount.has-unseen {
  color: var(--ink);
  font-weight: 600;
}

.mail-folders .folder:hover,
.mail-folders .folder.active {
  background: rgba(var(--voltr-rgb), 0.35);
}

.mail-folders .folder.depth-1 { padding-left: 16px; }
.mail-folders .folder.depth-2 { padding-left: 24px; }
.mail-folders .folder.depth-3 { padding-left: 32px; }

.mail-folders .folder-sep {
  height: 1px;
  background: var(--hairline);
  margin: 8px 6px;
}

.mail-folders .folder.sys { font-weight: 500; }

.mail-split {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  touch-action: none;
}

.mail-split::after {
  content: "";
  position: absolute;
  inset: 0 1px;
  background: var(--hairline);
  transition: background 0.15s ease, inset 0.15s ease;
}

.mail-split:hover::after,
.mail-split.is-dragging::after {
  background: var(--voltr);
  inset: 0 0;
}

body.mail-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.mail-resizing .mail-list,
body.mail-resizing .mail-read {
  pointer-events: none;
}

.mail-workspace {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: #fff;
}

.mail-mailbox {
  display: grid;
  grid-template-columns: var(--mail-list, 340px) 5px 1fr;
  height: 100%;
  min-height: 0;
}

.mail-stage[data-mode="compose"] .mail-mailbox {
  grid-template-columns: 1fr;
}

.mail-stage[data-mode="compose"] .mail-list-pane,
.mail-stage[data-mode="compose"] #splitList {
  display: none;
}

.mail-list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 0;
  background: #fff;
  height: 100%;
}

.mail-list-head {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.mail-list-head h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.mail-list-head .meta {
  margin: 0;
  font-size: 0.72rem;
}

.mail-list {
  overflow: auto;
  padding: 0;
  flex: 1;
  min-height: 0;
}

.mail-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
  background: var(--surface);
}

.mail-pager .pager-meta {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mail-pager .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mail-list .msg {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.mail-list .msg:hover { background: rgba(var(--ink-rgb), 0.03); }

.mail-list .msg.active {
  background: rgba(var(--voltr-rgb), 0.28);
  box-shadow: inset 3px 0 0 var(--voltr);
}

.mail-list .msg .from {
  margin: 0;
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-list .msg .when {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  justify-self: end;
}

.mail-list .msg .subj {
  margin: 0;
  font-size: 0.84rem;
  grid-column: 1 / -1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-list .msg .snip {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  grid-column: 1 / -1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-hint {
  padding: 22px 14px;
  color: var(--muted);
  margin: 0;
}

.mail-read {
  padding: 18px 22px 36px;
  overflow: auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #fff;
}

.mail-read.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.mail-read-head h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.mail-read-body {
  margin-top: 16px;
  line-height: 1.55;
  font-size: 0.95rem;
}

.mail-read-body.is-plain {
  white-space: pre-wrap;
}

.mail-html-frame {
  display: block;
  width: 100%;
  min-height: 80px;
  border: 0;
  background: transparent;
  overflow: hidden;
}

.mail-read-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.mail-read-actions select,
.mail-read-actions input,
.mail-compose input,
.mail-compose textarea,
.mail-settings input,
.mail-settings textarea {
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-field);
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}

.mail-read-actions input {
  flex: 1;
  min-width: 140px;
}

.mail-compose {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compose-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compose-toolbar .meta { margin: 0; }

.compose-send-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.btn-send-fly {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--voltr);
  color: var(--ink);
  border-radius: var(--radius-field);
  padding: 8px 14px 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font: 600 0.95rem/1 "Space Grotesk", sans-serif;
  letter-spacing: -0.02em;
  box-shadow: 3px 3px 0 rgba(var(--ink-rgb), 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-send-fly-lg {
  padding: 12px 18px 12px 12px;
  font-size: 1.05rem;
}

.btn-send-fly:hover {
  transform: translateY(-1px);
  box-shadow: 4px 4px 0 rgba(var(--ink-rgb), 0.22);
}

.btn-send-fly:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(var(--ink-rgb), 0.18);
}

.btn-send-fly:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.send-fly-visual {
  display: inline-flex;
  width: 44px;
  height: 28px;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.btn-send-fly-lg .send-fly-visual {
  width: 52px;
  height: 32px;
}

.send-fly-svg {
  overflow: visible;
}

.send-fly-envelope rect {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 2.2;
}

.send-fly-envelope path {
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send-fly-envelope .wing {
  stroke-width: 1.8;
  opacity: 0.85;
}

.send-fly-motion .trail {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.35;
}

.btn-send-fly:hover .send-fly-envelope,
.btn-send-fly.is-sending .send-fly-envelope {
  animation: send-envelope-fly 0.7s ease-in-out infinite;
}

.btn-send-fly:hover .trail,
.btn-send-fly.is-sending .trail {
  animation: send-trail-dash 0.55s linear infinite;
}

.btn-send-fly:hover .t2,
.btn-send-fly.is-sending .t2 { animation-delay: 0.08s; }
.btn-send-fly:hover .t3,
.btn-send-fly.is-sending .t3 { animation-delay: 0.16s; }

@keyframes send-envelope-fly {
  0% { transform: translate(0, 0) rotate(0deg); }
  40% { transform: translate(4px, -3px) rotate(-6deg); }
  70% { transform: translate(8px, 1px) rotate(4deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes send-trail-dash {
  0% { opacity: 0.15; stroke-dasharray: 2 8; stroke-dashoffset: 12; }
  50% { opacity: 0.55; }
  100% { opacity: 0.15; stroke-dasharray: 2 8; stroke-dashoffset: 0; }
}

.dock-compose {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
}

.dock-fly-env {
  display: inline-flex;
  align-items: center;
}

.dock-compose .send-fly-envelope rect {
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 2.2;
}

.dock-compose .send-fly-envelope path {
  stroke: var(--ink);
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock-compose .send-fly-motion .trail {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.4;
}

.dock-compose:hover .send-fly-envelope {
  animation: send-envelope-fly 0.7s ease-in-out infinite;
}

.dock-compose:hover .trail {
  animation: send-trail-dash 0.55s linear infinite;
}

.mail-compose label,
.mail-settings label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}

.mail-compose textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.5;
}

.mail-pane {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: #fff;
  padding: 22px 24px 40px;
  z-index: 2;
}

.mail-pane[hidden] {
  display: none !important;
}

.mail-settings {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mail-settings h2,
.mail-drive h2 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.settings-grid fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-field);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-grid legend {
  padding: 0 6px;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mail-settings label.stay {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}

.mail-settings textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.45;
}

.sync-progress {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-field);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-progress[hidden] {
  display: none !important;
}

.sync-progress .meta { margin: 0; }

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--voltr);
  transition: width 0.35s ease;
}

.progress-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mail-drive { max-width: 920px; }

.mail-drive h3.drive-report-title {
  margin: 28px 0 10px;
  font-size: 1rem;
}

.drive-hint {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 0.9rem;
}

.attach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.btn-file {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-field);
  cursor: pointer;
  font: inherit;
  background: #fff;
}

.drive-list,
.drive-picker-list,
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drive-row,
.audit-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-field);
  background: #fff;
  font-size: 0.9rem;
}

.drive-row .name {
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-row .meta-line,
.audit-row .meta-line {
  color: var(--muted);
  font-size: 0.78rem;
  grid-column: 1 / -1;
}

.drive-row .kind {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
}

.compose-attach {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

.attach-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attach-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-field);
  font-size: 0.88rem;
}

.drive-picker {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.drive-picker[hidden] { display: none !important; }

.drive-picker-panel {
  width: min(560px, 100%);
  max-height: min(70vh, 640px);
  overflow: auto;
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 18px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.drive-picker-panel header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.drive-picker-panel h3 {
  margin: 0;
  flex: 1;
  font-family: "Space Grotesk", sans-serif;
}

.chatux {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 84px;
  z-index: 25;
  width: var(--shell-chrome-width);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.chatux-form,
.chatux-reply { pointer-events: auto; }

@media (max-width: 900px) {
  .mail-stage.stage {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    min-height: calc(100vh - 160px);
  }
  .mail-split { display: none; }
  .mail-folders {
    flex-direction: row;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--hairline-strong);
    max-height: 110px;
  }
  .mail-mailbox {
    grid-template-columns: 1fr;
    height: auto;
  }
  .mail-list-pane {
    max-height: 40vh;
    border-bottom: 1px solid var(--hairline);
  }
  .mail-read { height: auto; max-height: 48vh; }
  .settings-grid { grid-template-columns: 1fr; }
  .mail-pane { position: relative; inset: auto; min-height: 50vh; }
}
