:root {
    --bg:          #0f0f11;
    --surface:     #1a1a1f;
    --surface2:    #222229;
    --border:      #2e2e38;
    --ink:         #e8e8f0;
    --sub:         #9090a8;
    --muted:       #55556a;
    --accent:      #7c6af7;
    --accent-deep: #6254e0;
    --accent-soft: #7c6af718;
    --ok:          #4caf80;
    --warn:        #f0a555;
    --danger:      #f05555;
    --radius:      8px;
}

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

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== HEADER ===== */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-title {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--ink);
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
    display: flex;
    gap: .35rem;
}

.search-box input {
    flex: 1;
    min-width: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .4rem .75rem;
    color: var(--ink);
    font-size: .9rem;
    outline: none;
}
.search-box input:focus { border-color: var(--accent); }

.search-btn {
    padding: .4rem .9rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.search-btn:hover { background: var(--accent-deep); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

.count-badge { font-size: .8rem; color: var(--sub); white-space: nowrap; }

.btn-import {
    padding: .35rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    font-size: .85rem;
    white-space: nowrap;
}
.btn-import:hover { background: var(--accent-deep); text-decoration: none; }

.btn-review-cta {
    padding: .35rem 1rem;
    background: rgba(240,165,85,.08);
    color: var(--warn);
    border: 1px solid var(--warn);
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}
.btn-review-cta:hover {
    background: var(--warn);
    color: #1a1a1f;
    text-decoration: none;
}

/* ===== GALLERY TOOLBAR (search + count) ===== */
.gallery-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem 0;
}
.gallery-toolbar .search-box { flex: 1; max-width: 480px; }
.gallery-toolbar .count-badge { margin-left: auto; }

@media (max-width: 600px) {
    .gallery-toolbar { flex-wrap: wrap; padding: .75rem 1rem 0; gap: .5rem; }
    .gallery-toolbar .search-box { order: 2; flex-basis: 100%; max-width: none; }
    .gallery-toolbar .count-badge { order: 1; margin-left: 0; }
}

/* ===== FILTER BAR ===== */
.filter-bar {
    padding: .5rem 1.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.filter-label { font-size: .8rem; color: var(--muted); }
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}
.filter-chip {
    padding: .25rem .7rem;
    border-radius: 14px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-size: .8rem;
}
.filter-clear {
    margin-left: auto;
    padding: .2rem .7rem;
    border-radius: 20px;
    border: 1px solid var(--danger);
    background: transparent;
    color: var(--danger);
    font-size: .78rem;
    cursor: pointer;
}
.filter-clear:hover { background: #f0555520; }

/* ===== GALLERY GRID ===== */
/* 汎用ギャラリー（レビュー募集ページなど）。カード幅ベースで自動フィル。 */
.gallery {
    padding: 1.25rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

/* トップページ専用: 横8列×縦2行 = 16件/ページ。狭い画面では列数を減らして行数が増える。 */
.gallery--index { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1000px) { .gallery--index { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width:  760px) { .gallery--index { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width:  520px) { .gallery--index { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 作品詳細の関連作品。親の .detail-section が余白を持つので、こちらの padding は外す。
   クラスを2つ重ねて詳細度を上げているのは、ファイル後方のレスポンシブ指定にある
   .gallery（同じ詳細度・後勝ち）に上書きされるのを防ぐため。 */
.gallery.gallery--related { padding: 0; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 1000px) { .gallery.gallery--related { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width:  760px) { .gallery.gallery--related { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width:  520px) { .gallery.gallery--related { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ピックアップ枠。すぐ上に並ぶ一覧（.gallery--index）とカードの大きさを揃える。
   同じページで上下に並ぶブロックなので、列数・間隔・折り返す幅がずれると
   幅の違う2つのグリッドが重なって見える。
   列数の段は .gallery--index と同じ 5 / 4 / 3 / 2、gap も同じ値にすること。

   一覧に合わせた結果、掲載件数（INDEX_PICKUP_LIMIT = 10）が割り切れるのは
   5列と2列のときだけで、4列・3列では最終行が欠ける。
   大きさを揃えることを優先しているので、そこは許容している。

   padding を 0 にしているのは .pickup-section 側が余白を持つため。
   ファイル後方の @media (max-width: 768px) にある .gallery（同じ詳細度・後勝ち）に
   上書きされないよう、.gallery--related と同じくクラスを2つ重ねて詳細度を上げている。
   その代わり、狭い画面で一覧に掛かる指定もこちらには届かないので書き直す。

   768px 以下を repeat(3) / repeat(2) ではなく auto-fill にしているのは、一覧の実際の
   見え方に合わせるため。.gallery--index の 760px / 520px の指定はどちらも単一クラスで、
   ファイル後方の RESPONSIVE 節にある .gallery（同じ詳細度・後勝ち）に上書きされ、
   効いていない。狭い画面の一覧を実際に決めているのはそちらの2つ:
     768px 以下 … auto-fill / minmax(140px, 1fr)
     480px 以下 … repeat(2, 1fr)
   ここではその2つと同じ値を書く。一覧側を変えたらここも合わせること。 */
.gallery.gallery--pickup { padding: 0; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 1000px) { .gallery.gallery--pickup { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width:  768px) {
    .gallery.gallery--pickup { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
}
@media (max-width:  480px) { .gallery.gallery--pickup { grid-template-columns: repeat(2, 1fr); } }

/* 一覧の下に置くブロックなので、境目の区切り線は上側に出す。
   幅の上限は持たせない。すぐ上の一覧（.gallery）が上限なしで広がるため、
   ここだけ 1200px で止めると広い画面でカードの大きさが揃わなくなる。 */
.pickup-section {
    padding: 1.25rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border);
}
/* 余白を詰める幅は一覧（.gallery の @media (max-width: 768px)）に合わせる。
   760px にしていると 761〜768px の間だけ左端が 8px ずれる。 */
@media (max-width: 768px) {
    .pickup-section { padding: .75rem 1rem 1rem; }
}

/* ===== PRODUCT CARD ===== */
.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
.card-link:hover { text-decoration: none; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .15s, transform .15s;
    cursor: pointer;
    height: 100%;
}
.card-link:hover .card { border-color: var(--accent); transform: translateY(-2px); }

.card-thumb {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
    background: var(--surface2);
}

.card-thumb-placeholder {
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 2rem;
}

.card-body { padding: .6rem .75rem .75rem; }

.card-code { font-size: .7rem; color: var(--muted); margin-bottom: .15rem; }

.card-title {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: .3rem;
}

.card-circle { font-size: .75rem; color: var(--sub); margin-bottom: .35rem; }

.card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: .4rem;
}

.rating { font-size: .78rem; color: #f5c542; }
.review-count { font-size: .72rem; color: var(--muted); }
.price { font-size: .78rem; color: var(--sub); flex-basis: 100%; }
.price-strike   { text-decoration: line-through; color: var(--muted); margin-right: .35em; }
.price-sale     { /* 親 .price と同じ見た目にする（区切り識別用class） */ }
.price-deadline { color: var(--muted); font-size: .7rem; margin-left: .4em; }

.card-tags { display: flex; flex-wrap: wrap; gap: .25rem; }

.tag-pill {
    font-size: .65rem;
    padding: .1rem .45rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--sub);
    text-decoration: none;
    display: inline-block;
}
a.tag-pill:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== EMPTY STATE ===== */
.empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--muted);
}
.empty p { margin-top: .5rem; font-size: .9rem; }

/* ===== BREADCRUMB ===== */
.breadcrumb {
    max-width: 1200px;
    margin: 0 auto;
    padding: .6rem 1.5rem 0;
    /* 作品名が長いと1行に収まらない。折り返すと段が増えて本文が押し下げられるため、
       横スクロールで逃がす。 */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.breadcrumb-list {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    font-size: .78rem;
}
.breadcrumb-item a {
    color: var(--sub);
    text-decoration: none;
}
.breadcrumb-item a:hover {
    color: var(--accent);
    text-decoration: underline;
}
.breadcrumb-item [aria-current="page"] { color: var(--ink); }
/* 区切り記号は装飾。読み上げに載せたくないので CSS で描く。 */
.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    margin: 0 .4rem;
    color: var(--muted);
}
@media (max-width: 640px) {
    .breadcrumb { padding: .5rem 1rem 0; }
}

/* ===== CIRCLE PAGE ===== */
/* 掲載数・平均・最新作。作品一覧より先に読ませたい要約なので hero 内に置く。 */
.circle-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin: .8rem 0 0;
}
.circle-fact dt {
    font-size: .7rem;
    color: var(--sub);
    margin-bottom: .1rem;
}
.circle-fact dd {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--ink);
}
.circle-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-top: .8rem;
}
.circle-tags-label {
    font-size: .7rem;
    color: var(--sub);
    margin-right: .15rem;
}
.circle-tags .tag-pill {
    font-size: .75rem;
    padding: .2rem .6rem;
}
/* タグ名の後ろに続く件数。主役はタグ名なので、一段落として添える。 */
.tag-pill-count {
    margin-left: .4em;
    opacity: .65;
    font-variant-numeric: tabular-nums;
}

/* ===== GENRE ARCHIVE (hub) ===== */
.genre-archive {
    list-style: none;
    margin: 0;
    padding: 0;
}
.genre-archive-item {
    padding: .7rem 0;
    border-bottom: 1px solid var(--border);
}
.genre-archive-item a {
    text-decoration: none;
    color: var(--ink);
}
.genre-archive-item a:hover .genre-archive-name { color: var(--accent); }
.genre-archive-name { font-weight: 600; }
.genre-archive-short {
    display: block;
    font-size: .78rem;
    color: var(--sub);
    margin-top: .2rem;
}

/* ===== GENRE CROSS LINKS ===== */
/* ジャンルページ同士を本文からつなぐ導線。
   作品カードは全体が <a> なので、カード内のタグをリンクにすると入れ子になる。
   その代わりをカードの外に置いたブロック。 */
.genre-links-section {
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    border-top: 1px solid var(--border);
}
.genre-links {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}
/* カード内のタグより一回り大きくする。ここは押してもらうための導線なので、
   指で触れる大きさを確保する。 */
.genre-links .tag-pill {
    font-size: .8rem;
    padding: .3rem .7rem;
    border-radius: 14px;
}

/* ===== DLSITE BLOG PARTS ===== */
.dlsite-blogparts-wrap {
    padding: 1.5rem 1.5rem 0;
    max-width: 1200px;
    margin: 0 auto;
}
.dlsite-blogparts-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 .75rem;
    text-align: center;
}
.dlsite-blogparts {
    display: flex;
    justify-content: center;
}
.dlsite-blogparts > [id^="DLsite_blog_parts_"] {
    max-width: 100%;
}
@media (max-width: 640px) {
    .dlsite-blogparts-wrap { padding: 1rem 1rem 0; }
}

/* PC/スマホの出し分けは各ビューのインラインスクリプトが行い、片方しか出力されない。
   以前は両方をHTMLに書いてここで display:none していたが、
   それではスクリプトの実行までは止められず、2つ読んで1つ捨てる形になっていた。 */

/* 作品詳細ページ内では、親の.detail-sectionが余白を持つので自前paddingは消す */
.dlsite-blogparts--in-section { padding: 0; }

/* DLsite公式CSSはあとから注入されるため、包含セレクタで特異性を上げて上書きする */
.dlsite-blogparts .DLsite_bp_body,
.dlsite-blogparts .DLsite_bp_inner,
.dlsite-blogparts .DLsite_bp_title_wrap {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--ink) !important;
}
.dlsite-blogparts .DLsite_bp_title,
.dlsite-blogparts .DLsite_bp_work_name,
.dlsite-blogparts .DLsite_bp_work_name a,
.dlsite-blogparts .DLsite_bp_maker_name,
.dlsite-blogparts .DLsite_bp_maker_name a,
.dlsite-blogparts .DLsite_bp_price,
.dlsite-blogparts dl,
.dlsite-blogparts dt,
.dlsite-blogparts dd,
.dlsite-blogparts li {
    color: var(--ink) !important;
    background: transparent !important;
}
.dlsite-blogparts .DLsite_bp_circle_name,
.dlsite-blogparts .DLsite_bp_circle_name a {
    color: var(--muted) !important;
}
.dlsite-blogparts .DLsite_bp_work_name a:hover,
.dlsite-blogparts .DLsite_bp_maker_name a:hover,
.dlsite-blogparts .DLsite_bp_circle_name a:hover {
    color: #7aa2ff !important;
}
.dlsite-blogparts .DLsite_bp_logo a {
    color: var(--muted) !important;
}
.dlsite-blogparts .DLsite_bp_btn_prev,
.dlsite-blogparts .DLsite_bp_btn_next {
    filter: invert(0.85) hue-rotate(180deg);
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem;
    padding: 1rem 1.5rem 2rem;
}
.page-btn, .page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-size: .85rem;
    text-decoration: none;
    transition: border-color .15s, background .15s, color .15s;
}
.page-btn:hover, a.page-num:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    text-decoration: none;
}
.page-num.is-current {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 700;
}
.page-btn.is-disabled {
    color: var(--muted);
    background: transparent;
    pointer-events: none;
    opacity: .5;
}
.page-ellipsis {
    color: var(--muted);
    padding: 0 .35rem;
    user-select: none;
}

/* ===== DETAIL PAGE ===== */
.back-link {
    color: var(--sub);
    font-size: .9rem;
    margin-right: .5rem;
    white-space: nowrap;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.detail-code {
    color: var(--muted);
    font-size: .85rem;
    font-weight: 400;
    font-family: monospace;
    margin-top: -.75rem;
}

.detail-wrap {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.main-image-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    display: block;
}
.main-image-placeholder {
    font-size: 4rem;
    color: var(--muted);
}
/* 画像の読み込みに失敗したとき、枠の中に出す説明。
   onerror 側で display:flex に切り替わるため、ここでは並びだけ指定する。 */
.main-image-error {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: 1.5rem 1rem;
    text-align: center;
}
.main-image-error-title { color: var(--sub);   font-size: .95rem; font-weight: 600; }
.main-image-error-sub   { color: var(--muted); font-size: .78rem; line-height: 1.6; }

.thumb-strip {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    margin-top: .75rem;
    padding-bottom: .5rem;
}
.thumb {
    width: 100px;
    height: 75px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    background: var(--surface2);
    transition: border-color .15s, transform .15s;
}
.thumb:hover { border-color: var(--accent); }
.thumb.active { border-color: var(--accent); transform: scale(1.05); }

.detail-right { display: flex; flex-direction: column; gap: 1rem; }

.detail-title {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ink);
}

.detail-circle {
    font-size: 1rem;
    color: var(--sub);
}
.circle-pill {
    display: inline-block;
    padding: .2rem .75rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--sub);
    text-decoration: none;
    font-size: .9rem;
}
.circle-pill:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.detail-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}
.meta-chip {
    font-size: .85rem;
    color: var(--sub);
}
.meta-chip + .meta-chip::before {
    content: '·';
    margin-right: .4rem;
    color: var(--muted);
}

