/* ===== Календарь добрых дней (использует токены из styles.css) ===== */
.cal { max-width: 680px; margin: 0 auto; }
.cal button, .pay button, .avatars__item { -webkit-tap-highlight-color: transparent; }
.cal__progress { margin-bottom: 20px; }
.cal__progress-text { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: .9rem; }
.cal__progress-text b { color: var(--c-heading); }
/* копия под первым экраном — белая карточка на сером фоне */
.stats .cal__progress { margin: 0; background: var(--c-surface); border-radius: var(--radius); border-top: 4px solid var(--c-primary); padding: 16px 18px 12px; }
.stats .cal__progress-text b { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats .progress { height: 10px; }

.cal__months {
  display: flex; gap: 6px; overflow-x: auto;
  margin: 0 calc(-1 * var(--gutter)) 8px; padding: 2px var(--gutter) 8px;
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.cal__months::-webkit-scrollbar { display: none; }
.cal__month {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; scroll-snap-align: center;
  min-height: 36px; padding: 0 14px; border: 1px solid var(--c-border); border-radius: var(--radius-pill);
  background: var(--c-surface); color: var(--c-text); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.cal__month small { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--c-accent); color: var(--c-heading); font-size: .7rem; line-height: 18px; text-align: center; }
.cal__month.is-active { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-on-primary); }
.cal__month.is-active small { background: #fff; }

.cal__head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 12px; }
.cal__title { margin: 0; font-size: 1.3rem; font-weight: 800; }
.cal__arrow {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--c-bg-alt);
  color: var(--c-heading); font-size: 1.6rem; line-height: 1; cursor: pointer; transition: background-color .2s;
}
.cal__arrow:hover:not(:disabled) { background: var(--c-primary); }
.cal__arrow:disabled { opacity: .35; cursor: default; }

