:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --ink: #26231f;
  --muted: #6f6a61;
  --line: #d8d0c4;
  --empty: #e6ded3;
  --lived: #425f57;
  --before-us: #6f9186;
  --current: #32b26f;
  --birthday: #e88aaa;
  --birthday-soft: #ffe1ec;
  --happy: #f2c94c;
  --happy-soft: #fff4c7;
  --sad: #161616;
  --sad-soft: #d8d8d8;
  --panel: #fffdf9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

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

.eyebrow {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  font-size: clamp(2.1rem, 5vw, 4.4rem);
  font-weight: 650;
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
  margin-bottom: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(128px, 1fr));
  gap: 10px;
  min-width: 300px;
}

.stats div {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px 16px;
}

.stats span {
  display: block;
  font-size: 1.7rem;
  font-weight: 750;
  line-height: 1;
}

.stats small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.intro {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin: 18px 0 22px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.chart-wrap {
  overflow-x: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chart {
  display: grid;
  grid-template-columns: 54px repeat(36, 18px);
  gap: 7px;
  min-width: max-content;
}

.year-label {
  align-self: center;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: right;
  padding-right: 4px;
}

.month {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--empty);
  position: relative;
}

.month.lived {
  background: var(--lived);
}

.month.lived.before-us {
  background: var(--before-us);
}

.month.current {
  outline: 3px solid var(--current);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--panel);
}

.month.birthday {
  background: var(--birthday);
}

.month.lived.birthday {
  background: var(--birthday);
}

.month.marker {
  background: var(--happy-soft);
}

.month.lived.marker {
  background: var(--happy);
}

.month.marker::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--happy);
}

.month.lived.marker::after {
  background: #fff9d8;
}

.month.marker.sad {
  background: var(--sad-soft);
}

.month.lived.marker.sad {
  background: var(--sad);
}

.month.marker.sad::after {
  background: var(--sad);
}

.month.lived.marker.sad::after {
  background: #f2f2f2;
}

.events-section {
  margin-top: 24px;
}

.events-section summary {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 750;
  margin-bottom: 8px;
}

.legend {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.legend-item {
  display: grid;
  grid-template-columns: 28px 14px 132px minmax(220px, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 36px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: #9b7a09;
}

.legend-item.editing {
  grid-template-columns: 28px 14px 170px minmax(220px, 1fr) 110px auto;
  gap: 10px;
  padding: 8px 0;
}

.legend-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--happy);
}

.legend-item.editing .legend-dot {
  align-self: end;
  margin-bottom: 12px;
}

.legend-dot.sad {
  background: var(--sad);
}

.legend-item.sad {
  color: var(--sad);
}

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

.legend-item label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.legend-item input,
.legend-item select {
  height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  padding: 6px 10px;
}

.edit-event {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}

.edit-event:hover,
.edit-event:focus-visible {
  background: rgba(0, 0, 0, 0.08);
  outline: 0;
}

.row-actions {
  display: flex;
  align-self: end;
  align-items: center;
  gap: 8px;
}

.row-actions button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0 12px;
}

.legend-date {
  color: inherit;
  font-size: 0.84rem;
  font-weight: 750;
}

.legend-label {
  color: inherit;
  font-size: 0.92rem;
  font-weight: 650;
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 24px;
  }

  .header,
  .intro {
    display: block;
  }

  .stats {
    min-width: 0;
    margin-top: 20px;
  }

  .intro p + p {
    margin-top: 8px;
  }

  .chart-wrap {
    padding: 12px;
  }

  .legend-item {
    grid-template-columns: 28px 14px 1fr;
  }

  .legend-item.editing {
    grid-template-columns: 28px 14px 1fr;
  }

  .legend-date,
  .legend-label,
  .legend-item label,
  .row-actions {
    grid-column: 3;
  }
}
