/* =========================================================
   ОБРЕЗКА ИЗОБРАЖЕНИЙ — стили рабочей области.
   Использует переменные дизайн-системы сайта (--color-*, --radius-*,
   --font-*, --transition-fast из style.css) — здесь только то, что
   нужно самому инструменту.

   КАК УСТРОЕН ИНСТРУМЕНТ
   Одна карточка (.ic-shell) с двумя состояниями, выбираемыми атрибутом
   hidden у .ic-drop и .ic-work:
     — пустое: видоискатель с угловыми метками (.ic-drop);
     — рабочее: тёмная сцена слева, белая панель параметров справа
       (.ic-work). Верхние границы обеих колонок лежат на одной линии:
       панель начинается строкой в те же 48px, что и верхняя планка сцены.
   Сетка: 4-пиксельный шаг. Отступы 12/16, высота кнопок 30/34/36/46,
   радиусы — 8 у полей и кнопок, 10 у плиток, 20 у карточки (как у
   остальных инструментов сайта).
   Цвет: графит сцены #2B2F33 и белая панель; зелёный — только для
   действия (главная кнопка, фокус, ползунок, рамка в момент движения).
   ========================================================= */

:root {
  --ic-border: rgba(43, 47, 51, 0.09);
  --ic-danger: #c94747;
  --ic-danger-bg: rgba(201, 71, 71, 0.07);
  --ic-mono: var(--font-mono);
  --ic-stage-bg: #17181a;
}

[class^="ri-"]:not(:is(.sidebar, .mobile-header, .mobile-nav-panel, .notice-slider, .breadcrumbs, .tool-faq, .site-footer) *),
[class*=" ri-"]:not(:is(.sidebar, .mobile-header, .mobile-nav-panel, .notice-slider, .breadcrumbs, .tool-faq, .site-footer) *) { line-height: 1; }

.ic-tool {
  --ic-stage: #2B2F33;
  --ic-deep: #23272B;
  --ic-on: rgba(255, 255, 255, 0.9);
  --ic-on-2: rgba(255, 255, 255, 0.64);
  --ic-on-3: rgba(255, 255, 255, 0.56);
  --ic-hair-on: rgba(255, 255, 255, 0.09);
  --ic-line: rgba(43, 47, 51, 0.1);
  --ic-field: #F3F5F7;
  --ic-field-hover: #EAEDF0;
  --ic-label: #5D757B;
  --ic-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  container-type: inline-size;
  container-name: ictool;
  margin-bottom: 8px;
}
.ic-tool [hidden] { display: none !important; }

.ic-shell {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--ic-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* =========================================================
   КНОПКИ
   ========================================================= */

.ic-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px;
  border: none; border-radius: var(--radius-sm);
  font: 600 14px/1 var(--font-body); cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}
.ic-btn i { font-size: 18px; }
.ic-btn--primary { background: var(--color-accent); color: #06231a; }
.ic-btn--primary:hover:not(:disabled) { background: var(--color-accent-dark); }
.ic-btn:active:not(:disabled) { transform: scale(0.985); }
.ic-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ic-btn--block { width: 100%; height: 46px; }

/* =========================================================
   ПУСТОЕ СОСТОЯНИЕ — ВИДОИСКАТЕЛЬ
   Плоский графит, три направляющие в каждую сторону еле заметной
   линией и четыре угловые метки — те же, что потом станут рамкой
   обрезки. При наведении метки светлеют и чуть сдвигаются внутрь,
   при перетаскивании файла — зеленеют и «схватывают» область.
   ========================================================= */

.ic-drop {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: clamp(400px, 56vh, 520px);
  padding: 64px 24px;
  background: var(--ic-stage);
  color: var(--ic-on);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
}
.ic-drop::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--ic-hair-on) 1px, transparent 1px),
    linear-gradient(to bottom, var(--ic-hair-on) 1px, transparent 1px);
  background-size: 33.3333% 100%, 100% 33.3333%;
  background-position: 0 0, 0 0;
  opacity: 0.6;
  transition: opacity 0.3s var(--ic-ease);
}
.ic-drop:hover::before, .ic-drop.is-dragover::before { opacity: 1; }
.ic-drop::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 340px 250px at 50% 50%, var(--ic-stage) 55%, rgba(43, 47, 51, 0) 100%);
}

