:root {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  color: #1d2733;
  background: #f6f8fb;
}

body {
  margin: 0;
}

.container {
  box-sizing: border-box;
  max-width: 720px;
  padding: 32px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgb(30 50 80 / 10%);
}

.page-shell {
  display: grid;
  grid-template-columns: 160px minmax(0, 720px) 160px;
  align-items: start;
  justify-content: center;
  gap: 32px;
  margin: 72px 24px;
}

.ad-slot {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  min-height: 600px;
  border: 1px dashed #b8c2d0;
  border-radius: 8px;
  color: #8490a0;
  background: #edf1f6;
  font-size: 0.75rem;
}

h1 {
  margin-top: 0;
}

label {
  display: block;
  margin: 28px 0 8px;
  font-weight: 600;
}

.form-row {
  display: flex;
  gap: 8px;
}

input {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border: 1px solid #b8c2d0;
  border-radius: 8px;
  font: inherit;
}

button {
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: #1769e0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.hint {
  margin-top: 24px;
  color: #5c6878;
  font-size: 0.9rem;
}

.search-progress {
  overflow: hidden;
  height: 5px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e1e7ef;
}

.search-progress[hidden] {
  display: none;
}

.search-progress-bar {
  width: 38%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #76b4ff, #1769e0, #76b4ff);
  animation: searching 1.15s ease-in-out infinite;
}

@keyframes searching {
  from { transform: translateX(-110%); }
  to { transform: translateX(280%); }
}

.result-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 32px;
}

.result-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

#image-count {
  color: #5c6878;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.image-card {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid #d6dde7;
  border-radius: 8px;
  cursor: pointer;
}

.preview-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.image-card input {
  position: absolute;
  z-index: 1;
  top: 8px;
  left: 8px;
  width: 18px;
  height: 18px;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card span {
  position: absolute;
  right: 8px;
  bottom: 58px;
  padding: 2px 6px;
  border-radius: 5px;
  color: white;
  background: rgb(0 0 0 / 65%);
  font-size: 0.8rem;
}

.image-card.is-dragging {
  opacity: 0.4;
}

#download-cbz {
  white-space: nowrap;
}

.download-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-row input {
  flex: 1;
}

.bulk-menu {
  position: fixed;
  z-index: 10;
  display: grid;
  min-width: 168px;
  margin: 0;
  padding: 4px;
  border: 1px solid #c5ced9;
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 20px rgb(30 50 80 / 20%);
}

/* .bulk-menu の display 指定より hidden 属性を優先させる。 */
.bulk-menu[hidden] {
  display: none;
}

.bulk-menu button {
  padding: 8px 10px;
  border-radius: 5px;
  color: #1d2733;
  background: transparent;
  text-align: left;
  font-size: 0.85rem;
}

.bulk-menu button:hover,
.bulk-menu button:focus-visible {
  background: #eaf2ff;
}

.image-preview {
  box-sizing: border-box;
  width: min(960px, 94vw);
  max-width: none;
  max-height: 92vh;
  padding: 28px 54px 18px;
  border: 0;
  border-radius: 12px;
  background: #18212c;
  color: white;
}

.image-preview::backdrop {
  background: rgb(0 0 0 / 70%);
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: calc(92vh - 95px);
  object-fit: contain;
}

.image-preview p {
  margin: 10px 0 0;
  text-align: center;
}

.close-preview,
.preview-arrow {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 18%);
  font-size: 1.8rem;
  line-height: 1;
}

.close-preview {
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
}

.preview-arrow {
  top: 50%;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
}

.previous { left: 8px; }
.next { right: 8px; }

@media (max-width: 1120px) {
  .page-shell {
    display: block;
    margin: 24px 16px;
  }

  .ad-slot {
    display: none;
  }
}

@media (max-width: 560px) {
  .container {
    padding: 24px;
  }

  .form-row {
    flex-direction: column;
  }
}
