/* ============================================================
   style.css
   スマートフォンを先に書き、あとから @media でPC用を足す
   （モバイルファースト）。
   色は :root にまとめてあるので、ここを変えれば全体の色が変わります。
   ============================================================ */

:root {
  --bg:          #fbfbfd;
  --surface:     #ffffff;
  --border:      #e6e6ee;
  --text:        #16161d;
  --text-weak:   #6b6b7b;
  --accent:      #5b5bd6;
  --accent-weak: #eeeefc;
  --warn-bg:     #fff6e5;
  --warn-text:   #8a5a00;
  --shadow:      0 1px 2px rgba(20, 20, 40, .05), 0 8px 24px rgba(20, 20, 40, .05);

  --radius:      14px;
  --radius-sm:   999px;
  --wrap:        1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0f0f14;
    --surface:     #191922;
    --border:      #2a2a38;
    --text:        #f2f2f7;
    --text-weak:   #9b9bb0;
    --accent:      #9a9aff;
    --accent-weak: #23233a;
    --warn-bg:     #33280f;
    --warn-text:   #f0c777;
    --shadow:      0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 16px;
}

/* ---------- ヘッダー ---------- */
.site-header {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.site-lead {
  margin: 8px 0 0;
  color: var(--text-weak);
  font-size: 14px;
}

.site-lead strong { color: var(--accent); }

.breadcrumb { margin: 0 0 10px; font-size: 13px; }
.breadcrumb a { text-decoration: none; }

/* ---------- 検索 ---------- */
.search { margin: 24px 0 8px; }

.search-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 6px 4px 12px;
  transition: border-color .15s;
}

.search-box:focus-within { border-color: var(--accent); }

.search-icon { font-size: 16px; opacity: .6; }

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  /* 16px未満にすると、iPhoneで入力時に画面が勝手に拡大する */
  font-size: 16px;
  padding: 10px 0;
  font-family: inherit;
}

.search-submit {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 42px;
}

.search-hint {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--text-weak);
  min-height: 1.2em;   /* 文言が変わっても高さが動かないように */
}

.section-title {
  margin: 24px 0 12px;
  font-size: 15px;
  font-weight: 700;
}

/* ---------- 種類の切り替えタブ ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin: 20px 0 4px;
  padding: 4px;
  background: var(--accent-weak);
  border-radius: var(--radius-sm);
}

.tab {
  flex: 1;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  text-decoration: none;
  color: var(--text-weak);
  font-size: 14px;
  font-weight: 700;
  /* タップしやすい高さを確保する */
  min-height: 40px;
  line-height: 22px;
}

.tab.is-current {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(20, 20, 40, .12);
}

.count {
  margin: 0 0 12px;
  color: var(--text-weak);
  font-size: 13px;
}

/* ---------- 作品カードの並び ---------- */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}

/* カードと、その右上に重ねる ⓘ ボタンの土台 */
.card-wrap { display: block; position: relative; }

/* 詳細を開く ⓘ
   カード本体（button）の中には置けないので、上に重ねています。
   指で押しやすいよう 40px 角を確保しています。 */
.card-info {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  text-decoration: none;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
  border-radius: 50%;
  transition: background .12s, transform .12s;
}

.card-info:hover,
.card-info:focus-visible { background: rgba(0, 0, 0, .7); transform: scale(1.08); }
.card-info:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* カードは <button>。ボタンの初期スタイルを打ち消してから作り直す */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  margin: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .12s, transform .12s;
}

.card:active { transform: scale(.985); }

.card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 選択中の見た目 */
.card[aria-pressed="true"] {
  border-color: var(--accent);
}

.card[aria-pressed="true"] .card-check {
  opacity: 1;
  transform: scale(1);
}

.card-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  opacity: 0;
  transform: scale(.5);
  transition: opacity .12s, transform .12s;
}

.card-cover {
  display: block;
  position: relative;
  aspect-ratio: 2 / 3;      /* 画像の有無にかかわらず高さをそろえる */
  background: var(--accent-weak);
}

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

