/* Ателье: Mini App. Цвета берутся из темы Telegram, акцент фирменный */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #faf7f2;
    --bg2: #f1ebe2;
    --card: #ffffff;
    --text: #231f1c;
    --hint: #8b8178;
    --line: rgba(35, 31, 28, 0.09);
    --accent: #8a3446;
    --accent-soft: rgba(138, 52, 70, 0.1);
    --accent-text: #ffffff;
    --ok: #3d7a52;
    --radius: 16px;
    --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --tabbar-h: 62px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root.dark {
    --bg: #171514;
    --bg2: #211e1c;
    --card: #24211f;
    --text: #f2ede7;
    --hint: #9a9087;
    --line: rgba(242, 237, 231, 0.1);
    --accent: #e3a0ad;
    --accent-soft: rgba(227, 160, 173, 0.14);
    --accent-text: #2a1519;
    --ok: #7cc293;
}

html, body { background: var(--bg); }

/* Cormorant по умолчанию рисует старостильные цифры, в ценах и датах нужны обычные */
.brand-title, .section-title, .service-group-title, .workshop-title, .date-badge b,
.detail-title, .sheet-head h2, .estimate strong, .success-block h3 { font-variant-numeric: lining-nums; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
}

body.has-booking-bar { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 90px); }
body.sheet-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.brand-title {
    font-family: var(--serif);
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
}

.brand-sub {
    font-size: 12px;
    color: var(--hint);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 4px;
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg2);
    color: var(--text);
    text-decoration: none;
}

.icon-btn:active { transform: scale(0.94); }

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
}

/* Views */
.view { display: none; }
.view.active { display: block; animation: fade 0.2s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.intro { padding: 14px 16px 4px; color: var(--hint); font-size: 14px; }

.section-title {
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 600;
    padding: 16px 16px 4px;
}

.loader, .empty {
    text-align: center;
    color: var(--hint);
    padding: 40px 16px;
    grid-column: 1 / -1;
}

/* Chips */
.chips {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    padding: 7px 14px;
    border-radius: 20px;
    background: var(--bg2);
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.chip.active { background: var(--text); color: var(--bg); }

/* Services */
.service-group { padding: 0 16px; margin-bottom: 18px; }

.service-group-title {
    font-family: var(--serif);
    font-size: 21px;
    font-weight: 600;
    margin: 10px 2px 8px;
}

.service-list {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--line);
}

.service {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.service:last-child { border-bottom: none; }
.service:active { background: var(--bg2); }

.service-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg2);
}

.service-main { flex: 1; min-width: 0; }
.service-name { font-weight: 600; }

.service-desc {
    color: var(--hint);
    font-size: 13px;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.service-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.service-price { font-weight: 600; white-space: nowrap; font-size: 14px; }
.service-price.muted { color: var(--hint); font-weight: 500; }

.add-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 18px;
    line-height: 1;
}

.service.selected .add-dot { background: var(--accent); color: var(--accent-text); font-size: 14px; }

/* Booking bar */
.booking-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 10px);
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px 10px 16px;
    border-radius: 18px;
    background: var(--text);
    color: var(--bg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    animation: rise 0.2s ease;
}

@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.booking-bar-count { font-size: 12px; opacity: 0.7; }
.booking-bar-total { font-weight: 700; }

/* Tabbar */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    display: flex;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--hint);
    font-size: 11px;
    font-weight: 500;
}

.tab.active { color: var(--accent); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 18px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 15px;
    transition: transform 0.1s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: var(--accent-soft); color: var(--accent); }
.btn-block { width: 100%; }

.booking-bar .btn-primary { padding: 10px 16px; }

/* Workshops */
.workshops { padding: 8px 16px; display: grid; gap: 14px; }

.workshop-card {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.workshop-card:active { transform: scale(0.99); }

.workshop-cover {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--bg2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hint);
    font-family: var(--serif);
    font-size: 22px;
}

.workshop-cover img { width: 100%; height: 100%; object-fit: cover; }

.date-badge {
    position: absolute;
    left: 12px;
    top: 12px;
    background: var(--card);
    color: var(--text);
    border-radius: 12px;
    padding: 6px 10px;
    text-align: center;
    line-height: 1.1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.date-badge b { display: block; font-family: var(--serif); font-size: 24px; }
.date-badge span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

.workshop-body { padding: 12px 14px 14px; }
.workshop-title { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.15; }
.workshop-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; color: var(--hint); font-size: 13px; }
.workshop-meta strong { color: var(--text); }

.tag {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
}

.tag.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }

/* Gallery (scroll-snap) */
.gallery {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 8px;
    margin: 0 -16px 14px;
    padding: 0 16px;
    scrollbar-width: none;
}

.gallery::-webkit-scrollbar { display: none; }

/* Размеры заданы явно в vw/vh, без aspect-ratio: встроенный браузер Telegram
   на части Android его не поддерживает. Фото вписывается целиком (contain), без обрезки */