.detail-rating {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.detail-rating .stars { font-size: 1rem; color: #f5c542; }
.rating-num { font-size: .9rem; color: var(--sub); }

.price-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}
.price-label { font-size: .75rem; color: var(--muted); margin-bottom: .25rem; }
.price-base {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: .75rem;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .25rem .5rem;
}
.price-strike-detail   { text-decoration: line-through; color: var(--muted); font-size: 1rem; font-weight: 500; }
.price-sale-detail     { color: var(--accent); font-size: 1.4rem; font-weight: 700; }
.price-deadline-detail { color: var(--sub); font-size: .8rem; font-weight: 400; }

.coupon-box {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    font-size: .9rem;
}
.coupon-box label { color: var(--sub); }
.coupon-box select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--ink);
    padding: .3rem .5rem;
    font-size: .85rem;
    cursor: pointer;
    outline: none;
}
.coupon-box select:focus { border-color: var(--accent); }
.discounted-arrow { color: var(--muted); }
.discounted-price {
    font-weight: 700;
    color: var(--accent);
    font-size: 1.05rem;
}

.btn-dlsite {
    display: inline-block;
    padding: .6rem 1.25rem;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
    align-self: flex-start;
}
.btn-dlsite:hover { background: var(--accent-deep); text-decoration: none; }

