/* The Email tab (js/tabs/email.js): four steps in a fixed order (Who, What, Write, Review and send), a bar at the
   bottom of the phone that always says what will go, then History. Phone first: one step open at a time, every
   control at least 44px, fields 16px. From 1000px the steps sit beside a "Ready to send" summary, and the message
   sits beside its preview. Colours are tokens only, so dark mode and every accent follow. */

.email-tab { display: grid; gap: var(--space-16); max-width: 1180px; padding-bottom: 96px; }
.email-tab h3 { font-family: var(--font-display); font-size: 21px; font-weight: 500; letter-spacing: -.01em; margin: 0 0 var(--space-16); }
.email-tab [hidden] { display: none !important; }
.et-sr, .et-result.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.et-quiet { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.5; }
.et-under { display: block; margin: 0 0 var(--space-4); }
.et-check-hint { margin: var(--space-4) 0 0; padding-left: var(--space-32); font-size: 13px; }
.et-para { margin: 0; font-size: 15px; line-height: 1.55; }
.et-sub { margin: var(--space-16) 0 var(--space-8); font-size: 14px; font-weight: 700; color: var(--muted); }
.et-h4 { margin: var(--space-16) 0 var(--space-8); font-size: 15px; font-weight: 800; }
.et-label { display: block; font-size: 14px; font-weight: 700; margin-bottom: var(--space-8); }
.et-field { display: grid; gap: 0; margin-bottom: var(--space-16); }
.et-input {
  width: 100%; box-sizing: border-box; min-height: 44px; padding: var(--space-8) var(--space-16); font: inherit; font-size: 16px; line-height: 1.4;
  background: var(--card); color: var(--text); border: 1.5px solid var(--control); border-radius: var(--radius);
}
textarea.et-input { min-height: 240px; resize: vertical; line-height: 1.55; }
.et-actions { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-top: var(--space-16); }
.et-actions.center { justify-content: center; }
.et-row { display: flex; flex-wrap: wrap; gap: var(--space-8); align-items: center; margin-top: var(--space-8); }
.email-tab .btn { min-height: 44px; }
.email-tab .btn.big { min-height: 52px; font-size: 16px; }

/* Email not switched on, or not yours to send. */
.et-banner { display: flex; gap: var(--space-8); align-items: flex-start; padding: var(--space-16) var(--space-16); background: var(--info-soft); border: 1px solid var(--info); border-radius: var(--radius); font-size: 14px; line-height: 1.5; }
.et-banner.in { margin: 0 0 var(--space-16); }
.et-banner .material-symbols-rounded { flex: none; margin-top: 0; }
.et-result { padding: var(--space-16) var(--space-16); border-radius: var(--radius); background: var(--good-soft); border: 1px solid var(--good); font-size: 14px; line-height: 1.5; }
.et-result.bad { background: var(--error-soft); border-color: var(--error); }
.et-warn { color: var(--error); font-size: 14px; margin: var(--space-8) 0 0; }

/* The layout: steps, and from 1000px the summary beside them. */
.et-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-16); align-items: start; }
.et-main { display: grid; gap: var(--space-16); min-width: 0; }
.et-aside { display: none; }
.et-only-narrow { display: block; }

.et-linkbtn {
  display: inline-flex; align-items: center; gap: var(--space-8); min-height: 44px; padding: 0 var(--space-4); font: inherit; font-size: 14px; color: var(--muted);
  background: transparent; border: 0; cursor: pointer; text-align: left;
}
.et-linkbtn span:not(.material-symbols-rounded) { text-decoration: underline; text-underline-offset: 3px; }
.et-linkbtn .material-symbols-rounded { font-size: 20px; }
.et-to-left { margin-left: var(--space-48); }

