/* Coach chat (all sizes) and the phone layout. Loaded last. */

a.btn, a.btn:hover { text-decoration: none; }

/* ---- chat card */
.askhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.askhead .asklabel { margin: 0; }
.asktoggle { border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 13px; padding: 4px 6px; }
.askform { display: flex; gap: 8px; align-items: center; }
.askform .input { flex: 1; min-width: 0; padding: 10px 14px; font-size: 16px; border-radius: 99px; }
.askform .btn { width: 42px; height: 42px; padding: 0; border-radius: 50%; flex: none; box-shadow: 0 3px 0 #B8962A; }
.asklog { max-height: 280px; overflow: auto; overscroll-behavior: contain; }
.donecol { display: flex; flex-direction: column; gap: 12px; }

/* ---- phones and small tablets */
@media (max-width: 899px) {
  .wide-only { display: none; }

  /* no dead space under the page: room for the bottom menu only where there is one */
  .main { padding: 4px 0 20px; }
  .main.hasnav { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .main.focus { padding-bottom: 0; }

  /* puzzle screens fill the screen: board, coach, actions, and the chat docked at the bottom */
  .fix { display: flex; flex-direction: column; gap: 10px; min-height: calc(100dvh - 60px); }
  .main.hasnav .fix { min-height: calc(100dvh - 130px - env(safe-area-inset-bottom)); }
  .fix-side { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; }
  .fix-head { margin-bottom: 6px; gap: 8px; }
  .steps { margin-top: 8px; }
  .coach { gap: 8px; }
  .coach-face { width: 40px; height: 40px; }
  .coach-bubble { padding: 10px 36px 10px 12px; min-height: 40px; border-radius: 4px 14px 14px 14px; }
  .coach-text { font-size: 15.5px; line-height: 1.38; }
  .coach-replay { right: 6px; top: 6px; width: 26px; height: 26px; }
  .prompt { padding: 10px 12px; }
  .prompt p { font-size: 14px; margin: 0 0 8px; }
  .prompt .tomove { color: var(--cream); }
  .habit { padding: 10px 12px; }
  .habit p { font-size: 16px; }
  .again { padding: 12px; }
  .again h3 { margin-bottom: 4px; }
  .again p { margin: 0 0 10px; font-size: 14px; }
  .lines { display: none; }
  .donecol { gap: 10px; }
  .fix-side > .btn.link { padding: 4px; align-self: center; }
  .moves { padding: 12px; }
  .movelist { max-height: 84px; }
  .pbar { padding: 5px 2px; font-size: 14px; }

  /* the chat: a bar at the bottom of the screen, answers open above it */
  .ask.dock {
    position: sticky; bottom: 0; z-index: 20; margin: auto -12px 0; border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(18, 22, 29, .97); backdrop-filter: blur(10px); box-shadow: 0 -8px 24px rgba(0, 0, 0, .35);
  }
  .main.hasnav .ask.dock { bottom: calc(58px + env(safe-area-inset-bottom)); }
  .ask.dock .askhead { margin-bottom: 6px; }
  .ask.dock:not(.has) .askhead { display: none; }
  .ask.dock .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 8px; padding: 0 12px; scrollbar-width: none; }
  .ask.dock .chips::-webkit-scrollbar { display: none; }
  .ask.dock .chips button { white-space: nowrap; flex: none; padding: 6px 11px; font-size: 13.5px; }
  .ask.dock .asklog { max-height: 34dvh; }
  .ask .asklog p { font-size: 14.5px; margin-bottom: 8px; padding: 8px 11px; }
  .ask .asklog p.me { margin-left: 28px; }
  .ask .asklog p.coach { margin-right: 12px; }

  /* scan */
  .scan { gap: 12px; }
  .scan-right { gap: 10px; }
  .counts .row { padding: 5px 0; }

  /* lists and cards */
  .card { padding: 14px; }
  .report-side { margin-top: 0; }
}

@media (max-width: 640px) { .trainrow { flex-direction: column; align-items: stretch; } .trainrow .btn { width: 100%; text-align: center; } }

/* Owner 16 Nov: the chat stays at the top of the coach panel at all times (right under the board on phones),
   so it never moves when buttons and cards appear below it. This replaces the bottom-docked bar. */
@media (max-width: 640px) {
  .fix { min-height: 0; }
  .main.hasnav .fix { min-height: 0; }
  .ask.dock { position: static; margin: 0; border-radius: 14px; border-width: 1px; padding: 10px 12px; box-shadow: none;
              background: var(--card); backdrop-filter: none; }
  .main.hasnav .ask.dock { bottom: auto; }
  .ask.dock .asklog { max-height: 24dvh; }
}

/* owner 17 Nov: iPhones zoom the page when an input with text under 16 px gets focus; every input is 16 px on touch screens */
@media (pointer: coarse) { input, textarea, select { font-size: max(16px, 1em); } }