.cal__weekdays, .cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__weekdays { margin-bottom: 4px; }
.cal__weekdays span { text-align: center; font-size: .75rem; font-weight: 600; color: var(--c-muted); }
.cal__weekdays span:nth-child(n+6) { color: #c88f00; }

.cal-day {
  position: relative; aspect-ratio: 1; min-width: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface);
  font: inherit; font-weight: 600; font-size: .9rem; color: var(--c-heading); cursor: pointer;
  overflow: hidden; transition: transform .15s, border-color .15s, background-color .15s, box-shadow .15s;
}
.cal-day--blank { border: 0; background: none; cursor: default; }
.cal-day--free:hover { border-color: var(--c-primary); background: #fff8e0; transform: translateY(-2px); box-shadow: var(--shadow); }
.cal-day--free:hover::after { content: "+"; position: absolute; right: 4px; bottom: 0; font-size: .9rem; color: #c88f00; }
.cal-day--past { background: var(--c-bg-alt); color: #b5b5b5; border-color: transparent; cursor: not-allowed; }
/* забронирован другим посетителем, ждёт оплаты */
.cal-day--held { background: repeating-linear-gradient(135deg, #fff8e0 0 6px, #fdf0c4 6px 12px); color: #b59a4a; border-color: transparent; cursor: not-allowed; }
.cal-day--today { box-shadow: inset 0 0 0 2px var(--c-primary); }
.cal-day--taken { border-color: transparent; background: var(--c-bg-alt); }
.cal-day--taken:hover { transform: translateY(-2px) scale(1.04); box-shadow: var(--shadow); z-index: 1; }
.cal-day__avatar { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cal-day--taken .cal-day__num {
  position: absolute; left: 2px; top: 2px; z-index: 1;
  min-width: 18px; padding: 0 3px; border-radius: 9px; background: rgba(255, 255, 255, .9);
  font-size: .65rem; line-height: 16px;
}
.cal-day:focus-visible { outline: 3px solid rgba(255, 195, 0, .6); outline-offset: 1px; }
.cal__error { grid-column: 1 / -1; text-align: center; color: var(--c-muted); }

.cal__legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; font-size: .8rem; color: var(--c-muted); }
.cal__legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--c-border); }
.dot--free { background: #fff; }
.dot--taken { background: linear-gradient(135deg, var(--c-primary), var(--c-accent)); border: 0; }
.dot--past { background: var(--c-bg-alt); border: 0; }

/* ----- всплывающая подсказка ----- */
.cal-tip {
  position: fixed; z-index: 60; width: max-content; max-width: min(300px, calc(100vw - 16px));
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  background: var(--c-dark); color: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  font-size: .85rem; line-height: 1.4; pointer-events: none; animation: tip-in .15s ease-out;
}
.cal-tip[hidden] { display: none; }
.cal-tip::after {
  content: ""; position: absolute; top: 100%; left: var(--arrow-x, 50%); translate: -50% 0;
  border: 7px solid transparent; border-top-color: var(--c-dark);
}
.cal-tip.is-below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--c-dark); }
.cal-tip__avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #fff; }
.cal-tip__date { font-size: .75rem; color: var(--c-primary); font-weight: 600; }
.cal-tip__name { font-weight: 700; font-size: .95rem; word-break: break-word; }
.cal-tip__wish { margin-top: 4px; color: #e6e6e6; font-style: italic; word-break: break-word; }
@keyframes tip-in { from { opacity: 0; translate: 0 4px; } }

/* ----- окно оплаты: на телефоне — шторка снизу, на десктопе — по центру ----- */
.has-modal { overflow: hidden; }
.pay {
  width: 100%; max-width: 100%; max-height: 94dvh; margin: auto 0 0; padding: 0;
  border: 0; border-radius: 16px 16px 0 0; background: var(--c-surface); color: var(--c-text);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
}
.pay[open] { display: flex; flex-direction: column; animation: sheet-in .25s ease-out; }
.pay::backdrop { background: rgba(34, 34, 34, .55); }
@keyframes sheet-in { from { translate: 0 40px; opacity: 0; } }
.pay__form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.pay__form[hidden], .pay__done[hidden] { display: none; }
.pay__header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 20px var(--gutter) 12px; border-bottom: 1px solid var(--c-bg-alt);
}
.pay__header h3 { margin: 0; font-size: 1.25rem; font-weight: 800; }
.pay__range { margin: 4px 0 0; color: var(--c-accent-text); font-weight: 600; }
.pay__close {
  width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 50%;
  background: var(--c-bg-alt); color: var(--c-heading); font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.pay__body { display: grid; gap: 18px; padding: 16px var(--gutter); overflow-y: auto; overscroll-behavior: contain; }
.pay__footer { display: grid; gap: 10px; padding: 12px var(--gutter) calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--c-bg-alt); }
.pay__total { display: flex; justify-content: space-between; font-size: 1rem; }
.pay__total b { color: var(--c-heading); font-size: 1.2rem; }
.pay__done { padding: 40px var(--gutter) calc(32px + env(safe-area-inset-bottom)); text-align: center; }
.pay__done-icon { font-size: 3rem; }

.pay .field__label { display: flex; justify-content: space-between; align-items: baseline; }
.field__hint { font-size: .75rem; color: var(--c-muted); }
.counter { font-weight: 400; font-size: .75rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }

.stepper { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; max-width: 220px; }
.stepper__btn {
  border: 0; border-radius: var(--radius-pill); background: var(--c-primary); color: var(--c-on-primary);
  font-size: 1.4rem; font-weight: 600; cursor: pointer;
}
.stepper__btn:disabled { background: var(--c-bg-alt); color: #b5b5b5; cursor: default; }
.stepper__input { text-align: center; font-weight: 700; -moz-appearance: textfield; appearance: textfield; }
.stepper__input::-webkit-inner-spin-button,
.stepper__input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.avatar-pick { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.avatar-pick__preview {
  width: 88px; height: 88px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  box-shadow: 0 0 0 4px var(--c-primary); background: var(--c-bg-alt);
}
.avatar-pick__actions { display: grid; gap: 8px; }
.avatar-pick__upload { position: relative; overflow: hidden; }
.avatar-pick__upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.avatar-pick__upload:focus-within { outline: 3px solid rgba(255, 195, 0, .5); outline-offset: 2px; }

.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.avatars__item { position: relative; cursor: pointer; border-radius: 50%; }
.avatars__item input { position: absolute; opacity: 0; pointer-events: none; }
.avatars__item img { width: 100%; height: auto; aspect-ratio: 1; border-radius: 50%; transition: transform .15s, box-shadow .15s; }
.avatars__item:hover img { transform: scale(1.08); }
.avatars__item input:checked + img { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c-heading); }
.avatars__item input:focus-visible + img { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c-primary); }

@media (min-width: 600px) {
  .cal__months { display: grid; grid-template-columns: repeat(6, 1fr); margin: 0 0 8px; padding: 2px 2px 8px; overflow: visible; }
  .cal__month { justify-content: center; padding: 0 8px; }
  .cal__weekdays, .cal__grid { gap: 8px; }
  .cal-day { font-size: 1rem; }
  .cal-day--taken .cal-day__num { font-size: .7rem; left: 4px; top: 4px; }
  .pay { width: min(560px, calc(100vw - 32px)); max-height: 90vh; margin: auto; border-radius: 16px; }
  .pay[open] { animation: pop-in .2s ease-out; }
  .avatars { grid-template-columns: repeat(8, 1fr); }
}
@keyframes pop-in { from { scale: .96; opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pay[open], .cal-tip { animation: none; }
  .cal-day { transition: none; }
}

/* ----- случайный день ----- */
.cal__random { margin-top: 20px; text-align: center; }
.cal__random .btn { width: 100%; }
.cal__random-note { margin: 8px 0 0; font-size: .85rem; color: var(--c-muted); }
.cal__random-note:empty { display: none; }
.cal-day--picked { z-index: 2; border-color: var(--c-primary); background: var(--c-primary); animation: day-picked .9s ease-out; }
@keyframes day-picked {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 195, 0, .7); }
  40%  { transform: scale(1.18); box-shadow: 0 0 0 10px rgba(255, 195, 0, 0); }
  100% { transform: scale(1.05); box-shadow: 0 0 0 0 rgba(255, 195, 0, 0); }
}
@media (min-width: 600px) { .cal__random .btn { width: auto; } }
@media (prefers-reduced-motion: reduce) { .cal-day--picked { animation: none; } }