/* 画像がまだ無い作品用。--hue はPHP/JSから渡している */
.cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 38px;
  font-weight: 800;
  color: hsl(var(--hue) 55% 40%);
  background: linear-gradient(150deg,
              hsl(var(--hue) 70% 92%),
              hsl(calc(var(--hue) + 40) 70% 86%));
}

@media (prefers-color-scheme: dark) {
  .cover-placeholder {
    color: hsl(var(--hue) 60% 82%);
    background: linear-gradient(150deg,
                hsl(var(--hue) 30% 22%),
                hsl(calc(var(--hue) + 40) 30% 16%));
  }
}

.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(20, 20, 40, .72);
}

.badge-drama { background: rgba(190, 60, 90, .85); }

.card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  flex: 1;
}

.card-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.card-meta {
  display: block;
  font-size: 11px;
  color: var(--text-weak);
}

.card-synopsis {
  margin: 0;
  font-size: 12px;
  color: var(--text-weak);
}

/* ---------- タグ ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-weak);
  color: var(--accent);
  white-space: nowrap;
}

.tag-genre     { background: #eceafd; color: #5b4bd6; }
.tag-mood      { background: #fdeaf1; color: #c2416e; }
.tag-theme     { background: #e9f6ec; color: #2f7d47; }
.tag-setting   { background: #eaf2fd; color: #2b64b8; }
.tag-character { background: #fdf1e4; color: #a5651c; }
.tag-story     { background: #f0eafd; color: #7040c0; }
.tag-pace      { background: #eafafa; color: #1d7e7e; }
.tag-audience  { background: #f1f1f4; color: #5c5c6e; }

@media (prefers-color-scheme: dark) {
  .tag-genre     { background: #262148; color: #b3a8ff; }
  .tag-mood      { background: #401f2e; color: #ff9dbd; }
  .tag-theme     { background: #16331f; color: #86d79c; }
  .tag-setting   { background: #16273f; color: #8dbcf5; }
  .tag-character { background: #3a2a14; color: #f0bb74; }
  .tag-story     { background: #2b1f45; color: #c3a5f5; }
  .tag-pace      { background: #133434; color: #79d6d6; }
  .tag-audience  { background: #26262e; color: #b4b4c4; }
}

/* ---------- 下の「えらんだ作品」バー ---------- */
.tray {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(20, 20, 40, .10);
  /* iPhoneのホームバーに隠れないようにする */
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
}

.tray-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-weak);
}

.tray-count strong { color: var(--accent); font-size: 16px; }

.tray-clear {
  border: 0;
  background: transparent;
  color: var(--text-weak);
  font-family: inherit;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}

.tray-chips {
  list-style: none;
  margin: 0;
  padding: 0 0 2px;
  display: flex;
  gap: 6px;
  overflow-x: auto;         /* 多く選んでも横スクロールで収まる */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;    /* PCで太いスクロールバーが出て目立つのを抑える */
}

.tray-chips::-webkit-scrollbar { height: 6px; }
.tray-chips::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.chip-selected {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  max-width: 190px;
  padding: 5px 4px 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.chip-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-remove {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
}

.btn-primary {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:disabled {
  background: var(--border);
  color: var(--text-weak);
  cursor: not-allowed;
}

/* ---------- えらんだ作品（結果ページ上部の小さい一覧） ---------- */
.picked-row {
  list-style: none;
  margin: 0 0 8px;
  padding: 0 0 4px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.picked {
  flex: 0 0 auto;
  width: 76px;
  text-align: center;
}

.picked-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  font-size: 30px;
  font-weight: 800;
  color: hsl(var(--hue) 55% 40%);
  background: linear-gradient(150deg,
              hsl(var(--hue) 70% 92%),
              hsl(calc(var(--hue) + 40) 70% 86%));
}

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

.picked-title {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-weak);
}

@media (prefers-color-scheme: dark) {
  .picked-cover {
    color: hsl(var(--hue) 60% 82%);
    background: linear-gradient(150deg,
                hsl(var(--hue) 30% 22%),
                hsl(calc(var(--hue) + 40) 30% 16%));
  }
}

/* ---------- 好みプロフィール ---------- */
.profile {
  margin: 28px 0;
  padding: 18px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.profile .section-title { margin-top: 0; }

.profile-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.profile-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 10px;
}

.profile-bar {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-weak);
  overflow: hidden;
}