.ic-drop-mark {
  position: absolute; width: 32px; height: 32px;
  border: 0 solid rgba(255, 255, 255, 0.3);
  transition: transform 0.35s var(--ic-ease), border-color 0.25s ease;
  pointer-events: none;
}
.ic-drop-mark--tl { top: 28px; left: 28px; border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 8px; }
.ic-drop-mark--tr { top: 28px; right: 28px; border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 8px; }
.ic-drop-mark--bl { bottom: 28px; left: 28px; border-bottom-width: 2px; border-left-width: 2px; border-bottom-left-radius: 8px; }
.ic-drop-mark--br { bottom: 28px; right: 28px; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 8px; }
.ic-drop:hover .ic-drop-mark { border-color: rgba(255, 255, 255, 0.62); }
.ic-drop:hover .ic-drop-mark--tl { transform: translate(-4px, -4px); }
.ic-drop:hover .ic-drop-mark--tr { transform: translate(4px, -4px); }
.ic-drop:hover .ic-drop-mark--bl { transform: translate(-4px, 4px); }
.ic-drop:hover .ic-drop-mark--br { transform: translate(4px, 4px); }
.ic-drop.is-dragover .ic-drop-mark { border-color: var(--color-accent); }
.ic-drop.is-dragover .ic-drop-mark--tl { transform: translate(18px, 18px); }
.ic-drop.is-dragover .ic-drop-mark--tr { transform: translate(-18px, 18px); }
.ic-drop.is-dragover .ic-drop-mark--bl { transform: translate(18px, -18px); }
.ic-drop.is-dragover .ic-drop-mark--br { transform: translate(-18px, -18px); }

.ic-drop-body { width: 100%; max-width: 440px; }
.ic-drop-tile {
  display: grid; place-items: center;
  width: 56px; height: 56px; margin: 0 auto 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
  color: var(--color-accent); font-size: 24px;
  transition: transform 0.3s var(--ic-ease);
}
.ic-drop:hover .ic-drop-tile { transform: translateY(-2px); }
.ic-drop-title {
  margin: 0 0 8px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 26px; line-height: 1.15; letter-spacing: -0.01em;
  color: #fff;
}
.ic-drop-sub { margin: 0 0 24px; font-size: 14.5px; line-height: 1.5; color: var(--ic-on-2); }
.ic-drop-sub kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; margin: 0 2px; padding: 0 5px;
  border-radius: 5px; background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.12);
  font: 500 11.5px/1 var(--ic-mono); color: var(--ic-on);
  vertical-align: 1px;
}
.ic-drop-hint { margin: 20px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ic-on-3); }
/* Ошибка лежит у нижнего края области и не сдвигает то, что по центру */
.ic-drop-error {
  position: absolute; left: 50%; bottom: 28px; z-index: 2; transform: translateX(-50%);
  width: min(440px, calc(100% - 48px)); margin: 0; padding: 11px 14px;
  background: #392d30; border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px rgba(255, 138, 138, 0.4);
  color: #ffd2d2; font-size: 13px; line-height: 1.5; text-align: left; cursor: default;
}
.ic-drop-error a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.ic-drop.is-busy { cursor: progress; }
.ic-drop.is-busy .ic-btn { pointer-events: none; opacity: 0.6; }

/* =========================================================
   РАБОЧЕЕ СОСТОЯНИЕ — СЕТКА
   ========================================================= */

.ic-work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 332px;
  height: clamp(560px, calc(100vh - 150px), 780px);
}
.ic-stage-col {
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0; min-height: 0;
  background: var(--ic-stage); color: var(--ic-on-2);
}

/* ---------- Планки сцены ---------- */
.ic-bar {
  display: flex; align-items: center; gap: 4px;
  min-height: 48px; padding: 0 12px 0 16px;
  background: var(--ic-stage);
}
.ic-bar--top { border-bottom: 1px solid var(--ic-hair-on); }
.ic-bar--bottom { border-top: 1px solid var(--ic-hair-on); padding: 6px 12px; gap: 8px; }
.ic-bar-sep { flex: none; width: 1px; height: 20px; margin: 0 6px; background: var(--ic-hair-on); }

.ic-file { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.ic-file-thumb { flex: none; width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: var(--ic-deep); box-shadow: 0 0 0 1px var(--ic-hair-on); }
.ic-file-text { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.ic-file-text strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13px/1.2 var(--font-body); color: var(--ic-on); }
.ic-file-text span { flex: none; font: 500 11.5px/1.2 var(--ic-mono); color: var(--ic-on-3); white-space: nowrap; }

.ic-ibtn, .ic-tbtn, .ic-zoom-value {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--ic-on-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.ic-ibtn { flex: none; width: 34px; font-size: 17px; }
.ic-tbtn { flex: none; padding: 0 10px; font: 600 12.5px/1 var(--font-body); white-space: nowrap; }
.ic-tbtn i { font-size: 16px; }
.ic-ibtn:hover, .ic-tbtn:hover, .ic-zoom-value:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.ic-ibtn:active, .ic-tbtn:active { transform: scale(0.94); }
.ic-ibtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.12); color: var(--color-accent); }
.ic-ibtn:disabled { opacity: 0.35; cursor: default; }
.ic-zoom { display: flex; align-items: center; gap: 0; }
.ic-zoom-value { min-width: 52px; padding: 0 6px; font: 600 12px/1 var(--ic-mono); font-variant-numeric: tabular-nums; }

