:root {
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --bg: #f2eef0;
  --surface: #ffffff;
  --inset: #e8e2e6;
  --text: #231a26;
  --hint: #7d6f79;
  --accent: #a12d63;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --tint: color-mix(in srgb, var(--accent) 10%, transparent);
  --soft: color-mix(in srgb, var(--text) 8%, transparent);
  --shadow: 0 18px 40px -24px rgba(61, 24, 45, 0.32);
  --shadow-accent: 0 14px 28px -12px color-mix(in srgb, var(--accent) 70%, transparent);
  --t-rose: #f6dde7;
  --t-sand: #f4e5d7;
  --t-sage: #dcebe0;
  --t-lilac: #e7ddf2;
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Onest", system-ui, -apple-system, sans-serif;
  --row: 48px;
  --pad: 8px;
  --label: 64px;
  --gutter: 20px;
}

:root[data-scheme="dark"] {
  --bg: #15101a;
  --surface: #211a27;
  --inset: #0f0b13;
  --text: #f4edf2;
  --hint: #a394a0;
  --accent: #f08dba;
  --on-accent: #2a1020;
  --danger: #ff8a7a;
  --soft: color-mix(in srgb, var(--text) 10%, transparent);
  --shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.7);
  --t-rose: #3b2231;
  --t-sand: #3a2f26;
  --t-sage: #25352c;
  --t-lilac: #30283f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  padding: 0 var(--gutter) calc(150px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }

h1 {
  margin: 28px 0 6px;
  font: 700 32px/1.05 var(--font-body);
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.lead { margin: 0 0 22px; color: var(--hint); }

/* Анимация появления: один раз при смене экрана, без скрытого контента при сбое скриптов */
.rise { animation: rise 0.7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* Шапка и переключатель разделов */
.top { padding-top: 22px; }
.brand { margin: 0; font: 700 15px/1 var(--font-body); letter-spacing: -0.01em; }
.tabs {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  margin-top: 16px; padding: 4px; border-radius: 20px; background: var(--inset);
}
.thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  border-radius: 16px; background: var(--surface); box-shadow: 0 6px 16px -8px rgba(40, 10, 30, 0.3);
  transition: transform 0.5s var(--ease);
}
.tabs[data-tab="my"] .thumb { transform: translateX(100%); }
.tab { position: relative; z-index: 1; padding: 11px 0; text-align: center; font-weight: 600; color: var(--hint); transition: color 0.3s; }
.tab[aria-current="page"] { color: var(--text); }

/* Услуги */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.service {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 16px;
  width: 100%; padding: 16px; border-radius: 28px;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform 0.4s var(--ease);
}
.service:active { transform: scale(0.975); }
.glyph { width: 56px; height: 56px; border-radius: 20px; display: grid; place-items: center; background: var(--g, var(--t-rose)); }
.glyph svg { width: 27px; height: 27px; fill: none; stroke: var(--text); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[data-tone="rose"] { --g: var(--t-rose); }
[data-tone="sand"] { --g: var(--t-sand); }
[data-tone="sage"] { --g: var(--t-sage); }
[data-tone="lilac"] { --g: var(--t-lilac); }
.service b { display: block; font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.service small { color: var(--hint); font-size: 14px; }
.price { font: 500 16px/1 var(--font-display); white-space: nowrap; letter-spacing: -0.02em; }

.foot { margin: 26px 4px 0; color: var(--hint); font-size: 14px; }

/* Шаг «время» */
.back {
  width: 44px; height: 44px; margin-top: 22px; border-radius: 16px;
  display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow);
  transition: transform 0.4s var(--ease);
}
.back:active { transform: scale(0.94); }
.back svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 22px; }
.chip { padding: 6px 12px; border-radius: 12px; background: var(--surface); font-size: 14px; font-weight: 500; box-shadow: var(--shadow); }

.days { display: flex; gap: 10px; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 6px var(--gutter) 22px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 62px; padding: 12px 0 14px; text-align: center; border-radius: 22px;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform 0.45s var(--ease), background 0.3s, color 0.3s;
}
.day span { display: block; font-size: 13px; color: var(--hint); transition: color 0.3s; }
.day b { display: block; margin-top: 2px; font: 500 20px/1.2 var(--font-display); letter-spacing: -0.03em; }
.day[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-accent); transform: translateY(-3px); }
.day[aria-pressed="true"] span { color: inherit; opacity: 0.85; }
.day:disabled { opacity: 0.4; box-shadow: none; background: var(--soft); }

