/* Phase 41 design layer (docs/PHASE41_FOCUS_ENGAGEMENT_ATTENDANCE_PROMPT.md): Message Center, active reading,
   cohorts, the student workspace switches, attendance teams, pardons and student uploads. Built on the
   Reformation and Phase 40 tokens so light and dark themes stay first-class. No inline styles anywhere. */

.p41-root { --p41-radius: 18px; }
.p41-hero h2 { max-width: 22ch; }
.p41-block { display: block; color: var(--rf-text-3); font-size: 12px; font-weight: 500; }
.p41-spacer { flex: 1 1 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* filters */
.p41-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.p41-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.p41-search { flex: 1 1 220px; min-width: 0; }
.p41-search .rf-input { width: 100%; }
.p41-check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--rf-text-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.p41-channel-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.p41-channel-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; color: var(--rf-text-2); background: var(--rf-surface-2); font-size: 12px; font-weight: 600; }
.p41-channel-chip b { color: var(--rf-text); }
.p41-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }

/* tables that become labelled cards on phones (see responsive.css) */
.p41-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.p41-table td { vertical-align: top; }
.p41-table .p40-bar { max-width: 160px; margin-bottom: 4px; }
.p41-actions { white-space: nowrap; }
.p41-actions .rf-link + .rf-link { margin-left: 10px; }
.p41-revoked td { opacity: .55; text-decoration: line-through; text-decoration-color: var(--rf-text-3); }
.p41-howto { display: grid; gap: 8px; margin: 0; padding-left: 18px; color: var(--rf-text-2); line-height: 1.55; }

