/* Workouts screens: feed (/), session detail, logging form. Tokens only. */

/* ---- Feed ---- */
.feed-stats { grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-bottom: var(--space-4); }
.feed-stats .stat-tile { padding: var(--space-3); text-align: center; }
.feed-filters { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.feed-search { width: 100%; min-height: var(--tap); }
.feed-chips-wrap { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.feed-chips {
  --fade-l: 0px; --fade-r: 0px;
  flex: 1; min-width: 0;
  display: flex; gap: var(--space-2);
  overflow-x: auto; overscroll-behavior-x: contain;
  padding-bottom: var(--space-1);
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
.feed-chips::-webkit-scrollbar { display: none; }
.feed-chips.fade-l { --fade-l: 28px; }
.feed-chips.fade-r { --fade-r: 28px; }
/* Mouse users get a thin visible scrollbar as well as the arrows. */
@media (pointer: fine) {
  .feed-chips { scrollbar-width: thin; padding-bottom: 6px; }
  .feed-chips::-webkit-scrollbar { display: block; height: 6px; }
  .feed-chips::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
}
.feed-chips-arrow {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: 50%;
  background: var(--surface); color: var(--text);
  font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.feed-chips-arrow:hover { background: var(--surface-2); }
@media (pointer: coarse) { .feed-chips-arrow { width: var(--tap); height: var(--tap); } }
.filter-chip {
  flex: 0 0 auto;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.filter-chip:hover { background: var(--surface-2); }
.filter-chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
@media (pointer: coarse) { .filter-chip { min-height: var(--tap); } }

.feed-group { margin-bottom: var(--space-5); }
.feed-group__title {
  position: sticky;
  top: 52px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 calc(var(--space-2) * -1) var(--space-2);
  padding: var(--space-2);
  background: var(--bg);
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.feed-group__count { font-variant-numeric: tabular-nums; font-weight: 700; }

.session-item { align-items: center; justify-content: flex-start; gap: var(--space-3); min-height: 64px; text-align: left; }
.session-daytile {
  flex: 0 0 auto;
  width: 48px;
  padding: var(--space-1) 0;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
  text-align: center;
  line-height: 1.15;
}
.session-daytile__num { display: block; font-size: var(--text-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.session-daytile__dow { display: block; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.session-main { flex: 1; min-width: 0; text-align: left; }
.session-type { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; }
.session-date { font-weight: 500; font-size: var(--text-xs); }
.session-body { font-size: var(--text-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .session-count { flex: 0 0 auto; }
@media (max-width: 480px) {
  .session-item .session-count { font-size: 0.6875rem; padding-inline: var(--space-2); }
}

/* ---- Detail ---- */
.detail-header h1 { margin: var(--space-1) 0; }
.detail-chips { margin-top: var(--space-2); }
.session-notes { color: var(--text-muted); font-size: var(--text-sm); margin-bottom: var(--space-3); }
.session-notes p { margin: 0; }
.card.exercise-log-row { padding: var(--space-4); border: 1px solid var(--border); }

.exercise-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.exercise-head .exercise-name { flex: 1; min-width: 0; font-size: var(--text-lg); font-weight: 700; }
.exercise-head .field-group { min-width: 0; align-items: flex-end; flex: 0 0 auto; }
.exercise-log-row > .field-group { max-width: none; }
.exercise-log-row .series-table { margin-top: var(--space-3); }
.exercise-log-row .series-table th { text-transform: uppercase; font-size: var(--text-xs); letter-spacing: 0.04em; }
.exercise-log-row .series-table tbody tr:nth-child(even) { background: var(--surface-2); }
.exercise-log-row .series-table td { font-variant-numeric: tabular-nums; }
.detail-header ~ .actions .btn { flex: 1 1 auto; }
@media (max-width: 480px) {
  .detail-header ~ .actions .btn { flex: 1 1 calc(50% - var(--space-3)); }
}

/* ---- Logging form ---- */
.section-title { margin: var(--space-2) 0 0; }
.exercise-stack { margin-bottom: var(--space-4); }
.exercise-stack .exercise-log-row { margin-bottom: 0; }
.exercise-head .series-count { flex: 0 0 auto; font-size: var(--text-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
/* Per-row remove (✕) and "+ Add set" below the grid. */
.exercise-log-row .series-table .series-remove-col { width: calc(var(--tap) + 0.5rem); padding-left: 0; padding-right: 0; text-align: center; }
.series-remove { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: var(--radius-sm, 6px); background: transparent; color: var(--text-muted); font-size: var(--text-sm); cursor: pointer; }
.series-remove:hover:not(:disabled) { color: var(--danger); background: var(--surface-2); }
.series-remove:focus-visible { outline: none; box-shadow: var(--ring); }
.series-remove:disabled { opacity: 0.35; cursor: default; }
.exercise-log-row .series-add { margin-top: var(--space-2); }
.rest-timer { margin-top: var(--space-3); flex-wrap: wrap; }
.exercise-log-row .series-table { table-layout: fixed; }
.exercise-log-row .series-table th:first-child,
.exercise-log-row .series-table td.series-row-number { width: 2.5rem; }
.exercise-log-row .series-table input[type="number"] { min-height: var(--tap); font-size: 1rem; text-align: center; padding: 0.4rem 0.25rem; }
.set-timer .btn-timer-toggle { min-height: 36px; }

.save-bar { position: sticky; bottom: 0; z-index: 20; margin-top: var(--space-4); padding: var(--space-3) 0; background: var(--bg); border-top: 1px solid var(--border); }
.save-bar .btn { min-height: var(--tap); }
.save-bar .btn-primary { flex: 1 1 auto; }
@media (max-width: 760px) {
  .save-bar {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    margin-inline: calc(var(--space-4) * -1);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow);
  }
  .save-bar .btn-primary { order: 2; }
}

/* ---- Feed cards on phones ----
   Stack the count under the title instead of squeezing it into a chip beside
   it, so the title gets the row's full width. The long date is redundant with
   the day tile + month header, so it is kept for screen readers only. */
@media (max-width: 560px) {
  .session-item {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    column-gap: var(--space-3);
    row-gap: var(--space-1);
    align-items: start;
    padding-block: var(--space-3);
  }
  .session-daytile { grid-row: 1 / span 2; }
  .session-main { grid-column: 2; }
  .session-type { -webkit-line-clamp: 3; font-size: var(--text-base); font-weight: 700; line-height: 1.3; }
  .session-date {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .session-body { margin-top: 2px; }
  .session-item .session-count {
    grid-column: 2; justify-self: start;
    padding: 0; min-height: 0;
    background: none; border: 0; border-radius: 0;
    color: var(--text-muted); font-size: var(--text-xs); font-weight: 600;
  }
}
