:root {
  --bg: #ffffff;
  --bg-soft: #f3f5f9;
  --bg-hover: #e9edf5;
  --card: #ffffff;
  --text: #1c2030;
  --text-soft: #5d6478;
  --line: #e3e7ef;
  --accent: #2f6fed;
  --accent-soft: #e4edff;
  --accent-text: #ffffff;
  --danger: #d93a3a;
  --shadow: 0 6px 24px rgba(20, 30, 60, .14);
  --header-h: 60px;
  --nav-h: 60px;
  --side-w: 240px;
  --radius: 14px;
  --gap: 4px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --bg-soft: #1a1d25;
    --bg-hover: #252935;
    --card: #181b22;
    --text: #e8eaf0;
    --text-soft: #9aa1b2;
    --line: #2a2e3a;
    --accent: #6b9bff;
    --accent-soft: #1f2a44;
    --accent-text: #0b1020;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
svg.i { width: 24px; height: 24px; fill: currentColor; flex: none; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- кнопки и поля */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  background: var(--bg-soft); font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: inherit; flex: none;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.on { color: var(--accent); }
input[type=text], input[type=email], input[type=password], input[type=search] {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-soft); }

/* ---------------------------------------------------------------- вход */
.auth {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 50%), var(--bg);
}
.auth form {
  width: min(380px, 100%); display: grid; gap: 16px; padding: 32px 28px; border-radius: 22px;
  background: var(--card); box-shadow: var(--shadow);
}
.auth h1 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 24px; }
.auth p { margin: 0; color: var(--text-soft); }
.form-error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ---------------------------------------------------------------- каркас */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: .2px; text-decoration: none; color: var(--text); }
.logo svg { width: 34px; height: 34px; }
.logo b { color: var(--accent); font-weight: 700; }

header.top {
  position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header.top .search { flex: 1; max-width: 640px; margin: 0 auto; position: relative; }
header.top .search input { padding-left: 44px; background: var(--bg-soft); border-color: transparent; border-radius: 999px; }
header.top .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-soft); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700; border: 0; cursor: pointer;
}

nav.side {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--side-w); padding: 12px 10px 16px;
  display: flex; flex-direction: column; gap: 2px; z-index: 20; overflow-y: auto;
}
nav.side a, nav.bottom a {
  display: flex; align-items: center; gap: 16px; padding: 11px 16px; border-radius: 999px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
nav.side a:hover { background: var(--bg-hover); }
nav.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.side .nav-title { font-size: 13px; color: var(--text-soft); padding: 18px 16px 6px; }
nav.side a { position: relative; }
nav.side .expander {
  position: absolute; left: -2px; top: 50%; transform: translateY(-50%); width: 20px; height: 28px; border: 0; padding: 0;
  background: none; color: var(--text-soft); cursor: pointer; display: grid; place-items: center;
}
nav.side .expander svg { width: 18px; height: 18px; transition: transform .15s; }
nav.side .expander.open svg { transform: rotate(90deg); }
nav.side .sub-albums { display: grid; gap: 1px; margin: 2px 0 6px 18px; }
nav.side .sub-albums a { padding: 6px 12px; gap: 10px; font-size: 14px; font-weight: 400; }
nav.side .sub-albums a span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav.side .sub-albums img, nav.side .sub-albums .ph { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex: none; background: var(--bg-soft); display: grid; place-items: center; }
nav.side .sub-albums .ph svg { width: 16px; height: 16px; }
nav.side .sub-albums .all, nav.side .sub-albums .none { font-size: 13px; color: var(--text-soft); padding: 6px 12px; }
.storage-card { margin-top: auto; background: var(--bg-soft); border-radius: 16px; padding: 14px 16px; display: grid; gap: 6px; }
nav.side .storage-card { margin: 18px 6px 0; }
nav.side .storage-card:empty { display: none; }
.storage-card .title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.storage-card .title svg { width: 20px; height: 20px; color: var(--text-soft); }
.storage-card .sub { font-size: 13px; color: var(--text-soft); }
.storage-card .bar { height: 6px; border-radius: 3px; background: var(--bg-hover); overflow: hidden; }
.storage-card .bar > div { height: 100%; background: var(--accent); border-radius: 3px; }
.storage-card .bar.warn > div { background: #f0a020; }
.storage-card .bar.bad > div { background: var(--danger); }
.server-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); padding: 12px 16px 4px; }
.server-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.server-status.online .dot { background: #2fbf71; }
.server-status .ver { margin-left: auto; }
svg.i.inline { width: 18px; height: 18px; vertical-align: -4px; }

/* поиск */
.search-page { max-width: 900px; display: grid; gap: 18px; }
.big-search { position: relative; }
.big-search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-soft); }
.big-search input { padding: 16px 16px 16px 52px; border-radius: 999px; font-size: 16px; background: var(--bg-soft); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: 14px; background: var(--bg);
}
.chip:hover { background: var(--bg-hover); }
.chip svg { width: 18px; height: 18px; color: var(--text-soft); }
.chip .n { color: var(--text-soft); font-size: 12px; }
.facets h2, .section-title { font-size: 17px; margin: 8px 0 12px; }
.section-title { margin-top: 20px; }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.year-card { position: relative; aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden; background: var(--bg-soft); color: #fff; text-decoration: none; }
.year-card img { width: 100%; height: 100%; object-fit: cover; }
.year-card span { position: absolute; inset: auto 0 0 0; padding: 24px 12px 10px; background: linear-gradient(transparent, rgba(0,0,0,.65)); font-size: 12px; display: grid; }
.year-card b { font-size: 20px; }
@media (max-width: 800px) {
  .search-page { padding: 0 12px; }
  .year-grid { grid-template-columns: repeat(2, 1fr); }
  .section-title { padding: 0 12px; }
}

/* библиотека (телефон), утилиты */
.library-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 12px; }
.lib-tile { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 16px; background: var(--bg-soft); color: var(--text); text-decoration: none; font-weight: 600; }
.lib-tile svg { color: var(--accent); }
.library-bottom { padding: 16px 12px; }
.util-list { display: grid; gap: 8px; max-width: 720px; }
@media (max-width: 800px) { .util-list { padding: 0 12px; } }
.util { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; background: var(--bg-soft); color: var(--text); text-decoration: none; }
.util:hover { background: var(--bg-hover); }
.util > svg:first-child { color: var(--accent); }
.util .grow { flex: 1; display: grid; }
.util .sub { font-size: 13px; color: var(--text-soft); }
.util .n { color: var(--text-soft); font-weight: 600; }

