:root{
  --bg0:#0b0f12;
  --bg1:#0f1820;
  --bg2:#101a22;
  --panel:#141e27;
  --panel2:#1a2732;
  --line:#233341;
  --accent:#c4008f;
  --accent2:#ff3aa8;
  --accent-rgb:196,0,143;
  --text:#e9f1f6;
  --muted:#b3c0cc;
  --good:#44d07b;
  --warn:#ffb86b;
  --bad:#ff5a6a;
  --shadow:0 12px 30px rgba(0,0,0,.35);
  --thumb:120px;
}

@font-face{
  font-family: "TTNormsTochkaExt";
  src: url("/Fonts/TTNormsDemiBold.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

*{ box-sizing:border-box; }
html,body{ height:100%; background:#0b0f12; }
body{
  margin:0;
  font-family: "TTNormsTochkaExt", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(900px 700px at 70% 15%, rgba(var(--accent-rgb),0.25), transparent 60%),
              radial-gradient(1000px 800px at 10% 85%, rgba(12,95,200,0.15), transparent 60%),
              linear-gradient(180deg, var(--bg0), var(--bg1) 40%, var(--bg2));
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}
body.gallery,
body.gallery *{
  /* pan-x pan-y: прокрутка ленты работает, а зум двумя пальцами и
     двойным касанием браузер не делает (было manipulation - зум проходил) */
  touch-action: pan-x pan-y;
}
html:has(body.gallery){ touch-action: pan-x pan-y; }
img{ -webkit-user-drag: none; user-select: none; pointer-events:none; }
video{ pointer-events:none; }
*{ -webkit-touch-callout: none; }

/* ============ ADMIN ============ */
body.admin{ background:#0b0f12; }
.adminWrap{ max-width:1100px; margin:0 auto; padding:20px 18px 50px; }
body.admin.sharingPage .adminWrap{ max-width: 1400px; }
.hTitle{ font-size:24px; font-weight:600; }
.subTitle{ font-size:13px; opacity:.78; margin-top:2px; }
.card{
  background: rgba(20,30,39,0.9);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 16px 18px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}

details.acc{
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  margin-top: 12px;
  background: rgba(12,18,24,0.6);
}
details.acc > summary{
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
}
details.acc > summary::-webkit-details-marker{ display:none; }
details.acc > summary::after{
  content: "›";
  float: right;
  transform: rotate(0deg);
  transition: transform .15s ease;
  opacity: .7;
}
details.acc[open] > summary::after{
  transform: rotate(90deg);
}
details.acc[open] > summary{
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
details.acc .card{
  margin-top: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.card h2{ margin:0 0 10px 0; font-size:18px; }

.grid2{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.grid3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; }
@media (max-width: 960px){ .grid3{ grid-template-columns:1fr; } }
@media (max-width: 840px){ .grid2{ grid-template-columns:1fr; } }

.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.row.end{ justify-content:flex-end; width:100%; }

label{ display:flex; flex-direction:column; gap:6px; font-size:13px; opacity:.95; }
input, select, button, textarea{ font:inherit; }
input, select, textarea{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.25);
  color: #fff;
  outline: none;
}
textarea{ min-height: 70px; resize: vertical; }
#tgCaption.tgLargeField,
#tgWelcome.tgLargeField{ min-height: 120px; }

button{
  padding: 12px 14px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  background: rgba(255,255,255,0.14);
  color: #fff;
}
button.primary{ background: var(--accent); }
button.ghost{ background: rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.12); }
button.danger{ background: rgba(255,80,80,0.24); border:1px solid rgba(255,80,80,0.5); }
button:active{ transform: translateY(1px); }
.status{ margin-top:10px; font-size:13px; opacity:.9; }
.smallHint{ font-size:12px; opacity:.75; line-height:1.35; }

/* ============ GALLERY ============ */
body.gallery{
  overflow:hidden;
  --grid-cols: 10;
  --grid-rows: 2;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

#galleryRoot{
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

#bgLayer{
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
#bgLayerViewer{
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.bgMedia{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit: cover;
  filter: saturate(1.1) contrast(1.05);
}
.bgImage{
  object-fit: contain;
  filter: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  image-rendering: auto;
}
.bgVideo{ object-fit: cover; }
.bgShade{
  position:absolute;
  inset:0;
  background: radial-gradient(900px 700px at 70% 10%, rgba(var(--accent-rgb),0.32), transparent 60%),
              linear-gradient(180deg, rgba(8,12,16,0.85), rgba(8,12,16,0.6));
}
body.has-bg{
  background: #0b0f12;
}
body.has-bg .bgShade{
  background: none;
}
body.has-bg .viewer{
  background: transparent;
}

.topBar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 14px;
  background: rgba(12,18,24,0.72);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 2;
  backdrop-filter: blur(10px);
}
.topBar.hidden{ display:none; }

.tabs{
  display:flex;
  width: 100%;
  gap: 0;
  background: rgba(0,0,0,0.3);
  border:1px solid var(--line);
  border-radius: 10px;
  overflow:hidden;
}
.tab{
  flex:1 1 0;
  text-align:center;
  padding: 12px 10px;
  font-weight:600;
  background: #0f0f0f;
  color: #fff;
  border-right:1px solid rgba(255,255,255,0.06);
}
.tab.active{
  background: var(--accent);
  color: #fff;
}
.tab:last-child{ border-right:0; }

.deviceBtns{ display:flex; gap:10px; align-items:center; }
.deviceBtn{
  width:36px; height:36px; border-radius:999px; background: var(--accent);
  display:inline-flex; align-items:center; justify-content:center; font-weight:700;
}
.deviceBtn.hidden{ display:none; }

.listWrap{
  overflow:auto;
  padding: 0 14px 24px;
  z-index: 2;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  height: 100%;
}
.listWrap::-webkit-scrollbar{ width: 10px; }
.listWrap::-webkit-scrollbar-track{ background: rgba(0,0,0,0.2); }
.listWrap::-webkit-scrollbar-thumb{
  background: linear-gradient(180deg, rgba(var(--accent-rgb),0.92), rgba(var(--accent-rgb),0.68));
  border-radius: 10px;
}
.listWrap{ scrollbar-width: thin; scrollbar-color: var(--accent) rgba(0,0,0,0.2); }

.grid{
  --grid-gap: 14px;
  display:grid;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows), var(--grid-row-h, 180px));
  grid-auto-flow: row;
  grid-auto-rows: var(--grid-row-h, 180px);
  gap: var(--grid-gap);
  height: auto;
  min-height: 100%;
  align-content: start;
  margin-top: -15px;
}

.cardItem{
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  box-shadow: none;
  position: relative;
  transition: transform .18s ease;
  content-visibility: auto;
  contain-intrinsic-size: 240px 320px;
  height: 100%;
  display: flex;
}
.cardItem:hover{
  transform: translateY(-2px);
}

.tabsRow{
  display:flex;
  gap: 8px;
  margin-bottom: 12px;
}
.tabBtn{
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}
.tabBtn.active{
  background: var(--accent);
}
.tabPanel{
  border: 1px dashed rgba(255,255,255,0.1);
  padding: 12px;
  border-radius: 12px;
}
.shareToggleRow{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items:end;
}
.switchLine{
  display:flex;
  flex-direction: row;
  align-items:center;
  gap: 8px;
  min-height: 42px;
}
.switchLine input[type="checkbox"]{
  width: 18px;
  height: 18px;
  margin: 0;
}
.shareFields{
  margin-top: 10px;
}
.tabPanel .smallHint{
  margin-top: 8px;
}
@media (max-width: 960px){
  .shareToggleRow{ grid-template-columns: 1fr; }
}
.divider{
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 12px 0;
}

.sharingTableWrap{
  overflow: hidden;
  margin-top: 10px;
}
.sharingTable{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.sharingTable th{
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  font-size: 13px;
}
.sharingPage .card{
  border-color: rgba(var(--accent-rgb),0.4);
  box-shadow: 0 10px 24px rgba(0,0,0,0.25), 0 0 0 1px rgba(var(--accent-rgb),0.15);
}
.sharingPage .sharingTable th{
  border-bottom-color: rgba(var(--accent-rgb),0.45);
}
.sharingPage .hTitle{
  color: var(--accent);
}
.sharingTable .cell{
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  vertical-align: top;
  font-size: 13px;
}
.sharingTable .cell.status{ font-weight: 600; }
.sharingTable .cell.error,
.sharingTable .cell.content,
.sharingTable .cell.contact{
  word-break: break-word;
  white-space: normal;
}
.sharingTable .cell.time{ white-space: nowrap; }
.sharingTable .cell.empty{ opacity: .8; text-align: center; }
.cardItem:after{
  content:"";
  position:absolute;
  inset:0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  pointer-events:none;
}
.cardMedia{
  width:100%;
  height:100%;
  aspect-ratio: auto;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.cardMedia.videoPreview{
  position: relative;
  overflow: hidden;
  background-color: #0f1820;
}
.cardVideo{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  background: #0f1820;
}

.badge{
  padding: 2px 8px;
  border-radius: 999px;
  font-size:11px;
  background: rgba(255,255,255,0.1);
}

.viewer{
  position: fixed;
  inset: 0;
  background: radial-gradient(900px 700px at 70% 10%, rgba(var(--accent-rgb),0.28), transparent 60%),
              radial-gradient(1000px 800px at 10% 85%, rgba(12,95,200,0.15), transparent 60%),
              linear-gradient(180deg, var(--bg0), var(--bg1) 40%, var(--bg2));
  display: none;
  --actions-h: 84px;
  --thumbs-h: calc(var(--thumb) * 1.6 + 2px);
  grid-template-rows: minmax(0, 1fr) var(--actions-h) var(--thumbs-h);
  z-index: 50;
}
.viewer.on{ display:grid; }

.viewerMain{
  display:grid;
  place-items:center;
  padding: 12px 20px 10px;
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
}

.viewerMedia{
  max-width: 70vw;
  max-height: calc(100vh - var(--actions-h) - var(--thumbs-h) - 90px);
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: var(--shadow);
  border-radius: 8px;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.viewerVideo{
  pointer-events: auto;
  background: transparent;
}
.viewerVideo.viewerVideoLoading{
  opacity: 0 !important;
  background: transparent;
  box-shadow: none;
}
.viewerVideo.viewerVideoReady{
  opacity: 1 !important;
  transition: opacity .16s ease;
}
.fade{ opacity: 0; }
.fade-in{ opacity: 1; transition: opacity .25s ease; }
.fade-out{ opacity: 0; transition: opacity .2s ease; }
.viewerMedia.photo{
  width: auto;
  height: auto;
  max-width: 70vw;
  max-height: 70vh;
}

.viewerClose{
  position: absolute;
  left: 26px;
  top: 16px;
  width:42px; height:42px;
  border-radius:999px;
  background: var(--accent);
  display:flex; align-items:center; justify-content:center;
  font-weight:700;
  font-size: 30px;
  line-height: 1;
  padding: 0;
  color: #fff;
  z-index: 5;
  cursor: pointer;
}
.viewerClose > span{
  display:block;
  transform: translateY(-2px);
}

.viewerActions{
  display:flex;
  gap: 14px;
  justify-content:center;
  align-items: center;
  padding: 0 0 6px;
  margin: 0 auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-height: var(--actions-h);
  height: var(--actions-h);
  z-index: 6;
  position: relative;
  pointer-events: auto;
}
.viewerActions .actionBtn{ transform: translateY(0); }
.actionBtn{
  width: 60px;
  height: 60px;
  border-radius: 999px;
  background: var(--accent);
  border: 0;
  display:flex; align-items:center; justify-content:center;
  gap: 0;
  font-weight:600;
  padding: 0;
  box-shadow: 0 10px 20px rgba(0,0,0,0.35);
  position: relative;
  overflow: hidden;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}
.actionBtn:focus{ outline:none; }
.actionBtn:focus-visible{ outline:none; }
.actionBtn .ico{ display:none; }
.actionBtn span:last-child{ display:none; }
.actionBtn::before{
  content:"";
  width: 30px;
  height: 30px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}
.actionBtn.print::before{ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9V4h12v5'/><rect x='4' y='9' width='16' height='8' rx='2'/><path d='M7 17h10v3H7z'/></svg>"); }
.actionBtn.email::before{ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='6' width='18' height='12' rx='2'/><path d='m4 8 8 6 8-6'/></svg>"); }
.actionBtn.telegram::before{ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M22 3 2.7 10.5c-.9.3-.9 1.6.1 1.9l5 1.5 1.9 5.5c.3.9 1.4 1.1 1.9.4l2.8-3.2 4.8 3.5c.7.5 1.7.1 1.9-.8L23.5 4c.2-.8-.7-1.5-1.5-1z'/></svg>"); }
.actionBtn.max::before{ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='14' rx='2'/><path d='M7 9h10M7 13h6'/></svg>"); }
.actionBtn.qr_download::before{ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M3 3h7v7H3V3zm2 2v3h3V5H5zM14 3h7v7h-7V3zm2 2v3h3V5h-3zM3 14h7v7H3v-7zm2 2v3h3v-3H5zM13 13h2v2h-2zm4 0h2v2h-2zm-4 4h2v2h-2zm4 4h2v-2h-2zm2-2h2v-2h-2zm-6 0h2v-2h-2z'/></svg>"); }
.actionBtn.telegram::before{ width: 34px; height: 34px; }
.actionBtn.ripple::after{
  content:"";
  position:absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255,255,255,0.58);
  transform-origin: var(--rx, 50%) var(--ry, 50%);
  animation: btnRipple .32s ease-out;
}
@keyframes btnRipple{
  from{ opacity: .62; transform: scale(0.12); }
  to{ opacity: 0; transform: scale(1); }
}

.viewerThumbs{
  padding: 26px 0 15px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24,28,34,0.22), rgba(14,18,24,0.38));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-x: auto;
  overflow-y: hidden;
  height: var(--thumbs-h);
  display:flex;
  align-items:flex-end;
  z-index: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: auto;
}
.viewerThumbs.instant{
  scroll-behavior: auto !important;
}
.viewerThumbs::-webkit-scrollbar{
  display: none;
}
.thumbTrack{
  --thumb-shift-dur: 520ms;
  --thumb-fade-dur: 300ms;
  display:flex;
  align-items:center;
  gap: 0;
  width: max-content;
  padding: 10px 56px 0;
  transition: transform .46s cubic-bezier(0.22, 0.7, 0.26, 1);
  will-change: transform;
}
.thumbTrack.instant{
  transition: none !important;
}
.viewerThumbs .thumb{
  height: calc(var(--thumb) * 1.28);
  width: auto;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  margin-right: -22px;
  border: 1px solid rgba(var(--accent-rgb),0.35);
  box-shadow: 0 12px 22px rgba(0,0,0,0.32);
  display: inline-block;
  transform-style: preserve-3d;
  transform-origin: center 78%;
  backface-visibility: hidden;
  position: relative;
  transition:
    transform var(--thumb-shift-dur) cubic-bezier(0.2, 0.72, 0.2, 1),
    box-shadow calc(var(--thumb-shift-dur) * 0.8) ease,
    opacity var(--thumb-fade-dur) ease;
  will-change: transform, opacity;
}
.viewerThumbs.instant .thumb{
  transition: none !important;
}
.viewerThumbs .thumb::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  pointer-events: none;
}
.viewerThumbs .thumb.active{
  box-shadow:
    0 0 0 2px rgba(var(--accent-rgb),0.85),
    0 20px 36px rgba(var(--accent-rgb),0.58);
}

.navBtn{
  position: absolute;
  top: 60px;
  bottom: calc(var(--thumbs-h) + 10px);
  width: 90px;
  --nav-ripple-size: max(110vw, 110vh);
  background: transparent;
  border: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 64px;
  color: #fff;
  cursor: pointer;
  z-index: 5;
  overflow: visible;
}
.navBtn.disabled{
  pointer-events: none;
}
.navBtn.disabled:not(.pulse):not(.hold){
  opacity: 0.22;
}
.navBtn::after{
  content:"";
  position:absolute;
  left: var(--rx, 50%);
  top: var(--ry, 50%);
  width: var(--nav-ripple-size);
  height: var(--nav-ripple-size);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255,255,255,0.16) 0%,
    rgba(var(--accent-rgb),0.72) 8%,
    rgba(var(--accent-rgb),0.44) 22%,
    rgba(var(--accent-rgb),0.23) 40%,
    rgba(var(--accent-rgb),0.12) 56%,
    rgba(var(--accent-rgb),0.05) 70%,
    rgba(var(--accent-rgb),0.015) 82%,
    rgba(var(--accent-rgb),0) 92%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  will-change: transform, opacity;
}
.navBtn.pulse::after{
  animation: ripple var(--pulse-dur, .42s) ease-out;
  animation-delay: var(--pulse-delay, 0s);
}
.navBtn.hold::after{
  animation-timing-function: linear;
}
@keyframes ripple{
  from{ transform: translate(-50%, -50%) scale(0.001); opacity: .78; }
  42%{ opacity: .42; }
  100%{ transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
.navBtn.left{ left: 0; }
.navBtn.right{ right: 0; }

.viewerSideQr{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  width: 168px;
  padding: 12px 12px 10px;
  background: rgba(20,30,39,0.88);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  z-index: 4;
  pointer-events: none;
}
.viewerSideQr.show{ display:flex; }
.viewerSideQr.left{ left: 102px; }
.viewerSideQr.right{ right: 102px; }
.viewerSideQr img{
  width: 140px;
  height: 140px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 6px;
}
.viewerSideQrTitle{
  margin-top: 5px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
.viewerSideQrHint{
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
}

/* Disable selection everywhere in viewer */
.viewer, .viewer * { user-select: none; -webkit-user-select:none; }

body.viewer-on #galleryRoot{ visibility:hidden; }

.videoOverlay{
  position: absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap: 10px;
  pointer-events: none;
  z-index: 2;
}
.videoDots{
  display:flex;
  gap: 8px;
}
.videoDots .dot{
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
}
.videoDots .dot.on{
  background: var(--accent);
  border-color: var(--accent2);
}
.videoOverlay.paused .videoDots{ display:none; }
.videoHint{
  font-size: 13px;
  opacity: 0.85;
  background: rgba(0,0,0,0.45);
  padding: 6px 10px;
  border-radius: 999px;
}

.modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display:none;
  align-items:center;
  justify-content:center;
  z-index: 60;
}
.modal.on{ display:flex; }
.modalBox{
  width: 1240px;
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 120px);
  background: #efefef;
  border:1px solid rgba(0,0,0,0.15);
  border-radius: 16px;
  padding: 18px 18px 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal.notice .modalBox{
  width: 620px;
  max-width: calc(100vw - 180px);
}
.modal.notice .modalCloseX{ display:none; }
.modal.notice #modalOk{
  font-size: 36px;
  padding: 12px 24px;
}
.modal.notice .modalButtons{
  justify-content:flex-end;
}
.modalTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: clamp(4px, 1vh, 8px);
}
.modalCounter{
  display:none;
  color:#2d2d2d;
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
}
.modalCloseX{
  width: clamp(54px, 7vh, 68px);
  height: clamp(54px, 7vh, 68px);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: clamp(40px, 5vh, 52px);
  line-height: 1;
  border: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0;
  box-shadow: 0 8px 20px rgba(0,0,0,0.22);
}
.modalCloseX > span{
  display:block;
  transform: translateY(-3px);
}
.modalPrompt{
  color:#232323;
  font-size: clamp(22px, 3.2vh, 38px);
  text-align:center;
  margin: clamp(6px, 1.2vh, 10px) 0;
}
.modalSuggest{
  text-align:center;
  font-size: clamp(18px, 2.6vh, 30px);
  color: var(--accent);
  margin: clamp(2px, 0.6vh, 8px) 0;
  min-height: clamp(22px, 3vh, 38px);
  height: clamp(22px, 3vh, 38px);
  cursor: pointer;
}
.modalSuggest.hidden{ visibility: hidden; pointer-events: none; opacity: 0; }
.modalInputWrap{
  margin: 0;
  position: relative;
}
.modalBox input{
  width: 100%;
  background:#fff;
  color:#111;
  border:0;
  padding: clamp(6px, 1vh, 10px) 2px;
  font-size: clamp(20px, 2.8vh, 34px);
  caret-color: #111;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.modalBox input.nativeHidden{
  color: transparent;
  caret-color: transparent;
}
.fakeInput{
  position: absolute;
  inset: 0;
  padding: 10px 2px;
  font-size: 34px;
  color: #111;
  display: flex;
  align-items: center;
  pointer-events: auto;
  white-space: pre;
  overflow: hidden;
  user-select: none;
}
.fakeInput.placeholder{ color: rgba(17,17,17,0.4); }
.fakeMeasure{
  position: absolute;
  left: -9999px;
  top: -9999px;
  white-space: pre;
  visibility: hidden;
}
.fakeCaret{
  display: inline-block;
  width: 3px;
  height: 1.15em;
  background: var(--accent);
  margin-left: 2px;
  animation: none;
}
.modalBox input.noNativeSelect{
  -webkit-user-select: none;
  user-select: none;
}
.modalBox input.noNativeSelect::selection{
  background: transparent;
}
.modalLine{
  height: 1px;
  background: rgba(0,0,0,0.3);
  margin: clamp(6px, 1vh, 12px) 0;
}
.modalBox .smallHint{ color:#444; }
.qrBox{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 6px;
  margin-top: clamp(8px, 1.6vh, 16px);
  margin-bottom: clamp(6px, 1.2vh, 12px);
}
.qrBox[hidden]{ display:none !important; }
.qrBox img{
  /* на планшете в альбомной ориентации высоты мало: если QR оставить крупным,
     ряд кнопок уезжает за нижний край и «Далее» становится недоступным */
  width: min(440px, 38vh, 72vw);
  height: min(440px, 38vh, 72vw);
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  padding: 8px;
}
.qrBox.done img{
  background: rgba(68,208,123,0.12);
  border-color: rgba(68,208,123,0.6);
}
.kbd{
  display:flex;
  flex-direction:column;
  gap: clamp(6px, 1.2vh, 10px);
  margin-top: clamp(6px, 1.2vh, 12px);
}
.kbdRow{
  display:flex;
  gap: clamp(6px, 1vh, 8px);
}
.kbd .key{
  flex: 1;
  padding: clamp(8px, 1.6vh, 16px) 0;
  text-align:center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  font-size: clamp(18px, 2.6vh, 30px);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.modalButtons{
  justify-content:flex-end;
  margin-top: clamp(6px, 1vh, 10px) !important;
}

.counterBox{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: clamp(24px, 4vw, 56px);
  padding: clamp(16px, 3vh, 36px) 0;
}
.counterBox[hidden]{ display:none !important; }
.counterBtn{
  width: clamp(72px, 10vh, 110px);
  height: clamp(72px, 10vh, 110px);
  border-radius: 14px;
  background: var(--accent);
  color:#fff;
  border: none;
  font-size: clamp(40px, 6vh, 64px);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform .08s ease;
}
.counterBtn:active{ transform: scale(0.96); }
.counterBtn:disabled{ cursor: default; }
.counterValue{
  min-width: clamp(64px, 8vw, 110px);
  text-align: center;
  font-size: clamp(48px, 8vh, 88px);
  font-weight: 700;
  color: #111;
  line-height: 1;
}
.modal.counter .modalBox{
  width: 820px;
  max-width: calc(100vw - 120px);
}
.modal.counter .modalCloseX{ display:none; }
.modal.counter .modalPrompt{
  font-size: clamp(32px, 4.6vh, 52px);
  font-weight: 700;
  margin: clamp(8px, 1.6vh, 16px) 0 clamp(4px, 1vh, 10px);
}
.modal.counter .modalBox .modalInputWrap,
.modal.counter .modalBox .modalLine,
.modal.counter .modalBox .kbd,
.modal.counter .modalBox .modalSuggest{ display:none !important; }
.modal.counter .modalButtons{ justify-content:center; gap: 16px; }
.modal.counter #modalCancel,
.modal.counter #modalOk{
  padding: clamp(12px, 1.8vh, 18px) clamp(24px, 3vw, 40px);
  border-radius: 12px;
  font-size: clamp(16px, 2.2vh, 22px);
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.modal.counter #modalCancel{
  order: 1;
  min-width: 140px;
  background: #e3e3e3;
  color: #333;
}
.modal.counter #modalOk{
  order: 2;
  min-width: 180px;
  background: var(--accent);
  color: #fff;
}

.toast{
  position: fixed;
  right: 16px;
  bottom: 16px;
  padding: 10px 14px;
  background: rgba(20,30,39,0.9);
  border:1px solid var(--line);
  border-radius: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: .2s;
  z-index: 80;
}
.toast.on{ opacity:1; transform: translateY(0); }

/* iPad help overlay */
.helpOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items:center;
  justify-content:center;
  z-index: 70;
}
.helpOverlay.on{ display:flex; }
.helpBox{
  width: 520px;
  max-width: 94vw;
  padding: 16px;
  background: rgba(20,30,39,0.95);
  border: 1px solid var(--line);
  border-radius: 16px;
}

@media (max-width: 900px){
  .viewerMedia{ max-width: 88vw; max-height: 60vh; }
}

@media (max-width: 900px){
  body.gallery{
    --grid-cols: 5;
    --grid-rows: 2;
  }
  .viewer{
    --actions-h: 78px;
    --thumbs-h: calc(var(--thumb) * 1.1 + 8px);
  }
  .viewerMedia{
    max-width: 92vw;
    max-height: calc(100dvh - var(--actions-h) - var(--thumbs-h) - 60px);
  }
  .navBtn{
    width: 64px;
    font-size: 48px;
  }
  .viewerSideQr{ display:none !important; }
  .modalBox{
    width: 860px;
    max-width: calc(100vw - 60px);
    max-height: calc(100vh - 80px);
    padding: 12px 12px 10px;
  }
  .modal.notice .modalBox{
    width: 520px;
    max-width: calc(100vw - 60px);
  }
  .modalPrompt{ font-size: 24px; }
  .modalBox input{ font-size: 24px; }
  .modalSuggest{ font-size: 20px; min-height: 26px; height: 26px; }
  .qrBox img{
    width: min(72vw, 320px);
    height: min(72vw, 320px);
  }
  .kbd{ gap: 6px; }
  .kbdRow{ gap: 6px; }
  .kbd .key{
    font-size: 20px;
    padding: 12px 0;
  }
}

@media (max-width: 900px) and (orientation: portrait){
  .viewerActions .actionBtn{ transform: translateY(0); }
  .qrBox img{
    width: min(70vw, 300px);
    height: min(70vw, 300px);
  }
  .modalBox{
    max-height: 96dvh;
  }
}

@media (max-width: 900px) and (orientation: landscape){
  body.gallery{ --thumb: 84px; }
  .viewer{
    --actions-h: 64px;
    --thumbs-h: calc(var(--thumb) * 0.95 + 8px);
  }
  .viewerMedia{
    max-height: calc(100dvh - var(--actions-h) - var(--thumbs-h) - 40px);
  }
  .qrBox img{
    width: min(44vw, 260px);
    height: min(44vw, 260px);
  }
  .kbd .key{
    font-size: 18px;
    padding: 8px 0;
  }
}

/* Personal data consent modal */
.dgModal{
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dgModal.hidden{ display: none !important; }
.dgModalBackdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}
.dgModalCard{
  position: relative;
  z-index: 1;
  background: #efefef;
  color: #111;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.15);
  padding: 22px 22px 18px;
  width: min(720px, calc(100vw - 60px));
  max-height: calc(100vh - 80px);
  box-shadow: 0 18px 50px rgba(0,0,0,0.32);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dgModalTitle{
  font-size: clamp(20px, 2.6vh, 28px);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}
.dgConsentBody{
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  max-height: calc(100vh - 320px);
  padding-right: 4px;
}
.dgConsentPreview,
.dgConsentFull{
  font-size: clamp(15px, 2vh, 18px);
  line-height: 1.45;
  color: #1a1a1a;
  white-space: pre-wrap;
  word-break: break-word;
}
.dgConsentFullWrap{
  border-top: 1px solid rgba(0,0,0,0.12);
  padding-top: 10px;
  margin-top: 4px;
}
.dgConsentFullWrap.hidden{ display: none !important; }
.dgConsentExpandRow{
  display: flex;
  justify-content: flex-start;
}
.dgConsentExpand{
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.dgConsentExpand:disabled{
  opacity: 0.5;
  cursor: progress;
  text-decoration: none;
}
.dgConsentCheckRow{
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: clamp(15px, 2vh, 18px);
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
}
.dgConsentCheckRow input[type="checkbox"]{
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.dgModalActions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.dgGhostBtn,
.dgActionBtn{
  appearance: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  min-width: 120px;
}
.dgGhostBtn{
  background: transparent;
  border-color: rgba(0,0,0,0.25);
  color: #333;
}
.dgGhostBtn:hover{ background: rgba(0,0,0,0.05); }
.dgActionBtn{
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
.dgActionBtn:disabled{
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
@media (max-width: 720px){
  .dgModalCard{
    width: calc(100vw - 24px);
    padding: 18px 16px 14px;
  }
  .dgModalActions{ justify-content: stretch; }
  .dgGhostBtn,
  .dgActionBtn{ flex: 1; min-width: 0; }
}

/* ===== Панель записи (караоке-кабинка) ===== */
.recBar{
  position: fixed;
  left: calc(14px + env(safe-area-inset-left));
  top: calc(12px + env(safe-area-inset-top));
  z-index: 90;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(12,18,24,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.recBar.hidden{ display: none; }
/* В детальном просмотре кнопка тоже нужна: оператор жмёт «Запись» не выходя из
   ролика. Сдвигаем правее, чтобы не налезать на крестик закрытия. */
body.viewer-on .recBar{
  left: calc(84px + env(safe-area-inset-left));
  z-index: 95;
}

.recBtn{
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 12px 18px;
  border-radius: 12px; border: 0; cursor: pointer;
  font-size: 16px; font-weight: 600; color: #fff;
  background: rgba(255,255,255,0.14);
}
.recBtn.hidden{ display: none; }
.recBtn:active{ transform: translateY(1px); }
.recBtn:disabled{ opacity: 0.5; cursor: not-allowed; }
.recBtn.recStart{ background: rgba(255,80,80,0.24); border: 1px solid rgba(255,80,80,0.5); }
.recBtn.recStop{ background: var(--bad); }
.recBtnDot{ width: 14px; height: 14px; border-radius: 999px; background: var(--bad); }
.recBtnSquare{ width: 12px; height: 12px; border-radius: 3px; background: #fff; }

.recStatus{
  display: none; align-items: center; gap: 8px;
  padding-right: 6px; font-size: 15px; color: var(--muted);
}
.recStatus.on{ display: inline-flex; }
.recStatus.rec{ color: #fff; }
.recStatus.rec::before{
  content: ""; width: 12px; height: 12px; border-radius: 999px;
  background: var(--bad); animation: recPulse 1s infinite;
}
.recTime{ font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }
@keyframes recPulse{
  0%, 100%{ opacity: 1; }
  50%{ opacity: 0.25; }
}

@media (max-width: 900px){
  .recBtn{ min-height: 44px; padding: 10px 14px; font-size: 15px; }
  .recBar{ gap: 8px; padding: 6px 8px; }
}


/* Кнопки в модалке важнее картинки: они не сжимаются и не обрезаются,
   а содержимое над ними ужимается по высоте. */
.modalBox > .qrBox{ min-height: 0; flex: 0 1 auto; }
.modalBox > .modalButtons{ flex: 0 0 auto; }
.modalBox > .modalPrompt{ flex: 0 0 auto; }
@media (max-height: 900px){
  .qrBox img{ width: min(340px, 34vh, 60vw); height: min(340px, 34vh, 60vw); }
  .modalBox{ padding: 12px 14px 12px; }
}
