:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --line: #e4e8ef;
  --green: #138a5b;
  --green-soft: #e9f8f1;
  --amber: #ad6700;
  --amber-soft: #fff4d9;
  --red: #c83e4d;
  --red-soft: #fff0f1;
  --blue: #3867d6;
  --shadow: 0 14px 36px rgba(17, 24, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(94, 224, 160, 0.13), transparent 35rem),
    var(--canvas);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom));
}

.boot-screen,
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 20px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 28px;
  font-weight: 800;
}

.login-card {
  width: min(100%, 390px);
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-card h1,
.page-header h1 {
  margin: 0;
  letter-spacing: -0.04em;
}

.login-card p,
.page-header p {
  margin: 8px 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 7px;
  text-align: left;
}

.field > span,
.field-label {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #ccd3df;
  border-radius: 13px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56, 103, 214, 0.14);
}

input:disabled,
textarea:disabled,
select:disabled {
  color: #7d8696;
  background: #f1f3f6;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  color: #fff;
  background: var(--ink);
}

.button-secondary {
  color: var(--ink);
  background: #e9edf3;
}

.button-success {
  color: #fff;
  background: var(--green);
}

.button-danger {
  color: #fff;
  background: var(--red);
}

.button-ghost {
  color: #344054;
  background: transparent;
}

.button-wide {
  width: 100%;
  margin-top: 14px;
}

.login-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 850;
}

.topbar .brand-mark {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 13px;
  font-size: 18px;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-online,
.tag-final {
  color: #08724a;
  background: var(--green-soft);
}

.status-offline,
.tag-pending {
  color: var(--amber);
  background: var(--amber-soft);
}

.tag-draft {
  color: #3a5ead;
  background: #edf2ff;
}

.page-header {
  margin-bottom: 18px;
}

.page-header h1 {
  font-size: clamp(30px, 8vw, 42px);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.day-card {
  position: relative;
  overflow: hidden;
  min-height: 148px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  text-align: left;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.05);
  cursor: pointer;
}

.day-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--day-accent, var(--green));
}

.day-day1 { --day-accent: #ef6c57; }
.day-day2 { --day-accent: #4b82d0; }
.day-day3 { --day-accent: #4a9b6f; }
.day-dayR { --day-accent: #8b68c8; }

.day-card strong,
.day-card span {
  display: block;
}

.day-card strong {
  margin-bottom: 7px;
  font-size: 20px;
}

.day-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.day-card .day-count {
  margin-top: 15px;
  color: var(--ink);
  font-weight: 750;
}

.readiness-card,
.history-card,
.exercise-card,
.summary-card,
.safety-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.045);
}

.readiness-card,
.summary-card,
.safety-card {
  padding: 17px;
}

.readiness-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.readiness-grid .field span {
  min-height: 34px;
}

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

.history-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
}

.history-card h3,
.history-card p {
  margin: 0;
}

.history-card h3 {
  margin-bottom: 4px;
  font-size: 15px;
}

.history-card p {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  padding: 25px;
  border: 1px dashed #cbd3df;
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

.workout-header {
  display: grid;
  gap: 13px;
  margin-bottom: 16px;
}

.workout-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.workout-header h1 {
  margin: 3px 0 3px;
  font-size: 28px;
  letter-spacing: -0.035em;
}

.workout-header p {
  margin: 0;
  color: var(--muted);
}

.exercise-list {
  display: grid;
  gap: 14px;
}

.exercise-card {
  overflow: hidden;
}

.exercise-head {
  padding: 17px 17px 13px;
  border-top: 4px solid var(--day-accent, var(--green));
}

.exercise-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.exercise-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.exercise-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.optional-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 11px;
  font-weight: 800;
}

.plan-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
}

.plan-value {
  padding: 9px;
  border-radius: 12px;
  background: #f3f5f8;
}

.plan-value span,
.plan-value strong {
  display: block;
}

.plan-value span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.plan-value strong {
  font-size: 13px;
}

.exercise-body {
  display: grid;
  gap: 13px;
  padding: 0 17px 17px;
}

.sets-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.set-input {
  display: grid;
  gap: 5px;
}

.set-input span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-align: center;
}

.set-input input {
  min-width: 0;
  padding-inline: 6px;
  text-align: center;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 8px;
}

.difficulty-field {
  grid-column: 1 / -1;
}

.difficulty-field select {
  min-height: 54px;
  line-height: 1.25;
}

.notes-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.safety-card {
  margin: 16px 0;
  color: #8f2c36;
  background: var(--red-soft);
  border-color: #ffd5da;
}

.safety-card strong {
  display: block;
  margin-bottom: 6px;
}

.safety-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.sticky-actions {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(208, 214, 224, 0.9);
  background: rgba(250, 251, 253, 0.92);
  backdrop-filter: blur(16px);
}

.sticky-actions-inner {
  width: min(100%, 728px);
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 10px;
  margin: 0 auto;
}

.sync-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
  text-align: center;
}

.locked-banner {
  padding: 14px;
  border-radius: 16px;
  color: #08724a;
  background: var(--green-soft);
  font-weight: 750;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 18px;
  bottom: calc(94px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 560px;
  margin: auto;
  padding: 13px 15px;
  border-radius: 14px;
  color: #fff;
  background: #1f2937;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--red);
}

@media (max-width: 520px) {
  .day-grid {
    grid-template-columns: 1fr;
  }

  .day-card {
    min-height: 124px;
  }

  .readiness-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sets-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metrics-grid .field:first-child {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