/* личная папка */
.lock-screen { max-width: 380px; margin: 8vh auto 0; text-align: center; display: grid; gap: 12px; padding: 0 16px; }
.lock-screen .lock-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto; }
.lock-screen .lock-icon svg { width: 36px; height: 36px; }
.lock-screen h1 { margin: 0; font-size: 22px; }
.lock-screen p { margin: 0; color: var(--text-soft); }
.lock-screen form { display: grid; gap: 12px; text-align: left; margin-top: 8px; }
.lock-screen input[name^=pin] { font-size: 22px; letter-spacing: 8px; text-align: center; }

nav.bottom {
  position: fixed; inset: auto 0 0 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 30;
  display: none; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
nav.bottom a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 12px; border-radius: 0; flex: 1; color: var(--text-soft); }
nav.bottom a.active { color: var(--accent); }
nav.bottom a.active svg { background: var(--accent-soft); border-radius: 999px; padding: 2px 16px; width: 56px; }

main { padding: calc(var(--header-h) + 8px) 24px 40px calc(var(--side-w) + 16px); min-height: 100%; }

@media (max-width: 800px) {
  :root { --gap: 2px; }
  nav.side { display: none; }
  nav.bottom { display: flex; }
  main { padding: calc(var(--header-h) + 4px) 0 calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px) 0; }
  header.top { padding: 0 6px 0 12px; gap: 6px; }
  header.top .search.collapsed { display: none; }
  header.top .search:not(.collapsed) { position: absolute; inset: 8px 8px auto 8px; z-index: 2; }
  header.top .btn.primary { padding: 10px; }
  .logo span { display: none; }
  .page-head { padding: 0 12px; }
}
@media (min-width: 801px) { .mobile-only { display: none !important; } }

/* ---------------------------------------------------------------- шапка при выделении */
header.select-bar { background: var(--accent-soft); }
header.select-bar .count { font-weight: 600; font-size: 17px; flex: 1; }

/* ---------------------------------------------------------------- страницы */
.page-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; min-width: 0; }
.page-head .sub { color: var(--text-soft); font-size: 14px; }
.empty { text-align: center; color: var(--text-soft); padding: 80px 20px; }
.empty svg { width: 72px; height: 72px; opacity: .35; }
.empty h2 { color: var(--text); margin: 12px 0 6px; font-size: 20px; }

