/* Standalone email check — document scrolls while composing; results use bounded panes. */

.mail-page .top .tagline { display: block; flex: 1; font-size: 1rem; }

html.mail-page, body.mail-page {
  min-height: 100%;
  height: auto;
  overflow-y: auto;
  overscroll-behavior-y: auto;
}
body.mail-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-height: none;
}
body.mail-page .top { flex: none; width: 100%; max-width: none; }
body.mail-page .mail-solo {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  padding: 0.75rem max(1rem, env(safe-area-inset-right, 0px)) 0.75rem max(1rem, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
/* Results use one viewport and two explicit scroll regions on wide screens. */
html.mail-page.mail-results,
body.mail-page.mail-results {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.mail-page.mail-results {
  height: 100dvh;
  max-height: 100dvh;
}
body.mail-page.mail-results .mail-solo {
  max-width: min(1320px, 100%);
  padding: 0.4rem 0.75rem 0.35rem;
  gap: 0.4rem;
  align-items: stretch;
  overflow: hidden;
}
body.mail-page {
  padding-bottom: 0 !important;
}
body.mail-page .foot {
  display: block;
  flex: none;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0.3rem 0.75rem !important;
  font-size: 0.7rem;
  line-height: 1.35;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 94%, #fff);
}
body.mail-page .foot-copy { margin-top: 0.1rem !important; font-size: 0.64rem; opacity: 0.8; }
body.mail-page .notify-blurb { font-size: 0.74rem; }

/* Safe centering falls back to the top when expanded guide/content is taller than the viewport. */
body.mail-page:not(.mail-results) .mail-solo {
  justify-content: safe center;
}
body.mail-page:not(.mail-results) .mail-results-stage { display: none; }

/* Results: hide paste; fill height with equal panes that scroll internally. */
body.mail-page.mail-results .mail-lead,
body.mail-page.mail-results .mail-privacy,
body.mail-page.mail-results .mail-guide,
body.mail-page.mail-results .mail-pane-input { display: none; }
body.mail-page.mail-results .mail-results-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}
body.mail-page.mail-results .mail-results-grid {
  flex: 1;
  min-height: 0;
  height: auto;
}

.mail-lead {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 36rem;
  text-align: center;
  flex-shrink: 0;
}
/* Paste-stage guide (kept off .mail-learn — that class is the per-row Details button). */
.mail-guide {
  flex-shrink: 0;
  width: 100%;
  max-width: 36rem;
  text-align: center;
}
.mail-guide > summary {
  list-style: none;
  cursor: pointer;
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-ink);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.mail-guide > summary::-webkit-details-marker { display: none; }
.mail-guide > summary:hover { background: rgba(18, 165, 148, 0.1); }
.mail-guide[open] > summary { margin-bottom: 0.35rem; }
.mail-privacy {
  margin: -0.15rem 0 0; max-width: 36rem; text-align: center; flex-shrink: 0;
  font-size: 0.8rem; font-weight: 600; color: var(--accent-ink);
}
.mail-guide-body {
  margin: 0; text-align: left; font-size: 0.82rem; line-height: 1.4; color: var(--ink-soft);
  padding: 0.65rem 0.85rem; border: 1px solid var(--line); border-radius: 10px;
  background: color-mix(in srgb, var(--card) 92%, #fff);
}
.mail-guide-body > p { margin: 0 0 0.45rem; }
.mail-guide-body ul, .mail-guide-body ol { margin: 0 0 0.45rem; padding-left: 1.1rem; }
.mail-guide-body li { margin: 0.12rem 0; }
.mail-guide-body strong { color: var(--ink); }
.mail-anno {
  margin: 0 0 0.4rem; padding: 0.5rem 0.65rem; border-radius: 8px; background: #fff;
  border: 1px dashed var(--line); font: 0.78rem/1.4 ui-monospace, Menlo, monospace; color: var(--ink);
}
.mail-anno p { margin: 0 0 0.3rem; }
.mail-examples {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.85rem; border-bottom: 1px solid var(--line); flex-shrink: 0;
  background: color-mix(in srgb, var(--card) 88%, #fff);
}
.mail-examples-label { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); }
.mail-examples .btn { font-size: 0.75rem; padding: 0.28rem 0.6rem; }

.mail-pane {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.mail-pane-input {
  max-width: 40rem;
  width: 100%;
  max-height: min(70dvh, 32rem);
  flex: 0 1 auto;
}

.mail-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 80%, #fff);
  flex-shrink: 0;
}
.mail-pane-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}
.mail-pane-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.mail-pane-input textarea {
  flex: 1;
  min-height: 12rem;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 0.75rem 0.9rem;
  font: 400 0.84rem/1.45 ui-monospace, Menlo, monospace;
  background: #fff;
  color: var(--ink);
  overflow: auto;
}
.mail-pane-input textarea:focus { outline: none; box-shadow: inset 0 0 0 2px rgba(18, 165, 148, 0.35); }

.mail-advanced {
  padding: 0.45rem 0.85rem 0.65rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.mail-advanced summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.mail-advanced input {
  margin-top: 0.4rem;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: #fff;
}

.mail-results-stage { width: 100%; min-height: 0; }
.mail-results-toolbar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  flex-shrink: 0;
}
#searchSender:disabled { opacity: 0.45; cursor: not-allowed; }
.mail-results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 0.65rem;
  align-items: stretch;
  min-height: 0;
}
.mail-results-grid > .mail-pane {
  height: 100%;
  min-height: 0;
}
body.mail-page.mail-results .mail-pane-head {
  padding: 0.4rem 0.7rem;
}
body.mail-page.mail-results .mail-pane-head h2 {
  font-size: 0.95rem;
}

.mail-pane-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.mail-pane-findings #findingsBody { background: #fff; }

.mail-view-body {
  padding: 0.5rem 0.7rem;
  background: #f0f4f7;
}
.mail-view-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 0.72rem/1.4 ui-monospace, Menlo, monospace;
  color: var(--ink);
}
.mail-hit {
  background: rgba(196, 140, 40, 0.45);
  outline: 2px solid rgba(196, 100, 20, 0.7);
  border-radius: 3px;
  padding: 0 0.12rem;
  scroll-margin-block: 2rem;
}
.mail-quote-callout {
  margin: 0.55rem 0 0;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(196, 140, 40, 0.14);
  font-size: 0.8rem;
  line-height: 1.4;
}
.mail-view-note { margin-top: 0.5rem; }

