html, body { height: 100%; overscroll-behavior: none; color-scheme: dark; }
body {
  background: #0a0a0c;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* Меню-бар */
#menuBar {
  height: 52px;
  background-color: rgba(28,28,30,0.78);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 0.5px solid rgba(255,255,255,0.14);
}
.topbar-icon-btn {
  width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.7); transition: background-color 0.12s ease, color 0.12s ease;
}
.topbar-icon-btn:hover { background-color: rgba(255,255,255,0.08); color: #fff; }
/* Активна — сплошная синяя заливка + белая иконка (не тёмно-синий текст на тёмном фоне, как было). */
.topbar-icon-btn.is-active { background-color: #0071e3; color: #fff; }
.menu-item {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease;
}
.menu-item:hover, .menu-item.is-open { background-color: rgba(255,255,255,0.08); }

.menu-dropdown {
  position: absolute;
  top: 52px;
  min-width: 260px;
  background-color: rgba(28,28,30,0.92);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  padding: 6px;
  z-index: 200;
}
.menu-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  white-space: nowrap;
}
.menu-dropdown-item:hover { background-color: rgba(255,255,255,0.09); }
.menu-dropdown-sep { height: 1px; background: rgba(255,255,255,0.1); margin: 6px 4px; }
.menu-dropdown-hint { font-size: 11px; color: rgba(255,255,255,0.4); padding: 4px 12px 2px; }

/* Settings rail (левая панель одиночного режима) */
.rail-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: rgba(255,255,255,0.4); margin-bottom: 6px; }
.rail-select, .rail-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 0.5px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: #fff;
  outline: none;
}
.rail-select:focus, .rail-input:focus { border-color: #0071e3; }
.rail-select option { background: #1c1c1e; color: #fff; }
select.rail-select { color-scheme: dark; }
.rail-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rail-section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.rail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; flex-shrink: 0; }
.toggle-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-switch .track { position: absolute; inset: 0; background: rgba(255,255,255,0.2); border-radius: 999px; transition: background-color 0.15s ease; }
.toggle-switch .thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform 0.15s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.toggle-switch input:checked + .track { background: #0071e3; }
.toggle-switch input:checked + .track + .thumb { transform: translateX(16px); }

/* Слайдеры — как в мобильном кроппере */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 24px; background-color: transparent; background-repeat: no-repeat; background-position: center;
  background-size: 100% 6px; border-radius: 3px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%; background: #ffffff; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45), 0 0 0 0.5px rgba(0,0,0,0.1);
}

/* Перспективные точки/линии — идентично мобильному кропперу */
.perspective-handle {
  width: 18px; height: 18px; background-color: #0071e3; border: 2px solid #fff; border-radius: 50%;
  position: absolute; transform: translate(-50%, -50%); z-index: 50; box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}
.perspective-handle--side { width: 14px; height: 14px; background-color: #fff; border: 2px solid #0071e3; z-index: 45; }
.perspective-handle--center { width: 22px; height: 22px; border-radius: 6px; background-color: #0071e3; border: 2px solid #fff; z-index: 45; }
.perspective-handle--scale { width: 14px; height: 14px; border-radius: 50%; background-color: #0071e3; border: 2px solid #fff; opacity: 0.55; z-index: 46; }
.perspective-handle--scale:hover, .perspective-handle--scale:active { opacity: 0.9; }
.perspective-line {
  position: absolute; height: 1.25px; background-color: rgba(0,113,227,0.9); transform-origin: 0 50%;
  z-index: 40; pointer-events: none; filter: drop-shadow(0 0 0.5px rgba(0,0,0,0.65));
}

.checkerboard-bg {
  background-image: linear-gradient(45deg, #1f1f23 25%, transparent 25%), linear-gradient(-45deg, #1f1f23 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #1f1f23 75%), linear-gradient(-45deg, transparent 75%, #1f1f23 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0px; background-color: #0f0f11;
}

#magnifier {
  position: absolute; width: 120px; height: 120px; border: 3px solid #fff; border-radius: 50%;
  pointer-events: none; display: none; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  overflow: hidden; background-color: #161617; transform: translate(-50%, -50%);
}
#magnifierCanvas { width: 100%; height: 100%; position: absolute; top: 0; left: 0; }

.pan-zoom-container { will-change: transform; }

/* Панели настроек/ретуши — общая система: боковые панели-оверлеи на десктопе, донные шторки-модалки
   на мобильном (медиа-запрос ниже). Настройки — слева, ретушь — справа, обе поверх канваса. */
.side-panel {
  position: absolute; top: 0; bottom: 0; width: 300px;
  background-color: rgba(38,38,41,0.92); /* тёмно-серый apple-like материал, НЕ чёрный */
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  z-index: 76;
  display: flex; flex-direction: column;
  transition: transform 0.28s cubic-bezier(0.22,1,0.36,1);
}
.side-panel--left { left: 0; transform: translateX(-100%); border-right: 0.5px solid rgba(255,255,255,0.14); box-shadow: 12px 0 40px rgba(0,0,0,0.35); }
.side-panel--left.is-open { transform: translateX(0); }
.side-panel--right { right: 0; width: 340px; transform: translateX(100%); border-left: 0.5px solid rgba(255,255,255,0.14); box-shadow: -12px 0 40px rgba(0,0,0,0.45); }
.side-panel--right.is-open { transform: translateX(0); }

.side-panel-header { flex-shrink: 0; padding: 20px 20px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.08); }
.side-panel-title { font-size: 17px; font-weight: 600; }
.side-panel-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }
.side-panel-body::-webkit-scrollbar { display: none; }

.panel-close-mobile { display: none; }

/* Ручка-индикатор свайпа вниз — видна только на мобильном (шторка-модалка), на десктопе панель
   не тянется жестом, там просто кнопка закрытия. */
.panel-grabber { display: none; width: 100%; justify-content: center; padding: 10px 0 2px; flex-shrink: 0; touch-action: none; cursor: grab; }
.panel-grabber span { width: 36px; height: 4px; border-radius: 999px; background: rgba(255,255,255,0.35); }

/* Пока конкретный ползунок зажат (только на мобильном) — прячем все остальные строки/шапку панели
   ретуши, оставляя видимым только тот, который сейчас двигают, чтобы видеть результат на фото
   позади шторки. Перенесено из мини-кроппера (static/card-cropper) — там уже было и хорошо работало.
   В мини-версии сама шторка при этом становится ПРОЗРАЧНОЙ (фон/блюр/тень убираются целиком) —
   этого не хватало здесь: строки прятались, но материал панели оставался виден и закрывал фото. */
#retouchPanel.is-dragging {
  background-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}
#retouchPanel.is-dragging .side-panel-header,
#retouchPanel.is-dragging .panel-grabber,
#retouchPanel.is-dragging .retouch-group,
#retouchPanel.is-dragging .retouch-row {
  visibility: hidden;
}
#retouchPanel.is-dragging .retouch-row.is-active {
  visibility: visible;
  background: rgba(20,20,22,0.7);
  border-radius: 16px;
  padding: 12px 14px;
  margin: -12px -14px;
}