.gallery img {
    flex: 0 0 auto;
    display: block;
    width: 84vw;
    max-width: 520px;
    height: 70vw;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 14px;
    scroll-snap-align: center;
    background: var(--bg2);
    cursor: zoom-in;
}

.gallery.single img { width: 100%; max-width: none; }

img { max-width: 100%; }

/* Просмотр фото на весь экран */
.viewer {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.94);
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.viewer::-webkit-scrollbar { display: none; }

.viewer img {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    max-width: none;
    object-fit: contain;
    scroll-snap-align: center;
}

.viewer-close {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 301;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 24px;
    line-height: 1;
}

.viewer-count {
    position: fixed;
    bottom: calc(18px + var(--safe-bottom));
    left: 0;
    right: 0;
    z-index: 301;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
}

.detail-title { font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.15; margin-bottom: 8px; }
.detail-desc { white-space: pre-line; margin: 12px 0; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.fact { background: var(--bg2); border-radius: 12px; padding: 10px 12px; }
.fact small { display: block; color: var(--hint); font-size: 12px; }
.fact b { font-size: 15px; }

.notice {
    background: var(--accent-soft);
    border-radius: 12px;
    padding: 12px;
    margin: 12px 0;
    font-size: 14px;
    white-space: pre-line;
}

/* Sheets */
.sheet {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.sheet.active { opacity: 1; pointer-events: auto; }

.sheet-panel {
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.sheet.active .sheet-panel { transform: none; }

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px;
}

.sheet-head h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; }

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg2);
    font-size: 22px;
    line-height: 1;
    color: var(--hint);
}

.sheet-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; -webkit-overflow-scrolling: touch; }

.sheet-foot {
    padding: 10px 16px calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--line);
}

.sheet-foot:empty { display: none; }

/* Forms */
.field-label { font-weight: 600; margin: 18px 0 8px; }
.field-label:first-child { margin-top: 4px; }
.hint { color: var(--hint); font-size: 13px; margin: -2px 0 8px; }

.input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--card);
    outline: none;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}

.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Booking items */
.booking-items {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.booking-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.booking-item:last-child { border-bottom: none; }
.booking-item-main { flex: 1; min-width: 0; }
.booking-item-name { font-weight: 600; }
.booking-item-price { color: var(--hint); font-size: 13px; }

.stepper { display: flex; align-items: center; background: var(--bg2); border-radius: 10px; }
.stepper button { width: 32px; height: 32px; font-size: 18px; color: var(--accent); }
.stepper span { min-width: 20px; text-align: center; font-weight: 600; font-size: 14px; }

.estimate {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
}

.estimate strong { font-family: var(--serif); font-size: 26px; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.photo, .photo-add {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
}

.photo img { width: 100%; height: 100%; object-fit: cover; }

.photo button {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 14px;
    line-height: 1;
}

.photo-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent);
    color: var(--accent);
    font-size: 11px;
    cursor: pointer;
}

/* Picker */
.picker-group { margin-bottom: 14px; }
.picker-group-title { font-size: 13px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.05em; margin: 8px 2px; }

.picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 6px;
    text-align: left;
}

.picker-item .service-main { flex: 1; }

.check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: transparent;
}

.picker-item.selected { border-color: var(--accent); }
.picker-item.selected .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Products */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 4px 16px 16px;
}

.product-card {
    position: relative;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.product-card:active { transform: scale(0.98); }
.product-image { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--bg2); }
@supports not (aspect-ratio: 1) {
    .product-image { height: 58vw; max-height: 320px; }
    .workshop-cover { height: 52vw; }
}
.product-info { padding: 10px 12px 12px; }
.product-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.product-price { font-weight: 700; margin-top: 4px; }
.product-old-price { color: var(--hint); text-decoration: line-through; font-size: 13px; margin-left: 6px; font-weight: 400; }

.product-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 11px;
    font-weight: 700;
    z-index: 1;
}

.options { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }

.option {
    min-width: 44px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--bg2);
    font-weight: 600;
    border: 1.5px solid transparent;
}

.option.selected { border-color: var(--accent); color: var(--accent); }

.color-option { width: 36px; height: 36px; min-width: 0; padding: 0; border-radius: 50%; border: 2px solid var(--line); }
.color-option.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

/* Cart */
.cart-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-item-image { width: 56px; height: 70px; object-fit: cover; border-radius: 10px; background: var(--bg2); }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; }
.cart-item-details { color: var(--hint); font-size: 13px; }
.cart-item-remove { color: var(--hint); font-size: 18px; padding: 6px; }

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
    transform: translate(-50%, 20px);
    z-index: 200;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.success-block { text-align: center; padding: 20px 8px; }
.success-block .big { font-size: 44px; }
.success-block h3 { font-family: var(--serif); font-size: 26px; margin: 8px 0; }
.success-block p { color: var(--hint); }

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: -2px 0 10px;
    padding: 5px 12px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}