/* ---------------------------------------------------------------- лента */
.month { position: relative; }
.month > h2 { font-size: 20px; font-weight: 600; margin: 18px 0 4px; padding: 0 2px; }
.day { margin-bottom: 4px; }
.day > h3 {
  display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--text-soft);
  margin: 10px 0 6px; padding: 0 2px; cursor: pointer; user-select: none;
}
.day > h3 .check { display: none; }
.day > h3:hover .check, body.selecting .day > h3 .check { display: inline-flex; }
@media (max-width: 800px) {
  .month > h2, .day > h3 { padding: 0 12px; }
}
.row { display: flex; gap: var(--gap); margin-bottom: var(--gap); }
.tile {
  position: relative; overflow: hidden; background: var(--bg-soft); cursor: pointer; flex: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s; }
.tile .badge {
  position: absolute; right: 6px; top: 6px; color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 2px; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.tile .badge svg { width: 18px; height: 18px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.tile .fav { position: absolute; left: 6px; bottom: 6px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.tile .fav svg { width: 18px; height: 18px; }
.tile .check {
  position: absolute; left: 6px; top: 6px; opacity: 0; transition: opacity .1s; color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.6));
}
.tile:hover .check, body.selecting .tile .check { opacity: 1; }
.tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(0,0,0,.25), transparent 30%); opacity: 0; pointer-events: none; }
.tile:hover::after { opacity: 1; }
.tile.selected { background: var(--accent-soft); }
.tile.flash { outline: 4px solid var(--accent); outline-offset: -4px; animation: flash 1.2s ease 2; }
@keyframes flash { 50% { outline-color: transparent; } }
.avatar.has-img { padding: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.tile.selected img { transform: scale(.86); border-radius: 8px; }
.tile.selected .check { opacity: 1; color: var(--accent); filter: none; }
.check-svg { width: 24px; height: 24px; }

/* быстрая прокрутка */
.scrubber {
  position: fixed; right: 0; top: calc(var(--header-h) + 8px); bottom: 8px; width: 56px; z-index: 25;
  touch-action: none; user-select: none;
}
.scrubber .years { position: absolute; inset: 0; font-size: 11px; color: var(--text-soft); }
.scrubber .years span { position: absolute; right: 8px; transform: translateY(-50%); }
.scrubber .thumb {
  position: absolute; right: 4px; width: 40px; height: 28px; border-radius: 14px; transform: translateY(-50%);
  background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--text-soft);
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.scrubber.show .thumb, .scrubber.drag .thumb { opacity: 1; }
.scrubber .label {
  position: absolute; right: 52px; transform: translateY(-50%); background: var(--card); box-shadow: var(--shadow);
  padding: 6px 12px; border-radius: 999px; font-weight: 600; white-space: nowrap; display: none;
}
.scrubber.drag .label { display: block; }
@media (max-width: 800px) {
  .scrubber { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); width: 44px; }
  .scrubber .years { display: none; }
}
@media (min-width: 801px) { main.with-scrubber { padding-right: 64px; } }