/* Затемняет фон за модалкой настроек/ретуши только на мобильном (см. медиа-запрос) — тап по нему
   закрывает открытую панель. На десктопе панели — не модальные оверлеи, поэтому здесь ВСЕГДА
   pointer-events:none (даже когда is-open) — иначе прозрачный бэкдроп перехватывал бы клики по
   канвасу/ручкам на весь экран, хотя визуально ничего не меняется. */
.panel-backdrop { position: fixed; inset: 0; z-index: 74; background: transparent; pointer-events: none; opacity: 0; transition: opacity 0.25s ease; }
/* Пока зажат ползунок ретуши (мобильный, is-dragging проставляется в setupRetouchFade) — гасим
   и сам общий затемнитель фона, не только материал панели, иначе фото всё ещё прикрыто rgba(0,0,0,0.5). */
.panel-backdrop.is-dragging { opacity: 0 !important; }

.retouch-group { background: rgba(255,255,255,0.07); border-radius: 22px; padding: 20px; transition: opacity 0.2s ease; }

/* На вкладке "Коррекция" живой предпросмотр (см. #singleEditPreviewCanvas / renderEditLivePreview()
   в single-image.js) показывает ТОЛЬКО Коррекцию и Уровни — Размытие/Резкость на исходнике в
   масштабе экрана считать слишком дорого и не совсем то же самое, что итоговый рендер, поэтому эти
   две группы там сознательно приглушены: понятно, что ползунки работают (сохраняются, применятся
   при экспорте), но результат нужно смотреть на вкладке "Предпросмотр". */
