:root {
  color-scheme: light;
  --ink: #f4f1e8;
  --ink-soft: #fffdf8;
  --panel: #eeebe2;
  --line: #d5d1c5;
  --text: #17201e;
  --muted: #5c6b66;
  --muted-dim: #74827d;
  --lime: #557f12;
  --lime-fill: #a8e84a;
  --orange: #bd481d;
  --aqua: #147c70;
  --cream: #38443f;
  --danger: #a73c20;
  --accent-ink: #13200f;
  --tone-ink: #fffdf8;
  --surface-glass: rgb(255 253 248 / 86%);
  --placeholder: #84908c;
  --dash-border: #a9b4af;
  --badge-border: #a7b5af;
  --preview-border: #c8c3b6;
  --tone-purple: #805ac5;
  --radius-large: 30px;
  --radius-medium: 20px;
  font-family:
    "Avenir Next", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-synthesis: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #0c1513;
  --ink-soft: #111f1c;
  --panel: #172622;
  --line: #2b3b36;
  --text: #f5f4ec;
  --muted: #94a69f;
  --muted-dim: #71837d;
  --lime: #b4ff45;
  --lime-fill: #b4ff45;
  --orange: #ff8c5a;
  --aqua: #6de6d2;
  --cream: #e8e4d6;
  --danger: #ffb29a;
  --accent-ink: #0c1513;
  --tone-ink: #0c1513;
  --surface-glass: rgb(17 31 28 / 80%);
  --placeholder: #62736d;
  --dash-border: #486058;
  --badge-border: #3d524b;
  --preview-border: #3b4e47;
  --tone-purple: #ba9cff;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 90% 0%, rgb(180 255 69 / 10%), transparent 28rem),
    var(--ink);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 3px;
}

.site-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 48px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.52fr);
  gap: 64px;
  min-height: 610px;
  padding: 42px 0 72px;
  border-bottom: 1px solid var(--line);
}

.topbar {
  position: absolute;
  top: 42px;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-decoration: none;
}

.wordmark__mark {
  width: 28px;
  height: 11px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    var(--orange) 0 42%,
    var(--lime-fill) 42%
  );
}

.theme-toggle {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--ink-soft);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 750;
}

.theme-toggle:hover {
  border-color: var(--lime);
}

.theme-toggle__icon {
  position: relative;
  width: 18px;
  height: 18px;
  border: 2px solid var(--orange);
  border-radius: 50%;
  background: var(--lime-fill);
}

html[data-theme="dark"] .theme-toggle__icon {
  border-color: var(--aqua);
  background: transparent;
}

html[data-theme="dark"] .theme-toggle__icon::after {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ink-soft);
  content: "";
}

.hero__content {
  align-self: end;
  max-width: 800px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 18px;
  color: var(--lime);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 850px;
  margin-bottom: 28px;
  font-size: clamp(3.2rem, 7vw, 6.8rem);
  font-weight: 800;
  letter-spacing: -0.07em;
  line-height: 0.92;
}

h1 span {
  color: var(--muted);
}

.hero__lede {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--cream);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.8;
}

.hero__examples {
  align-self: end;
  display: grid;
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--surface-glass);
}

.hero__examples > span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.hero__examples button {
  min-height: 72px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.5;
  text-align: left;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.hero__examples button:hover {
  border-color: var(--lime);
  background: rgb(180 255 69 / 6%);
  transform: translateY(-2px);
}

.hero__examples b {
  display: block;
  margin-bottom: 3px;
  color: var(--lime);
  font-family: var(--font-sans, system-ui);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(410px, 0.65fr);
  gap: 48px;
  padding: 72px 0 96px;
}

.builder,
.summary {
  min-width: 0;
}

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

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  letter-spacing: -0.045em;
}

.section-kicker {
  margin-bottom: 10px;
  color: var(--muted);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  min-width: 220px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--ink-soft);
}

.mode-switch button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-switch button.is-active {
  background: var(--lime-fill);
  color: var(--accent-ink);
}

.repeat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--ink-soft);
}

.repeat-row > label {
  font-weight: 700;
}

.repeat-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.repeat-control input {
  width: 86px;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 1.8rem;
  font-weight: 800;
  text-align: right;
}

.segments {
  display: grid;
  gap: 14px;
}

.segment-card {
  --tone: var(--orange);
  position: relative;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--ink-soft);
}

.segment-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tone);
  content: "";
}

.segment-card.tone-2 {
  --tone: var(--aqua);
}

.segment-card.tone-3 {
  --tone: var(--lime);
}

.segment-card.tone-4 {
  --tone: var(--tone-purple);
}

