/* The coach sheet. Uses the tokens from styles.css and phone.css; no remote fonts, images or inline styles. */
.coach-dialog {
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: #1f1a42;
}
.coach-dialog[open] { display: flex; }
.coach-dialog::backdrop { background: rgba(8, 5, 23, .76); }
.coach-sheet {
  display: flex;
  width: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(169deg, #25204d 0%, #29234f 57%, #1f1a42 100%);
}
.coach-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.coach-top h2 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.coach-top h2:focus { outline: none; }
.coach-top h2:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.coach-close { border-radius: 50%; }
.coach-ai-line {
  margin: 0;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--ink);
  background: #2f2858;
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.4;
}
.coach-body {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 4px;
}
.coach-panel { display: grid; align-content: start; justify-items: start; gap: 14px; padding: 8px 2px; }
.coach-panel .button { text-decoration: none; }
.coach-panel .button-large { width: 100%; }
.coach-line { margin: 0; color: var(--ink-soft); font-size: .96rem; line-height: 1.52; }
.coach-muted { color: var(--muted); }
.coach-locked-title { margin: 0; font-size: 1.45rem; font-weight: 600; letter-spacing: -.02em; }
.coach-price { margin: 0; color: var(--ink); font-size: 1.7rem; font-weight: 650; letter-spacing: -.02em; }
.coach-how { width: 100%; border-top: 1px solid var(--line); padding-top: 4px; }
.coach-how summary { display: flex; min-height: 44px; align-items: center; color: var(--ink-soft); cursor: pointer; font-weight: 650; }
.coach-how .coach-line { padding-bottom: 8px; }

.coach-log { display: flex; min-height: 120px; flex: 1 0 auto; flex-direction: column; gap: 9px; padding: 4px 0; }
.coach-empty { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.coach-msg { max-width: 88%; margin: 0; padding: 10px 14px; border-radius: 16px; font-size: .96rem; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.coach-msg-user { align-self: flex-end; border-bottom-right-radius: 5px; color: var(--primary-text); background: var(--primary-bg); }
.coach-msg-assistant { align-self: flex-start; border-bottom-left-radius: 5px; color: var(--ink); background: #43396d; }
.coach-msg-crisis { max-width: 100%; border-left: 4px solid var(--citrus-deep); background: #50427f; }

.coach-form { display: grid; flex: 0 0 auto; gap: 8px; }
.coach-check { min-height: 44px; align-items: flex-start; font-size: .88rem; line-height: 1.42; }
.coach-check span { padding-top: 1px; }
.coach-plan-note { margin: 0 0 0 31px; }
.coach-plan-preview { margin: 0 0 0 31px; padding: 9px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--ink-soft); background: #2c2552; font-size: .86rem; line-height: 1.45; overflow-wrap: anywhere; }
.coach-input { min-height: 88px; }
.coach-input:disabled { color: #6a5f7e; background: #cfc5dc; }
.coach-counter { margin: -2px 2px 0; text-align: right; }
.coach-hint { margin: 0; }
.coach-notice { margin: 0; padding: 10px 13px; border-radius: 12px; color: var(--ink); background: #43396d; font-size: .9rem; line-height: 1.45; overflow-wrap: anywhere; }
.coach-notice.is-limit { border: 1px solid var(--line-strong); }
.coach-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.coach-left { margin: 0; color: var(--muted); font-size: .88rem; }
.coach-send { min-width: 112px; }
.coach-privacy { justify-self: start; }

@media (min-width: 640px) {
  .coach-dialog { width: min(560px, calc(100% - 48px)); height: min(760px, calc(100dvh - 48px)); margin: auto; border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
  .coach-sheet { padding: 20px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .coach-dialog, .coach-dialog * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* The coach bubble: a round button on the right edge, above the bottom bar on phones. Shown by app.js only in billing builds. */
.coach-bubble {
  position: fixed;
  z-index: 25;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: inline-flex;
  width: 58px;
  height: 58px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid var(--primary-bg);
  border-radius: 50%;
  color: var(--primary-text);
  background: var(--primary-bg);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .38);
  cursor: pointer;
}
.coach-bubble[hidden] { display: none; }
.coach-bubble .ui-icon { width: 26px; height: 26px; }
.coach-bubble:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.coach-bubble:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
@media (max-width: 760px) {
  .coach-bubble { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: no-preference) {
  .coach-bubble { transition: transform .15s ease; }
  .coach-bubble:active { transform: scale(.94); }
}

/* Sharing choices: shown until the first answer, then folded into one line with a Change button. */
.coach-sharing[hidden], .coach-sharing-summary[hidden] { display: none; }
.coach-sharing-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coach-sharing-summary .coach-line { font-size: .88rem; }

/* Coach David: a drawn avatar on the bubble (with an AI tag) and on the sheet header. */
.coach-bubble { width: 62px; height: 62px; overflow: visible; }
.coach-bubble .coach-avatar { width: 100%; height: 100%; border-radius: 50%; display: block; }
.coach-bubble-tag {
  position: absolute;
  left: -4px;
  bottom: -2px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--primary-bg);
  background: var(--primary-text);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.3;
}
.coach-ident { display: flex; align-items: center; gap: 10px; min-width: 0; }
.coach-avatar-small { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; }

/* The Install button in the header, next to Settings (hidden once the app is installed), and the short how-to under the header. */
.install-header { min-width: 44px; gap: 6px; padding: 9px 13px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: .84rem; font-weight: 650; white-space: nowrap; }
.install-header[hidden] { display: none; }
.install-how { margin: 6px 0 0; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-surface); color: var(--ink); background: var(--surface); font-size: .9rem; line-height: 1.5; }
.install-how[hidden] { display: none; }
