:root {
  --bg: #fff8fa;
  --surface: #ffffff;
  --text: #2b2330;
  --muted: #7a6f7d;
  --accent: #e8467c;
  --accent-soft: #fde6ee;
  --border: #eedde4;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1519;
    --surface: #251e24;
    --text: #f2eaf0;
    --muted: #a898a5;
    --accent: #ff6b9a;
    --accent-soft: #3a2230;
    --border: #3a2f38;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
main { max-width: 1200px; margin: 0 auto; padding: 0 16px 40px; }
h1 { font-size: 1.4rem; margin: 20px 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; display: flex; align-items: baseline; gap: 12px; }
.more { font-size: .85rem; font-weight: normal; margin-left: auto; }
.muted { color: var(--muted); font-size: .9rem; margin: 4px 0 12px; }
.empty { color: var(--muted); padding: 24px 0; }
.section { margin-top: 28px; }

/* header / footer */
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.logo picture, .logo img { display: block; width: 32px; height: 32px; }
.nav { display: flex; gap: 14px; font-size: .9rem; overflow-x: auto; white-space: nowrap; }
.nav-ai { font-weight: 700; }
.site-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px; border-top: 1px solid var(--border); }

/* hero */
.hero {
  display: flex; align-items: center; gap: 16px;
  margin-top: 16px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
}
.chara { display: block; flex-shrink: 0; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface)); }
.chara img { display: block; width: 100%; height: auto; }
.hero-chara { width: 110px; }
.bubble {
  position: relative; margin: 0 0 14px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.btn-ai, .btn-main, .btn-sub, .search button, .chat-form button {
  display: inline-block; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 700; text-align: center;
}
.btn-ai { padding: 12px 18px; background: var(--accent); color: #fff; white-space: nowrap; font-size: .95rem; }
.btn-ai:hover { text-decoration: none; opacity: .9; }

/* search */
.search { display: grid; grid-template-columns: 1fr; gap: 8px; }
.search input, .search select, .chat-form input {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.search button { padding: 10px 18px; background: var(--accent); color: #fff; }
@media (min-width: 768px) {
  .search { grid-template-columns: 1fr 200px 140px auto; }
  .hero-chara { width: 160px; }
}

/* cards */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.card-img { display: block; aspect-ratio: 147 / 200; background: var(--accent-soft); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 大きいパッケージ画像は見開き（左: 裏表紙 / 右: 表紙）なので右寄せで表紙を見せる */
.card-img img.cover-crop { object-position: right center; }
.noimg { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .8rem; }
.card-body { padding: 8px 10px 10px; font-size: .85rem; }
.card-title { font-size: .9rem; margin: 0 0 6px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a { color: var(--text); }
.card-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 0; }
.card-meta dt { color: var(--muted); }
.card-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.card-meta dd a + a::before { content: "、"; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips a, .chips span {
  padding: 2px 10px; border-radius: 999px; background: var(--accent-soft);
  color: var(--text); font-size: .85rem;
}
.chips small { margin-left: 4px; color: var(--muted); }
.card-meta .chips a + a::before { content: none; }
.reason { margin: 8px 0 0; padding: 8px; border-radius: 8px; background: var(--accent-soft); }
.reason-label { display: block; font-size: .75rem; color: var(--accent); font-weight: 700; }
.reason.is-pending .reason-text { color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .reason.is-pending .reason-text { animation: none; } }
.card-links { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.btn-main { padding: 8px 12px; background: var(--accent); color: #fff; }
.btn-sub { padding: 7px 12px; border: 1px solid var(--accent); color: var(--accent); }
.btn-main:hover, .btn-sub:hover { text-decoration: none; opacity: .9; }

/* work detail */
.work-detail .card { flex-direction: column; }
@media (min-width: 768px) {
  .work-detail .card { flex-direction: row; }
  .work-detail .card-img { width: 300px; flex-shrink: 0; }
  .work-detail .card-body { font-size: .95rem; padding: 16px; }
  .work-detail .card-links { flex-direction: row; }
}
.spec { margin-top: 16px; border-collapse: collapse; font-size: .9rem; }
.spec th, .spec td { padding: 6px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.spec th { color: var(--muted); font-weight: normal; }

/* actresses */
.actresses { list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 768px) { .actresses { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.actresses a { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text); font-size: .85rem; text-align: center; }
.actresses img, .noimg-round { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); display: block; }
.actresses small { color: var(--muted); }
.actress-head { display: flex; align-items: center; gap: 16px; }
.actress-head img { border-radius: 50%; object-fit: cover; }

.pager { display: flex; justify-content: center; gap: 16px; margin-top: 24px; }

/* chat: スマホは キャラ → チャット → おすすめ作品 の縦並び */
.chat-layout { display: flex; flex-direction: column; gap: 20px; margin-top: 16px; }
.chat-pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.chat-chara { display: flex; align-items: center; gap: 12px; }
.chat-chara-img { width: 72px; }
.chat-name { font-weight: 700; margin: 0; }
.chat-log { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px;
  max-height: 50vh; overflow-y: auto; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-ai { align-self: flex-start; background: var(--accent-soft); border-top-left-radius: 4px; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.msg-pending { opacity: .6; }
.chat-form { display: flex; gap: 8px; }
.chat-form button { padding: 10px 18px; background: var(--accent); color: #fff; flex-shrink: 0; }
.chat-form button:disabled { opacity: .5; cursor: wait; }
.chat-note { font-size: .75rem; color: var(--muted); margin: 8px 0 0; }
/* PC: 左にキャラ+チャット、右におすすめ作品 */
@media (min-width: 1024px) {
  .chat-layout { flex-direction: row; align-items: flex-start; }
  .chat-pane { width: 400px; flex-shrink: 0; position: sticky; top: 72px; }
  .chat-chara-img { width: 120px; }
  .chat-log { max-height: calc(100vh - 360px); }
  .chat-results { flex: 1; min-width: 0; }
  .chat-results .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.chat-reset { margin-left: auto; padding: 4px 12px; font: inherit; font-size: .8rem; color: var(--muted);
  background: none; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }

/* コンシェルジュ選択 */
.chara-picker { display: flex; gap: 8px; margin: 10px 0 0; }
.chara-picker a { flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--text); font-size: .8rem; }
.chara-picker a:hover { text-decoration: none; border-color: var(--accent); }
.chara-picker a[aria-current] { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.chara-picker-img { width: 32px; border-radius: 50%; }
.hero-choose { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 12px 0 0; font-size: .8rem; color: var(--muted); }
.hero-choose a { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.hero-choose-img { width: 28px; border-radius: 50%; }
.chara-picker a > span { display: flex; flex-direction: column; line-height: 1.3; }
.chara-picker small, .chat-name small { font-weight: normal; font-size: .72rem; color: var(--muted); }
.chat-name small { display: block; }
.hero-choose small { color: var(--muted); }
