:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-soft: #f3f5ef;
  --ink: #222620;
  --muted: #667064;
  --line: #d9ded3;
  --accent: #2f6f56;
  --accent-soft: #e3f0e8;
  --accent-strong: #1f513f;
  --shadow: 0 14px 34px rgba(31, 42, 36, 0.1);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: default;
  opacity: 0.72;
}

.app-shell {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 18px 96px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 2px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.65rem;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.28rem;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.prototype-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
}

.screen {
  display: grid;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.today-panel {
  background: linear-gradient(180deg, #ffffff, #f7fbf7);
}

.date-strip {
  display: grid;
  grid-auto-columns: minmax(62px, 1fr);
  grid-auto-flow: column;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 12px;
}

.date-strip button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.date-strip button.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.bodywork-select {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.bodywork-select span {
  color: var(--muted);
  font-size: 0.82rem;
}

.bodywork-select strong {
  display: block;
  margin: 4px 0;
  font-size: 1.3rem;
  line-height: 1.25;
}

.bodywork-select small {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.chapter-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
  gap: 8px;
}

.chapter-picker button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
}

.chapter-picker button.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.checkin-panel {
  display: grid;
  gap: 12px;
}

.checkin-panel.is-confirmed {
  background: #fbfcfa;
}

.check-row,
.activity-toggle {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
  font-size: 1.06rem;
}

.check-row.is-checked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.check-box {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-strong);
  font-weight: 700;
}

.activity-toggle {
  padding: 12px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #c8ddcf;
  font-weight: 700;
}

.activity-box {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.activity-header strong {
  font-size: 1.02rem;
}

.collapse-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--accent-strong);
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field-label input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

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

.runner-card {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.runner-check {
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
}

.runner-check.is-checked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.runner-check .check-box {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  font-size: 0.85rem;
}

.runner-check span:last-child {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runner-minutes {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.runner-minutes input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
  text-align: center;
}

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

.segmented button,
.collapse-button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.segmented button.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.checkin-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.checkin-actions span {
  color: var(--muted);
  font-size: 0.9rem;
}

.primary-button,
.secondary-button {
  min-width: 104px;
  padding: 9px 16px;
  font-weight: 700;
}

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

.secondary-button {
  border-color: #c8ddcf;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.summary-grid div {
  display: grid;
  gap: 4px;
  min-height: 78px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.summary-grid strong {
  font-size: 1.28rem;
}

.summary-grid span {
  color: var(--muted);
  font-size: 0.85rem;
}

.record-tabs-panel {
  padding: 10px;
}

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

.record-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.record-tabs button.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

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

.bar-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.bar-row strong {
  color: var(--ink);
  font-size: 0.88rem;
  text-align: right;
}

.bar-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar-track div {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-head {
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.calendar-day {
  display: grid;
  min-height: 52px;
  align-content: start;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 5px;
  background: var(--surface-soft);
}

.calendar-day > span {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.calendar-day.is-empty {
  border-style: dashed;
  background: transparent;
  opacity: 0.55;
}

.calendar-dots,
.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.calendar-legend {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot.baduanjin {
  background: #2f6f56;
}

.dot.bodywork {
  background: #5d77a8;
}

.dot.strength {
  background: #9b6a3f;
}

.dot.pushups {
  background: #8a5aa3;
}

.dot.running {
  background: #b75050;
}

.week-list,
.chapter-list {
  display: grid;
  gap: 8px;
}

.week-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
  color: var(--muted);
}

.week-row .day-cell {
  min-width: 34px;
  color: var(--ink);
  font-weight: 700;
}

.week-row:first-child {
  padding-top: 0;
}

.week-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.placeholder-chart {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
}

.pwa-status {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.pwa-status span,
.sync-status span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  line-height: 1.4;
}

.status-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c4b66e;
}

.status-dot.ready {
  background: var(--accent);
}

.status-dot.pending {
  background: #c4b66e;
}

.inline-action {
  margin-bottom: 10px;
}

.sync-status,
.sync-form,
.sync-actions {
  display: grid;
  gap: 10px;
}

.sync-status {
  margin-bottom: 12px;
}

.sync-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.sync-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.sync-field input,
.sync-field select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.sync-field:first-child,
.sync-field:nth-child(2),
.sync-field:last-child {
  grid-column: 1 / -1;
}

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

.sync-actions button {
  width: 100%;
}

.sync-error {
  margin-top: 10px;
  color: #9b3f3f;
  font-size: 0.86rem;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 720px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -12px 30px rgba(31, 42, 36, 0.08);
}

.nav-item {
  display: grid;
  min-height: 62px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
}

.nav-item span {
  font-size: 1.08rem;
}

.nav-item.is-active {
  color: var(--accent-strong);
  font-weight: 700;
}

@media (max-width: 560px) {
  body {
    font-size: 15px;
  }

  .app-shell {
    padding: 10px 10px 78px;
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0 10px;
  }

  h1 {
    font-size: 1.38rem;
  }

  h2 {
    font-size: 1.08rem;
  }

  .prototype-pill {
    padding: 5px 8px;
    font-size: 0.72rem;
  }

  .screen {
    gap: 10px;
  }

  .panel {
    padding: 12px;
  }

  .date-strip {
    grid-auto-columns: minmax(54px, 1fr);
    gap: 5px;
    padding-bottom: 8px;
  }

  .date-strip button {
    min-height: 34px;
    font-size: 0.86rem;
  }

  .bodywork-select {
    gap: 9px;
    padding: 11px;
  }

  .bodywork-select strong {
    font-size: 1.12rem;
  }

  .bodywork-select small {
    font-size: 0.78rem;
  }

  .chapter-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .chapter-picker button {
    min-height: 34px;
    padding: 6px;
    font-size: 0.88rem;
  }

  .checkin-panel,
  .activity-box {
    gap: 8px;
  }

  .check-row,
  .activity-toggle {
    min-height: 46px;
  }

  .check-row {
    gap: 9px;
    padding: 9px 10px;
    font-size: 0.98rem;
  }

  .check-box {
    width: 26px;
    height: 26px;
  }

  .activity-toggle {
    padding: 9px;
  }

  .activity-box {
    padding: 9px;
  }

  .activity-header {
    align-items: center;
  }

  .collapse-button {
    min-height: 34px;
    padding: 6px 10px;
  }

  .running-columns {
    gap: 6px;
  }

  .runner-card {
    gap: 6px;
  }

  .runner-check {
    min-height: 40px;
    gap: 6px;
    padding: 6px;
  }

  .runner-check .check-box {
    width: 22px;
    height: 22px;
  }

  .runner-minutes input {
    min-height: 34px;
    padding: 6px;
  }

  .bottom-nav {
    min-height: 56px;
  }

  .nav-item {
    min-height: 56px;
    font-size: 0.78rem;
  }

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

  .bar-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .bar-row strong {
    grid-column: 2;
    text-align: left;
  }

  .collapse-button {
    width: auto;
  }

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

  .sync-form,
  .sync-actions {
    grid-template-columns: 1fr;
  }
}