.mail-findings-inner { padding: 0.4rem 0.55rem 0.5rem; }
.mail-findings-empty {
  padding: 1rem 0.85rem;
  text-align: center;
  color: var(--ink-soft);
}
.mail-verdict {
  text-align: left;
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.4rem;
}
.mail-verdict h3 { margin: 0 0 0.1rem; font-family: var(--font-display); font-size: 0.95rem; }
.mail-verdict p { margin: 0; font-size: 0.75rem; line-height: 1.3; }
.mail-verdict.ok { background: rgba(18, 165, 148, 0.12); color: #0b5c52; }
.mail-verdict.caution { background: rgba(196, 140, 40, 0.14); color: #6b4a00; }
.mail-verdict.bad { background: rgba(196, 75, 75, 0.12); color: #8a1f1f; }

/* Dense checklist — one compact row per technical surface */
.mail-topics { display: grid; gap: 0.2rem; }

.mail-topic-wrap {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}
.mail-topic-wrap.on { box-shadow: 0 0 0 1.5px rgba(18, 165, 148, 0.28); }

.mail-topic-wrap.sev-high { background: rgba(180, 40, 40, 0.14); border-color: rgba(160, 30, 30, 0.35); }
.mail-topic-wrap.sev-mid  { background: rgba(196, 75, 75, 0.09); border-color: rgba(196, 75, 75, 0.28); }
.mail-topic-wrap.sev-low  { background: rgba(196, 100, 90, 0.06); border-color: rgba(196, 100, 90, 0.22); }
.mail-topic-wrap.caution  { background: rgba(196, 160, 40, 0.1); border-color: rgba(196, 160, 40, 0.3); }
.mail-topic-wrap.ok       { background: rgba(18, 165, 148, 0.07); border-color: rgba(18, 165, 148, 0.22); }
.mail-topic-wrap.na       { background: #eef1f4; border-color: rgba(7, 17, 26, 0.08); opacity: 0.68; }

.mail-topic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem;
  min-height: 2rem;
}
.mail-topic {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem 0.4rem 0.35rem 0.5rem;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  min-width: 0;
}
.mail-topic:disabled { cursor: not-allowed; }
.mail-topic-badge {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.16rem 0.32rem;
  border-radius: 999px;
  white-space: nowrap;
  text-align: center;
  background: rgba(7, 17, 26, 0.08);
  color: var(--ink-soft);
}
.mail-topic-wrap.sev-high .mail-topic-badge { background: rgba(140, 20, 20, 0.2); color: #6e1010; }
.mail-topic-wrap.sev-mid .mail-topic-badge  { background: rgba(180, 50, 50, 0.16); color: #8a1f1f; }
.mail-topic-wrap.sev-low .mail-topic-badge  { background: rgba(196, 90, 80, 0.14); color: #a04038; }
.mail-topic-wrap.caution .mail-topic-badge  { background: rgba(196, 160, 40, 0.2); color: #8a5a00; }
.mail-topic-wrap.ok .mail-topic-badge       { background: rgba(18, 165, 148, 0.16); color: #0b6f64; }
.mail-topic-wrap.na .mail-topic-badge       { background: rgba(7, 17, 26, 0.08); color: #6a7680; }

.mail-topic-text {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.4rem;
  align-items: baseline;
  min-width: 0;
}
.mail-topic-text b {
  font-size: 0.9rem;
  font-weight: 650;
  white-space: nowrap;
}
.mail-topic-text small {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Per-row Details — separate from paste-stage .mail-guide */
.mail-topic-row > .mail-learn {
  margin: 0 0.35rem 0 0;
  font-size: 0.74rem;
  padding: 0.22rem 0.55rem;
  flex-shrink: 0;
}
.mail-learn-spacer { width: 0.3rem; }
.mail-topic-wrap.na .mail-learn { display: none; }

.mail-topic-detail {
  border-top: 1px solid var(--line);
  padding: 0.5rem 0.65rem 0.6rem;
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.84rem;
  color: var(--ink-soft);
  animation: mail-detail-in 0.18s ease;
}
.mail-topic-detail ul { margin: 0.25rem 0 0; padding-left: 1rem; display: grid; gap: 0.25rem; }
.mail-topic-detail li.fail { color: #8a1f1f; }
.mail-topic-detail li.warn { color: #8a5a00; }
@keyframes mail-detail-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  .mail-topic-text { grid-template-columns: 1fr; gap: 0.05rem; }
  .mail-topic-text b { white-space: normal; }
  .mail-topic-text small { white-space: normal; }
}

.mail-domain-face {
  margin: 0.55rem 0 0.35rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: rgba(7, 17, 26, 0.04);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  color: var(--ink);
}
.mail-domain-label {
  display: block;
  font-family: var(--font-sans, inherit);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.2rem;
}
.mail-glyph { display: inline; }

.mail-path-compare {
  display: grid;
  gap: 0.2rem;
  margin: 0.35rem 0 0.5rem;
  font-size: 0.8rem;
}
.mail-path-compare code {
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: 0.04em;
}

.mail-findings-hint { margin: 0.65rem 0 0; }

.mail-trust {
  margin: 0.45rem 0 0.1rem;
  max-width: none;
  text-align: left;
}
.mail-trust-head {
  display: flex; align-items: baseline; gap: 0.5rem;
  font-size: 0.75rem; margin-bottom: 0.2rem;
}
.mail-trust-head strong { font-size: 0.95rem; }
.mail-trust-label { margin-left: auto; font-weight: 700; font-size: 0.68rem; letter-spacing: 0.03em; text-transform: uppercase; }
.mail-trust-track {
  height: 0.4rem; border-radius: 99px; background: rgba(0,0,0,0.08); overflow: hidden;
}
.mail-trust-track > span { display: block; height: 100%; border-radius: inherit; transition: width .25s ease; }
.mail-trust.ok .mail-trust-track > span { background: #1a9a7a; }
.mail-trust.ok .mail-trust-label, .mail-trust.ok strong { color: #0b6f64; }
.mail-trust.caution .mail-trust-track > span { background: #c4a035; }
.mail-trust.caution .mail-trust-label, .mail-trust.caution strong { color: #8a5a00; }
.mail-trust.bad .mail-trust-track > span { background: #c44b4b; }
.mail-trust.bad .mail-trust-label, .mail-trust.bad strong { color: #8a1f1f; }

.mail-next {
  border-top: 1px solid var(--line);
  padding: 0.55rem 0.75rem 0.7rem;
}
.mail-next .fine { margin: 0 0 0.3rem; font-size: 0.75rem; }
.mail-match-list { list-style: none; padding: 0; margin: 0.35rem 0 0; display: grid; gap: 0.25rem; }
.mail-findings-hint { margin: 0.45rem 0 0; font-size: 0.74rem; }
.fine.warn { color: #8a1f1f; }

@media (max-width: 860px) {
  /*
   * Mobile: Nested overflow-y on .mail-solo alone
   * still feels locked (and justify-content:center clips the top of tall paste cards).
   */
  html.mail-page,
  body.mail-page {
    height: auto;
    max-height: none;
    overflow: auto;
    overscroll-behavior: auto;
  }
  body.mail-page .mail-solo {
    flex: none;
    overflow: visible;
    justify-content: flex-start;
    padding: 0.65rem max(1.15rem, env(safe-area-inset-right, 0px)) 1.25rem max(1.15rem, env(safe-area-inset-left, 0px));
  }
  body.mail-page .top,
  body.mail-page .foot {
    padding-left: max(1.15rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.15rem, env(safe-area-inset-right, 0px));
  }
  body.mail-page:not(.mail-results) .mail-solo {
    justify-content: flex-start;
  }
  body.mail-page.mail-results .mail-results-stage {
    flex: none;
  }
  .mail-results-grid {
    grid-template-columns: 1fr;
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .mail-results-grid > .mail-pane {
    height: auto;
    max-height: none;
  }
  /* One mobile scroll surface avoids nested wheel/touch traps. */
  .mail-pane-scroll {
    max-height: none;
    overflow: visible;
  }
  .mail-pane-input { max-width: none; }
}
@media (max-height: 700px) {
  body.mail-page.mail-results .mail-verdict p { display: none; }
  body.mail-page.mail-results .mail-findings-hint { display: none; }
}
