*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ヌキドキ: 夜っぽい紫がかった黒 × ドキッとするホットピンク */
:root {
  --accent: #ff2d78;
  --accent-2: #ff8a3d;
  --accent-grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --bg: #0e0a12;
  --bg-deep: #08060b;
  --surface: #1a1320;
}

/* 心臓の鼓動（ドッ、ドッ） */
@keyframes heartbeat {
  0%, 40%, 100% { transform: scale(1); }
  10%           { transform: scale(1.14); }
  20%           { transform: scale(1); }
  30%           { transform: scale(1.1); }
}

button, input { font-family: inherit; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  position: fixed; /* iOS Safari pull-to-refresh 完全無効化 */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: #fff;
  font-family: 'Zen Maru Gothic', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic', sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  justify-content: center;
}

#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-deep);
}

/* ---- Header ---- */
header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(14,10,18,0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.search-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.search-btn:active {
  background: rgba(255,255,255,0.18);
}

.search-btn svg {
  width: 16px;
  height: 16px;
}

/* ---- Search Overlay ---- */
.search-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
}

.search-overlay.open {
  pointer-events: all;
  opacity: 1;
  transform: translateY(0);
}

.search-panel {
  background: rgba(14,10,18,0.97);
  backdrop-filter: blur(16px);
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 0 10px;
  height: 44px;
}

.search-icon-sm {
  width: 16px;
  height: 16px;
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 15px;
  caret-color: var(--accent);
}

#search-input::placeholder { color: rgba(255,255,255,0.3); }
#search-input::-webkit-search-cancel-button { display: none; }

.search-close {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.search-close svg { width: 15px; height: 15px; }

.suggest-section { margin-top: 18px; }
.suggest-section.hidden { display: none; }

.suggest-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  margin-bottom: 10px;
}

#actress-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

#actress-chips {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}

#actress-chips::-webkit-scrollbar {
  width: 3px;
}
#actress-chips::-webkit-scrollbar-track {
  background: transparent;
}
#actress-chips::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
}
#actress-chips::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.35);
}

.suggest-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
}

.suggest-chip {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 20px;
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.chip-name {
  padding: 5px 7px 5px 12px;
  font-weight: 500;
}

.chip-count {
  padding: 5px 9px 5px 7px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.38);
  border-left: 1px solid rgba(255,255,255,0.1);
}

.suggest-chip:active,
.suggest-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.suggest-chip:active .chip-count,
.suggest-chip.active .chip-count {
  color: rgba(255,255,255,0.7);
  border-left-color: rgba(255,255,255,0.25);
}

/* ---- Feed Tabs ---- */
header {
  flex-wrap: wrap;
  row-gap: 6px;
}

.feed-tabs {
  flex-basis: 100%;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.feed-tab {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 2px 0 5px;
  color: rgba(255,255,255,0.55);
  font-size: 15px;
  font-weight: 700;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.feed-tab.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.feed-tab-fav svg {
  width: 14px;
  height: 14px;
  fill: var(--accent);
}

/* 絞り込み中はタブの選択表示を消す（タップで絞り込み解除＆タブ切替） */
header.filtering .feed-tab.active {
  color: rgba(255,255,255,0.55);
  border-bottom-color: transparent;
}

/* ---- Filter Bar ---- */
.filter-bar {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-bar[hidden] { display: none; }

.filter-label {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.filter-clear {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.filter-clear svg { width: 12px; height: 12px; }

.header-logo {
  height: 30px;
  width: auto;
  object-fit: contain;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  margin-left: 48px; /* 右の検索ボタン（36px + 隙間 12px）と釣り合わせて画面中央に置く */
}

/* ---- Feed ---- */
#feed {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

/* ---- Video Card (3-slot virtual carousel) ---- */
.card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  will-change: transform;
}

.card video {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
  display: block;
}

/* 動画の上下の余白を埋める、ぼかしたサムネイル */
.card-bg {
  position: absolute;
  inset: -40px;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(0.45);
  pointer-events: none;
}

/* ---- Tap hint ---- */
.tap-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  z-index: 20;
  background: rgba(0,0,0,0.45);
}
.tap-hint.visible { opacity: 1; }

.tap-hint-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2.5px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: heartbeat 1.4s ease-in-out infinite;
  box-shadow: 0 0 24px rgba(0,0,0,0.5);
}
.tap-hint-icon svg {
  width: 32px;
  height: 32px;
  fill: #fff;
  margin-left: 5px;
}
.tap-hint-text {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.06em;
  background: rgba(0,0,0,0.55);
  padding: 6px 16px;
  border-radius: 20px;
}

/* gradient overlay */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.85) 0%,
    rgba(0,0,0,0.35) 22%,
    transparent 40%
  );
  pointer-events: none;
}

