:root {
  --bg: #14151a;
  --bg-soft: #1b1d24;
  --card: #20222b;
  --card-hover: #272a35;
  --line: #2e313d;
  --fg: #e8e9ee;
  --fg-dim: #9aa0ae;
  --fg-faint: #6b7180;
  --accent: #ff5c8a;
  --accent-soft: rgba(255, 92, 138, 0.14);
  --gold: #f5b942;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP",
        "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: rgba(20, 21, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 700; font-size: 16px; letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand span { color: var(--accent); }
.brand small { color: var(--fg-faint); font-weight: 400; font-size: 11px; }
.search {
  flex: 1; max-width: 560px; position: relative;
}
.search input {
  width: 100%; padding: 9px 36px 9px 34px;
  background: var(--bg-soft); color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px;
  outline: none; transition: border-color .15s;
}
.search input:focus { border-color: var(--accent); }
.search .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--fg-faint); font-size: 13px;
}
.search .clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--fg-faint); font-size: 16px;
}
.stats { margin-left: auto; color: var(--fg-faint); font-size: 12px; white-space: nowrap; }
.fbtn {
  display: none; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--fg-dim); font-size: 12px;
}
.fbtn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- category tabs ---------- */
.cats { display: flex; gap: 4px; align-items: center; }
.cat {
  padding: 6px 12px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--fg-dim); font-size: 12.5px;
  display: flex; align-items: center; gap: 6px; transition: all .12s;
}
.cat:hover { background: var(--bg-soft); color: var(--fg); }
.cat.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cat span { font-size: 10.5px; color: var(--fg-faint); }
.cat.on span { color: var(--accent); opacity: .8; }

