:root {
  color-scheme: light;
  --ink: #1f2528;
  --muted: #617071;
  --paper: #f6f1e8;
  --panel: #fffaf1;
  --line: #d9d0c0;
  --teal: #137f78;
  --teal-dark: #0f5d59;
  --coral: #e9674f;
  --gold: #e2a72e;
  --blue: #365b86;
  --mint: #b9d8cb;
  --shadow: 0 18px 45px rgba(31, 37, 40, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(19, 127, 120, 0.12) 0 24%, transparent 24% 100%),
    linear-gradient(315deg, rgba(226, 167, 46, 0.18) 0 18%, transparent 18% 100%),
    repeating-linear-gradient(0deg, rgba(31, 37, 40, 0.035) 0 1px, transparent 1px 24px),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(233, 103, 79, 0.45);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 1040px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

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

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(31, 37, 40, 0.16);
}

.brand-mark svg {
  width: 26px;
  fill: var(--gold);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 1.25rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-chip {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.76);
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
  gap: 16px;
  align-items: stretch;
}

.timer-panel,
.stretch-panel {
  border: 1px solid rgba(31, 37, 40, 0.1);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.88);
  box-shadow: var(--shadow);
}

.timer-panel {
  min-height: 620px;
  padding: 26px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 22px;
}

.dial {
  --progress: 0;
  width: min(100%, 390px);
  aspect-ratio: 1;
  margin: auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--teal) calc(var(--progress) * 1%), rgba(31, 37, 40, 0.09) 0),
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 250, 241, 0.4));
  box-shadow:
    inset 0 0 0 1px rgba(31, 37, 40, 0.06),
    0 26px 48px rgba(19, 127, 120, 0.16);
}

.app-shell[data-phase="stretch"] .dial {
  background:
    conic-gradient(var(--coral) calc(var(--progress) * 1%), rgba(31, 37, 40, 0.09) 0),
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 250, 241, 0.4));
}

.dial-core {
  width: calc(100% - 42px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid rgba(31, 37, 40, 0.08);
  text-align: center;
}

.dial-core p {
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 800;
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 4.4rem;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.routine-line {
  max-width: 220px;
  min-height: 1.4em;
  color: var(--blue) !important;
}

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

.primary,
.icon-button,
.preset {
  min-height: 52px;
  border-radius: 8px;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary:hover,
.icon-button:hover,
.preset:hover {
  transform: translateY(-1px);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--ink);
  color: white;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(31, 37, 40, 0.18);
}

.primary svg,
.icon-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.icon-button {
  display: grid;
  place-items: center;
  background: #f0e6d8;
  color: var(--ink);
  border: 1px solid rgba(31, 37, 40, 0.08);
}

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

.preset {
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 10px;
  text-align: left;
  color: var(--ink);
  background: #f0e6d8;
  border: 1px solid transparent;
}

.preset span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.preset strong {
  font-size: 1.08rem;
}

.preset.is-active {
  background: #e6f0eb;
  border-color: rgba(19, 127, 120, 0.38);
  box-shadow: inset 0 0 0 1px rgba(19, 127, 120, 0.12);
}

.stretch-panel {
  min-height: 620px;
  padding: 20px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.pose-frame {
  min-height: 176px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(54, 91, 134, 0.1), rgba(19, 127, 120, 0.12)),
    #efe9dc;
  border: 1px solid rgba(31, 37, 40, 0.08);
}

.pose {
  width: min(100%, 260px);
}

.pose .mat {
  fill: rgba(31, 37, 40, 0.11);
}

.pose .head {
  fill: var(--gold);
  stroke: var(--ink);
  stroke-width: 5;
}

.pose .body,
.pose .arm,
.pose .leg {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 13;
}

.pose .body {
  stroke: var(--ink);
}

.accent-a {
  stroke: var(--coral);
}

.accent-b {
  stroke: var(--teal);
}

.accent-c {
  stroke: var(--blue);
}

.accent-d {
  stroke: var(--gold);
}

.settings {
  display: grid;
  gap: 12px;
}

.settings label {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 12px;
  align-items: center;
  color: var(--ink);
  font-weight: 800;
}

.settings output {
  justify-self: end;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
}

.settings input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--teal);
}

.routine-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}

.routine-list li {
  min-height: 54px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(31, 37, 40, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
}

.routine-list li.is-current {
  background: #fff2dd;
  border-color: rgba(226, 167, 46, 0.58);
}

.routine-list .count {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.routine-list strong {
  display: block;
  font-size: 0.96rem;
}

.routine-list span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.routine-list .tag {
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--mint);
  font-size: 0.72rem;
  font-weight: 900;
}

@media (max-width: 820px) {
  .app-shell {
    justify-content: flex-start;
    padding: 16px;
  }

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

  .timer-panel,
  .stretch-panel {
    min-height: auto;
  }

  .timer-panel {
    padding: 18px;
  }

  .dial {
    width: min(100%, 330px);
  }

  .time {
    font-size: 3.5rem;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-chip {
    width: 100%;
  }

  .controls {
    grid-template-columns: 1fr 50px 50px;
  }

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

  .time {
    font-size: 3rem;
  }

  .routine-list li {
    grid-template-columns: 34px 1fr;
  }

  .routine-list .tag {
    grid-column: 2;
    justify-self: start;
  }
}

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