/* Инструмент «штамп на фото». Цвета - токены сайта Geoplate (site/geoplate/styles.css: Concrete и
   Graphite из темы приложения); на странице без них - те же значения запасными. Всё внутри .gst,
   чтобы модуль встал в каркас Фазы 2 и не задел его стили. */

.gst {
    --gst-bg: var(--gp-bg, #ECEBE7);
    --gst-surface: var(--gp-surface, #FFFFFF);
    --gst-surface2: var(--gp-surface2, #F5F4F1);
    --gst-ink: var(--gp-ink, #16191D);
    --gst-mute: var(--gp-mute, #555B64);
    --gst-line: var(--gp-line, #DEDBD4);
    --gst-accent: var(--gp-accent, #FFCC00);
    --gst-on-accent: #16191D;
    --gst-error: #B42318;
    --gst-r: 18px;
    color: var(--gst-ink);
    font-size: 16px;
    line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
    .gst {
        --gst-bg: var(--gp-bg, #0F1114);
        --gst-surface: var(--gp-surface, #191C21);
        --gst-surface2: var(--gp-surface2, #23272D);
        --gst-ink: var(--gp-ink, #F3F4F5);
        --gst-mute: var(--gp-mute, #A9AFB8);
        --gst-line: var(--gp-line, #2C3138);
        --gst-accent: var(--gp-accent, #FFD21F);
        --gst-error: #FF8A80;
    }
}

.gst *, .gst *::before, .gst *::after { box-sizing: border-box; }
.gst [hidden] { display: none !important; }

.gst-h { font-size: 18px; line-height: 1.3; margin: 0 0 12px; font-weight: 700; }
.gst-muted { color: var(--gst-mute); }
.gst-small { font-size: 13px; margin: 8px 0 0; }

/* Кнопки */
.gst-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 12px 20px; border-radius: 99px; border: 0;
    font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.gst-btn:focus-visible, .gst-face:focus-visible, .gst-link:focus-visible, .gst-chip:focus-visible,
.gst-close:focus-visible {
    outline: 3px solid var(--gst-accent); outline-offset: 2px;
}
.gst-btn-primary { background: var(--gst-accent); color: var(--gst-on-accent); }
.gst-btn-primary:disabled { opacity: .6; cursor: progress; }
.gst-btn-ghost { background: var(--gst-surface2); color: var(--gst-ink); min-height: 44px; padding: 10px 16px; font-weight: 600; }
.gst-btn-store { background: var(--gst-ink); color: var(--gst-bg); width: 100%; }
.gst-btn-store svg { width: 20px; height: 20px; }
.gst-link {
    background: none; border: 0; padding: 8px 0; font: inherit; color: var(--gst-ink);
    text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* Выбор фото */
.gst-drop {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
    padding: 36px 20px; border: 2px dashed var(--gst-line); border-radius: var(--gst-r);
    background: var(--gst-surface);
    transition: border-color .15s, background-color .15s;
}
.gst-drop.is-over { border-color: var(--gst-accent); background: var(--gst-surface2); }
.gst-drop-icon { width: 44px; height: 44px; color: var(--gst-mute); }
.gst-drop .gst-btn-primary { min-width: 220px; font-size: 17px; }
.gst-drop-text { margin: 0; color: var(--gst-mute); font-size: 14px; }
.gst-privacy { margin: 6px 0 0; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.gst-lock { width: 14px; height: 14px; flex: none; }

.gst-status { margin: 12px 0 0; font-weight: 600; }
.gst-status.is-error { color: var(--gst-error); }

/* Редактор: превью и панель рядом на широком экране, друг под другом на телефоне */
/* minmax(0, ...) - лента штампов листается внутри колонки, а не распирает страницу вбок */
.gst-editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
@media (min-width: 900px) {
    .gst-editor { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
    .gst-stage { position: sticky; top: 16px; grid-row: span 2; }
}
.gst-stage { position: relative; background: #0B0C0E; border-radius: var(--gst-r); overflow: hidden; }
.gst-preview { display: block; width: 100%; height: auto; max-height: 72vh; object-fit: contain; margin: 0 auto; }
.gst-change { position: absolute; top: 10px; right: 10px; background: rgba(15,17,20,.72); color: #fff; min-height: 36px; padding: 6px 14px; font-size: 14px; }

.gst-panel, .gst-pitch { background: var(--gst-surface); border-radius: var(--gst-r); padding: 18px; min-width: 0; }

/* Штампы: лента карточек, на телефоне листается вбок */
.gst-faces {
    display: grid; grid-auto-flow: column; grid-auto-columns: 96px; gap: 10px;
    overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-padding-inline: 18px;
    margin: 0 -18px 18px; padding: 3px 18px 6px; scrollbar-width: thin;
}
.gst-face {
    display: flex; flex-direction: column; gap: 6px; padding: 0; border: 0; background: none;
    font: inherit; font-size: 12px; font-weight: 600; line-height: 1.25; color: var(--gst-ink);
    text-align: left; cursor: pointer; scroll-snap-align: start; text-decoration: none;
}
.gst-face canvas, .gst-more-art {
    width: 96px; aspect-ratio: 3 / 4; border-radius: 12px; background: #2A2D33;
    box-shadow: 0 0 0 1px var(--gst-line); display: block;
}
.gst-face[aria-checked="true"] canvas { box-shadow: 0 0 0 3px var(--gst-accent); }
.gst-more-art {
    display: grid; place-items: center; color: #fff;
    background: radial-gradient(circle at 30% 30%, #3B4048, #16191D);
}
.gst-more-art .gst-lock { width: 22px; height: 22px; }
.gst-face-more span:last-child { color: var(--gst-mute); font-weight: 500; }
.gst-face-more b { color: var(--gst-ink); font-weight: 600; }

/* Поля */
.gst-form { display: grid; gap: 14px; margin-bottom: 18px; }
.gst-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.gst-field { display: grid; gap: 6px; min-width: 0; }
.gst-field > span { font-size: 13px; font-weight: 650; color: var(--gst-mute); }
.gst input, .gst select {
    width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px;
    border: 1px solid var(--gst-line); border-radius: 12px; background: var(--gst-surface2); color: var(--gst-ink);
    font: inherit; font-size: 16px; /* меньше 16 - iPhone увеличивает страницу при вводе */
    -webkit-appearance: none; appearance: none;
}
.gst select {
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
    background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px;
}
.gst input:focus, .gst select:focus { outline: 2px solid var(--gst-accent); outline-offset: 0; border-color: transparent; }
.gst-note { margin: 0; font-size: 14px; color: var(--gst-mute); }
.gst-coords { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.gst-coords .gst-link { font-size: 13px; padding: 0; }

/* Карта */
.gst-map-panel { display: grid; gap: 10px; margin-top: 4px; }
.gst-search { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.gst-search .gst-btn { white-space: nowrap; }
@media (max-width: 420px) { .gst-search { grid-template-columns: 1fr; } }
.gst-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.gst-results:empty { display: none; }
.gst-results li { font-size: 14px; }
.gst-results li.gst-muted { padding: 8px 4px; }
.gst-results button {
    width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px;
    background: var(--gst-surface2); color: var(--gst-ink); font: inherit; cursor: pointer;
}
.gst-map { position: relative; height: 280px; border-radius: 14px; overflow: hidden; background: var(--gst-surface2); }
/* width и height - класс maplibregl-map ставит position: relative, и без них высота 0 */
.gst-map-box { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Булавка по центру: двигается карта, точка - центр */
.gst-pin {
    position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -26px 0 0 -13px;
    background: #E5483A; border: 3px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    box-shadow: 0 2px 6px rgba(0,0,0,.35); pointer-events: none;
}
.gst-map-msg { margin: 0; font-size: 13px; }
.gst-map-msg.is-error { color: var(--gst-error); }

.gst-download { width: 100%; font-size: 17px; }

/* Приложение */
.gst-pitch p { margin: 0 0 12px; }
.gst-chips { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.gst-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px;
    background: var(--gst-surface2); color: var(--gst-ink); font-size: 13px; font-weight: 600; text-decoration: none;
}

/* Готовое фото */
.gst-sheet {
    position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center;
    background: rgba(0,0,0,.55); padding: 16px 0 0;
}
@media (min-width: 700px) { .gst-sheet { align-items: center; padding: 24px; } }
.gst-sheet-card {
    width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; background: var(--gst-bg);
    border-radius: 22px 22px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    display: grid; gap: 12px;
}
@media (min-width: 700px) { .gst-sheet-card { border-radius: 22px; } }
.gst-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gst-sheet-head .gst-h { margin: 0; }
.gst-close {
    width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--gst-surface2); color: var(--gst-ink);
    font-size: 26px; line-height: 1; cursor: pointer;
}
.gst-sheet-img {
    width: 100%; max-height: 46vh; object-fit: contain; border-radius: 12px; background: #0B0C0E;
    -webkit-touch-callout: default; /* долгое нажатие → «Сохранить» на iPhone */
}
.gst-sheet .gst-pitch { padding: 16px; }
.gst-sheet .gst-small { margin: 0; text-align: center; }
.gst-sheet [data-el="again"] { justify-self: center; }
html.gst-locked, html.gst-locked body { overflow: hidden; }

/* Встроенный браузер TikTok/Instagram не открыл App Store */
.gst-inapp {
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 1100;
    background: var(--gst-ink); color: var(--gst-bg); border-radius: 16px; padding: 14px 16px; display: grid; gap: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.gst-inapp p { margin: 0; font-size: 14px; }
.gst-inapp .gst-link { color: var(--gst-bg); justify-self: start; }
