/* ======================================
 * 佐久市志 PDF表示システム - カスタムスタイル
 * Webアクセシビリティ AA 対応
 * ====================================== */

/* ルートフォントサイズ設定 */
html {
  font-size: 16px; /* 1rem = 16px */
}

/* フォントサイズ設定クラス */
html.font-size-1-0 {
  font-size: 16px;
}

html.font-size-1-5 {
  font-size: 24px;
}

html.font-size-2-0 {
  font-size: 32px;
}

/* 背景色テーマ */
body.theme-white {
  background-color: #ffffff;
  color: #212529;
}

body.theme-blue {
  background-color: #1e3a8a;
  color: #ffffff;
}

body.theme-blue .sidebar-desktop,
body.theme-blue .offcanvas-body,
body.theme-blue .tab-content,
body.theme-blue .search-container,
body.theme-blue .toc-tab-content,
body.theme-blue .search-tab-content {
  background-color: #2563eb;
  color: #ffffff;
}

body.theme-blue .toc-item {
  color: #ffffff;
}

body.theme-blue .toc-item:hover {
  background-color: #1e40af;
}

body.theme-blue .toc-item.active {
  background-color: #1e3a8a;
  border-left: 4px solid #93c5fd;
  font-weight: 600;
}

body.theme-blue .toc-level-2 {
  color: #f0f0f0;
}

body.theme-blue .toc-level-3 {
  color: #e8e8e8;
}

body.theme-blue .sidebar-tabs,
body.theme-blue .search-results-header {
  background-color: #1e40af;
  color: #ffffff;
}

body.theme-blue .nav-link {
  color: #e0e0e0;
}

body.theme-blue .nav-link:hover {
  background-color: #1e3a8a;
  border-bottom-color: #ffffff;
  color: #ffffff;
}

body.theme-blue .nav-link.active {
  background-color: #1e3a8a;
  border-bottom-color: #ffffff;
  color: #ffffff;
}

body.theme-blue .page-navigation-bottom,
body.theme-blue .page-navigation {
  background-color: #1e3a8a;
}

body.theme-blue .search-result-item,
body.theme-blue .search-result-text {
  color: #ffffff;
}

body.theme-blue .search-result-item:hover {
  background-color: #1e40af;
}

body.theme-blue .search-result-page {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

body.theme-blue .pdf-container {
  background-color: #1e3a8a;
}

body.theme-black {
  background-color: #000000;
  color: #ffeb3b;
}

body.theme-black .sidebar-desktop,
body.theme-black .offcanvas-body,
body.theme-black .tab-content,
body.theme-black .search-container,
body.theme-black .toc-tab-content,
body.theme-black .search-tab-content {
  background-color: #1a1a1a;
  color: #ffeb3b;
}

body.theme-black .toc-item {
  color: #ffeb3b;
}

body.theme-black .toc-item:hover {
  background-color: #2a2a2a;
}

body.theme-black .toc-item.active {
  background-color: #3a3a3a;
  border-left: 4px solid #ff9999;
  font-weight: 600;
}

body.theme-black .toc-level-2 {
  color: #ffd700;
}

body.theme-black .toc-level-3 {
  color: #ffe066;
}

body.theme-black .sidebar-tabs,
body.theme-black .search-results-header {
  background-color: #2a2a2a;
  color: #ffeb3b;
}

body.theme-black .nav-link {
  color: #d4af37;
}

body.theme-black .nav-link:hover {
  background-color: #3a3a3a;
  border-bottom-color: #ffeb3b;
  color: #ffeb3b;
}

body.theme-black .nav-link.active {
  background-color: #1a1a1a;
  border-bottom-color: #ffeb3b;
  color: #ffeb3b;
}

body.theme-black .page-navigation-bottom,
body.theme-black .page-navigation {
  background-color: #000000;
  border-top-color: #444444;
}

body.theme-black .search-result-item,
body.theme-black .search-result-text {
  color: #ffeb3b;
}

body.theme-black .search-result-item:hover {
  background-color: #2a2a2a;
}

body.theme-black .search-result-page {
  color: #ffeb3b;
}

body.theme-black .pdf-container {
  background-color: #000000;
}

body.theme-black .form-control {
  background-color: #2a2a2a;
  border-color: #444444;
  color: #ffeb3b;
}

body.theme-black .btn-outline-secondary,
body.theme-black .btn-outline-primary {
  color: #ffeb3b;
  border-color: #ffeb3b;
}

/* スキップリンク（アクセシビリティ対応） */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #086bd4;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 9999;
  border-radius: 0 0 4px 0;
}

