body {
  margin: 0;
  padding: 0;
  background-color: #f8f4eb;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, rgba(245, 239, 226, 0.8) 100%),
    url('bg.webp');
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  /* 白ベース */
  font-family: 'Noto Serif JP', serif;
  overflow: hidden;
}

#container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.kakidashi {
  position: absolute;
  writing-mode: vertical-rl;
  /* 縦書き */
  font-size: clamp(1.7rem, 2.1vw, 2.2rem);
  line-height: 1.2;
  opacity: 0;
  animation: dissolve 12s ease-in-out forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80vw;
}

@keyframes dissolve {
  0% {
    opacity: 0;
    transform: translateY(-16px);
    filter: blur(3px);
  }

  10% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  82% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(3px);
  }
}

/* --- オープニングアニメーション（背景化） --- */
#opening-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(245, 239, 226, 0.32) 100%);
  z-index: -1;
  /* kakidashiより後ろへ */
  overflow: hidden;
  pointer-events: none;
  /* クリックを阻害しない */
}

/* 水中のゆらめき効果 */
.opening-water {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: radial-gradient(circle at 50% 50%, rgba(63, 114, 175, 0.1) 0%, transparent 50%);
  animation: ripple 8s infinite alternate ease-in-out;
  pointer-events: none;
}

@keyframes ripple {
  0% {
    transform: scale(1) translateY(0);
    opacity: 0.3;
  }

  100% {
    transform: scale(1.5) translateY(20px);
    opacity: 0.6;
  }
}

.opening-title {
  position: absolute;
  top: 16px;
  left: 16px;
  color: #1f3857;
  font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
  font-size: 0.95rem;
  /* サイズを小さく */
  letter-spacing: 0.14em;
  font-weight: 500;
  opacity: 0.28;
  /* 背景として目立ちすぎないように */
  text-shadow: 0 1px 6px rgba(255, 255, 255, 0.75);
  /* アニメーションを削除 */
  z-index: -1;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
    text-shadow: 0 4px 15px rgba(255, 255, 255, 0.5), 0 0 20px rgba(63, 114, 175, 0.3);
  }

  50% {
    transform: translateY(-10px);
    text-shadow: 0 14px 25px rgba(255, 255, 255, 0.3), 0 0 30px rgba(63, 114, 175, 0.5);
  }
}

/* --- ハンバーガーメニュー --- */
.menu-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 35px;
  height: 30px;
  cursor: pointer;
  z-index: 10001;
  /* アニメーションより手前 */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.menu-toggle span {
  display: block;
  height: 3px;
  width: 100%;
  background-color: #7a5a33;
  border-radius: 3px;
  transition: all 0.3s ease;
}

/* メニューオープン時のバツ印アニメーション */
.menu-toggle.open span:nth-child(1) {
  transform: translateY(13.5px) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
  transform: translateY(-13.5px) rotate(-45deg);
}

/* --- スライドメニュー本体 --- */
.slide-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  height: 100dvh;
  background-color: rgba(253, 253, 253, 0.95);
  box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  z-index: 10000;
  transform: translateX(100%);
  /* 初期は画面外 */
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  box-sizing: border-box;
}

.slide-menu.menu-open {
  transform: translateX(0);
  /* 表示 */
}

