/* =====================================================================
   mail（メール管理）— FIT-SC UI v7 の上に重ねる
   ===================================================================== */

.ml-stat-link { color: inherit; text-decoration: none; transition: border-color var(--dur-2), transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2); }
.ml-stat-link:hover { color: inherit; text-decoration: none; border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ---- 送信までの流れ ---- */
.ml-flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; counter-reset: flow; list-style: none; margin: 0; padding: 0; }
.ml-flow li { position: relative; counter-increment: flow; }
.ml-flow li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -9px;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--text-subtle);
  border-right: 2px solid var(--text-subtle);
  transform: translateY(-50%) rotate(45deg);
  opacity: .6;
}
.ml-flow a {
  display: grid;
  gap: 4px;
  height: 100%;
  padding: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--dur-2), background-color var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.ml-flow a:hover { border-color: var(--accent-line); background: var(--accent-soft); transform: translateY(-2px); text-decoration: none; color: var(--text); }
.ml-flow a::before { content: counter(flow); position: absolute; top: 10px; right: 12px; font-size: var(--fs-xs); font-weight: 800; color: var(--text-subtle); }
.ml-flow__icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.ml-flow strong { font-size: var(--fs-sm); }
.ml-flow small { font-size: var(--fs-xs); color: var(--text-subtle); }
@media (max-width: 1100px) { .ml-flow { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ml-flow li::after { display: none; } }
@media (max-width: 600px) {
  .ml-flow { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .ml-flow a { grid-template-columns: 34px minmax(0, 1fr); column-gap: 12px; row-gap: 0; align-items: center; padding: 10px 14px; }
  .ml-flow__icon { grid-row: span 2; margin: 0; }
  .ml-flow a::before { top: 50%; transform: translateY(-50%); }
}

/* ---- メール作成 ---- */
.ml-compose { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.ml-compose__side { position: sticky; top: calc(var(--topbar-h) + 16px); }
@media (max-width: 1100px) { .ml-compose { grid-template-columns: minmax(0, 1fr); } .ml-compose__side { position: static; } }
.ml-recipient-count { display: flex; align-items: baseline; gap: 8px; }
.ml-recipient-count strong { font-size: var(--fs-2xl); font-variant-numeric: tabular-nums; display: inline-block; }
.ml-recipient-count span { color: var(--text-muted); font-size: var(--fs-sm); }
.variable-list { display: flex; flex-wrap: wrap; gap: 6px; }
.variable-chip { font-family: var(--font-mono); letter-spacing: 0; }
.variable-chip:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* リッチテキストエディタ */
.editor-field { display: grid; gap: 6px; }
.html-editor-source { display: none !important; }
.html-editor-wrap { border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--input-bg); overflow: hidden; transition: border-color var(--dur-1), box-shadow var(--dur-1); }
.html-editor-wrap:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.html-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.html-editor-toolbar button {
  min-width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background-color var(--dur-1), color var(--dur-1);
}
.html-editor-toolbar button:hover { background: var(--surface-3); color: var(--text-strong); }
.html-editor-toolbar select { width: auto; min-height: 32px; padding: 2px 30px 2px 10px; font-size: var(--fs-xs); }
.html-editor-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 4px; }
.editor-color-picker { display: inline-flex; align-items: center; cursor: pointer; }
.editor-color-picker input[type="color"] { width: 32px; height: 28px; padding: 2px; }
.html-editor {
  min-height: 280px;
  max-height: 60vh;
  overflow: auto;
  padding: 14px 16px;
  line-height: 1.85;
  outline: none;
  /* メールの見え方に合わせ、本文エリアはテーマに関係なく白い「紙」で表示する */
  background: #fff;
  color: #1b2430;
  -webkit-user-select: text;
  user-select: text;
}
.html-editor:empty::before { content: attr(data-placeholder); color: #8a90a3; }
.html-editor p { margin: 0 0 .8em; }
.html-editor ul, .html-editor ol { padding-left: 1.4em; }
.html-editor table { border-collapse: collapse; }
.html-editor td, .html-editor th { border: 1px solid #d8e0ea; padding: 4px 8px; }
.html-editor a { color: #1d5fd6; }

/* 送信対象の選択 */
.ml-recipient-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 22px 14px;
  border-bottom: 1px solid var(--divider);
}
.ml-recipient-search { flex: 1 1 260px; }
.recipient-view.is-hidden { display: none; }
.recipient-category { display: grid; gap: 10px; margin-top: 16px; }
.recipient-category:first-child { margin-top: 0; }
.recipient-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.recipient-card { padding: 10px 12px; }
.recipient-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipient-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipient-card.is-disabled { opacity: .55; cursor: not-allowed; }
.recipient-card > span { min-width: 0; }

/* ---- 送信バッチ ---- */
.ml-batches { align-items: start; }
.ml-batch-list { position: sticky; top: calc(var(--topbar-h) + 16px); }
.ml-scroll-list { max-height: calc(100dvh - var(--topbar-h) - 120px); overflow-y: auto; scrollbar-width: thin; }
.ml-scroll-list .list-item.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
@media (max-width: 900px) { .ml-batch-list { position: static; } .ml-scroll-list { max-height: 320px; } }
.ml-mini-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ml-status-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.ml-status-form .field { min-width: 180px; }
.ml-preview__subject { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.mail-preview-frame { width: 100%; flex: 1 1 auto; min-height: 50vh; border: 1px solid var(--border); border-radius: var(--r-md); background: #fff; }
.ml-preview { display: flex; flex-direction: column; }

/* ---- 添付・Gmail下書き ---- */
.ml-batch-picker { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.ml-batch-picker .field { flex: 1 1 320px; max-width: 560px; }
.ml-att-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.ml-reassign { display: inline-flex; gap: 6px; align-items: center; }
.ml-reassign select { width: auto; max-width: 200px; min-height: 32px; font-size: var(--fs-xs); }

/* ---- ログ ---- */
.ml-log-detail summary { cursor: pointer; font-size: var(--fs-xs); color: var(--accent); font-weight: 600; }
.ml-log-detail pre { margin-top: 6px; max-width: 460px; max-height: 240px; font-size: var(--fs-2xs); }

/* ---- 設定 ---- */
.ml-settings { align-items: start; }
.ml-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.ml-steps li::marker { color: var(--accent); font-weight: 700; }
.ml-step-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-xs); font-weight: 800; }