/* ---------- Сцена ---------- */
.ic-stage {
  position: relative; display: flex; min-height: 0;
  padding: 28px; overflow: auto;
  background: var(--ic-deep);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
/* margin:auto вместо justify/align-content:center — так картинка,
   которая больше сцены, центрируется, а не уезжает за левый край,
   куда прокруткой не добраться */
.ic-canvas-viewport { position: relative; flex: none; margin: auto; user-select: none; -webkit-user-select: none; }
.ic-canvas-viewport canvas {
  display: block;
  background-color: #3a3f45;
  background-image: conic-gradient(#444a51 25%, #3a3f45 0 50%, #444a51 0 75%, #3a3f45 0);
  background-size: 16px 16px;
}

.ic-overlay { position: absolute; inset: 0; cursor: crosshair; touch-action: pan-x pan-y; }

/* ---------- Рамка обрезки ---------- */
.ic-crop {
  --hc: #fff;
  position: absolute; cursor: move; outline: none; touch-action: none;
  box-shadow: 0 0 0 9999px rgba(18, 20, 23, 0.6);
}
.ic-crop::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border: 1px solid var(--hc);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
  transition: border-color 0.15s ease;
}
.ic-crop.is-ellipse, .ic-crop.is-ellipse::before { border-radius: 50%; }
.ic-crop.is-drag { --hc: var(--color-accent); }
.ic-crop:focus-visible::before { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(29, 217, 122, 0.55); }

.ic-crop-grid {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  opacity: 0; transition: opacity 0.15s ease;
  --gl: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5));
  background-image: var(--gl), var(--gl), var(--gl), var(--gl);
  background-size: 1px 100%, 1px 100%, 100% 1px, 100% 1px;
  background-position: 33.3333% 0, 66.6667% 0, 0 33.3333%, 0 66.6667%;
  background-repeat: no-repeat;
}.ic-crop.is-ellipse .ic-crop-grid { border-radius: 50%; }
.ic-crop.is-drag .ic-crop-grid, .ic-crop.show-grid .ic-crop-grid { opacity: 1; }

/* Ручки. Видимое — только метки: уголки и короткие планки по
   серединам сторон. Область захвата заметно шире видимого: углы
   44×44, стороны — полосой на всю длину. */
.ic-h { position: absolute; z-index: 2; touch-action: none; }
.ic-h::before { content: ''; position: absolute; pointer-events: none; filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5)); transition: border-color 0.15s ease, background 0.15s ease; }
.ic-h--nw, .ic-h--ne, .ic-h--se, .ic-h--sw { width: 44px; height: 44px; }
.ic-h--nw { left: -22px; top: -22px; cursor: nwse-resize; }
.ic-h--ne { right: -22px; top: -22px; cursor: nesw-resize; }
.ic-h--se { right: -22px; bottom: -22px; cursor: nwse-resize; }
.ic-h--sw { left: -22px; bottom: -22px; cursor: nesw-resize; }
.ic-h--nw::before, .ic-h--ne::before, .ic-h--se::before, .ic-h--sw::before { width: 18px; height: 18px; border: 0 solid var(--hc); }
.ic-h--nw::before { left: 20.5px; top: 20.5px; border-left-width: 3px; border-top-width: 3px; border-top-left-radius: 3px; }
.ic-h--ne::before { left: 5.5px; top: 20.5px; border-right-width: 3px; border-top-width: 3px; border-top-right-radius: 3px; }
.ic-h--se::before { left: 5.5px; top: 5.5px; border-right-width: 3px; border-bottom-width: 3px; border-bottom-right-radius: 3px; }
.ic-h--sw::before { left: 20.5px; top: 5.5px; border-left-width: 3px; border-bottom-width: 3px; border-bottom-left-radius: 3px; }

.ic-h--n, .ic-h--s { left: 22px; right: 22px; height: 24px; cursor: ns-resize; }
.ic-h--e, .ic-h--w { top: 22px; bottom: 22px; width: 24px; cursor: ew-resize; }
.ic-h--n { top: -12px; } .ic-h--s { bottom: -12px; } .ic-h--e { right: -12px; } .ic-h--w { left: -12px; }
.ic-h--n::before, .ic-h--s::before { left: 50%; top: 50%; width: 24px; height: 3px; margin: -1.5px 0 0 -12px; border-radius: 2px; background: var(--hc); }
.ic-h--e::before, .ic-h--w::before { left: 50%; top: 50%; width: 3px; height: 24px; margin: -12px 0 0 -1.5px; border-radius: 2px; background: var(--hc); }
/* на совсем маленькой рамке планки по серединам только мешают */
.ic-crop.is-small .ic-h--n::before, .ic-crop.is-small .ic-h--e::before,
.ic-crop.is-small .ic-h--s::before, .ic-crop.is-small .ic-h--w::before { display: none; }