.menu-content {
  padding: 80px 30px calc(40px + env(safe-area-inset-bottom));
  color: #333;
  min-height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.menu-content h2 {
  font-size: 1.3rem;
  color: #112d4e;
  border-bottom: 2px solid #3f72af;
  padding-bottom: 5px;
  margin-bottom: 15px;
}

.about-section p {
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 15px;
  text-align: justify;
}

.about-section a {
  color: #3f72af;
  text-decoration: none;
}

.about-section a:hover {
  text-decoration: underline;
}

.jump-bookmarks-btn {
  width: 100%;
  border: 1px solid #d7c6b4;
  border-radius: 8px;
  background-color: #fff7ec;
  color: #7a5a33;
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.jump-bookmarks-btn:hover {
  background-color: #f3e6d9;
  transform: translateY(-1px);
}

.search-section {
  margin-top: 24px;
  padding: 14px 16px 16px;
  border: 1px solid #e5dacd;
  border-radius: 10px;
  background-color: #fffaf2;
}

.search-section h2 {
  margin-top: 0;
}

.search-help {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: #7a6b57;
}

.work-search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.work-search-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d7c6b4;
  border-radius: 8px;
  background-color: #fff;
  color: #5b4833;
  font-size: 0.9rem;
  padding: 0.52rem 0.62rem;
}

.work-search-button {
  border: 1px solid #d7c6b4;
  border-radius: 8px;
  background-color: #fff7ec;
  color: #7a5a33;
  font-size: 0.82rem;
  padding: 0.52rem 0.8rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.work-search-button:hover {
  background-color: #f3e6d9;
  transform: translateY(-1px);
}

.work-search-button:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

.work-search-status {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: #7a6b57;
}

.work-search-status.error {
  color: #a14227;
}

.work-search-results {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.work-search-item {
  margin: 0;
}

.work-search-result-btn {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e1d4c7;
  border-radius: 8px;
  background: #fff;
  color: #4c3b29;
  text-align: left;
  cursor: pointer;
  padding: 0.62rem 0.7rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.work-search-result-btn:hover {
  background-color: #fbf3e8;
  border-color: #d6bfa7;
}

.work-search-result-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  color: #5b3f20;
}

.work-search-result-author {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: #7b6853;
}

.work-search-result-snippet {
  display: block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: #8a7a66;
  line-height: 1.45;
}

.work-search-empty {
  margin: 0;
  padding: 0.7rem;
  border: 1px dashed #dac9b5;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #8a775f;
  background-color: #fffdf8;
  text-align: center;
}

.bgm-section {
  margin-top: 24px;
  padding: 14px 16px 16px;
  border: 1px solid #e5dacd;
  border-radius: 10px;
  background-color: #fffaf2;
}

.bgm-section h2 {
  margin-top: 0;
}

.bgm-description {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: #7a6b57;
}

.bgm-label {
  display: block;
  font-size: 0.82rem;
  color: #6a5844;
  margin-bottom: 6px;
}

.bgm-select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d7c6b4;
  border-radius: 8px;
  background-color: #fff;
  color: #5b4833;
  font-size: 0.85rem;
  padding: 0.48rem 0.56rem;
  margin-bottom: 10px;
}

.bgm-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.bgm-btn {
  border: 1px solid #d7c6b4;
  border-radius: 8px;
  background-color: #fff7ec;
  color: #7a5a33;
  font-size: 0.82rem;
  padding: 0.52rem 0.4rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.bgm-btn:hover {
  background-color: #f3e6d9;
  transform: translateY(-1px);
}

.bgm-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.bgm-status {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: #7a6b57;
  text-align: right;
}

.kakidashi .kakidashi-fade-tail-char {
  opacity: var(--tail-opacity, 0.5);
}

/* しおり一覧リスト */
.bookmarks-section {
  margin-top: 40px;
}

.menu-credit {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #e5dacd;
  text-align: center;
  color: #7a6b57;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

.menu-credit a {
  color: inherit;
  text-decoration: none;
}

.menu-credit a:hover {
  text-decoration: underline;
}

.bookmarks-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.bookmarks-list li {
  margin-bottom: 15px;
  padding: 15px;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.bookmarks-list li:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.bookmarks-list .bookmark-title {
  font-weight: bold;
  font-size: 1.1rem;
  color: #3f72af;
  margin-bottom: 5px;
  display: block;
}

.bookmarks-list .bookmark-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.bookmarks-list .bookmark-delete-btn {
  border: 1px solid #d7c6b4;
  background-color: #fff8f0;
  color: #7a5a33;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.bookmarks-list .bookmark-delete-btn:hover {
  background-color: #f3e6d9;
}

.bookmarks-list .bookmark-author {
  font-size: 0.85rem;
  color: #666;
  display: block;
  /* 改行させる */
}

.bookmarks-list .bookmark-snippet {
  font-size: 0.8rem;
  color: #888;
  margin-top: 6px;
  display: block;
  line-height: 1.4;
  border-left: 2px solid #ddd;
  padding-left: 8px;
}

.bookmarks-list .empty-message {
  background-color: transparent;
  border: none;
  color: #999;
  text-align: center;
  cursor: default;
}

.bookmarks-list .empty-message:hover {
  transform: none;
  box-shadow: none;
}

/* 閲覧履歴セクション */
.history-section {
  margin-top: 24px;
  padding: 14px 16px 16px;
  border: 1px solid #e5dacd;
  border-radius: 10px;
  background-color: #fffaf2;
}

.history-section h2 {
  margin-top: 0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-bottom: 1px solid #ede2d3;
  cursor: pointer;
  transition: background-color 0.15s;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background-color: rgba(201, 169, 110, 0.1);
}

.history-title {
  font-weight: 600;
  color: #3d2c18;
  font-size: 0.92rem;
}

.history-author {
  font-size: 0.8rem;
  color: #7a6b57;
}

.history-date {
  font-size: 0.72rem;
  color: #a09080;
}

.history-list .empty-message {
  background-color: transparent;
  border: none;
  color: #999;
  text-align: center;
  cursor: default;
  padding: 12px 0;
}

/* マイページリンク */
.mypage-link {
  display: block;
  text-align: right;
  color: #7a5a33;
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #ede2d3;
}

.mypage-link:hover {
  text-decoration: underline;
}

/* マイページを開く大きなボタン */
.mypage-section {
  margin-top: 24px;
}

.mypage-btn-large {
  display: block;
  width: 100%;
  text-align: center;
  padding: 14px;
  background: linear-gradient(135deg, #7a5a33, #5b4833);
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.mypage-btn-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* 読破セクション */
.completion-section {
  margin-top: 20px;
}

.completion-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d7c6b4;
  border-radius: 8px;
  background: linear-gradient(135deg, #3d2c18, #6d5132);
  color: #fffaf2;
  font-size: 0.95rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.completion-toggle-btn:hover {
  opacity: 0.9;
}

.completion-icon {
  font-size: 1.2rem;
}

.completion-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  opacity: 0.7;
}

.completion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid #e5dacd;
  border-top: none;
  border-radius: 0 0 8px 8px;
  background-color: #fffaf2;
}

.completion-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid #ede2d3;
  cursor: pointer;
  transition: background-color 0.15s;
}

.completion-item:last-child {
  border-bottom: none;
}

.completion-item:hover {
  background-color: rgba(201, 169, 110, 0.1);
}

.completion-item-title {
  font-weight: 600;
  color: #3d2c18;
  font-size: 0.92rem;
}

.completion-item-author {
  font-size: 0.8rem;
  color: #7a6b57;
}

.completion-item-date {
  font-size: 0.72rem;
  color: #a09080;
}

.completion-list .empty-message {
  color: #999;
  text-align: center;
  padding: 12px 0;
  cursor: default;
}

.viewer-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(248, 244, 235, 0.7);
  backdrop-filter: blur(2px);
}

.viewer-loading-overlay.is-visible {
  display: flex;
}

body.viewer-loading {
  cursor: progress;
}

.viewer-loading-card {
  min-width: 88px;
  min-height: 58px;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-loader {
  position: relative;
  width: 88px;
  height: 58px;
  perspective: 600px;
}

.book-loader-left,
.book-loader-right,
.book-loader-page {
  position: absolute;
  top: 4px;
  height: 50px;
  border: 1px solid #d7c1a4;
  background: #fffaf2;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.book-loader-left {
  left: 6px;
  width: 36px;
  border-radius: 6px 2px 2px 6px;
  background: linear-gradient(90deg, #f3e2cb 0%, #fdf8ef 100%);
}

.book-loader-right {
  left: 42px;
  width: 36px;
  border-radius: 2px 6px 6px 2px;
  background: linear-gradient(90deg, #fffdf9 0%, #f2e4d1 100%);
}

.book-loader::before {
  content: "";
  position: absolute;
  left: 41px;
  top: 4px;
  width: 2px;
  height: 50px;
  border-radius: 2px;
  background: #c6ab87;
  z-index: 6;
}

.book-loader-page {
  left: 42px;
  width: 36px;
  border-radius: 2px 6px 6px 2px;
  transform-origin: left center;
  background: linear-gradient(90deg, #fffefc 0%, #f2dfc5 100%);
  z-index: 5;
}

.book-loader-page.page-1 {
  animation: page-flip 1.45s linear infinite;
}

.book-loader-page.page-2 {
  animation: page-flip 1.45s linear infinite;
  animation-delay: 0.3s;
}

.book-loader-page.page-3 {
  animation: page-flip 1.45s linear infinite;
  animation-delay: 0.6s;
}

@keyframes page-flip {
  0% {
    transform: rotateY(0deg);
    opacity: 0.95;
  }

  20% {
    transform: rotateY(-18deg);
    opacity: 0.95;
  }

  58% {
    transform: rotateY(-175deg);
    opacity: 0.3;
  }

  60% {
    transform: rotateY(0deg);
    opacity: 0;
  }

  100% {
    transform: rotateY(0deg);
    opacity: 0.95;
  }
}

/* スマホ用のレスポンシブ対応 */
@media (max-width: 768px) {
  .kakidashi {
    font-size: 1.5rem;
    line-height: 1.28;
    max-width: 86vw;
    animation-duration: 9s;
  }

  .opening-title {
    top: 12px;
    left: 12px;
    font-size: 0.75rem;
    opacity: 0.22;
  }

  .slide-menu {
    width: 100vw;
  }

  .menu-content {
    padding: 70px 20px calc(30px + env(safe-area-inset-bottom));
  }
}

/* 自社ツール紹介（ハウス広告） */
.house-ad {
  display: block;
  text-decoration: none;
  background-color: #fff;
  border: 1px solid #e5dacd;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  transition: transform 0.2s, box-shadow 0.2s;
  text-align: left;
}

.house-ad:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #d6bfa7;
}

.house-ad-tag {
  display: inline-block;
  font-size: 0.65rem;
  background-color: #f7f2ea;
  color: #a08f79;
  padding: 1px 6px;
  border-radius: 3px;
  margin-bottom: 6px;
  border: 1px solid #e5dacd;
}

.house-ad-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #3d2c18;
  margin-bottom: 4px;
  line-height: 1.4;
}

.house-ad-desc {
  display: block;
  font-size: 0.75rem;
  color: #7a6b57;
  line-height: 1.5;
}