/* 共通スタイルシート */
/* 基本設定 */
:root {
  --color-bg: #f3f4f6;
  --color-border: #e5e7eb;
  --color-muted: #6b7280;
  --color-primary: #2563eb;
  --color-surface: #fff;
  --color-text: #374151;
  --maxw: 1000px;
  --radius: 8px;
  --space: 12px;
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Hiragino Sans",
    "Meiryo",
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  line-height: 1.5;
}

.app-header {
  background: var(--color-primary);
  color: #fff;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  text-align: center;
}

.app-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* スキル検索部分 */
.search-container {
  display: grid;
  gap: var(--space);
  margin-bottom: var(--space);
}
.condition-card {
  padding: var(--space);
}
.skill-combo {
  padding: var(--space);
}
.skill-combo .mode {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 14px;
}
.condition-card h2 {
  margin: 0 0 var(--space);
  font-size: 16px;
}
.search-action {
  text-align: center;
}
.search-action .btn-primary {
  width: 100%;
  padding: 0.75rem;
  font-size: 16px;
}

.search-action .search-hint {
  margin-top: 8px;
  font-size: 14px;
  color: var(--color-muted);
}

@media (min-width: 769px) {
  .search-container {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }
}
.skill-combo-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space);
}
.skill-combo .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 72px;
  gap: var(--space);
  align-items: center;
  min-width: 0;
}
.skill-combo .row input[type="text"],
.skill-combo .row input[type="number"],
.skill-combo .row select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  min-width: 0;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
  align-items: center;
  margin-bottom: var(--space);
  font-size: 14px;
}
.filter-bar .rarity-filter {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.filter-bar .slot-filter {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar label {
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-bar input[type="number"],
.filter-bar select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
}

#pageSize {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
}

#btnAddSkill {
  margin-top: var(--space);
}

.summary {
  color: #111827;
  font-weight: 500;
  font-size: 14px;
  margin: 0 auto var(--space);
  text-align: right;
  max-width: var(--maxw);
}

/* 該当なしメッセージ */
.no-result {
  text-align: center;
  color: var(--color-muted);
  padding: 2rem;
  font-size: 16px;
  max-width: var(--maxw);
  margin: 0 auto var(--space);
}

/* 検索結果テーブル */
.table-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 800px;
  background: var(--color-surface);
}
th,
td {
  border: 1px solid var(--color-border);
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
  font-size: 14px;
}
th {
  background: var(--color-primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
}
th.sortable {
  cursor: pointer;
}
th.sortable .indicator {
  margin-left: 4px;
}
tbody tr:nth-child(even) {
  background: #f9fafb;
}
tbody tr:hover {
  background: #eff6ff;
}
.table-wrap table tbody tr.rarity-5 {
  background: #fefce8;
}
.table-wrap table tbody tr.rarity-6 {
  background: #f0f9ff;
}
.table-wrap table tbody tr.rarity-7 {
  background: #f5f3ff;
}
.table-wrap table tbody tr.rarity-8 {
  background: #fef2f2;
}

/* 検索結果カード表示（モバイル） */
.cards {
  display: none;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space) 0;
}
.card-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: var(--space);
  margin-bottom: var(--space);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.card-item .title {
  font-weight: 600;
  margin-bottom: 4px;
}
.chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef2ff;
  font-size: 12px;
  margin-right: 6px;
}
.slots {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.cards .card-item.rarity-5 {
  border-left: 4px solid #facc15;
}
.cards .card-item.rarity-6 {
  border-left: 4px solid #0ea5e9;
}
.cards .card-item.rarity-7 {
  border-left: 4px solid #8b5cf6;
}
.cards .card-item.rarity-8 {
  border-left: 4px solid #f87171;
}

/* ページャ */
.pager {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem auto;
}
.pager button {
  min-width: 84px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 14px;
  cursor: pointer;
}
.pager button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.page-indicator {
  font-size: 14px;
  color: var(--color-text);
  padding: 0.25rem 0.5rem;
}

/* お知らせカード */
.notice-card {
  border: 1px solid #fda4af;
  background: #fff1f2;
  margin-bottom: var(--space);
}
.notice-header {
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: #9f1239;
  background: #ffe4e6;
  border-bottom: 1px solid #fda4af;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.notice-body {
  padding: 1rem;
  color: #9f1239;
}
.notice-actions {
  display: flex;
  gap: var(--space);
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space);
}
.notice-meta {
  font-size: 12px;
  opacity: 0.8;
}

