:root {
  font-family: system-ui, sans-serif;
  overflow-wrap: anywhere;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem max(1rem, calc((100vw - 1400px) / 2));
  background: #173d4e;
  color: white;
}
header a {
  color: white;
  font-weight: 700;
}
header span {
  flex: 1;
  min-width: 0;
}
main {
  max-width: 1400px;
  margin: auto;
  padding: 1rem;
}
h1 {
  font-size: 1.8rem;
}
h2 {
  font-size: 1.3rem;
}
.coach-page h1 {
  margin: 0.35rem 0;
}
button,
input,
select,
textarea {
  font: inherit;
  min-height: 44px;
  border: 1px solid var(--control-border);
  border-radius: 0.45rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}
button {
  cursor: pointer;
}
button:hover {
  background: var(--surface-hover);
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
input[type="checkbox"] {
  min-width: 24px;
  min-height: 24px;
}
article,
#administration,
#invitation,
#session-report,
#plan > details,
#workout > details {
  background: var(--surface);
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  margin: 1rem 0;
}
.toolbar,
.participant {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin: 0.6rem 0;
}
.toolbar > button {
  flex-shrink: 0;
}
.journal-controls {
  flex-wrap: wrap;
  justify-content: flex-start;
}
.journal-controls label {
  min-width: 0;
}
.journal-controls select {
  min-width: 0;
  max-width: min(100%, 24rem);
}
.lesson-picker {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface);
}
.lesson-picker h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}
.lesson-picker .journal-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}
.lesson-picker label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.lesson-picker input,
.lesson-picker select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 1rem;
  font-weight: 400;
}
.roster-controls label {
  flex: 1 1 14rem;
}
.roster-controls input {
  min-width: 0;
  flex: 1;
}
#attendance-summary {
  border-left: 4px solid #197bba;
  background: var(--surface-hover);
  border-radius: 0.35rem;
  padding: 0.8rem;
  font-weight: 600;
}
#attendance-summary strong,
#attendance-summary span {
  display: block;
}
#attendance-summary span {
  font-size: 0.85rem;
  font-weight: 400;
  margin-top: 0.25rem;
}
#attendance-summary .summary-people,
#attendance-summary .summary-visits {
  display: inline;
  font: inherit;
  margin: 0;
}
.refresh-icon,
.mobile-button-text {
  display: none;
}
.roster-summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.roster-summary > p {
  flex: 1 1 24rem;
}
.roster-actions {
  display: flex;
  gap: 0.5rem;
}
.coach-sections {
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem 0;
  background: var(--page-bg);
}
.coach-sections a {
  display: flex;
  flex: 1;
  min-height: 44px;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  color: #173d4e;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  font-weight: 600;
  text-decoration: none;
}
.coach-sections a:hover {
  background: var(--surface-hover);
}
.coach-sections .administration-nav {
  display: none;
}
.coach-page main:has(#administration:not([hidden])) .administration-nav {
  display: flex;
}
#lessons,
#workout,
#administration,
#session-report {
  scroll-margin-top: 4rem;
}
#lessons > h2 {
  margin: 0.35rem 0 0;
}
.lesson-hint {
  margin: 0.25rem 0 0.55rem;
}
.sync-help {
  margin: 0.75rem 0;
}
.attendance-toggle-text {
  display: none;
}
.table-scroll {
  max-width: 100%;
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
}
.month-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.9rem;
}
.month-table caption {
  text-align: left;
  padding: 0.8rem;
  font-weight: 600;
}
.month-table th,
.month-table td {
  padding: 0.35rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.month-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-muted);
}
.month-table .person-column {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 8rem;
  max-width: 16rem;
  width: 12rem;
  text-align: left;
}
.month-table thead .person-column {
  z-index: 3;
  background: var(--surface-muted);
}
.person-column button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.3rem;
  color: #173d4e;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}
