/* Токены темы — смаппены на Telegram.WebApp.themeParams (те же var(--tg-theme-*), что и в
   присланных DevTools-выдержках другой аппки), поэтому UI автоматически подстраивается
   под светлую/тёмную тему и акцентный цвет клиента пользователя. */
:root {
    --color-bg: var(--tg-theme-bg-color, #ffffff);
    --color-secondary-bg: var(--tg-theme-secondary-bg-color, #f1f1f1);
    --color-section-bg: var(--tg-theme-section-bg-color, #ffffff);
    --color-text: var(--tg-theme-text-color, #000000);
    --color-hint: var(--tg-theme-hint-color, #999999);
    --color-subtitle: var(--tg-theme-subtitle-text-color, #999999);
    --color-link: var(--tg-theme-link-color, #168acd);
    --color-button: var(--tg-theme-button-color, #40a7e3);
    --color-button-text: var(--tg-theme-button-text-color, #ffffff);
    --color-destructive: var(--tg-theme-destructive-text-color, #d14e4e);
    --color-separator: var(--tg-theme-section-separator-color, #e7e7e7);
    --radius-full: 999px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    margin: 0; padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: SF Pro, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
body::-webkit-scrollbar { display: none; }
button { font: inherit; }

.hidden { display: none !important; }

/* Pill-кнопка — тот же паттерн, что в присланном "кнопка, откуда нужно взять акцентный
   цвет" (rounded-full, bg-button/text-button-text, py-2.5 px-4, font-medium text-sm). */
.pill-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%;
    border: none; border-radius: var(--radius-full);
    padding: 13px 16px;
    font-size: 15px; font-weight: 600;
    background: var(--color-button);
    color: var(--color-button-text);
    cursor: pointer;
    transition: opacity .15s ease, transform .1s ease;
}
.pill-btn:active { opacity: .8; transform: scale(.98); }
.pill-btn[disabled] { opacity: .45; pointer-events: none; }

.pill-btn--muted {
    background: color-mix(in srgb, var(--color-hint) 22%, transparent);
    color: var(--color-hint);
}

.pill-btn--outline {
    background: transparent;
    color: var(--color-button);
    box-shadow: inset 0 0 0 1.5px var(--color-button);
}

/* Три акцентных цвета кнопки участия, которые выбирает админ на шаге 4. */
.btn-accent-blue  { background: #3390EC; color: #ffffff; }
.btn-accent-red   { background: #E53935; color: #ffffff; }
.btn-accent-green { background: #34C759; color: #ffffff; }

/* ---- Нижний bottom sheet ("снизу вверх") ---- */
.sheet-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .35);
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
    z-index: 40;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    max-height: 88vh;
    background: var(--color-bg);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.15);
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.32,.72,0,1);
    z-index: 41;
    display: flex; flex-direction: column;
    padding-bottom: calc(16px + var(--safe-bottom));
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
    width: 36px; height: 4px; border-radius: 3px;
    background: var(--color-separator);
    margin: 8px auto 4px;
}

.sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px 4px;
}
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-close {
    border: none; background: var(--color-secondary-bg); color: var(--color-hint);
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; cursor: pointer;
}

.sheet-body {
    padding: 12px 16px 4px;
    overflow-y: auto;
}

.step-dots { display: flex; gap: 6px; justify-content: center; padding: 4px 0 14px; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-separator); }
.step-dot.active { background: var(--color-button); width: 16px; border-radius: 3px; transition: all .2s ease; }

.field-label {
    font-size: 13px; color: var(--color-hint); font-weight: 500;
    margin: 14px 0 6px;
    text-transform: uppercase; letter-spacing: .2px;
}
.field-label:first-child { margin-top: 0; }

textarea.field-input, input.field-input {
    width: 100%;
    background: var(--color-secondary-bg);
    border: none; border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px; color: var(--color-text);
    resize: none;
    outline: none;
}
textarea.field-input { min-height: 110px; line-height: 1.4; }
.field-hint { font-size: 12.5px; color: var(--color-hint); margin-top: 6px; }
.field-counter { text-align: right; font-size: 12px; color: var(--color-hint); margin-top: 4px; }

.option-row {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--color-secondary-bg);
    border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.option-row .option-label { font-size: 15px; }
.option-row .option-sub { font-size: 12.5px; color: var(--color-hint); margin-top: 2px; }

.switch {
    position: relative; width: 46px; height: 28px; flex-shrink: 0;
    border-radius: var(--radius-full);
    background: var(--color-separator);
    cursor: pointer; transition: background .15s ease;
    touch-action: manipulation;
}
.switch.on { background: var(--color-button); }
.switch .knob {
    position: absolute; top: 2px; left: 2px;
    width: 24px; height: 24px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
    transition: transform .15s ease;
    /* Клики всегда должны попадать на .switch, а не на этот дочерний круг —
       иначе обработчик клика получает e.target === .knob, у которого никогда
       нет класса .on, и определяет состояние переключателя неверно (см. app.js). */
    pointer-events: none;
}
.switch.on .knob { transform: translateX(18px); }

.color-picker { display: flex; gap: 10px; }
.color-swatch {
    flex: 1; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 600;
    border: 2.5px solid transparent;
    cursor: pointer;
    /* Теперь это <button>, а не <div> — сбрасываем UA-стили и явно просим браузер не
       откладывать обработку тапа в ожидании возможного двойного тапа/зума. На части
       мобильных WebView (в т.ч. внутри Telegram) это иногда мешало клику по div'ам
       регистрироваться с первого раза. */
    appearance: none; -webkit-appearance: none; outline: none;
    touch-action: manipulation;
}
.color-swatch.selected { border-color: var(--color-text); }

.btn-preview-wrap { margin-top: 18px; padding: 14px; background: var(--color-secondary-bg); border-radius: 14px; }
.btn-preview-caption { font-size: 12.5px; color: var(--color-hint); margin-bottom: 10px; text-align: center; }

.datetime-input { display: flex; gap: 8px; }
.datetime-input input { flex: 1; }

.summary-row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--color-separator);
    font-size: 14px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row .k { color: var(--color-hint); }
.summary-row .v { text-align: right; max-width: 65%; }

.error-banner {
    background: color-mix(in srgb, var(--color-destructive) 14%, transparent);
    color: var(--color-destructive);
    border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px;
}
