@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap");

:root {
  --paper: #f5f1e8;
  --ink: #173c36;
  --ink-soft: #526963;
  --card: #fffdf8;
  --line: #dcd7cc;
  --orange: #f26a3d;
  --orange-dark: #d9552d;
  --mint: #dce9df;
  --yellow: #f4cf66;
  --shadow: 0 18px 50px rgba(39, 58, 52, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(244, 207, 102, 0.2), transparent 28rem),
    radial-gradient(circle at 100% 100%, rgba(220, 233, 223, 0.9), transparent 32rem),
    var(--paper);
  font-family: "DM Sans", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.build-badge {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 99999;
  padding: 7px 10px;
  border: 1px solid rgba(242, 106, 61, 0.45);
  border-radius: 8px;
  color: var(--ink);
  background: #fff6d8;
  box-shadow: 0 8px 22px rgba(39, 58, 52, 0.16);
  font-size: 0.72rem;
  font-weight: 800;
}

.app-shell {
  width: min(100%, 700px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 54px 24px 40px;
}

.view[hidden] {
  display: none;
}

.hero {
  position: relative;
  padding-right: 80px;
  margin-bottom: 34px;
}

.brand-mark {
  position: absolute;
  top: 8px;
  right: 0;
  width: 62px;
  height: 62px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: grid;
  place-content: center;
  gap: 4px;
  transform: rotate(-8deg);
}

.brand-mark span {
  display: block;
  width: 27px;
  height: 3px;
  border-radius: 3px;
  background: var(--orange);
}

.brand-mark span:nth-child(2) {
  width: 38px;
  background: var(--ink);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--orange-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  letter-spacing: -0.04em;
}

.hero h1 {
  font-size: clamp(2.8rem, 10vw, 5.4rem);
  line-height: 0.98;
}

.hero-copy {
  max-width: 440px;
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.6;
}

.summary-card {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.7);
  box-shadow: var(--shadow);
}

.summary-card > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 17px 20px;
  border-radius: 15px;
  background: var(--ink);
  color: white;
}

.summary-label,
.rest-setting > span:first-child {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#total-duration {
  margin-top: 4px;
  font-family: "Manrope", sans-serif;
  font-size: 1.8rem;
}

.rest-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 10px 12px 16px;
}

.number-input,
.duration-field {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.number-input input,
.duration-field input {
  width: 48px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
  text-align: right;
}

.number-input small,
.duration-field small {
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 700;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
}

.saved-workouts-section,
.account-section {
  margin-bottom: 42px;
}

.account-section details {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow);
}

.account-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.section-note {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 750;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 12px;
  padding: 0 14px 14px;
}

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

.account-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.account-panel label {
  display: grid;
  gap: 5px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.account-panel input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: white;
}

.account-panel button,
.import-data-button {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.import-data-button input {
  display: none;
}

.saved-heading {
  margin-bottom: 14px;
}

.saved-workout-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.empty-saved-message {
  grid-column: 1 / -1;
  margin: 0;
  padding: 20px;
  border: 1px dashed #bbb7ac;
  border-radius: 16px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  text-align: center;
}

.saved-workout-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.load-saved-workout {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.load-saved-workout:hover {
  background: #f7f3e9;
}

.saved-workout-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--orange-dark);
  background: #fce6df;
  font-size: 0.66rem;
}

.saved-workout-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.saved-workout-name {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-workout-details {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.delete-saved-workout {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #8b9a96;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}

.delete-saved-workout:hover {
  color: var(--orange-dark);
  background: #fce6df;
}

.save-workout-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 9px;
  margin-top: 10px;
}

.save-name-field input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  color: var(--ink);
  background: white;
}

.save-name-field input:focus {
  border-color: var(--ink);
}

.save-workout-button,
.new-workout-button {
  height: 48px;
  padding: 0 17px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
}

.save-workout-button {
  color: white;
  background: var(--ink);
}

.new-workout-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
}

.save-workout-button span {
  margin-right: 5px;
  color: var(--yellow);
}

.save-message {
  min-height: 18px;
  margin: 7px 0 0;
  color: var(--orange-dark);
  font-size: 0.76rem;
}

.section-heading h2 {
  font-size: 1.85rem;
}

.count-pill {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--mint);
  font-size: 0.76rem;
  font-weight: 800;
}

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

.exercise-card,
.block-exercise-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--card);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.exercise-card:focus-within,
.block-card:focus-within {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(39, 58, 52, 0.08);
}

.block-card {
  display: grid;
  gap: 10px;
  padding: 13px 12px;
  border: 1.5px solid rgba(242, 106, 61, 0.32);
  border-radius: 19px;
  background: #fff9ee;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.block-header {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
}

.block-repeat-field,
.block-rest-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 850;
}

.block-repeat-field input,
.block-rest-field input {
  width: 58px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: white;
  font-weight: 850;
  text-align: right;
}

.block-exercise-list {
  display: grid;
  gap: 8px;
  padding-left: 16px;
  border-left: 3px solid rgba(242, 106, 61, 0.22);
}

.block-exercise-card {
  grid-template-columns: 28px minmax(0, 1fr) auto 30px;
  padding: 9px 9px;
  border-radius: 14px;
}

.block-exercise-card .exercise-number {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 0.7rem;
}

.exercise-number {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--mint);
  font-family: "Manrope", sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
}

.exercise-name-field input {
  width: 100%;
  padding: 8px 4px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
  font-weight: 700;
}