.ic-crop-dim {
  position: absolute; left: 10px; top: 10px; z-index: 3; pointer-events: none;
  padding: 5px 9px; border-radius: 6px;
  background: rgba(18, 20, 23, 0.82); color: #fff;
  font: 600 11.5px/1 var(--ic-mono); white-space: nowrap;
  opacity: 0; transform: translateY(2px); transition: opacity 0.15s ease, transform 0.15s ease;
}
.ic-crop.is-drag .ic-crop-dim { opacity: 1; transform: none; }
.ic-crop.is-small .ic-crop-dim { display: none; }

/* ---------- Подсказки поверх сцены ---------- */
.ic-toast {
  position: absolute; left: 50%; bottom: 16px; z-index: 6; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 9px 14px;
  border-radius: var(--radius-sm); background: rgba(18, 20, 23, 0.92); color: var(--ic-on);
  font-size: 12.5px; line-height: 1.45; text-align: center;
  box-shadow: 0 0 0 1px var(--ic-hair-on);
}
.ic-toast a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.ic-toast.is-error { box-shadow: inset 0 0 0 1px rgba(255, 138, 138, 0.4); color: #ffd2d2; }

.ic-veil {
  position: absolute; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center;
  background: rgba(35, 39, 43, 0.86); pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--color-accent);
}
.ic-veil span { display: inline-flex; align-items: center; gap: 10px; font: 600 15px/1.2 var(--font-body); color: #fff; }
.ic-veil i { font-size: 22px; color: var(--color-accent); }
.ic-shell.is-dragover .ic-work .ic-veil { display: flex; }

/* ---------- Нижняя планка: поворот, линейка, вид ---------- */
.ic-tools { display: flex; align-items: center; gap: 2px; flex: none; }

/* Линейка наклона. Лента с делениями (шаг 1°, крупные через 5°)
   едет под неподвижной меткой по центру; число над меткой — текущий
   угол. Вся лента — один элемент с фоном из градиентов, никаких
   сотен узлов в разметке. */
.ic-ruler {
  --a: 0;
  position: relative; flex: 1 1 auto; min-width: 160px; height: 46px;
  overflow: hidden; cursor: ew-resize; touch-action: none; outline: none;
  border-radius: var(--radius-sm); user-select: none; -webkit-user-select: none;
}
.ic-ruler::before, .ic-ruler::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 72px; z-index: 2; pointer-events: none;
}
.ic-ruler::before { left: 0; background: linear-gradient(to right, var(--ic-stage), transparent); }
.ic-ruler::after { right: 0; background: linear-gradient(to left, var(--ic-stage), transparent); }
.ic-ruler-value {
  position: absolute; left: 50%; top: 3px; z-index: 3; transform: translateX(-50%);
  font: 600 12px/1 var(--ic-mono); color: var(--ic-on); font-variant-numeric: tabular-nums; pointer-events: none;
}
.ic-ruler-strip {
  position: absolute; left: 50%; bottom: 6px; height: 16px; width: 722px; margin-left: -360px;
  transform: translateX(calc(var(--a) * -8px));
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.34) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.72) 1px, transparent 1px);
  background-size: 8px 8px, 40px 16px;
  background-position: 0 100%, 0 100%;
  background-repeat: repeat-x;
  will-change: transform;
}
.ic-ruler-mark {
  position: absolute; left: 50%; bottom: 4px; z-index: 3; width: 2px; height: 20px; margin-left: -1px;
  border-radius: 1px; background: #fff; pointer-events: none;
  transition: background 0.15s ease;
}
.ic-ruler.is-zero .ic-ruler-mark { background: var(--color-accent); }
.ic-ruler:focus-visible { box-shadow: 0 0 0 2px var(--color-accent); }

/* ---------- Лента миниатюр ---------- */
.ic-film {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px;
  border-top: 1px solid var(--ic-hair-on);
}
.ic-film-count { flex: none; font: 500 12px/1 var(--font-body); color: var(--ic-on-3); }
.ic-film-count b { color: var(--ic-on); font-weight: 600; }
/* Поля вокруг миниатюр — под крестик (выступает на 5px) и кольцо выбранной (4px): overflow-x обрезает и по вертикали */
.ic-film-list { flex: 0 1 auto; min-width: 0; display: flex; gap: 8px; padding: 8px; margin: -8px; overflow-x: auto; scrollbar-width: none; }
.ic-film-list::-webkit-scrollbar { display: none; }
.ic-thumb {
  position: relative; flex: none; width: 48px; height: 48px;
  border-radius: 8px; cursor: pointer; background: var(--ic-deep);
  box-shadow: 0 0 0 1px var(--ic-hair-on);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.ic-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 8px; opacity: 0.7; transition: opacity 0.15s ease; }