.detail-section {
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    border-top: 1px solid var(--border);
}
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: .75rem;
}

.description {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    line-height: 1.8;
    color: var(--ink);
    font-size: .9rem;
    word-wrap: break-word;
}
.description img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: .5rem 0;
}
.description a { color: var(--accent); }
.description p { margin: .5rem 0; }
.description h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.25rem 0 .5rem;
    color: var(--ink);
}
.description .work_parts { margin: 1rem 0; }
.description .work_parts_multitype {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .75rem;
}
.description .work_parts_multitype.type_left {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
@media (max-width: 600px) {
    .description .work_parts_multitype.type_left {
        grid-template-columns: minmax(0, 1fr);
    }
}

.credits {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 1.25rem;
    row-gap: .5rem;
    align-items: baseline;
}
.credits dt { color: var(--sub); font-size: .85rem; white-space: nowrap; }
.credits dd { color: var(--ink); font-size: .9rem; }

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.detail-tags-inline {
    margin-top: .5rem;
    align-items: center;
}
.detail-tags-label {
    font-size: .75rem;
    color: var(--sub);
    margin-right: .25rem;
}

/* ===== HERO SECTION ===== */
.hero {
    padding: 2.5rem 1.5rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-bottom: 1px solid var(--border);
}
.hero-inner {
    max-width: 1100px;
    margin: 0 auto;
}
.hero-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: .75rem;
    line-height: 1.4;
}
/* 導入文を出さないページ（ジャンル2ページ目以降）で下余白が残らないように */
.hero-title:last-child {
    margin-bottom: 0;
}
.hero-desc {
    color: var(--sub);
    font-size: .9rem;
    line-height: 1.7;
    margin-bottom: 1.25rem;
}
.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: .8rem;
    color: var(--ink);
}
.stat-badge.stat-total {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.hero-notice {
    font-size: .78rem;
    color: var(--muted);
    border-left: 3px solid var(--danger);
    padding-left: .75rem;
    margin-top: .5rem;
}
.site-title-link { color: inherit; text-decoration: none; }
.site-title-link:hover { text-decoration: none; }

/* ===== STATIC PAGES (about/privacy/contact) ===== */
.static-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
    color: var(--ink);
    line-height: 1.8;
}
.static-page h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--ink);
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}
.static-page h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: .75rem;
    color: var(--ink);
}
.static-page p { margin-bottom: 1rem; color: var(--sub); font-size: .92rem; }
.static-page ul { margin: 0 0 1rem 1.5rem; color: var(--sub); font-size: .92rem; }
.static-page ul li { margin-bottom: .35rem; }
.static-page a { color: var(--accent); }
/* ボタン見た目のリンクは上のリンク色より優先させる（accent背景にaccent文字で潰れるため） */
.static-page a.btn-primary { color: #fff; }
.static-page a.btn-secondary { color: var(--ink); }
.notice-box {
    padding: .85rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    font-size: .9rem;
}
.notice-warn {
    background: rgba(240,85,85,.08);
    border: 1px solid var(--danger);
    color: #ffb4b4;
}
.notice-ok {
    background: rgba(76,175,128,.08);
    border: 1px solid var(--ok);
    color: #b4f0d0;
}
.notice-info {
    background: rgba(124,106,247,.08);
    border: 1px solid var(--accent);
    color: #cec4ff;
}
.pr-badge {
    display: inline-block;
    padding: .05rem .35rem;
    margin: 0 .3rem;
    font-size: .7rem;
    font-weight: bold;
    line-height: 1.3;
    color: var(--warn);
    border: 1px solid var(--warn);
    border-radius: 3px;
    letter-spacing: .05em;
    vertical-align: middle;
}
.meta-sub { color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }

/* ===== CONTACT / EDIT FORM ===== */
.contact-form { display: flex; flex-direction: column; gap: 1rem; max-width: 600px; }
.form-row { display: flex; flex-direction: column; gap: .35rem; }
.form-row label, .form-label {
    font-size: .85rem;
    color: var(--sub);
    font-weight: 500;
}
.form-row .required { color: var(--danger); }
.form-row input[type=text],
.form-row input[type=email],
.form-row textarea,
.contact-form input[type=text],
.contact-form input[type=email],
.contact-form textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--ink);
    padding: .55rem .75rem;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
}
.contact-form input:focus, .contact-form textarea:focus { border-color: var(--accent); }
.form-actions { display: flex; align-items: center; gap: .75rem; }
.btn-primary {
    padding: .55rem 1.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .9rem;
    cursor: pointer;
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-secondary {
    padding: .55rem 1.25rem;
    background: var(--surface2);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }
.btn-danger {
    padding: .45rem 1rem;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .85rem;
    cursor: pointer;
}

/* ハニーポット（非表示・タブ移動も無効） */
.honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* ===== MY REVIEW ===== */
.my-review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}
.my-review-head .section-title { margin-bottom: 0; }
.my-review-edit-link {
    font-size: .8rem;
    color: var(--sub);
    padding: .25rem .65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.my-review-edit-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.my-review {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    line-height: 1.8;
    color: var(--ink);
    font-size: .9rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.my-review-empty { color: var(--muted); font-style: italic; }

/* ===== RATING UI ===== */
.rating-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.rating-avg-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .85rem;
    flex-wrap: wrap;
}
.rating-avg-stars { color: #f5c542; font-size: 1.1rem; }
.rating-avg-num { font-weight: 700; color: var(--ink); }
.rating-count, .rating-empty { color: var(--muted); font-size: .85rem; }
.rating-input { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.rating-input-label { color: var(--sub); font-size: .85rem; margin-right: .35rem; }
.star-row {
    display: inline-flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}
.star-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: .1rem .15rem;
    transition: color .1s;
}
.star-btn.active { color: #f5c542; }
.star-row:hover .star-btn { color: var(--muted); }
.star-row .star-btn:hover,
.star-row .star-btn:hover ~ .star-btn { color: #f5c542; }
.rating-msg { font-size: .8rem; color: var(--sub); margin-left: .5rem; }

/* ===== COMMENT UI ===== */
.comment-count { color: var(--muted); font-weight: 400; font-size: .85rem; }
.comment-form {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}
.comment-form input[type=text],
.comment-form textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--ink);
    padding: .55rem .75rem;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--accent); }
.comment-form-msg { font-size: .82rem; color: var(--sub); }

.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.comment-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
}
.comment-head {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .35rem;
}
.comment-name { font-weight: 600; font-size: .85rem; color: var(--ink); }
.comment-time { font-size: .75rem; color: var(--muted); }
.comment-report-btn {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: .72rem;
    padding: .15rem .55rem;
    border-radius: 4px;
    cursor: pointer;
}
.comment-report-btn:hover { border-color: var(--danger); color: var(--danger); }
.comment-body { color: var(--ink); font-size: .9rem; line-height: 1.7; word-wrap: break-word; }
.comment-empty { color: var(--muted); font-style: italic; text-align: center; padding: 2rem; }

