:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --text: #20231f;
  --muted: #687066;
  --line: #d9ded4;
  --accent: #1f7a68;
  --accent-strong: #14584b;
  --surface: #eef4f1;
  --warning: #9f5d12;
  --danger: #b3343d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Hiragino Sans", sans-serif;
  color: var(--text);
  background:
    linear-gradient(150deg, #f6f4ef 0%, #edf4f1 52%, #f3f5f7 100%);
}

button,
input {
  font: inherit;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.tracker {
  width: min(560px, 100%);
  display: grid;
  gap: 1.15rem;
  padding: clamp(1rem, 4vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(32, 35, 31, 0.12);
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.date {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1rem;
}

.state {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  color: var(--accent-strong);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 800;
}

form {
  display: grid;
  gap: 1rem;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.menu-list,
.pain-options {
  display: grid;
  gap: 0.6rem;
}

.menu-list label,
.pain-options label {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  align-items: center;
  gap: 0.7rem;
  min-height: 48px;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  font-weight: 700;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--accent);
}

.primary-action {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  color: #ffffff;
  background: var(--accent);
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
}

.primary-action:active {
  background: var(--accent-strong);
}

.message {
  min-height: 1.5em;
  margin: -0.2rem 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.history-section {
  display: grid;
  gap: 0.65rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.history {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history li {
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 40px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.history-date,
.history-summary,
.history-pain {
  overflow-wrap: anywhere;
}

.history-date {
  color: var(--muted);
  font-weight: 800;
}

.history-summary {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.history-pain {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.history-pain[data-pain="none"] {
  color: var(--accent-strong);
}

.history-pain[data-pain="mild"] {
  color: var(--warning);
}

.history-pain[data-pain="bad"] {
  color: var(--danger);
}

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

  .state {
    width: fit-content;
  }

  .history li {
    grid-template-columns: 3.5rem 1fr;
  }

  .history-pain {
    grid-column: 2;
  }
}
