* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--surface);
}

button { font-family: inherit; }

/* ---------- Плавающие элементы поверх холста ---------- */

.brand--float {
    position: fixed;
    top: 12px; left: 14px;
    z-index: 40;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 10px rgba(var(--text-rgb), .1);
}
.brand--float:hover { color: var(--brand); }

.zoom-bar--float {
    position: fixed;
    top: 12px; right: 12px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    padding: 2px;
    box-shadow: 0 2px 10px rgba(var(--text-rgb), .1);
}
.zoom-bar--float button {
    width: 24px; height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}
.zoom-bar--float button:hover { background: var(--brand-soft); color: var(--brand); }
.zoom-value { min-width: 42px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.zoom-value--reset { text-decoration: underline; text-decoration-style: dashed; text-underline-offset: 2px; }

/* ---------- Холст ---------- */

.canvas-viewport {
    position: fixed;
    inset: 0;
    overflow: hidden;
    touch-action: none;
    cursor: default;
    background: var(--bg);
    /* долгий тап на мобильном не должен открывать системное меню (docs/download.md) */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.editor-canvas { position: absolute; inset: 0; display: block; }

/* ---------- Панель слоёв: столбик иконок без единой плашки, «＋» сверху ---------- */

.layers-col {
    position: fixed;
    top: 62px; right: 12px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-height: 52vh;
    width: 58px;
}
.layers-add {
    width: 38px; height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--brand);
    color: var(--text-inverse);
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}
.layers-add:hover { background: var(--brand-hover); }
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-bottom: 4px;
    width: 100%;
    padding-right: 2px;
    /* нативный скроллбар скрыт: прокрутка только кнопками-стрелками (↑/↓) */
    scrollbar-width: none;
}
.layers-list::-webkit-scrollbar { display: none; }
.layers-scroll-group {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.layers-scroll {
    width: 26px; height: 26px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    box-shadow: 0 2px 8px rgba(var(--text-rgb), .1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.layers-scroll:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.layers-scroll:active { background: var(--brand-soft); }
/* кнопки-стрелки видимы, только когда список переполнен */
.layer-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.layer-row.is-hidden { opacity: 0.4; }
.layer-item {
    position: relative;
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    cursor: grab;
    touch-action: none;
    box-shadow: 0 2px 8px rgba(var(--text-rgb), .1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.layer-item:active { cursor: grabbing; }
.layer-item:hover { border-color: var(--brand); }
/* содержимое кружка (миниатюра изображения/кисти/фигуры) — «прозрачно» для указателя и нативного drag:
   захват/перетаскивание должно всегда доставаться самому слою */
.layer-icon img, .layer-icon canvas {
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}
.layer-row.is-selected .layer-item { border-color: var(--brand); background: var(--surface); color: var(--brand); }
.layer-row:hover .layer-item { border-color: var(--brand); }
/* Иконки меню слоя у верхнего края панели: глаз / клонировать / удалить.
   Половина над панелью, половина на панели (наезд); выше рукоятки-полосы по слою. */
.sheet .sheet-actions {
    position: absolute;
    top: -13px; right: 14px;
    z-index: 3;
    display: flex;
    gap: 18px;
}
.sheet .sheet-action {
    width: 26px; height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}
.sheet .sheet-action svg {
    width: 16px; height: 16px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sheet .sheet-action svg[hidden] { display: none; }
/* Цвета: глаз и копия — серые, корзина — красная. При наведении все три подсвечиваются заливкой
   (как корзина): глаз/копия — брендовым, корзина — красным. */
.sheet .sheet-action--eye { color: var(--muted); }
/* слой скрыт — значок глаза темнее (--text), слой виден — серый; при наведении в обоих случаях брендовая заливка */
.sheet .sheet-action--eye.is-off { color: var(--text); }
.sheet .sheet-action:hover { background: var(--brand); color: var(--text-inverse); }
.sheet .sheet-action--danger { color: var(--danger); }
.sheet .sheet-action--danger:hover { background: var(--danger); color: var(--text-inverse); }
.sheet .sheet-action[disabled] { opacity: 0.45; cursor: default; }
.sheet .sheet-action[disabled]:hover { background: var(--surface-2); color: var(--muted); }
.layer-row { transition: transform 0.12s ease; z-index: 0; }
.layer-row.is-dragging {
    transform: scale(1.18);
    z-index: 10;
}
.layer-row.is-dragging .layer-item { border-color: var(--brand); }
.layer-icon { line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.layer-icon img { width: 26px; height: 26px; object-fit: contain; display: block; }
.layer-icon-text { font-size: 13px; letter-spacing: -0.5px; }
/* Подсказка с названием слоя: показывается при наведении на кружок.
   Лежит вне прокручиваемого списка слоёв (в `.layers-col`), иначе список её обрезает. */
.layer-tip {
    position: absolute;
    right: calc(100% + 10px);
    transform: translateY(-50%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
}

.layers-menu {
    position: fixed;
    top: 110px;
    right: 12px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 35;
}
[hidden] { display: none !important; }
.layers-menu[hidden] { display: none; }
.layers-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.layers-menu .add-icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    line-height: 1;
}
.layers-menu button:hover { background: var(--brand-soft); }

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

.sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 40vh;
    z-index: 35;
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -6px 24px rgba(var(--text-rgb), .1);
    transition: height 0.2s ease;
    display: flex;
    flex-direction: column;
}
.sheet-handle {
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    touch-action: none;
    flex: none;
}
.sheet-handle span { width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet.is-collapsed { display: none; }
.sheet.is-resizing { transition: none; }
.sheet-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sheet-menu {
    display: flex;
    gap: 4px;
    padding: 0 10px 8px;
    border-bottom: 1px solid var(--line);
    flex: none;
    overflow-x: auto;
}
.menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.menu-btn:hover { background: var(--brand-soft); }
.menu-btn.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.menu-btn--save { margin-left: auto; background: var(--brand); color: var(--text-inverse); }
.menu-btn--save:hover { background: var(--brand-hover); }
.menu-btn--save.is-active { background: var(--brand); color: var(--text-inverse); }
.sheet-content { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 18px; }
.sheet-page[hidden] { display: none; }

/* ---------- Плавающие кнопки: ✂ (изображение, слева внизу), Сохранить (внизу справа) ---------- */
.fab {
    position: fixed;
    border: none;
    z-index: 20; /* ниже панели слоёв и нижней панели настроек (обе по 35) */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(var(--text-rgb), .25);
}
.fab--image {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 20px;
    left: 16px;
    bottom: 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text);
}
.fab--image:hover { background: var(--brand-soft); }
.fab--filter {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 20px;
    left: 16px;
    bottom: 76px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text);
}
.fab--filter:hover { background: var(--brand-soft); }
.fab--filter.is-active { background: var(--brand); border-color: var(--brand); color: var(--text-inverse); }
.fab--save {
    right: 16px;
    bottom: 16px;
    height: 44px;
    padding: 0 22px;
    border-radius: var(--radius-pill);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--brand);
    color: var(--text-inverse);
}
.fab--save:hover { background: var(--brand-hover); }

/* ---------- Панель фильтров (глобальный эффект на весь холст) ---------- */
.filter-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 45vh;
    z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -6px 24px rgba(var(--text-rgb), .14);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.2s ease;
}
.filter-sheet[hidden] { display: none; }
.filter-sheet.is-resizing { transition: none; }
.filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    flex: none;
}
.filter-head h1 { margin: 0; font-size: 15px; }
.filter-close {
    width: 30px; height: 30px; border: none; border-radius: 50%;
    background: var(--brand-soft); color: var(--muted); font-size: 16px; cursor: pointer;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 6px;
    padding: 12px 12px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.filter-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 6px 2px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: none;
    cursor: pointer;
    font-family: inherit;
}
.filter-item:hover { background: var(--brand-soft); }
.filter-item.is-active { background: var(--brand-soft); border-color: var(--brand); }
.filter-swatch {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid var(--line);
    display: block;
    background: conic-gradient(from 180deg, #f77, #f7f, #6ff, #6f6, #ff6, #f77);
}
.filter-item.is-active .filter-swatch { border-color: var(--brand); }
.filter-name { font-size: 11px; color: var(--text); text-align: center; line-height: 1.1; }
.filter-strength { flex: none; padding: 8px 14px 4px; border-top: 1px solid var(--line); }
.filter-strength .ctl { display: flex; gap: 10px; }
.filter-strength input[type="range"] { flex: 1; width: auto; }
.filter-strength b { min-width: 30px; text-align: center; font-size: 13px; color: var(--brand); }
.filter-sheet .row-actions { padding: 6px 14px 12px; flex: none; }

/* ---------- Панель изображения (Размер / Обрезать / Повернуть) ---------- */
.img-tabs { display: flex; gap: 4px; padding: 0 2px 8px; border-bottom: 1px solid var(--line); }
.img-tab {
    padding: 6px 12px; border: none; border-radius: var(--radius-pill); background: transparent;
    color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer;
}
.img-tab:hover { background: var(--brand-soft); }
.img-tab.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.img-page[hidden] { display: none; }
.crop-box { margin: 4px 0 10px; }
.crop-canvas { display: block; width: 100%; height: 240px; border: 1px solid var(--line); border-radius: var(--radius-md); touch-action: none; }
.rotate-row { display: flex; gap: 8px; margin-top: 10px; }
.rbtn {
    flex: 1; height: 40px; border: 1px solid var(--line); border-radius: var(--radius-md);
    background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
}
.rbtn:hover { background: var(--brand-soft); }

/* ---------- Панель объекта / эмодзи ---------- */
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.emoji-row button {
    width: 34px; height: 34px; border: 1px solid var(--line); border-radius: var(--radius-md);
    background: var(--surface-2); font-size: 18px; cursor: pointer; line-height: 1;
}
.emoji-row button:hover { background: var(--brand-soft); }

/* ---------- Пикер фигур из наборов (SVG, аккордеон) ---------- */
.shape-picker { margin: 6px 0 4px; }
.shape-picker .shape-set { border-bottom: 1px solid var(--line); }
.shape-picker .shape-set summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 4px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text);
    /* Заголовок набора скрыт: оставляем элемент (гармошка рабочая),
       но прячем текст и стрелку, чтобы был виден только блок миниатюр. */
    font-size: 0;
}
.shape-picker .shape-set summary::after { content: ""; }
.shape-picker .shape-set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; padding: 2px 2px 8px; }
.shape-picker .shape-set-grid button {
    width: 100%; aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--radius-md);
    background: var(--surface-2); cursor: pointer; padding: 4px;
}
.shape-picker .shape-set-grid button:hover { background: var(--brand-soft); }
.shape-picker .shape-set-grid button img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shape-picker .shape-set-grid button.is-active { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }

