#dialog:is([data-kind="mail-briefing"], [data-kind="mail-complete"]) {
  width: min(94vw, 750px, calc(100% - var(--phone-left, 0px) - var(--phone-right, 0px)));
  border-color: #263f46;
  background: #fcfaef;
}
#dialog:is([data-kind="mail-briefing"], [data-kind="mail-complete"]) .dialog-content {
  background: repeating-linear-gradient(120deg, #659b98 0 10px, #faf5df 10px 20px, #cc8a52 20px 30px, #faf5df 30px 40px) top / 100% 4px no-repeat;
}
#dialog[data-kind="mail-briefing"] #dialog-title {
  color: #213f46; margin-bottom: 14px; line-height: 1.15;
}
#dialog[data-kind="mail-briefing"] .dialog-close {
  color: #385455; background: #edf0e6; border-color: #9dafa4;
  min-width: 44px; min-height: 44px;
}

.glide-mail-briefing {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  align-items: stretch;
  gap: 10px 14px;
}

.mail-profile {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 138px;
  border: 1px solid #526970;
  border-radius: 11px;
  background: radial-gradient(ellipse at 52% 67%, #407c81, transparent 74%),
    linear-gradient(155deg, #193f54, #24556c 62%, #315a60);
}

.mail-profile::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(#dff7ec0d 1px, transparent 1px),
    linear-gradient(90deg, #dff7ec0d 1px, transparent 1px);
  background-size: 16px 16px;
}

.mail-profile > i { position: absolute; display: block; }
.mail-distant-ridge {
  inset: 24% 0 0;
  background: linear-gradient(#86b4b959, #91b7ab08);
  clip-path: polygon(0 47%,9% 47%,9% 38%,15% 38%,15% 46%,23% 46%,23% 51%,31% 51%,31% 44%,38% 44%,38% 26%,43% 26%,43% 41%,49% 41%,49% 50%,61% 50%,61% 46%,70% 46%,70% 36%,76% 36%,76% 28%,83% 28%,83% 42%,92% 42%,92% 35%,100% 35%,100% 100%,0 100%);
}

.mail-updraft {
  left: 33%; top: 15%; bottom: 34%; width: 15%;
  background: repeating-linear-gradient(170deg, transparent 0 6px, #a9e4e04a 7px 8px, transparent 9px 12px),
    linear-gradient(90deg, transparent, #95e8e423 48%, transparent);
  clip-path: polygon(0 0,100% 0,70% 100%,32% 100%);
}

.mail-track { inset: 0; }
.mail-track-low {
  background: #72e4d6;
  clip-path: polygon(8% 66%, 24% 46%, 33% 44%, 47% 57%, 57% 44%, 64% 41%, 72% 41%, 88% 51%,
    88% 53%, 72% 43%, 64% 43%, 57% 46%, 47% 60%, 33% 46%, 24% 48%, 8% 68%);
}
.mail-track-high {
  background: #ffd388;
  clip-path: polygon(8% 66%, 24% 49%, 34% 38%, 41% 21%, 52% 13%, 63% 12%, 72% 18%, 88% 51%,
    88% 54%, 71% 20%, 63% 14%, 52% 15%, 42% 23%, 35% 40%, 24% 51%, 8% 68%);
}

.mail-deck {
  width: 21%; height: 21%;
  background: linear-gradient(165deg, #c8ead8 0 23%, #70ad9e 24% 38%, #3e7875 39% 65%, #315b64 66%);
  clip-path: polygon(0 22%, 68% 0, 100% 16%, 100% 45%, 84% 50%, 84% 65%, 59% 74%, 59% 90%, 32% 100%, 32% 81%, 13% 69%, 13% 53%, 0 47%);
}
.mail-departure { left: -2%; top: 64%; }
.mail-relay { left: 36%; top: 57%; }
.mail-destination { left: 78%; top: 51%; }
.mail-relay-pad {
  left: 45%; top: 54%; width: 6%; height: 6%;
  background: #95fff0;
  clip-path: polygon(0 46%, 54% 22%, 54% 0, 100% 30%, 58% 88%, 58% 64%, 0 100%);
}
.mail-wind-gate {
  left: 63%; top: 5%; width: 6%; height: 20%;
  border: 3px solid #ffd083;
  box-shadow: inset 0 0 0 1px #805b40, 0 0 9px #ffcf862e;
  border-radius: 2px;
  transform: skewY(-13deg);
}
.mail-post-flag {
  left: 89%; top: 37%; width: 6%; height: 17%;
  background: #ffecc0;
  clip-path: polygon(0 0, 100% 0, 81% 22%, 100% 40%, 12% 40%, 12% 100%, 0 100%);
}
.mail-current-arrow {
  left: 37%; top: 28%; color: #ffe5a5;
  filter: drop-shadow(0 1px #234555);
}
.mail-current-arrow .glyph { width: 14px; height: 14px; }
.mail-profile-label {
  position: absolute;
  transform: translateX(-50%);
  color: #f2f9eb;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 1px 3px #142e39;
}
.mail-label-start { left: 13%; top: 82%; }
.mail-label-relay { left: 48%; top: 77%; }
.mail-label-end { left: 89%; top: 71%; }

.mail-route-choices { display: grid; gap: 8px; }
:is(.mail-route-choice, .mail-receipt, .mail-retry)[data-route="relay"] {
  --mail-paper: #e2f1e8; --mail-line: #8ab9aa; --mail-ink: #185d52; --mail-accent: #76c9b6;
}
:is(.mail-route-choice, .mail-receipt, .mail-retry)[data-route="direct"] {
  --mail-paper: #f8ecd6; --mail-line: #d4ad72; --mail-ink: #77501d; --mail-accent: #edba71;
}
.mail-route-choice {
  display: grid; grid-template-columns: 31px minmax(0, 1fr) 18px; gap: 9px; align-items: center;
  min-height: 64px; min-width: 0; padding: 9px 10px; text-align: left; border-radius: 8px;
  color: var(--mail-ink); border: 1px solid var(--mail-line); background: var(--mail-paper);
  box-shadow: 0 2px var(--mail-line);
}
.mail-route-mark {
  display: grid; place-items: center; width: 31px; height: 31px;
  border: 1px dashed var(--mail-ink); border-radius: 5px; background: #fff9ed80;
}
.mail-route-mark .glyph { width: 19px; height: 19px; }
.mail-route-copy, .mail-route-copy > span { display: block; }
.mail-route-copy strong { font-size: 17px; font-weight: 900; }
.mail-route-note { color: #384c49; font-size: 12px; line-height: 1.45; margin-top: 2px; }
.mail-route-best { margin-top: 3px; color: var(--mail-ink); font: 700 11px/1.25 var(--rounded); font-variant-numeric: tabular-nums; }
.mail-route-go .glyph, .mail-flight-controls .glyph { width: 16px; height: 16px; }
.mail-brief-foot {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding-top: 8px; border-top: 1px dashed #abb8a9;
}
.dialog-content .mail-flight-controls {
  display: flex; align-items: center; gap: 7px; margin: 0;
  color: #395350; font-size: 12px; line-height: 1.5;
}
.mail-free-choice, .mail-receipt-actions button, #dialog[data-kind="mail-complete"] .result-activity-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  min-width: 44px; min-height: 44px; border: 1px solid #99aaa0; border-radius: 7px; padding: 6px 11px;
  color: #37564d; background: #edf1e7; font: 800 13px/1.25 var(--rounded);
}
.mail-free-choice .glyph, .mail-receipt-actions .glyph { width: 16px; height: 16px; }
.mail-receipt-actions .mail-retry { color: var(--mail-ink); border-color: var(--mail-line); background: var(--mail-paper); }
.mail-route-choice:hover, .mail-free-choice:hover, .mail-receipt-actions button:hover { filter: brightness(.96); }
.mail-route-choice:active { transform: translateY(1px); box-shadow: none; }

#dialog[data-kind="mail-complete"] .dialog-content {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px 8px;
}
.mail-receipt {
  grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr);
  overflow: hidden; border: 1px solid #879d90; border-radius: 10px; background: #f5f5e9;
  font-variant-numeric: tabular-nums;
}
.mail-receipt-post {
  display: grid; align-content: center; justify-items: start; padding: 18px;
  background: linear-gradient(145deg, #254c51, #1f3a41); color: #f9f6e7;
}
.mail-receipt-address { display: flex; gap: 6px; align-items: center; font: 750 12px/1.35 var(--rounded); color: var(--mail-accent); }
.mail-receipt-address .glyph { width: 16px; height: 16px; }
#dialog[data-kind="mail-complete"] #dialog-title { margin: 3px 0 13px; font-size: clamp(22px, 3.2vw, 32px); line-height: 1.16; }
.mail-total-label { color: #deeadc; font-size: 12px; font-weight: 730; }
.mail-total { font: 850 clamp(25px, 4vw, 36px)/1.12 var(--rounded); letter-spacing: -.025em; }
.mail-reference { display: flex; flex-wrap: wrap; gap: 2px 5px; align-items: baseline; margin-top: 5px; font-size: 11px; line-height: 1.4; color: #e4eee0; }
.mail-delta { font-weight: 750; white-space: nowrap; }
.mail-faster { color: #216852; }
.mail-slower { color: #914d2b; }
.mail-reference .mail-faster { color: #a1e6c6; }
.mail-reference .mail-slower { color: #ffd2a6; }
.mail-receipt-log { padding: 14px 16px; align-self: center; min-width: 0; }
.mail-splits { width: 100%; border-collapse: collapse; color: #294a43; font-size: 13px; line-height: 1.35; }
.mail-splits th, .mail-splits td { padding: 8px 3px; text-align: right; white-space: nowrap; }
.mail-splits th:first-child { text-align: left; padding-left: 0; }
.mail-splits th:last-child, .mail-splits td:last-child { padding-right: 0; }
.mail-splits thead th { padding-top: 0; color: #53675f; font-size: 11px; font-weight: 750; }
.mail-splits tbody tr { border-top: 1px dashed #b8c3b2; }
.mail-splits tbody th { font-weight: 800; }
.mail-splits tbody td { font-weight: 740; }
.mail-splits tbody th i { display: inline-block; width: 6px; height: 6px; margin: 0 6px 2px 0; background: var(--mail-accent); outline: 1px solid var(--mail-ink); }
.mail-outcome {
  display: flex; flex-wrap: wrap; gap: 2px 9px; align-items: center; margin-top: 4px;
  color: #625134; font-size: 11px; font-weight: 740; line-height: 1.4;
}
.mail-outcome > span { display: inline-flex; gap: 3px; align-items: center; }
.mail-outcome .glyph { width: 14px; height: 14px; }
.dialog-content .mail-splits-empty { margin: 0; color: #53675f; }
.mail-delivery-context { grid-column: 1 / -1; }
#dialog[data-kind="mail-complete"] .mail-delivery-context > * { margin: 0; }
.mail-receipt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#dialog[data-kind="mail-complete"] .result-activity-footer {
  margin: 0; padding: 0; border: 0; align-self: end;
}
.mail-flight-chart { display: block; width: 100%; height: auto; border: 1px solid #536e70; border-radius: 10px; }

#glide-mail-pilot {
  position:absolute; z-index:2; right:max(14px,var(--safe-right,0px)); top:max(76px,calc(var(--top,11px) + 58px));
  width:clamp(177px,17vw,209px); padding:6px 7px; border:1px solid #baa574; border-radius:8px;
  color:#fff1ce; background:#253b43f5; box-shadow:0 2px #172c3580; pointer-events:none;
  text-align:left; font-family:inherit; font-variant-numeric:tabular-nums;
}
#glide-mail-pilot[hidden] { display:none; }
.mail-pilot-head { display:flex; align-items:center; justify-content:space-between; gap:5px; margin-bottom:4px; line-height:1.15; }
.mail-pilot-head strong { font-size:13px; font-weight:860; color:#ffddb0; }
.mail-pilot-phase { color:#eadfbf; font-size:10px; font-weight:790; }
#glide-mail-pilot[data-phase="return"] .mail-pilot-phase { color:#ffbba2; }
#glide-mail-pilot[data-phase="climb"] .mail-pilot-phase { color:#a7e5df; }
.mail-pilot-grid { display:grid; grid-template-columns:minmax(60px,.82fr) minmax(0,1fr); gap:6px; align-items:center; }
.mail-pilot-plot { margin:0; min-width:0; padding-bottom:2px; border:1px solid #6d817b; border-radius:5px; background:#182e38; }
.mail-pilot-plot svg { display:block; width:100%; height:auto; }
.mail-pilot-plot text { font:740 9px/1 system-ui,sans-serif; fill:#d2e2d4; }
.mail-pilot-axes { fill:none; stroke:#657b75; stroke-width:.9; stroke-dasharray:2 3; }
.mail-pilot-aperture { fill:#f1d29512; stroke:#cda86f; stroke-width:1; }
.mail-pilot-corners { fill:none; stroke:#ffdd94; stroke-width:3; stroke-linejoin:round; }
.mail-pilot-live-point { fill:#a2ffe921; stroke:#a2ffe9; stroke-width:1.8; }
.mail-pilot-miss-point { fill:none; stroke:#ffa994; stroke-width:2.8; stroke-linecap:round; stroke-linejoin:round; filter:drop-shadow(0 .6px 1px #29313d); }
.mail-pilot-plot figcaption { color:#ccd9ce; text-align:center; font-size:9px; line-height:1.1; font-weight:700; }
.mail-pilot-alignment[data-live] { color:#b1ffed; font-size:10px; }
.mail-pilot-alignment[data-live]::before { content:""; display:inline-block; width:6px; height:6px; margin-right:2px; border:1px solid #a2ffe9; border-radius:50%; vertical-align:.1em; }
.mail-pilot-copy { display:grid; gap:2px; min-width:0; line-height:1.25; }
.mail-pilot-action { font-size:12px; font-weight:820; }
.mail-pilot-detail { color:#e2e7d3; font-size:10px; font-weight:700; }
.mail-pilot-last { display:grid; gap:1px; margin:3px 0 0; padding:3px 0 0; border-top:1px solid #82998a88; }
.mail-pilot-last[hidden] { display:none; }
.mail-pilot-last dt { color:#ffbda7; font-size:10px; font-weight:820; }
.mail-pilot-last dd { margin:0; color:#f6ebd6; font-size:10px; font-weight:720; }
#glide-mail-pilot[data-instrument="landing"] { border-color:#80b8ad; background:#1f3943f5; }
#glide-mail-pilot[data-instrument="landing"] .mail-pilot-head strong { color:#c1ebdc; }
#glide-mail-pilot[data-dock="finish"] { border-color:#c9a478; }
#glide-mail-pilot[data-dock="finish"] .mail-pilot-head strong { color:#ffe0ad; }
.mail-landing-action { display:block; margin-bottom:5px; }
#glide-mail-pilot:is([data-phase="brake"], [data-phase="low"]) .mail-landing-action { color:#ffcf9d; }
#glide-mail-pilot[data-phase="fold"] .mail-landing-action { color:#bcffd7; }
#app[data-play="glide"] #race .touch-item[data-mail-fold-ready] {
  --control-face:#d3f7d7;
  --control-down:#b1e5be;
  --control-edge:#355f58;
  box-shadow:var(--control-depth), 0 0 0 2px #c8ffda;
}
.mail-landing-metrics { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; margin:0; }
.mail-landing-metrics > div { padding:3px 5px; border-left:2px solid #6b9d94; border-radius:2px; background:#152d37; }
.mail-landing-metrics dt { color:#c5d9d1; font-size:10px; font-weight:740; white-space:nowrap; }
.mail-landing-metrics dd { margin:0; color:#fff4db; font-size:11px; font-weight:820; white-space:nowrap; }
@media (orientation:landscape) and (max-height:445px) {
  #glide-mail-pilot { width:177px; right:var(--phone-right,12px); top:calc(var(--top,8px) + 52px); padding:5px; }
}
@media (orientation:landscape) and (max-height:370px) and (min-aspect-ratio:2/1) {
  #glide-mail-pilot[data-instrument="gate"] { top:calc(var(--top,8px) + 48px); }
  .mail-pilot-last { gap:0; margin-top:1px; padding-top:2px; }
}
@media (orientation:portrait) and (max-width:520px) {
  #glide-mail-pilot { width:123px; right:max(10px,var(--safe-right,0px)); top:max(77px,calc(var(--top,8px) + 57px)); padding:5px; }
  .mail-pilot-grid { grid-template-columns:minmax(0,1fr); gap:4px; }
  .mail-pilot-plot { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; padding:0 3px; }
  .mail-pilot-plot figcaption { width:1em; font-size:9px; }
  .mail-pilot-plot:has(.mail-pilot-alignment[data-live]) { display:block; padding:0 3px 2px; }
  .mail-pilot-plot:has(.mail-pilot-alignment[data-live]) svg { width:min(100%, 92px); margin:auto; }
  .mail-pilot-plot .mail-pilot-alignment[data-live] { width:auto; font-size:10px; }
  .mail-landing-metrics > div { padding-inline:3px; }
  .mail-landing-metrics dd { font-size:10px; }
  #app[data-play="glide"]:has(#glide-mail-pilot:not([hidden])) .festival-overlay {
    left:max(10px,var(--safe-left,0px)); width:calc(100vw - 152px - var(--safe-left,0px) - var(--safe-right,0px));
    transform:none; align-items:stretch;
  }
}

@media (orientation: landscape) and (max-height: 440px) {
  #dialog:is([data-kind="mail-briefing"], [data-kind="mail-complete"]) .dialog-content { padding: 10px 13px; }
  #dialog[data-kind="mail-briefing"] #dialog-title { font-size: 24px; line-height: 1.15; margin: 0 48px 8px 0; }
  #dialog[data-kind="mail-briefing"] .dialog-close { top: 4px; right: 8px; background: transparent; border: 0; }
  .glide-mail-briefing { grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr); gap: 6px 8px; }
  .mail-profile { min-height: 95px; }
  .mail-route-choices { gap: 5px; }
  .mail-route-choice { min-height: 48px; grid-template-columns: 23px minmax(0,1fr) 14px; gap: 6px; padding: 4px 7px; }
  .mail-route-mark { width: 23px; height: 23px; }
  .mail-route-mark .glyph, .mail-route-go .glyph { width: 14px; height: 14px; }
  .mail-route-copy strong { font-size: 15px; line-height: 1.2; }
  .mail-route-note { font-size: 12px; line-height: 1.28; margin: 1px 0 0; }
  .mail-route-best { margin-top: 1px; }
  .mail-brief-foot { padding-top: 3px; }
  .dialog-content .mail-flight-controls { font-size: 12px; }
  #dialog[data-kind="mail-complete"] .dialog-content { gap: 6px; }
  .mail-receipt { grid-template-columns: minmax(0,.78fr) minmax(0,1.22fr); }
  .mail-receipt-post { padding: 8px 12px; }
  .mail-receipt-log { padding: 8px 10px; }
  #dialog[data-kind="mail-complete"] #dialog-title { margin: 2px 0 5px; font-size: 22px; }
  .mail-total { font-size: 26px; }
  .mail-splits th, .mail-splits td { padding-block: 5px; }
  .mail-splits thead th { padding-top: 0; }
  .mail-outcome, .mail-reference { margin-top: 2px; }
  .mail-receipt-actions button, #dialog[data-kind="mail-complete"] .result-activity-link { padding-inline: 8px; font-size: 12px; }
  #dialog[data-kind="mail-complete"] .voyage-handoff { display: flex; align-items: stretch; }
  #dialog[data-kind="mail-complete"] .voyage-passage-info { flex: 1; padding-block: 2px; }
  #dialog[data-kind="mail-complete"] .voyage-handoff-foot { flex: 1; border: 0; }
  #dialog[data-kind="mail-complete"] .voyage-handoff-foot button { min-height: 44px; }
}
@media (max-width: 560px) and (orientation: portrait) {
  .glide-mail-briefing { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .mail-profile { min-height: 0; aspect-ratio: 2.7; }
  .mail-brief-foot { gap: 6px; }
  .mail-route-choices { gap: 6px; }
  #dialog[data-kind="mail-complete"] .dialog-content { display: flex; flex-direction: column; align-items: stretch; padding: 16px; gap: 8px; }
  .mail-receipt { grid-template-columns: minmax(0, 1fr); }
  .mail-receipt-post { padding: 13px 16px; }
  #dialog[data-kind="mail-complete"] #dialog-title { margin: 3px 0 8px; }
  .mail-receipt-actions { display: grid; grid-template-columns: repeat(2,1fr); }
  #dialog[data-kind="mail-complete"] .result-activity-footer { align-self: stretch; }
  #dialog[data-kind="mail-complete"] .result-activity-link { width: 100%; }
}