/* ボタン共通スタイル */
.btn {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}
.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-primary);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* CSV入出力モーダル */
#csvOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
#csvOverlay .csv-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  width: 90%;
  max-width: 600px;
}
#csvOverlay textarea {
  width: 100%;
  height: 200px;
}
#csvOverlay .csv-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ローディング画面 */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}
#loadingOverlay .spinner {
  border: 8px solid #f3f3f3;
  border-top: 8px solid var(--color-primary);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
}
.loading-text {
  margin-top: 0.5rem;
  font-size: 14px;
  color: var(--color-text);
}
@keyframes spin {
  0% {
    transform: rotate(0);
  }
  100% {
    transform: rotate(360deg);
  }
}
.is-loading {
  overflow: hidden;
}

/* フッター */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  text-align: center;
  padding: 1rem;
  font-size: 14px;
}
.footer a {
  color: var(--color-primary);
  margin: 0 0.5rem;
  text-decoration: none;
}
.footer a:hover {
  text-decoration: underline;
}

/* jQuery UI のドロップダウン */
.skill-ac-dropdown {
  z-index: 3000;
  max-height: 240px;
  overflow-y: auto;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .app-main {
    padding: var(--space);
  }
  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-bar .rarity-filter,
  .filter-bar .slot-filter {
    width: 100%;
    flex-wrap: wrap;
  }
  .skill-combo .row {
    grid-template-columns: minmax(0, 1fr) 100px 64px;
  }
  .summary {
    text-align: left;
  }
  .table-wrap {
    display: none;
  }
  .cards {
    display: block;
  }
  .pager {
    position: sticky;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(1.2) blur(6px);
    padding: 0.5rem;
    border-radius: 999px;
  }
}

.author-icon {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1rem;
}

.app-header a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.app-header a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.app-header a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  border-radius: 4px;
}

.app-header .page-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
}
.app-header .page-title .sep {
  opacity: 0.6;
}
.app-header .page-title .section {
  color: #eaf2ff;
  font-weight: 700;
}

.section-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.section-header h2 {
  margin: 0 0 6px;
  font-size: 18px;
}
.section-header .muted {
  color: var(--color-muted);
  font-size: 12px;
}


.grid.grid-5 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.charm-card {
  padding: 12px;
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.charm-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
}
.slots {
  margin-left: auto;
  font-size: 12px;
  color: var(--color-muted);
}
.charm-title {
  font-size: 14px;
  margin: 0 0 6px;
}
.note {
  font-size: 12px;
  color: var(--color-muted);
}

.name-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
.name-field .name-label {
  font-size: 12px;
  color: var(--color-muted);
}
.name-field input {
  flex: 1;
}
.level-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
.level-field .level-label {
  font-size: 12px;
  color: var(--color-muted);
}
@media (max-width: 768px) {
  .level-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .level-field select {
    width: 100%;
  }
  .name-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .name-field input {
    width: 100%;
  }
  /* 入力・セレクトの高さ/フォントを上げてタップしやすく */
  .skill-combo .row input[type="text"],
  .skill-combo .row input[type="number"],
  .skill-combo .row select {
    padding: 0.6rem 0.75rem; /* だいたい 40〜44px 高さ */
    font-size: 16px; /* iOSの自動ズーム防止 */
  }
  #pageSize {
    padding: 0.6rem 0.75rem;
    font-size: 16px;
  }
  /* スキルLvのセレクトが列いっぱいに広がるように */
  .skill-combo .row .skill-level {
    min-width: 100px;
    width: 100%;
  }
  .footer{ min-height:88px; contain-intrinsic-size:block-size 88px; }
}
/* 追加：フッターの高さ予約でCLSを防止 */
.footer{
  text-align:center;
  padding:1rem;
  font-size:14px;
  color:#6b7280;
  min-height:72px;                 /* ← ここがポイント：実測に合わせて 56〜96px で調整可 */
  box-sizing:border-box;
  content-visibility:auto;         /* レンダリング最適化（対応ブラウザのみ） */
  contain-intrinsic-size:block-size 80px; /* 初期推定高さ（min-height と同程度に） */
}
.notice-card{
  content-visibility:auto;
  contain-intrinsic-size:block-size 120px; /* 想定の高さに合わせて調整 */
}

/* お気に入りボタン */
.fav-btn{
  background:none;
  border:none;
  cursor:pointer;
  font-size:1.2em;
}
.fav-btn.favorited{ color:#e6b400; }