body.coach-page {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.coach-page > header, .coach-page > nav, .coach-page > main { width: 100%; }
.coach-page > header { grid-row: 1; padding-block: 10px; }
.coach-page > nav { grid-row: 3; position: relative; }
.coach-page > main {
  grid-row: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  margin-block: 0;
  padding: 0;
}
.coach-page > #toast:empty { display: none; }
.coach-bar {
  display: grid;
  gap: 8px;
  justify-items: center;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}
.coach-bar h1 { font-size: 23px; margin: 0; text-align: center; }
.coach-clear { min-height: 32px; padding: 4px 10px; font-size: 12px; color: var(--accent); background: transparent; }
nav button { transition: color .18s ease, background .18s ease, transform .18s ease; }
nav button:active { transform: scale(.95); }
.coach-tabs { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; }
.coach-tabs button { min-height: 38px; font-size: 12px; padding: 5px 8px; transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease; }
.coach-tabs button:active { transform: scale(.96); }
.coach-tabs button[aria-pressed="false"] { background: transparent; color: var(--muted); }
.coach-tabs button[aria-pressed="true"] { background: #253321; border-color: #657943; color: var(--accent); }
.coach-panel { width: min(100%, 620px); margin-inline: auto; overflow: auto; overscroll-behavior: contain; padding: 12px; }
.coach-chat { width: min(100%, 620px); min-height: 0; justify-self: center; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.coach-thread { min-height: 0; position: relative; }
.coach-messages {
  height: 100%;
  width: 100%;
  max-width: 620px;
  margin-inline: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px;
}
.coach-messages .bubble { width: fit-content; max-width: 94%; padding: 9px 13px; line-height: 1.45; }
.coach-messages .bubble[data-message-index] { cursor: pointer; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.coach-messages .bubble[data-message-index] { cursor: pointer; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.coach-messages .bubble:not(.user) { margin-inline: auto; }
.coach-messages .bubble.user { margin-left: auto; max-width: 87%; background: #253321; }
.coach-messages .bubble small { font-size: 11px; }
.coach-bubble-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 3px; }
.coach-delete { min-height: 30px; font-size: 12px; padding: 2px 7px; background: transparent; color: var(--muted); }
.coach-empty, .coach-typing { color: var(--muted); padding: 6px; text-align: center; }
.coach-latest {
  position: absolute;
  bottom: 8px;
  right: 15px;
  z-index: 1;
  min-height: 40px;
  background: #263426;
  border-color: #657943;
  color: var(--accent);
  font-size: 13px;
}
.coach-composer { width: min(100%, 620px); justify-self: center; background: var(--bg); padding: 7px 12px 6px; border-top: 1px solid var(--line); }
.coach-entry { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 7px; }
.coach-entry textarea { margin: 0; resize: none; min-height: 44px; font-size: 16px; }
.coach-entry button { min-height: 44px; }
.coach-composer label { margin: 5px 0 0; }
.coach-composer > small { font-size: 11px; }
.coach-error { color: #f4b0a8; font-size: 13px; margin: 0 0 4px; }
@keyframes screen-enter { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
.screen-enter { animation: screen-enter .38s cubic-bezier(.2,.75,.25,1) both; }
@media (prefers-reduced-motion: reduce) { .screen-enter { animation: none; } .coach-tabs button { transition: none; } }
@media (max-height: 490px) {
  .coach-page > header { display: none; }
  .coach-entry textarea { height: 44px; }
}
