/* 共通スタイルシート */
/* 基本設定 */
: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--row { display:flex; align-items:center; gap:16px; }
.ml-auto { margin-left:auto; }
/* ヘッダー内の認証バー表示 */
.app-header #authBar { display:flex; align-items:center; gap:8px; }
.app-header .muted { color: #eaf2ff; }
.app-header .btn-ghost { color:#fff; border-color: rgba(255,255,255,0.6); background: transparent; }
.app-header .btn-ghost:hover { background: rgba(255,255,255,0.15); }

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

/* 管理ヘッダー内ナビのレイアウト */
.app-header nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 管理用ナビの微調整 */
.admin-nav .btn {
  padding: 0.4rem 0.6rem;
  font-size: 14px;
}
.admin-nav .btn-ghost {
  color: #fff;
  border-color: rgba(255,255,255,0.6);
}

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

/* 初期非表示（JSで切り替え） */
#noticeCard, #tblContainer, #csvOverlay, #importCsv, #loadingOverlay, #noResult { display:none; }

/* 広告の共通スタイル（単一表示） */
.ad-container { text-align: center; }
.ad-block { display: inline-block; }
.ad-block img,
.ad-block iframe,
.ad-block ins { display: block; margin: 0 auto; }

/* 規約・ポリシーの共通スタイル */
.terms article,
.policy article { padding: 1.5rem; line-height: 1.8; }
.terms h2,
.policy h2 { font-size: 18px; margin: 1.25rem 0 .25rem; }
.terms ul,
.policy ul { margin: .25rem 0 .5rem 1.25rem; }
.terms p, .terms li,
.policy p, .policy li { font-size: 14px; }
.page-meta { color: var(--color-muted); margin: 0 0 1rem; }

/* 広告のレイアウト */
.ad-container {
  max-width: var(--maxw);
  margin: 8px auto var(--space);
  text-align: center;
}
.ad-container .ad-desktop {
  display: none;
}
@media (min-width: 769px) {
  .ad-container .ad-mobile {
    display: none;
  }
  .ad-container .ad-desktop {
    display: inline-block;
  }
}

.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);
}

/* 汎用ユーティリティ */
.text-center { text-align:center; }
.msg-spacer { margin-top:8px; }
.auth-container { max-width:480px; margin:40px auto; }
.center-box { text-align:center; padding:3rem; }

/* 汎用記事カード */
article.card { padding:1.5rem; line-height:1.7; }
.card h2:first-child { margin-top: 0; }

/* 汎用フォーム */
.form { display:flex; flex-direction:column; gap:12px; }
.form-field label { display:block; font-weight:600; margin-bottom:4px; }
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="text"] {
  width: 100%;
  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);
}
.form-actions { margin-top: 8px; }

/* 該当なしメッセージ */
.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;
}

/* usage: 使い方ページの画像レイアウト */
.page-article .usage-figure-li {
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
  /* 段落と同じ開始位置に視覚的に揃える（他のliは影響しない） */
  margin-left: 0;
  position: relative;
  left: -1.5em; /* テーマにより 1.5em〜2em 程度で微調整 */
  display: block;
}
.page-article .usage-figure-li::marker { content: ''; }
.page-article .usage-figure {
  margin: 0;
  padding: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.page-article .usage-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  cursor: zoom-in;
}
.page-article .usage-caption {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-muted);
  text-align: center;
}

/* 画像ライトボックス */
.img-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  z-index: 4000;
  padding: 1rem;
}
.img-lightbox.open { display: flex; }
.img-lightbox .box {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
}
.img-lightbox img {
  display: block;
  max-width: 95vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  background: #fff;
}
.img-lightbox .caption {
  margin-top: .5rem;
  color: #fff;
  font-size: 14px;
  text-align: center;
}
.img-lightbox .close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

/* 管理フォーム */
.admin-form .row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
  align-items: center;
  margin: .5rem 0;
}
.admin-form label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.admin-form .admin-input,
.admin-form .admin-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);
}

/* 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;
}

/* フッター */
.footer nav { margin-bottom: .5rem; }
.footer nav a { margin: 0 .5rem; }
.footer p { margin: .25rem 0; }

.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; }
