:root {
  color-scheme: light;
  --ink: #1b2422;
  --muted: #5e675f;
  --paper: #f7f4ee;
  --card: #fffdf9;
  --line: #e3dcd1;
  --deep: #163a40;
  --deep-text: #f6f3ee;
  --danger: #8c3a2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #e5dfd6;
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid #1f7a8c;
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.noscript {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 24px 16px;
  background: var(--paper);
}

.wrap {
  width: min(440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
}

.top {
  padding: calc(20px + env(safe-area-inset-top)) 16px 16px;
  background: var(--deep);
  color: var(--deep-text);
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.lede {
  margin: 6px 0 16px;
  color: rgba(246, 243, 238, 0.86);
}

.date-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.date-bar p {
  margin: 0;
  text-align: center;
  font-weight: 650;
}

.top button,
.foot summary {
  min-height: 44px;
}

.top button {
  border: 1px solid rgba(246, 243, 238, 0.45);
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: inherit;
}

.top button:disabled {
  opacity: 0.35;
  cursor: default;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.summary-row p {
  margin: 0;
}

main {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.card {
  --accent: #1f7a8c;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 10px 24px rgba(22, 58, 64, 0.05);
}

.card[data-metric="steps"] {
  --accent: #2a6b45;
}

.card[data-metric="run"] {
  --accent: #b85c38;
}

.card.is-done {
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
}

.card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.figures {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 8px 0 12px;
  font-size: 1.7rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.slash,
.unit {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .fill {
    transition: width 160ms ease;
  }
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
}

.percent {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.progress-line [data-role="status"] {
  color: var(--muted);
}

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.editor input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.editor button,
.quick button,
.dialog-actions button {
  min-height: 44px;
  border-radius: 12px;
}

.editor button,
.quick button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.editor button {
  padding: 8px 12px;
}

.quick-label {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 0.875rem;
}

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick button {
  flex: 1 1 6rem;
  padding: 8px 10px;
}

.entries {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entries-empty {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.entry {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-variant-numeric: tabular-nums;
}

.entry time {
  color: var(--muted);
}

.entry button {
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  background: transparent;
  color: var(--danger);
}

.field-error,
#goal-error {
  min-height: 0;
  margin: 8px 0 0;
  color: var(--danger);
}

.field-error:empty,
#goal-error:empty {
  display: none;
}

.save-error {
  margin: 0 16px;
  color: var(--danger);
}

.foot {
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  color: var(--muted);
}

.foot p {
  margin: 0 0 8px;
}

.install {
  width: 100%;
  margin: 8px 0 12px;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--deep);
  color: var(--deep-text);
}

.foot details {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.foot summary {
  display: flex;
  align-items: center;
}

.foot ol {
  margin: 0 0 12px;
  padding-left: 1.2rem;
}

dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  border: 0;
  border-radius: 18px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(22, 26, 29, 0.46);
}

#goal-form {
  padding: 18px 16px 16px;
}

#goal-form h2 {
  margin: 0;
}

.dialog-note {
  margin: 8px 0 12px;
  color: var(--muted);
}

#goal-form label {
  display: block;
  margin-top: 12px;
}

#goal-form input {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 16px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

#goal-cancel {
  border: 1px solid var(--line);
  background: #fff;
}

#goal-save {
  border: 0;
  background: var(--deep);
  color: var(--deep-text);
}
