
:root { font-family: system-ui, sans-serif; }
body { margin: 0; background: #f7f7f8; }
header { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 1rem; background: #111827; color: white; }
nav a { color: #d1d5db; margin-left: 1rem; text-decoration: none; }
main { padding: 1rem; max-width: 980px; margin: 0 auto; }
.card { background: white; border-radius: 12px; padding: 1rem; box-shadow: 0 1px 8px rgba(0,0,0,.08); }
label { display: block; margin-top: .8rem; font-weight: 600; }
input, button { width: 100%; padding: .65rem; border-radius: 8px; border: 1px solid #ddd; margin-top: .3rem; }
select { width: 100%; padding: .65rem; border-radius: 8px; border: 1px solid #ddd; margin-top: .3rem; }
button { cursor: pointer; background: #2563eb; color: white; border: none; margin-top: .8rem; }
button:disabled {
  cursor: not-allowed;
  opacity: .45;
  filter: saturate(.55);
}
#stop-import { background: #b91c1c; }
#stop-import:disabled {
  background: #d1d5db;
  color: #6b7280;
  opacity: 1;
  filter: none;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.checkbox-label { display: flex; align-items: center; gap: .6rem; margin-top: .9rem; font-weight: 500; }
.checkbox-label input { width: auto; margin: 0; }
.filters { margin-bottom: 1rem; }
.grid-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.gallery-card { text-decoration: none; color: inherit; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: .8rem; }
.gallery-wrap { position: relative; }
.select-gallery { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; z-index: 2; }
.gallery-wrap.selected .gallery-card { outline: 3px solid #2563eb; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .4rem; }
.thumb-wrap { position: relative; }
.thumb { width: 100%; height: 130px; object-fit: cover; border-radius: 8px; }
.thumb-favorite {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  background: rgba(107, 114, 128, .7);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: .78rem;
}
.select-image { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; z-index: 2; }
.thumb-wrap.selected .thumb { outline: 3px solid #2563eb; }
.actions { display: flex; gap: .6rem; margin: .7rem 0; align-items: center; }
.actions form { margin: 0; }
.danger { background: #b91c1c; }
.lightbox { position: fixed; inset: 0; z-index: 100; display:flex; justify-content:center; align-items:center; background: rgba(0,0,0,.8); }
.lightbox img { max-width:95vw; max-height:95vh; }
.lightbox-hotspot {
  position: fixed;
  top: 12.5vh;
  height: 75vh;
  width: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}
.lightbox-hotspot.left { left: 0; }
.lightbox-hotspot.right { right: 0; }
.lightbox-btn {
  position: fixed;
  background: rgba(107, 114, 128, .62);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  padding: .45rem .65rem;
  border-radius: 8px;
  width: auto;
  margin: 0;
  text-decoration: none;
  line-height: 1.2;
  z-index: 3;
}
.lightbox-btn:hover { background: rgba(107, 114, 128, .78); }
.top-left { top: 12px; left: 12px; }
.follow-link { left: 106px; }
.top-right-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  gap: .45rem;
}
.top-right-controls .lightbox-btn { position: relative; z-index: 3; }
.lightbox-counter {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(107, 114, 128, .62);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  padding: .35rem .8rem;
}
.lightbox-caption {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 920px);
  color: #fff;
  background: rgba(107, 114, 128, .62);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px;
  padding: .5rem .8rem;
  z-index: 3;
}
.hidden { display:none; }
#status { margin-top: .8rem; font-size: .95rem; }
@media (max-width: 640px){
  .thumb{ height: 100px; }
  .row { grid-template-columns: 1fr; }
}

.shuffle-card { margin-bottom: 1rem; }
.shuffle-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; align-items: end; }
.shuffle-controls button { margin-top: 1.6rem; }

.shuffle-stage {
  position: relative;
  width: min(1800px, calc(100vw - 2rem));
  margin-left: calc(50% - 50vw + 1rem);
  margin-right: calc(50% - 50vw + 1rem);
  height: min(80vh, 980px);
  min-height: 540px;
  background: #050505;
  border-radius: 12px;
  overflow: hidden;
}

.shuffle-grid-layer {
  position: absolute;
  inset: 0;
  display: grid;
  gap: .25rem;
  opacity: 0;
  transition: opacity .35s ease-in-out;
  pointer-events: none;
}
.shuffle-grid-layer.active { opacity: 1; }

.shuffle-stage.single .shuffle-grid-layer { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.shuffle-stage.quad .shuffle-grid-layer { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.shuffle-stage.triple .shuffle-grid-layer { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr; }

.shuffle-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.shuffle-stage.single .shuffle-image {
  object-fit: contain;
  background: #000;
}

.shuffle-hotspot {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 15%;
  min-width: 70px;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 3;
}
.shuffle-hotspot.left { left: 0; }
.shuffle-hotspot.right { right: 0; }
.shuffle-hotspot:hover { background: rgba(255,255,255,.06); }

.shuffle-empty {
  color: #fff;
  text-align: center;
  margin: auto;
  font-size: 1.05rem;
}

#shuffle-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  border-radius: 0;
}

@media (max-width: 900px) {
  .shuffle-stage {
    height: 72vh;
    min-height: 420px;
  }
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .65rem .9rem;
  border-radius: 8px;
  background: #1d4ed8;
  color: white;
  text-decoration: none;
  font-size: .92rem;
}

.table-wrap { overflow-x: auto; }
.downloads-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: .5rem;
}
.downloads-table th,
.downloads-table td {
  text-align: left;
  padding: .65rem;
  border-bottom: 1px solid #e5e7eb;
}
