:root {
  --bg: var(--tg-theme-bg-color, #f4f5f7);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111318);
  --hint: var(--tg-theme-hint-color, #777b84);
  --accent: var(--tg-theme-button-color, #111318);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(120, 120, 128, 0.18);
  --danger: #d64545;
  --safe-bottom: var(--tg-content-safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

body {
  padding:
    max(12px, var(--tg-content-safe-area-inset-top, 0px))
    max(14px, var(--tg-content-safe-area-inset-right, 0px))
    calc(92px + var(--safe-bottom))
    max(14px, var(--tg-content-safe-area-inset-left, 0px));
}

button, input, select, textarea { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0 20px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--hint);
  margin-bottom: 5px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 17px;
  margin-bottom: 0;
}

.section { margin-bottom: 28px; }

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.muted { color: var(--hint); font-size: 13px; }

.cards {
  display: grid;
  gap: 10px;
}

.workout-card {
  width: 100%;
  border: 0;
  text-align: left;
  color: var(--text);
  background: var(--card);
  border-radius: 18px;
  padding: 15px;
  box-shadow: 0 1px 0 var(--line);
  cursor: pointer;
}

.workout-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.workout-kind {
  display: flex;
  gap: 11px;
  align-items: center;
}

.workout-emoji {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(127,127,127,.10);
  font-size: 22px;
}

.workout-title {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 3px;
}

.workout-subtitle {
  color: var(--hint);
  font-size: 13px;
}

.people-badge {
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(127,127,127,.10);
}

.workout-place {
  margin-top: 12px;
  color: var(--hint);
  font-size: 13px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 20px;
  color: var(--hint);
  text-align: center;
  font-size: 14px;
}

.icon-button {
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.view { display: none; }
.view.active { display: block; }

.bottom-nav {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(10px + var(--safe-bottom));
  height: 70px;
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  align-items: center;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 6px 10px;
  z-index: 20;
}

.nav-item {
  height: 56px;
  border: 0;
  background: transparent;
  color: var(--hint);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  cursor: pointer;
}

.nav-item span { font-size: 21px; }
.nav-item small { font-size: 11px; font-weight: 700; }

.nav-item.active { color: var(--text); }

.create-fab {
  justify-self: center;
  width: 58px;
  height: 58px;
  border-radius: 19px;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}

.create-header { margin: 8px 0 24px; }

.back-link {
  border: 0;
  background: transparent;
  color: var(--hint);
  padding: 6px 0;
  cursor: pointer;
}

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 9px 0 22px;
}

.type-card {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 17px;
  padding: 16px 10px;
  display: grid;
  gap: 7px;
  place-items: center;
  font-weight: 750;
  cursor: pointer;
}

.type-card.selected {
  border: 2px solid var(--accent);
  padding: 15px 9px;
}

.type-icon { font-size: 27px; }

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field-label, .field label {
  font-size: 13px;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.primary-button {
  width: 100%;
  margin: 6px 0 18px;
  padding: 15px 18px;
  border: 0;
  border-radius: 15px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
  cursor: pointer;
}

.primary-button:disabled { opacity: .55; }

.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 5px 0 18px;
}

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

.weekdays span {
  font-size: 10px;
  font-weight: 800;
  color: var(--hint);
  text-align: center;
  padding: 6px 0;
}

.calendar-grid {
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.day {
  min-height: 54px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  position: relative;
  cursor: pointer;
}

.day:nth-child(7n) { border-right: 0; }

.day.other { color: var(--hint); opacity: .45; }

.day.selected {
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
  font-weight: 800;
}

.day.today::before {
  content: "";
  position: absolute;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.day-number {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
}

.day-dots {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}

.day-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.calendar-events { margin-top: 22px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.38);
  z-index: 50;
  display: grid;
  align-items: end;
}

.modal-sheet {
  position: relative;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  max-height: 88vh;
  overflow: auto;
  padding: 12px 18px calc(26px + var(--safe-bottom));
}

.modal-grabber {
  width: 42px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 0 auto 18px;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.detail-hero { padding-right: 48px; }
.detail-emoji { font-size: 36px; margin-bottom: 10px; }
.detail-meta { color: var(--hint); margin: 7px 0; }

.participants {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.person {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--card);
  border-radius: 13px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(127,127,127,.13);
  font-weight: 800;
  font-size: 12px;
}

.secondary-button, .danger-button {
  width: 100%;
  border-radius: 15px;
  padding: 14px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.danger-button {
  margin-top: 10px;
  border: 1px solid rgba(214,69,69,.35);
  background: transparent;
  color: var(--danger);
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #1d1f24;
  color: white;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.hidden { display: none !important; }

@media (min-width: 720px) {
  body { max-width: 620px; margin: 0 auto; }
  .bottom-nav {
    left: 50%;
    right: auto;
    width: min(590px, calc(100vw - 28px));
    transform: translateX(-50%);
  }
  .modal-sheet {
    width: min(620px, 100%);
    margin: 0 auto;
  }
}
