/* GymCrimea — minimalist light */
:root {
  --bg: #f4f4f5;
  --bg-card: #ffffff;
  --bg-muted: #ebebed;
  --bg-hover: #f0f0f2;
  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #18181b;
  --accent-soft: #3f3f46;
  --danger: #71717a;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --nav-h: 60px;
  --header-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 20px 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-mark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.header__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.header__subtitle {
  margin: 2px 0 0;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Main */
.main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 20px;
}

.panel {
  display: none;
  animation: fadeIn 0.22s ease;
}

.panel--active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel__title--static {
  margin-bottom: 20px;
  font-size: 1.35rem;
  font-weight: 700;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0 0 20px;
  line-height: 1.5;
}

.section-label {
  margin: 24px 0 10px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-soft);
}

.btn--outline {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn--outline:hover {
  background: var(--bg-hover);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 9px 16px;
  font-size: 0.8rem;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
}

.btn--delete {
  margin-top: 10px;
  width: auto;
  font-size: 0.75rem;
  padding: 7px 14px;
  color: var(--text-secondary);
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.icon-btn--flip svg {
  transform: scaleX(-1);
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

/* Calendar */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  min-height: 44px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s;
}

.cal-day--empty {
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
}

.cal-day--today {
  border-color: var(--accent);
  font-weight: 600;
}

.cal-day--selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cal-day--has-workout .cal-day__dot {
  display: block;
}

.cal-day__dot {
  display: none;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-secondary);
}

.cal-day--selected .cal-day__dot {
  background: rgba(255, 255, 255, 0.85);
}

.cal-day__count {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
}

.cal-day--selected .cal-day__count {
  color: rgba(255, 255, 255, 0.9);
}

.day-detail__date {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.workout-card-mini {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.workout-card-mini:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.workout-card-mini strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.workout-card-mini__ex {
  font-size: 0.8rem;
  margin-top: 6px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Fields */
.field {
  display: block;
  margin-bottom: 12px;
}

.field--last {
  margin-bottom: 0;
}

.field__label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field__input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field__input::placeholder {
  color: var(--text-muted);
}

.field__input:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
  background: var(--bg-card);
}

.field-input-wrap {
  position: relative;
  margin-bottom: 12px;
}

.field-input-wrap__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.field-input-wrap .field__input {
  padding-left: 42px;
}

/* Exercise blocks */
.exercise-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.exercise-block__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.exercise-block__name {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.exercise-block__muscle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

.set-row {
  display: grid;
  grid-template-columns: 24px 1fr 1fr 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.set-row__num {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.set-row input {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  min-width: 0;
}

.set-row input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: var(--bg-card);
}

.btn-remove-set,
.btn-remove-ex {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 1.25rem;
  font-weight: 300;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.exercise-block__actions {
  margin-top: 4px;
}

.exercise-block__actions button {
  width: 100%;
  padding: 10px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  letter-spacing: 0.02em;
}

.exercise-block__actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Suggest */
.exercise-picker {
  position: relative;
  margin-bottom: 12px;
}

.exercise-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-md);
}

.exercise-suggest li button {
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text);
  text-align: left;
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.exercise-suggest li button small {
  color: var(--text-muted);
}

.exercise-suggest li button:hover,
.exercise-suggest li button:focus {
  background: var(--bg-hover);
}

.workout-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
  padding: 16px 0 4px;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 28%);
}

.workout-actions .btn {
  flex: 1;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.stat-card__value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
}

.stat-card__label {
  display: block;
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.pr-list,
.freq-list,
.exercise-library {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pr-list li,
.freq-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-sm);
}

.pr-list__weight {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.freq-bar {
  height: 4px;
  background: var(--bg-muted);
  border-radius: 2px;
  flex: 1;
  max-width: 80px;
  margin-left: auto;
  overflow: hidden;
}

.freq-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

/* Library */
.lib-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.lib-header .panel__title--static {
  margin-bottom: 0;
}

.lib-header__count {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.muscle-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
}

.filter-chip {
  padding: 7px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.filter-chip--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.exercise-library {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ex-lib-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 12px 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ex-lib-item:hover {
  border-color: var(--border-strong);
}

.ex-lib-item--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.ex-lib-item__thumb {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.ex-lib-item__body {
  flex: 1;
  min-width: 0;
}

.ex-lib-item__name {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ex-lib-item__meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.ex-lib-item__chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
}

/* Exercise detail */
.ex-detail__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  padding: 6px 0;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.ex-detail__back:hover {
  color: var(--text);
}

.ex-detail__hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.ex-detail__title {
  margin: 0 0 14px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.ex-detail__meta {
  margin: 0;
  display: grid;
  gap: 10px;
}

.ex-detail__meta div {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  font-size: 0.82rem;
}

.ex-detail__meta dt {
  color: var(--text-muted);
  font-weight: 500;
}

.ex-detail__meta dd {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.ex-detail__video-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  aspect-ratio: 16 / 10;
}

.ex-detail__video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #e8e8ec;
}

.ex-detail__tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.ex-tab {
  flex: 1;
  padding: 13px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  letter-spacing: -0.01em;
}

.ex-tab--active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.ex-detail__panel {
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: 0;
  margin-bottom: 14px;
  padding: 18px;
  border-top: none;
  min-height: 100px;
}

.ex-detail__panel .empty-state {
  padding: 12px 0;
}

.ex-detail__how ol {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text-secondary);
}

.ex-detail__how li {
  margin-bottom: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.ex-detail__how li::marker {
  color: var(--text-muted);
  font-weight: 600;
}

.ex-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.ex-stat-row:last-child {
  border-bottom: none;
}

.ex-stat-row strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ex-history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.ex-history-item:last-child {
  border-bottom: none;
}

.ex-history-item__date {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: capitalize;
}

.ex-detail__cta {
  margin-bottom: 8px;
}

#panelExercises:has(#exerciseDetailView:not([hidden])) #libraryListView {
  display: none;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 0 8px var(--safe-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  padding: 8px 4px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.bottom-nav__item--active {
  color: var(--text);
}

.bottom-nav__item--active .bottom-nav__icon {
  stroke-width: 2;
}

.bottom-nav__icon {
  display: block;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--accent);
  color: #fff;
  padding: 11px 20px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 200;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 16px;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Larger screens */
@media (min-width: 481px) {
  body {
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 28px);
  }

  .main {
    padding: 24px 28px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .toast {
    animation: none;
    transition: none;
  }
}
