/* Coach chat (coach.html). Tokens and shell come from app.css. */
.ch-wrap { max-width: 820px; margin: 0 auto; padding: 0 16px 40px; }
.ch-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }

.ch-context { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; min-height: 36px;
    padding: 0 12px; border-radius: var(--pill); background: var(--accent-soft); border: 1px solid var(--accent-line);
    color: var(--accent-paler, #fecaca); font-size: .82rem; font-weight: 600; text-decoration: none; }
.ch-context:hover { background: rgba(var(--accent-rgb, 220, 38, 38), .2); }
.ch-context:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

.ch-thread { display: flex; flex-direction: column; gap: 12px; min-height: 280px;
    max-height: min(62vh, 640px); overflow-y: auto; padding: 4px 2px; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { .ch-thread { scroll-behavior: auto; } }

.ch-msg { max-width: 86%; padding: 11px 14px; border-radius: 16px; line-height: 1.6; font-size: .95rem;
    overflow-wrap: anywhere; }
.ch-msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent, #fff); border-bottom-right-radius: 6px;
    white-space: pre-wrap; }
.ch-msg.coach { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-dim); border-bottom-left-radius: 6px; }
.ch-msg.coach p { margin: 0; }
.ch-msg.coach p + p, .ch-msg.coach p + ul, .ch-msg.coach ul + p { margin-top: .55rem; }
.ch-msg.coach ul { margin: .35rem 0 0; padding-left: 1.15rem; }
.ch-msg.coach li + li { margin-top: .2rem; }
.ch-msg.coach strong { color: var(--text); font-weight: 600; }
.ch-msg.error { align-self: center; max-width: 100%; background: transparent; border: 1px dashed var(--border-strong);
    color: var(--text-dim); font-size: .88rem; text-align: center; }

.ch-typing { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px;
    border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-faint); font-size: .86rem; }
.ch-dots { display: inline-flex; gap: 4px; }
.ch-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: ch-blink 1.2s infinite ease-in-out; }
.ch-dots i:nth-child(2) { animation-delay: .15s; }
.ch-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ch-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ch-dots i { animation: none; opacity: .6; } }

.ch-empty { margin: auto 0; text-align: center; padding: 24px 8px; }
.ch-empty-title { margin: 0 0 14px; color: var(--text); font-size: 1.05rem; font-weight: 700; }
.ch-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ch-chip { min-height: 44px; padding: 8px 14px; border-radius: var(--pill); cursor: pointer; text-align: left;
    background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); font: inherit;
    font-size: .88rem; line-height: 1.35; transition: background var(--t), border-color var(--t); }
.ch-chip:hover { background: var(--surface-3); border-color: var(--accent-line); }
.ch-chip:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

.ch-form { display: flex; align-items: flex-end; gap: 8px; padding: 6px; border-radius: 16px;
    background: var(--surface-2); border: 1px solid var(--border-strong); }
.ch-form:focus-within { border-color: var(--accent-line); }
.ch-form textarea { flex: 1; min-height: 44px; max-height: 160px; resize: none; padding: 11px 10px; border: 0;
    background: transparent; color: var(--text); font: inherit; font-size: 1rem; line-height: 1.4; outline: none; }
.ch-form textarea::placeholder { color: var(--text-faint); }
.ch-send { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0; cursor: pointer; display: grid;
    place-items: center; background: var(--accent); color: var(--on-accent, #fff); transition: background var(--t), opacity var(--t); }
.ch-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ch-send:hover { background: var(--accent-dark, #b91c1c); }
.ch-send:disabled { opacity: .45; cursor: not-allowed; }
.ch-send:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

.ch-note { margin: 0; color: var(--text-faint); font-size: .78rem; line-height: 1.5; text-align: center; }

@media (max-width: 768px) {
    .ch-thread { max-height: none; min-height: 34vh; }
    .ch-msg { max-width: 92%; }
    /* The page scrolls on a phone: the message box stays in reach above the tab bar. */
    .ch-form { position: sticky; z-index: 5; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
        box-shadow: 0 -10px 24px rgba(0, 0, 0, .55); }
    .ch-msg, .ch-typing { scroll-margin-top: 84px; scroll-margin-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px); }
}

.ch .page-head .ph-in { max-width: 820px; }

/* Free plan: the chat is part of Premium and Pro (js/coach.js showUpgrade). */
.ch-upgrade { padding: 12px 8px 16px; text-align: center; }
.ch-upgrade h2 { margin: 0 0 10px; font-size: 1.25rem; color: var(--text); }
.ch-upgrade p { margin: 0 auto 10px; max-width: 46ch; color: var(--text-dim); line-height: 1.55; }
.ch-upgrade-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.ch-upgrade-actions .btn { padding: .7rem 1.3rem; min-height: 44px; }
