:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --ink: #17231e;
  --muted: #63706a;
  --line: #dbe3df;
  --green: #32654d;
  --green-soft: #e4efe9;
  --coral: #db654f;
  --coral-soft: #fae8e3;
  --blue: #5177a8;
  --blue-soft: #e8eef7;
  --shadow: 0 12px 36px rgba(32, 55, 44, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef4f1 0, var(--bg) 240px),
    var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(50, 101, 77, 0.24);
  outline-offset: 2px;
}

.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;
}

.app-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  margin-bottom: 38px;
}

.brand,
.home-link {
  color: inherit;
  text-decoration: none;
}

.brand {
  font-size: 0.78rem;
  font-weight: 800;
}

.home-link {
  color: var(--muted);
  font-size: 0.9rem;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 3rem;
  line-height: 1.04;
}

.date-label {
  margin-bottom: 0;
  color: var(--muted);
}

.date-controls {
  display: grid;
  grid-template-columns: 42px minmax(150px, 178px) 42px;
  gap: 8px;
  align-items: center;
}

.date-controls button,
.date-picker input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

.date-controls button {
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.15rem;
  cursor: pointer;
}

.date-controls button:disabled {
  color: #aeb8b3;
  cursor: default;
  background: #eef1f0;
}

.date-picker input {
  width: 100%;
  padding: 0 10px;
}

.checkin-section,
.stats-section {
  padding: 34px 0;
  border-bottom: 1px solid var(--line);
}

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

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

.completion-count,
.month-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

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

.activity-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 106px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.activity-card:hover {
  transform: translateY(-1px);
}

.gym-card.completed {
  border-color: rgba(219, 101, 79, 0.35);
  background: linear-gradient(135deg, var(--surface), var(--coral-soft));
}

.posture-card.completed {
  border-color: rgba(81, 119, 168, 0.35);
  background: linear-gradient(135deg, var(--surface), var(--blue-soft));
}

.activity-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
}

.activity-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.checkmark {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 2px solid #bcc8c2;
  border-radius: 50%;
  color: transparent;
  background: var(--surface);
  font-weight: 800;
}

.activity-toggle input:focus-visible + .checkmark {
  outline: 3px solid rgba(50, 101, 77, 0.24);
  outline-offset: 2px;
}

.activity-toggle input:checked + .checkmark {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.activity-copy {
  display: block;
  min-width: 0;
}

.activity-copy strong,
.activity-copy small {
  display: block;
}

.activity-copy strong {
  margin-bottom: 5px;
  font-size: 1.08rem;
}

.activity-copy small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.duration-field {
  flex: 0 0 74px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: right;
}

.duration-field span {
  display: block;
  margin-bottom: 5px;
}

.duration-field input {
  width: 74px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.duration-field input:disabled {
  color: #a5afaa;
  background: #eef1f0;
}

.note-field {
  display: block;
  margin-top: 18px;
}

.note-field > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.note-field textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 84px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.55;
}

.note-field textarea::placeholder {
  color: #9aa6a0;
}

.save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 16px;
}

#save-status {
  color: var(--muted);
  font-size: 0.82rem;
}

#save-status.error {
  color: #b54235;
}

.save-button {
  min-width: 126px;
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  color: white;
  background: var(--green);
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(50, 101, 77, 0.2);
}

.save-button:hover {
  background: #28553f;
}

.save-button:disabled {
  opacity: 0.55;
  cursor: default;
}

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

.metric {
  min-height: 102px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric strong {
  font-size: 0.92rem;
  font-weight: 650;
}

.metric b {
  margin-right: 3px;
  font-size: 1.7rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.history-block {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.history-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.history-header h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.history-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 0.72rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.gym-dot {
  background: var(--coral);
}

.posture-dot {
  background: var(--blue);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(14, minmax(28px, 1fr));
  gap: 7px;
}

.history-day {
  display: grid;
  grid-template-rows: 42px 14px;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.history-day:hover {
  background: #f0f4f2;
}

.history-day.selected {
  background: var(--green-soft);
}

.history-marks {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 34px;
  border: 1px solid #e4e9e6;
  border-radius: 6px;
  background: #f7f9f8;
}

.history-mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d9e0dc;
}

.history-mark.gym.active {
  background: var(--coral);
}

.history-mark.posture.active {
  background: var(--blue);
}

.history-day small {
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

footer {
  padding-top: 22px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 980px);
  }

  .app-header {
    margin-bottom: 26px;
  }

  .page-heading {
    align-items: start;
    flex-direction: column;
  }

  h1 {
    font-size: 2.45rem;
  }

  .date-controls {
    width: 100%;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

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

  .history-grid {
    grid-template-columns: repeat(7, minmax(28px, 1fr));
  }
}

@media (max-width: 480px) {
  .activity-list,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .activity-card {
    min-height: 96px;
    padding: 15px;
  }

  .history-header {
    flex-direction: column;
  }

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

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

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