.coach-fallback { margin: 0 0 1rem; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.coach-fallback summary { cursor: pointer; font-weight: 650; padding: .6rem; width: fit-content; }
.coach-topline { margin: .8rem 0 1.4rem; }
.coach-topline h2 { margin: .4rem 0; font-size: clamp(1.5rem, 3vw, 2rem); }
.coach-layout { display: grid; grid-template-columns: minmax(290px, .8fr) minmax(0, 1.6fr); gap: 1.25rem; align-items: start; }
.coach-sidebar { position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
.coach-sidebar h3 { margin-top: 0; }
.coach-sidebar textarea, .coach-workspace textarea, .coach-workspace input[type="text"], .coach-sidebar select, .coach-workspace select { display: block; width: 100%; padding: .75rem; color: var(--text); background: var(--input-bg); border: 1px solid var(--border); border-radius: .6rem; font: inherit; }
.coach-workspace textarea { min-height: 90px; resize: vertical; }
.coach-workspace { min-width: 0; min-height: 500px; }
.coach-workspace h3 { overflow-wrap: anywhere; }
.coach-workspace h4, .coach-section h4 { margin-bottom: .5rem; }
.coach-workspace label, .coach-sidebar > label { display: block; margin: 1rem 0 .4rem; font-weight: 600; }
.coach-starters { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 1rem 0; }
.coach-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.coach-actions button { flex-grow: 0; }
.coach-history-item { display: grid; gap: .3rem; text-align: left; width: 100%; border: 1px solid var(--border); border-radius: .7rem; color: var(--text); background: var(--surface-soft); padding: .8rem; margin-top: .6rem; cursor: pointer; }
.coach-history-item.selected { border: 2px solid var(--primary); padding: calc(.8rem - 1px); }
.coach-history-item strong { text-transform: capitalize; color: var(--primary); }
.coach-history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coach-history-item small { color: var(--muted); }
.coach-message { border-radius: .7rem; padding: .8rem; background: var(--surface-soft); border: 1px solid var(--border); }
.coach-message.student { margin-left: 1rem; }
.coach-message strong { display: block; margin-bottom: .35rem; font-size: .8rem; color: var(--muted); }
.coach-message span { white-space: pre-wrap; overflow-wrap: anywhere; }
#coachConversation { max-height: 320px; overflow-y: auto; }
#coachStatus { min-height: 1.5em; font-size: .9rem; color: var(--primary); }
.coach-prose { white-space: pre-wrap; line-height: 1.65; overflow-wrap: anywhere; }
.coach-section, .coach-thread { border-bottom: 1px solid var(--border); padding: .6rem 0; }
.coach-feedback { padding: 1rem; margin: 1rem 0; border-left: 3px solid var(--primary); border-radius: .5rem; background: var(--surface-soft); }
.coach-feedback h5 { font-size: 1rem; margin: .5rem 0; }
.coach-question { margin: 1.5rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: .8rem; min-width: 0; }
.coach-question legend { font-weight: 650; line-height: 1.6; padding: 0 .3rem; }
.coach-question .coach-choice { display: flex; align-items: start; gap: .7rem; font-weight: 400; padding: .7rem; margin: .4rem 0; background: var(--surface-soft); border-radius: .5rem; cursor: pointer; }
.coach-choice input, .coach-check input { width: auto; flex-shrink: 0; margin-top: .3rem; accent-color: var(--primary); }
.coach-check { display: flex !important; gap: .5rem; font-weight: 400 !important; }
.coach-fields fieldset { border: 1px solid var(--border); margin-top: 1rem; border-radius: .6rem; }
.coach-progress { padding: .8rem; background: var(--info-bg); border: 1px solid var(--info-border); border-radius: .6rem; }
.coach-score { font-size: 1.5rem; font-weight: 700; }
.coach-save-status { padding: .8rem; color: var(--success); background: var(--success-bg); }
.coach-back { display: inline-flex; margin-bottom: 1rem; }
.coach-history-storage { margin: 1rem 0; padding: .75rem; border: 1px solid var(--border); border-radius: .6rem; }
.coach-history-storage summary { cursor: pointer; font-weight: 650; }
.coach-history-storage p { font-size: .9rem; line-height: 1.5; }
.coach-history-storage input[type="file"] { max-width: 100%; }
.coach-welcome { padding: 2rem 0; }
.coach-layout button:focus-visible, .coach-fallback summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
#mode-coach [hidden], [data-coach-pilot][hidden], #coachNavButton[hidden], #legacyStudyTools[hidden], #notebookCoachReturn[hidden] { display: none !important; }
@media (max-width: 850px) {
  .coach-layout { grid-template-columns: minmax(0, 1fr); }
  .coach-sidebar { position: static; max-height: none; }
  .coach-back { display: inline-flex; margin-bottom: 1rem; position: sticky; top: .5rem; z-index: 2; background: var(--surface); }
  .coach-workspace { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) { .coach-layout * { scroll-behavior: auto !important; } }
