.app { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; padding: 24px 0 48px; align-items: start; }
@media (max-width: 980px) { .app { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .filebar { flex-wrap: wrap; } .filebar .fbtns { width: 100%; } .filebar .fbtns .btn { flex: 1; } }

/* ---------- Файл ---------- */
.filebar { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-sm); padding: 14px 16px; margin-bottom: 16px; }
.filebar .ficon { width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--blue-wash); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--blue); letter-spacing: .04em; }
.filebar .fname { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filebar .fmeta { font-size: 13px; color: var(--faint); }
.filebar .finfo { min-width: 0; flex: 1; }
.filebar .fbtns { display: flex; gap: 8px; }
.errors { background: #fff3f1; border: 1px solid #f3c9c2; color: var(--bad); border-radius: 12px; padding: 10px 14px; margin: -6px 0 16px; font-size: 14px; display: grid; gap: 4px; }
.dragging .viewer-card { outline: 3px dashed var(--accent); outline-offset: 4px; }

/* ---------- Превью ---------- */
.viewer-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-sm); padding: 16px; }
.viewer-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.stage { background: repeating-conic-gradient(#eef2f7 0 25%, #f6f8fb 0 50%) 0 0 / 22px 22px; border-radius: 12px; padding: 28px; display: grid; place-items: center; min-height: 420px; }
@media (max-width: 600px) { .stage { padding: 12px; min-height: 0; } }
.page { position: relative; width: 100%; max-width: 640px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12), 0 18px 40px rgba(16, 35, 53, .14); background: #fff; user-select: none; touch-action: pan-y; }
.page canvas { width: 100%; height: auto; }
.page .before { position: absolute; inset: 0; height: 100%; clip-path: inset(0 calc(100% - var(--x, 50%)) 0 0); }
.page .split { position: absolute; top: 0; bottom: 0; left: var(--x, 50%); width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; }
.page .split::after { content: "⟷"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: var(--sh-md); }
.page input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: ew-resize; }
.page:not(.compare) .before, .page:not(.compare) .split, .page:not(.compare) input { display: none; }
.busy-dot { position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity .2s; }
.page.loading .busy-dot { opacity: 1; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.6); opacity: .4; } }

.pager { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 18px; line-height: 1; }
.icon-btn:hover:not(:disabled) { border-color: var(--line-2); box-shadow: var(--sh-sm); }
.icon-btn:disabled { opacity: .4; cursor: default; }

/* ---------- Сегменты ---------- */
.seg { display: inline-flex; background: var(--bg-soft); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); }
.seg.full { display: flex; }
.seg.full button { flex: 1; padding: 8px 4px; }
.seg.dpi button { display: grid; line-height: 1.15; font-variant-numeric: tabular-nums; }
.seg.dpi small { font-size: 10px; font-weight: 700; letter-spacing: .05em; opacity: .7; }

/* ---------- Настройки ---------- */
.panel { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-sm); padding: 20px; position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; overscroll-behavior: contain; }
@media (max-width: 980px) { .panel { position: static; max-height: none; } }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head h2 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.link-btn { border: 0; background: none; color: var(--blue); font-weight: 600; font-size: 14px; cursor: pointer; padding: 4px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.presets button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.presets button:hover { border-color: var(--accent); color: var(--accent-deep); }
.presets button[aria-pressed=true] { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-deep); }
.group { border-top: 1px solid var(--line); padding: 16px 0 4px; margin-top: 12px; display: grid; gap: 14px; }
.group h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.field { display: grid; gap: 6px; }
.field .lbl { display: flex; justify-content: space-between; font-size: 14px; font-weight: 550; }
.field output { color: var(--blue); font-weight: 650; font-variant-numeric: tabular-nums; }
.toggle { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 550; cursor: pointer; }
.toggle input { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.toggle input:checked { background: var(--blue); }
.toggle input:checked::after { transform: translateX(18px); }

input[type=range].rng { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer; }
.rng::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--blue) var(--p, 50%), var(--bg-soft) var(--p, 50%)); }
.rng::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--blue) var(--p, 50%), var(--bg-soft) var(--p, 50%)); }
.rng::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: #fff; border: 2px solid var(--blue); box-shadow: var(--sh-sm); }
.rng::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--blue); }

.cta { margin: 20px -20px -20px; padding: 12px 20px 14px; display: grid; gap: 10px; position: sticky; bottom: -20px; background: linear-gradient(180deg, rgba(255, 255, 255, .85), #fff 30%); border-top: 1px solid var(--line); }
@media (max-width: 980px) { .cta { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; box-shadow: 0 -8px 24px rgba(16, 35, 53, .1); } .app { padding-bottom: 170px; } .cta .privacy-note { display: none; } }
.cta .btn { width: 100%; }
.progress { height: 8px; border-radius: 4px; background: var(--bg-soft); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffb14d); transition: width .15s; }
.status { font-size: 13px; color: var(--muted); text-align: center; min-height: 1.4em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--bad); }
.privacy-note { font-size: 12px; color: var(--faint); text-align: center; }

/* Невысокие экраны ноутбуков: панель компактнее, кнопка меньше */
@media (min-width: 981px) and (max-height: 820px) {
  .cta .btn-lg { padding: 13px 20px; font-size: 16px; }
  .cta .privacy-note { display: none; }
  .group { padding-top: 12px; gap: 10px; margin-top: 8px; }
}

/* ---------- Миниатюры ---------- */
.thumbs { list-style: none; margin: 14px 0 0; padding: 4px 2px 8px; display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; }
.thumbs li { position: relative; flex: none; width: 96px; cursor: pointer; scroll-snap-align: start; border-radius: 8px; padding: 4px; border: 2px solid transparent; transition: border-color .15s; }
.thumbs li.active { border-color: var(--blue); }
.thumbs li.dragging { opacity: .4; }
.thumbs li.drop-before { box-shadow: -4px 0 0 var(--accent); }
.thumbs canvas { width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); border-radius: 2px; min-height: 60px; }
.thumbs .tn { display: block; text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.thumbs .tbtns { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.thumbs li:hover .tbtns, .thumbs li.active .tbtns, .thumbs li:focus-within .tbtns { opacity: 1; }
@media (hover: none) { .thumbs .tbtns { opacity: 1; } }
.thumbs .tbtns button { width: 26px; height: 26px; border-radius: 7px; border: 0; background: rgba(16, 35, 53, .78); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.thumbs .tbtns button:hover { background: var(--ink); }
.thumbs .tbtns button[data-act=del]:hover { background: var(--bad); }
.thumbs-hint { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ---------- Диалог пароля ---------- */
.dlg { border: 0; border-radius: var(--r); box-shadow: var(--sh-lg); padding: 22px; width: min(420px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(16, 35, 53, .4); }
.dlg p { margin-bottom: 12px; font-weight: 600; overflow-wrap: anywhere; }
.dlg input { width: 100%; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 16px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.ad-slot { margin-top: 16px; min-height: 90px; }
