/* Companion card only exists after arriving through a personal coach link. */
.coach-companion { position: fixed; z-index: 25; bottom: calc(24px + env(safe-area-inset-bottom)); right: calc(24px + env(safe-area-inset-right)); width: 292px; max-width: calc(100vw - 36px); display: flex; align-items: flex-start; padding: 12px; border: 1px solid var(--line, #ccd4d4); border-top: 3px solid var(--ink, #092a30); background: #fff; color: var(--ink, #092a30); box-shadow: 0 6px 24px rgba(9, 42, 48, .12); }
.coach-companion__link { display: flex; flex: 1; min-width: 0; align-items: center; gap: 12px; padding: 4px; text-decoration: none; }
.coach-companion__avatar { display: grid; place-items: center; flex-shrink: 0; width: 46px; height: 46px; background: var(--lime-soft, #edf3e8); font-size: 23px; font-weight: 600; }
.coach-companion__copy { display: grid; min-width: 0; gap: 1px; }
.coach-companion__copy > span:first-child { color: var(--ink-soft, #4a6065); font-size: 13px; line-height: 1.4; }
.coach-companion__copy strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 18px; line-height: 1.3; white-space: normal; overflow: hidden; overflow-wrap: anywhere; text-overflow: ellipsis; font-weight: 600; }
.coach-companion__action { overflow-wrap: anywhere; color: var(--coral, #b6503e); font-size: 14px; line-height: 1.4; text-decoration: underline; text-underline-offset: 3px; margin-top: 3px; }
.coach-companion__minimize { display: grid; place-items: center; width: 32px; height: 32px; min-width: 32px; border: 0; padding: 0; background: transparent; color: var(--ink-soft, #4a6065); font-size: 25px; line-height: 1; cursor: pointer; }
.coach-companion__minimize:hover { background: var(--lime-soft, #edf3e8); color: var(--ink, #092a30); }
.has-coach-widget .site-footer { padding-bottom: 175px; }
@media (max-width: 760px) {
  .coach-companion { bottom: calc(12px + env(safe-area-inset-bottom)); right: calc(12px + env(safe-area-inset-right)); width: 272px; padding: 9px; }
  .coach-companion__minimize { width: 44px; height: 44px; min-width: 44px; }
  .coach-companion__link { gap: 9px; }
  .coach-companion__copy strong { font-size: 17px; }
  .has-coach-widget .site-footer { padding-bottom: calc(185px + env(safe-area-inset-bottom)); }
}
@media print { .coach-companion { display: none; } .has-coach-widget .site-footer { padding-bottom: 0; } }

/* Quiet view preserves the personal return path without the expanded card. */
.coach-companion [hidden] { display: none !important; }
.coach-companion__panel { position: relative; width: 100%; min-width: 0; }
.coach-companion__row { display: flex; align-items: flex-start; gap: 4px; }
.coach-companion__forget { display: block; min-height: 44px; padding: 10px 12px; border: 0; width: 100%; background: transparent; color: var(--ink-soft, #4a6065); text-align: left; font: inherit; font-size: 13px; cursor: pointer; }
.coach-companion__forget:hover { color: var(--coral, #b6503e); }
.coach-companion--quiet { width: auto; max-width: calc(100vw - 36px); padding: 0; border: 0; border-radius: 50%; background: transparent; box-shadow: none; }
.coach-companion__reopen { position: relative; display: grid; place-items: center; width: 56px; height: 56px; padding: 3px; border: 0; border-radius: 50%; color: var(--ink, #092a30); background: #fff; box-shadow: 0 3px 14px rgba(9, 42, 48, .16); font: inherit; cursor: pointer; }
.coach-companion__reopen .coach-companion__avatar { width: 50px; height: 50px; font-size: 23px; }
.coach-companion__reopen::after { content: ''; position: absolute; inset: -1px; border: 1px solid var(--ink, #092a30); border-radius: 50%; opacity: 0; pointer-events: none; animation: coach-portrait-pulse 8s ease-out 3; }
.coach-companion__reopen:hover { box-shadow: 0 3px 16px rgba(9, 42, 48, .24); }
.coach-companion__reopen:focus-visible { outline: 2px solid var(--ink, #092a30); outline-offset: 4px; }
.coach-companion__reopen:hover::after,
.coach-companion__reopen:focus-visible::after { animation: none; opacity: 0; }
/* Three short, soft rings with long pauses, then the portrait remains still. */
@keyframes coach-portrait-pulse {
  0% { transform: scale(1); opacity: .28; }
  18% { transform: scale(1.2); opacity: 0; }
  19%, 100% { transform: scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .coach-companion__reopen::after { animation: none; opacity: 0; } }
.has-coach-widget.coach-widget-quiet .site-footer { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
@media (max-width: 760px) { .coach-companion__forget { min-height: 44px; } }
@media print { .has-coach-widget.coach-widget-quiet .site-footer { padding-bottom: 0; } }

/* Reuse the coach's portrait in both views, with the initial underneath as fallback. */
.coach-companion__avatar { position: relative; overflow: hidden; border-radius: 50%; }
.coach-companion__avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }

/* Secondary controls stay behind a small, keyboard-accessible options menu. */
.coach-companion__controls { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.coach-companion__options > summary { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; list-style: none; color: var(--ink-soft, #4a6065); font-size: 24px; line-height: 1; cursor: pointer; }
.coach-companion__options > summary::-webkit-details-marker { display: none; }
.coach-companion__options > summary:hover,
.coach-companion__options[open] > summary { background: var(--lime-soft, #edf3e8); color: var(--ink, #092a30); }
.coach-companion__options-panel { position: absolute; right: 0; bottom: calc(100% + 10px); width: 210px; max-width: 100%; padding: 4px; border: 1px solid var(--line, #ccd4d4); background: #fff; box-shadow: 0 4px 16px rgba(9, 42, 48, .12); }
.coach-companion__forget:hover { background: var(--lime-soft, #edf3e8); }
.coach-companion__controls :focus-visible,
.coach-companion__forget:focus-visible { outline: 2px solid var(--ink, #092a30); outline-offset: 2px; }
@media (max-width: 760px) { .coach-companion__options > summary { width: 44px; height: 44px; } }


/* A single automatic greeting after following a link from the coach profile. */
.coach-companion--welcome { width: 340px; animation: coach-welcome-enter 360ms ease-out both; }
.coach-companion__welcome { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line, #ccd4d4); max-height: calc(100svh - 220px); overflow-y: auto; }
.coach-companion__welcome-title { margin: 0 0 10px; color: var(--ink-soft, #4a6065); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.coach-companion__messages { display: grid; gap: 8px; }
.coach-companion__message { margin: 0; padding: 11px 12px; background: var(--lime-soft, #edf3e8); color: var(--ink, #092a30); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; animation: coach-message-enter 240ms ease-out both; }
.coach-companion__typing { display: flex; gap: 4px; align-items: center; width: fit-content; min-height: 36px; padding: 10px 12px; background: var(--lime-soft, #edf3e8); }
.coach-companion__typing span { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-soft, #4a6065); animation: coach-typing 750ms ease-in-out 2; }
.coach-companion__typing span:nth-child(2) { animation-delay: 100ms; }
.coach-companion__typing span:nth-child(3) { animation-delay: 200ms; }
.coach-companion__welcome-dismiss { display: block; min-height: 44px; margin-top: 8px; padding: 8px 12px; width: 100%; border: 1px solid var(--line, #ccd4d4); background: #fff; color: var(--ink, #092a30); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.coach-companion__welcome-dismiss:hover { background: var(--lime-soft, #edf3e8); }
.has-coach-widget.coach-widget-welcome .site-footer { padding-bottom: calc(360px + env(safe-area-inset-bottom)); }
@keyframes coach-welcome-enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes coach-message-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes coach-typing { 0%, 100% { opacity: .35; transform: none; } 50% { opacity: .8; transform: translateY(-2px); } }
@media (max-width: 760px) { .coach-companion--welcome { width: 320px; } }
@media (prefers-reduced-motion: reduce) { .coach-companion--welcome, .coach-companion__message, .coach-companion__typing span { animation: none; } }
@media print { .has-coach-widget.coach-widget-welcome .site-footer { padding-bottom: 0; } }

/* Keep the portrait still while the welcome card folds down into its quiet view. */
.coach-companion--settling .coach-companion__reopen::after { animation: none; opacity: 0; }
