:root {
  /* Фолбэки (если открыто вне Telegram). Внутри — переопределяются из темы. */
  --bg: #f4f1ea;
  --card: #ffffff;
  --text: #1f2a24;
  --hint: #7d8a82;
  --accent: #2f9e6f;      /* лесной зелёный */
  --accent-ink: #ffffff;
  --wood: #b5835a;
  --busy: #d9534f;
  --line: rgba(0, 0, 0, 0.08);
  --day-bg: #eef4f0;      /* фон свободного дня (переопределяется в тёмной теме) */
  --shadow: 0 6px 24px rgba(20, 40, 30, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0 0 90px;
}

.app { max-width: 520px; margin: 0 auto; padding: 12px; }

/* ---------- Шапка ---------- */
.hero {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--accent), #227a54);
  color: #fff; border-radius: var(--radius);
  padding: 18px; margin: 6px 0 14px;
  box-shadow: var(--shadow);
}
.hero__emoji { font-size: 40px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.2)); }
.hero__text h1 { margin: 0; font-size: 20px; font-weight: 800; }
.hero__text p { margin: 4px 0 0; font-size: 13px; opacity: .92; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 16px; }

/* ---------- Календарь ---------- */
.calendar__nav {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.calendar__title { font-weight: 700; font-size: 16px; text-transform: capitalize; }
.nav-btn {
  width: 38px; height: 38px; border: none; border-radius: 12px;
  background: var(--bg); color: var(--text); font-size: 22px; line-height: 1;
  cursor: pointer; transition: transform .1s, background .2s;
}
.nav-btn:active { transform: scale(.9); }

.calendar__weekdays, .calendar__grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.calendar__weekdays {
  margin-bottom: 8px; font-size: 12px; color: var(--hint); text-align: center;
}
.calendar__weekdays .we { color: var(--wood); }

.day {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 15px; font-weight: 600; position: relative;
  background: var(--day-bg); color: var(--text); cursor: pointer;
  transition: transform .08s, background .15s, color .15s;
}
.day.empty { background: transparent; cursor: default; }
.day.free:active { transform: scale(.88); }

.day.busy {
  background: transparent; color: var(--hint); cursor: not-allowed;
  text-decoration: line-through; opacity: .55;
}
.day.past { background: transparent; color: var(--hint); opacity: .35; cursor: not-allowed; }

.day.today::after {
  content: ""; position: absolute; bottom: 6px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--accent);
}

.day.in-range { background: rgba(47, 158, 111, .18); border-radius: 4px; }
.day.selected {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 4px 12px rgba(47, 158, 111, .45);
}
.day.selected.today::after { background: #fff; }
.day.edge-start { border-radius: 12px 4px 4px 12px; }
.day.edge-end { border-radius: 4px 12px 12px 4px; }

/* ---------- Легенда ---------- */
.legend {
  display: flex; gap: 16px; justify-content: center; margin-top: 14px;
  font-size: 12px; color: var(--hint);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.dot--free { background: var(--day-bg); border: 1px solid var(--line); }
.dot--busy { background: var(--busy); opacity: .55; }
.dot--sel { background: var(--accent); }

/* ---------- Итог ---------- */
.summary { animation: pop .25s ease; }
.summary__row { display: flex; align-items: center; justify-content: space-between; }
.summary__col { display: flex; flex-direction: column; gap: 2px; }
.summary__label { font-size: 12px; color: var(--hint); }
.summary__col b { font-size: 16px; }
.summary__arrow { color: var(--accent); font-size: 20px; }
.summary__price {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.summary__price b { font-size: 20px; color: var(--accent); }

/* ---------- Форма ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--hint); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font-size: 15px; font-family: inherit;
  outline: none; transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input.invalid, .field select.invalid { border-color: var(--busy); background: rgba(217,83,79,.06); }
textarea { resize: none; }

.stepper {
  display: flex; align-items: center; gap: 16px; align-self: flex-start;
  background: var(--bg); border-radius: 12px; padding: 4px 8px; border: 1px solid var(--line);
}
.stepper button {
  width: 34px; height: 34px; border: none; border-radius: 9px; font-size: 20px;
  background: var(--card); color: var(--accent); cursor: pointer; box-shadow: var(--shadow);
}
.stepper button:active { transform: scale(.9); }
.stepper b { min-width: 22px; text-align: center; font-size: 17px; }

.hint { font-size: 12px; color: var(--hint); text-align: center; margin: 4px 12px 0; }

/* ---------- Экран успеха ---------- */
.success {
  position: fixed; inset: 0; background: rgba(15, 30, 22, .6);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
  backdrop-filter: blur(4px);
}
.success__box {
  background: var(--card); border-radius: 24px; padding: 30px 24px; text-align: center;
  max-width: 340px; width: 100%; box-shadow: var(--shadow); animation: pop .3s ease;
}
.success__emoji { font-size: 52px; margin-bottom: 8px; animation: bounce .6s ease; }
.success__box h2 { margin: 6px 0; }
.success__box p { color: var(--hint); margin: 0 0 18px; }
.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { transform: scale(.97); }

/* ---------- Утилиты ---------- */
.hidden { display: none !important; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bounce {
  0% { transform: scale(.4); } 60% { transform: scale(1.15); } 100% { transform: scale(1); }
}