/* ---------------------------------------------------------------- Message Center */
.p41-mc-layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.p41-thread-list { max-height: 72vh; overflow-x: hidden; overflow-y: auto; padding-bottom: 8px; }
.p41-threads { display: grid; gap: 6px; }
.p41-thread { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; width: 100%; overflow: hidden; padding: 12px; border: 1px solid transparent; border-radius: 14px; color: inherit; background: transparent; text-align: left; cursor: pointer; transition: background .2s var(--rf-ease), border-color .2s var(--rf-ease); }
.p41-thread:hover { background: var(--rf-surface-2); }
.p41-thread.active { border-color: var(--rf-gold); background: var(--rf-gold-soft); }
.p41-thread.unread .p41-thread-top strong::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--rf-red); vertical-align: middle; }
.p41-thread-avatars { display: flex; }
.p41-thread-avatars .p41-avatar + .p41-avatar { margin-left: -12px; box-shadow: 0 0 0 2px var(--rf-surface); }
.p41-thread-main { display: grid; gap: 4px; min-width: 0; }
.p41-thread-top { display: flex; justify-content: space-between; gap: 8px; }
.p41-thread-top strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.p41-thread-top time { flex: none; color: var(--rf-text-3); font-size: 11px; font-weight: 600; }
.p41-thread small { color: var(--rf-text-3); font-size: 11px; }
.p41-thread-preview { display: -webkit-box; overflow: hidden; color: var(--rf-text-2); font-size: 13px; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.p41-thread-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.p41-count { margin-left: auto; padding: 1px 8px; border-radius: 999px; color: var(--rf-text-2); background: var(--rf-surface-2); font-size: 11px; font-weight: 800; }
.p41-arrow { margin: 0 4px; color: var(--rf-gold-ink); font-weight: 800; }
.p41-avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; color: #fff; background: #0b3b5d; font-size: 12px; font-weight: 800; }
.p41-avatar.p41-tone-gold { color: #052b47; background: linear-gradient(135deg, #ffd978, #f0b429); }
.p41-avatar.p41-tone-blue { background: var(--rf-blue); }
.p41-avatar.p41-tone-green { background: var(--rf-green); }
.p41-avatar.p41-tone-amber { background: var(--rf-amber); }
.p41-person { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.p41-person strong { display: block; font-size: 14px; }
.p41-person small { display: block; color: var(--rf-text-3); font-size: 11px; }
.p41-conversation { display: grid; grid-template-rows: auto 1fr; min-height: 420px; }
.p41-conv-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--rf-hairline); }
.p41-conv-people { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.p41-back { display: none; }
.p41-bubbles { display: grid; gap: 14px; max-height: 64vh; margin: 0; padding: 16px 4px; overflow: auto; list-style: none; }
.p41-bubble { max-width: min(78%, 620px); padding: 12px 14px; border: 1px solid var(--rf-hairline); border-radius: 16px 16px 16px 4px; background: var(--rf-surface-2); }
.p41-bubble.right { justify-self: end; border-radius: 16px 16px 4px 16px; background: var(--rf-blue-soft); }
.p41-bubble.high { border-color: color-mix(in srgb, var(--rf-red) 45%, transparent); }
.p41-bubble p { margin: 6px 0; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.p41-bubble-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.p41-bubble-meta span { color: var(--rf-text-3); }
.p41-bubble-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--rf-text-3); font-size: 11px; font-weight: 600; }
.p41-receipt.read { color: var(--rf-green); }
.p41-detail-table th { width: 140px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.p41-detail-body { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--rf-surface-2); line-height: 1.6; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- reading */
.p41-reading-indicator { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 5px 11px; border-radius: 999px; color: #0f7a50; background: #e3f6ed; font-size: 12px; font-weight: 700; white-space: nowrap; }
.p41-reading-indicator.paused { color: #946200; background: #fff3d3; }
:root[data-theme="dark"] .p41-reading-indicator { color: #4fd39b; background: rgba(79, 211, 155, .14); }
:root[data-theme="dark"] .p41-reading-indicator.paused { color: #f0c65a; background: rgba(240, 180, 41, .14); }
.p41-tracking-host { display: flex; align-items: center; }
.p41-presence { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(3, 27, 44, .55); backdrop-filter: blur(3px); }
.p41-presence[hidden] { display: none; }
.p41-presence-card { display: grid; gap: 10px; max-width: 340px; margin: 16px; padding: 24px; border-radius: 20px; background: var(--rf-surface, #fff); box-shadow: var(--rf-shadow-lg); text-align: center; }
.p41-presence-card strong { font-size: 20px; }
.p41-presence-card p { margin: 0; color: var(--rf-text-2); }
.p41-my-reading { display: grid; gap: 16px; border-left: 4px solid var(--rf-gold); }
.p41-my-reading.p41-tone-green { border-left-color: var(--rf-green); }
.p41-my-reading.p41-tone-red { border-left-color: var(--rf-red); }
.p41-my-reading.p41-tone-amber { border-left-color: var(--rf-amber); }
.p41-my-reading-main { display: flex; align-items: center; gap: 18px; }
.p41-my-reading-main h3 { margin: 2px 0 6px; }
.p41-my-reading-main p { margin: 0; }
.p41-my-reading-host { margin-bottom: 18px; }
.p41-book-progress { display: grid; gap: 10px; }
.p41-book-row { display: grid; grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 2fr) auto; align-items: center; gap: 14px; }
.p41-book-row small { display: block; color: var(--rf-text-3); font-size: 12px; }
.p41-book-row > span { color: var(--rf-text-2); font-size: 12px; font-weight: 700; white-space: nowrap; }
.p41-tip { padding: 14px 16px; border-radius: 14px; background: var(--rf-gold-soft); }
.p41-tip p:last-child { margin: 4px 0 0; color: var(--rf-text); line-height: 1.55; }
.p41-detail-top { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.p41-pages, .p41-sessions { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.p41-pages li { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 10px; background: var(--rf-surface-2); font-size: 13px; }
.p41-sessions li { display: grid; gap: 2px; padding: 8px 10px; border-left: 3px solid var(--rf-gold); background: var(--rf-surface-2); font-size: 12px; }
.p41-sessions li span { color: var(--rf-text-2); }

/* ---------------------------------------------------------------- cohorts */
.p41-cohort-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.p41-cohort { display: grid; gap: 14px; border-top: 5px solid #0b3b5d; }
.p41-cohort.p41-tone-gold { border-top-color: var(--rf-gold); }
.p41-cohort.p41-tone-red { border-top-color: var(--rf-red); }
.p41-cohort.p41-tone-green { border-top-color: var(--rf-green); }
.p41-cohort.p41-tone-teal { border-top-color: #0f8b8d; }
.p41-cohort.p41-tone-purple { border-top-color: #6b4fbb; }
.p41-cohort-head { display: flex; justify-content: space-between; gap: 12px; }
.p41-cohort-head h3 { margin: 2px 0; }
.p41-cohort-progress { display: grid; gap: 6px; }
.p41-cohort-progress small { color: var(--rf-text-2); }
.p41-cohort-dates { display: flex; justify-content: space-between; color: var(--rf-text-3); font-size: 12px; font-weight: 700; }
.p41-next { margin: 4px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--rf-surface-2); font-size: 13px; }
.p41-cohort-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 0; }
.p41-cohort-stats div { padding: 10px; border-radius: 12px; background: var(--rf-surface-2); }
.p41-cohort-stats dt { color: var(--rf-text-3); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.p41-cohort-stats dd { margin: 4px 0 0; font-size: 16px; font-weight: 800; }
.p41-back-link { justify-self: start; margin-bottom: 4px; }
.p41-timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.p41-timeline li { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 0 0 16px; }
.p41-timeline li::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: 0; width: 2px; background: var(--rf-hairline-strong); }
.p41-timeline li:last-child::before { display: none; }
.p41-tl-dot { width: 16px; height: 16px; margin-top: 2px; border: 3px solid var(--rf-surface); border-radius: 50%; background: #0b3b5d; box-shadow: 0 0 0 1px var(--rf-hairline-strong); }
.p41-timeline .type-exam .p41-tl-dot { background: var(--rf-red); }
.p41-timeline .type-break .p41-tl-dot, .p41-timeline .type-holiday .p41-tl-dot { background: var(--rf-green); }
.p41-timeline .type-graduation .p41-tl-dot { background: var(--rf-gold); }
.p41-timeline .p41-tl-now .p41-tl-dot { box-shadow: 0 0 0 4px rgba(240, 180, 41, .35); }
.p41-timeline .p41-tl-past { opacity: .55; }
.p41-timeline strong { display: block; font-size: 14px; }
.p41-timeline small { color: var(--rf-text-3); font-size: 12px; }
.p41-timeline p { margin: 4px 0 0; color: var(--rf-text-2); font-size: 13px; }
.p41-timeline.compact li { padding-bottom: 10px; }
.p41-my-cohort { display: grid; gap: 14px; margin-bottom: 18px; border-left: 4px solid var(--rf-gold); }
.p41-my-cohort-head { display: flex; align-items: center; gap: 16px; }
.p41-my-cohort-head h3 { margin: 2px 0 4px; }
.p41-my-cohort-head p { margin: 0; }
.p41-cal-rows { display: grid; gap: 8px; margin: 8px 0; }
.p41-cal-row { display: grid; grid-template-columns: minmax(160px, 2fr) minmax(120px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) auto; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- student workspace switches */
.p41-switch-groups { display: grid; gap: 16px; }
.p41-switch { position: relative; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--rf-hairline); cursor: pointer; }
.p41-switch:last-child { border-bottom: 0; }
.p41-switch input { position: absolute; opacity: 0; pointer-events: none; }
.p41-switch-track { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--rf-hairline-strong); transition: background .2s var(--rf-ease); }
.p41-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--rf-shadow-sm); transition: transform .2s var(--rf-ease); }
.p41-switch input:checked + .p41-switch-track { background: var(--rf-green); }
.p41-switch input:checked + .p41-switch-track::after { transform: translateX(20px); }
.p41-switch input:focus-visible + .p41-switch-track { outline: 3px solid rgba(240, 180, 41, .6); outline-offset: 2px; }
.p41-switch-text strong { display: block; }
.p41-switch-text small { color: var(--rf-text-3); }

/* ---------------------------------------------------------------- attendance teams */
.p41-team-pick { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 10px; background: var(--rf-surface-2); }
.p41-team-btn { padding: 6px 10px; border: 0; border-radius: 8px; color: var(--rf-text-2); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.p41-team-btn.active { color: var(--rf-text); background: var(--rf-surface); box-shadow: var(--rf-shadow-sm); }
.p41-team-btn:focus-visible { outline: 3px solid rgba(240, 180, 41, .6); }

/* ---------------------------------------------------------------- pardons */
.p41-pardon-form { display: grid; gap: 10px; }
.p41-pardon-who { margin: 0; font-size: 16px; font-weight: 800; }
.p41-exemptions { border-left: 4px solid var(--rf-blue); }

/* ---------------------------------------------------------------- documents: student uploads */
.p41-doc-classification { margin-bottom: 14px; }
.p41-doc-segments { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.p41-doc-seg { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--line, var(--rf-hairline)); border-radius: 16px; color: inherit; background: var(--paper, var(--rf-surface)); text-align: left; cursor: pointer; transition: border-color .2s ease, box-shadow .2s ease; }
.p41-doc-seg span { color: var(--muted, var(--rf-text-2)); font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.p41-doc-seg b { font-size: 24px; letter-spacing: -.02em; }
.p41-doc-seg small { color: var(--gold-text, #8a6208); font-size: 12px; font-weight: 700; }
.p41-doc-seg.active { border-color: var(--gold, #f0b429); box-shadow: 0 0 0 3px rgba(240, 180, 41, .22); }
.doc-card.p41-student-upload { position: relative; border-color: rgba(240, 180, 41, .55); box-shadow: inset 0 3px 0 #f0b429; }
.p41-doc-ribbon { position: absolute; top: 10px; right: 10px; padding: 3px 9px; border-radius: 999px; color: #052b47; background: linear-gradient(135deg, #ffd978, #f0b429); font-size: 11px; font-weight: 800; }
.doc-card.p41-student-upload .doc-card-top .status-pill { margin-right: 120px; }

/* ---------------------------------------------------------------- phone dock (shown by responsive.css) */
.p41-dock { display: none; }

@media (prefers-reduced-motion: reduce) {
  .p41-thread, .p41-switch-track, .p41-switch-track::after, .p41-doc-seg { transition: none; }
}