.skip-link:focus {
  top: 0;
}

/* フォーカス表示の強化（WCAG 2.4.7準拠） */
*:focus {
  outline: 2px solid #086bd4;
  outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #086bd4;
  outline-offset: 2px;
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
  body {
    background: #000;
    color: #fff;
  }

  .sidebar-desktop,
  .search-container {
    background-color: #000;
    border-color: #fff;
  }
}

/* ベーススタイル */
body {
  height: 100vh;
  overflow: hidden;
  font-family:
    "Noto Sans JP",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-weight: 400;
  line-height: 1.6;
}

/* Material Symbols Outlined 調整 */
.material-symbols-outlined {
  vertical-align: middle;
  font-size: 1.25rem; /* 20px */
  line-height: 1;
  font-variation-settings:
    "FILL" 0,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24;
}

/* フォント読み込み中はアイコンを非表示にしてリガチャ文字のちらつきを防止 */
body.fonts-loading .material-symbols-outlined {
  opacity: 0;
}

body:not(.fonts-loading) .material-symbols-outlined {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.btn .material-symbols-outlined {
  font-size: 1.125rem; /* 18px */
}

.btn-sm .material-symbols-outlined {
  font-size: 1rem; /* 16px */
}

.nav-link .material-symbols-outlined {
  font-size: 1.125rem; /* 18px */
  margin-right: 0.25rem; /* 4px */
}

.offcanvas-title .material-symbols-outlined {
  font-size: 1.5rem; /* 24px */
  vertical-align: middle;
  margin-right: 0.5rem; /* 8px */
}

/* サイドバー（デスクトップ） */
.sidebar-desktop {
  height: 100vh;
  overflow-y: auto;
  background-color: #f8f9fa;
  border-right: 0.0625rem solid #dee2e6; /* 1px */
  scrollbar-width: thin;
  scrollbar-color: #ddd #f8f9fa;
  display: flex;
  flex-direction: column;
}

.sidebar-desktop::-webkit-scrollbar {
  width: 0.5rem; /* 8px */
}

.sidebar-desktop::-webkit-scrollbar-track {
  background: #f8f9fa;
}

.sidebar-desktop::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 0.25rem; /* 4px */
}

.sidebar-desktop::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

/* Offcanvas（モバイル） */
.offcanvas {
  width: 85% !important;
  max-width: 21.875rem; /* 350px */
  z-index: 1070 !important;
}

.offcanvas-backdrop {
  z-index: 1060 !important;
}

.offcanvas-header {
  background-color: #086bd4;
  color: white;
  padding: 1rem 1.5rem;
}

.offcanvas-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.offcanvas-header .btn-close {
  filter: invert(1);
}

.offcanvas-body {
  padding: 0;
}

