:root {
  color-scheme: light;
  --tg-bg: #f5f7fb;
  --tg-text: #142033;
  --tg-hint: #718096;
  --accent: #2f80ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px
    calc(24px + env(safe-area-inset-bottom));
}

.card {
  padding: 20px;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 14px 40px rgba(31, 54, 88, 0.1);
}

.app-header,
.section-heading,
.hero-card,
.list-card,
.history-card,
.plan-summary {
  display: flex;
  align-items: center;
}

.app-header {
  justify-content: space-between;
  margin-bottom: 22px;
}

.app-header h1 {
  margin-bottom: 0;
}

.ghost-button,
.primary-button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.ghost-button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(47, 128, 237, 0.1);
  color: var(--accent);
  font-size: 24px;
}

.section-heading {
  justify-content: space-between;
  margin: 26px 2px 12px;
}

.section-heading h2,
.hero-card h2,
.card h2 {
  margin: 0;
}

.section-heading p {
  margin: 4px 0 0;
}

.hero-card {
  gap: 16px;
  margin-bottom: 22px;
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, #2f80ed, #56ccf2);
  color: #ffffff;
}

.hero-card.compact {
  align-items: flex-start;
  margin-bottom: 14px;
}

.hero-card .eyebrow {
  color: rgba(255, 255, 255, 0.76);
}

.hero-card p {
  margin: 4px 0 0;
}

.avatar,
.icon-tile,
.day-number,
.exercise-index {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #e9f2ff;
  color: var(--accent);
  font-weight: 800;
}

.avatar.large {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-size: 22px;
}

.icon-tile,
.day-number,
.exercise-index {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #edf5ff;
  color: var(--accent);
  font-weight: 800;
}

.icon-tile.large {
  width: 54px;
  height: 54px;
  font-size: 24px;
}

.count-badge {
  min-width: 28px;
  padding: 5px 9px;
  border-radius: 10px;
  background: #e9f2ff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.list {
  display: grid;
  gap: 10px;
}

.list-card {
  width: 100%;
  gap: 13px;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.entity-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.entity-main {
  display: flex;
  width: 100%;
  gap: 13px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.entity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 57px;
}

.entity-actions button {
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 13px;
}

.danger-button {
  border: 0;
  background: #fff0f0;
  color: #b33a3a;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.exercise-card {
  display: flex;
  width: 100%;
  gap: 13px;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.list-card-content {
  min-width: 0;
  display: grid;
  flex: 1;
  gap: 4px;
}

.list-card-content strong {
  overflow-wrap: anywhere;
}

.chevron {
  color: #9aa8bb;
  font-size: 28px;
  line-height: 1;
}

.plan-line {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.weekly-card {
  padding: 20px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.metrics span,
.set-chips span {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f1f5fa;
  font-size: 13px;
}

.plan-summary {
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.history-list {
  margin-top: 12px;
}

.history-card {
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
}

.history-date {
  color: var(--tg-hint);
  font-weight: 700;
}

.set-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.empty-card,
.loading {
  color: var(--tg-hint);
  text-align: center;
}

.primary-button {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.full-width {
  width: 100%;
  margin-bottom: 14px;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.plan-fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 15px 16px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(31, 54, 88, 0.08);
}

.stat-card span,
.form-label,
.form-row label {
  color: var(--tg-hint);
  font-size: 13px;
  font-weight: 600;
}

.target-card {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 20px;
  border-radius: 20px;
  background: #eaf3ff;
  color: #135ba8;
}

.target-card .eyebrow {
  color: #2474c7;
}

.target-card strong {
  font-size: 27px;
}

.rest-card {
  margin-bottom: 12px;
  padding: 13px 16px;
  border-radius: 14px;
  background: #fff7e6;
  color: #906314;
}

.set-form,
.recorded-card {
  margin-bottom: 12px;
}

.form-row {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.form-row input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #d9e2ee;
  border-radius: 12px;
  background: #fbfdff;
  color: var(--tg-text);
  font: inherit;
  font-size: 17px;
}

.rir-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.rir-button,
.secondary-button {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.rir-button {
  min-width: 42px;
  padding: 9px 10px;
  border-radius: 11px;
  background: #f0f4f9;
  color: var(--tg-text);
}

.rir-button.selected {
  background: var(--accent);
  color: #ffffff;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.secondary-button {
  padding: 12px 13px;
  border-radius: 12px;
  background: #eaf0f7;
  color: #38506e;
}

.workout-progress-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.workout-progress-list > strong {
  margin-bottom: 3px;
}

.workout-progress {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  color: #65748a;
  font-size: 14px;
}

.workout-progress.is-done {
  color: #23835a;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #edf1f6;
}

.summary-line:last-child {
  border-bottom: 0;
}

.error-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #fff0f0;
  color: #d64545;
  font-weight: 800;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

h1 {
  margin: 10px 0 12px;
  font-size: 32px;
}

h2 {
  font-size: 20px;
}

p {
  line-height: 1.5;
}

.muted {
  color: var(--tg-hint);
  font-size: 14px;
}
