:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f4f1f3);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #1d1a1c);
  --hint: var(--tg-theme-hint-color, #8e8a8d);
  --link: var(--tg-theme-link-color, #c2187a);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --accent: #d1207f;
  --accent-text: #ffffff;
  --accent-soft: rgba(209, 32, 127, 0.12);
  --ok: #2fa66a;
  --ok-soft: rgba(47, 166, 106, 0.14);
  --radius: 14px;
  --line: rgba(127, 127, 127, 0.16);
  /* отступ от «полоски» iPhone; Telegram передаёт свой, браузер — свой, минимум 14px */
  --safe-b: max(14px, env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  /* кривые из скилла Эмиля: встроенные ease слишком вялые */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  -webkit-tap-highlight-color: transparent;   /* без серой вспышки при нажатии */
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;                   /* страница не «тянется» за край */
}
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg2);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

/* всё, что нажимается: мгновенный отклик, без задержки 300 мс, без выделения текста */
.btn, .tile, .hero[data-go], .item:not(.static), .time, .cal-d[data-date], .cal-nav, .chip, .seg button,
#tabs button, .media .m, [data-go], label.check {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* нажатие «слышно»: лёгкое сжатие на :active, отпускание — быстрое */
.btn, .tile, .hero, .time, .cal-d, .cal-nav, .chip, .seg button, .media .m {
  transition: transform 160ms var(--ease-out), opacity 160ms var(--ease-out), background-color 160ms ease;
}
.btn:active:not(:disabled), .tile:active, .hero[data-go]:active, .time:active, .cal-d[data-date]:active,
.cal-nav:active:not(:disabled), .chip.add:active, .seg button:active, .media .m:active {
  transform: scale(0.97);
}
body.has-tabs #app { padding-bottom: calc(var(--tabs-h, 84px) + 16px); }
#app { padding: 16px 16px 32px; max-width: 560px; margin: 0 auto; }

h1 { font-size: 24px; margin: 4px 0 4px; letter-spacing: -0.3px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
     color: var(--hint); margin: 22px 4px 8px; }
.sub { color: var(--hint); margin: 0 0 16px; font-size: 15px; }
.hint { color: var(--hint); font-size: 14px; }
.pre { white-space: pre-line; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.spacer { height: 12px; }

/* карточки и списки */
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; position: relative; cursor: pointer; }
.item + .item::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.item { transition: background-color 200ms ease; }
.item:not(.static):active { background: var(--bg2); transition-duration: 0ms; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 500; }
.item .meta { color: var(--hint); font-size: 14px; margin-top: 2px; }
.item .price { font-weight: 600; white-space: nowrap; }
.item .chev { color: var(--hint); font-size: 20px; }
.item.static { cursor: default; }
.item.static:active { background: none; }

/* плитки на главной */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 16px; cursor: pointer; min-height: 92px;
        display: flex; flex-direction: column; justify-content: space-between; }
.tile .ic { font-size: 26px; }
.tile .t { font-weight: 600; font-size: 15px; }
.tile .badge { align-self: flex-start; }

.hero { background: linear-gradient(135deg, #d1207f, #f06aa9); color: #fff; border-radius: 18px;
        padding: 18px; margin-bottom: 12px; }
.hero .label { opacity: .85; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.hero .big { font-size: 22px; font-weight: 700; margin: 4px 0; }
.hero .small { opacity: .9; font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px; }
.stat .n { font-size: 20px; font-weight: 700; }
.stat .l { color: var(--hint); font-size: 12px; }

/* кнопки */
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 600;
       background: var(--accent); color: var(--accent-text); cursor: pointer; text-align: center; font-family: inherit; }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--card); color: var(--text); }
.btn.danger { background: rgba(229, 72, 77, .12); color: var(--danger); }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btns { display: grid; gap: 8px; margin-top: 12px; }
.btns.two { grid-template-columns: 1fr 1fr; }
/* нижняя кнопка закреплена над вкладками и не двигается при прокрутке */
.sticky-bottom { position: fixed; left: 0; right: 0; bottom: var(--tabs-h, 0px); z-index: 9;
                 padding: 10px max(16px, calc((100% - 528px) / 2)) calc(10px + var(--safe-b));
                 background: var(--bg2); box-shadow: 0 -1px 0 var(--line); }
body.has-tabs .sticky-bottom { padding-bottom: 10px; }
body.has-fixed #app { padding-bottom: calc(var(--fixed-h) + var(--tabs-h, 0px) + 16px); }