.exercise-name-field input::placeholder {
  color: #9ba8a4;
}

.delete-exercise,
.delete-block {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #8b9a96;
  background: transparent;
  font-size: 1.35rem;
  cursor: pointer;
}

.delete-exercise:hover,
.delete-block:hover {
  color: var(--orange-dark);
  background: #fce6df;
}

.add-button,
.primary-button,
.text-button,
.icon-button,
.secondary-control,
.pause-button {
  border: 0;
  cursor: pointer;
}

.add-button {
  width: 100%;
  margin-top: 11px;
  padding: 15px;
  border: 1.5px dashed #b9b5aa;
  border-radius: 17px;
  color: var(--ink-soft);
  background: transparent;
  font-weight: 700;
}

.add-button span {
  margin-right: 8px;
  color: var(--orange-dark);
  font-size: 1.2rem;
}

.secondary-add {
  margin-top: 9px;
}

.add-block-exercise {
  justify-self: start;
  min-height: 36px;
  padding: 0 12px;
  border: 1px dashed #b9b5aa;
  border-radius: 12px;
  color: var(--ink-soft);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 26px;
  padding: 19px 24px;
  border-radius: 17px;
  color: white;
  background: var(--orange);
  box-shadow: 0 12px 28px rgba(242, 106, 61, 0.25);
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  font-weight: 800;
  transition: transform 150ms ease, background 150ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: var(--orange-dark);
}

.primary-button span {
  font-size: 1.4rem;
}

.error-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--orange-dark);
  font-size: 0.82rem;
  text-align: center;
}

.timer-view {
  min-height: calc(100vh - 94px);
  display: flex;
  flex-direction: column;
}

.timer-topbar {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 24px;
}

.icon-button,
.secondary-control {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.8);
  font-size: 1.5rem;
}

.sound-button {
  font-size: 1.1rem;
}

.sound-button.muted {
  color: #9ba8a4;
  text-decoration: line-through;
}

.step-indicator {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.step-track {
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #dcd8ce;
}

.step-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  transition: width 300ms ease;
}

.timer-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px 0 28px;
  text-align: center;
}

.phase-label {
  margin: 0 0 12px;
  padding: 7px 15px;
  border-radius: 999px;
  color: var(--orange-dark);
  background: #fce6df;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.timer-view.resting .phase-label {
  color: var(--ink);
  background: var(--mint);
}

.timer-content h1 {
  max-width: 100%;
  font-size: clamp(2.1rem, 9vw, 4.3rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.next-exercise {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.timer-ring {
  position: relative;
  width: min(70vw, 330px);
  aspect-ratio: 1;
  margin-top: 28px;
}

.timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring circle {
  fill: none;
  stroke-width: 9;
}

.ring-background {
  stroke: #dedbd2;
}

.ring-progress {
  stroke: var(--orange);
  stroke-linecap: round;
  stroke-dasharray: 659.73;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 250ms linear;
}

.resting .ring-progress {
  stroke: var(--ink);
}

.timer-number {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.timer-number strong {
  font-family: "Manrope", sans-serif;
  font-size: clamp(3.1rem, 14vw, 5.5rem);
  letter-spacing: -0.07em;
  line-height: 1;
}

.timer-number span {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.secondary-control:disabled {
  opacity: 0.35;
  cursor: default;
}

.pause-button {
  min-width: 150px;
  height: 60px;
  padding: 0 24px;
  border-radius: 18px;
  color: white;
  background: var(--ink);
  font-weight: 800;
}

.pause-button span:first-child {
  margin-right: 9px;
}

.complete-view {
  min-height: calc(100vh - 94px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.celebration {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
  color: var(--orange);
  font-size: 1.4rem;
}

.celebration span:nth-child(even) {
  color: var(--yellow);
  font-size: 0.8rem;
}

.complete-view h1 {
  font-size: clamp(3.4rem, 13vw, 6rem);
}

.complete-copy {
  max-width: 460px;
  margin: 18px auto 28px;
  color: var(--ink-soft);
  line-height: 1.65;
}

.complete-stats {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--line);
}

.complete-stats div {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--card);
}

.complete-stats strong {
  font-family: "Manrope", sans-serif;
  font-size: 1.8rem;
}

.complete-stats span {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.complete-view .primary-button {
  max-width: 420px;
}

.text-button {
  margin-top: 20px;
  padding: 8px;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  .app-shell {
    padding: 34px 16px 28px;
  }

  .summary-card {
    grid-template-columns: 1fr;
  }

  .summary-card > div {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .saved-workout-list {
    grid-template-columns: 1fr;
  }

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

  .save-workout-row {
    grid-template-columns: 1fr;
  }

  .save-workout-button {
    width: 100%;
  }

  #total-duration {
    margin: 0;
  }

  .exercise-card,
  .block-exercise-card {
    grid-template-columns: 34px minmax(0, 1fr) 74px 28px;
    gap: 6px;
    padding: 11px 8px;
  }

  .block-header {
    grid-template-columns: 34px minmax(0, 1fr) 28px;
  }

  .block-rest-field {
    grid-column: 2 / -1;
  }

  .delete-block {
    grid-column: 3;
    grid-row: 1;
  }

  .exercise-number {
    width: 32px;
    height: 32px;
  }

  .timer-view,
  .complete-view {
    min-height: calc(100vh - 62px);
  }

  .timer-topbar {
    gap: 14px;
  }
}

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