/* PDFコンテナ */
.pdf-container {
  height: calc(100vh - 3.75rem - env(safe-area-inset-bottom, 0px)); /* 60px */
  overflow: visible;
  position: relative;
  background-color: #f5f5f5;
  padding: 1.25rem 1.25rem 0 1.25rem; /* 20px */
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 目次アイテム */
.toc-item {
  padding: 0.5rem 0.9375rem; /* 8px 15px */
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 0.875rem; /* 14px */
}

.toc-item:hover {
  background-color: #e9ecef;
}

.toc-item.active {
  background-color: #0056b3;
  color: white;
  border-left: 4px solid #17a2b8;
  font-weight: 600;
}

/* 目次の階層スタイル */
.toc-level-0 {
  padding-left: 0;
  font-weight: bold;
  font-size: 0.875rem; /* 14px */
}

/* 化学式・数式の上標・下標 */
.toc-item sup,
.toc-item sub {
  font-size: 0.7em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

.toc-item sup {
  top: -0.5em;
}

.toc-item sub {
  bottom: -0.25em;
}

.toc-level-1 {
  padding-left: 0.5rem; /* 8px - 章 */
  font-weight: 600;
  font-size: 0.8125rem; /* 13px */
}

.toc-level-2 {
  padding-left: 1.25rem; /* 20px - 節 */
  font-size: 0.8125rem; /* 13px */
  color: #595959;
}

.toc-level-3 {
  padding-left: 2rem; /* 32px - 数字 */
  font-size: 0.8125rem; /* 13px */
  color: #757575;
}

.toc-level-4 {
  padding-left: 2.75rem; /* 44px - (数字) */
  font-size: 0.8125rem; /* 13px */
  color: #757575;
}

.toc-level-5 {
  padding-left: 3.5rem; /* 56px - その他 */
  font-size: 0.8125rem; /* 13px */
  color: #757575;
}

/* サイドバータブ */
.sidebar-tabs {
  background-color: #f8f9fa;
  border-bottom: 0.125rem solid #dee2e6; /* 2px */
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-tabs .nav-link {
  color: #343a40;
  border: none;
  border-bottom: 0.1875rem solid transparent;
  border-radius: 0;
  padding: 0.75rem 1.25rem;
  font-weight: 500;
}

.sidebar-tabs .nav-link:hover {
  background-color: #e9ecef;
  border-bottom-color: #086bd4;
  color: #0056b3;
}

.sidebar-tabs .nav-link.active {
  background-color: white;
  color: #0056b3;
  border-bottom-color: #0056b3;
}

/* 検索コンテナ */
.search-container {
  padding: 15px;
  background-color: white;
  flex-shrink: 0;
}

.search-container .input-group {
  margin-bottom: 10px;
}

.search-container .form-control {
  font-size: 14px;
  border-radius: 4px 0 0 4px;
}

.search-container .btn {
  border-radius: 0 4px 4px 0;
}

/* タブコンテンツ */
.tab-content {
  flex: 1;
  background-color: white;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-content > .tab-pane {
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

.tab-content > .tab-pane.active.show {
  display: flex;
}

/* 検索タブと目次タブ（テーマカラー設定用） */
.search-tab-content,
.toc-tab-content {
  /* テーマカラー設定で背景色等を上書き */
}

.toc-tab-content nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 検索結果 */
.search-results-header {
  padding: 10px 15px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #495057;
  flex-shrink: 0;
  z-index: 10;
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #ccc #f1f1f1;
  min-height: 0;
}

.search-results-list::-webkit-scrollbar {
  width: 8px;
}

.search-results-list::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 4px;
}

.search-results-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.search-results-list::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.search-result-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: #e9ecef;
}

.search-result-page {
  color: #0056b3;
  font-weight: bold;
  margin-right: 8px;
}

.search-result-text {
  color: #333;
}

.search-highlight {
  background-color: #ffe033;
  color: #000000;
  padding: 1px 2px;
  border-radius: 2px;
  font-weight: 500;
}

body.theme-blue .search-highlight {
  background-color: #ffd700;
  font-weight: 600;
}

body.theme-black .search-highlight {
  background-color: #ff9999;
  font-weight: 600;
}

/* 検索進度表示 */
.search-progress {
  padding: 1rem;
  flex-shrink: 0;
  background-color: white;
}

.search-progress .progress {
  border-radius: 0.25rem; /* 4px */
  background-color: #e9ecef;
}

.search-progress .progress-bar {
  background-color: #086bd4;
  transition: width 0.3s ease;
}

body.theme-blue .search-progress {
  background-color: #2563eb;
}

body.theme-blue .search-progress .progress {
  background-color: #1e40af;
}

body.theme-blue .search-progress .progress-bar {
  background-color: #60a5fa;
}

body.theme-blue .search-progress .text-primary {
  color: #ffffff !important;
}

body.theme-blue .search-progress .text-muted {
  color: #e0e0e0 !important;
}

body.theme-black .search-progress {
  background-color: #1a1a1a;
}

body.theme-black .search-progress .progress {
  background-color: #2a2a2a;
}

body.theme-black .search-progress .progress-bar {
  background-color: #ffeb3b;
}

body.theme-black .search-progress .text-primary {
  color: #ffeb3b !important;
}

body.theme-black .search-progress .text-muted {
  color: #ffd700 !important;
}

/* ローディング */
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  color: #666;
  z-index: 10;
}

body.theme-blue .loading {
  color: #ffffff;
}

body.theme-black .loading {
  color: #ffeb3b;
}

/* PDF表示 */
.pdf-page-wrapper {
  position: relative !important;
  display: inline-block;
  padding: 0;
  overflow: visible;
  touch-action: none;
}

.pdf-viewer {
  display: block;
  position: relative;
}

/* ハイライト表示 */
.search-highlight-layer {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  pointer-events: none !important;
  z-index: 10 !important;
  background: transparent !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.search-highlight-box {
  position: absolute !important;
  background-color: rgba(255, 235, 59, 0.3) !important;
  border: 2px solid rgba(255, 193, 7, 0.6) !important;
  border-radius: 4px !important;
  pointer-events: none !important;
  z-index: 9999 !important;
  box-shadow: 0 2px 6px rgba(255, 193, 7, 0.3) !important;
  animation: highlightPulse 2s ease-in-out infinite !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body.theme-blue .search-highlight-box {
  background-color: rgba(96, 165, 250, 0.4) !important;
  border: 2px solid rgba(96, 165, 250, 0.8) !important;
  box-shadow: 0 2px 6px rgba(96, 165, 250, 0.3) !important;
  animation: highlightPulseBlue 2s ease-in-out infinite !important;
}

body.theme-black .search-highlight-box {
  background-color: rgba(255, 153, 153, 0.35) !important;
  border: 2px solid rgba(255, 153, 153, 0.7) !important;
  box-shadow: 0 2px 6px rgba(255, 153, 153, 0.3) !important;
  animation: highlightPulseBlack 2s ease-in-out infinite !important;
}

@keyframes highlightPulse {
  0%,
  100% {
    background-color: rgba(255, 235, 59, 0.3);
  }
  50% {
    background-color: rgba(255, 235, 59, 0.5);
  }
}

@keyframes highlightPulseBlue {
  0%,
  100% {
    background-color: rgba(96, 165, 250, 0.4);
  }
  50% {
    background-color: rgba(96, 165, 250, 0.6);
  }
}

@keyframes highlightPulseBlack {
  0%,
  100% {
    background-color: rgba(255, 153, 153, 0.35);
  }
  50% {
    background-color: rgba(255, 153, 153, 0.5);
  }
}

/* ページナビゲーション（下部固定） */
.page-navigation-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  background-color: #ffffff;
  border-top: 0.125rem solid #dee2e6; /* 2px */
  box-shadow: 0 -0.125rem 0.625rem rgba(0, 0, 0, 0.1); /* -2px 10px */
  /* iOS対応：ダブルタップズーム防止 */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* iOSセーフエリア対応 */
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* デスクトップ時は目次を避ける */
@media (min-width: 768px) {
  .page-navigation-bottom {
    left: 25%;
  }
}

.page-navigation {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  padding: 0.75rem 0.9375rem; /* 12px 15px */
  background-color: #fff;
  gap: 0.5rem; /* 8px */
  max-width: 100%;
  /* iOS対応：ダブルタップズーム防止 */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.page-navigation .btn {
  margin: 0;
  white-space: nowrap;
  font-size: 0.875rem; /* 14px */
  padding: 0.375rem 0.75rem; /* 6px 12px */
}

.page-navigation span {
  white-space: nowrap;
}

.page-navigation .info-text {
  font-size: 0.6875rem; /* 11px */
  margin-left: 0.625rem; /* 10px */
}

/* ページ情報表示とジャンプ入力 */
.page-info-wrapper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: bold;
}

.page-current-input {
  width: 3rem; /* 48px */
  text-align: center;
  font-size: 0.875rem; /* 14px */
  font-weight: bold;
  padding: 0.2rem 0.3rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.8);
  color: inherit;
  cursor: pointer;
  transition: all 0.2s;
  -moz-appearance: textfield; /* Firefox */
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 数字入力の矢印を非表示 */
.page-current-input::-webkit-inner-spin-button,
.page-current-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-current-input:hover {
  border-color: #086bd4;
  background-color: rgba(8, 107, 212, 0.08);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.08),
    0 0 0 0.1rem rgba(8, 107, 212, 0.1);
}

.page-current-input:focus {
  border-color: #086bd4;
  background-color: #ffffff;
  box-shadow: 0 0 0 0.2rem rgba(8, 107, 212, 0.25);
  outline: none;
  cursor: text;
}

.page-separator {
  font-weight: bold;
  color: inherit;
  margin: 0 0.15rem;
}

.page-total {
  font-weight: bold;
  color: inherit;
}

/* 青テーマ */
body.theme-blue .page-current-input {
  color: #ffffff;
  background-color: rgba(30, 64, 175, 0.5);
  border-color: #60a5fa;
}

body.theme-blue .page-current-input:hover {
  border-color: #93c5fd;
  background-color: rgba(30, 64, 175, 0.7);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 0 0.1rem rgba(147, 197, 253, 0.2);
}

body.theme-blue .page-current-input:focus {
  border-color: #93c5fd;
  background-color: #1e40af;
  box-shadow: 0 0 0 0.2rem rgba(147, 197, 253, 0.4);
}

/* 黒テーマ */
body.theme-black .page-current-input {
  color: #ffeb3b;
  background-color: rgba(42, 42, 42, 0.8);
  border-color: #ffd700;
}

body.theme-black .page-current-input:hover {
  border-color: #ffeb3b;
  background-color: rgba(58, 58, 58, 0.9);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.3),
    0 0 0 0.1rem rgba(255, 235, 59, 0.2);
}

body.theme-black .page-current-input:focus {
  border-color: #ffeb3b;
  background-color: #2a2a2a;
  box-shadow: 0 0 0 0.2rem rgba(255, 235, 59, 0.4);
}

/* アクセシビリティ設定ボタン */
.accessibility-btn {
  position: fixed;
  top: 0.625rem; /* 10px */
  right: 0.625rem; /* 10px */
  z-index: 1060;
  border-radius: 50%;
  box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.3); /* 2px 10px */
  width: 3rem; /* 48px */
  height: 3rem; /* 48px */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dee2e6;
}

.accessibility-btn .material-symbols-outlined {
  font-size: 1.5rem; /* 24px */
}

.accessibility-btn:hover {
  background-color: #f8f9fa;
}

body.theme-blue .accessibility-btn {
  background-color: #2563eb;
  border-color: #1e40af;
  color: #ffffff;
}

body.theme-blue .accessibility-btn:hover {
  background-color: #1e40af;
}

body.theme-black .accessibility-btn {
  background-color: #1a1a1a;
  border-color: #444444;
  color: #ffeb3b;
}

body.theme-black .accessibility-btn:hover {
  background-color: #333333;
}

/* アクセシビリティ設定パネル */
.accessibility-offcanvas {
  width: 320px !important;
}

.accessibility-offcanvas .offcanvas-header {
  background-color: #086bd4;
  color: white;
}

.accessibility-offcanvas .btn-close {
  filter: invert(1);
}

body.theme-blue .offcanvas-header,
body.theme-blue .accessibility-offcanvas .offcanvas-header {
  background-color: #1e40af;
}

body.theme-black .offcanvas-header,
body.theme-black .accessibility-offcanvas .offcanvas-header {
  background-color: #2a2a2a;
  color: #ffeb3b;
}

.accessibility-offcanvas .offcanvas-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.accessibility-section {
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 0.5rem;
}

.accessibility-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: #495057;
}

