body {
  font-family: system-ui, sans-serif;
  margin: 0;
  background: #f4f4f8;
  color: #111;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #222;
  color: #fff;
  padding: 8px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.logo { flex: 0 0 auto; }

.topbar-center {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
}

.right-controls { flex: 0 0 auto; }

.container {
  margin: 72px 0 72px 0;
  padding: 0 8px;
  box-sizing: border-box;
}

.menu-input, .menu-button, .menu-button-in, .sort-select, .lang-select {
  height: 32px;
  line-height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  border: none;
  background: #444;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.hit-count {
  color: #fff;
  font-size: 13px;
  margin-right: 6px;
  min-width: 40px;
  text-align: right;
  display: inline-block;
  opacity: 0.8;
}

/* 検索ボックス + クリアボタン */
.search-wrapper {
  position: relative;
  display: inline-block;
}
#search-input {
  height: 32px;
  line-height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  border: none;
  background: #444;
  color: #fff;
  font-size: 14px;
}
#search-clear {
  display: none;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  color: #fff;
}
#search-clear:hover { color: #ff4444; }
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

#loading-spinner {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* 共通 dex-list */
.dex-list {
  display: grid;
  gap: 8px;
}
.dex-item {
  background: #fff;
  padding: 8px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  display:block;
  flex-direction: row;
  gap: 8px;
  min-height: 72px;
  align-items: center;
}
.icon { width: 64px; height: 64px; object-fit: contain; background: #fff; }
.dex-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.title-line { display: flex; align-items: baseline; gap: 2px; white-space: nowrap; }
.title-line .dex-number { font-weight: normal; font-size: 0.9rem; }
.title-line .dex-name { font-weight: bold; }
.title-line .dex-ex { font-style: italic; }
.title-line .dex-category { font-weight: normal; color: #444; font-size: 0.9rem; }
.status-line { display: flex; align-items: center; gap: 1px; height: 16px; }
.status-line img {
  height: 16px;
  object-fit: contain;
}

/* タイプ・タマゴアイコンを含む行に適用 */
.status-line {
  display: inline-flex;
  align-items: center;
  min-width: 100px; /* ← 必要に応じて調整 */
  gap: 1; /* 余白を一定化 */
}

/* タイプやタマゴが1つしかないとき、ダミーを確保 */
.status-line .placeholder16 {
  width: 16px;
  height: 16px;
  display: inline-block;
  visibility: hidden; /* 非表示だがレイアウトを保つ */
}

.stats-line { display: flex; gap: 8px; font-size: 0.9rem; flex-wrap: wrap; }
.stats-line span { display: inline-block; min-width: 120px; }
.stats-line .ability-abh { color: #999; }

/* ステータスバー */
.status-bar {
  position: relative;
  display: flex;
  align-items: center;
  height: 10px;
  margin-left: 6px;
  transition: height 0.25s ease;
  user-select: none;
  cursor: pointer;
}
.status-bar.expanded {
  height: 24px;
}
.status-bar .status-frame {
  position: absolute; left: 0; top: 0; width: 300px; height: 100%;
  border: 1px solid #888; box-sizing: border-box; z-index: 2; pointer-events: none;
}
.bar-wrapper { position: relative; height: 100%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.bar-wrapper .bar { position: absolute; left: 0; top: 0; height: 100%; width: 100%; z-index: 0; transition: width 0.25s ease; }
.bar-wrapper .status-label {
  position: relative; z-index: 3; pointer-events: none; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1; color: black;
  -webkit-text-stroke: 2px white; paint-order: stroke fill;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.status-bar.expanded .status-label { opacity: 1; transform: translateY(0); }
.status-bar .H { background: #FFEE00; }
.status-bar .A { background: #FF4444; }
.status-bar .B { background: #FF9900; }
.status-bar .C { background: #3399FF; }
.status-bar .D { background: #AA33CC; }
.status-bar .S { background: #33CC33; }
/*.bar-wrapper.too-narrow .status-label { opacity: 0 !important; transform: translateY(6px) !important; }*/

#filter-panel {
  display: none;
  position: absolute;
  top: 60px; /* 初期位置（必要に応じて調整） */
  left: calc(50% - 200px); /* 中央寄せの代替（幅300px想定） */
  width: 400px;  
  background: #222;
  border: 1px solid #888;
  padding: 8px;
  border-radius: 6px;
  cursor: move; /* ドラッグ可能を示すカーソル */
  z-index: 1000;
 /* 追加：縦方向に並べる */
  flex-direction: column;
  gap: 6px;
}

#filter-panel .type-row,
#filter-panel .egg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  justify-content: flex-start;
}
#filter-panel img { width: 32px; height: 32px; cursor: pointer; }
#filter-panel img.selected { border: 2px solid white; box-sizing: border-box; }
.icon-wrapper button.selected { border: 2px solid #fff; border-radius: 4px; background-color: #aaa; width: 32px; height: 32px; padding: 0; }

/* 除外アイコン */
.exclusion-icons { display: flex; flex-wrap: wrap; gap: 3px; max-width: 300px; margin-top: 2px; }
.exclusion-icons img { cursor: pointer; border: 1px solid #ccc; border-radius: 4px; }
.exclusion-icons.size-large img { width: 48px; height: 48px; }
.exclusion-icons.size-medium img { width: 36px; height: 36px; }
.exclusion-icons.size-small img { width: 32px; height: 32px; }
.exclusion-icons.size-xsmall img { width: 24px; height: 24px; }
.icon-wrapper { display: inline-flex; flex-direction: column; align-items: center; margin: 2px; }
.icon-label { font-size: 8px; text-align: center; margin-bottom: 2px; }

/* ▼ UI1: リスト表示 */
.dex-list.ui1 {
  grid-template-columns: 1fr;
  gap: 4px;
}
.dex-list.ui1 .dex-item {
  border: 1px solid #e5e5e5;
  background: #fff;
  padding: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
}
.dex-list.ui1 .dex-info,
.dex-list.ui1 .exclusion-icons {
  display: flex;
}

/* ▼ UI2: グリッド表示 */
.dex-list.ui2 {
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 2px;
}
.dex-list.ui2 .dex-item {
  border: none;
  background: transparent;
  padding: 2px;
  display: flex;
  justify-content: center;
}
.dex-list.ui2 .dex-info,
.dex-list.ui2 .exclusion-icons {
  display: none !important;
}
.dex-list.ui2 .icon {
  width: 64px;
  height: 64px;
}
#dex-container.ui2 .dex-article {
  display: none !important;}
.info-button {
  background: #444; color: #fff; border: 0;
  padding: 6px 10px; border-radius: 50%;
  cursor: pointer; font-size: 16px; line-height: 1;
}
.dex-article {
  background: #f8f8f8;
  border: 1px solid #ddd;
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.25s ease;
}

.article-header {
  font-weight: bold;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #333;
}
/* --- dex本文 verID とテキスト（成功時の再現レイアウト） --- */
.row-article {
  font-family: system-ui, sans-serif;
  color: #111;
  background: #f8f8f8;
  display: block;                /* 各行を独立したブロックに */
  width: 100%;
  padding: 1px;
  transition: all 0.25s ease;
}

/* verIDアイコン側（インラインフレックス＋中央揃え） */
.ver-wrapper {
  font-family: system-ui, sans-serif;
  color: #111;
  line-height: 1.4;
  vertical-align: middle;
  justify-content: center;
  min-width: 48px;
  display: inline-flex;          /* アイコンとテキストの中央合わせを保つ */
  align-items: center;
  margin-right: 6px;
}

/* テキスト側（インラインブロック＋中央揃え） */
.article-text {
  font-family: system-ui, sans-serif;
  color: #111;
  line-height: 1.4;
  flex: 1;
  white-space: pre-wrap;
  font-size: 1rem;
  align-items: center;
  display: inline-block;         /* インライン扱いで中央軸が一致する */
  vertical-align: middle;
  width: calc(100% - 80px);
}
.ver.placeholder {
  display: inline-flex;
  width: 24px;       /* ← 実ver画像と完全一致 */
  height: 24px;
  align-items: center;
  justify-content: center;
  visibility: hidden; /* ← 非表示だがスペースを確保 */
}

/* --- 展開後の行（verID + テキスト）を中央揃え --- */
.toggle-content .row-article {
  display: flex;                 /* ← 中でver画像とテキストを横並びに */
  align-items: center;           /* ← 縦中央揃え */
  gap: 6px;
  padding: 4px 0;
  width: 100%;
  line-height: 1.4;
}

/* verIDアイコン */
.toggle-content .row-article img.ver {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* テキスト部分 */
.toggle-content .article-text {
  flex: 1;
  display: block;
  line-height: 1.4;
  font-size: 1rem;
  white-space: pre-wrap;
}

/* --- h3 折りたたみ時の空白防止 --- */
.article-text h3 {
  display: inline;        /* 行内扱いにする */
  margin: 4;            
  padding: 2;
  font-size: 1em;      
  font-weight: bold;
}

.toggle-btn {
  cursor: pointer;
  font-size: 14px;
  margin-right: 6px;
}

.row-article img.ver {
  width: 24px;
  height: 24px;
  margin-right: 1px;
}

/* 通常状態：クリック可能インジケータ */
.icon-wrapper {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

/* 下辺バー */
.icon-wrapper::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(120, 120, 120, 0.3);
  border-radius: 2px;
  transform: scaleX(0.8);
  transform-origin: center;
  transition: background 0.25s, transform 0.25s;
}

.icon-wrapper:hover::after {
  background: rgba(70, 160, 255, 0.7);
  transform: scaleX(1);
}

/* 展開中：黄色バー */
.dex-item.expanded .icon-wrapper::after {
  background: rgba(255, 200, 60, 0.9);
  transform: scaleX(1);
}

.toggle-images {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px;
}

.toggle-images img {
  height: 120px;
  margin: 4px;
  object-fit: contain;
  transition: transform 0.3s ease, height 0.3s ease;
  cursor: zoom-in;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
  animation: fadeIn 0.25s ease;
}

.image-modal img {
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  transition: transform 0.25s ease;
}

.image-modal img:hover {
  transform: scale(1.05);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.info-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.info-content {
  background: #fff;
  color: #111;
  padding: 24px;
  border-radius: 8px;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: fadeIn 0.25s ease;
}

.info-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
}
/* ▼ verIDクリックポップアップ */
.ver-popup {
  position: fixed;
  background: #fff;
  color: #111;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 6px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-line;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.special-filter-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.special-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.special-btn img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: border 0.2s, transform 0.2s;
}

.special-btn img:hover {
  transform: scale(1.1);
}

.special-btn.active img {
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
}

.special-label {
  color: #fff;
  font-size: 11px;
  margin-top: 2px;
  text-align: center;
}
/* ==================== サジェスト ==================== */
#suggest-list {
  position: absolute;
  background: #222;
  border: 1px solid #555;
  border-radius: 4px;
  z-index: 1000;
  max-height: 240px;
  overflow-y: auto;
  width: 240px;
  color: #fff;
  font-size: 13px;
  top: 32px; /* 検索ボックス下に出す */
  left: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* 各候補 */
.suggest-item {
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

/* ホバー時 */
.suggest-item:hover {
  background: #444;
}

.form-mode-row input[type="radio"] {
  accent-color: #66ccff;
  transform: scale(1.1);
}
.form-mode-row label:hover {
  color: #aaf;
}

.filter-title {
  font-family: system-ui, sans-serif;
  font-weight: bold;
  color: #fff;
  text-align: left;
  margin: 6px 0 2px 4px;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}