.ic-thumb:hover img { opacity: 1; }
.ic-thumb.is-active { box-shadow: 0 0 0 2px var(--ic-stage), 0 0 0 4px var(--color-accent); }
.ic-thumb.is-active img { opacity: 1; }
.ic-thumb-x {
  position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%;
  background: #191B1E; color: #fff; font-size: 11px; cursor: pointer;
  box-shadow: 0 0 0 1.5px var(--ic-stage);
  opacity: 0; transition: opacity 0.15s ease;
}
.ic-thumb:hover .ic-thumb-x, .ic-thumb:focus-within .ic-thumb-x, .ic-thumb.is-active .ic-thumb-x { opacity: 1; }
@media (hover: none) { .ic-thumb-x { opacity: 1; } }
.ic-film-add {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center;
  border: 1.5px dashed rgba(255, 255, 255, 0.22); border-radius: 8px; background: transparent;
  color: var(--ic-on-2); font-size: 18px; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.ic-film-add:hover { border-color: var(--color-accent); color: var(--color-accent); background: rgba(29, 217, 122, 0.06); }

/* =========================================================
   ПАНЕЛЬ ПАРАМЕТРОВ
   ========================================================= */

.ic-insp {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--color-surface); border-left: 1px solid var(--ic-line);
}
.ic-insp-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(43, 47, 51, 0.22) transparent; }