.profile-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.profile-note {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--text-weak);
}

/* ---------- おすすめ ---------- */
.rec-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.rec {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.rec-head {
  display: grid;
  grid-template-columns: 40px 60px 1fr;
  align-items: center;
  gap: 10px;
}

.rec-rank {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  line-height: 1.1;
}

.rec-rank small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-weak);
}

/* 上位3件は少し目立たせる */
.rec:nth-child(1) .rec-rank { font-size: 30px; }
.rec:nth-child(2) .rec-rank,
.rec:nth-child(3) .rec-rank { font-size: 27px; }

.rec-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  font-size: 24px;
  font-weight: 800;
  color: hsl(var(--hue) 55% 40%);
  background: linear-gradient(150deg,
              hsl(var(--hue) 70% 92%),
              hsl(calc(var(--hue) + 40) 70% 86%));
}

.rec-cover img { width: 100%; height: 100%; object-fit: cover; }

@media (prefers-color-scheme: dark) {
  .rec-cover {
    color: hsl(var(--hue) 60% 82%);
    background: linear-gradient(150deg,
                hsl(var(--hue) 30% 22%),
                hsl(calc(var(--hue) + 40) 30% 16%));
  }
}

.rec-headings { min-width: 0; }

.rec-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.rec-meta {
  display: block;
  font-size: 12px;
  color: var(--text-weak);
}

.rec-match {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 10px;
}

.rec-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-weak);
  overflow: hidden;
}

.rec-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), hsl(280 70% 62%));
}

.rec-percent {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.rec-reason {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-weak);
  font-size: 13px;
  line-height: 1.6;
}

.rec-reason-icon { margin-right: 4px; }

.rec-synopsis {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-weak);
  line-height: 1.65;
}

/* ---------- どこで見られるか ---------- */
.watch {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
}

.watch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin-bottom: 6px;
}

.watch-row:last-of-type { margin-bottom: 0; }

.watch-label {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* 追加のお金がかからない＝緑、かかる＝オレンジ。色でひと目で分かるようにする */
.watch-free .watch-label { background: #e9f6ec; color: #2f7d47; }
.watch-paid .watch-label { background: #fff1e0; color: #a5651c; }

@media (prefers-color-scheme: dark) {
  .watch-free .watch-label { background: #16331f; color: #86d79c; }
  .watch-paid .watch-label { background: #3a2a14; color: #f0bb74; }
}

.watch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.provider {
  display: inline-block;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-weak);
  font-size: 11px;
  white-space: nowrap;
}

/* サービスへ飛べるものは、押せると分かる見た目にする */
.provider-link {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  /* 指でタップしやすい高さを確保する */
  min-height: 28px;
  line-height: 20px;
}

.provider-link:active { background: var(--accent-weak); }
.provider-link span { opacity: .6; font-size: 10px; }

.provider-more { border-style: dashed; }

.watch-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
}

.rec-action { margin: 12px 0 0; }

.btn-add {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-add span {
  font-weight: 400;
  font-size: 12px;
  opacity: .8;
}

.btn-add:active { background: var(--accent-weak); }

.back-link {
  margin: 32px 0;
  font-size: 14px;
}

/* ---------- そのほか ---------- */
.empty {
  padding: 48px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-weak);
}

.empty-sub { font-size: 13px; }

.notice {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-weak);
  font-size: 13px;
}

.notice p { margin: 0 0 10px; }
.notice p:last-child { margin-bottom: 0; }

.notice-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.next-preview { margin-top: 32px; }

.phase-note {
  margin: 24px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-weak);
  color: var(--text-weak);
  font-size: 13px;
}

.site-footer {
  margin-top: 48px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--text-weak);
  font-size: 12px;
}