body.single-edit-tab-active #retouchPanel .retouch-group--no-edit-preview { opacity: 0.4; }

.quick-action-btn { width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,0.5); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; color: #fff; }

.toggle-pill { background: rgba(255,255,255,0.1); backdrop-filter: blur(8px); padding: 4px; border-radius: 999px; display: flex; font-size: 12px; font-weight: 500; }
.toggle-pill button { padding: 6px 16px; border-radius: 999px; color: rgba(255,255,255,0.5); transition: all 0.15s ease; }
.toggle-pill button.active { background: #2d2d2f; color: #fff; }

/* Пока открыта панель настроек и/или ретуши (на десктопе), --ui-shift-x — суммарный сдвиг вправо
   минус влево (см. single-image.js) — сдвигаем плавающий интерфейс канваса, чтобы панели его не
   перекрывали. Вид фото уже панорамируется на ту же величину — это чисто про сам интерфейс. */
#singleTopToggleWrap, #singleQuickActions, #singleZoomToolbarEdit, #singleZoomToolbarPreview {
  transition: transform 0.28s ease;
  transform: translateX(-50%) translateX(var(--ui-shift-x, 0px));
}

/* Список файлов батча — тёмно-серая рабочая область (НЕ фон body #0a0a0c, который читается как
   чёрный на глаз), тот же apple-like тон, что у панелей. Сдвигается вправо (а не перекрывается),
   когда справа открыта панель настроек батча — см. .is-panel-open ниже и applyBatchPanelState(). */
#batchMainContent {
  background-color: #17171a;
  transition: right 0.28s cubic-bezier(0.22,1,0.36,1);
}
@media (min-width: 768px) {
  #batchMainContent.is-panel-open { right: 340px; }
}

@media (max-width: 767px) {
  /* На телефоне панели настроек/ретуши — донные шторки-модалки, а не боковые полосы: экран
     слишком узкий, чтобы делить его с постоянно видимой панелью. */
  .side-panel {
    left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; max-height: 78vh;
    border-radius: 24px; border: 0.5px solid rgba(255,255,255,0.14);
    box-shadow: 0 20px 60px rgba(0,0,0,0.55);
    transform: translateY(120%);
  }
  .side-panel.is-open { transform: translateY(0); }
  .panel-close-mobile { display: flex; }
  .panel-grabber { display: flex; }
  .panel-backdrop.is-open { opacity: 1; background: rgba(0,0,0,0.5); pointer-events: auto; }
}

.zoom-toolbar { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.1); backdrop-filter: blur(8px); padding: 6px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.1); }
.zoom-toolbar button { width: 28px; height: 28px; border-radius: 999px; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.8); }
.zoom-toolbar button:hover { background: rgba(255,255,255,0.1); }

.orient-btn { flex: 1; padding: 6px 0; border-radius: 8px; font-size: 12.5px; font-weight: 500; color: rgba(255,255,255,0.5); text-align: center; }
.orient-btn.active { background: #2d2d2f; color: #fff; }

.corner-tab { padding: 8px 0; border-radius: 8px; font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.5); text-align: center; background: rgba(255,255,255,0.05); }
.corner-tab.active { background: #0071e3; color: #fff; }

.batch-thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; background: rgba(255,255,255,0.06); flex-shrink: 0; }

