/* Стили модульных блоков посадочных (js/blocks/*). Префикс mb- — чтобы не пересекаться с landing.css
   и стилями страниц. Стилистика — как в /app (apps/web/ui.css): КОПИЯ по образцу, /app эти стили не грузит.
   Цвета — токены --brand* из landing.css, поэтому этот файл подключается ПОСЛЕ landing.css. */

/* ---------- Кнопки (как #download-btn / #new-btn в /app) ---------- */
.mb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 8px 16px;
    border: none;
    border-radius: 9px;
    background: var(--brand);
    color: var(--brand-on);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.mb-btn:hover { background: var(--brand-hover); }
.mb-btn:active { background: var(--brand-active); }
.mb-btn:disabled { background: var(--brand-disabled); cursor: default; }
.mb-btn svg { flex-shrink: 0; color: var(--brand-lighter); }

.mb-btn--ghost {
    background: transparent;
    color: var(--brand);
    border: .7px solid var(--brand);
}
.mb-btn--ghost:hover { background: var(--brand-tint-soft); }
.mb-btn--ghost:active { background: var(--brand-tint); }
.mb-btn--ghost svg { color: var(--brand); }

/* ---------- Тулбар (как .main-toolbar в /app) ---------- */
.mb-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 100%;
    min-height: 56px;
    padding: 8px 14px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(0,0,0,.15);
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
/* Активный инструмент (как .toolbar-tool-btn.active) */
.mb-toolbar__tool {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--brand-tint);
    color: var(--brand);
    font-size: 14px;
    font-weight: 600;
}
.mb-toolbar__divider { width: 1px; height: 24px; background: #e0e0e0; flex-shrink: 0; }
.mb-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #4a4a4a;
    cursor: pointer;
    touch-action: none; /* удержание на телефоне не должно превращаться в скролл/выделение */
    -webkit-user-select: none;
    user-select: none;
    transition: color .15s ease, background-color .15s ease;
}
.mb-icon-btn:hover { background: #f2f2f2; }
.mb-icon-btn.is-pressed,
.mb-icon-btn:active { color: var(--brand); background: var(--brand-tint); }

/* ---------- Боковая панель (как .controls / .section-label в /app) ---------- */
.mb-panel {
    flex: 0 0 300px;
    width: 300px;
    max-width: 100%;
    padding: 15px 14px;
    border-radius: 10px;
    border: 1px solid #e3e3e3;
    background: #fff;
}
.mb-panel__label {
    font-size: 14px;
    font-weight: 500;
    color: #9ca3af;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin: 0 0 16px;
}
.mb-panel__section + .mb-panel__label { margin-top: 22px; }
.mb-panel__hint { font-size: 12px; line-height: 1.4; color: #9ca3af; margin-top: 8px; }

/* ---------- block: preview (как .ba-container в /app) ---------- */
.mb-preview {
    --checkerboard: repeating-conic-gradient(#e0e0e0 0% 25%, #ffffff 0% 50%);
    position: relative;
    flex: 0 0 auto;
    width: min(80vw, 1000px);
    aspect-ratio: var(--ar, 1);
    overflow: hidden;
    box-shadow: 0 0 12px rgba(0,0,0,.5);
    background-image: var(--checkerboard);
    background-size: 20px 20px;
}
.mb-preview[data-bg="white"] { background-image: none; background-color: #fff; }
.mb-preview[data-bg="dark"]  { background-image: none; background-color: #1f1f24; }
.mb-preview__img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mb-preview__badge {
    position: absolute;
    left: 10px;
    bottom: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.1);
    background: rgba(255,255,255,.85);
    color: #4a4a4a;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.mb-preview__compare {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}
.mb-preview.is-comparing .mb-preview__compare { display: block; }
/* Режим source: 'canvas' (remove-color): канвас в размер блока, курсор по state.cursor */
.mb-preview__canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.mb-preview[data-cursor="area"] .mb-preview__canvas { cursor: crosshair; }
/* Курсор-пипетка (иконка pipette из Lucide, ISC): белая обводка под чёрной, хотспот — кончик */
.mb-preview[data-cursor="pick"] .mb-preview__canvas {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='white' stroke-width='4'%3E%3Cpath d='m2 22 1-1h3l9-9'/%3E%3Cpath d='M3 21v-3l9-9'/%3E%3Cpath d='m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z'/%3E%3C/g%3E%3Cg stroke='black' stroke-width='1.7'%3E%3Cpath d='m2 22 1-1h3l9-9'/%3E%3Cpath d='M3 21v-3l9-9'/%3E%3Cpath d='m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z'/%3E%3C/g%3E%3C/svg%3E") 2 22, crosshair;
}
.mb-preview__compare { pointer-events: none; }

/* Выключенные иконки-кнопки (Undo/Redo без истории) */
.mb-icon-btn:disabled,
.mb-icon-btn:disabled:hover,
.mb-icon-btn:disabled:active { color: #c8c8c8; background: transparent; cursor: default; }

/* Системная подсветка тапа на мобильных красит плитку цвета и кнопки — путает с выбранным цветом */
.mb-color, .mb-eyedropper, .mb-segmented__btn, .mb-cp { -webkit-tap-highlight-color: transparent; }

/* ---------- block: history ---------- */
.mb-history { display: inline-flex; gap: 4px; }

/* ---------- block: color-picker — плитка цвета ---------- */
.mb-color {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    padding: 0;
    overflow: hidden;
    border: 1.5px solid #e3e3e3;
    border-radius: 10px;
    background: repeating-conic-gradient(#e0e0e0 0% 25%, #fff 0% 50%) 0 0 / 12px 12px;
    font: inherit;
    cursor: pointer;
    transition: border-color .15s;
}
.mb-color:hover,
.mb-color[aria-expanded="true"] { border-color: var(--brand); }
.mb-color__fill {
    position: absolute;
    inset: 0;
    background: var(--c, transparent);
    /* Тонкая внутренняя обводка: белый на белом иначе не отличить от пустого места */
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.mb-color.is-empty .mb-color__fill {
    background: #fff linear-gradient(to top right, transparent calc(50% - 1px), #e17055 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
}
.mb-color__text {
    position: relative;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.08);
    background: rgba(255,255,255,.9);
    color: #333;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------- block: color-picker — поп-ап палитры (КОПИЯ .cp-* из apps/web/ui.css) ---------- */
.mb-cp {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    display: none;
    width: 328px;
    max-width: calc(100vw - 16px);
    padding: 20px;
    box-sizing: border-box;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.08);
    --cp-hue: 0;
}
.mb-cp.is-open { display: block; }
.mb-cp__sv {
    position: relative;
    height: 170px;
    border-radius: 10px;
    background-color: hsl(var(--cp-hue) 100% 50%);
    background-image: linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, rgba(255,255,255,0));
    cursor: crosshair;
    touch-action: none;
}
.mb-cp__hue {
    position: relative;
    height: 14px;
    margin: 16px 0;
    border-radius: 999px;
    background: linear-gradient(to right, #f00 0%, #ff0 16.67%, #0f0 33.33%, #0ff 50%, #00f 66.67%, #f0f 83.33%, #f00 100%);
    cursor: pointer;
    touch-action: none;
}
.mb-cp__sv-thumb,
.mb-cp__hue-thumb {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 1px 4px rgba(0,0,0,.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-sizing: border-box;
}
.mb-cp__hue-thumb { top: 50%; background: hsl(var(--cp-hue) 100% 50%); }
.mb-cp__inputs { display: flex; gap: 8px; }
.mb-cp__format,
.mb-cp__value {
    height: 40px;
    box-sizing: border-box;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    color: #222;
    outline: none;
}
.mb-cp__format { flex: 0 0 84px; padding: 0 8px; cursor: pointer; }
.mb-cp__value { flex: 1 1 auto; min-width: 0; padding: 0 12px; }
.mb-cp__format:focus,
.mb-cp__value:focus { border-color: var(--brand); }

/* ---------- block: eyedropper (рамка как .brush-mode-btn) ---------- */
.mb-eyedropper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1.5px solid #e3e3e3;
    border-radius: 10px;
    background: #fff;
    color: #4a4a4a;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.mb-eyedropper:hover { background: #fafafa; }
.mb-eyedropper.is-active { border-color: var(--brand); color: var(--brand); background: var(--brand-tint-soft); }

/* ---------- block: segmented (как .brush-mode-btn в /app) ---------- */
.mb-segmented { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 8px; }
.mb-segmented__btn {
    padding: 9px 0;
    border: 1.5px solid #e3e3e3;
    border-radius: 10px;
    background: #fff;
    color: #4a4a4a;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.mb-segmented__btn:hover { background: #fafafa; }
.mb-segmented__btn.is-active { border-color: var(--brand); color: var(--brand); background: var(--brand-tint-soft); }

/* ---------- block: preview-bg (как .bg-swatch в /app) ---------- */
.mb-preview-bg {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 4px; /* место под outline активной плитки */
}
.mb-preview-bg__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: none;
    background: none;
    color: #4a4a4a;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.mb-preview-bg__item i {
    display: block;
    width: 100%;
    aspect-ratio: 1.6;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,.08);
    transition: transform .12s ease;
}
.mb-preview-bg__item:hover i { transform: scale(1.04); }
.mb-preview-bg__item.is-active i { outline: 2px solid var(--brand); outline-offset: 2px; }
.mb-preview-bg__item--checker i { background: repeating-conic-gradient(#e0e0e0 0% 25%, #fff 0% 50%) 0 0 / 12px 12px; }
.mb-preview-bg__item--white i { background: #fff; }
.mb-preview-bg__item--dark i { background: #1f1f24; }

/* ---------- block: opacity-control (как .fx-slider / .brush-size-slider / .brush-mode-btn в /app) ---------- */
.mb-opacity__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
    color: #4a4a4a;
}
.mb-opacity__num {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fff;
}
.mb-opacity__num:focus-within { border-color: var(--brand); }
.mb-opacity__num input {
    width: 38px;
    border: none;
    outline: none;
    background: transparent;
    text-align: right;
    font: inherit;
    font-size: 14px;
    color: #222;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}
.mb-opacity__num input::-webkit-outer-spin-button,
.mb-opacity__num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mb-opacity__num span { font-size: 14px; color: #9ca3af; }
.mb-opacity__range {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(to right, var(--brand) 0 var(--fill, 50%), #e5e5e5 var(--fill, 50%) 100%);
}
.mb-opacity__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: var(--brand);
    cursor: pointer;
}
.mb-opacity__range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: var(--brand);
    cursor: pointer;
}
.mb-opacity__range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .3); }
.mb-opacity__range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .3); }
.mb-opacity__ends {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: #9ca3af;
}
.mb-opacity__presets {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}
.mb-opacity__preset {
    padding: 8px 0;
    border: 1.5px solid #e3e3e3;
    border-radius: 10px;
    background: #fff;
    color: #4a4a4a;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.mb-opacity__preset:hover { background: #fafafa; }
.mb-opacity__preset.is-active { border-color: var(--brand); color: var(--brand); background: var(--brand-tint-soft); }

/* ---------- block: uploader — оверлей D&D (как .drop-overlay в /app) ---------- */
.mb-drop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: rgba(var(--brand-rgb), .88);
}
.mb-drop.is-shown { display: flex; }
.mb-drop p {
    padding: 0 20px;
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    text-align: center;
}

/* ---------- notify: сообщение об ошибке (иконка как .error-icon в /app) ---------- */
.mb-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1500;
    display: none;
    max-width: min(360px, calc(100vw - 40px));
    padding: 14px 18px 14px 50px;
    border-radius: 12px;
    background: #fff;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.mb-toast::before {
    content: "!";
    position: absolute;
    left: 14px;
    top: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffc341;
    color: #fff;
    font-weight: 700;
    line-height: 24px;
    text-align: center;
}
.mb-toast.is-shown { display: block; }
