html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #07070d;
  color: #f4f4f8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

a {
  color: inherit;
}

.d-none {
  display: none !important;
}

.doujin-discover-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 1.2rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.doujin-discover-header a,
.doujin-discover-header button {
  pointer-events: auto;
}

.back-button,
.saved-items-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.45rem 0.68rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.saved-items-button {
  position: relative;
  padding-right: 1.85rem;
  cursor: pointer;
}

.saved-count-badge {
  position: absolute;
  top: -0.42rem;
  right: -0.42rem;
  min-width: 1.38rem;
  height: 1.38rem;
  padding: 0 0.32rem;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  background: #f8c24e;
  color: #151006;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 900;
  text-shadow: none;
}

.doujin-discover-container {
  width: 100%;
  height: 100dvh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.doujin-discover-container::-webkit-scrollbar {
  display: none;
}

.doujin-discover-item {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  display: grid;
  place-items: center;
  padding: 4.6rem 0.75rem 7.2rem;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #0b0b12;
  touch-action: pan-y;
}

.cover-bg {
  position: absolute;
  inset: -2rem;
  background-image: var(--cover-image);
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  filter: blur(22px) saturate(1.08);
  transform: scale(1.08);
}

.doujin-discover-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.05) 30%, rgba(0, 0, 0, 0.84)),
    radial-gradient(circle at 50% 42%, rgba(248, 194, 78, 0.16), transparent 42%);
}

.cover-frame {
  position: relative;
  z-index: 1;
  display: block;
  width: min(86vw, 500px);
  height: min(calc(100dvh - 12rem), 680px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #050508;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  touch-action: pan-y;
}

.cover-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.doujin-discover-item.is-viewing-sample .cover-image {
  object-fit: contain;
}

.swipe-reader-ui {
  position: absolute;
  top: 0.68rem;
  right: 0.68rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  max-width: calc(100% - 1rem);
  min-height: 28px;
  padding: 0.3rem 0.42rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.swipe-reader-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
  animation: readerArrowNudge 1.65s ease-in-out infinite;
}

.swipe-reader-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.swipe-reader-dot {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  transition: background 0.16s ease, transform 0.16s ease, width 0.16s ease;
}

.swipe-reader-dot.is-active {
  width: 0.64rem;
  border-radius: 8px;
  background: #f8c24e;
  transform: scale(1.04);
}

@keyframes readerArrowNudge {
  0%,
  100% {
    transform: translateX(-2px);
    opacity: 0.62;
  }
  45% {
    transform: translateX(3px);
    opacity: 1;
  }
}

.item-overlay {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  padding: 5.6rem 1rem max(1rem, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.54) 58%, rgba(0, 0, 0, 0));
  pointer-events: none;
}

.item-copy,
.item-actions {
  pointer-events: auto;
}

.item-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  margin: 0 0 0.38rem;
  color: #f8c24e;
  font-size: 0.78rem;
  font-weight: 900;
}

.item-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: clamp(1.05rem, 3.8vw, 1.35rem);
  font-weight: 900;
  line-height: 1.38;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.86);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: 0.55rem;
}

.meta-chip,
.tag-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 1.74rem;
  padding: 0.24rem 0.52rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.76rem;
  font-weight: 850;
  text-decoration: none;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
  margin-top: 0.48rem;
}

.tag-chip {
  border-color: rgba(64, 196, 255, 0.2);
  background: rgba(64, 196, 255, 0.12);
}

.item-actions {
  display: grid;
  gap: 0.72rem;
  justify-items: center;
}