.badge { display: inline-block; background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px;
         font-weight: 700; padding: 2px 8px; min-width: 20px; text-align: center; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.pill.free { background: var(--ok-soft); color: var(--ok); }
.pill.busy { background: var(--accent-soft); color: var(--accent); }
.pill.off { background: var(--bg2); color: var(--hint); }

/* календарь */
.cal { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head .m { font-weight: 600; font-size: 17px; text-transform: capitalize; }
.cal-nav { border: 0; background: var(--bg2); color: var(--text); width: 36px; height: 36px; border-radius: 10px;
           font-size: 18px; cursor: pointer; }
.cal-nav:disabled { opacity: .3; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; color: var(--hint); font-size: 12px; padding: 4px 0; }
.cal-d { aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center;
         justify-content: center; font-size: 15px; position: relative; color: var(--hint); }
.cal-d.on { color: var(--text); font-weight: 600; cursor: pointer; background: var(--accent-soft); }
.cal-d.full { color: var(--text); cursor: pointer; background: var(--bg2); }
.cal-d.any { color: var(--text); cursor: pointer; }
.cal-d.today::after { content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cal-d.sel { background: var(--accent) !important; color: #fff !important; }
.cal-d.sel.today::after { background: #fff; }

/* время */
.times { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.time { border: 0; background: var(--card); color: var(--text); border-radius: 10px; padding: 12px 0; font-size: 16px;
        font-weight: 600; cursor: pointer; font-family: inherit; }
.time.sel { background: var(--accent); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent);
        border-radius: 999px; padding: 6px 10px; font-weight: 600; font-size: 14px; }
.chip button { border: 0; background: none; color: inherit; font-size: 16px; padding: 0; cursor: pointer; line-height: 1; }
.chip.add { background: var(--bg2); color: var(--text); cursor: pointer; }

/* формы */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin: 0 4px 6px; }
input, textarea, select {
  width: 100%; border: 0; border-radius: 12px; padding: 13px 14px; font-size: 16px; font-family: inherit;
  background: var(--card); color: var(--text); outline: none; -webkit-appearance: none; appearance: none;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 13px 14px;
         margin-bottom: 12px; cursor: pointer; }
.check input { width: 22px; height: 22px; padding: 0; -webkit-appearance: checkbox; appearance: auto; accent-color: var(--accent); }

.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; color: var(--hint); padding: 9px; border-radius: 9px; font-size: 15px;
              font-weight: 600; cursor: pointer; font-family: inherit; }
.seg button.on { background: var(--accent); color: #fff; }

/* отзывы */
.stars { color: #f5a623; letter-spacing: 1px; }
.media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.media .m { aspect-ratio: 1; border-radius: 10px; background: var(--bg2); overflow: hidden; position: relative; cursor: pointer; }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
               font-size: 28px; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.5); pointer-events: none; }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex; align-items: center;
          justify-content: center; opacity: 0; transition: opacity 200ms ease; overscroll-behavior: contain; }
.viewer.open { opacity: 1; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; transform: scale(0.96);
                              transition: transform 260ms var(--ease-out); }
.viewer.open img, .viewer.open video { transform: scale(1); }

/* нижняя панель вкладок */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
        padding: 8px 4px calc(10px + var(--safe-b)); z-index: 10; }
#tabs button { flex: 1; border: 0; background: none; color: var(--hint); font-size: 11px; font-weight: 600; padding: 4px 0;
               display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-family: inherit; position: relative; }
#tabs button .ic { font-size: 22px; filter: grayscale(1); opacity: .7; }
#tabs button.on { color: var(--accent); }
#tabs button.on .ic { filter: none; opacity: 1; }
#tabs .badge { position: absolute; top: 0; left: 55%; font-size: 10px; padding: 1px 5px; min-width: 16px; }

/* шторка снизу */
/* Шторка выезжает снизу по кривой iOS-шторки и уходит быстрее, чем приходит.
   Переходы, а не keyframes: если закрыть посреди анимации, она плавно развернётся. */
#sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end;
         background: rgba(0,0,0,0); transition: background-color 200ms ease; }
#sheet.open { background: rgba(0,0,0,.35); transition-duration: 300ms; }
#sheet .panel { background: var(--bg2); width: 100%; border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + var(--safe-b));
                max-width: 560px; margin: 0 auto; overscroll-behavior: contain;
                transform: translateY(100%); transition: transform 200ms var(--ease-out); }
#sheet.open .panel { transform: translateY(0); transition: transform 320ms var(--ease-drawer); }
#sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
#sheet .panel h3 { margin: 4px 4px 12px; font-size: 17px; }

/* Сообщение появляется над закреплённой кнопкой и вкладками, а не поверх них */
#toast { position: fixed; left: 50%; bottom: calc(var(--fixed-h, 0px) + var(--tabs-h, 0px) + 16px);
         background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px;
         z-index: 60; max-width: 90%; text-align: center; pointer-events: none;
         opacity: 0; transform: translate(-50%, 8px) scale(0.97);
         transition: opacity 150ms ease, transform 150ms var(--ease-out); }
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); transition-duration: 220ms; }

.empty { text-align: center; color: var(--hint); padding: 28px 12px; }
.empty .ic { font-size: 40px; margin-bottom: 6px; }
/* Лоадер показывается, только если загрузка дольше 150 мс — быстрые экраны не мигают.
   Крутится быстрее: так ожидание ощущается короче. */
.loader { width: 28px; height: 28px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%;
          margin: 60px auto; animation: spin .6s linear infinite, loader-in 150ms ease both; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loader-in { from { opacity: 0; } to { opacity: 1; } }

/* Меньше движения — для тех, кому от анимаций плохо: оставляем только прозрачность */
@media (prefers-reduced-motion: reduce) {
  .btn, .tile, .hero, .time, .cal-d, .cal-nav, .chip, .seg button, .media .m { transition: opacity 160ms ease, background-color 160ms ease; }
  .btn:active:not(:disabled), .tile:active, .hero[data-go]:active, .time:active, .cal-d[data-date]:active,
  .cal-nav:active:not(:disabled), .chip.add:active, .seg button:active, .media .m:active { transform: none; opacity: .7; }
  #sheet .panel, #sheet.open .panel { transform: none; transition: opacity 200ms ease; }
  #sheet .panel { opacity: 0; }
  #sheet.open .panel { opacity: 1; }
  #toast, #toast.show { transform: translate(-50%, 0); }
  .viewer img, .viewer video { transform: none !important; }
}
.error { background: rgba(229,72,77,.1); color: var(--danger); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
a { color: var(--link); text-decoration: none; }