.review-empty-cta {
    background: var(--accent-soft);
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    margin-bottom: 1rem;
    text-align: center;
}
.review-empty-cta-title {
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: .5rem;
}
.review-empty-cta-body {
    color: var(--sub);
    font-size: .88rem;
    line-height: 1.6;
    margin-bottom: .75rem;
}
.review-empty-cta-arrow {
    color: var(--accent);
    font-size: .88rem;
    font-weight: 600;
}

/* ===== ADMIN PANEL ===== */
.admin-comment-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.hidden-comment {
    background: var(--surface);
    border: 1px solid var(--danger);
    border-left-width: 4px;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.hidden-meta { margin-bottom: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.hidden-body { color: var(--sub); font-size: .9rem; line-height: 1.7; margin-bottom: .75rem; padding: .5rem .75rem; background: var(--surface2); border-radius: 4px; overflow-wrap: anywhere; word-break: break-word; }
.hidden-actions { display: flex; gap: .5rem; }

/* ===== ADMIN PANEL LAYOUT ===== */
/* 管理画面は一覧とテーブルが主役なので、文章ページ用の .static-page（800px）だと窮屈になる。
   幅だけ広げ、読み物とフォームは行が長くなりすぎない幅で止める。 */
.admin-panel { max-width: 1200px; }
.admin-panel > p,
.admin-panel .meta-sub,
.admin-panel .hidden-body { max-width: 78ch; }
.admin-panel .form-row input[type=text],
.admin-panel .form-row input[type=email],
.admin-panel .form-row textarea { max-width: 600px; }

/* ===== ADMIN PRODUCT LIST ===== */
.admin-search-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.admin-search-input {
    flex: 1; min-width: 12rem; max-width: 24rem;
    padding: .5rem .75rem; font-size: .9rem;
    background: var(--surface2); color: var(--ink);
    border: 1px solid var(--border); border-radius: 6px;
}
.admin-search-input:focus { border-color: var(--accent); outline: none; }
.admin-search-btn { padding: .5rem 1.25rem; }
.admin-search-clear { font-size: .85rem; color: var(--sub); }
.static-page a.admin-search-clear { color: var(--sub); }
.static-page a.admin-search-clear:hover { color: var(--accent); }
.admin-search-term { font-weight: normal; color: var(--sub); font-size: .9em; }

/* 絞り込みと並び順のバー。中身は inline-block のボタンなので指定しなくても横に並ぶが、
   その場合の間隔は HTML の改行由来の空白になり、CSS から調整できない。
   flex にして gap で間隔を持たせ、狭い画面では折り返す。
   上下の margin は隣接するバー同士で相殺されるので、間隔は .5rem のまま増えない。 */
.admin-filter-bar,
.admin-sort-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }

/* 並び順はフィルタと役割が違うので、見出しを付けてボタンも一段小さくし、階層を分ける。 */
.admin-sort-label { color: var(--sub); font-size: .85rem; }
.admin-sort-bar .btn-primary,
.admin-sort-bar .btn-secondary { padding: .35rem .8rem; font-size: .85rem; }
/* 発売日未取得は「まだ取れていない」ことが分かればよいので、通常の日付より落とす。 */
.admin-product-date.is-unknown { color: var(--sub); opacity: .7; }

/* 検索結果に出す一文の入力欄と、そのプレビュー。
   何文字で切られるかは画面幅とフォントで決まり、同じ文字数でも語の並びで
   切れる位置が変わる。そのため文字数を数えて示すのではなく、検索結果と同じ幅・
   同じ行数の枠を用意して、そこに流し込んだ結果をそのまま見せる。
   検索結果は白背景で表示されるため、この枠だけは管理画面の配色に合わせない。 */
.serp-hint   { color: var(--sub);  font-size: .85rem; line-height: 1.7; margin: .2rem 0 .5rem; }
.serp-note   { color: var(--warn); font-size: .8rem;  line-height: 1.7; margin: .4rem 0 0; }
.serp-source { color: var(--ok);   font-size: .8rem;  margin: .9rem 0 .4rem; }
.serp-source.is-fallback { color: var(--sub); }

/* 枠は縮めない。縮めるとプレビューが実物と違う位置で折り返してしまうので、
   入り切らないときは畳むか横に送る。 */
.serp-preview { display: flex; flex-wrap: wrap; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.serp-pane { flex: 0 0 auto; }
.serp-pane-label { font-size: .75rem; color: var(--sub); margin-bottom: .3rem; }

.serp-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .8rem .9rem;
    font-family: Arial, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}
.serp-pc { width: 600px; }
.serp-sp { width: 360px; }

.serp-site  { color: #202124; font-size: 12px; line-height: 1.5; }
.serp-path  { color: #5f6368; }
.serp-title {
    color: #1a0dab; font-size: 20px; line-height: 1.35; margin: .15rem 0 .2rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* スマホの検索結果は作品名を2行まで折り返す。 */
.serp-sp .serp-title {
    font-size: 18px; white-space: normal; text-overflow: clip;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.serp-desc {
    color: #4d5156; font-size: 14px; line-height: 1.58;
    display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden;
}
/* 説明文に割かれる行数。PCは2行、スマホは3行で打ち切られる。 */
.serp-pc .serp-desc { -webkit-line-clamp: 2; }
.serp-sp .serp-desc { -webkit-line-clamp: 3; }

.serp-cut { color: var(--warn); font-size: .75rem; margin: .35rem 0 0; }

/* DB構造の適用画面。結果は件数が多く、状態の違いが一目で分かることが重要なので、
   行ごとに色を分けて、失敗だけが目に留まるようにする。 */
.schema-table-wrap { overflow-x: auto; }
.schema-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.schema-table th,
.schema-table td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--border); }
.schema-table th { color: var(--sub); font-weight: normal; white-space: nowrap; }
.schema-status { white-space: nowrap; font-weight: bold; }
.schema-note { color: var(--sub); }
.schema-table tr.is-applied .schema-status { color: var(--ok); }
.schema-table tr.is-skipped .schema-status { color: var(--sub); }
.schema-table tr.is-failed  .schema-status { color: var(--warn); }
/* 失敗した行だけ背景を敷く。件数が多いので、色が付いているのが例外であるほうが読みやすい。 */
.schema-table tr.is-failed { background: rgba(240, 165, 85, .08); }

/* 変わったものだけの一覧。件数が少ないので表にせず、状態を頭に付けて並べる。 */
.schema-changed { list-style: none; margin: 0 0 1.2rem; padding: 0; }
.schema-changed li {
    padding: .5rem .7rem; margin-bottom: .35rem; font-size: .9rem;
    border: 1px solid var(--border); border-radius: 6px; background: var(--surface2);
}
.schema-changed li.is-applied .schema-status { color: var(--ok); }
.schema-changed li.is-failed  .schema-status { color: var(--warn); }
.schema-changed li.is-failed  { border-color: var(--warn); }
.schema-changed .schema-note { margin-top: .25rem; font-size: .8rem; word-break: break-word; }

.schema-detail { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface2); }
.schema-detail > summary { padding: .75rem 1rem; cursor: pointer; }
.schema-detail-body { padding: 0 1rem 1rem; }
.schema-group { font-size: .9rem; margin: 1rem 0 .4rem; }
.schema-list { margin: 0; padding-left: 1.2rem; }
.schema-list li { margin-bottom: .6rem; }
.schema-label { font-size: .85rem; }
/* SQLは折り返すと構造が読めなくなるため、そのまま横スクロールさせる。 */
.schema-sql {
    margin: .2rem 0 0; padding: .5rem .6rem; overflow-x: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .75rem;
    line-height: 1.5; color: var(--sub); white-space: pre;
}

.admin-bulk-bar {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    margin-top: 1rem; padding: .6rem .8rem;
    background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
}
.admin-bulk-bar .btn-primary,
.admin-bulk-bar .btn-secondary { padding: .35rem .8rem; font-size: .85rem; }
.admin-bulk-all { display: flex; align-items: center; gap: .35rem; font-size: .85rem; cursor: pointer; }
/* 件数は残り幅を取り、操作ボタンをバーの右端へ寄せる */
.admin-bulk-count { font-size: .8rem; color: var(--sub); margin-right: auto; }
.admin-product-check { flex-shrink: 0; display: flex; align-items: center; }
.admin-product-check input { width: 18px; height: 18px; cursor: pointer; }

.admin-product-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.admin-product-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: var(--radius);
    padding: .75rem 1rem;
}
.admin-product-row.is-public  { border-left-color: #22c55e; }
.admin-product-row.is-private { border-left-color: var(--sub); }
.admin-product-thumb { flex-shrink: 0; width: 96px; }
.admin-product-thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 4px; display: block; }
.admin-product-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.admin-product-badges { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.admin-product-meta a { font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-product-meta a:hover { color: var(--accent); }
.admin-product-badge {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 3px;
    width: fit-content;
}
.is-public  .admin-product-badge { background: #dcfce7; color: #15803d; }
.is-private .admin-product-badge { background: var(--surface2); color: var(--sub); }
.admin-product-sub { font-size: .8rem; color: var(--sub); }
.admin-product-actions { flex-shrink: 0; }

/* ===== ADMIN GENRE TABLE ===== */
.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.genre-sort-hint,
.admin-sort-hint { font-size: .8rem; color: var(--sub); margin: .25rem 0 .5rem; }
.genre-sort-hint kbd,
.admin-sort-hint kbd {
    font-family: monospace; font-size: .95em;
    border: 1px solid var(--border); border-radius: 3px;
    padding: 0 .3rem; background: var(--surface2);
}
/* AIアシストのモデル選択とボタン行（レビュー編集・ジャンル編集で共通）。
   モデル一覧はAPIから取得していて名前が長く、select の min-content 幅が
   最長の選択肢に引きずられて 600px を超える。
   フレックス項目の min-width は既定が auto（＝min-content）なので、
   max-width を付けても親の行がそこまでしか縮まず、狭い画面でボタンが枠外へ出る。
   親子ともに min-width: 0 を明示して、縮んで折り返せるようにする。 */
.ai-assist-controls { min-width: 0; }
#ai-model-select { max-width: min(100%, 320px); min-width: 0; }

.genre-sort-status { font-size: .8rem; min-height: 1.2em; margin-bottom: .35rem; color: var(--sub); }
.genre-sort-status.is-ok    { color: var(--ok); }
.genre-sort-status.is-error { color: var(--danger); }

.genre-admin-table { width: 100%; border-collapse: collapse; margin-top: .5rem; table-layout: fixed; }
.genre-admin-table th {
    text-align: left; padding: .5rem; font-size: .8rem; color: var(--sub);
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.genre-admin-table td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.genre-admin-table tr.is-dragging { background: var(--accent-soft); opacity: .85; }
.genre-admin-table tbody.is-sorting { cursor: grabbing; user-select: none; }

/* 列幅を固定して、タグ名やスラッグが途中で折り返されないようにする */
.gcol-handle  { width: 4.5rem; }
.gcol-slug    { width: 10rem; }
.gcol-tags    { width: 12rem; }
.gcol-state   { width: 5.5rem; }
.gcol-actions { width: 10rem; }

/* td は table-cell のまま保つ（flex にすると列幅の計算から外れて崩れる） */
.genre-handle-cell { white-space: nowrap; }
/* .admin-drag-handle は同じ見た目の別名。ランキング編集など、ジャンル以外の
   並び替えでも使う。genre- の名前を他の画面へ広げないために別名を足している */
.genre-drag-handle,
.admin-drag-handle {
    background: none; border: none; color: var(--sub);
    font-size: 1rem; line-height: 1; padding: .2rem .1rem;
    margin-right: .2rem; vertical-align: middle;
    cursor: grab; touch-action: none; /* タッチのスクロールに奪われないようにする */
}
.genre-drag-handle:hover,  .admin-drag-handle:hover  { color: var(--ink); }
.genre-drag-handle:focus,  .admin-drag-handle:focus  { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
.genre-drag-handle:active, .admin-drag-handle:active { cursor: grabbing; }
.genre-order { font-family: monospace; font-size: .8rem; color: var(--sub); vertical-align: middle; }

/* 名前と説明を1行ずつに抑える。全文は title 属性のホバーで読む */
.genre-name-cell { min-width: 0; }
.genre-name-cell strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.genre-short {
    display: block; font-size: .78rem; color: var(--sub);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.genre-slug-link {
    font-family: monospace; font-size: .85rem;
    display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.genre-tags-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.genre-tags-cell .tag-pill { margin-right: .25rem; }

.genre-inline-form { margin: 0; display: inline; }
.genre-state-toggle {
    font-size: .75rem; font-weight: 600; white-space: nowrap;
    padding: .2rem .5rem; border-radius: 999px;
    background: none; cursor: pointer;
}
.genre-state-toggle.is-on  { color: var(--ok);  border: 1px solid var(--ok); }
.genre-state-toggle.is-off { color: var(--sub); border: 1px solid var(--border); }
.genre-state-toggle:hover  { border-color: var(--accent); color: var(--accent); }

.genre-actions-cell { white-space: nowrap; }
.genre-actions-cell > a { margin-right: .35rem; }
.genre-btn-sm { font-size: .8rem; padding: .3rem .6rem; vertical-align: middle; }

.genre-btn-danger { color: var(--danger); border-color: var(--danger); }
.genre-btn-danger:hover { border-color: var(--danger); background: var(--danger); color: #fff; }

/* 狭い画面では6列が入りきらないので、スラッグ・対象タグを畳む。
   どちらも編集画面で確認・変更できる。 */
@media (max-width: 768px) {
    .genre-admin-table th:nth-child(3), .genre-admin-table td:nth-child(3),
    .genre-admin-table th:nth-child(4), .genre-admin-table td:nth-child(4) { display: none; }
    .gcol-handle  { width: 3.75rem; }
    .gcol-state   { width: 5rem; }
    .gcol-actions { width: 8.5rem; }
    .genre-btn-sm { padding: .3rem .45rem; }
}

/* ===== SITE FOOTER ===== */
.site-footer {
    margin-top: 3rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
}
.footer-nav {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.footer-nav a {
    color: var(--sub);
    font-size: .85rem;
}
.footer-nav a:hover { color: var(--accent); text-decoration: none; }
.footer-copy { color: var(--muted); font-size: .78rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; padding: 1rem; }
    .site-header { padding: 0 1rem; }
    .filter-bar { padding: .5rem 1rem; }
    .detail-wrap { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; padding: 1rem; }
    .detail-right { min-width: 0; }
    .detail-left { min-width: 0; }
    .detail-section { padding: 1.25rem 1rem; }
    .detail-title { font-size: 1.15rem; }
    /* 高さは PC と同じ 4:3 で先に確保する。aspect-ratio: auto にすると
       画像が届くまで高さ0になり、読み込み完了時に下の内容がずれる（CLS）。
       画像がブロックされた場合も枠が残らず、何も無いように見えてしまう。 */
    .main-image-box { max-height: 60vh; }
    .description { padding: 1rem; }
    .description table { max-width: 100%; display: block; overflow-x: auto; }
    .hero { padding: 1.5rem 1rem; }
    .hero-title { font-size: 1.15rem; }
    .hero-desc { font-size: .85rem; }
    .static-page { padding: 1.5rem 1rem 2rem; }
    .static-page h1 { font-size: 1.3rem; }

    /* --- 管理画面 --- */
    /* ヘッダー：高さ固定を解除し、ナビを2段目に折り返す */
    .admin-header { height: auto; flex-wrap: wrap; padding: .5rem 1rem; row-gap: .5rem; }
    .admin-header .admin-nav { order: 3; flex-basis: 100%; flex-wrap: wrap; }
    .admin-header .admin-nav-link { padding: .35rem .6rem; }
    /* 作品管理：行を折り返し、操作ボタンを下段フル幅に */
    .admin-product-row { flex-wrap: wrap; }
    .admin-product-actions { flex-basis: 100%; display: flex; gap: .5rem; }
    .admin-product-actions button { flex: 1; }
    /* 一括操作：全選択と件数を1段目、ボタンを2段目に分ける */
    .admin-bulk-bar button { flex: 1; }
    .admin-bulk-count { margin-right: 0; flex-basis: 100%; }
    /* ファイル入力のはみ出し対策。
       フィルタ・並び順バーの折り返しは基本ルール側で常時有効にしてある。 */
    .contact-form input[type=file] { max-width: 100%; }
}
/* ===== ADMIN ===== */
.admin-title { color: var(--sub); }

.admin-nav {
    display: flex;
    gap: .25rem;
    flex: 1;
}
.admin-nav-link {
    padding: .3rem .75rem;
    border-radius: 6px;
    font-size: .9rem;
    color: var(--sub);
    transition: background .15s, color .15s;
}
.admin-nav-link:hover {
    background: var(--surface2);
    color: var(--ink);
    text-decoration: none;
}
.admin-site-link {
    font-size: .85rem;
    padding: .3rem .75rem;
}
.admin-logout-link {
    font-size: .85rem;
    color: var(--danger);
    margin-left: .25rem;
}
.admin-logout-link:hover { text-decoration: underline; }

.admin-login {
    max-width: 400px;
    margin: 80px auto;
    padding: 0 1rem;
}
.admin-login h1 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
}
.admin-login .back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
}

/* インポート結果はフォーム群より上に出す（件数が多いと下端まで見に行くのが手間なため） */
.import-results { margin: 0 0 2rem; }
.import-results-ok { font-size: 1rem; margin-bottom: .5rem; color: var(--ok); }
.import-results-ng { font-size: 1rem; margin-bottom: .5rem; margin-top: 1rem; color: var(--danger); }
.import-results-list { list-style: none; padding: 0; }
.import-results-list li { padding: .3rem 0; font-size: .9rem; border-bottom: 1px solid var(--border); }
.ok { color: var(--ok); }
.ng { color: var(--danger); }

html, body { overflow-x: hidden; }
@media (max-width: 480px) {
    .gallery { grid-template-columns: repeat(2, 1fr); }
}

.genre-intro {
    max-width: 780px;
    line-height: 1.9;
}

.hamburger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.hamburger:hover {
    background: var(--surface);
    border-color: var(--accent);
}
.hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink);
    border-radius: 2px;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 200;
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
}
body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.site-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    /* 下端に続きがあるときだけ、うっすら光らせて気づけるようにする。
       1層目のカバーを local（本文と一緒にスクロール）、2層目の光を scroll（枠に固定）にすると、
       最下部まで来たところでカバーが光に重なって自動的に消える。
       JS もスクロール量の監視も要らず、項目が何件でも正しく動く。
       内容が短くてはみ出していない場合も、カバーが最初から重なるので光らない。
       光の色は --accent (#7c6af7) の 38%。--accent は透明度を持たないため直値で書いている
       （.btn-review-cta が --warn を rgba で書いているのと同じ扱い）。 */
    background-color: var(--surface);
    background-image:
        linear-gradient(to top, var(--surface), var(--surface)),
        linear-gradient(to top, rgba(124, 106, 247, .38), rgba(124, 106, 247, 0));
    background-repeat: no-repeat, no-repeat;
    background-position: bottom, bottom;
    background-size: 100% 48px, 100% 48px;
    background-attachment: local, scroll;
    border-right: 1px solid var(--border);
    z-index: 201;
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* ネイティブのスクロールバーは見た目が悪いので隠す。スクロール自体は可能。 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.site-drawer::-webkit-scrollbar {
    width: 0;
    height: 0;
}
body.drawer-open .site-drawer {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, .4);
}

.drawer-inner {
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.drawer-close {
    align-self: flex-end;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink);
    font-size: 1rem;
    cursor: pointer;
    transition: background .15s;
}
.drawer-close:hover { background: var(--surface2); }

.drawer-section {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.drawer-title {
    font-size: .85rem;
    font-weight: 700;
    color: var(--sub);
    letter-spacing: .05em;
    margin: 0;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

.drawer-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.drawer-item {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: .65rem .75rem;
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    transition: background .15s;
}
.drawer-item:hover {
    background: var(--accent-soft);
    text-decoration: none;
}
.drawer-item-name { font-size: 1rem; font-weight: 600; }
.drawer-item-short { font-size: .75rem; color: var(--sub); }

/* ドロワー先頭に置くため、下の見出しとの間隔は .drawer-inner の gap に任せる。 */
.drawer-cta .btn-review-cta { width: 100%; text-align: center; }

@media (min-width: 1024px) {
    .hamburger,
    .drawer-close,
    .drawer-backdrop {
        display: none !important;
    }
    .site-drawer {
        transform: translateX(0) !important;
        width: 260px;
        z-index: 50;
        box-shadow: none;
    }
    /* サイドバーの幅ぶんだけ本文をずらす。
       管理画面はサイドバーを出さないため、ずらすと左に空白ができてしまう。 */
    body:not(.admin-body) {
        padding-left: 260px;
    }
    body.drawer-open {
        overflow: auto;
    }
}

.btn-buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .85rem 1.5rem;
    background: linear-gradient(180deg, var(--accent), var(--accent-deep));
    color: #fff;
    border-radius: 10px;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 4px 14px rgba(124, 106, 247, .35);
    transition: transform .1s, box-shadow .2s, background .2s;
    line-height: 1.3;
    text-decoration: none;
}
.btn-buy:hover {
    background: linear-gradient(180deg, var(--accent-deep), var(--accent-deep));
    box-shadow: 0 6px 18px rgba(124, 106, 247, .5);
    text-decoration: none;
    transform: translateY(-1px);
}
.btn-buy:active { transform: translateY(0); }
.btn-buy-lead { font-size: 1rem; }
.btn-buy-price { font-size: 1.15rem; font-weight: 800; letter-spacing: .02em; }
.btn-buy-arrow { font-size: 1.1rem; }
.btn-buy-note {
    font-size: .72rem;
    color: var(--muted);
    margin-top: .5rem;
    text-align: center;
}

.btn-buy--top {
    width: 100%;
    align-self: stretch;
    margin-top: .25rem;
}

.highlights {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.highlight {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--sub);
    border-radius: 6px;
    flex-wrap: wrap;
    line-height: 1.5;
}
.highlight-label {
    font-size: .8rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--surface2);
    padding: .15rem .55rem;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}
.highlight-text {
    font-size: .9rem;
    color: var(--ink);
    word-break: break-word;
}
.highlight--sale   { border-left-color: var(--danger); }
.highlight--sale   .highlight-label { color: var(--danger); }
.highlight--rating { border-left-color: var(--warn); }
.highlight--rating .highlight-label { color: var(--warn); }
.highlight--new    { border-left-color: var(--accent); }
.highlight--new    .highlight-label { color: var(--accent); }
.highlight--tags   { border-left-color: var(--sub); }
.highlight--tags   .highlight-text { color: var(--sub); font-size: .85rem; }

.sticky-cta-mobile {
    display: none;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 100;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .95rem 1rem;
    background: linear-gradient(180deg, var(--accent), var(--accent-deep));
    color: #fff;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .35), 0 2px 6px rgba(124, 106, 247, .5);
    text-decoration: none;
    line-height: 1.3;
}
.sticky-cta-mobile:hover { text-decoration: none; }
.sticky-cta-lead { font-size: .95rem; }
.sticky-cta-price { font-size: 1.1rem; font-weight: 800; }
.sticky-cta-arrow { font-size: 1.05rem; }

@media (max-width: 768px) {
    .sticky-cta-mobile { display: inline-flex; }
    body { padding-bottom: 80px; }
}

/* ===== ランキングページ ===== */

.rank-period {
    margin-top: .5rem;
    font-size: .85rem;
    color: var(--sub);
}

.rank-list {
    list-style: none;
    margin: 0 auto;
    padding: 0 1rem;
    max-width: 860px;
}

.rank-item {
    display: grid;
    grid-template-columns: 3rem 160px 1fr;
    gap: 1rem;
    align-items: start;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
}

.rank-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    line-height: 1;
}

.rank-thumb-link { display: block; }

.rank-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    background: var(--surface2);
    display: block;
}

.rank-thumb--empty { background: var(--surface2); }

.rank-body { min-width: 0; }

.rank-title {
    margin: 0 0 .4rem;
    font-size: 1.05rem;
    line-height: 1.4;
}

.rank-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
    font-size: .8rem;
    color: var(--sub);
    margin-bottom: .6rem;
}

.rank-comment {
    margin: 0 0 .7rem;
    font-size: .92rem;
    line-height: 1.75;
    color: var(--ink);
}

.rank-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

/* ハブページ */

.rank-top3 {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.rank-top3-item a {
    display: block;
    position: relative;
    text-decoration: none;
    color: var(--ink);
}

.rank-top3-badge {
    position: absolute;
    top: .4rem;
    left: .4rem;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
}

.rank-top3-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    background: var(--surface2);
    display: block;
    margin-bottom: .5rem;
}

.rank-top3-title {
    display: block;
    font-size: .88rem;
    line-height: 1.45;
}

.rank-archive,
.rank-other-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rank-archive-item,
.rank-other-list li {
    padding: .7rem 0;
    border-bottom: 1px solid var(--border);
}

.rank-archive-meta,
.rank-other-count {
    display: block;
    font-size: .78rem;
    color: var(--sub);
    margin-top: .2rem;
}

.rank-other-more { margin-top: 1rem; }

@media (max-width: 640px) {
    .rank-item {
        grid-template-columns: 2.4rem 110px 1fr;
        gap: .7rem;
    }
    .rank-badge {
        width: 2.1rem;
        height: 2.1rem;
        font-size: .95rem;
    }
    .rank-top3 { grid-template-columns: 1fr; }
    .rank-top3-item a { display: grid; grid-template-columns: 110px 1fr; gap: .7rem; align-items: center; }
    .rank-top3-thumb { margin-bottom: 0; }
}
