:root {
  --bg: #e6ebf0;
  --bg2: #f3f4f6;
  --sheet: #ffffff;
  --line: #e4e6ea;
  --text: #1d1f23;
  --muted: #80858d;
  --accent: #1d1f23;
  --accent-ink: #ffffff;
  --danger: #c8442f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light; }
body {
  margin: 0; color: var(--text); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  background: linear-gradient(160deg, #eef1f5, #dde4ea 60%, #e8edf1) fixed; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.wrap { width: min(1400px, 100%); margin: 0 auto; padding: clamp(0px, 2vw, 24px); }


.hero { padding: clamp(28px, 8vw, 90px) 0 clamp(18px, 4vw, 40px); }
.hero h1 { font: 400 clamp(2.2rem, 7vw, 4.6rem)/1.05 var(--serif); margin: 0; letter-spacing: -.01em; }
.hero p { color: var(--muted); margin: 14px 0 0; }

/* Картки галерей */
.cards { display: grid; padding-top: 6px; gap: clamp(12px, 2vw, 24px); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); padding-bottom: 20px; }
.card { position: relative; display: block; aspect-ratio: 4 / 5; overflow: hidden; background: var(--bg2); border-radius: 12px; opacity: 0; animation: rise .7s var(--ease) forwards; }
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ease), opacity .6s; }
.card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0) 55%); }
.card:hover img { transform: scale(1.05); }
.card h2 { position: absolute; z-index: 1; left: 18px; right: 18px; bottom: 16px; margin: 0; font: 400 1.45rem/1.15 var(--serif); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Галерея */
/* Перегляд на весь екран */
.lb { position: fixed; inset: 0; z-index: 50; background: rgba(255,255,255,.98); display: flex; flex-direction: column; opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility .35s; touch-action: none; }
.lb.open { opacity: 1; visibility: visible; }
.lb-top, .lb-bot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(12px, 3vw, 28px); padding-top: max(12px, env(safe-area-inset-top)); }
.lb-bot { justify-content: center; padding-top: 8px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.lb-count { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.lb-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { background: none; border: 0; color: var(--text); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; transition: background .2s; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 52px; height: 52px; font-size: 2rem; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
@media (hover: none) { .lb-nav { display: none; } }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); text-decoration: none; transition: background .2s, border-color .2s, transform .15s; }
.btn:hover { border-color: #b9bdc4; background: #fff; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 14px; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: default; }

.msg { padding: 60px 0; color: var(--muted); text-align: center; }
.msg.err { color: var(--danger); }
.spinner { width: 28px; height: 28px; margin: 60px auto; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 80; background: #1d1f23; color: #fff; padding: 12px 20px; border-radius: 999px; opacity: 0; transition: .3s var(--ease); pointer-events: none; max-width: 90vw; text-align: center; font-size: .95rem; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
footer { padding: 30px 0 50px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Адмінка */
.admin h1 { font: 400 2rem var(--serif); margin: 30px 0 4px; }
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin: 18px 0; }
.panel h2 { margin: 0 0 14px; font: 400 1.4rem var(--serif); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; color: var(--muted); font-size: .88rem; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=url] { width: 100%; padding: 12px 14px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font: inherit; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.grow > input { flex: 1; min-width: 200px; }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; max-height: 420px; overflow: auto; margin: 10px 0 16px; padding: 2px; }
.pick button { padding: 0; border: 0; background: var(--bg); border-radius: 4px; aspect-ratio: 1; overflow: hidden; position: relative; outline-offset: 0; }
.pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick button.sel { outline: 3px solid var(--accent); }
.pick button.sel::after { content: "Обкладинка"; position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 600; padding: 2px 0; text-align: center; }
.item { display: grid; grid-template-columns: 84px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); align-items: start; }
.item:first-of-type { border-top: 0; }
.item .thumb { width: 84px; height: 105px; object-fit: cover; border-radius: 4px; background: var(--bg); }
.item h3 { margin: 0 0 4px; font-size: 1.05rem; word-break: break-word; }
.item .meta { color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
.item .row { gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.login { max-width: 380px; margin: 14vh auto 0; }
.ok { color: var(--accent); }

/* Біла «картка» сторінки */
.sheet { background: var(--sheet); border-radius: clamp(0px, 2vw, 18px); box-shadow: 0 10px 40px rgba(40,55,75,.12); padding: 0 clamp(12px, 2.4vw, 32px) 40px; min-height: 100vh; }
@media (min-width: 700px) { .sheet { min-height: 0; } }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 0 18px; }
.bar .ttl { min-width: 0; }
.bar .ttl a, .bar .ttl b { display: block; font-size: .78rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .ttl small { display: block; font-size: .58rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.bar .icons { display: flex; gap: 2px; }
.bar .icon-btn { width: 40px; height: 40px; color: #555a63; }
.bar .icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.dl-box { margin: 4px auto 22px; max-width: 420px; text-align: center; }
.btn-big { display: block; width: 100%; padding: 16px 22px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 1.05rem; font-weight: 600; transition: transform .2s var(--ease), opacity .2s, box-shadow .2s; position: relative; overflow: hidden; box-shadow: 0 6px 18px rgba(20,25,35,.18); }
.btn-big:hover { box-shadow: 0 8px 24px rgba(20,25,35,.26); }
.btn-big:active { transform: scale(.985); }
.btn-big[disabled] { opacity: .85; cursor: progress; }
.btn-big .prog { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(255,255,255,.22); transition: width .25s; }
.btn-big span { position: relative; }
.hint { margin: 10px 4px 0; color: var(--muted); font-size: .86rem; }
.hint.err { color: var(--danger); }

.grid { display: flex; gap: 8px; align-items: flex-start; padding-bottom: 10px; }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tile { display: block; width: 100%; margin: 0; padding: 0; border: 0; background: #eceef1; overflow: hidden; aspect-ratio: var(--r, 1.5); cursor: zoom-in; contain: layout paint; border-radius: 12px; }
@media (max-width: 639px) { .tile { border-radius: 9px; } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s ease, transform .8s var(--ease); }
.tile img.on { opacity: 1; }
@media (hover: hover) { .grid:not(.is-scrolling) .tile:hover img { transform: scale(1.03); } }
.grid.is-scrolling .tile img { transition: opacity .25s ease; }

.hero { padding: clamp(24px, 7vw, 70px) 0 clamp(18px, 4vw, 34px); text-align: center; }
.hero h1 { font: 400 clamp(1.8rem, 5vw, 3rem)/1.1 var(--serif); margin: 0; }
.hero p { margin: 10px 0 0; color: var(--muted); }
.g-count { text-align: center; color: var(--muted); font-size: .85rem; margin: 0 0 16px; }

/* Екран входу: вузька картка по центру екрана */
body.login-mode .wrap { min-height: 100vh; display: grid; place-items: center; }
body.login-mode .sheet { width: min(400px, 100%); min-height: 0; padding: 36px 30px 32px; text-align: center; }
.login { margin: 0; max-width: none; }
.login h1 { margin: 0 0 22px; }
.login .field { text-align: left; }
.login .btn { width: 100%; justify-content: center; padding: 14px; }
.login .hint { min-height: 1.3em; text-align: center; }
.lock-ico { font-size: 1.6rem; margin-bottom: 8px; }
.login .field input { text-align: center; letter-spacing: .06em; }
.item .pw { font-size: .88rem; margin-bottom: 10px; color: var(--muted); }
.item .pw code { font: 600 .95rem ui-monospace, Consolas, monospace; color: var(--text); background: var(--bg2); padding: 2px 8px; border-radius: 6px; user-select: all; }

/* Слайди перегляду */
.lb-stage { cursor: grab; touch-action: pan-y; }
.lb-stage:active { cursor: grabbing; }
.lb-track { position: absolute; inset: 0; will-change: transform; }
.lb-slide { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 clamp(0px, 5vw, 72px); will-change: transform; }
.lb-slide img { grid-area: 1 / 1; max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.lb-slide img:not([src]) { visibility: hidden; }
.lb-slide .hi { opacity: 0; transition: opacity .5s ease; }
.lb-slide .hi.on { opacity: 1; }
.lb.open .lb-slide .lo { animation: lbIn .5s cubic-bezier(.22,.9,.28,1); }
@keyframes lbIn { from { opacity: 0; transform: scale(.965); } to { opacity: 1; transform: none; } }

/* Екран пароля клієнта: спокійний, з рівним ритмом відступів */
body.login-mode .sheet:has(.lock) { width: min(440px, calc(100% - 32px)); padding: 52px 44px 44px; border-radius: 22px; box-shadow: 0 24px 70px rgba(40,55,75,.16), 0 2px 8px rgba(40,55,75,.06); }
.lock { display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.lock-ico { width: 54px; height: 54px; margin: 0 auto 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg2); color: #3b3f46; }
.lock-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.lock-brand { font-size: .68rem; font-weight: 600; letter-spacing: .26em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.lock h1 { font: 400 clamp(1.7rem, 6vw, 2.1rem)/1.15 var(--serif); margin: 0 0 14px; letter-spacing: -.005em; word-break: break-word; }
.lock-hint { margin: 0 0 30px; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.lock input { width: 100%; height: 54px; padding: 0 18px; margin: 0 0 14px; text-align: center; font-size: 1.05rem; letter-spacing: .08em; background: #fff; border: 1px solid #d5d9df; border-radius: 14px; transition: border-color .2s, box-shadow .2s; }
.lock input::placeholder { letter-spacing: .02em; color: #a5aab2; }
.lock input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 4px rgba(29,31,35,.08); }
.lock .btn { width: 100%; height: 54px; padding: 0; justify-content: center; font-size: 1rem; border-radius: 14px; }
.lock-err { min-height: 1.4em; margin: 16px 0 0; font-size: .88rem; color: var(--danger); }

/* ---- Анімації наведення та натискання ---- */
.btn, .btn-big, .icon-btn, .tile, .card { position: relative; overflow: hidden; }
.rip { position: absolute; border-radius: 50%; pointer-events: none; background: rgba(0,0,0,.07); transform: scale(0); opacity: .9; animation: rip 1s cubic-bezier(.25,.6,.3,1) forwards; z-index: 3; }
.btn.primary .rip, .btn-big .rip, .tile .rip, .card .rip { background: rgba(255,255,255,.26); }
@keyframes rip { to { transform: scale(1); opacity: 0; } }

.btn, .btn-big, .icon-btn { transition: transform .4s var(--ease), box-shadow .4s var(--ease), background-color .3s, border-color .3s, opacity .3s; }
.tile { transition: transform .5s var(--ease), box-shadow .5s var(--ease); }
.card { transition: transform .6s var(--ease), box-shadow .6s var(--ease); }
.tile::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s; background: linear-gradient(to top, rgba(0,0,0,.22), rgba(0,0,0,0) 45%); }

@media (hover: hover) {
  .btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(20,25,35,.07); }
  .btn.primary:hover { box-shadow: 0 8px 20px rgba(20,25,35,.22); }
  .btn-big:hover { transform: translateY(-1px); }
  .icon-btn:hover { transform: scale(1.05); }
  .lb-nav:hover { transform: translateY(-50%) scale(1.1); }
  .card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(30,40,55,.14); }
  .grid:not(.is-scrolling) .tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(30,40,55,.14); z-index: 2; }
  .grid:not(.is-scrolling) .tile:hover::after { opacity: 1; }
  .item .thumb { transition: transform .35s var(--ease); }
  .item:hover .thumb { transform: scale(1.04); }
  .pick button { transition: transform .2s var(--ease); }
  .pick button:hover { transform: scale(1.06); }
}
/* Натискання/тап: «втискання» */
.btn:active, .btn-big:active { transform: scale(.985); box-shadow: none; }
.icon-btn:active { transform: scale(.94); }
.tile:active { transform: scale(.985); }
.card:active { transform: scale(.992); }
.pick button:active { transform: scale(.96); }
.lb-nav:active { transform: translateY(-50%) scale(.92); }

.icon-btn.lb-nav { position: absolute; }

/* ---- Перемикач теми: сонце ↔ місяць ---- */
.theme-switch { position: relative; flex: none; align-self: center; width: 58px; height: 30px; margin: 0 8px; padding: 0; border: 0; border-radius: 999px; cursor: pointer; overflow: hidden;
  background: linear-gradient(180deg, #7fc0ff, #bfe2ff); box-shadow: inset 0 1px 3px rgba(20,60,110,.28), 0 1px 0 rgba(255,255,255,.5);
  transition: background .6s var(--ease), box-shadow .6s; -webkit-tap-highlight-color: transparent; }
.theme-switch:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.ts-knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #ffd45c; overflow: hidden;
  box-shadow: 0 0 0 3px rgba(255,212,92,.38), 0 2px 6px rgba(0,0,0,.25);
  transition: transform .65s cubic-bezier(.68,-.3,.27,1.25), background .5s, box-shadow .6s; }
.ts-crater { position: absolute; border-radius: 50%; background: rgba(110,120,145,.38); width: 7px; height: 7px; left: 12px; top: 4px; opacity: 0; transform: scale(.4); transition: opacity .4s .15s, transform .5s .15s; }
.ts-crater.c2 { width: 5px; height: 5px; left: 6px; top: 13px; }
.ts-cloud { position: absolute; right: 7px; bottom: 5px; width: 17px; height: 7px; border-radius: 8px; background: #fff; box-shadow: -7px -3px 0 -1px #fff, -2px -5px 0 -2px #fff;
  transition: transform .6s var(--ease), opacity .4s; }
.ts-stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; opacity: 0; transform: scale(0); transition: opacity .4s, transform .5s; }
.ts-stars i:nth-child(1) { left: 9px; top: 8px; } .ts-stars i:nth-child(2) { left: 17px; top: 19px; width: 1.5px; height: 1.5px; }
.ts-stars i:nth-child(3) { left: 27px; top: 7px; } .ts-stars i:nth-child(4) { left: 21px; top: 13px; width: 1.5px; height: 1.5px; }
@media (hover: hover) { .theme-switch:hover .ts-knob { box-shadow: 0 0 0 5px rgba(255,212,92,.32), 0 2px 8px rgba(0,0,0,.28); } }
.theme-switch:active .ts-knob { width: 28px; }

html[data-theme=dark] .theme-switch { background: linear-gradient(180deg, #2a3346, #1b2130); box-shadow: inset 0 1px 4px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.06); }
html[data-theme=dark] .ts-knob { transform: translateX(28px); background: #e4e8f1; box-shadow: 0 0 0 3px rgba(228,232,241,.14), 0 2px 6px rgba(0,0,0,.45); }
html[data-theme=dark] .theme-switch:active .ts-knob { transform: translateX(24px); }
html[data-theme=dark] .ts-crater { opacity: 1; transform: none; }
html[data-theme=dark] .ts-cloud { transform: translateY(16px); opacity: 0; }
html[data-theme=dark] .ts-stars i { opacity: .95; transform: scale(1); animation: twinkle 3s ease-in-out infinite; }
html[data-theme=dark] .ts-stars i:nth-child(2) { animation-delay: .7s; } html[data-theme=dark] .ts-stars i:nth-child(3) { animation-delay: 1.4s; } html[data-theme=dark] .ts-stars i:nth-child(4) { animation-delay: 2.1s; }
@keyframes twinkle { 0%, 100% { opacity: .95; } 50% { opacity: .25; } }
@media (hover: hover) { html[data-theme=dark] .theme-switch:hover .ts-knob { box-shadow: 0 0 0 5px rgba(228,232,241,.16), 0 2px 8px rgba(0,0,0,.5); } }

/* Перехід теми «кругом» від місця натискання */

/* ---- Темна тема: м'який графіт із синюватим відтінком, не чорний ---- */
html[data-theme=dark] {
  color-scheme: dark;
  --bg: #1d2128;
  --bg2: #2d333c;
  --sheet: #262b33;
  --line: #373e49;
  --text: #eceef2;
  --muted: #99a1ad;
  --accent: #ebe6dc;
  --accent-ink: #1c2027;
  --danger: #f08d7d;
}
html[data-theme=dark] body { background: linear-gradient(160deg, #1b1f26, #21262e 55%, #1c2027) fixed; }
html[data-theme=dark] .sheet { box-shadow: 0 14px 50px rgba(0,0,0,.35); }
html[data-theme=dark] .lb { background: rgba(31,35,43,.985); }
html[data-theme=dark] .tile, html[data-theme=dark] .lb-slide { background-color: transparent; }
html[data-theme=dark] .tile { background: #323944; }
html[data-theme=dark] .btn:hover { background: #3a414d; border-color: #505967; }
html[data-theme=dark] .btn.primary:hover { background: #f4efe6; }
html[data-theme=dark] .btn.danger { color: var(--danger); }
html[data-theme=dark] .bar .icon-btn { color: #b6bdc8; }
html[data-theme=dark] .icon-btn:hover { background: rgba(255,255,255,.09); }
html[data-theme=dark] .lock-ico { color: #cfd4dc; }
html[data-theme=dark] .lock input { background: #2d333c; border-color: #414957; color: var(--text); }
html[data-theme=dark] .lock input::placeholder { color: #7c8593; }
html[data-theme=dark] .lock input:focus { border-color: #b9c0cc; box-shadow: 0 0 0 4px rgba(233,228,218,.1); }
html[data-theme=dark] input[type=text], html[data-theme=dark] input[type=password], html[data-theme=dark] input[type=url] { background: #21262d; border-color: var(--line); color: var(--text); }
html[data-theme=dark] .toast { background: #ebe6dc; color: #1c2027; }
html[data-theme=dark] .btn-big { box-shadow: 0 6px 20px rgba(0,0,0,.3); }
html[data-theme=dark] .btn-big .prog { background: rgba(0,0,0,.14); }
html[data-theme=dark] .rip { background: rgba(255,255,255,.09); }
html[data-theme=dark] .btn.primary .rip, html[data-theme=dark] .btn-big .rip { background: rgba(0,0,0,.1); }
html[data-theme=dark] .tile .rip, html[data-theme=dark] .card .rip { background: rgba(255,255,255,.2); }
html[data-theme=dark] .card:hover { box-shadow: 0 18px 40px rgba(0,0,0,.4); }
html[data-theme=dark] .grid:not(.is-scrolling) .tile:hover { box-shadow: 0 12px 28px rgba(0,0,0,.4); }
html[data-theme=dark] .item .pw code { background: #323944; }
html[data-theme=dark] .pick button.sel { outline-color: var(--accent); }
html[data-theme=dark] .spinner, html[data-theme=dark] .lb-spin { border-color: var(--line); border-top-color: var(--accent); }

/* ---- Ніжніший перемикач теми: плавний рух без «пружинки» ---- */
.theme-switch { transition: background .9s ease, box-shadow .9s ease; }
.ts-knob { transition: transform .85s cubic-bezier(.45, .05, .25, 1), background .8s ease, box-shadow .8s ease; }
.ts-cloud { transition: transform .9s ease, opacity .7s ease; }
.ts-crater { transition: opacity .7s .2s ease, transform .8s .2s ease; }
.ts-stars i { transition: opacity .8s .15s ease, transform .8s .15s ease; }
.theme-switch:active .ts-knob { width: 24px; }
html[data-theme=dark] .theme-switch:active .ts-knob { transform: translateX(28px); }
html[data-theme=dark] .ts-stars i { animation-duration: 4.5s; }

/* Плавна зміна теми: кольори «перетікають», рух перемикача не чіпаємо */
html.theme-anim *:not(.theme-switch):not(.ts-knob):not(.ts-cloud):not(.ts-crater):not(.ts-stars):not(.ts-stars i),
html.theme-anim *::before, html.theme-anim *::after {
  transition-property: background-color, background-image, border-color, color, box-shadow, fill, stroke, opacity;
  transition-duration: .8s; transition-timing-function: ease; transition-delay: 0s;
}

/* ---- Режим вибору ---- */
.sel-row { display: flex; gap: 10px; justify-content: center; margin: -6px 0 22px; }
.tile .check { position: absolute; top: 9px; left: 9px; z-index: 2; width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(255,255,255,.95); background: rgba(0,0,0,.2); display: grid; place-items: center; opacity: 0; transform: scale(.6); transition: opacity .35s ease, transform .45s var(--ease), background-color .3s, border-color .3s; pointer-events: none; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.tile .check svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .4s ease .05s; }
.grid.selecting .tile .check { opacity: 1; transform: none; }
.grid.selecting .tile { cursor: pointer; }
.tile.sel .check { background: var(--accent); border-color: var(--accent); }
.tile.sel .check svg { stroke: var(--accent-ink); stroke-dashoffset: 0; }
.tile img { transition: opacity .35s ease, transform .5s var(--ease), border-radius .4s var(--ease); }
html .grid.selecting .tile.sel img, html .grid.selecting .tile.sel:hover img { transform: scale(.9) !important; border-radius: 10px; }
html .grid.selecting .tile:hover img { transform: none; }
.grid.selecting { padding-bottom: 130px; }

.sel-bar { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 40; width: min(600px, calc(100% - 24px)); padding: 10px 10px 10px 20px; border-radius: 20px; background: var(--sheet); box-shadow: 0 14px 44px rgba(20,30,45,.28), 0 0 0 1px var(--line);
  transform: translate(-50%, 150%); opacity: 0; visibility: hidden; transition: transform .7s var(--ease), opacity .5s ease, visibility .7s; }
.sel-bar.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.sel-top { display: flex; align-items: center; gap: 12px; }
.sel-info { display: flex; flex-direction: column; line-height: 1.15; min-width: 74px; }
.sel-info b { font: 400 1.5rem/1 var(--serif); }
.sel-info span { font-size: .72rem; color: var(--muted); margin-top: 3px; max-width: 110px; }
.sel-bar .btn-big { width: auto; flex: 1; padding: 15px 18px; font-size: 1rem; box-shadow: none; }
.sel-bar .hint { margin: 8px 4px 2px; text-align: center; }
.sel-bar .hint:empty { display: none; }
html[data-theme=dark] .sel-bar { box-shadow: 0 14px 44px rgba(0,0,0,.5), 0 0 0 1px var(--line); }

.link-btn { display: block; margin: 12px auto 0; padding: 4px 8px; border: 0; background: none; color: var(--muted); font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent); cursor: pointer; transition: color .25s; }
.link-btn:hover { color: var(--text); }
.link-btn[hidden] { display: none; }
.sel-foot { text-align: center; }
.sel-foot .link-btn { margin-top: 4px; }

/* ---- Знак оклику біля небезпечної дії, вікно підтвердження, картка «Зупинити» ---- */
.warn-ico { width: 15px; height: 15px; margin: -2px 6px 0 0; vertical-align: middle; fill: none; stroke: #c98a1b; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme=dark] .warn-ico { stroke: #e0a94a; }
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(18,24,34,.42); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); opacity: 0; transition: opacity .3s ease; }
.modal.on { opacity: 1; }
.modal-card { width: min(420px, 100%); padding: 30px 28px 24px; border-radius: 22px; background: var(--sheet); color: var(--text); text-align: center; box-shadow: 0 30px 80px rgba(10,15,25,.35);
  transform: translateY(14px) scale(.97); transition: transform .45s var(--ease); }
.modal.on .modal-card { transform: none; }
.modal-ico { width: 46px; height: 46px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; font: 700 1.4rem/1 var(--sans); color: #b97a12; background: rgba(224,169,74,.18); }
.modal-card h3 { margin: 0 0 10px; font: 400 1.45rem/1.2 var(--serif); }
.modal-card p { margin: 0; color: var(--muted); font-size: .93rem; line-height: 1.55; }
.modal-card p b { color: var(--text); font-weight: 600; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; justify-content: center; padding: 13px 10px; }
.run-count { font: 400 2rem/1 var(--serif); color: var(--text) !important; margin: 6px 0 18px !important; font-variant-numeric: tabular-nums; }
.run-bar { height: 6px; border-radius: 6px; background: var(--bg2); overflow: hidden; margin-bottom: 22px; }
.run-bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--accent); transition: width .35s ease; }
.modal-card .btn-big.stop { width: 100%; box-shadow: none; }
.modal-card .hint { margin-top: 14px; }
.modal-card .run-count { font-size: 2.1rem; }

/* ---- Адмін у своєму браузері ---- */
.admin-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; margin: 0 0 16px; padding: 10px 14px; border-radius: 14px; background: var(--bg2); font-size: .82rem; color: var(--muted); }
.admin-strip code { font: 600 .9rem ui-monospace, Consolas, monospace; color: var(--text); background: var(--sheet); padding: 3px 9px; border-radius: 8px; user-select: all; }
.card .pill { position: absolute; top: 12px; right: 12px; z-index: 2; padding: 4px 11px; border-radius: 999px; background: rgba(15,20,28,.62); color: #fff; font-size: .7rem; letter-spacing: .04em; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* ---- Адмінка: два бокси на всю ширину, весь блок по центру екрана ---- */
.admin .wrap { min-height: 100vh; display: grid; place-items: center; }
.admin .sheet { width: min(1400px, 100%); min-height: 0; }
.admin-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.admin-grid .panel { margin: 0; }
.item.new { animation: itemIn .8s var(--ease) both; }
@keyframes itemIn { from { opacity: 0; transform: translateY(-10px) scale(.98); background: color-mix(in srgb, var(--accent) 12%, transparent); } to { opacity: 1; transform: none; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }



.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: .8rem; }

/* ---- Вікно «Повідомлення клієнту» ---- */
.modal-card.wide { width: min(560px, 100%); text-align: left; }
.modal-card.wide h3 { text-align: center; }
.modal-sub { text-align: center; margin: 0 0 18px !important; }
.msg-preview { white-space: pre-wrap; word-break: break-word; padding: 16px 18px; border-radius: 14px; background: var(--bg2); color: var(--text); font-size: .95rem; line-height: 1.6; max-height: 52vh; overflow: auto; user-select: all; }
.msg-edit { margin-top: 14px; color: var(--muted); font-size: .88rem; }
.msg-edit summary { cursor: pointer; padding: 4px 0; }
.msg-edit textarea { width: 100%; margin-top: 8px; padding: 12px 14px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: .9rem; line-height: 1.5; resize: vertical; }
.msg-edit textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.chips button { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg2); color: var(--text); font: inherit; font-size: .8rem; cursor: pointer; }
.chips .reset { margin-left: auto; color: var(--muted); }

/* ---- Картка галереї в адмінці: інформація + два окремі блоки ---- */
.item { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 22px; padding: 22px 0; border-top: 1px solid var(--line); align-items: start; }
.item:first-child { border-top: 0; padding-top: 6px; }
.item .thumb { width: 132px; height: 165px; object-fit: cover; border-radius: 12px; background: var(--bg); }
.gbody { min-width: 0; }
.ghead { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.ghead h3 { margin: 0 0 6px; font: 400 1.45rem/1.2 var(--serif); word-break: break-word; }
.meta { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .82rem; color: var(--muted); }
.meta::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5aa57a; }
.meta.is-hidden::before { background: #c98a1b; }
.reorder { display: flex; gap: 6px; flex: none; }
.icon-mini { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 1rem; line-height: 1; transition: background .25s, opacity .25s, transform .25s var(--ease); }
.icon-mini:hover:not([disabled]) { background: var(--bg2); transform: translateY(-1px); }
.icon-mini[disabled] { opacity: .3; cursor: default; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 14px 0 18px; }
.facts .pw { margin: 0; display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.gblocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.gblock { padding: 16px 18px 18px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); }
.gblock.share { background: color-mix(in srgb, var(--accent) 5%, var(--bg)); }
.gblock h4 { margin: 0 0 12px; font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.gbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.gbtns .btn { flex: 0 1 auto; }
.gbtns .push { margin-left: auto; }
.cover-box { margin-top: 14px; }
@media (max-width: 860px) {
  .gblocks { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .item { grid-template-columns: 88px minmax(0, 1fr); gap: 14px; }
  .item .thumb { width: 88px; height: 110px; }
  .ghead h3 { font-size: 1.2rem; }
}
.facts .pw span { white-space: nowrap; }
@media (max-width: 560px) {
  .facts { flex-direction: column; gap: 6px; }
  .gbtns .btn { flex: 1 1 calc(50% - 8px); justify-content: center; text-align: center; }
  .gbtns .push { margin-left: 0; }
  .gblock { padding: 14px; }
}

/* Перегляд: велике фото завжди повністю вміщується, без обрізання. Мініатюра і велика версія займають однаковий блок. */
.lb-slide { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.lb-slide img { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; }

/* ---- Картка галереї: назва зверху, посередині мініатюра + блоки, внизу пароль і назви файлів ---- */
#list { display: grid; gap: 16px; }
.item { display: block; padding: 22px 24px 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); }
.item:first-child { padding-top: 22px; border-top: 1px solid var(--line); }
.ihead { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.item .ghead { display: none; }
.imid { display: grid; grid-template-columns: minmax(180px, 300px) minmax(0, 1fr); gap: 22px; align-items: center; }
.item .thumb { width: 100%; height: auto; max-height: 320px; object-fit: contain; display: block; border-radius: 14px; background: var(--bg2); }
.imid .gblocks { grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: center; }
.gblock { background: var(--sheet); }
.gblock.share { background: color-mix(in srgb, var(--accent) 6%, var(--sheet)); }
.item .facts { justify-content: center; margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .imid { grid-template-columns: 1fr; gap: 16px; }
  .item .thumb { max-height: 260px; margin: 0 auto; }
}
@media (max-width: 560px) {
  .item { padding: 16px 14px; }
  .item .thumb { width: 100%; height: auto; }
}

/* Уточнення картки галереї */
.ihead h3 { margin: 0 0 6px; font: 400 1.6rem/1.2 var(--serif); word-break: break-word; }
.imid { grid-template-columns: max-content minmax(0, 1fr); }
.item .thumb { width: auto; max-width: min(320px, 100%); height: auto; max-height: 320px; background: none; }
.gblock { min-width: 0; }
.gbtns .btn { min-width: 0; white-space: normal; text-align: center; }
@media (max-width: 760px) {
  .imid { grid-template-columns: minmax(0, 1fr); justify-items: stretch; }
  .item .thumb { max-width: 100%; max-height: 280px; margin: 0 auto; }
}
.facts .pw { flex-wrap: wrap; min-width: 0; }
.facts code { overflow-wrap: anywhere; white-space: normal; max-width: 100%; }
.ihead .gtitle { min-width: 0; }

/* Блоки заповнюють висоту мініатюри, кнопки — рівною сіткою (без порожнього місця) */
.imid { align-items: stretch; }
.imid .gblocks { grid-template-rows: minmax(auto, 2fr) minmax(auto, 3fr); align-content: stretch; }
.gblock { display: flex; flex-direction: column; }
.gbtns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(42px, 1fr); gap: 10px; flex: 1; }
.gbtns .btn { width: 100%; height: 100%; justify-content: center; padding: 8px 12px; font-size: .9rem; }
.gbtns .push { grid-column: 1 / -1; margin-left: 0; }
@media (max-width: 760px) { .imid .gblocks { grid-template-rows: auto auto; } }

.imid .thumb { align-self: center; }

/* Обкладинка в рамці: фото вписане повністю (будь-які пропорції), тло — його ж розмита копія */
.imid { grid-template-columns: minmax(220px, 340px) minmax(0, 1fr); }
.thumbwrap { position: relative; overflow: hidden; isolation: isolate; border-radius: 16px; min-height: 260px; background: var(--bg2); align-self: stretch; }
.thumbwrap::before { content: ""; position: absolute; inset: -30px; z-index: -1; background: var(--cover) center / cover no-repeat; filter: blur(26px) saturate(1.15); opacity: .6; }
.thumbwrap .thumb { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); max-width: none; max-height: none; margin: 0; object-fit: contain; border-radius: 10px; filter: drop-shadow(0 6px 18px rgba(0,0,0,.35)); }
@media (max-width: 760px) {
  .imid { grid-template-columns: minmax(0, 1fr); }
  .thumbwrap { min-height: 0; height: 250px; }
}

/* ---- Вікна введення в адмінці та стан «завантажується» ---- */
.ask-input { display: block; width: 100%; margin: 10px 0 4px; padding: 14px 16px; font-size: 1.02rem; }
.ask-hint { margin: 8px 2px 0; font-size: .84rem; color: var(--muted); text-align: left; word-break: break-word; }
.ask-tools { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.btn.danger-solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.busy { pointer-events: none; opacity: .9; }
.btn.busy::before { content: ""; width: 14px; height: 14px; margin-right: 9px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }

/* Клік по паролю копіює його */
code.copyable { cursor: pointer; user-select: none; transition: background .25s, box-shadow .25s, color .25s; }
code.copyable:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
code.copyable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code.copyable.copied { background: var(--accent); color: var(--accent-ink); box-shadow: none; }

/* Формат пароля в повідомленні */
.msg-fmt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 14px; font-size: .85rem; color: var(--muted); }
.msg-fmt label { display: inline-flex; align-items: center; gap: 6px; color: var(--text); cursor: pointer; }
.msg-fmt input { accent-color: var(--accent); }
.msg-fmt-note { margin: 8px 0 0 !important; font-size: .8rem !important; line-height: 1.5; text-align: left; }

.kind-select { padding: 0 12px; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; font-size: .88rem; }
.ask-tools .kind-select { height: 36px; }