/* ---------- layout ---------- */
.layout { display: flex; gap: 20px; padding: 18px 20px 60px; align-items: flex-start; }
.sidebar {
  width: 210px; flex: 0 0 210px; position: sticky; top: 74px;
  max-height: calc(100vh - 90px); overflow-y: auto;
  padding-right: 4px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.side-group { margin-bottom: 22px; }
.side-title {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-faint); margin-bottom: 9px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--fg-dim); font-size: 12px;
  transition: all .12s;
}
.chip:hover { border-color: var(--fg-faint); color: var(--fg); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .n { color: var(--fg-faint); margin-left: 4px; font-size: 10px; }
.sortbar { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- grid ---------- */
.content { flex: 1; min-width: 0; }
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .16s, border-color .16s, background .16s;
  cursor: pointer; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); border-color: #3d4152; background: var(--card-hover); }
.cover {
  position: relative; aspect-ratio: 4 / 3; background: #0e0f13; overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .badge {
  position: absolute; top: 6px; left: 6px;
  padding: 2px 6px; border-radius: 4px; font-size: 10px;
  background: rgba(0,0,0,.72); color: #fff; backdrop-filter: blur(4px);
}
.cover .badge.age { left: auto; right: 6px; background: rgba(214, 40, 66, .88); }
.cover .badge.off { left: 6px; top: auto; bottom: 6px; background: rgba(214, 40, 66, .9); font-weight: 700; }
.card-body { padding: 8px 9px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card-title {
  font-size: 12.5px; line-height: 1.4; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.8em;
}
.card-circle { font-size: 11px; color: var(--fg-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding-top: 4px; }
.price { color: var(--gold); font-weight: 700; font-size: 12.5px; }
.price .old { color: var(--fg-faint); font-weight: 400; font-size: 10.5px; text-decoration: line-through; margin-left: 4px; }
.meta { margin-left: auto; color: var(--fg-faint); font-size: 10.5px; display: flex; gap: 7px; }
.meta .star { color: var(--gold); }

/* ---------- empty / footer ---------- */
.empty { padding: 80px 0; text-align: center; color: var(--fg-faint); }
.more { text-align: center; padding: 26px 0 0; }
.more button {
  padding: 9px 26px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--fg-dim);
}
.more button:hover { border-color: var(--accent); color: var(--accent); }
footer {
  padding: 26px 20px 40px; color: var(--fg-faint); font-size: 11.5px;
  text-align: center; border-top: 1px solid var(--line); margin-top: 20px;
}

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 90; display: none;
  background: rgba(8, 9, 12, .82); backdrop-filter: blur(6px);
  padding: 30px 20px; overflow-y: auto;
}
.modal.on { display: block; }
.sheet {
  max-width: 1020px; margin: 0 auto; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: rgba(27, 29, 36, .96);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 14px; margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .x {
  margin-left: auto; border: 0; background: none; color: var(--fg-dim);
  font-size: 22px; line-height: 1; padding: 0 4px;
}
.sheet-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0; }
.shots { padding: 14px; border-right: 1px solid var(--line); }
.shots .hero {
  width: 100%; border-radius: 8px; overflow: hidden; background: #0e0f13; margin-bottom: 10px;
}
.shots .hero img { width: 100%; display: block; }
.shots .thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.shots .thumbs img {
  width: 100%; border-radius: 6px; cursor: zoom-in; background: #0e0f13;
  transition: opacity .12s;
}
.shots .thumbs img:hover { opacity: .82; }
.info { padding: 16px 18px 22px; min-width: 0; }
.info h1 { font-size: 17px; line-height: 1.45; margin: 0 0 4px; }
.romaji { color: var(--fg-faint); font-size: 11px; margin-bottom: 12px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 78px 1fr; gap: 7px 10px; font-size: 12.5px; margin-bottom: 14px; }
.kv dt { color: var(--fg-faint); }
.kv dd { margin: 0; word-break: break-word; }
.taglist { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 14px; }
.taglist .chip { font-size: 11px; padding: 3px 8px; cursor: pointer; }
.price-row {
  display: flex; align-items: baseline; gap: 10px; margin: 12px 0;
  padding: 10px 12px; background: var(--bg); border-radius: 8px; border: 1px solid var(--line);
}
.price-row .big { font-size: 20px; font-weight: 700; color: var(--gold); }
.price-row .was { color: var(--fg-faint); text-decoration: line-through; font-size: 12px; }
.price-row .cur { margin-left: auto; color: var(--fg-faint); font-size: 11px; }
.intro { font-size: 12.5px; color: var(--fg-dim); line-height: 1.7; }
.intro h3 { color: var(--fg); font-size: 13px; margin: 16px 0 6px; }
.intro img { max-width: 100%; border-radius: 6px; margin: 8px 0; }
.intro br { line-height: 2; }
.ext { display: inline-block; margin-top: 14px; padding: 8px 16px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
  font-size: 12.5px; }

/* ---------- age gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 200; display: flex;
  align-items: center; justify-content: center; background: rgba(12,13,17,.94);
  backdrop-filter: blur(3px);
}
.gate .box {
  max-width: 420px; padding: 30px; text-align: center;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px;
}
.gate .hint { color: var(--fg-dim); font-size: 12px; margin: 14px 0 0; }
.loading {
  grid-column: 1 / -1; padding: 60px 0; text-align: center;
  color: var(--fg-dim); font-size: 14px;
}
.loading::after {
  content: ''; display: block; width: 28px; height: 28px; margin: 16px auto 0;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gate h2 { margin: 0 0 8px; font-size: 18px; }
.gate p { color: var(--fg-dim); font-size: 13px; margin: 0 0 20px; }
.gate button {
  padding: 10px 24px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.gate .no { border-color: var(--line); background: none; color: var(--fg-faint); margin-right: 8px; }

@media (max-width: 860px) {
  /* compact top bar: brand + tabs + filter toggle on line 1, search below */
  .topbar {
    flex-wrap: wrap; gap: 8px; padding: 8px 12px;
  }
  .brand { font-size: 15px; flex: 0 0 auto; }
  .brand span { display: none; }
  .brand small { display: none; }
  .cats {
    order: 1; flex: 1 1 0; min-width: 0; justify-content: flex-end;
    overflow-x: auto; scrollbar-width: none;
  }
  .cats::-webkit-scrollbar { display: none; }
  .cat { padding: 5px 9px; font-size: 12px; white-space: nowrap; }
  .cat span { font-size: 9.5px; }
  .fbtn { order: 2; flex: 0 0 auto; display: inline-flex; margin: 0; }
  .search { order: 3; flex: 1 1 100%; max-width: none; }
  .search input { padding: 8px 34px 8px 32px; font-size: 14px; }
  .stats { display: none; }

  /* filters collapse behind a toggle so the first screen is product, not chrome */
  .layout { flex-direction: column; padding: 10px 12px 40px; gap: 10px; }
  .sidebar {
    display: none; width: 100%; flex: none; position: static;
    max-height: none; overflow: visible; padding: 10px 10px 6px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  }
  .sidebar.open { display: block; }
  .fbtn { display: inline-flex; margin-left: auto; }
  .side-group { margin-bottom: 8px; }
  .side-group:last-child { margin-bottom: 0; }
  .side-title { margin-bottom: 6px; font-size: 10px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; padding: 5px 10px; font-size: 12px; }

  /* two cards per row on phones instead of one tall column */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-title { font-size: 12.5px; -webkit-line-clamp: 2; }
  .card-circle { font-size: 11px; }
  .card-foot { font-size: 12px; }
  .more button { width: 100%; }

  /* detail sheet fills the phone screen */
  .modal { padding: 0; }
  .sheet {
    width: 100%; max-width: none; height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: 0;
  }
  .sheet-body { grid-template-columns: 1fr; }
  .shots { border-right: 0; border-bottom: 1px solid var(--line); }
}