/* The steps. */
.et-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
.et-step { scroll-margin-top: 124px; background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius-card); }
.et-step.open { border-color: var(--accent); }
.email-tab .et-step-h { margin: 0; font-family: inherit; font-size: inherit; letter-spacing: 0; }
.et-step-head {
  display: flex; align-items: center; gap: var(--space-16); width: 100%; min-height: 60px; box-sizing: border-box; padding: var(--space-8) var(--space-16); text-align: left;
  font: inherit; color: inherit; background: transparent; border: 0; border-radius: var(--radius-card); cursor: pointer;
}
.et-step-head:hover { background: var(--surface); }
.et-num { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; font-size: 14px; font-weight: 800; border: 2px solid var(--control); }
.et-num .material-symbols-rounded { font-size: 18px; }
.et-step.open .et-num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.et-step.done .et-num { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }
.et-step-main { display: grid; gap: var(--space-4); flex: 1; min-width: 0; }
.et-step-title { font-size: 15px; font-weight: 700; color: var(--muted); }
.et-step.open .et-step-title { font-size: 17px; font-weight: 800; color: var(--text); }
.et-step-sum { font-size: 16px; font-weight: 700; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.et-step-act { display: inline-flex; align-items: center; gap: var(--space-4); flex: none; font-size: 14px; font-weight: 700; color: var(--accent-dark); }
.et-step.open .et-step-act .material-symbols-rounded { transform: rotate(180deg); }
.et-step-body { padding: var(--space-4) var(--space-16) var(--space-16); }

/* Choosing: radios drawn as rows, or as chips. */
.et-choices { display: grid; gap: var(--space-8); }
.et-choices.small { gap: var(--space-8); }
.et-choice {
  position: relative; display: flex; align-items: center; gap: var(--space-16); min-height: 48px; box-sizing: border-box; padding: var(--space-8) var(--space-16); cursor: pointer;
  background: var(--card); border: 1.5px solid var(--control); border-radius: var(--radius);
}
.et-choice:hover { background: var(--surface); }
/* The radios and ticks are the app's own (css/shell.css draws them 24px inside a 44px target on a phone). */
.et-choice input { flex: none; accent-color: var(--accent); cursor: pointer; }
.et-choice input:disabled { cursor: default; }
.et-choice:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.et-choice:has(input:disabled) { opacity: .75; cursor: default; }
.et-choice-text { display: grid; gap: 0; flex: 1; min-width: 0; }
.et-choice-main { font-size: 15px; font-weight: 600; }
.et-choice:has(input:checked) .et-choice-main { color: var(--accent-dark); font-weight: 800; }
.et-choice-hint, .et-choice-note { font-size: 13px; color: var(--muted); }
.et-choice:has(input:checked) .et-choice-hint, .et-choice:has(input:checked) .et-choice-note { color: var(--accent-dark); }
.et-count { font-size: 14px; font-weight: 700; color: var(--muted); }
.et-choice:has(input:checked) .et-count { color: var(--accent-dark); }
.et-choices.chips { display: flex; flex-wrap: wrap; }
.et-choices.chips .et-choice { border-radius: var(--radius-pill); min-height: 44px; padding: var(--space-8) var(--space-16); gap: var(--space-8); }
.et-choices.chips .et-choice input { position: absolute; inset: 0; width: 100% !important; height: 100% !important; margin: 0; opacity: 0; border-radius: var(--radius-pill); }
.et-choices.chips .et-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.et-choices.chips .et-choice:has(input:checked) { border-width: 2px; }
.et-choice-wrap { display: grid; gap: var(--space-8); }
.et-detail { padding: var(--space-4) 0 var(--space-4) var(--space-16); border-left: 3px solid var(--accent-soft); display: grid; gap: var(--space-8); }
.et-checks { display: flex; flex-direction: column; gap: var(--space-4); max-height: 280px; overflow: auto; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.et-check { flex: none; display: flex; align-items: center; gap: var(--space-16); min-height: 44px; padding: var(--space-4) var(--space-8); cursor: pointer; border-radius: var(--radius-sm); }
.et-check:hover { background: var(--surface); }
.et-check input { flex: none; accent-color: var(--accent); }
.et-check > span { display: grid; min-width: 0; }
.et-more { margin-top: var(--space-16); }
.et-more > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 700; font-size: 14px; color: var(--muted); }
.et-more-body { display: grid; gap: var(--space-4); padding-bottom: var(--space-8); }
.et-more .check-row { min-height: 44px; margin: 0; }

/* Step 3: write, and the preview. */
.et-seg-wrap { display: inline-flex; padding: var(--space-4); gap: var(--space-4); margin-bottom: var(--space-16); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); }
.et-seg {
  min-height: 44px; padding: 0 var(--space-24); cursor: pointer; font: inherit; font-size: 14px; font-weight: 700;
  background: transparent; color: var(--muted); border: 0; border-radius: var(--radius-pill);
}
.et-seg[aria-pressed="true"] { background: var(--card); color: var(--accent-dark); box-shadow: var(--shadow); }
.et-write { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.et-pane, .et-step-body, .et-review, .et-write-wrap { min-width: 0; }
.et-write[data-view="edit"] .prev, .et-write[data-view="preview"] .edit { display: none; }
.et-label-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) var(--space-16); margin-bottom: var(--space-8); }
.et-label-row .et-label { margin: 0 auto 0 0; }
.et-draft { margin-top: var(--space-4); }
.et-locked .et-input { opacity: .75; }
.et-empty { margin: 0; padding: var(--space-16); text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.et-warn-box { margin: 0 0 var(--space-16); padding: var(--space-8) var(--space-16); background: var(--error-soft); border: 1px solid var(--error); border-radius: var(--radius); font-size: 14px; }
.et-for { margin-bottom: var(--space-8); }
.et-for-row { display: flex; align-items: center; gap: var(--space-4); }
.et-for select { flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 16px; padding: var(--space-8) var(--space-16); border: 1.5px solid var(--control); border-radius: var(--radius); background: var(--card); color: var(--text); }

/* Step 4: when, and the summary. */
.et-sched { display: grid; gap: var(--space-8); margin-top: var(--space-16); }
.et-sum { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-8) var(--space-16); margin: 0 0 var(--space-16); font-size: 15px; }
.et-sum dt { color: var(--muted); font-size: 14px; }
.et-sum dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.et-summary { display: grid; gap: var(--space-8); }
.et-summary h3 { margin: 0 0 var(--space-8); font-size: 22px; }
.et-icons { display: flex; gap: var(--space-4); margin: var(--space-4) 0; }
.et-iconbtn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 64px; min-height: 52px; padding: var(--space-4) var(--space-8); cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: transparent; border: 0; border-radius: var(--radius);
}
.et-iconbtn:hover { background: var(--surface); }
.et-iconbtn:disabled { opacity: .55; cursor: default; }
.et-iconbtn[aria-disabled="true"] { opacity: .65; }
.et-send { width: 100%; justify-content: center; }
.et-meterbox { margin-top: var(--space-16); display: grid; gap: var(--space-8); }
.et-meter { height: 10px; border-radius: var(--radius-pill); background: var(--track); overflow: hidden; border: 1px solid var(--border-strong); }
.et-meter span { display: block; height: 100%; background: var(--good); border-radius: var(--radius-pill); }
.et-meter.tone-low span { background: var(--warning); }
.et-meter.tone-full span { background: var(--error); }
.et-meter-words { font-size: 13px; color: var(--muted); }

