/* Blade & Co Mini App — тёмная премиальная тема, светлый вариант под светлую тему Telegram */

:root,
:root[data-theme="dark"] {
  --bg: #0c0b09;
  --surface: #161411;
  --surface-2: #1d1a16;
  --surface-3: #26221c;
  --line: rgba(236, 214, 178, 0.09);
  --line-2: rgba(236, 214, 178, 0.18);
  --text: #f3ede3;
  --muted: #a39a8c;
  --faint: #6f675c;
  --gold: #cfa968;
  --gold-2: #ecd09a;
  --gold-3: #9f7c45;
  --on-gold: #17110a;
  --gold-soft: rgba(207, 169, 104, 0.12);
  --ok: #8cc79a;
  --warn: #e8b45e;
  --danger: #e47b66;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  --glow: rgba(207, 169, 104, 0.1);
}

:root[data-theme="light"] {
  --bg: #f5f0e7;
  --surface: #fffdf9;
  --surface-2: #f7f1e7;
  --surface-3: #ece3d4;
  --line: rgba(70, 50, 20, 0.1);
  --line-2: rgba(70, 50, 20, 0.2);
  --text: #1d1813;
  --muted: #6d6457;
  --faint: #a09484;
  --gold: #a37d42;
  --gold-2: #c49a58;
  --gold-3: #84642f;
  --on-gold: #fffaf0;
  --gold-soft: rgba(163, 125, 66, 0.12);
  --ok: #3f8f52;
  --warn: #b7801f;
  --danger: #c4513b;
  --shadow: 0 14px 34px rgba(70, 50, 20, 0.12);
  --glow: rgba(163, 125, 66, 0.1);
}

:root {
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden]:not(.bar) { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(120% 50% at 50% -8%, var(--glow), transparent 62%);
  background-repeat: no-repeat;
  color: var(--text);
  font: 500 15px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
img { display: block; max-width: 100%; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px calc(120px + var(--safe-bottom));
  overflow-x: clip; /* сдвиг экранов при переходе не даёт горизонтального скролла */
}

/* ---------- шапка ---------- */

.top { display: flex; align-items: center; gap: 12px; height: 52px; }

.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--gold); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 700 19px/1 var(--font-display); letter-spacing: 0.26em; color: var(--text); white-space: nowrap; }
.brand-sub { margin-top: 4px; font-size: 10px; font-weight: 600; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gold); }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line);
  transition: transform 0.15s ease, background 0.2s ease;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg.i { width: 18px; height: 18px; }

.lang {
  display: flex; padding: 3px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.lang button {
  min-width: 38px; height: 28px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted);
  transition: background 0.25s var(--ease), color 0.25s ease;
}
.lang button.on { background: var(--gold); color: var(--on-gold); }

.preview-note {
  margin: 4px 0 6px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--gold-soft); border: 1px solid var(--line-2);
  color: var(--muted); font-size: 12.5px;
}

/* ---------- прогресс и заголовок шага ---------- */

.progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0 18px; }
.progress span { height: 3px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.progress span::after {
  content: ""; display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--gold-3), var(--gold-2));
  transform: scaleX(0); transform-origin: left; transition: transform 0.45s var(--ease);
}
.progress span.done::after { transform: scaleX(1); }

.step-head { margin-bottom: 16px; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }
.title { margin: 4px 0 0; font: 600 34px/1.05 var(--font-display); letter-spacing: -0.005em; }