.accessibility-section-title .material-symbols-outlined {
  font-size: 1.125rem;
}

body.theme-blue .accessibility-offcanvas .offcanvas-body {
  background-color: #2563eb;
}

body.theme-blue .accessibility-section {
  background-color: #1e40af;
}

body.theme-blue .accessibility-section-title {
  color: #ffffff;
}

body.theme-black .accessibility-offcanvas .offcanvas-body {
  background-color: #1a1a1a;
}

body.theme-black .accessibility-section {
  background-color: #2a2a2a;
}

body.theme-black .accessibility-section-title {
  color: #ffeb3b;
}

body.theme-blue .text-muted {
  color: #e0e0e0 !important;
}

body.theme-black .text-muted {
  color: #ffd700 !important;
}

body.theme-blue .btn-outline-primary {
  color: #ffffff;
  border-color: #60a5fa;
  background-color: #1e40af;
}

body.theme-blue .btn-outline-primary:hover {
  background-color: #1e3a8a;
  border-color: #93c5fd;
}

body.theme-blue .btn-check:checked + .btn-outline-primary,
body.theme-blue .btn-outline-primary.active {
  background-color: #ffffff;
  color: #1e3a8a;
  border-color: #ffffff;
}

body.theme-black .btn-outline-primary {
  color: #ffeb3b;
  border-color: #ffd700;
  background-color: #2a2a2a;
}