.read-link,
.action-button {
  display: grid;
  justify-items: center;
  gap: 0.28rem;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.action-btn {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  backdrop-filter: blur(8px);
}

.action-btn--primary {
  background: #f8c24e;
  color: #160f04;
  border-color: rgba(255, 255, 255, 0.8);
}

.save-button.is-saved .action-btn {
  background: #40c4ff;
  color: #06131c;
  border-color: rgba(255, 255, 255, 0.84);
}

.action-label {
  max-width: 4.4rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

.loading-indicator {
  position: fixed;
  z-index: 240;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
}

.loader-dot {
  width: 2.2rem;
  height: 2.2rem;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #f8c24e;
  border-radius: 50%;
  display: block;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.swipe-tutorial {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  transition: opacity 0.24s ease;
}

.tutorial-content {
  width: min(280px, calc(100% - 2rem));
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(10, 10, 16, 0.88);
  text-align: center;
}

.tutorial-content p {
  margin: 0.4rem 0 0;
  font-weight: 850;
}

.tutorial-sub {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.84rem;
}

.swipe-icon {
  color: #f8c24e;
  font-size: 2rem;
  animation: swipeSide 1.8s ease-in-out infinite;
}

@keyframes swipeSide {
  0%,
  100% {
    transform: translateX(-9px);
    opacity: 0.5;
  }
  45% {
    transform: translateX(9px);
    opacity: 1;
  }
}

.saved-items-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

.saved-items-overlay.is-open {
  pointer-events: auto;
}

.saved-items-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.saved-items-overlay.is-open .saved-items-backdrop {
  opacity: 1;
}

.saved-items-sheet {
  position: absolute;
  inset: auto 0 0;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(13, 13, 18, 0.98);
  transform: translateY(100%);
  transition: transform 0.2s ease;
}

.saved-items-overlay.is-open .saved-items-sheet {
  transform: translateY(0);
}

.saved-items-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.saved-items-eyebrow {
  margin: 0 0 0.2rem;
  color: #f8c24e;
  font-size: 0.78rem;
  font-weight: 900;
}

.saved-items-sheet h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 900;
}

.saved-items-close,
.saved-items-clear {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 850;
  cursor: pointer;
}

.saved-items-close {
  width: 42px;
  flex: 0 0 auto;
}

.saved-items-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.saved-items-clear {
  padding: 0 0.82rem;
  font-size: 0.84rem;
}

.saved-items-empty {
  margin: 0.8rem 0 1rem;
  padding: 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.06);
  line-height: 1.7;
}

.saved-items-list {
  min-height: 0;
  flex: 1;
  display: grid;
  gap: 0.65rem;
  overflow-y: auto;
}

.saved-item-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.58rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-decoration: none;
}

.saved-item-card img {
  width: 64px;
  height: 86px;
  object-fit: cover;
  border-radius: 6px;
}

.saved-item-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.35;
}

.saved-item-card__meta {
  margin: 0.32rem 0 0;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.78rem;
  font-weight: 760;
}

.save-toast {
  position: fixed;
  left: 50%;
  bottom: 1.3rem;
  z-index: 340;
  transform: translateX(-50%);
  max-width: min(320px, calc(100vw - 2rem));
  padding: 0.68rem 0.88rem;
  border-radius: 8px;
  background: rgba(248, 194, 78, 0.95);
  color: #151006;
  font-size: 0.86rem;
  font-weight: 900;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
}

@media (min-width: 900px) {
  .cover-frame {
    width: min(42vw, 540px);
    height: min(calc(100dvh - 10.5rem), 740px);
  }

  .item-overlay {
    padding-inline: max(1.4rem, calc((100vw - 960px) / 2));
  }
}

@media (max-width: 520px) {
  .doujin-discover-header {
    padding-inline: 0.72rem;
  }

  .back-button span,
  .saved-items-button span:not(.saved-count-badge) {
    display: none;
  }

  .cover-frame {
    width: min(92vw, 430px);
    height: min(calc(100dvh - 12.6rem), 640px);
  }

  .item-overlay {
    grid-template-columns: minmax(0, 1fr) 54px;
    gap: 0.7rem;
    padding-inline: 0.82rem;
  }

  .action-btn {
    width: 42px;
    height: 42px;
    font-size: 1.22rem;
  }

}