.segment-card__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.segment-number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--tone);
  color: var(--tone-ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.field {
  display: grid;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field--name {
  display: flex;
  align-items: center;
}

.field--name .field-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.name-input {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 750;
}

.remove-button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.remove-button:hover:not(:disabled) {
  color: var(--danger);
}

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

.segment-fields {
  display: grid;
  grid-template-columns: minmax(190px, 0.72fr) minmax(300px, 1.28fr);
  gap: 16px;
}

.field-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.field-label span {
  color: var(--muted-dim);
}

.field-input,
.unit-select {
  min-width: 0;
  min-height: 50px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}

.field-input {
  width: 100%;
  padding: 0 14px;
  border-radius: 12px;
}

.field-input::placeholder {
  color: var(--placeholder);
}

.amount-control {
  display: flex;
}

.amount-control .field-input {
  border-radius: 12px 0 0 12px;
}

.amount-control--time {
  position: relative;
}

.amount-control--time .field-input {
  padding-right: 100px;
  border-radius: 12px;
}

.unit-label {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  font-size: 0.72rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.unit-select {
  width: 72px;
  padding: 0 10px;
  border-left: 0;
  border-radius: 0 12px 12px 0;
}

.pace-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.pace-separator {
  color: var(--muted);
  font-size: 0.75rem;
}

.field-hint {
  margin-top: 7px;
  color: var(--muted-dim);
  font-size: 0.7rem;
}

.add-button {
  width: 100%;
  min-height: 58px;
  margin-top: 14px;
  border: 1px dashed var(--dash-border);
  border-radius: var(--radius-medium);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.add-button:hover:not(:disabled) {
  border-color: var(--lime);
  color: var(--lime);
}

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

.summary__sticky {
  position: sticky;
  top: 28px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background:
    linear-gradient(155deg, rgb(180 255 69 / 7%), transparent 38%),
    var(--ink-soft);
}

.section-heading--summary {
  align-items: flex-start;
}

.live-badge,
.card-dimensions {
  flex: none;
  padding: 7px 10px;
  border: 1px solid var(--badge-border);
  border-radius: 99px;
  color: var(--aqua);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.workout-expression {
  overflow-wrap: anywhere;
  margin-bottom: 26px;
  color: var(--lime);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  font-weight: 700;
  line-height: 1.55;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric {
  min-width: 0;
  padding: 20px;
  border-radius: 16px;
  background: var(--panel);
}

.metric--wide {
  grid-column: 1 / -1;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  overflow-wrap: anywhere;
  font-size: clamp(1.65rem, 3.2vw, 2.65rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
}

.range-notice,
.error-panel {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.5;
}

.range-notice {
  background: rgb(109 230 210 / 8%);
  color: var(--aqua);
}

.error-panel {
  background: rgb(255 140 90 / 10%);
  color: var(--danger);
}

.share-callout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 20px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.share-callout__tag {
  color: var(--orange);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.share-callout h3 {
  margin: 8px 0;
  font-size: 1.25rem;
}

.share-callout p,
.share-actions p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.65;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 0 20px;
  border-radius: 13px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  background: var(--lime-fill);
  color: var(--accent-ink);
  box-shadow: 0 10px 32px rgb(180 255 69 / 12%);
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.06);
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.share-panel {
  grid-column: 1 / -1;
  margin-top: 34px;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-large);
  background: var(--ink-soft);
}

.share-layout {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(280px, 440px);
  gap: clamp(34px, 6vw, 88px);
  align-items: center;
  justify-content: center;
}

.share-preview-frame {
  overflow: hidden;
  border: 1px solid var(--preview-border);
  border-radius: 22px;
  box-shadow: 0 28px 70px rgb(0 0 0 / 28%);
}

.share-preview-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.share-actions {
  display: grid;
  gap: 12px;
}

.share-actions > p:first-child {
  margin-bottom: 14px;
  font-size: 1rem;
}

.share-status {
  min-height: 1.5em;
  color: var(--aqua) !important;
}

footer {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  min-height: 110px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

footer span {
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.15em;
}

footer p {
  margin: 0;
  font-size: 0.78rem;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  .site-shell {
    padding: 0 28px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 42px;
    min-height: auto;
    padding-top: 170px;
  }

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

  .hero__examples > span {
    grid-column: 1 / -1;
  }

  main {
    grid-template-columns: 1fr;
  }

  .summary__sticky {
    position: static;
  }
}

@media (max-width: 680px) {
  .site-shell {
    padding: 0 16px;
  }

  .hero {
    gap: 32px;
    padding: 130px 0 48px;
  }

  .topbar {
    top: 28px;
  }

  h1 {
    font-size: clamp(3rem, 15vw, 4.7rem);
  }

  .hero__lede {
    font-size: 0.96rem;
  }

  .hero__examples {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  main {
    gap: 48px;
    padding: 48px 0 72px;
  }

  .section-heading {
    display: grid;
    align-items: start;
  }

  .mode-switch {
    width: 100%;
  }

  .segment-card {
    padding: 20px 18px;
  }

  .segment-fields {
    grid-template-columns: 1fr;
  }

  .summary__sticky {
    padding: 24px 18px;
  }

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

  .metric--wide {
    grid-column: auto;
  }

  .share-panel {
    padding: 26px 18px;
  }

  .share-layout {
    grid-template-columns: 1fr;
  }

  .share-preview-frame {
    max-width: 390px;
    margin: 0 auto;
  }

  footer {
    display: grid;
    gap: 8px;
    padding: 28px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition-duration: 0.01ms !important;
  }
}