.trail { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.trail:empty { display: none; }
.trail button {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: pop 0.35s var(--ease) both;
}
.trail button svg.i { width: 13px; height: 13px; color: var(--gold); }

/* ---------- экраны и переходы ---------- */

.view { display: grid; }
.screen { grid-area: 1 / 1; min-width: 0; }
.screen.enter-forward { animation: enter-forward 0.42s var(--ease) both; }
.screen.enter-back { animation: enter-back 0.42s var(--ease) both; }
.screen.leave-forward { animation: leave-forward 0.22s ease both; pointer-events: none; }
.screen.leave-back { animation: leave-back 0.22s ease both; pointer-events: none; }

@keyframes enter-forward { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }
@keyframes enter-back { from { opacity: 0; transform: translateX(-32px); } to { opacity: 1; transform: none; } }
@keyframes leave-forward { to { opacity: 0; transform: translateX(-24px); } }
@keyframes leave-back { to { opacity: 0; transform: translateX(24px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.stagger > * { animation: rise 0.45s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }

.list { display: grid; gap: 12px; }

.card {
  position: relative; display: block; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform 0.18s var(--ease), border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
button.card:active { transform: scale(0.985); }
.card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow); }

.chev { margin-left: auto; color: var(--faint); }

/* ---------- филиалы ---------- */

.branch-card { overflow: hidden; }
.branch-photo { position: relative; aspect-ratio: 16 / 8.5; background: var(--surface-3); overflow: hidden; }
.branch-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.branch-card:active .branch-photo img { transform: scale(1.03); }
.branch-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.55));
}
.power {
  position: absolute; z-index: 1; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(12, 11, 9, 0.72); color: #f3ede3; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.power svg.i { width: 14px; height: 14px; }
.power.grid svg { color: #9fdcab; }
.power.generator svg { color: #f0c26e; }
.branch-body { display: flex; align-items: flex-end; gap: 12px; padding: 14px 16px 16px; }
.branch-info { min-width: 0; flex: 1; }
.branch-name { font: 600 23px/1.1 var(--font-display); margin-bottom: 8px; }
.meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; }
.meta + .meta { margin-top: 4px; }
.meta svg.i { color: var(--gold); }

/* ---------- услуги ---------- */

.chips {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 8px; margin: 0 -16px 14px; padding: 8px 16px;
  overflow-x: auto; scrollbar-width: none;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  transition: background 0.25s var(--ease), color 0.2s ease, border-color 0.2s ease;
}
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }

.service { display: flex; align-items: center; gap: 14px; padding: 16px; }
.service-main { flex: 1; min-width: 0; }
.service-name { font-weight: 700; font-size: 15.5px; }
.service-desc { margin-top: 3px; color: var(--muted); font-size: 13px; }
.service-dur { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--faint); font-size: 12.5px; font-weight: 600; }
.service-price { flex: none; font: 600 22px/1 var(--font-display); color: var(--gold); white-space: nowrap; }

/* ---------- мастера ---------- */

