:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #242424;
  background: #f5f5f5;
  font-synthesis: none;
  --teams-purple: #5b5fc7;
  --teams-purple-dark: #4f52b2;
  --teams-purple-soft: #f0f0ff;
  --teams-border: #d1d1d1;
  --teams-muted: #616161;
  --teams-success: #107c10;
  --panel: #ffffff;
}

* { box-sizing: border-box; }

.skip-link {
  position: absolute;
  top: -60px;
  left: 8px;
  z-index: 1000;
  padding: 12px 18px;
  border-radius: 4px;
  background: var(--teams-purple);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  transition: top .15s ease;
}

.skip-link:focus {
  top: 8px;
  outline: 2px solid #242424;
  outline-offset: 2px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f5f5f5;
}

button,
input,
select,
textarea { font: inherit; }

button,
select { cursor: pointer; }

.app-header {
  min-height: 82px;
  display: grid;
  grid-template-columns: auto 1px minmax(280px, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  padding: 12px 28px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
}

.district-logo {
  width: 156px;
  height: auto;
  display: block;
}

.header-divider {
  width: 1px;
  height: 40px;
  background: #d1d1d1;
}

.app-header h1 {
  margin: 0 0 3px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 650;
}

.app-header p {
  margin: 0;
  color: var(--teams-muted);
  font-size: 13px;
}

.allowlist-banner {
  margin: 0;
  padding: 10px 28px;
  background: #fdf2f3;
  border-bottom: 1px solid #a4262c;
  color: #a4262c;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.allowlist-banner[hidden] { display: none; }

.demo-badge {
  padding: 5px 10px;
  border: 1px solid #e2c661;
  border-radius: 4px;
  color: #6b5300;
  background: #fff7d6;
  font-size: 12px;
  font-weight: 650;
}

.educator-block {
  min-width: 170px;
  padding-left: 20px;
  border-left: 1px solid #e0e0e0;
  text-align: right;
}

.educator-block strong,
.educator-block span { display: block; }
.educator-block strong { font-size: 14px; }
.educator-block span { margin-top: 2px; color: var(--teams-muted); font-size: 12px; }

.app-shell {
  min-height: calc(100vh - 82px);
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
}

.workflow {
  padding: 26px 18px;
  background: #f0f0f0;
  border-right: 1px solid #d1d1d1;
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 10px 22px;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 46px;
  bottom: -3px;
  left: 26px;
  width: 2px;
  background: #c7c7c7;
}

.step-number {
  position: relative;
  z-index: 1;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid #b3b3b3;
  border-radius: 50%;
  color: #616161;
  background: #f0f0f0;
  font-size: 13px;
  font-weight: 700;
}

.step.is-current .step-number {
  border-color: var(--teams-purple);
  color: #fff;
  background: var(--teams-purple);
  box-shadow: 0 0 0 3px #dedfff;
}

.step.is-complete .step-number {
  border-color: var(--teams-success);
  color: transparent;
  background: var(--teams-success);
}

.step.is-complete .step-number::before {
  content: "✓";
  position: absolute;
  color: #fff;
  font-size: 15px;
}

.step-content { min-width: 0; }

.step label,
.step-label {
  display: block;
  margin: 4px 0 8px;
  font-size: 14px;
  font-weight: 650;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.retry-button {
  flex: none;
  min-height: 44px;
  min-width: 44px;
  margin-top: 8px;
  padding: 5px 12px;
  border: 1px solid #b3b3b3;
  border-radius: 4px;
  color: #242424;
  background: #fff;
  font-size: 12px;
  font-weight: 650;
}

.retry-button:hover { background: #f5f5f5; }

input:focus,
textarea:focus,
button:focus-visible,
.picker-input:focus {
  outline: 2px solid var(--teams-purple);
  outline-offset: 2px;
}

/* --- Unified class + student picker (WW-89) --------------------------- */

.picker-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

/* `display: flex` above and the `[hidden]` UA rule have equal specificity, so
   without this the later (author) rule would win and the element would never
   actually hide. */
.picker-crumbs[hidden],
.picker-selected[hidden],
.contact-list[hidden] {
  display: none;
}

/* The whole crumb is one button — not a label plus a small nested ✕ button —
   so the click/tap target is the full pill (comfortably over 44px) rather
   than a 24px circle (WW-89 opus review P2-10). */
.picker-crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  max-width: 100%;
  padding: 4px 12px;
  border: 1px solid #d9d9f2;
  border-radius: 999px;
  color: #3b3c70;
  background: var(--teams-purple-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
}

.picker-crumb:hover { background: #e2e2ff; }

.picker-crumb span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-crumb-glyph {
  flex: none;
  font-size: 13px;
  line-height: 1;
}

/* Anchors the popup: relative positioning lives on the field itself (not a
   wrapper that also contains the crumbs or the results-count line), so the
   panel's `top: 100%` sits directly under the input with no gap, and its
   width matches the field exactly instead of a separate, wider minimum
   spilling into the Compose card next to it (WW-89 opus review — visual).
   This CSS was inert until the opus re-review (finding #1): the panel markup
   was a *sibling* of .picker-field in the HTML, so it anchored to the
   nearest positioned ancestor up the tree (#class-step) instead of this
   element. The panel is now nested inside .picker-field in index.html.
   The 20px margin-bottom that the generic `input` rule (below) puts on
   #picker-input is zeroed on .picker-input and moved here instead: as a
   margin on the field's own box it doesn't affect the field's content
   height (and therefore doesn't affect the panel's `top: 100%`), but still
   preserves the original spacing before the next element in the step. */
.picker-field {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 20px;
}

.picker-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  margin-bottom: 0;
  padding: 8px 10px;
  border: 1px solid #b3b3b3;
  border-radius: 4px;
  color: #242424;
  background: #fff;
  font-size: 13px;
}

.picker-input:disabled {
  color: #8a8a8a;
  background: #f7f7f7;
  cursor: not-allowed;
}

.picker-clear {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #b3b3b3;
  border-radius: 4px;
  color: #616161;
  background: #fff;
  font-size: 14px;
}

.picker-clear:hover { background: #f5f5f5; }

.picker-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-width: calc(100vw - 24px);
  max-height: min(360px, calc(100vh - 220px));
  overflow-y: auto;
  border: 1px solid var(--teams-border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}

/* The result-count line lives inside the panel, as its header — not floating
   between the field and the panel, which used to read as a detached gap. */
.picker-count {
  margin: 0;
  padding: 8px 10px;
  border-bottom: 1px solid #ececec;
  color: var(--teams-muted);
  font-size: 11px;
}

.picker-listbox {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.picker-group {
  list-style: none;
}

.picker-group-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.picker-group-label {
  margin: 4px 2px 2px;
  padding: 4px 8px 0;
  color: var(--teams-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.picker-option {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.picker-option:hover {
  background: var(--teams-purple-soft);
}

/* Distinct from :hover (background tint only) and from the default
   ~1.1:1 tint-on-white the option previously relied on as its only focus
   affordance: a 2px inset outline in the accent color clears the ≥3:1
   non-text-contrast bar and is visibly different from a plain hover.
   Outlines are solid color, not motion, so this is reduced-motion safe. */
.picker-option.is-active {
  background: var(--teams-purple-soft);
  outline: 2px solid var(--teams-purple);
  outline-offset: -2px;
}

.picker-option .option-title {
  overflow: hidden;
  color: #242424;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-option .option-meta {
  overflow: hidden;
  color: var(--teams-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-empty {
  padding: 14px 10px;
  color: var(--teams-muted);
  font-size: 12px;
  text-align: center;
}

.picker-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d1d1d1;
  border-radius: 4px;
  background: #f7f7f7;
}

#picker-selected-summary {
  overflow: hidden;
  color: #242424;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-button {
  flex: none;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  color: var(--teams-purple);
  background: none;
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
}

.link-button:hover { background: var(--teams-purple-soft); }

/* --- Parent-contact list (WW-89) --------------------------------------- */

.contact-progress {
  margin: 6px 0 0;
  color: var(--teams-muted);
  font-size: 12px;
}

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

.contact-option {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid #b3b3b3;
  border-radius: 4px;
  color: #242424;
  background: #fff;
  font-size: 12px;
  text-align: left;
}

.contact-option:hover { background: #f5f5f5; }

.contact-option.is-selected {
  border-color: var(--teams-purple);
  background: var(--teams-purple-soft);
}

.contact-option .option-meta {
  color: var(--teams-muted);
  font-size: 11px;
}

/* --- Loading skeleton (WW-89) ------------------------------------------ */

.skeleton {
  background: linear-gradient(90deg, #ececec 25%, #f5f5f5 50%, #ececec 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.3s ease-in-out infinite;
  color: transparent !important;
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.step-value {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  color: var(--teams-muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-area {
  min-width: 0;
  padding: 22px 24px 30px;
}

.recipient-bar {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 16px;
  border: 1px solid #d9d9f2;
  border-radius: 6px;
  background: var(--teams-purple-soft);
  color: #3b3c70;
  font-size: 13px;
}

.recipient-bar strong { flex: 0 0 auto; }

#recipient-summary {
  min-width: 0;
  overflow-wrap: anywhere;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(340px, .92fr) minmax(390px, 1.08fr);
  gap: 18px;
  align-items: start;
}

.composer,
.preview-panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--teams-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0 0 5px;
  font-size: 18px;
  font-weight: 650;
}

.section-heading p {
  margin: 0;
  color: var(--teams-muted);
  font-size: 12px;
  line-height: 1.45;
}

.language-control {
  flex: 0 0 auto;
  margin-left: 16px;
}

.language-control label {
  display: block;
  margin-bottom: 5px;
  color: var(--teams-muted);
  font-size: 11px;
  font-weight: 650;
}

.language-control select {
  min-height: 36px;
  max-width: 130px;
  padding: 5px 8px;
  border: 1px solid #b3b3b3;
  border-radius: 4px;
  color: #242424;
  background: #fff;
  font-size: 13px;
}

.composer > label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 650;
}

.automatic-label {
  margin-left: 5px;
  color: var(--teams-purple);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  border: 1px solid #b3b3b3;
  border-radius: 4px;
  color: #242424;
  background: #fff;
}

input {
  min-height: 44px;
  margin-bottom: 20px;
  padding: 8px 10px;
}

input[readonly] { color: #616161; background: #f5f5f5; }

textarea {
  min-height: 245px;
  padding: 11px 12px;
  line-height: 1.5;
  resize: vertical;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 7px;
  color: var(--teams-muted);
  font-size: 11px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #e0e0e0;
}

button {
  min-height: 44px;
  padding: 7px 16px;
  border-radius: 4px;
  font-weight: 650;
}

.secondary-button {
  border: 1px solid #b3b3b3;
  color: #242424;
  background: #fff;
}

.secondary-button:hover { background: #f5f5f5; }

.primary-button {
  border: 1px solid var(--teams-purple);
  color: #fff;
  background: var(--teams-purple);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--teams-purple-dark);
  background: var(--teams-purple-dark);
}

button:disabled {
  border-color: #d1d1d1;
  color: #8a8a8a;
  background: #e8e8e8;
  cursor: not-allowed;
}

.send-help {
  min-height: 16px;
  margin: 8px 0 0;
  color: var(--teams-muted);
  font-size: 12px;
  text-align: right;
}

.status {
  min-height: 20px;
  margin: 6px 0 0;
  color: #a4262c;
  font-size: 12px;
  text-align: right;
}

.status.is-success { color: var(--teams-success); }

.delivery-panel {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--teams-border);
  border-radius: 8px;
  background: var(--panel);
}

.delivery-panel .section-heading { margin-bottom: 12px; }
.delivery-status { margin: 0; color: var(--teams-muted); font-size: 12px; }
.delivery-list { display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }

.delivery-item {
  padding: 14px 16px;
  border: 1px solid var(--teams-border);
  border-radius: 6px;
  background: #fafafa;
}

.delivery-item-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.delivery-item-header strong { font-size: 13px; }
.delivery-badge { padding: 3px 8px; border-radius: 999px; background: #e8e8e8; font-size: 11px; font-weight: 700; }
.delivery-badge.is-opened { color: #004e8c; background: #e5f1fb; }
.delivery-badge.is-replied { color: #0b5a0b; background: #e7f4e7; }
.delivery-meta,
.delivery-reply-label { margin: 5px 0 0; color: var(--teams-muted); font-size: 12px; }
.delivery-reply-label { margin-top: 12px; font-weight: 650; }
.delivery-reply { margin: 4px 0 0; padding: 10px 12px; border-left: 3px solid var(--teams-purple); background: #fff; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

.preview-panel {
  transition: box-shadow .2s ease, border-color .2s ease;
}

.preview-panel.is-highlighted {
  border-color: var(--teams-purple);
  box-shadow: 0 0 0 3px rgba(91, 95, 199, .15);
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--teams-border);
  border-radius: 8px;
  background: var(--panel);
  color: #242424;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, .45);
}

.confirm-dialog h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 650;
}

.confirm-dialog p {
  margin: 0 0 16px;
  color: var(--teams-muted);
  font-size: 13px;
  line-height: 1.5;
}

.confirm-details {
  margin: 0 0 20px;
  padding: 14px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #f7f7fa;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.confirm-row:not(:last-child) { border-bottom: 1px solid #e6e6f0; }

.confirm-row dt {
  color: var(--teams-muted);
  font-size: 12px;
  font-weight: 650;
}

.confirm-row dd {
  margin: 0;
  overflow: hidden;
  max-width: 65%;
  color: #242424;
  font-size: 13px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .skip-link,
  .preview-panel {
    transition: none;
  }
}

@media (max-width: 600px) {
  .language-control {
    margin-left: 10px;
  }

  .language-control select {
    max-width: 110px;
  }
}

.email-preview {
  overflow: hidden;
  border: 1px solid #d1d1d1;
  border-radius: 6px;
  background: #fff;
}

.email-header {
  padding: 22px 28px 18px;
  border-bottom: 3px solid var(--teams-purple);
}

.email-header img {
  width: 200px;
  height: auto;
  display: block;
}

.email-content {
  max-width: 540px;
  min-height: 290px;
  margin: 0 auto;
  padding: 28px 34px 30px;
  font-size: 14px;
  line-height: 1.55;
}

.email-content > p:first-child { margin-top: 0; }

.preview-placeholder {
  /* WW-93: was #8a8a8a (3.45:1 on white, below the 4.5:1 floor for normal text —
     WCAG 1.4.3). var(--teams-muted) is the same gray used everywhere else in this
     file for secondary text and passes at 6.19:1. */
  min-height: 92px;
  color: var(--teams-muted);
  white-space: pre-wrap;
}

.preview-placeholder.has-message { color: #242424; }

.signature {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid #e0e0e0;
  color: #616161;
}

.signature strong { color: #242424; }

.email-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 19px 24px;
  border-top: 1px solid #e0e0e0;
  color: #616161;
  background: #fafafa;
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
}

.email-footer strong { color: var(--teams-purple); }
.email-footer a { margin-top: 9px; color: var(--teams-purple); }

@media (max-width: 1100px) {
  .workspace-grid { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .app-header { grid-template-columns: auto 1px minmax(200px, 1fr) auto; }
  .educator-block { display: none; }
  .app-shell { grid-template-columns: 240px minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .app-header {
    grid-template-areas:
      "logo badge"
      "title title";
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px 16px;
  }
  .district-logo { grid-area: logo; width: 140px; }
  .header-divider { display: none; }
  .app-header > div:nth-of-type(2) { grid-area: title; }
  .app-header > div:nth-of-type(2) p { display: none; }
  .app-header h1 { font-size: 17px; }
  .demo-badge { grid-area: badge; }
  .app-shell { display: block; }
  .workflow {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid #d1d1d1;
  }
  .step {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 4px;
    text-align: left;
  }
  .step:not(:last-child)::after { display: none; }
  .step-number {
    width: 24px;
    height: 24px;
    margin: 2px 0 0;
    font-size: 11px;
  }
  .step label,
  .step-label { margin: 0 0 6px; font-size: 12px; }
  .message-area { padding: 14px 10px 24px; }
  .composer,
  .preview-panel { padding: 16px; }
  .email-content { min-height: 250px; padding: 24px 22px; }
  .field-meta { display: block; }
  #message-count { display: block; margin-top: 3px; text-align: right; }
}
