/* Gramotix editor (gx-editor) v1 — стили компонента редактора и страницы конструктора.
   Оформление по образцу cvguide.ru/konstruktor-rezume.html, токены — tokens.css (--stx-*). */

.gx-editor, .gx-picker, .gx-toast, .gx-page {
  --gx-text: var(--stx-text, #1B2430);
  --gx-text-2: #52617A;
  --gx-text-3: #64748F;
  --gx-accent: var(--stx-accent, #2F6BFF);
  --gx-accent-text: var(--stx-accent-text, #1F52D9);
  --gx-accent-ring: var(--stx-accent-ring, rgba(47, 107, 255, .30));
  --gx-line: #DCE2ED;
  --gx-line-soft: #CFDBFA;
  --gx-field-bg: #F9FAFF;
  --gx-card-shadow: 0 10px 28px rgba(36, 71, 131, .024), 0 2px 5px rgba(38, 54, 83, .01);
  --gx-btn-grad: linear-gradient(110deg, #2F6BFF, #5384FF);
  --gx-font: "Inter", var(--stx-font, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-family: var(--gx-font);
  color: var(--gx-text);
}
.gx-editor *, .gx-editor *::before, .gx-editor *::after,
.gx-picker *, .gx-picker *::before, .gx-picker *::after { box-sizing: border-box; }

.gx-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gx-editor [hidden], .gx-picker[hidden], .gx-toast[hidden], .gx-picker [hidden] { display: none !important; }

/* ---------- страница konstruktor.html ---------- */
.gx-page { width: 100%; max-width: 1360px; margin: 0 auto; padding: 32px 0 64px; }
.gx-page__intro { text-align: center; max-width: 900px; margin: 0 auto 28px; }
.gx-page__intro h1 { font-size: clamp(26px, 3.2vw, 36px); line-height: 1.18; font-weight: 600; letter-spacing: -.02em; color: #0B1945; margin: 0 0 14px; }
.gx-page__intro p { font-size: 16px; line-height: 1.6; color: var(--gx-text-2); margin: 0; }
.gx-page__seo { max-width: 820px; margin: 56px auto 0; color: var(--gx-text); font-size: 17px; line-height: 1.6; }
.gx-page__seo h2 { font-size: clamp(22px, 2.4vw, 30px); line-height: 1.25; font-weight: 700; margin: 0 0 16px; color: var(--gx-text); }
.gx-page__seo p { margin: 0 0 14px; }
.gx-page__seo .gx-placeholder { padding: 16px 18px; border: 1px dashed var(--gx-line-soft); border-radius: 16px; color: var(--gx-text-3); background: #fff; }

/* ---------- раскладка ---------- */
.gx-editor { position: relative; display: block; }
/* обвязка: плотная светлая подложка с рамкой и тенью — редактор отделён от фона страницы (в т.ч. от hero-bg) */
.gx-layout {
  display: grid; grid-template-columns: minmax(360px, 1fr) minmax(420px, 1.18fr); gap: 16px; align-items: start;
  padding: 16px; background: #F4F7FF; border: 1px solid #CBD6EA; border-radius: 28px;
  box-shadow: 0 1px 2px rgba(20, 40, 80, .06), 0 18px 48px rgba(20, 40, 80, .14);
}
.gx-col { min-width: 0; }
.gx-col--preview { position: sticky; top: 16px; }

/* ---------- карточки формы ---------- */
.gx-form { display: grid; gap: 12px; margin: 0; }
.gx-card {
  position: relative; margin: 0; min-width: 0;
  background: #fff; border: 1px solid #D3DCEC; border-radius: 22px; padding: 20px 22px;
  box-shadow: 0 1px 2px rgba(20, 40, 80, .06), 0 6px 18px rgba(20, 40, 80, .07);
}
.gx-eyebrow { display: block; font-size: 10px; line-height: 1.5; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--gx-text-3); }
.gx-card__title { font-size: 24px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; margin: 4px 0 2px; color: #0B1945; }
.gx-card__sub { font-size: 13px; line-height: 1.45; color: var(--gx-text-2); margin: 0 0 12px; }
.gx-group { padding-top: 18px; }
.gx-group__legend { float: left; width: 100%; padding: 0 0 0 12px; margin: 0 0 12px; font-size: 17px; line-height: 1.3; font-weight: 700; color: #0B1945; position: relative; }
.gx-group__legend::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px; border-radius: 4px; background: var(--gx-accent); }
.gx-grid { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }

/* карточка выбранного шаблона */
.gx-tplcard { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--gx-line); border-radius: 18px; background: var(--gx-field-bg); }
.gx-tplcard__img { flex: 0 0 auto; width: 84px; height: 60px; object-fit: contain; border-radius: 8px; background: #fff; box-shadow: 0 1px 3px rgba(20, 40, 80, .12); }
.gx-tplcard__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gx-tplcard__name { font-size: 14px; line-height: 1.35; font-weight: 600; color: var(--gx-text); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gx-tplcard__meta { font-size: 12px; line-height: 1.4; color: var(--gx-text-3); }
.gx-note { margin-top: 10px; padding: 10px 12px; border-radius: 14px; font-size: 13px; line-height: 1.5; background: #FFF8EA; border: 1px solid rgba(245, 158, 11, .28); color: #7A4A00; }

/* ---------- поля ---------- */
.gx-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gx-field--wide { grid-column: 1 / -1; }
.gx-field__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.gx-label { font-size: 14px; line-height: 1.4; font-weight: 600; color: var(--gx-text); }
.gx-field.is-focus > .gx-field__top .gx-label { color: var(--gx-accent-text); }
/* счётчик: аккуратная «таблетка», при приближении к пределу — жёлтая, на пределе — красная */
.gx-count {
  flex: 0 0 auto; padding: 1px 8px; border-radius: 999px; background: #EEF1F7; color: var(--gx-text-2);
  font-size: 11.5px; line-height: 1.6; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.gx-count.is-near { background: #FFF1D6; color: #8A4B00; font-weight: 600; }
.gx-count.is-limit { background: #FDE4E8; color: #B3243C; font-weight: 600; }
.gx-input {
  width: 100%; min-height: 54px; margin: 0; padding: 14px 16px;
  font: 500 16.5px/1.45 var(--gx-font); color: var(--gx-text);
  background: #fff; border: 1.5px solid #B9C4D8; border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20, 40, 80, .06), 0 3px 8px rgba(20, 40, 80, .04);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
  -webkit-appearance: none; appearance: none;
}
textarea.gx-input { resize: vertical; min-height: 96px; }
/* подсказка-пример (placeholder) заметно светлее и курсивом, введённый текст — тёмный и плотнее */
.gx-input::placeholder { color: #9AA6BA; font-weight: 400; font-style: italic; opacity: 1; }
.gx-input:hover { border-color: #8EA0BD; }
.gx-input:focus { outline: none; background: #fff; border-color: var(--gx-accent); box-shadow: 0 0 0 4px var(--gx-accent-ring), 0 6px 18px rgba(47, 107, 255, .16); }
.gx-input[type="date"] { min-height: 54px; }
.gx-field.is-filled .gx-input:not(:focus) { border-color: #7FA0F0; }
.gx-field.is-limit .gx-input { border-color: #E0405A; }
.gx-field.is-limit .gx-input:focus { box-shadow: 0 0 0 4px rgba(224, 64, 90, .22); }
.gx-input[aria-invalid="true"] { border-color: #E0405A; }
.gx-select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2352617A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; cursor: pointer; }
.gx-select:disabled { opacity: .6; cursor: not-allowed; }
.gx-select:focus { background-color: #fff; }

/* Селект в стиле сайта (окно выбора шаблона): кнопка как поле формы + свой список; на телефоне — нативный select */
.gx-dd { position: relative; }
.gx-dd:not(.is-native) > .gx-select { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0; pointer-events: none; }
.gx-dd.is-native > .gx-dd__btn, .gx-dd.is-native > .gx-dd__list { display: none !important; }
.gx-dd__btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  text-align: left; cursor: pointer; padding-right: 42px; position: relative;
}
.gx-dd__btn::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2352617A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") center / 18px no-repeat;
  transition: transform .18s var(--stx-ease, ease);
}
.gx-dd.is-open .gx-dd__btn { background: #fff; border-color: var(--gx-accent); box-shadow: 0 0 0 4px var(--gx-accent-ring); }
.gx-dd.is-open .gx-dd__btn::after { transform: rotate(180deg); }
.gx-dd__val { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gx-dd.is-empty .gx-dd__val { color: var(--gx-text-2); }
.gx-dd__btn:disabled { opacity: .6; cursor: not-allowed; }
.gx-dd__list {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; max-height: 300px; overflow: auto;
  margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--gx-line); border-radius: 14px;
  box-shadow: var(--stx-shadow-md, 0 8px 24px rgba(20, 40, 80, .10)); outline: none;
}
.gx-dd__list:focus-visible { box-shadow: var(--stx-shadow-md, 0 8px 24px rgba(20, 40, 80, .10)), 0 0 0 3px var(--gx-accent-ring); }
.gx-dd__opt { position: relative; margin: 0; padding: 9px 34px 9px 12px; border-radius: 10px; font-size: 14px; line-height: 1.35; color: var(--gx-text); cursor: pointer; }
.gx-dd__opt::before { content: none; }
.gx-dd__opt--all { color: var(--gx-text-2); }
.gx-dd__opt.is-active { background: #EEF3FF; }
.gx-dd__opt[aria-selected="true"] { color: var(--gx-accent-text); font-weight: 600; }
.gx-dd__opt[aria-selected="true"]::after {
  content: ""; position: absolute; right: 10px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231F52D9' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.gx-picker__filters { position: relative; z-index: 3; }
.gx-hint { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--gx-text-2); }
.gx-field.is-limit .gx-hint::after { content: " Достигнут предел длины."; color: #B3243C; font-weight: 600; }

/* готовые формулировки */
.gx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gx-chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; margin: 0;
  font: 500 13.5px/1.3 var(--gx-font); color: var(--gx-accent-text);
  background: #fff; border: 1px solid var(--gx-line-soft); border-radius: 999px; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.gx-chip:hover { background: #EEF3FF; border-color: #AFC4F7; }
.gx-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--gx-accent-ring); }

/* ---------- кнопки (как на cvguide) ---------- */
.gx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px 10px 14px; margin: 0;
  font: 600 14px/1.2 var(--gx-font); border-radius: 13px; cursor: pointer; white-space: nowrap;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
}
.gx-btn svg { flex: 0 0 auto; }
.gx-btn--ghost { color: #2C58DC; background: #fff; border: .8px solid var(--gx-line-soft); box-shadow: 0 2px 6px rgba(44, 88, 220, .07); }
.gx-btn--ghost:hover { border-color: #9DB6F5; background: #F6F9FF; }
.gx-btn--primary { color: #fff; background: var(--gx-btn-grad); border: .8px solid #3A6DF0; box-shadow: inset 0 1px 1px rgba(255, 255, 255, .31), 0 3px 6px rgba(49, 95, 223, .14); }
.gx-btn--primary:hover { box-shadow: inset 0 1px 1px rgba(255, 255, 255, .31), 0 6px 16px rgba(47, 107, 255, .26); }
.gx-btn--lg { min-height: 44px; padding: 11px 16px; border-radius: 14px; }
.gx-btn--sm { min-height: 38px; padding: 7px 12px 7px 10px; font-size: 13px; }
.gx-btn:active { transform: translateY(1px); }
.gx-btn:focus-visible, .gx-iconbtn:focus-visible, .gx-switch__btn:focus-visible, .gx-tpl:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--gx-accent-ring); }
.gx-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: 0; padding: 0; border: 0; border-radius: 12px; background: #F1F4FA; color: var(--gx-text); cursor: pointer; }
.gx-iconbtn:hover { background: #E6EBF5; }

/* ---------- превью ---------- */
.gx-preview {
  background: #fff; border: 1px solid #D3DCEC; border-radius: 22px; padding: 18px 18px 16px;
  box-shadow: 0 1px 2px rgba(20, 40, 80, .06), 0 6px 18px rgba(20, 40, 80, .07);
}
.gx-preview__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 10px; }
.gx-preview__head .gx-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; color: #0B1945; }
.gx-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; color: #7A4A00; background: #FFF3DC; }
.gx-preview__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gx-preview__actions [data-gx-action="download"] { margin-left: auto; }
.gx-preview__note { margin: 10px 2px 12px; font-size: 12px; line-height: 1.45; color: var(--gx-text-2); }
/* подложка листа: тёмнее нейтральная, чтобы белый лист и его тень читались */
.gx-sheet-wrap { display: flex; justify-content: center; padding: 16px; background: #CDD3DE; border-radius: 14px; box-shadow: inset 0 1px 4px rgba(20, 30, 60, .18); }

/* лист A4: фон-картинка + слой полей + слой водяного знака */
.gx-sheet {
  --gx-mm: 2px;
  position: relative; width: 100%; aspect-ratio: 297 / 210; overflow: hidden;
  background: #fff; border-radius: 4px; box-shadow: 0 2px 4px rgba(20, 30, 60, .2), 0 14px 34px rgba(20, 30, 60, .3);
  user-select: none; -webkit-user-select: none; container-type: inline-size;
}
.gx-sheet--portrait { aspect-ratio: 210 / 297; max-width: min(100%, 560px); }
.gx-sheet__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }
.gx-sheet__layer { position: absolute; inset: 0; }
.gx-el { position: absolute; display: flex; overflow: hidden; }
.gx-el--line { display: block; }
.gx-el--text { flex-direction: column; justify-content: center; }
.gx-el.gx-va-top { justify-content: flex-start; }
.gx-el.gx-va-bottom { justify-content: flex-end; }
.gx-el__text { width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; hyphens: manual; }
.gx-el--field { cursor: pointer; }
.gx-el--field:hover { outline: 1px dashed rgba(47, 107, 255, .45); outline-offset: -1px; }
.gx-el.is-active { outline: 2px solid rgba(47, 107, 255, .85); outline-offset: -1px; background-color: rgba(47, 107, 255, .09); border-radius: 3px; box-shadow: 0 0 0 4px rgba(47, 107, 255, .16); }
.gx-sheet.has-active .gx-el--field:not(.is-active) { opacity: .6; transition: opacity .15s; }
.gx-el.is-sample .gx-el__text { opacity: .38; }

/* Водяной знак «Gramotix» справа внизу (этап 6): параметры дублируются в серверном рендере, см. editor-template-format.md */
.gx-sheet__wm {
  position: absolute; right: calc(var(--gx-mm) * 5); bottom: calc(var(--gx-mm) * 5);
  padding: calc(var(--gx-mm) * 2.2) calc(var(--gx-mm) * 4.9); background: #fff; border-radius: calc(var(--gx-mm) * 4.3);
  font: 600 calc(var(--gx-mm) * 4.4) / 1.2 "Inter", Arial, sans-serif; color: #1b2430; white-space: nowrap;
  box-shadow: 0 calc(var(--gx-mm) * .3) calc(var(--gx-mm) * 1.5) rgba(27, 36, 48, .22);
  pointer-events: auto; cursor: pointer; z-index: 2; border: 0; margin: 0; appearance: none; -webkit-appearance: none;
  transition: background .15s, color .15s;
}
.gx-sheet__wm[hidden] { display: none; }
.gx-sheet__wm:hover, .gx-sheet__wm:focus-visible { background: rgba(255, 255, 255, .55); color: rgba(27, 36, 48, .55); box-shadow: none; }
.gx-sheet__wm::after {
  content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 6px); width: max-content; max-width: min(260px, 60cqw);
  padding: 6px 10px; border-radius: 8px; background: #1b2430; color: #fff; font: 500 12px/1.35 "Inter", Arial, sans-serif;
  white-space: normal; text-align: left; box-shadow: 0 4px 14px rgba(20, 30, 60, .3);
  opacity: 0; visibility: hidden; transition: opacity .15s; pointer-events: none;
}
.gx-sheet__wm:hover::after, .gx-sheet__wm:focus-visible::after { opacity: 1; visibility: visible; }

/* ---------- окно выбора шаблона ---------- */
html.gx-noscroll { overflow: hidden; }
.gx-picker { position: fixed; inset: 0; z-index: 10050; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gx-picker__scrim { position: absolute; inset: 0; background: rgba(27, 36, 48, .38); backdrop-filter: blur(2px); }
.gx-picker__panel {
  position: relative; width: min(1080px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: #fff; border-radius: 24px; padding: 22px 24px 18px; box-shadow: 0 24px 64px rgba(20, 40, 80, .18);
}
.gx-picker__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gx-picker__title { margin: 0; font-size: 22px; line-height: 1.3; font-weight: 600; color: var(--gx-text); }
.gx-picker__sub { margin: 4px 0 14px; font-size: 13px; color: var(--gx-text-2); }
.gx-picker__filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
.gx-search { position: relative; }
.gx-search__ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #8C97AA; display: flex; pointer-events: none; }
.gx-input--search { padding-left: 40px; }
.gx-picker__count { margin: 12px 0 8px; font-size: 12px; color: var(--gx-text-3); }
.gx-picker__body { overflow: auto; margin: 0 -6px; padding: 4px 6px 6px; }
.gx-picker__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.gx-picker__grid li { margin: 0; padding: 0; }
.gx-picker__grid li::before { content: none; }
.gx-tpl {
  display: flex; flex-direction: column; gap: 6px; width: 100%; height: 100%; margin: 0; padding: 10px; text-align: left;
  background: #fff; border: 1px solid var(--gx-line); border-radius: 16px; cursor: pointer; font-family: var(--gx-font);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.gx-tpl:hover { border-color: #9DB6F5; box-shadow: 0 12px 32px rgba(20, 40, 80, .10); transform: translateY(-1px); }
.gx-tpl.is-current { border-color: var(--gx-accent); box-shadow: 0 0 0 2px var(--gx-accent-ring); }
.gx-tpl__img { display: flex; align-items: center; justify-content: center; height: 130px; border-radius: 10px; background: #F1F4FA; overflow: hidden; }
.gx-tpl__img img { max-width: 92%; max-height: 92%; object-fit: contain; box-shadow: 0 1px 4px rgba(20, 40, 80, .15); background: #fff; }
.gx-tpl__name { font-size: 13px; line-height: 1.35; font-weight: 600; color: var(--gx-text); }
.gx-tpl__meta { font-size: 11.5px; line-height: 1.35; color: var(--gx-text-3); }

/* ---------- состояние сохранения и окна этапа 6 ---------- */
.gx-savestate { margin-left: auto; margin-right: 8px; font-size: 12px; line-height: 1.3; color: var(--gx-text-2); text-align: right; }
.gx-savestate:empty { display: none; }
.gx-editor.is-saving .gx-btn[aria-busy="true"] { opacity: .75; cursor: progress; }
.gx-btn:disabled { cursor: not-allowed; opacity: .6; }
.gx-btn.is-spin > svg, .gx-switch__dl.is-spin > svg { display: none; }
.gx-btn.is-spin::after, .gx-switch__dl.is-spin::after {
  content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: gx-spin .7s linear infinite; flex: none;
}
@keyframes gx-spin { to { transform: rotate(360deg); } }
.gx-switch__dl { display: none; }
.gx-dialog__panel { width: min(480px, 100%); padding: 22px 24px 20px; }
.gx-dialog .gx-picker__sub { margin: 6px 0 16px; font-size: 14px; line-height: 1.5; }
.gx-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.gx-formats { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.gx-format { display: grid; grid-template-columns: auto 64px 1fr; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--gx-line); border-radius: 14px; background: var(--gx-field-bg); cursor: pointer; }
.gx-format:has(input:checked) { border-color: var(--gx-accent); background: #fff; box-shadow: 0 0 0 3px var(--gx-accent-ring); }
.gx-format input { width: 18px; height: 18px; margin: 0; accent-color: var(--gx-accent); }
.gx-format__name { font-weight: 600; font-size: 15px; color: var(--gx-text); }
.gx-format__hint { font-size: 13px; color: var(--gx-text-2); }

/* ---------- тост ---------- */
.gx-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10060;
  max-width: min(520px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 14px;
  background: #1B2430; color: #fff; font: 500 14px/1.45 var(--gx-font); box-shadow: 0 12px 32px rgba(20, 40, 80, .25);
}

/* ---------- мобильный переключатель «Данные / Превью» ---------- */
.gx-switch { display: none; }
.gx-only-narrow { display: none; }
.gx-switch__btn {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin: 0; padding: 10px;
  font: 500 14px/1.2 var(--gx-font); color: #303C58; background: transparent; border: 0; border-radius: 15px; cursor: pointer;
}
.gx-switch__btn[aria-selected="true"] { background: #fff; color: var(--gx-accent-text); font-weight: 600; box-shadow: 0 2px 6px rgba(37, 50, 83, .043), 0 0 0 1px #E6EAF0; }

@media (max-width: 1400px) { .gx-page { padding-left: 20px; padding-right: 20px; } }

@media (max-width: 1100px) {
  .gx-layout { grid-template-columns: minmax(320px, 1fr) minmax(360px, 1fr); }
}

@media (max-width: 899px) {
  .gx-page { padding: 20px 12px 48px; }
  .gx-layout { padding: 12px; border-radius: 22px; }
  .gx-switch {
    display: flex; gap: 4px; position: fixed; left: 12px; right: 12px; bottom: 10px; top: auto; z-index: 30; margin: 0; padding: 4px;
    background: rgba(241, 244, 250, .92); backdrop-filter: blur(10px); border-radius: 18px; box-shadow: 0 0 0 1px rgba(27, 36, 48, .06);
  }
  .gx-switch__dl {
    flex: 1.35 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin: 0; padding: 10px 14px;
    font: 600 15px/1.2 var(--gx-font); color: #fff; background: var(--gx-accent, #2F6BFF); border: 0; border-radius: 15px; cursor: pointer;
    box-shadow: 0 6px 16px rgba(47, 107, 255, .35);
  }
  .gx-switch__dl:disabled { opacity: .6; cursor: not-allowed; }
  .gx-editor, .gx-preview { scroll-margin-top: 72px; }
  .gx-only-wide { display: none; }
  .gx-only-narrow { display: inline; }
  .gx-layout { grid-template-columns: 1fr; gap: 16px; }
  .gx-col--preview { position: static; }
  /* превью под формой; переключатель показывает одну из панелей */
  .gx-editor[data-gx-view="data"] .gx-col--preview { display: none; }
  .gx-editor[data-gx-view="preview"] .gx-col--form { display: none; }
  .gx-picker__filters { grid-template-columns: 1fr 1fr; }
  .gx-field--search { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .gx-layout { padding: 8px; gap: 10px; border-radius: 18px; }
  .gx-card { padding: 16px 14px; border-radius: 16px; }
  .gx-sheet-wrap { padding: 10px; }
  .gx-input { font-size: 16px; } /* iOS не масштабирует страницу при фокусе */
  .gx-card__title { font-size: 21px; }
  .gx-grid { grid-template-columns: 1fr; }
  .gx-preview { padding: 14px 10px 12px; border-radius: 16px; }
  .gx-preview__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .gx-preview__actions .gx-btn { padding-left: 8px; padding-right: 8px; font-size: 13px; }
  .gx-preview__actions [data-gx-action="download"] { margin-left: 0; grid-column: 1 / -1; }
  .gx-preview__note { font-size: 11.5px; margin: 10px 2px 12px; }
  .gx-tplcard { flex-wrap: wrap; }
  .gx-tplcard__img { width: 64px; height: 46px; }
  .gx-tplcard .gx-btn { width: 100%; }
  .gx-picker { padding: 0; align-items: stretch; }
  .gx-picker__panel { max-height: 100vh; height: 100%; border-radius: 0; padding: 16px; }
  .gx-picker__filters { grid-template-columns: 1fr; }
  .gx-picker__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gx-tpl__img { height: 100px; }
  .gx-dialog { padding: 16px; align-items: center; }
  .gx-dialog .gx-picker__panel { height: auto; border-radius: 20px; }
  .gx-dialog__actions .gx-btn { flex: 1 1 100%; white-space: normal; }
  .gx-savestate { flex-basis: 100%; order: 3; text-align: left; margin: 4px 0 0; }
  .gx-preview__head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .gx-editor *, .gx-picker * { transition: none !important; scroll-behavior: auto !important; }
}

/* конструктор: одна синяя кнопка «Выбрать шаблон» по центру */
.cv-exact-hero.gx-kon-hero .cv-hero-buttons { grid-template-columns: minmax(0, 382px); justify-content: center; }

/* «Похожие шаблоны» (только ПК) */
.gx-sim { margin-top: 14px; }
.gx-sim__title { margin: 0 0 8px; font-size: 16px; line-height: 1.3; font-weight: 600; color: var(--gx-text); }
.gx-sim__wrap { position: relative; }
.gx-sim__view { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.gx-sim__view::-webkit-scrollbar { display: none; }
.gx-sim__track { display: flex; align-items: flex-start; gap: 10px; }
.gx-sim__card {
  display: block; align-self: flex-start; flex: 0 0 calc((100% - 30px) / 4); scroll-snap-align: start; min-width: 0; padding: 0; margin: 0; border: 0; background: none; cursor: pointer;
  text-align: left; font: inherit; color: var(--gx-text); user-select: none; -webkit-user-select: none;
}
.gx-sim__img { display: block; aspect-ratio: 272 / 385; border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px rgba(27, 36, 48, .1); transition: box-shadow .15s, transform .15s; }
.gx-sim__img img { width: 100%; height: 100%; object-fit: contain; display: block; -webkit-user-drag: none; user-select: none; }
.gx-sim__card:hover .gx-sim__img, .gx-sim__card:focus-visible .gx-sim__img { box-shadow: 0 0 0 2px #3A6DF0, 0 6px 16px rgba(47, 107, 255, .22); transform: translateY(-2px); }
.gx-sim__name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 6px; font-size: 12px; line-height: 1.3; }
.gx-sim__arrow {
  position: absolute; top: 38%; z-index: 2; width: 32px; height: 32px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: #fff; color: #1b2430; font-size: 22px; line-height: 30px; box-shadow: 0 2px 8px rgba(20, 30, 60, .25);
}
.gx-sim__arrow--prev { left: -10px; } .gx-sim__arrow--next { right: -10px; }
.gx-sim__arrow:hover { background: #EEF3FF; }
@media (max-width: 899px) { .gx-sim { display: none !important; } }

/* окно выбора: нельзя выделять названия и сохранять картинки */
.gx-nosave .gx-tpl, .gx-nosave .gx-tpl * { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.gx-nosave img { -webkit-user-drag: none; user-drag: none; pointer-events: none; }

/* плавающая кнопка «Заполнить шаблон» */
.gx-fab {
  position: fixed; left: 50%; bottom: 16px; z-index: 900; transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  padding: 14px 28px; border-radius: 16px; border: .8px solid #3A6DF0; color: #fff; font: 600 16px/1.2 "Inter", Arial, sans-serif; cursor: pointer; white-space: nowrap;
  background: linear-gradient(180deg, #4C86FF 0%, #2F6BFF 100%); box-shadow: inset 0 1px 1px rgba(255, 255, 255, .31), 0 8px 22px rgba(47, 107, 255, .35);
  transition: opacity .2s, transform .2s;
}
.gx-fab.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* мобильная версия: «Продолжить заполнение» сверху превью, кнопки действий — под листом */
.gx-continue { display: none; }
@media (max-width: 899px) {
  .gx-preview { display: flex; flex-direction: column; }
  .gx-continue { display: inline-flex; width: 100%; justify-content: center; order: 0; margin-bottom: 12px; }
  .gx-preview__head { order: 1; } .gx-preview__note { order: 2; } .gx-sheet-wrap { order: 3; }
  .gx-preview__actions { order: 4; margin-top: 12px; }
}

/* окно выбора: крупные вертикальные мини-превью (как в каталоге) */
.gx-picker__grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.gx-tpl__img { height: auto; aspect-ratio: 272 / 385; }
.gx-tpl__img img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; }
@media (max-width: 560px) {
  .gx-picker__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gx-tpl { padding: 6px; }
  .gx-tpl__img { height: auto; }
}

/* правки 30.10: переключатель внизу, компактный выбор шаблона, без «Ваш документ» */
@media (max-width: 899px) {
  .gx-page { padding-bottom: 88px; }
  .gx-preview__head .gx-eyebrow { display: none; }
  .gx-toast { bottom: 84px; }
}
@media (max-width: 560px) {
  .gx-picker__panel { padding: 12px; }
  .gx-picker__head { margin-bottom: 8px; }
  .gx-picker__title { font-size: 18px; }
  .gx-picker__sub { display: none; }
  .gx-picker__filters { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gx-picker__filters .gx-field--search { grid-column: 1 / -1; }
  .gx-picker__filters .gx-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .gx-picker__filters .gx-input { min-height: 40px; height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; }
  .gx-picker__filters .gx-input--search { padding-left: 38px; }
  .gx-picker__filters .gx-select { padding-right: 28px; text-overflow: ellipsis; }
  .gx-picker__count { margin: 8px 0 4px; }
}

/* узкая колонка превью: три кнопки в одну строку, без спуска «Скачать» вниз */
@media (min-width: 561px) and (max-width: 1240px) {
  .gx-preview__actions { flex-wrap: nowrap; gap: 6px; }
  .gx-preview__actions .gx-btn { min-width: 0; flex: 0 1 auto; padding-left: 10px; padding-right: 10px; font-size: 13px; gap: 6px; }
  .gx-preview__actions [data-gx-action="download"] { flex: 0 0 auto; }
}
@media (min-width: 561px) and (max-width: 1060px) {
  .gx-preview__actions .gx-btn { padding-left: 8px; padding-right: 8px; font-size: 12.5px; }
}

/* окно оплаты поверх нижней панели и плавающей кнопки */
.stx-pw-lock .gx-switch, .stx-pw-lock .gx-fab { display: none !important; }
body:has(.screen.is-active) .gx-switch, body:has(.screen.is-active) .gx-fab { display: none !important; }
@media (max-width: 899px) { .gx-savestate { display: none !important; } }
