:root {
  --bg: #0b0e14;
  --surface: #11151e;
  --surface-2: #151b27;
  --border: #1d2432;
  --border-soft: #171d29;
  --text: #d7dde8;
  --muted: #737e92;
  --faint: #4a5266;
  --accent: #6ea8f5;

  --c-run: #64a4f4;
  --c-weights: #2f63c2;
  --c-boxing: #a9cdff;
  --c-workout: #4f86dd;
  --c-sauna: #e0975a;
  --c-massage: #4fc0a0;
  --c-meditation: #a08cf0;
  --c-prayer: #c0b17e;

  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  user-select: none;
}

.masthead {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 8px 0 18px;
}

/* ---- month navigation ---- */

.monthnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 14px;
}

.month-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.month-title .year { color: var(--muted); font-weight: 400; margin-left: 6px; }

.navbtn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, opacity 0.15s;
}
.navbtn:hover:not(:disabled) { color: var(--text); border-color: #2a3346; }
.navbtn:disabled { opacity: 0.25; cursor: default; }

/* ---- calendar ---- */

.calendar {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 10px 10px;
}

.weekdays, .week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.weekdays { padding-bottom: 8px; }

.weekdays span {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--faint);
  text-transform: uppercase;
}

.day {
  position: relative;
  aspect-ratio: 1 / 1.12;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 7px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.day.blank { cursor: default; }
.day:not(.blank):hover { background: var(--surface-2); }
.day.selected { background: var(--surface-2); border-color: #2a3244; }

.day .num {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.day.has-entries .num { color: var(--text); }

.day.today .num {
  color: var(--accent);
  font-weight: 700;
}

.day .blocks {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  max-width: 34px;
}

.block {
  width: 8px;
  height: 8px;
  border-radius: 2.5px;
}

/* ---- legend ---- */

.legend {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 4px 16px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.legend-row:last-child { border-bottom: none; }

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: none;
}
.swatch.striped {
  background: linear-gradient(
    90deg,
    var(--c-weights) 0 33.3%,
    var(--c-run) 33.3% 66.6%,
    var(--c-boxing) 66.6% 100%
  );
}

.legend-name {
  font-size: 14px;
  text-transform: capitalize;
  letter-spacing: 0.01em;
}

.legend-sub {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}
.legend-sub i {
  font-style: normal;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend-sub i::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--dot);
}

.legend-count {
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.legend-count.zero { color: var(--faint); font-weight: 400; }

/* ---- status line ---- */

.status {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.status button {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* ---- day sheet ---- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(2px);
  z-index: 10;
  opacity: 1;
  transition: opacity 0.2s;
}
.backdrop[hidden] { display: none; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 10px 22px calc(26px + env(safe-area-inset-bottom));
  z-index: 11;
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.sheet[hidden] { display: none; }

@keyframes rise {
  from { transform: translate(-50%, 30px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}

.sheet .grip {
  width: 34px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 14px;
}

.sheet h2 {
  font-size: 15px;
  font-weight: 600;
  padding-bottom: 4px;
}
.sheet h2 .weekday { color: var(--muted); font-weight: 400; }

.sheet .empty {
  color: var(--faint);
  font-size: 13px;
  padding: 14px 0 6px;
}

.entry {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}
.entry:last-child { border-bottom: none; }

.entry .dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-top: 4px;
}

.entry .name {
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
}
.entry .name .sub { color: var(--muted); font-weight: 400; }

.entry .detail {
  font-size: 13px;
  color: var(--text);
  opacity: 0.85;
  margin-top: 2px;
}

.entry .notes {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}