.brush-done-row { margin: 8px 0 4px; }
.brush-done { display: block; width: 100%; padding: 8px; border: 1px solid var(--brand); border-radius: var(--radius-md); background: var(--brand); color: var(--text-inverse); font-size: 14px; font-weight: 600; cursor: pointer; }
.brush-done:hover { filter: brightness(1.05); }

/* ---------- Полноэкранный режим работы с изображением (Размер -> Повернуть/Обрезать) ---------- */
.image-work {
    position: fixed; inset: 0; z-index: 60;
    background: var(--surface);
}
.image-work:not([hidden]) { display: flex; flex-direction: column; }
.iw-top {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.iw-close {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--surface-2); color: var(--text); font-size: 18px; cursor: pointer;
    margin-left: auto;
}
.iw-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.iw-step {
    padding: 6px 12px; border: none; border-radius: var(--radius-pill); background: transparent;
    color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.iw-step:hover { background: var(--brand-soft); }
.iw-step.is-active { background: var(--brand); color: var(--text-inverse); }
.iw-stage { flex: 1; min-height: 0; overflow: hidden; position: relative; }
.iw-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.iw-bottom {
    flex: none; padding: 10px 14px; border-top: 1px solid var(--line);
    background: var(--surface); display: flex; flex-direction: column; gap: 8px;
}
.iw-panel[hidden] { display: none; }
.iw-hint { font-size: 12px; color: var(--muted); }
.rot-angle {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 56px; font-size: 14px; font-weight: 700; color: var(--brand);
    background: var(--brand-soft); border-radius: var(--radius-md); padding: 4px 8px;
}

/* ---------- Текстовые секции ---------- */

.acc { border-bottom: 1px solid var(--line); }
.acc summary {
    list-style: none;
    padding: 11px 2px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "›"; transform: rotate(90deg); color: var(--muted); font-size: 14px; transition: transform 0.15s; }
.acc[open] summary::after { transform: rotate(-90deg); }
.acc-body { padding: 2px 2px 12px; display: grid; gap: 8px; }
.text-editor {
    width: 100%;
    line-height: 20px;
    min-height: 60px;   /* 3 строки */
    max-height: 240px;  /* 12 строк */
    resize: none;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 9px 11px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
}
.text-editor:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.ctl-grid { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ctl {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
}
.ctl span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ctl input[type="number"] { width: 52px; border: none; background: none; font-size: 13px; color: var(--text); text-align: center; }
.ctl input[type="number"]:focus { outline: none; }
.ctl select { border: none; background: none; font-size: 13px; color: var(--text); }
.ctl input[type="color"] { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: none; cursor: pointer; }

/* ---------- Вертикальный бегунок размера текста (клик по «Размер») ---------- */
.ctl span[data-slider-key] { cursor: pointer; text-decoration: underline dashed; text-decoration-color: var(--muted); text-underline-offset: 3px; }
.ctl span[data-slider-key].is-active { color: var(--brand); font-weight: 600; text-decoration-color: var(--brand); }
.size-slider {
    position: fixed;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(var(--text-rgb), .3);
    touch-action: none;
}
.size-slider-track {
    position: relative;
    width: 36px;
    height: 180px;
    background: var(--surface-2);
    border-radius: var(--radius-pill);
    cursor: ns-resize;
}
.size-slider-thumb {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 2px 8px rgba(var(--brand-rgb), .5);
}

/* ---------- Пикер шрифта (нижняя панель, как панель настроек: верх на её высоте, низ у края экрана) ---------- */
.font-btn {
    border: none; background: none;
    font-size: 13px; color: var(--text);
    text-align: left; cursor: pointer;
    max-width: 110px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; padding: 0;
}
.font-btn:active { color: var(--brand); }
.font-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 40vh;
    z-index: 42;
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -6px 24px rgba(var(--text-rgb), .1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.2s ease;
}
.font-sheet[hidden] { display: none; }
.font-sheet.is-resizing { transition: none; }
.font-sheet .sheet-handle { height: 22px; flex: none; }
.font-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 14px 8px; border-bottom: 1px solid var(--line); flex: none;
}
.font-head h1 { margin: 0; font-size: 15px; }
.font-close {
    width: 30px; height: 30px; border: none; border-radius: 50%;
    background: var(--brand-soft); color: var(--muted); font-size: 16px; cursor: pointer;
}
.font-list {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 6px 8px 18px;
}
.font-list button {
    display: block; width: 100%; text-align: left;
    border: none; background: none; cursor: pointer;
    font-size: 19.5px; color: var(--text);
    padding: 10px 13px; border-radius: var(--radius-sm); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.font-list button:hover { background: var(--brand-soft); }
.font-list button.is-active { background: var(--brand); color: var(--text-inverse); }
.font-list button.is-active:hover { background: var(--brand); }
.tbtn {
    min-width: 34px; height: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.tbtn:hover { background: var(--brand-soft); }
.tbtn.is-active { background: var(--brand); border-color: var(--brand); color: var(--text-inverse); }
.tbtn-group { display: flex; gap: 4px; }
.tbtn-group .tbtn { border-radius: var(--radius-sm); }

/* Переключатели «Тень / Обводка / Подложка»: кнопка-чекбокс без текста.
   Внутри — кружочек: серый, пока эффект выключен; при включении заливается
   весь фон кнопки (кружочек становится белым). Кнопка стоит первой в строке
   своих настроек (обёртка `.ctl-break` для раскладки «прозрачна»). */
.ctl-break { display: contents; }
.tcheck {
    width: 28px; height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
}
.tcheck::after {
    content: '';
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--line-strong);
}
.tcheck:hover { background: var(--brand-soft); border-color: var(--brand); }
.tcheck.is-active { background: var(--brand); border-color: var(--brand); }
.tcheck.is-active::after { background: var(--surface); }

/* ---------- Прочие страницы панели ---------- */

.page-heading { margin: 2px 0 10px; }
.page-heading strong { display: block; font-size: 14px; }
.page-heading span { font-size: 12px; color: var(--muted); }
.resize-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.resize-grid .ctl { justify-content: space-between; }
.resize-grid .ctl input[type="number"] { width: 70px; }
.resize-lock { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.row-actions { display: flex; gap: 8px; margin-top: 4px; }
.btn { flex: 1; height: 38px; border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer; }
.btn--primary { background: var(--brand); color: var(--text-inverse); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--ghost { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.form-error { margin: 6px 0 0; font-size: 13px; color: var(--danger); }
.empty-note { font-size: 13px; color: var(--muted); }

/* ---------- Скрытый источник ввода текста (НЕ накладывается на картинку) ---------- */

.hidden-input {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 2px;
    height: 2px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    opacity: 0;
}
.hidden-input[hidden] { display: none; }

/* ---------- Меню действий слоя ---------- */

.layer-actions {
    position: fixed;
    z-index: 55;
    display: grid;
    min-width: 140px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.layer-actions[hidden] { display: none; }
.layer-actions button { padding: 10px 14px; border: none; background: none; font-size: 13px; text-align: left; cursor: pointer; }
.layer-actions button:hover { background: var(--brand-soft); }
.layer-actions [data-layer-delete] { color: var(--danger); }

/* ---------- Модальные окна ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--text-rgb), .45);
    padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    box-shadow: var(--shadow-lg);
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { margin: 0 0 12px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.modal-card small { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; }
.modal-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 30px; height: 30px;
    border: none;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
}
.modal-actions { display: grid; gap: 8px; margin: 14px 0 4px; }
.modal-card a.btn, .modal-card .btn { display: flex; align-items: center; justify-content: center; text-decoration: none; width: 100%; margin-top: 2px; }
.btn--danger { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); }
.save-form { display: grid; gap: 10px; }
.save-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.save-form input, .save-form textarea, .save-form select { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 9px 11px; font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface-2); }
.save-form textarea { resize: vertical; min-height: 70px; }
.save-note { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }
/* Заметка гостевого блока «Можете просто скачать» — отступ сверху 10px
   (перебиваем `.modal-card p`, у которого margin-top: 0). */
.modal-card .save-note--guest { margin-top: 10px; }
/* Заголовок окна сохранения: слово видимости — кнопка со стрелкой, открывает список видимости. */
.save-title { display: block; }
/* Слово видимости — цветом обычного текста заголовка (стрелка и пунктир наследуют его). */
.save-vis-btn { border: none; background: none; padding: 0; font: inherit; color: var(--text); text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.save-vis-arrow { font-size: 12px; }
/* Описание в форме: высота растёт по строкам, но не больше 300px (дальше — прокрутка). */
.save-form textarea[data-save-description] { max-height: 300px; overflow-y: auto; resize: none; }
/* Поле «Предложите название рубрики»: появляется под селектом при выборе соответствующего пункта. */
.save-offer { margin-top: -4px; }
.save-offer input { border: 1px solid var(--brand) !important; }
/* Согласие на публикацию от своего имени (docs/legal/registration.md) */
.save-form .save-consent { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.45; }
.save-form .save-consent[hidden] { display: none; }
.save-form .save-consent input { flex: 0 0 auto; margin: 2px 0 0; padding: 0; width: 16px; height: 16px; }
/* Рубрика: свой список вместо <select> (нативный список нельзя ограничить низом экрана). */
.save-form .save-field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.save-form .save-field .is-error { color: var(--danger); }
.save-cat { position: relative; }
.save-cat-btn { width: 100%; box-sizing: border-box; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 9px 11px; font-family: inherit; font-size: 14px; color: var(--text); background: var(--surface-2); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-cat-list { position: fixed; z-index: 80; box-sizing: border-box; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow-y: auto; overscroll-behavior: contain; }
.save-cat-opt { display: block; width: 100%; text-align: left; border: none; background: none; border-radius: var(--radius-sm); padding: 9px 10px; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-cat-opt.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
/* Первый пункт списка рубрик: приглушён только когда это подсказка («Выбрать»);
   в режиме «Не выбирать» (по ссылке / непубличная) выглядит как обычный пункт. */
.save-cat-opt--placeholder.is-hint { color: var(--muted); cursor: default; }
/* «скачать» в нижней заметке — ссылка на скачивание результата. */
.save-download-link { color: var(--brand); text-decoration: underline; cursor: pointer; font-weight: 600; }
/* Переключатель «Разрешить использование шаблонов» — внизу панели видимости, под разделителем. */
.save-vis-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.save-vis-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; box-sizing: border-box; text-align: left; border: none; background: none; border-radius: var(--radius-sm); padding: 9px 10px; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; }
.save-vis-toggle:hover { background: var(--surface-2); }
.save-vis-toggle.is-disabled { color: var(--muted); cursor: default; }
.save-vis-toggle.is-disabled:hover { background: none; }
.save-vis-switch { position: relative; flex: none; width: 40px; height: 22px; border-radius: var(--radius-pill); background: var(--line-strong); transition: background .22s ease; }
.save-vis-switch-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .22s ease; }
.save-vis-toggle.is-on .save-vis-switch { background: var(--brand); }
.save-vis-toggle.is-on .save-vis-switch-thumb { transform: translateX(18px); }
.save-vis-toggle.is-disabled .save-vis-switch { background: #dfe3ea; }
.save-vis-toggle.is-disabled .save-vis-switch-thumb { box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
/* Во время скачивания вместо ссылки — кружок ожидания. */
.btn--busy { opacity: .8; pointer-events: none; }
.btn-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.5); border-top-color: var(--surface); border-radius: 50%; animation: save-wait-spin .7s linear infinite; }
.save-download-wait { display: inline-block; vertical-align: -2px; width: 14px; height: 14px; border: 2px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: save-wait-spin 0.7s linear infinite; }
@keyframes save-wait-spin { to { transform: rotate(360deg); } }

/* ---------- Стартовый экран ---------- */

.start {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 16px;
}
.start[hidden] { display: none; }
.start-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 34px 28px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.start-icon { width: 56px; height: 56px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-lg); background: var(--surface-2); color: var(--brand); font-size: 26px; }
.start-card h1 { margin: 0 0 6px; font-size: 20px; }
.start-card > p { margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.file-btn { display: flex; align-items: center; justify-content: center; height: 46px; border-radius: var(--radius-md); background: var(--brand); color: var(--text-inverse); font-size: 15px; font-weight: 600; cursor: pointer; }
.file-btn:hover { background: var(--brand-hover); }
.file-btn input { display: none; }
.start-hint { margin: 10px 0 14px !important; font-size: 12px !important; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius-md); padding: 20px; font-size: 13px; color: var(--muted); transition: border-color 0.15s, background 0.15s; }
.drop.is-dragging { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.upload-error { margin: 12px 0 0 !important; font-size: 13px !important; color: var(--danger) !important; }
/* Создание картинки без фото: кнопка входа и панель выбора размера/фона */
.blank-open { display: block; width: 100%; height: 46px; margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: transparent; color: var(--brand); font-size: 15px; font-weight: 600; cursor: pointer; }
.blank-open:hover { background: var(--brand-soft); }
.blank-panel { text-align: left; }
.blank-panel[hidden] { display: none; }
.blank-title { margin: 0 0 10px !important; font-size: 13px !important; color: var(--muted) !important; }
.blank-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.blank-size { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border: 1px solid var(--line); border-radius: var(--radius-md); background: transparent; color: var(--text); font-size: 12px; cursor: pointer; }
.blank-size i { display: block; width: 100%; max-width: 42px; aspect-ratio: 1 / 1; border: 1px solid var(--brand); border-radius: var(--radius-sm); background: var(--brand-soft); }
.blank-size[data-blank-size="900x1125"] i { aspect-ratio: 900 / 1125; }
.blank-size[data-blank-size="1125x900"] i { aspect-ratio: 1125 / 900; }
.blank-size small { font-size: 11px; color: var(--muted); }
.blank-size.is-active { border-color: var(--brand); background: var(--brand-soft); }
.blank-panel .file-btn { width: 100%; }
.blank-color { display: flex; align-items: center; gap: 10px; width: 100%; height: 46px; margin-bottom: 14px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: transparent; color: var(--text); font-size: 14px; cursor: pointer; }
.blank-swatch { flex: none; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.blank-cancel { display: block; width: 100%; margin-top: 10px; border: none; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.upload-spinner { margin: 16px auto 0; width: 26px; height: 26px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: upload-spin 0.7s linear infinite; }
@keyframes upload-spin { to { transform: rotate(360deg); } }

/* ---------- Значок загрузки (кружочек) ---------- */

.editor-loader {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
}
.loader-circle {
    width: 34px; height: 34px;
    border: 3px solid var(--brand-soft);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: upload-spin 0.7s linear infinite;
}

/* ---------- Тост ---------- */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 12px);
    z-index: 70;
    background: #242b3d;
    color: var(--text-inverse);
    font-size: 13px;
    padding: 9px 16px;
    border-radius: var(--radius-pill);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Десктоп ---------- */

/* ПК: все листы (параметры слоя, шрифт, фильтры, пикер цвета) стоят слева на всю высоту,
   картинка по-прежнему вписывается целиком и перекрывается панелью. Ширина: 30% экрана,
   но не меньше 300px и не больше 480px; рукоятка тянет ширину по горизонтали. */
@media (min-width: 900px) {
    .sheet,
    .font-sheet,
    .filter-sheet,
    .color-picker {
        left: 0;
        right: auto;
        /* отступ сверху: листы не перекрывают плавающий логотип */
        top: 48px;
        bottom: 0;
        height: auto;
        width: clamp(300px, 30vw, 480px);
        max-height: none;
        border-top: none;
        border-right: 1px solid var(--line);
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
        box-shadow: 6px 0 24px rgba(var(--text-rgb), .12);
        transition: width 0.2s ease;
    }
    /* рукоятка — вертикальная полоса у правого края листа */
    .sheet-handle {
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 22px; height: auto;
        cursor: ew-resize;
        z-index: 2;
    }
    .sheet-handle span { width: 4px; height: 40px; }
    .font-sheet .sheet-handle { width: 22px; height: auto; }
    /* иконки слоя — правее полосы-рукоятки, чтобы не мешать перетаскиванию ширины
       (наезд на верхний край панели берётся из базового правила `.sheet-actions`) */
    .sheet .sheet-actions { right: 30px; }
    /* содержимое листа: одна колонка, без центрирования по ширине */
    .sheet-menu { max-width: none; margin: 0; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
    .sheet-content { max-width: none; margin: 0; }
    /* содержимое не заходит под полосу-рукоятку у правого края листа
       (правила пикера цвета — в отдельном блоке в конце файла, см. ниже) */
    .sheet-content,
    .font-head,
    .font-list,
    .filter-head,
    .filter-grid,
    .filter-strength,
    .filter-sheet .row-actions { padding-right: 34px; }
}

@media (max-width: 899px) {
    .layers-col { top: 58px; }
    .layers-menu { top: 106px; }
    .sheet-menu { flex-wrap: wrap; }
    .menu-btn { padding: 7px 10px; font-size: 12px; }
}
/* ---------- Кнопка цвета (замена <input type=color>) ---------- */
.ctl .color-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    color: var(--text);
    font-size: 12px;
    line-height: 1;
}
.ctl .color-btn:active { background: var(--brand-soft); }
.color-btn .swatch {
    width: 14px; height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(var(--text-rgb), .4);
    flex: none;
}
.color-btn .color-hex { font-variant-numeric: tabular-nums; }

/* ---------- Пикер цвета текста (iro.js, локальная копия): нижний лист ---------- */
.color-picker {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 46vh;
    z-index: 62;
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -6px 24px rgba(var(--text-rgb), .1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.2s ease;
    touch-action: none;
}
.color-picker[hidden] { display: none; }
/* рукоятка пикера — как у остальных листов: на мобиле сверху, на ПК полоса справа */
.color-picker .sheet-handle { height: 22px; flex: none; }
.color-picker .cp-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 14px 8px; border-bottom: 1px solid var(--line); flex: none;
}
.color-picker .cp-head h1 { margin: 0; font-size: 15px; }
/* Переключатель режимов «Цвет | Градиент» и тип градиента */
.color-picker .cp-modes,
.color-picker .cp-kinds { display: flex; gap: 6px; }
.color-picker .cp-mode {
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: none; color: var(--text);
    font-size: 13px; line-height: 1; padding: 7px 10px; cursor: pointer;
}
.color-picker .cp-mode.is-active { background: var(--brand); border-color: var(--brand); color: var(--text-inverse); }
/* Полоса градиента со стопами-маркерами (только в режиме «Градиент») */
.color-picker .cp-grad { flex: none; padding: 8px 14px 0; }
.color-picker .cp-strip {
    position: relative; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--surface); touch-action: none; cursor: pointer;
}
.color-picker .cp-stop {
    position: absolute; top: -5px; width: 16px; height: 40px; margin-left: -8px; padding: 0;
    border: 2px solid var(--surface); border-radius: var(--radius-sm); box-shadow: 0 0 0 1px rgba(var(--text-rgb), .5);
    cursor: grab; touch-action: none;
}
.color-picker .cp-stop.is-active { box-shadow: 0 0 0 2px var(--brand); }
.color-picker .cp-stops-actions { display: flex; gap: 8px; margin-top: 6px; }
.color-picker .cp-stop-btn {
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: none; color: var(--text);
    font-size: 12px; padding: 5px 9px; cursor: pointer;
}
.color-picker .cp-stop-btn:active { background: var(--line); }
/* Низ листа: тип градиента и угол */
.color-picker .cp-grad-foot {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 6px 14px 8px; border-top: 1px solid var(--line);
}
.color-picker .cp-angle-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.color-picker .cp-angle-label input { width: 120px; }
/* В режиме градиента лист растёт по содержимому (высоту диктует контент, не vh) */
.color-picker.is-grad { height: auto; max-height: 88vh; }
/* .cp-body может прокручиваться: если пользователь задал листу высоту рукояткой,
   содержимое не обрезается (при автоматической высоте листа прокрутки нет) */
.color-picker.is-grad .cp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 14px 6px; }
.color-picker.is-grad .cp-recents { padding-bottom: 6px; }
.color-picker.is-grad .cp-grad-foot { display: flex; }
.color-picker:not(.is-grad) .cp-grad,
.color-picker:not(.is-grad) .cp-grad-foot { display: none; }
.color-picker .cp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px 12px; }
/* Сетка: квадрат SV слева, слайдеры справа столбиком. iro рендерит IroBox и IroSlider подряд — разводим колонками.
   display:grid с !important — иначе inline-стиль iro (display:block) перебивает сетку.
   Box вытянут на все 4 строки (рядом с ним столбик слайдеров). */
.color-picker #cp-iro .IroColorPicker {
    display: grid !important;
    grid-template-columns: 170px 1fr;
    grid-template-rows: repeat(4, auto);
    align-items: center;
    column-gap: 18px;
    row-gap: 6px;
}
.color-picker #cp-iro .IroBox { grid-column: 1; grid-row: 1 / span 4; }
/* iro позиционирует дорожку абсолютно внутри .IroSlider, поэтому подпись выносится в строку-обёртку */
.color-picker #cp-iro .cp-slider-row { grid-column: 2; display: flex; flex-direction: column; align-items: center; gap: 0; }
/* iro добавляет слайдеру margin-top:12px — убираем, чтобы подпись была ближе к дорожке (короче высота листа) */
.color-picker #cp-iro .cp-slider-row .IroSlider { margin-top: 0 !important; }
.color-picker .ios-slider-label { font-size: 10px; line-height: 12px; color: var(--muted); }
.color-picker .cp-side { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.color-picker .cp-preview .cp-swatch {
    width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block;
}
.color-picker .cp-hex-label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
.color-picker .cp-hex-label input {
    width: 88px; height: 28px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: none; color: var(--text); font-size: 12px; text-align: center; text-transform: uppercase;
}
.color-picker .cp-done {
    border: none; border-radius: var(--radius-sm); padding: 8px 12px;
    background: var(--brand); color: var(--text-inverse); font-size: 13px; cursor: pointer;
}
.color-picker .cp-done:active { background: var(--brand-hover); }
.color-picker .cp-recents {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; min-height: 22px;
    padding: 0 14px 12px; flex: none;
}
.cp-recent {
    width: 20px; height: 20px; border-radius: 50%;
    border: 1px solid rgba(var(--text-rgb), .4); cursor: pointer; padding: 0;
}
.color-picker .cp-recents:empty::before {
    content: 'Недавние появятся здесь'; font-size: 11px; color: var(--muted);
}

/* ---------- Пипетка: выбор цвета с картинки ---------- */
.color-picker .cp-head-right { display: flex; align-items: center; gap: 8px; }
.color-picker .cp-dropper {
    display: inline-flex; align-items: center; gap: 5px;
    height: 30px; padding: 0 9px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: none; color: var(--text); font-size: 13px; line-height: 1; cursor: pointer;
}
.color-picker .cp-dropper-icon { font-size: 16px; }
.color-picker .cp-dropper:active { background: var(--line); }

/* режим пипетки: убираем пикер и панели, картинка на весь экран */
body.dropper-mode .sheet,
body.dropper-mode .layers-col,
body.dropper-mode .fab,
body.dropper-mode .zoom-bar,
body.dropper-mode .brand,
body.dropper-mode .color-picker { display: none !important; }

/* ...и всегда показываем крестик вместо курсора редактора (перемещение/ресайз),
   который иначе остаётся от прежнего жеста */
body.dropper-mode [data-canvas-viewport] { cursor: crosshair !important; }

/* карточка-образец — у нижнего края */
.cp-dropper-card {
    position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
    z-index: 70; display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: var(--radius-md);
    background: rgba(var(--text-rgb), .94); color: var(--text-inverse);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    touch-action: none;
}
.cp-dropper-card[hidden] { display: none; }
.cp-dropper-card .cp-dropper-swatch {
    width: 34px; height: 34px; border-radius: var(--radius-sm); display: block;
    border: 1px solid rgba(255, 255, 255, 0.3); background: var(--surface);
}
.cp-dropper-card .cp-dropper-hex {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 13px; letter-spacing: 0.5px; min-width: 74px; text-align: center;
}
.cp-dropper-card button {
    width: 34px; height: 34px; border: none; border-radius: var(--radius-sm);
    font-size: 16px; line-height: 1; cursor: pointer;
}
.cp-dropper-card .cp-dropper-ok { background: var(--brand); color: var(--text-inverse); }
.cp-dropper-card .cp-dropper-cancel { background: rgba(255, 255, 255, 0.16); color: var(--text-inverse); }

/* прицел в точке снимка */
.cp-dropper-target {
    position: fixed; width: 36px; height: 36px; margin: -18px 0 0 -18px;
    z-index: 69; pointer-events: none;
}
.cp-dropper-target[hidden] { display: none; }
.cp-dropper-target::before,
.cp-dropper-target::after {
    content: ''; position: absolute; background: var(--surface);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.65);
}
.cp-dropper-target::before { left: 50%; top: 0; width: 1px; height: 100%; }
.cp-dropper-target::after { top: 50%; left: 0; height: 1px; width: 100%; }

/* ---------- Десктоп: пикер цвета ----------
   Базовые правила `.color-picker` (высота), `.color-picker.is-grad` и сетка `#cp-iro .IroColorPicker`
   идут в файле ниже блока «Десктоп» и с той же специфичностью перебивают его, поэтому
   высота и расклад пикера переопределяются здесь. */
@media (min-width: 900px) {
    .color-picker,
    .color-picker.is-grad { height: auto; max-height: none; }
    /* рукоятка-полоса у правого края + место под неё в содержимом */
    .color-picker .sheet-handle { display: flex; }
    .color-picker .cp-head,
    .color-picker .cp-grad,
    .color-picker .cp-body,
    .color-picker .cp-recents,
    .color-picker .cp-grad-foot { padding-right: 34px; }
    /* строки переносятся, ничего не обрезается в узкой колонке */
    .color-picker .cp-head,
    .color-picker .cp-grad-foot { flex-wrap: wrap; row-gap: 6px; }
    .color-picker .cp-angle-label { flex: 1 1 140px; }
    .color-picker .cp-angle-label input { flex: 1; width: auto; min-width: 60px; }
    /* квадрат SV и слайдеры — столбиком: в узкую колонку рядом не влезают */
    .color-picker #cp-iro .IroColorPicker {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        column-gap: 0;
        row-gap: 10px;
    }
    .color-picker #cp-iro .IroBox { grid-row: auto; }
    .color-picker #cp-iro .cp-slider-row { grid-column: 1; }
}