/* ---------------------------------------------------------------- альбомы */
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px 16px; }
@media (max-width: 800px) { .albums { grid-template-columns: repeat(2, 1fr); gap: 16px 10px; padding: 0 12px; } }
.album-card { cursor: pointer; text-decoration: none; color: inherit; }
.album-card .cover { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--bg-soft); display: grid; place-items: center; }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.album-card:hover .cover img { transform: scale(1.04); }
.album-card .cover svg { width: 48px; height: 48px; opacity: .3; }
.album-card .name { font-weight: 600; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-card .meta { font-size: 13px; color: var(--text-soft); display: flex; gap: 6px; align-items: center; }
.album-card .meta svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- просмотр */
.viewer {
  position: fixed; inset: 0; z-index: 100; background: #000; color: #fff; display: flex; flex-direction: column;
  touch-action: none; user-select: none;
}
.viewer .bar {
  position: absolute; inset: 0 0 auto 0; z-index: 3; display: flex; align-items: center; gap: 2px;
  padding: max(8px, env(safe-area-inset-top)) 8px 24px; background: linear-gradient(rgba(0,0,0,.6), transparent);
  transition: opacity .2s;
}
.viewer .bar .spacer { flex: 1; }
.viewer .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer .icon-btn.on { color: #ff6b81; }
.viewer.chrome-off .bar, .viewer.chrome-off .nav-btn { opacity: 0; pointer-events: none; }
.viewer .stage { position: relative; flex: 1; overflow: hidden; }
.viewer .slide { position: absolute; inset: 0; display: grid; place-items: center; will-change: transform; }
.viewer .slide img, .viewer .slide video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.viewer .slide img { transform-origin: 0 0; }
.viewer .slide.zoom { overflow: auto; touch-action: pan-x pan-y; display: block; }
.viewer .slide.zoom img { max-width: none; max-height: none; }
.viewer .nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.35); color: #fff; cursor: pointer; display: grid; place-items: center; transition: opacity .2s;
}
.viewer .nav-btn.prev { left: 12px; } .viewer .nav-btn.next { right: 12px; }
@media (max-width: 800px) { .viewer .nav-btn { display: none; } }
.viewer .spinner { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.info-panel {
  position: absolute; z-index: 4; right: 0; top: 0; bottom: 0; width: min(360px, 100%); background: var(--card); color: var(--text);
  padding: max(12px, env(safe-area-inset-top)) 20px 24px; overflow-y: auto; box-shadow: var(--shadow);
}
.info-panel h2 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; font-size: 18px; }
.info-panel .item { display: flex; gap: 14px; padding: 10px 0; }
.info-panel .item svg { color: var(--text-soft); }
.info-panel .item .sub { color: var(--text-soft); font-size: 13px; }
.info-panel .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.info-panel .chip { background: var(--bg-soft); padding: 4px 10px; border-radius: 999px; font-size: 13px; text-decoration: none; color: inherit; }
@media (max-width: 800px) { .info-panel { top: auto; height: 60%; width: 100%; border-radius: 20px 20px 0 0; } }
/* панель сведений как в Immich */
.info-head { display: flex; align-items: center; gap: 8px; margin: 0 -8px 8px; }
.info-head h2 { margin: 0; font-size: 18px; }
.info-panel .desc {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font: inherit;
  padding: 10px 0; resize: none; outline: none; overflow: hidden;
}
.info-panel .desc:focus { border-bottom-color: var(--accent); }
.info-panel .desc-ro { margin: 4px 0 8px; white-space: pre-wrap; }
.info-title { font-size: 13px; color: var(--text-soft); margin: 22px 0 6px; }
.info-panel .item { align-items: flex-start; }
.info-panel .item .grow { flex: 1; min-width: 0; }
.info-panel .item .name { word-break: break-all; }
.info-panel .item .sub { white-space: pre-wrap; }
.icon-btn.small { width: 34px; height: 34px; margin: -6px -6px 0 0; }
.icon-btn.small svg { width: 20px; height: 20px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.info-album { display: flex; align-items: center; gap: 14px; padding: 8px 0; color: var(--text); text-decoration: none; }
.info-album img, .info-album .ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--bg-soft); display: grid; place-items: center; flex: none; }
.info-album span { display: grid; }
.info-album .sub { font-size: 13px; color: var(--text-soft); }
.video-note { position: absolute; bottom: 80px; left: 0; right: 0; text-align: center; padding: 12px; }
.video-note a { color: #9cf; }
.viewer .bar .icon-btn { flex: none; }
@media (max-width: 800px) {
  .viewer .bar { gap: 0; overflow-x: auto; scrollbar-width: none; }
  .viewer .bar .icon-btn { width: 40px; height: 40px; }
}
.viewer.slideshow { cursor: none; }
.menu { max-height: calc(100vh - 16px); overflow-y: auto; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* редактор */
.editor { position: fixed; inset: 0; z-index: 120; background: #0b0c10; color: #fff; display: flex; flex-direction: column; }
.ed-bar { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
.ed-bar .ed-title { flex: 1; text-align: center; font-weight: 600; }
.ed-bar .btn.ghost { color: #fff; }
.ed-stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.ed-canvas-wrap { position: relative; line-height: 0; }
.ed-canvas-wrap.cropping canvas { filter: brightness(.55); }
.crop-box {
  position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.0); cursor: move; touch-action: none;
  background-image: linear-gradient(to right, transparent 33%, rgba(255,255,255,.35) 33%, rgba(255,255,255,.35) calc(33% + 1px), transparent calc(33% + 1px), transparent 66%, rgba(255,255,255,.35) 66%, rgba(255,255,255,.35) calc(66% + 1px), transparent calc(66% + 1px)),
    linear-gradient(to bottom, transparent 33%, rgba(255,255,255,.35) 33%, rgba(255,255,255,.35) calc(33% + 1px), transparent calc(33% + 1px), transparent 66%, rgba(255,255,255,.35) 66%, rgba(255,255,255,.35) calc(66% + 1px), transparent calc(66% + 1px));
  backdrop-filter: brightness(1.8);
}
.crop-box .h { position: absolute; width: 22px; height: 22px; border: 4px solid #fff; }
.crop-box .nw { left: -4px; top: -4px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.crop-box .ne { right: -4px; top: -4px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.crop-box .sw { left: -4px; bottom: -4px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.crop-box .se { right: -4px; bottom: -4px; border-left: 0; border-top: 0; cursor: nwse-resize; }
.ed-panel { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 10px; background: #14161c; }
.ed-tool { min-height: 52px; display: grid; align-items: center; justify-items: center; }
.ed-panel .chip { background: transparent; color: #ddd; border-color: #333; cursor: pointer; }
.ed-panel .chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.ed-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ed-buttons .btn { background: #22252e; color: #fff; }
.slider { display: grid; grid-template-columns: 120px 1fr 40px; align-items: center; gap: 12px; width: min(560px, 100%); font-size: 14px; }
.slider output { text-align: right; color: #aaa; }
.slider input { accent-color: var(--accent); }
.ed-tabs { display: flex; justify-content: center; gap: 4px; }
.ed-tab { display: grid; justify-items: center; gap: 2px; border: 0; background: none; color: #aaa; padding: 6px 16px; border-radius: 12px; cursor: pointer; font-size: 12px; }
.ed-tab.active { color: #fff; background: #22252e; }
@media (max-width: 800px) {
  .ed-bar .btn.primary span { display: none; }
  .slider { grid-template-columns: 96px 1fr 34px; }
}

@media (min-width: 801px) {
  .viewer.with-info { padding-right: 360px; }
  .viewer.with-info .bar { right: 360px; }
  .viewer.with-info .nav-btn.next { right: 372px; }
}

/* ---------------------------------------------------------------- диалоги и меню */
.backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.dialog {
  width: min(440px, 100%); max-height: min(80vh, 640px); overflow: auto; background: var(--card); color: var(--text);
  border-radius: 22px; padding: 22px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.dialog h2 { margin: 0; font-size: 19px; }
.dialog p { margin: 0; color: var(--text-soft); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dialog .list { display: grid; gap: 2px; max-height: 50vh; overflow: auto; margin: 0 -8px; }
.dialog .list button {
  display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; background: none; border-radius: 12px; cursor: pointer; text-align: left;
}
.dialog .list button:hover { background: var(--bg-hover); }
.dialog .list img, .dialog .list .ph { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--bg-soft); display: grid; place-items: center; }
.dialog .list .sub { font-size: 13px; color: var(--text-soft); }
@media (max-width: 800px) {
  .backdrop.sheet { align-items: end; padding: 0; }
  .backdrop.sheet .dialog { border-radius: 22px 22px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); width: 100%; }
}
.menu {
  position: fixed; z-index: 210; min-width: 220px; background: var(--card); color: var(--text); border-radius: 14px;
  box-shadow: var(--shadow); padding: 6px; display: grid;
}
.menu button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--bg-hover); }
.menu .head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .head .sub { font-size: 13px; color: var(--text-soft); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; background: #222630; color: #fff;
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
@media (max-width: 800px) { .toast { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); } }

/* ---------------------------------------------------------------- загрузка */
.uploads {
  position: fixed; right: 16px; bottom: 16px; z-index: 150; width: min(380px, calc(100% - 32px));
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
@media (max-width: 800px) { .uploads { right: 8px; left: 8px; width: auto; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); } }
.uploads .head { display: flex; align-items: center; gap: 8px; padding: 12px 8px 12px 16px; }
.uploads .head .title { flex: 1; font-weight: 600; }
.uploads .head .sub { font-size: 13px; color: var(--text-soft); font-weight: 400; }
.progress { height: 4px; background: var(--bg-soft); }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.uploads .items { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--line); }
.uploads .item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 14px; }
.uploads .item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploads .item .st { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.uploads .item.err .st { color: var(--danger); }
.uploads .item.done .st { color: #2e9e5b; }

.drop-zone {
  position: fixed; inset: 0; z-index: 400; background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 22px; font-weight: 600; color: var(--accent);
  pointer-events: none;
}

/* ---------------------------------------------------------------- настройки */
.settings { max-width: 720px; display: grid; gap: 20px; }
@media (max-width: 800px) { .settings { padding: 0 12px; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: grid; gap: 14px; }
.panel h2 { margin: 0; font-size: 17px; }
.panel .row-line { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.panel .row-line:first-of-type { border-top: 0; }
.panel .row-line .grow { flex: 1; min-width: 0; }
.panel .row-line .sub { font-size: 13px; color: var(--text-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stats div { background: var(--bg-soft); border-radius: 14px; padding: 14px; }
.stats b { display: block; font-size: 22px; }
.stats span { font-size: 13px; color: var(--text-soft); }

.loader { width: 36px; height: 36px; border: 3px solid rgba(127,127,127,.3); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
.viewer .loader { border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