body.theme-black .btn-outline-primary:hover {
  background-color: #3a3a3a;
  border-color: #ffeb3b;
  color: #ffeb3b;
}

body.theme-black .btn-check:checked + .btn-outline-primary,
body.theme-black .btn-outline-primary.active {
  background-color: #ffeb3b;
  color: #000000;
  border-color: #ffeb3b;
}

body.theme-blue .btn-secondary {
  background-color: #1e40af;
  border-color: #1e40af;
  color: #ffffff;
}

body.theme-blue .btn-secondary:hover {
  background-color: #1e3a8a;
  border-color: #1e3a8a;
}

body.theme-black .btn-secondary {
  background-color: #444444;
  border-color: #444444;
  color: #ffeb3b;
}

body.theme-black .btn-secondary:hover {
  background-color: #555555;
  border-color: #555555;
  color: #ffeb3b;
}

body.theme-blue .btn-outline-secondary:not(:hover),
body.theme-blue .btn-primary,
body.theme-blue .page-navigation .btn {
  color: #ffffff;
  border-color: #ffffff;
}

body.theme-blue .btn-primary {
  background-color: #1e40af;
  border-color: #ffffff;
}

body.theme-blue .btn-primary:hover {
  background-color: #1e3a8a;
}

body.theme-blue .btn-outline-secondary:hover {
  background-color: #ffffff;
  color: #1e3a8a;
}

