:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #eef5ef;
  --ink: #17211f;
  --muted: #66736e;
  --line: #dbe4df;
  --accent: #1d5f57;
  --accent-2: #d95f32;
  --accent-3: #5472b8;
  --gold: #f4c76b;
  --shadow: 0 18px 45px rgba(23, 33, 31, 0.09);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(29, 95, 87, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(217, 95, 50, 0.1), transparent 26%),
    var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #102d2a;
  color: #f8fbf8;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #102d2a;
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

.brand p,
.date-card span {
  color: rgba(248, 251, 248, 0.68);
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: rgba(248, 251, 248, 0.78);
  padding: 12px 14px;
  border-radius: 8px;
  text-align: left;
}

.nav-tab.active,
.nav-tab:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.date-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 6px;
}

.date-card strong {
  font-size: 24px;
}

.main {
  padding: 28px;
  overflow: visible;
}

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

.eyebrow {
  color: var(--accent);
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 13px;
}

.topbar h2 {
  margin: 0;
  font-size: 30px;
}

.topbar-actions,
.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.file-button,
.text-button {
  border: 1px solid transparent;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

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

.secondary-button,
.file-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button,
.text-button {
  background: transparent;
  color: var(--accent);
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
  border-color: var(--line);
}

.mini-button {
  min-height: 32px;
  padding: 0 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.file-button input {
  display: none;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.panel-block {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 228, 223, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  min-height: 132px;
  display: grid;
  gap: 10px;
}

.timer-actions {
  margin-top: 2px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 26px;
  overflow-wrap: anywhere;
}

.progress-track {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.live-strip {
  position: sticky;
  top: 12px;
  z-index: 8;
  display: grid;
  grid-template-columns: 0.8fr 1.2fr 1fr;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid rgba(219, 228, 223, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(23, 33, 31, 0.08);
  backdrop-filter: blur(10px);
}

.live-strip div {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.live-strip span,
.live-strip small {
  color: var(--muted);
  font-size: 12px;
}

.live-strip strong {
  overflow-wrap: anywhere;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 14px;
}

.panel-block {
  padding: 20px;
}

.panel-block.compact {
  align-self: start;
}

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

.section-heading h3 {
  margin: 0;
  font-size: 20px;
}

.subtext {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.timeline,
.history-list,
.weekly-plan,
.guide-grid {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.timeline-item.done {
  background: var(--surface-soft);
}

.timeline-item.session-marker {
  border-color: rgba(29, 95, 87, 0.35);
  background: linear-gradient(90deg, rgba(29, 95, 87, 0.1), #fff);
}

.timeline-item.exercise-marker {
  border-color: rgba(84, 114, 184, 0.32);
  background: linear-gradient(90deg, rgba(84, 114, 184, 0.09), #fff);
}

.timeline-item.supplement-marker {
  border-color: rgba(217, 95, 50, 0.32);
  background: linear-gradient(90deg, rgba(217, 95, 50, 0.1), #fff);
}

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

.check-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 1px;
}

.fake-check {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-radius: 7px;
  flex: 0 0 auto;
}

.check-row input:checked + .fake-check {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 4px #fff;
}

.item-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.item-time {
  color: var(--accent-3);
  font-weight: 700;
  font-size: 13px;
}

.item-title,
.item-note {
  overflow-wrap: anywhere;
}

.item-note {
  color: var(--muted);
}

.item-duration {
  color: var(--accent);
  font-weight: 700;
}

.item-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.item-action {
  min-height: 34px;
  padding: 0 12px;
}

.item-action.active-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.workout-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.workout-card.current {
  border-color: var(--accent);
  background: var(--surface-soft);
}

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

.workout-head span {
  color: var(--accent);
  font-weight: 800;
}

.workout-card p {
  color: var(--muted);
  margin: 8px 0 12px;
}

.workout-card ol,
.guide-section ol,
.guide-section ul {
  margin: 0;
  padding-left: 22px;
}

.workout-card li,
.guide-section li {
  margin: 5px 0;
}

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

.guide-card {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1fr);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  scroll-margin-top: 18px;
}

.guide-card.highlight {
  outline: 3px solid rgba(217, 95, 50, 0.35);
}

.guide-media {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #0f1f1d;
}

.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.exercise-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 8px;
  background: #0f1f1d;
  object-fit: contain;
}

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

.image-pair figure {
  margin: 0;
  display: grid;
  gap: 6px;
}

.image-pair img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-pair figcaption,
.source-note {
  color: var(--muted);
  font-size: 12px;
}

.image-pair figcaption {
  text-align: center;
}

.source-note {
  margin: 0;
  line-height: 1.5;
}

.source-note a {
  color: var(--accent);
  font-weight: 700;
}

.media-missing {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.drawer-open {
  overflow: hidden;
}

.guide-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.guide-drawer.open {
  display: block;
}

.guide-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 45, 42, 0.28);
}

.guide-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100%;
  overflow: auto;
  background: var(--surface);
  box-shadow: -18px 0 45px rgba(23, 33, 31, 0.18);
  padding: 20px;
}

.guide-drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -20px -20px 18px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.guide-drawer-head span {
  color: var(--accent-3);
  font-size: 13px;
  font-weight: 800;
}

.guide-drawer-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
}

.guide-drawer-body {
  display: grid;
  gap: 16px;
}

.guide-drawer-body .guide-media,
.guide-drawer-body .guide-content {
  min-width: 0;
}

.motion-svg {
  width: 100%;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(29, 95, 87, 0.08), rgba(84, 114, 184, 0.07)),
    var(--surface-soft);
  color: var(--accent);
}

.motion-svg * {
  vector-effect: non-scaling-stroke;
}

.motion-svg .body,
.motion-svg .load,
.motion-svg .arrow,
.motion-svg .cue-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.motion-svg .bench,
.motion-svg .box,
.motion-svg .wall,
.motion-svg .floor,
.motion-svg .dumbbell {
  fill: rgba(29, 95, 87, 0.15);
  stroke: currentColor;
  stroke-width: 3;
}

.motion-svg .arrow {
  marker-end: url("#arrow");
  stroke: var(--accent-2);
}

.motion-svg .cue-line {
  stroke: var(--accent-3);
  stroke-dasharray: 8 8;
}

.animated .moving-up,
.animated .push,
.animated .squat,
.animated .hinge,
.animated .split,
.animated .calf,
.animated .rowing,
.animated .fly-arm,
.animated .curl-arm,
.animated .curl-load,
.animated .lateral-arm,
.animated .legraise,
.animated .twist,
.animated .step,
.animated .walk,
.animated .stretch,
.animated .crunch,
.animated .deadbug {
  animation: rep 1.8s ease-in-out infinite alternate;
  transform-origin: 110px 90px;
}

.animated .moving-up {
  animation-name: lift;
}

.animated .rowing,
.animated .curl-load {
  animation-name: pull;
}

.animated .squat,
.animated .split,
.animated .wallsit {
  animation-name: lower;
}

.animated .hinge,
.animated .stretch {
  animation-name: hinge;
}

.frame-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.frame-strip figure {
  margin: 0;
  display: grid;
  gap: 6px;
}

.frame-strip .motion-svg {
  min-height: 86px;
}

.frame-strip figcaption {
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.frame-1 .moving-up,
.frame-1 .rowing,
.frame-1 .curl-load,
.frame-1 .squat,
.frame-1 .split,
.frame-1 .hinge {
  transform: translateY(9px);
}

.frame-2 .moving-up,
.frame-2 .rowing,
.frame-2 .curl-load {
  transform: translateY(-8px);
}

.frame-2 .squat,
.frame-2 .split {
  transform: translateY(10px);
}

.frame-2 .hinge {
  transform: rotate(7deg);
}

.guide-content {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.guide-title span {
  color: var(--accent-3);
  font-weight: 800;
  font-size: 13px;
}

.guide-title h4 {
  margin: 4px 0 0;
  font-size: 22px;
}

.guide-section {
  display: grid;
  gap: 6px;
}

.guide-section strong {
  color: var(--ink);
}

.guide-section p {
  margin: 0;
  color: var(--muted);
}

.guide-section.warning {
  border-left: 3px solid var(--accent-2);
  padding-left: 10px;
}

.next-reminder,
.tip-box,
.status-list div,
.history-row {
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 14px;
}

.tip-box {
  margin-top: 12px;
  color: var(--muted);
}

.tip-box strong {
  color: var(--ink);
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.status-list dt,
.status-list dd {
  margin: 0;
}

.status-list dt {
  color: var(--muted);
}

.history-row {
  display: grid;
  grid-template-columns: 120px 1fr 90px;
  align-items: center;
  gap: 12px;
}

textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

@keyframes lift {
  from {
    transform: translateY(12px);
  }
  to {
    transform: translateY(-10px);
  }
}

@keyframes pull {
  from {
    transform: translate(0, 8px);
  }
  to {
    transform: translate(16px, -16px);
  }
}

@keyframes lower {
  from {
    transform: translateY(-6px);
  }
  to {
    transform: translateY(12px);
  }
}

@keyframes hinge {
  from {
    transform: rotate(-4deg);
  }
  to {
    transform: rotate(8deg);
  }
}

@keyframes rep {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .animated * {
    animation: none !important;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 18px;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-tab {
    text-align: center;
  }

  .date-card {
    display: none;
  }

  .metric-grid,
  .content-grid,
  .weekly-plan,
  .live-strip {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 680px) {
  .main {
    padding: 16px;
    padding-bottom: 164px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .metric-grid,
  .content-grid,
  .weekly-plan,
  .live-strip {
    grid-template-columns: 1fr;
  }

  .live-strip {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    margin: 0;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .timeline-item {
    align-items: stretch;
    flex-direction: column;
  }

  .item-actions,
  .guide-link,
  .item-action {
    width: 100%;
  }

  .item-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .frame-strip {
    grid-template-columns: 1fr;
  }

  .image-pair {
    grid-template-columns: 1fr;
  }

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