/* Батч: список прогресса */
.batch-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; font-size: 12.5px; cursor: pointer; }
.batch-row:hover { background: rgba(255,255,255,0.05); }
.batch-row.is-preview-active { background: rgba(0,113,227,0.16); box-shadow: inset 0 0 0 1px rgba(0,113,227,0.5); }
.batch-row.status-pending { color: rgba(255,255,255,0.4); }
.batch-row.status-processing { color: #fff; background: rgba(0,113,227,0.12); }
.batch-row.status-done { color: rgba(255,255,255,0.75); }
.batch-row.status-error { color: #ff6b6b; background: rgba(255,59,48,0.08); }
.batch-row.status-skipped { color: rgba(255,255,255,0.3); }

.batch-row .batch-row-path { font-size: 11px; color: rgba(255,255,255,0.3); }

.progress-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
.progress-fill { height: 100%; background: #0071e3; transition: width 0.15s ease; }

/* Пояснение про доступ к файловой системе: нейтральное по умолчанию, янтарное — когда браузер
   что-то не даёт и включился запасной путь. Красного нет намеренно — это не ошибка, а режим. */
.access-note {
  display: flex; align-items: flex-start; gap: 7px;
  margin-top: 10px; padding: 9px 11px; border-radius: 10px;
  font-size: 11.5px; line-height: 1.45;
  background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.07);
}
.access-note--warn { background: rgba(255,159,10,0.1); border-color: rgba(255,159,10,0.22); color: rgba(255,214,150,0.9); }
.access-note--ok { background: rgba(48,209,88,0.09); border-color: rgba(48,209,88,0.2); color: rgba(178,236,190,0.9); }
.access-note i { flex-shrink: 0; margin-top: 1px; }

.batch-drop-hint { flex-shrink: 0; padding: 0 0 18px; text-align: center; font-size: 12px; color: rgba(255,255,255,0.25); }

/* Сводка ретуши пресета. Пустая — схлопывается, чтобы не оставлять дыру у нейтральных пресетов. */
.preset-summary { margin-top: 7px; font-size: 11.5px; line-height: 1.4; color: rgba(255,255,255,0.42); }
.preset-summary:empty { display: none; }
.preset-summary--neutral { color: rgba(255,255,255,0.28); }
/* nowrap: без него «Сохранить как новый» переносится на две строки и кнопки становятся разной высоты */
.preset-action-btn { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
.preset-card__filters { font-size: 11px; color: rgba(0,113,227,0.85); margin-top: 2px; }

/* Оверлей перетаскивания: перекрывает весь батч-воркспейс, включая панель настроек, — бросать
   можно куда угодно, не целясь в список. */
.drop-zone {
  position: absolute; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,8,10,0.84); backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.drop-zone.is-active { opacity: 1; }
.drop-zone__inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 40px 56px; border-radius: 24px;
  border: 2px dashed rgba(0,113,227,0.9); background: rgba(0,113,227,0.14);
  font-size: 15px; font-weight: 500; color: #fff;
}
.drop-zone__inner i, .drop-zone__inner svg { color: #0071e3; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px);
  padding: 12px 20px; background: rgba(255,255,255,0.95); color: #000; border-radius: 999px;
  font-size: 14px; font-weight: 500; box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  z-index: 300; opacity: 0; pointer-events: none; transition: all 0.25s ease;
  display: flex; align-items: center; gap: 8px;
}
#toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Модалка пресетов */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 400; display: flex; align-items: center; justify-content: center; }
.modal-panel {
  width: 560px; max-width: 92vw; max-height: 82vh; display: flex; flex-direction: column;
  background-color: rgba(28,28,30,0.96);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid rgba(255,255,255,0.14);
  border-radius: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); overflow: hidden;
}
.modal-tabs { display: flex; gap: 4px; padding: 14px 18px 0; }
.modal-tab { padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: rgba(255,255,255,0.5); }
.modal-tab.active { background: rgba(255,255,255,0.1); color: #fff; }
.preset-card { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }
.preset-card + .preset-card { margin-top: 8px; }

.json-textarea {
  width: 100%; min-height: 260px; background: rgba(0,0,0,0.35); border: 0.5px solid rgba(255,255,255,0.14);
  border-radius: 14px; padding: 14px; color: #d7e6ff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.5; resize: vertical;
}

.btn { padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; transition: all 0.12s ease; }
.btn-primary { background: #0071e3; color: #fff; }
.btn-primary:hover { background: #0077ed; }
.btn-ghost { background: rgba(255,255,255,0.08); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.14); }
.btn-danger { background: rgba(255,59,48,0.15); color: #ff6b6b; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