body.theme-blue #pageInfo,
body.theme-blue #zoomLevel {
  color: #ffffff;
}

body.theme-black .btn-outline-secondary:not(:hover),
body.theme-black .btn-primary,
body.theme-black .page-navigation .btn {
  color: #ffeb3b;
  border-color: #ffeb3b;
}

body.theme-black .btn-primary {
  background-color: #2a2a2a;
  border-color: #ffeb3b;
}

body.theme-black .btn-primary:hover {
  background-color: #3a3a3a;
  color: #ffeb3b;
}

body.theme-black .btn-outline-secondary:hover {
  background-color: #ffeb3b;
  color: #000000 !important;
}

body.theme-black #pageInfo,
body.theme-black #zoomLevel {
  color: #ffeb3b;
}

/* モバイル用メニューボタン */
.mobile-menu-btn {
  position: fixed;
  top: 0.625rem; /* 10px */
  left: 0.625rem; /* 10px */
  z-index: 1060;
  border-radius: 0.5rem; /* 8px */
  box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.3); /* 2px 10px */
  padding: 0.5rem 1rem; /* 8px 16px */
  font-size: 0.875rem; /* 14px */
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.375rem; /* 6px */
}

.mobile-menu-btn .material-symbols-outlined {
  font-size: 1.25rem; /* 20px */
}

/* レスポンシブデザイン */
@media (max-width: 576px) {
  .page-navigation {
    padding: 0.625rem 0.5rem; /* 10px 8px */
    gap: 0.3125rem; /* 5px */
  }

  .page-navigation .btn {
    padding: 0.3125rem 0.5rem; /* 5px 8px */
    font-size: 0.8125rem; /* 13px */
  }

  .page-navigation #zoomLevel {
    font-size: 0.8125rem; /* 13px */
    margin: 0 0.3125rem !important; /* 5px */
  }

  .page-info-wrapper {
    gap: 0.15rem;
  }

  .page-current-input {
    width: 2.5rem; /* 40px */
    font-size: 0.8125rem; /* 13px */
    padding: 0.15rem 0.25rem;
  }

  .page-separator,
  .page-total {
    font-size: 0.8125rem; /* 13px */
  }
}