/* The bar at the bottom of the phone: what will go, and Send within reach. It rides above the bottom navigation. */
.et-bar {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 26; display: flex; align-items: center; gap: var(--space-8);
  max-width: 760px; margin-inline: auto; padding: var(--space-8) var(--space-8) var(--space-8) var(--space-16); background: var(--card); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow-lg);
}
.et-bar-sum { display: grid; flex: 1; min-width: 0; min-height: 44px; padding: var(--space-4) var(--space-8); text-align: left; font: inherit; color: inherit; background: transparent; border: 0; border-radius: var(--radius); cursor: pointer; }
.et-bar-sum:hover { background: var(--surface); }
.et-bar-main { font-size: 16px; font-weight: 800; }
.et-bar-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.et-bar-send { flex: none; min-height: 48px; padding-inline: var(--space-16); }

/* Sent, and scheduled. */
.et-sent { padding: var(--space-24) var(--space-16); text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); display: grid; justify-items: center; gap: var(--space-8); }
.et-sent h3 { margin: var(--space-4) 0 0; font-size: 26px; }
.et-sent .et-para { max-width: 46ch; }
.et-sent-tick { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--good-soft); color: var(--good); border: 2px solid var(--good); }
.et-sent-tick .material-symbols-rounded { font-size: 28px; }

/* History and what is scheduled. */
.et-lower { display: grid; gap: var(--space-8); }
.et-history-wrap { padding: 0 var(--space-4); }
.et-history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.et-history-list li { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-8); align-items: baseline; padding: var(--space-8) 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.et-history-count { font-variant-numeric: tabular-nums; }
.et-history-when { color: var(--muted); font-size: 13px; margin-left: auto; }
.et-history-wrap > summary { gap: var(--space-8); list-style: none; }
.et-history-wrap > summary::-webkit-details-marker { display: none; }
.et-history-wrap > summary .material-symbols-rounded { color: var(--accent-dark); transition: transform .15s; }
.et-history-wrap[open] > summary .material-symbols-rounded { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .et-history-wrap > summary .material-symbols-rounded { transition: none; } }
.et-history-wrap > summary .et-history-h { font-family: var(--font-display); font-size: 22px; font-weight: 500; letter-spacing: -.01em; margin: 0; color: var(--text); }
.et-fine { font-size: 13px; margin-top: var(--space-16); }
.et-skiplist { list-style: none; margin: var(--space-8) 0; padding: 0; display: grid; font-size: 14px; }
.et-skiplist li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4) var(--space-16); padding: var(--space-8) 0; border-bottom: 1px solid var(--border); }
.et-sheet { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
.et-sheet > *, .et-preview { min-width: 0; }
.et-preview .mail-preview { max-width: 100%; }

@media (max-width: 640px) {
  .email-tab { gap: var(--space-16); padding-bottom: 176px; }
  .et-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .email-tab input, .email-tab textarea, .email-tab select { font-size: 16px; }
  .et-icons { justify-content: space-between; }
  .et-iconbtn { flex: 1; }
}

/* A laptop: the steps with the summary beside them, the message beside its preview. */
@media (min-width: 1000px) {
  .email-tab { padding-bottom: 0; }
  .et-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-24); }
  .et-aside { display: block; position: sticky; top: 112px; padding: var(--space-16); background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius-card); }
  .et-only-narrow, .et-narrow-only, .et-bar { display: none !important; }
  .et-write { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-24); }
  .et-write[data-view] .prev, .et-write[data-view] .edit { display: block; }
}

@media (prefers-reduced-motion: no-preference) {
  .et-step-act .material-symbols-rounded { transition: transform .15s; }
}
@media (prefers-reduced-motion: reduce) {
  .et-step-act .material-symbols-rounded { transition: none; }
}

/* While the bar is showing, messages ride above it instead of over it. */
@media (max-width: 999px) {
  body:has(.tab-panel.active .email-tab .et-bar:not([hidden])) #toasts { bottom: calc(150px + env(safe-area-inset-bottom)); }
}
@media (min-width: 641px) and (max-width: 999px) {
  body:has(.tab-panel.active .email-tab .et-bar:not([hidden])) #toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