/* Страница ежедневника */
.sheet { position: relative; padding: var(--pad); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.slot { display: grid; grid-template-columns: var(--label) 1fr; align-items: center; width: 100%; height: var(--row); }
.slot-time { padding-left: 8px; font-size: 13px; color: var(--hint); font-variant-numeric: tabular-nums; }
.slot.hour .slot-time { font-size: 14px; font-weight: 700; color: var(--text); }
.slot::after { content: ""; align-self: stretch; margin: 3px 0; border-radius: 14px; transition: background 0.25s; }
.slot.ok { cursor: pointer; }
.slot.ok::after { background: var(--tint); }
.slot.ok:active::after { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.slot.busy::after { background: repeating-linear-gradient(135deg, var(--soft) 0 2px, transparent 2px 8px); }
.slot.free .slot-time { opacity: 0.45; }

.pick {
  position: absolute; left: calc(var(--pad) + var(--label)); right: var(--pad); z-index: 1;
  padding: 10px 16px; border-radius: 18px; pointer-events: none;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-accent);
  transition: top 0.45s var(--ease), height 0.45s var(--ease);
}
.pick b { display: block; font: 500 16px/1.2 var(--font-display); letter-spacing: -0.03em; }
.pick span { font-size: 14px; opacity: 0.9; }

.legend { display: flex; gap: 18px; margin: 14px 4px 0; font-size: 13px; color: var(--hint); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 5px; margin-right: 7px; vertical-align: -2px; }
.legend .l-ok { background: var(--tint); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.legend .l-busy { background: repeating-linear-gradient(135deg, var(--soft) 0 2px, transparent 2px 5px); }

/* Билет: подтверждение и «Вы записаны» */
.ticket { position: relative; margin-top: 6px; padding: 26px 24px 8px; border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.t-when { margin: 0; color: var(--hint); font-weight: 500; }
.t-when::first-letter { text-transform: uppercase; }
.t-time { margin: 6px 0 4px; font: 500 40px/1.05 var(--font-display); letter-spacing: -0.05em; }
.t-time small { font-size: 22px; color: var(--hint); letter-spacing: -0.03em; }
.t-svc { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.perf { position: relative; margin: 24px -24px 4px; border-top: 2px dashed var(--soft); }
.perf::before, .perf::after { content: ""; position: absolute; top: -13px; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); }
.perf::before { left: -12px; }
.perf::after { right: -12px; }
.t-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 14px 0; }
.t-row span { color: var(--hint); }
.t-row b { font-weight: 600; }
.t-row .big { font: 500 20px/1 var(--font-display); letter-spacing: -0.03em; }
.note { margin: 18px 4px 0; color: var(--hint); font-size: 14px; }

.done { padding-top: 34px; }
.mark { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 10px var(--tint); animation: pop 0.8s var(--ease) both; }
.mark svg { width: 72px; height: 72px; display: block; }
.mark path {
  fill: none; stroke: var(--on-accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 44; stroke-dashoffset: 44; animation: draw 0.5s 0.3s ease-out forwards;
}
@keyframes pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done h1 { margin-top: 26px; }
.done .ticket { margin-top: 20px; }
.actions { display: grid; gap: 10px; margin-top: 22px; }

/* Мои записи */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.entry { display: grid; grid-template-columns: 68px 1fr; gap: 2px 16px; padding: 16px; border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.when { grid-row: span 2; display: grid; place-content: center; text-align: center; height: 68px; border-radius: 22px; background: var(--g, var(--t-rose)); }
.when b { font: 500 24px/1 var(--font-display); letter-spacing: -0.04em; }
.when span { font-size: 13px; color: var(--hint); }
.what { align-self: end; }
.what b { display: block; font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.what span { color: var(--hint); font-size: 14px; }
.cancel { justify-self: start; align-self: start; padding: 4px 0; color: var(--danger); font-weight: 600; font-size: 14px; }
.empty { display: grid; justify-items: start; gap: 6px; padding-top: 6px; }
.empty .glyph { width: 72px; height: 72px; border-radius: 26px; margin-bottom: 14px; }
.empty .glyph svg { width: 32px; height: 32px; }
.empty p { margin: 0 0 20px; color: var(--hint); }

/* Кнопки */
.pill {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%;
  padding: 7px 7px 7px 24px; border-radius: 999px; font-weight: 700; font-size: 16px;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-accent);
  transition: transform 0.4s var(--ease);
}
.pill:active { transform: scale(0.97); }
.pill:disabled { opacity: 0.6; }
.go { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--on-accent) 18%, transparent); transition: transform 0.45s var(--ease); }
.go svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill:active .go { transform: translate(2px, -2px) scale(1.06); }
.ghost { display: block; width: 100%; padding: 16px; border-radius: 999px; text-align: center; font-weight: 600; background: var(--surface); box-shadow: var(--shadow); transition: transform 0.4s var(--ease); }
.ghost:active { transform: scale(0.97); }

/* Плавающая нижняя панель */
.bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; align-items: center; gap: 12px; padding: 9px 9px 9px 22px; border-radius: 34px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: 0 24px 50px -20px rgba(40, 10, 30, 0.45);
  animation: rise 0.6s var(--ease) both;
}
.bar[hidden] { display: none; }
.bar-text { margin: 0; flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.bar-text b { display: block; font-weight: 700; }
.bar-text span { color: var(--hint); }
.bar .pill { width: auto; flex: none; box-shadow: none; }

.toast {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(104px + env(safe-area-inset-bottom)); z-index: 10;
  padding: 14px 18px; border-radius: 20px; text-align: center; font-size: 14px; font-weight: 500;
  background: var(--text); color: var(--bg); animation: rise 0.5s var(--ease) both;
}
.toast[hidden] { display: none; }

.skeleton { margin: 28px 0; color: var(--hint); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

@media (prefers-reduced-motion: reduce) {
  .rise, .bar, .toast, .mark, .skeleton { animation: none; }
  .mark path { animation: none; stroke-dashoffset: 0; }
  .thumb, .pick, .day, .service, .pill, .go { transition: none; }
}