@media (max-width: 767.98px) {
  .pdf-container {
    padding: 4.375rem 0.625rem 0.625rem 0.625rem; /* 70px 10px 10px 10px */
    height: calc(100vh - 3.75rem - env(safe-area-inset-bottom, 0px)); /* 60px */
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .sidebar-desktop {
    width: 35%;
  }

  .main-content {
    width: 65%;
  }

  .page-navigation-bottom {
    left: 35%;
  }
}

/* ========================================
 * ズームレベル表示（固定幅）
 * ======================================== */
#zoomLevel {
  display: inline-block;
  min-width: 3.25rem; /* 52px - 固定幅で "100%" を表示できる */
  text-align: center;
  font-family: "Courier New", Courier, monospace;
  font-variant-numeric: tabular-nums;
}

/* ========================================
 * PDF読み込み進度表示
 * ======================================== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(248, 249, 250, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(0.3125rem); /* 5px */
  -webkit-backdrop-filter: blur(0.3125rem); /* 5px */
}

.loading-content {
  text-align: center;
  padding: 1.875rem; /* 30px */
  background-color: white;
  border-radius: 0.75rem; /* 12px */
  box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.1); /* 4px 20px */
  max-width: 25rem; /* 400px */
}

.loading-content .progress {
  height: 0.5rem; /* 8px */
  border-radius: 0.25rem; /* 4px */
  margin: 0 auto;
}

.loading-content small {
  display: block;
  font-size: 0.875rem; /* 14px */
}

/* テーマ別ローディング表示 */
body.theme-blue .loading-overlay {
  background-color: rgba(30, 58, 138, 0.95);
}

body.theme-blue .loading-content {
  background-color: #2563eb;
  color: #ffffff;
}

body.theme-blue .loading-content h5 {
  color: #ffffff;
}

body.theme-blue .loading-content .text-muted {
  color: #e0e0e0 !important;
}

body.theme-blue .loading-content .progress {
  background-color: #1e40af;
}

body.theme-blue .loading-content .progress-bar {
  background-color: #60a5fa;
}

body.theme-blue .loading-content .spinner-border,
body.theme-blue .loading-content .text-primary {
  color: #ffffff !important;
}

body.theme-black .loading-overlay {
  background-color: rgba(0, 0, 0, 0.95);
}

body.theme-black .loading-content {
  background-color: #1a1a1a;
  color: #ffeb3b;
}

body.theme-black .loading-content h5 {
  color: #ffeb3b;
}

body.theme-black .loading-content .text-muted {
  color: #ffd700 !important;
}

body.theme-black .loading-content .progress {
  background-color: #2a2a2a;
}

body.theme-black .loading-content .progress-bar {
  background-color: #ffeb3b;
}

body.theme-black .loading-content .spinner-border,
body.theme-black .loading-content .text-primary {
  color: #ffeb3b !important;
}

#tableOfContentsDesktop,
#tableOfContentsMobile {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: #ddd #f8f9fa;
}
#tableOfContentsDesktop::-webkit-scrollbar,
#tableOfContentsMobile::-webkit-scrollbar {
  width: 8px;
}
#tableOfContentsDesktop::-webkit-scrollbar-track,
#tableOfContentsMobile::-webkit-scrollbar-track {
  background: #f8f9fa;
}
#tableOfContentsDesktop::-webkit-scrollbar-thumb,
#tableOfContentsMobile::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}
#tableOfContentsDesktop::-webkit-scrollbar-thumb:hover,
#tableOfContentsMobile::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

/* ========================================
 * Bootstrap #6c757d アクセシビリティ対応オーバーライド
 * #6c757d → #5a636b（コントラスト比改善）
 * ======================================== */
:root {
  --bs-secondary: #5a636b;
  --bs-secondary-rgb: 90, 99, 107;
}

.text-muted {
  color: #5a636b !important;
}

.btn-secondary {
  background-color: #5a636b;
  border-color: #5a636b;
}

.btn-secondary:hover {
  background-color: #4e5760;
  border-color: #4e5760;
}

.btn-outline-secondary {
  color: #5a636b;
  border-color: #5a636b;
}

.btn-outline-secondary:hover {
  background-color: #5a636b;
  border-color: #5a636b;
}