/* 外部サービスへの帰属表示（規約上の義務。消さないこと） */
.attribution {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.6;
  opacity: .85;
}

/* ---------- ここからPC向け ---------- */
@media (min-width: 768px) {
  .site-header { padding: 56px 0 32px; }
  .site-title  { font-size: 34px; }
  .site-lead   { font-size: 16px; }
  .grid        { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px; }
  .card-title  { font-size: 14px; }

  .tray-inner {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  .tray-head  { flex: 0 0 auto; flex-direction: column; align-items: flex-start; gap: 0; }
  .tray-chips { flex: 1; }
  .btn-primary { width: auto; flex: 0 0 auto; padding-inline: 32px; }
}

/* 見出しの横に出す件数 */
.section-count {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-weak);
  white-space: nowrap;
}

.section-count:empty { display: none; }

/* 件数の上限で切れたときの断り */
.list-more {
  margin: 20px 0 0;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-weak);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}

/* ============================================================
   作品の詳細（work.php のページ / 下からせり上がるパネル）
   ============================================================ */

.wd-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
}

.wd-head { display: flex; gap: 14px; align-items: flex-start; }

.wd-cover {
  flex: 0 0 auto;
  width: 96px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: var(--border);
}

.wd-cover-none {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  background: hsl(var(--hue, 220) 55% 62%);
}

.wd-headings { min-width: 0; flex: 1; }
.wd-title { margin: 0 0 4px; font-size: 20px; font-weight: 800; line-height: 1.35; }
.wd-kana  { margin: 0; font-size: 12px; color: var(--text-weak); }
.wd-en    { margin: 2px 0 0; font-size: 12px; color: var(--text-weak); }
.wd-meta  { margin: 6px 0 0; font-size: 13px; color: var(--text-weak); }

.wd-section { margin-top: 20px; }
.wd-h {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-weak);
}

.wd-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }

.wd-synopsis {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
}
.wd-synopsis.is-empty { color: var(--text-weak); font-style: italic; }

.wd-official {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
}

.wd-back { margin-top: 24px; }

/* ---------- せり上がるパネル ---------- */

/* パネルが開いている間は、後ろのページをスクロールさせない */
body.sheet-open { overflow: hidden; }

.sheet { position: fixed; inset: 0; z-index: 100; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  animation: sheet-fade .18s ease-out;
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .3);
  animation: sheet-up .22s cubic-bezier(.2, .8, .3, 1);
}

@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up   { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* 上端のつまみ。押せるものではなく「下から出てきた」ことを伝える印 */
.sheet-grip {
  width: 40px;
  height: 4px;
  margin: 10px auto 4px;
  border-radius: 999px;
  background: var(--border);
}

.sheet-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  color: var(--text-weak);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.sheet-close:hover { background: var(--border); }
.sheet-close:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 中身だけがスクロールする（ページ全体は動かない） */
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 18px 4px;
}

.sheet-loading { color: var(--text-weak); font-size: 14px; }

.sheet-foot {
  flex: 0 0 auto;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.sheet-foot .btn-primary { width: 100%; }
.sheet-foot .btn-primary.is-selected { background: var(--text-weak); }

.sheet-permalink { font-size: 12px; color: var(--text-weak); }

/* パネルの中では見出しの上の余白を詰める */
.sheet-body .wd-head { padding-top: 4px; }

@media (min-width: 720px) {
  /* PCでは中央のダイアログとして出す（下から出す必要がないため） */
  .sheet-panel {
    left: 50%;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, 92vw);
    max-height: 82vh;
    border-radius: 18px;
    animation: sheet-pop .18s cubic-bezier(.2, .8, .3, 1);
  }
  @keyframes sheet-pop {
    from { opacity: 0; transform: translate(-50%, -46%) scale(.97); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }
  .sheet-grip { display: none; }
  .sheet-foot { flex-direction: row; }
  .sheet-foot .btn-primary { width: auto; flex: 1; }
  .wd-cover { width: 120px; }
}

/* 動きを減らす設定にしている人には、アニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .sheet-panel, .sheet-backdrop { animation: none !important; }
}