.ic-sec { padding: 14px 16px 16px; border-bottom: 1px solid var(--ic-line); }
.ic-sec--head {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 12px 0 16px;
}
.ic-sec--ratios { padding-top: 14px; padding-bottom: 14px; }
.ic-sec-head { display: flex; align-items: center; justify-content: space-between; min-height: 20px; margin-bottom: 8px; }
.ic-label {
  margin: 0; font: 600 11px/1 var(--font-body);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ic-label);
}
.ic-unit { font: 500 11px/1 var(--ic-mono); color: var(--ic-label); }
.ic-hint { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--ic-label); }
.ic-hint--mono { font-family: var(--ic-mono); font-size: 12px; color: var(--color-text); }
.ic-note { display: flex; gap: 7px; margin: 10px 0 0; font-size: 12px; line-height: 1.45; color: var(--ic-label); }
.ic-note i { flex: none; margin-top: 1px; }
.ic-note.is-warn { color: #8a5a00; }
.ic-link {
  padding: 2px 0; border: 0; background: none; cursor: pointer;
  font: 600 12px/1 var(--font-body); color: var(--color-accent-dark);
}
.ic-link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Плитки пропорций ---------- */
.ic-ratios { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ic-ratio {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px;
  height: 54px; padding: 0 0 8px;
  border: 0; border-radius: 10px; background: var(--ic-field); color: var(--color-text);
  font: 500 10px/1 var(--font-body); letter-spacing: -0.01em; white-space: nowrap; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.ic-ratio:hover { background: var(--ic-field-hover); }
.ic-ratio:active { transform: scale(0.96); }
.ic-ratio[aria-pressed="true"] { background: var(--color-text-strong); color: #fff; }
/* Значок-образец: прямоугольник в той самой пропорции, вписанный в
   квадрат 22×22. Размер считается из --ar прямо в CSS. */
.ic-rg {
  position: relative; display: block; flex: none;
  width: 20px; height: 16px; /* запас для браузеров без min()/max() в calc() */
  width: calc(22px * min(1, var(--ar)));
  height: calc(22px / max(1, var(--ar)));
  border: 1.5px solid currentColor; border-radius: 3px;
}
.ic-rg--free { border-style: dashed; }
.ic-rg--orig::after { content: ''; position: absolute; inset: 2.5px; border: 1.5px solid currentColor; border-radius: 1px; opacity: 0.45; }

/* ---------- Поля ---------- */
.ic-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ic-fields--pair { grid-template-columns: minmax(0, 1fr) 10px minmax(0, 1fr); align-items: center; gap: 6px; }
.ic-times { text-align: center; font: normal 13px/1 var(--font-body); color: var(--ic-label); }
.ic-field {
  display: flex; align-items: center; height: 36px; margin: 0;
  border-radius: var(--radius-sm); background: var(--ic-field);
  box-shadow: inset 0 0 0 1.5px transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.ic-field > span { flex: none; width: 28px; text-align: center; font: 600 11px/1 var(--ic-mono); color: var(--ic-label); }
.ic-field input {
  flex: 1 1 auto; min-width: 0; width: 100%; height: 100%; padding: 0 10px 0 0;
  border: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: transparent; outline: none;
  font: 500 13px/1 var(--ic-mono); color: var(--color-text-strong); text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.ic-field input::-webkit-outer-spin-button, .ic-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ic-field:hover { background: var(--ic-field-hover); }
.ic-field:focus-within { background: #fff; box-shadow: inset 0 0 0 1.5px var(--color-accent), 0 0 0 3px rgba(29, 217, 122, 0.18); }
/* общее правило сайта даёт полю ещё и собственное кольцо — внутри
   рамки .ic-field оно лишнее */
.ic-field input:focus-visible { box-shadow: none; border-color: transparent; }

/* ---------- Сегментные переключатели ---------- */
.ic-seg { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--ic-field); }
.ic-seg-btn {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center;
  height: 30px; padding: 0 6px; border: 0; border-radius: 8px; background: transparent;
  font: 600 12.5px/1 var(--font-body); color: var(--ic-label); white-space: nowrap; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.ic-seg-btn:hover { color: var(--color-text-strong); }
.ic-seg-btn[aria-pressed="true"] { background: #fff; color: var(--color-text-strong); box-shadow: 0 1px 2px rgba(25, 27, 30, 0.14), 0 0 0 0.5px rgba(25, 27, 30, 0.06); }
.ic-seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ic-seg--icons { flex: none; padding: 2px; }
.ic-seg--icons .ic-seg-btn { flex: none; width: 32px; height: 28px; padding: 0; font-size: 16px; }

/* ---------- Качество ---------- */
.ic-quality { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.ic-quality label { flex: none; margin: 0; font: 600 12.5px/1 var(--font-body); color: var(--color-text-strong); }
.ic-quality-value { flex: none; min-width: 34px; text-align: right; font: 500 12.5px/1 var(--ic-mono); color: var(--color-text-strong); }
.ic-chip {
  flex: none; height: 22px; padding: 0 8px; border: 0; border-radius: 6px;
  background: rgba(29, 217, 122, 0.14); color: #0d7a43;
  font: 600 11px/1 var(--font-body); letter-spacing: 0.02em; cursor: pointer;
  transition: background 0.15s ease;
}
.ic-chip:hover { background: rgba(29, 217, 122, 0.24); }
.ic-chip.is-off { background: var(--ic-field); color: var(--ic-label); }
.ic-chip.is-off:hover { background: var(--ic-field-hover); color: var(--color-text-strong); }

/* ---------- Ползунки ---------- */
input[type="range"].ic-range {
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto; min-width: 0; width: 100%; height: 20px; margin: 0; background: none; cursor: pointer;
}
input[type="range"].ic-range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--color-accent) var(--ic-range-fill, 50%), #E1E5E9 var(--ic-range-fill, 50%));
}
input[type="range"].ic-range::-moz-range-track { height: 4px; border-radius: 999px; background: #E1E5E9; }
input[type="range"].ic-range::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--color-accent); }
input[type="range"].ic-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 0;
  box-shadow: 0 0 0 1px rgba(25, 27, 30, 0.14), 0 1px 3px rgba(25, 27, 30, 0.28);
  transition: transform 0.12s ease;
}
input[type="range"].ic-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: 0; background: #fff;
  box-shadow: 0 0 0 1px rgba(25, 27, 30, 0.14), 0 1px 3px rgba(25, 27, 30, 0.28);
}
input[type="range"].ic-range:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"].ic-range:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- Низ панели: вес и скачивание ---------- */
.ic-foot { flex: none; padding: 12px 16px 14px; border-top: 1px solid var(--ic-line); background: var(--color-surface); }
.ic-size { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; transition: opacity 0.2s ease; }
.ic-size.is-calculating { opacity: 0.55; }
.ic-size-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 62px; align-items: center; gap: 10px; }
.ic-size-row > span { font: 600 11px/1 var(--font-body); color: var(--ic-label); }
.ic-size-row > strong { text-align: right; font: 500 12.5px/1 var(--ic-mono); color: var(--color-text-strong); font-variant-numeric: tabular-nums; }
.ic-size-track { height: 6px; border-radius: 3px; background: var(--ic-field); overflow: hidden; }
.ic-size-fill { display: block; height: 100%; border-radius: 3px; transition: width 0.28s var(--ic-ease); }
.ic-size.is-calculating .ic-size-fill { transition: none; }
.ic-size-fill--before { background: #C5CBD2; }
.ic-size-fill--after { background: var(--color-accent); }
.ic-size.is-heavier .ic-size-fill--after { background: var(--color-text-strong); }
.ic-size-ok { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; font: 600 12px/1.3 var(--font-body); color: #0d7a43; }
.ic-size-ok i { font-size: 15px; color: var(--color-accent-dark); }
.ic-size-hint { margin: 2px 0 0; font-size: 12px; line-height: 1.4; color: var(--ic-label); }
.ic-privacy { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 9px 0 0; font-size: 11.5px; line-height: 1.3; color: var(--ic-label); }

/* Палец крупнее мыши: у всех нажимаемых элементов на сенсорных экранах не меньше 32px по обеим сторонам */
@media (pointer: coarse) {
  .ic-seg-btn { height: 36px; }
  .ic-seg--icons .ic-seg-btn { width: 40px; height: 34px; }
  .ic-chip { height: 32px; padding: 0 12px; }
  .ic-link { padding: 8px 0; }
  .ic-tbtn { min-width: 34px; }
}

/* =========================================================
   ФОКУС
   ========================================================= */
.ic-btn:focus-visible, .ic-ibtn:focus-visible, .ic-tbtn:focus-visible, .ic-zoom-value:focus-visible,
.ic-film-add:focus-visible, .ic-thumb:focus-visible, .ic-thumb-x:focus-visible,
.ic-ratio:focus-visible, .ic-seg-btn:focus-visible, .ic-chip:focus-visible, .ic-link:focus-visible {
  outline: 2px solid var(--color-accent); outline-offset: 2px;
}
.ic-seg-btn:focus-visible { outline-offset: -2px; }

/* =========================================================
   АДАПТИВНОСТЬ — ПО ШИРИНЕ КОНТЕЙНЕРА, А НЕ ОКНА
   С 992px на сайте появляется боковое меню в 332px, и оконный
   медиазапрос ошибается ровно на эту величину: ширину инструмента
   знает только он сам.
   ========================================================= */

@container ictool (max-width: 800px) {
  .ic-work { grid-template-columns: minmax(0, 1fr); height: auto; }
  .ic-stage-col { grid-template-rows: auto auto auto auto; }
  .ic-stage { height: auto; min-height: 240px; }
  .ic-insp { border-left: 0; border-top: 1px solid var(--ic-line); }
  .ic-insp-scroll { overflow: visible; }
  .ic-sec--head { height: 52px; }
  /* кнопка скачивания всегда под рукой, пока листаешь параметры */
  .ic-foot { position: sticky; bottom: 0; z-index: 5; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .ic-ratios { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@container ictool (max-width: 960px) {
  .ic-file-text span { display: none; }
  .ic-tbtn span { display: none; }
  .ic-tbtn { width: 34px; padding: 0; }
}
@container ictool (max-width: 640px) {
  .ic-bar--bottom { flex-wrap: wrap; row-gap: 2px; }
  .ic-ruler { order: -1; flex: 1 0 100%; min-width: 0; }
  .ic-bar--bottom .ic-tools:first-child { margin-right: auto; }
  .ic-drop { min-height: 360px; padding: 56px 20px; }
  .ic-drop-mark { width: 26px; height: 26px; }
  .ic-drop-mark--tl { top: 18px; left: 18px; } .ic-drop-mark--tr { top: 18px; right: 18px; }
  .ic-drop-mark--bl { bottom: 18px; left: 18px; } .ic-drop-mark--br { bottom: 18px; right: 18px; }
  .ic-drop-error { bottom: 54px; }
  .ic-drop-title { font-size: 23px; }
  .ic-drop .ic-btn { width: 100%; max-width: 320px; height: 48px; }
  .ic-stage { padding: 16px; }
}
@container ictool (max-width: 420px) {
  .ic-sec, .ic-foot { padding-left: 14px; padding-right: 14px; }
  .ic-sec--head { padding-left: 14px; padding-right: 10px; }
  .ic-ratio { height: 54px; font-size: 10.5px; }
  .ic-rg { width: calc(20px * min(1, var(--ar))); height: calc(20px / max(1, var(--ar))); }
  .ic-drop-sub kbd { display: none; }
  .ic-drop-sub { font-size: 14px; }
}
@container ictool (max-width: 330px) {
  .ic-ratio { font-size: 9.5px; letter-spacing: -0.02em; }
}
/* 320px-экраны: в пять колонок подпись «Свободно» встаёт впритык к краям плитки — тут плитки шире, рядов три */
@container ictool (max-width: 300px) {
  .ic-ratios { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ic-ratio { font-size: 10.5px; letter-spacing: 0; }
}
@supports not (container-type: inline-size) {
  @media (max-width: 1132px) {
    .ic-work { grid-template-columns: minmax(0, 1fr); height: auto; }
    .ic-stage { height: auto; min-height: 240px; }
    .ic-insp { border-left: 0; border-top: 1px solid var(--ic-line); }
    .ic-insp-scroll { overflow: visible; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .ic-tool *, .ic-tool *::before, .ic-tool *::after { transition-duration: 0.01ms !important; }
}
@media (forced-colors: active) {
  .ic-crop::before { border-color: CanvasText; }
  .ic-ratio[aria-pressed="true"], .ic-seg-btn[aria-pressed="true"] { outline: 2px solid Highlight; }
}

/* =========================================================
   SEO-БЛОК "почему это проблема" — единая нейтральная карточка.
   Раньше здесь были два блока с полупрозрачной красной/зелёной
   заливкой — читалось как самодеятельность, а не продуманный
   интерфейс. "Проблема" и "решение" теперь различаются только
   маленьким значком слева от заголовка, а не цветом всей плашки.
   ========================================================= */

.ic-explain-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .ic-explain-grid { grid-template-columns: 1fr; } }

/* Настоящий контраст между карточками вместо унылого серого на
   сером: "проблема" — тёмная поверхность (тот же язык, что уже
   принят на сайте для технических/кодовых панелей — не новая
   идея), "решение" — светлая с акцентными деталями. Различие
   считывается сразу, без чтения подписи. */
.ic-explain-card {
  position: relative;
  padding: 32px 30px; border-radius: var(--radius-lg);
}
.ic-explain-card--problem { background: var(--ic-stage-bg); border: 1px solid rgba(255,255,255,0.06); }
.ic-explain-card--solution { background: var(--color-surface); border: 1px solid var(--ic-border); box-shadow: var(--shadow-card); }

.ic-explain-head { display: flex; align-items: center; gap: 14px; margin: 12px 0 18px; }
.ic-explain-card h3 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.ic-explain-card--problem h3 { color: #fff; }
.ic-explain-card--solution h3 { color: var(--color-text-strong); }

.ic-explain-card p { font-size: 13.5px; line-height: 1.7; margin: 0 0 14px; }
.ic-explain-card p:last-child { margin-bottom: 0; }
.ic-explain-card--problem p { color: rgba(255,255,255,0.65); }
.ic-explain-card--solution p { color: var(--color-text); }
.ic-explain-card--problem p strong { color: #fff; }
.ic-explain-card--problem code { background: rgba(255,255,255,0.1); color: #fff; }

.ic-explain-eyebrow {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}
.ic-explain-card--problem .ic-explain-eyebrow { color: rgba(255,255,255,0.45); }
.ic-explain-card--solution .ic-explain-eyebrow { color: var(--color-accent-dark); }

.ic-explain-badge {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.ic-explain-card--problem .ic-explain-badge { background: rgba(255,255,255,0.1); color: #fff; }
.ic-explain-card--solution .ic-explain-badge {
  background: var(--color-accent); color: #06231a;
  box-shadow: 0 0 0 6px rgba(29,217,122,0.14);
}

/* =========================================================
   Справочник пропорций — практическая таблица, не просто список
   ========================================================= */
.ic-ratio-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--ic-border);
  border-radius: var(--radius-lg);
}
.ic-ratio-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ic-ratio-table th {
  text-align: left; padding: 12px 16px; background: var(--color-bg);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-muted); white-space: nowrap;
}
.ic-ratio-table td { padding: 12px 16px; border-top: 1px solid var(--ic-border); color: var(--color-text); vertical-align: middle; }
.ic-ratio-table td:first-child { font-weight: 700; color: var(--color-text-strong); }
/* Колонка «Пресет» — значение, которое пользователь выбирает в инструменте: выделено цветом
   так же, как рекомендованное значение в таблице генератора ЧПУ (зелёный текст ссылок, 600, без плашки) */
.ic-ratio-table code { font-size: 12px; color: var(--link); font-weight: 600; white-space: nowrap; }
.ic-ratio-table-note {
  display: flex; align-items: flex-start; gap: 8px; margin: 12px 2px 0;
  font-size: 12.5px; color: var(--color-muted); line-height: 1.6;
}
.ic-ratio-table-note i { flex-shrink: 0; margin-top: 2px; }

/* =========================================================
   ПОЯСНИТЕЛЬНЫЕ РЯДЫ SEO-РАЗДЕЛА

   Не сетка карточек: это текст, который читают подряд, а не
   набор равнозначных плиток для выбора. Тот же приём, что у
   «Принципов» на странице «О нас» — волосяная линия и метка
   слева вместо коробки с тенью.
   ========================================================= */

.ic-explain-rows { display: flex; flex-direction: column; }

.ic-explain-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  padding: 26px 0;
  border-top: 1px solid var(--ic-border);
}
.ic-explain-row:first-child { border-top: none; padding-top: 0; }

.ic-explain-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--color-accent-dark);
}
.ic-explain-row h3 {
  font-size: 17px; line-height: 1.35; margin: 0 0 10px;
  color: var(--color-text-strong);
}
.ic-explain-row p {
  font-size: 14.5px; line-height: 1.75; color: var(--color-muted); margin: 0 0 12px;
}
.ic-explain-row p:last-child { margin-bottom: 0; }
.ic-explain-row strong { color: var(--color-text-strong); font-weight: 600; }

/* Ширину меряем у контейнера, а не у окна: с 1024px сайдбар
   в 332px делает оконный медиазапрос неверным ровно на эту
   величину — та же причина, что и у сетки самого инструмента. */
.tool-seo, .section { container-type: inline-size; container-name: icseo; }
@container icseo (max-width: 620px) {
  .ic-explain-row { grid-template-columns: 1fr; gap: 8px; padding: 20px 0; }
}
@supports not (container-type: inline-size) {
  @media (max-width: 952px) {
    .ic-explain-row { grid-template-columns: 1fr; gap: 8px; padding: 20px 0; }
  }
}

/* =========================================================
   ВРЕЗКА-ВЫВОД
   ========================================================= */

.ic-note-block {
  display: flex; align-items: flex-start; gap: 12px;
  margin-top: 22px; padding: 16px 20px;
  background: var(--color-bg); border-radius: var(--radius-md);
}
.ic-note-block i {
  font-size: 17px; color: var(--color-accent-dark);
  margin-top: 2px; flex-shrink: 0;
}
.ic-note-block p {
  margin: 0; font-size: 14px; line-height: 1.75; color: var(--color-muted);
}
.ic-note-block strong { color: var(--color-text-strong); }

@media (max-width: 599px) {
  .ic-note-block { padding: 14px 16px; }
}
