* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
}
header {
  background: #0d1117;
  border-bottom: 1px solid #30363d;
  padding: 12px 16px;
}
header h1 { margin: 0 0 8px; font-size: 18px; }
nav a {
  color: #58a6ff;
  text-decoration: none;
  margin-right: 16px;
  font-size: 14px;
}
nav a.current {
  color: #e0e0e0;
  border-bottom: 2px solid #58a6ff;
  padding-bottom: 2px;
}
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
footer {
  border-top: 1px solid #30363d;
  padding: 12px 16px;
  font-size: 12px;
  color: #8b949e;
  text-align: right;
}

/* ツールバー */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar input[type="search"] {
  padding: 8px 12px;
  font-size: 14px;
  background: #0d1117;
  color: #e0e0e0;
  border: 1px solid #30363d;
  border-radius: 4px;
  min-width: 200px;
  flex: 1;
  max-width: 300px;
}
.sort-buttons button {
  padding: 6px 12px;
  font-size: 13px;
  background: #21262d;
  color: #e0e0e0;
  border: 1px solid #30363d;
  border-radius: 4px;
  cursor: pointer;
}
.sort-buttons button.active {
  background: #1f6feb;
  border-color: #1f6feb;
}
.sort-buttons button:hover { background: #30363d; }
.sort-buttons button.active:hover { background: #1f6feb; }
.count { color: #8b949e; font-size: 13px; margin-left: auto; }

/* メンバーグリッド */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.member-card {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  transition: border-color 0.15s;
}
.member-card:hover {
  border-color: #58a6ff;
}
.member-card .name {
  font-weight: 600;
  font-size: 15px;
  margin: 4px 0 6px;
  word-break: break-all;
}
.member-card .power {
  font-size: 22px;
  color: #58a6ff;
  font-variant-numeric: tabular-nums;
}
.member-card .updated {
  font-size: 11px;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stale-fresh { color: #3fb950; }
.stale-mid { color: #d29922; }
.stale-old { color: #f85149; }
.stale-unknown { color: #6e7681; }

.badge {
  display: inline-block;
  background: #30363d;
  color: #8b949e;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  position: absolute;
  top: 8px;
  right: 8px;
}
.badge-leader {
  background: #f0883e;
  color: black;
  font-weight: bold;
}

.loading, .empty, .error { color: #8b949e; padding: 20px; text-align: center; }
.error { color: #f85149; }

/* 個人ページ */
.back-link {
  color: #58a6ff;
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
  margin-bottom: 12px;
}
.back-link:hover { text-decoration: underline; }

.member-header {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 24px;
  position: relative;
}
.member-header h2 { margin: 0 0 8px; font-size: 24px; }
.member-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  color: #8b949e;
}
.power-big {
  font-size: 28px;
  color: #58a6ff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.meta-item { color: #8b949e; }
.memo {
  margin-top: 12px;
  padding: 8px 12px;
  background: #0d1117;
  border-left: 3px solid #d29922;
  font-size: 13px;
  color: #c9d1d9;
  white-space: pre-wrap;
}

section {
  margin-bottom: 28px;
}
section h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #c9d1d9;
  border-bottom: 1px solid #30363d;
  padding-bottom: 6px;
}

.equipment-table {
  max-width: 500px;
}
.equipment-table th {
  background: #161b22;
  font-size: 13px;
  padding: 6px 10px;
}
.rank-cell {
  font-weight: 600;
  font-size: 14px;
  width: 50px;
}

/* キャラ表示 */
.char-group { margin-bottom: 16px; }
.char-group h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #8b949e;
  font-weight: normal;
}
.char-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.char-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  background: #21262d;
  border: 1px solid #30363d;
  font-size: 13px;
}
.char-name { color: #c9d1d9; }
.char-stars {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 16px;
  text-align: center;
}
.stars-max { background: #1f6feb; border-color: #1f6feb; }
.stars-max .char-name, .stars-max .char-stars { color: white; }
.stars-high { background: #238636; border-color: #238636; }
.stars-high .char-name, .stars-high .char-stars { color: white; }
.stars-mid { background: #21262d; }
.stars-low, .stars-none { opacity: 0.5; }

/* ランクグリッド */
.rank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
}
.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  font-size: 13px;
}
.rank-label { color: #c9d1d9; }
.rank-value {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  min-width: 24px;
  text-align: center;
  font-size: 12px;
}

/* ミシックエンチャ */
.mythic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mythic-chip {
  background: #1f6feb;
  color: white;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mythic-count {
  background: rgba(255,255,255,0.25);
  padding: 0 6px;
  border-radius: 8px;
  font-size: 11px;
}

/* ヒートマップ */
.heatmap-wrap {
  overflow-x: auto;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #0d1117;
}
.heatmap {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.heatmap th, .heatmap td {
  border-right: 1px solid #30363d;
  border-bottom: 1px solid #30363d;
  padding: 4px 6px;
  white-space: nowrap;
}
.heatmap thead th {
  background: #161b22;
  color: #c9d1d9;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}
.heatmap thead th.group-header {
  background: #1c2128;
  font-size: 11px;
  color: #8b949e;
  border-bottom: 2px solid #30363d;
}
.heatmap thead th.cell-header {
  font-size: 10px;
  font-weight: normal;
  color: #c9d1d9;
  min-width: 28px;
  max-width: 36px;
  writing-mode: horizontal-tb;
}
.heatmap .sticky-col {
  position: sticky;
  left: 0;
  background: #161b22;
  z-index: 3;
  font-weight: 600;
}
.heatmap .sticky-col2 {
  position: sticky;
  left: 36px;
  background: #161b22;
  z-index: 3;
  font-weight: 600;
}
.heatmap thead .sticky-col, .heatmap thead .sticky-col2 {
  z-index: 4;
}
.heatmap .slot-cell {
  text-align: center;
  color: #8b949e;
  width: 36px;
}
.heatmap .name-cell {
  min-width: 110px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.heatmap .name-cell a {
  color: #58a6ff;
  text-decoration: none;
}
.heatmap .name-cell a:hover { text-decoration: underline; }
.heatmap .power-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #58a6ff;
  font-weight: 600;
}
.hm-cell {
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  min-width: 28px;
}
.hm-cell.rank-none { color: #6e7681; background: #21262d; }

/* キャラ星セル */
.stars-cell-max { background: #1f6feb; color: white; }
.stars-cell-high { background: #238636; color: white; }
.stars-cell-mid { background: #d29922; color: black; }
.stars-cell-low { background: #21262d; color: #c9d1d9; }
.stars-cell-none { background: #21262d; color: #6e7681; }

/* エンチャ集計 */
.enchant-row {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}
.enchant-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  border-bottom: 1px solid #30363d;
  padding-bottom: 6px;
}
.enchant-name {
  font-size: 16px;
  font-weight: 600;
  color: #58a6ff;
}
.enchant-count {
  font-size: 12px;
  color: #8b949e;
}
.enchant-holders {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.holder-chip {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 12px;
  color: #c9d1d9;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}
.holder-chip:hover {
  border-color: #58a6ff;
}
.holder-name { color: #c9d1d9; }
.holder-count {
  background: #1f6feb;
  color: white;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}
.holder-power {
  color: #8b949e;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* 編集モード */
.edit-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(90deg, #1f6feb 0%, #1158c7 100%);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  flex-wrap: wrap;
}
.edit-mode-label { font-weight: 600; }
.save-status {
  flex: 1;
  font-size: 12px;
  color: #c8e1ff;
  opacity: 0;
  transition: opacity 0.2s;
}
.save-status.flash { opacity: 1; color: #56d364; }
.btn-clear {
  background: rgba(0, 0, 0, 0.3);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.btn-clear:hover { background: rgba(0, 0, 0, 0.5); }

.readonly-banner {
  background: #21262d;
  color: #8b949e;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 16px;
  border-left: 3px solid #58a6ff;
}

[data-edit] {
  cursor: pointer;
  position: relative;
  transition: outline-color 0.15s;
}
[data-edit]:hover {
  outline: 2px solid #58a6ff;
  outline-offset: 1px;
}
[data-edit]:active {
  outline-color: #1f6feb;
}

.editable-power {
  display: inline-block;
  padding: 0 4px;
}

/* ポップオーバー */
.popover {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
  min-width: 200px;
}
.popover.popover-wide { min-width: 280px; }
.popover-title {
  font-size: 12px;
  color: #8b949e;
  margin-bottom: 8px;
  font-weight: 600;
}
.popover-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.popover-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-end;
}
.opt-btn {
  padding: 8px 14px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #c9d1d9;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  min-width: 44px;
  transition: all 0.1s;
}
.opt-btn:hover { background: #1f6feb; border-color: #1f6feb; color: white; }
.opt-btn:active { transform: scale(0.95); }
.opt-btn.opt-star { min-width: 36px; padding: 6px 8px; }
.opt-btn.save-btn { background: #238636; border-color: #238636; color: white; }
.opt-btn.cancel-btn { background: #21262d; }

.power-input, .mythic-input {
  width: 100%;
  padding: 8px 12px;
  background: #0d1117;
  color: #e0e0e0;
  border: 1px solid #30363d;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 8px;
}

/* エンチャ削除/追加 */
.chip-remove {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0 0 0 4px;
  font-size: 14px;
  line-height: 1;
}
.chip-remove:hover { color: #f85149; }
.chip-add {
  background: #21262d;
  border: 1px dashed #30363d;
  color: #8b949e;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip-add:hover { border-color: #58a6ff; color: #58a6ff; }
.empty-inline { color: #6e7681; font-size: 13px; padding: 4px; }

/* ランクの色分け（軍師ヒートマップ用） */
.rank-C { background: #1f6feb; color: white; }
.rank-L { background: #238636; color: white; }
.rank-M { background: #d29922; color: black; }
.rank-E { background: #db6d28; color: white; }
.rank-none, .rank- { background: #30363d; color: #6e7681; }

table { border-collapse: collapse; width: 100%; }
th, td {
  border: 1px solid #30363d;
  padding: 4px 8px;
  font-size: 12px;
  text-align: center;
}
th { background: #161b22; position: sticky; top: 0; z-index: 1; }