.lesson-heading {
  min-width: 5.5rem;
  width: 5.5rem;
}
.lesson-heading button {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.3rem;
  font-weight: 600;
  color: #173d4e;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}
.lesson-heading small {
  display: block;
  font-weight: 400;
}
.month-table input[type="checkbox"] {
  width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0.6rem;
  cursor: pointer;
  accent-color: var(--primary);
}
.attendance-toggle {
  display: flex;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
}
.attendance-author {
  display: block;
  max-width: 12rem;
  margin: 0.35rem auto;
  color: var(--text-muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}
.attendance-author span,
.attendance-author time {
  display: block;
}
.attendance-pending {
  box-shadow: inset 0 0 0 2px #b97916;
}
#attendance-saving:empty {
  display: none;
}
.month-table .attendance-kind {
  display: block;
  width: 100%;
  min-width: 7.2rem;
  min-height: 44px;
  font-size: 0.85rem;
  padding: 0.4rem;
}
.month-table .attended {
  background: #e1f3e6;
}
.month-table .unavailable,
.month-table .cancelled {
  background: #edf0f2;
  color: var(--text-muted);
}
.month-table .total {
  font-weight: 600;
  min-width: 3.5rem;
}
.session-roster {
  width: fit-content;
}
.single-session .lesson-heading {
  width: 8rem;
}
.single-session .total {
  width: 4.5rem;
}
#newcomer-form label {
  display: block;
  margin: 0.7rem 0;
}
#newcomer-form input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
#newcomer-status[data-error="true"] {
  color: #a02821;
}
#report-text {
  display: block;
  width: 100%;
  resize: vertical;
  margin-top: 0.5rem;
}
#report-status[data-error="true"] {
  color: #a02821;
}
#report-status[data-dirty="true"] {
  font-weight: 600;
}
#saved-reports article {
  margin: 0.5rem 0;
  padding: 0.7rem;
  background: var(--page-bg);
}
.participant {
  padding-top: 0.5rem;
  border-top: 1px solid #e2e8ed;
}
.participant > button {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
}
.participant > label {
  flex-shrink: 0;
}
.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}
summary {
  cursor: pointer;
  padding: 0.6rem 0;
  font-weight: 600;
  min-height: 44px;
}
p,
li {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
fieldset {
  min-inline-size: 0;
  border: 1px solid var(--border);
  margin: 0.8rem 0;
}
fieldset label {
  margin: 0.4rem 0;
}
#status {
  padding: 0.7rem 0;
}
#status[data-error="true"] {
  color: #a02821;
}
#invite-link {
  width: 100%;
}
dl {
  overflow-wrap: anywhere;
}
dt {
  font-weight: 600;
  margin-top: 0.7rem;
}
dd {
  margin: 0.2rem 0;
}
dialog {
  border: 1px solid var(--control-border);
  border-radius: 0.7rem;
  width: min(90vw, 500px);
  color: var(--text);
  background: var(--surface);
}
dialog::backdrop {
  background: #152b4280;
}
[hidden] {
  display: none !important;
}
@media (max-width: 620px) {
  header {
    padding: 0.65rem;
    gap: 0.5rem;
  }
  main {
    padding: 0.75rem;
  }
  #identity {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
  }
  h1 {
    font-size: 1.5rem;
    margin: 0.7rem 0;
  }
  #status {
    margin: 0.3rem 0;
    padding: 0;
    font-size: 0.85rem;
  }
  .coach-sections {
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 0.2rem 0;
  }
  .coach-sections a {
    flex: 1 1 auto;
    min-width: 44px;
    padding-inline: 0.25rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  .journal-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.5rem;
    margin: 0.5rem 0;
  }
  .lesson-picker {
    padding: 0.5rem 0.6rem;
  }
  .lesson-picker h2 {
    margin-bottom: 0.25rem;
  }
  .lesson-picker .journal-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 0.35rem;
    margin: 0;
  }
  .roster-controls {
    margin: 0.35rem 0;
  }
  .journal-controls label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
  }
  .journal-controls select,
  .journal-controls input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .roster-controls label > span,
  .single-session caption,
  .single-session thead {
    /* The search and filter describe themselves. The lesson heading and cards
       replace the repeated table header on phones while keeping table semantics. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #newcomer-limit {
    margin: 0.5rem 0;
  }
  #newcomer-limit[data-exhausted="false"] {
    display: none;
  }
  #attendance-saving,
  #attendance-saving:empty {
    /* Reserve one line so a slow save does not move the next person's tap
       target as the coach quickly marks several people. */
    display: block;
    min-height: 1.2rem;
    margin: 0.2rem 0;
    font-size: 0.85rem;
  }
  #attendance-summary {
    padding: 0.45rem;
    margin: 0;
    font-size: 0.85rem;
  }
  #attendance-summary > span {
    font-size: 0.75rem;
  }
  #attendance-summary .summary-people,
  #cabinet[data-single-session="true"] .summary-visits {
    display: none;
  }
  .roster-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.4rem;
  }
  .roster-summary > p {
    min-width: 0;
  }
  .roster-actions {
    gap: 0.35rem;
  }
  .roster-actions button {
    padding: 0.45rem;
    font-size: 0.85rem;
  }
  #lessons > h2 {
    font-size: 1.12rem;
  }
  #refresh {
    min-width: 44px;
  }
  .desktop-button-text {
    display: none;
  }
  .refresh-icon,
  .mobile-button-text {
    display: inline;
  }
  .refresh-icon {
    font-size: 1.35rem;
  }
  /* A chosen lesson uses one set of editable controls as phone cards. The
     month overview retains its table; tapping a heading selects that lesson. */
  .session-roster {
    width: auto;
    max-height: none;
    overflow: visible;
    border: none;
    background: transparent;
  }
  .single-session,
  .single-session tbody {
    display: block;
    width: 100%;
  }
  .single-session tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8.25rem;
    align-items: start;
    gap: 0.5rem;
  }
  .single-session tbody tr {
    margin: 0.5rem 0;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--surface);
  }
  .single-session th,
  .single-session td {
    min-width: 0;
    border: none;
    padding: 0;
  }
  .single-session .person-column {
    position: static;
    min-width: 0;
    max-width: none;
    width: auto;
    background: transparent;
  }
  .single-session .person-column button {
    font-size: 1rem;
    min-height: 44px;
  }
  .single-session .attendance-cell {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: transparent;
  }
  .single-session .attendance-toggle {
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.35rem;
    border: 1px solid var(--control-border);
    border-radius: 0.45rem;
    background: var(--page-bg);
    flex-wrap: nowrap;
  }
  .single-session .attended .attendance-toggle {
    border-color: #3e8850;
    background: #e1f3e6;
  }
  .single-session .person-attended {
    border-left: 4px solid #3e8850;
  }
  .single-session input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
  }
  .single-session .attendance-toggle-text {
    display: inline;
    font-size: 0.8rem;
  }
  .single-session .attendance-kind {
    min-width: 0;
  }
  .single-session .attendance-author {
    margin: 0;
    max-width: none;
    width: 100%;
    font-size: 0.7rem;
  }
  .single-session tbody .total,
  .single-session thead .total,
  .single-session tfoot {
    display: none;
  }
  .participant {
    align-items: flex-start;
  }
}
/* Programme balance remains visible without expanding individual sections. */
.workout-time-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
}
.workout-time-summary p {
  margin: 0.25rem 0;
}
.workout-free-time {
  color: #245342;
  font-weight: 600;
}
.workout-time-exceeded {
  color: #a32626;
  font-weight: 600;
}