/* ---- Info (bottom-left) ---- */
.card-info {
  position: absolute;
  bottom: 38px;
  left: 14px;
  right: 76px;
  pointer-events: none;
}

.card-actress {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 5px;
  color: #fff;
  text-decoration: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}

.card-title {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Sidebar (right) ---- */
.card-sidebar {
  position: absolute;
  right: 10px;
  bottom: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.side-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  color: #fff;
  user-select: none;
}

.side-btn .icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  transition: transform 0.12s;
}

.side-btn:active .icon {
  transform: scale(0.88);
}

.side-btn .icon-svg {
  width: 24px;
  height: 24px;
  display: block;
}

.side-btn .label {
  font-size: 11px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* ---- 購入ボタン（タイトル下） ---- */
.cta-buy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 18px;
  background: var(--accent-grad);
  border-radius: 22px;
  box-shadow: 0 2px 14px rgba(255,45,120,0.45);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s;
}

.cta-buy:active { transform: scale(0.95); }

.cta-icon { width: 18px; height: 18px; }

.btn-share .icon {
  background: rgba(255,255,255,0.18);
}

/* ---- 「ドキッ」ボタン（お気に入り） ---- */
.btn-like .icon {
  background: rgba(255,255,255,0.18);
}

.icon-heart {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: fill 0.15s;
}

.btn-like.liked .icon-heart { fill: var(--accent); }
.btn-like.liked .label { color: var(--accent); }
.btn-like.beat .icon { animation: heartbeat 0.9s ease-in-out; }

/* ---- Tap flash (play / pause) ---- */
.tap-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 10;
}

.tap-flash.visible { opacity: 1; }

/* play triangle */
.tap-flash[data-icon="play"]::before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 13px 0 13px 22px;
  border-color: transparent transparent transparent #fff;
  margin-left: 5px;
}

/* pause bars */
.tap-flash[data-icon="pause"]::before {
  content: '';
  display: block;
  width: 20px;
  height: 22px;
  border-left: 6px solid #fff;
  border-right: 6px solid #fff;
}

/* ---- Spinner ---- */
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  pointer-events: none;
}

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ---- Progress Bar ---- */
.progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  display: flex;
  align-items: flex-end;
  z-index: 30;
  cursor: pointer;
  touch-action: none;
}

.progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.28);
  transition: height 0.15s;
}

.progress-bar.seeking .progress-track {
  height: 5px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s linear;
}

.progress-bar.seeking .progress-fill {
  transition: none;
}

/* ---- Swipe Hint ---- */
.swipe-hint {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

.swipe-hint.visible {
  opacity: 1;
  animation: swipeUp 1.6s ease-in-out infinite;
}

.swipe-hint-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.swipe-hint-arrow {
  width: 14px;
  height: 14px;
  border-left: 2.5px solid #fff;
  border-top: 2.5px solid #fff;
  transform: rotate(45deg) translate(1px, 1px);
}

.swipe-hint-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

@keyframes swipeUp {
  0%   { transform: translate(-50%, 0); }
  50%  { transform: translate(-50%, -6px); }
  100% { transform: translate(-50%, 0); }
}

/* ---- Grid View ---- */
#grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 20;
  background: var(--bg);
  padding-top: var(--header-h, 100px);
  padding-bottom: 20px;
  display: none;
}

#grid.visible {
  display: block;
}

.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 12px 0;
}

.grid-item {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right center; /* サムネイル右半分がパッケージ表面 */
  display: block;
  transition: transform 0.2s;
}

.grid-item:active img {
  transform: scale(0.96);
}

.grid-item-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.grid-item-play::after {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 13px;
  border-color: transparent transparent transparent #fff;
  margin-left: 2px;
}

.grid-item-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
  padding: 24px 8px 8px;
  pointer-events: none;
}

.grid-item-actress {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.grid-item-title {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.grid-empty {
  grid-column: 1 / -1;
  padding: 60px 24px;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
}

/* ---- Feed Loading ---- */
.feed-loading {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feed-loading::after {
  content: '';
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ---- Error / Empty ---- */
.feed-message {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255,255,255,0.45);
  font-size: 14px;
}

.feed-message .icon { font-size: 40px; }

/* ---- Age Gate ---- */
.age-gate {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.age-gate.hidden { display: none; }

.age-gate-box {
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.age-gate-logo {
  width: 220px;
  max-width: 70%;
  height: auto;
}

.age-gate-label {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.age-gate-desc {
  font-size: 14px;
  color: rgba(255,255,255,0.65);
  line-height: 1.65;
}

.age-gate-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.age-gate-buttons button {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 26px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.age-gate-buttons button:active { opacity: 0.75; }

.btn-yes { background: var(--accent-grad); color: #fff; box-shadow: 0 2px 14px rgba(255,45,120,0.4); }
.btn-no  { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8); }