.master { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.avatar {
  position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%;
  padding: 2px; background: linear-gradient(140deg, var(--gold-2), var(--gold-3));
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.avatar.sm { width: 40px; height: 40px; }
.avatar .initials {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  background: var(--surface-3); color: var(--gold); font: 700 15px var(--font-ui);
}
.master-info { min-width: 0; flex: 1; }
.master-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.master-name { font: 600 22px/1.1 var(--font-display); }
.badge {
  padding: 3px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  background: var(--gold-soft); color: var(--gold); border: 1px solid var(--line-2);
}
.master-spec { margin-top: 4px; color: var(--muted); font-size: 13px; }
.master.regular {
  border-color: var(--line-2);
  background: linear-gradient(140deg, var(--gold-soft), transparent 55%), var(--surface);
}
.regular-badge {
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 7px; padding: 4px 10px 4px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.01em;
  background: linear-gradient(140deg, var(--gold-2), var(--gold)); color: var(--on-gold);
}
.regular-badge svg.i { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.master-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; font-size: 12.5px; color: var(--faint); font-weight: 600; }
.rating { display: inline-flex; align-items: center; gap: 4px; color: var(--gold); font-weight: 800; }
.rating svg.i { width: 14px; height: 14px; fill: currentColor; stroke: none; }

/* ---------- календарь и слоты ---------- */

.calendar { padding: 14px 14px 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-month { font: 600 22px/1 var(--font-display); text-transform: capitalize; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav .icon-btn { width: 34px; height: 34px; }
.cal-nav .icon-btn:disabled { opacity: 0.3; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { padding: 4px 0 6px; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--faint); text-transform: uppercase; }
.day {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; max-height: 46px;
  border-radius: 12px; font-weight: 700; font-size: 14.5px; color: var(--text);
  transition: background 0.2s var(--ease), color 0.2s ease, transform 0.15s ease;
}
.day:not(:disabled):active { transform: scale(0.92); }
.day:disabled { color: var(--faint); opacity: 0.45; }
.day.off { text-decoration: line-through; text-decoration-color: var(--faint); }
.day.today::before { content: ""; position: absolute; inset: 3px; border-radius: 10px; border: 1px solid var(--line-2); }
.day.avail::after {
  content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--gold);
}
.day.selected { background: linear-gradient(140deg, var(--gold-2), var(--gold)); color: var(--on-gold); }
.day.selected::after { background: var(--on-gold); }
.day.selected.today::before { border-color: transparent; }

.slots { margin-top: 18px; }
.slots-group + .slots-group { margin-top: 16px; }
.slots-label { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 8px; }
.slots-label b { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.slots-label span { font-size: 12px; color: var(--faint); font-weight: 600; }
.slot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot {
  height: 44px; border-radius: 12px; text-align: center; font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums;
  background: var(--surface); border: 1px solid var(--line);
  transition: background 0.2s var(--ease), color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.slot:not(:disabled):active { transform: scale(0.94); }
.slot:disabled { color: var(--faint); background: transparent; border-style: dashed; text-decoration: line-through; opacity: 0.55; }
.slot.selected { background: linear-gradient(140deg, var(--gold-2), var(--gold)); border-color: transparent; color: var(--on-gold); }

.empty {
  padding: 22px 18px; border-radius: var(--radius); text-align: center;
  background: var(--surface); border: 1px dashed var(--line-2); color: var(--muted); font-size: 14px;
}

/* ---------- подтверждение ---------- */

.summary { padding: 6px 16px; }
.summary-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 0; }
.summary-row + .summary-row { border-top: 1px solid var(--line); }
.summary-ico {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--gold-soft); color: var(--gold);
}
.summary-ico svg.i { width: 18px; height: 18px; }
.summary-text { flex: 1; min-width: 0; }
.summary-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.summary-value { margin-top: 2px; font-weight: 700; font-size: 15px; }
.summary-sub { color: var(--muted); font-size: 13px; }
.summary-edit { flex: none; font-size: 12.5px; font-weight: 700; color: var(--gold); }

.total {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(140deg, var(--surface-2), var(--surface)); border: 1px solid var(--line-2);
}
.total-label { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.total-sub { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.total-value { font: 600 32px/1 var(--font-display); color: var(--gold); }

.client { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 14px 16px; }
.client-name { font-weight: 700; }
.client-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.bonus-hint {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--gold-soft); color: var(--text); font-size: 13.5px; font-weight: 600;
}
.bonus-hint svg.i { color: var(--gold); width: 18px; height: 18px; }

/* ---------- нижняя панель ---------- */

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(transparent, var(--bg) 26%);
  transform: translateY(0); transition: transform 0.35s var(--ease), opacity 0.25s ease;
}
.bar[hidden] { display: block; transform: translateY(110%); opacity: 0; pointer-events: none; }
.bar-inner { display: flex; align-items: center; gap: 12px; max-width: 528px; margin: 0 auto; }
.bar-summary { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); line-height: 1.3; }
.bar-summary b { display: block; color: var(--text); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cta {
  position: relative; flex: none; min-width: 150px; height: 54px; padding: 0 24px; border-radius: 16px;
  background: linear-gradient(140deg, var(--gold-2), var(--gold) 55%, var(--gold-3));
  color: var(--on-gold); font-weight: 800; font-size: 15.5px; text-align: center; letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(207, 169, 104, 0.28);
  transition: transform 0.15s ease, opacity 0.2s ease, filter 0.2s ease;
}
.cta:not(:disabled):active { transform: scale(0.97); }
.cta:disabled { opacity: 0.4; box-shadow: none; filter: saturate(0.6); }
.cta.wide { flex: 1; }
.cta.loading { color: transparent; }
.cta.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--on-gold); border-right-color: transparent; animation: spin 0.7s linear infinite;
}

/* ---------- скелетоны, ошибки, тост ---------- */

.skeleton {
  border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}

.error { text-align: center; padding: 36px 16px; color: var(--muted); }
.error .cta { margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); z-index: 30;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px; text-align: center;
  box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity 0.25s ease, transform 0.3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- успех ---------- */

.success {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: var(--bg); background-image: radial-gradient(80% 50% at 50% 30%, var(--glow), transparent 70%);
  animation: fade 0.35s ease both;
}
@keyframes fade { from { opacity: 0; } }
.success-inner { max-width: 360px; text-align: center; }
.success-mark { width: 104px; height: 104px; margin: 0 auto 22px; color: var(--gold); }
.success-mark circle { stroke-dasharray: 302; stroke-dashoffset: 302; animation: draw 0.8s var(--ease) 0.1s forwards; }
.success-mark path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.45s var(--ease) 0.7s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.success h2 { margin: 0; font: 600 36px/1.05 var(--font-display); animation: rise 0.5s var(--ease) 0.5s both; }
.success p { margin: 10px 0 0; color: var(--muted); animation: rise 0.5s var(--ease) 0.6s both; }
.success-card {
  margin-top: 22px; padding: 16px; border-radius: var(--radius); text-align: left;
  background: var(--surface); border: 1px solid var(--line-2); animation: rise 0.5s var(--ease) 0.7s both;
}
.success-card b { display: block; font: 600 22px/1.15 var(--font-display); color: var(--gold); }
.success-card span { display: block; margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.success .cta { margin-top: 22px; width: 100%; animation: rise 0.5s var(--ease) 0.8s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 360px) {
  .title { font-size: 30px; }
  .slot-grid { grid-template-columns: repeat(3, 1fr); }
  .cta { min-width: 128px; padding: 0 18px; }
}
