/* 🔷 全体レイアウトと基本色 */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  background-color: #fdfdfd;
  color: #333;
}

/* 🔷 メインレイアウト */
.stats-main {
  display: flex;
  justify-content: center;
  padding-top: 60px; /* ナビバー高さ分 */
  box-sizing: border-box;
  min-height: 100vh;
}

.stats-container {
  width: 800px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: calc(100vh - 60px);
}

/* 🔷 タブ切り替えUI */
.stats-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  font-weight: bold;
  background-color: var(--main-mid);
  color: var(--main-dark);
  border: none;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.tab.active {
  background-color: var(--main-light);
  color: var(--main-dark);
  border-bottom: 3px solid var(--magenta); /* 🔹 強調色で下線 */
  box-shadow: inset 0 -2px 0 var(--magenta); /* 🔹 下線の厚みを補強 */
  font-weight: 900; /* 🔹 非アクティブとの差を出す */
  opacity: 1;
}

.tab:hover {
  background-color: var(--main-light); /* ← お好みで色を指定 */
  color: var(--main-dark);
}


/* 🔷 表示領域切り替え */
.ranking-section {
  display: none !important;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0; /* ← flex子要素のスクロール対策 */
}

.ranking-section.active {
  display: flex !important;
  flex-direction: column;
}

/* 🔷 年・月選択のコントロール部 */
.stats-controls {
  padding: 1em;
  background-color: var(--bg-light);
  border-bottom: 1px solid var(--border);
}

.stats-select-group {
  display: flex;
  gap: 2em;
  flex-wrap: wrap;
  align-items: center;
}

.select-block {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.select-block label {
  white-space: nowrap;
  font-weight: bold;
}

.select-block select {
  font-size: 16px;
  padding: 6px 12px;
}

/* 🔷 スクロール対象領域 */
.stats-scrollable {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1em;
  min-height: 0; /* ← flex子要素のスクロール対策 */
}

/* 🔷 ランキング表示 */
#stats-ranking,
#favorite-ranking,
#favorite-ranking-stats {
  margin-top: 20px;
  padding-right: 8px;
}

.ranking-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  padding: 12px;
  background: #fff;
  border-left: 4px solid #ccc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.rank-label {
  font-weight: bold;
  font-size: 18px;
  margin-bottom: 6px;
}

.ranking-item ul {
  margin: 0;
  padding-left: 20px;
}

.ranking-item li {
  font-size: 15px;
  margin-bottom: 4px;
}

/* 🔷 お気に入り配信トグル */
.stream-detail {
  margin-left: 1em;
  margin-top: 0.5em;
}

.stream-detail.hidden {
  display: none;
}

.stream-detail div {
  margin-bottom: 6px;
  font-size: 14px;
}

.stream-detail a {
  margin-left: 8px;
  color: var(--main-dark);
  text-decoration: underline;
}

.stream-detail button {
  margin-left: 8px;
  font-size: 12px;
  padding: 2px 6px;
  background-color: var(--main-mid);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* 🔷 補足表示（凡例など） */
#stats-legend {
  margin-top: 20px;
  font-size: 14px;
  text-align: right;
  color: #555;
}

/* 🔷 グラフ表示領域 */
#chart-wrapper {
  height: 240px;
  position: relative;
}

#stats-chart {
  height: 100% !important;
  width: 100% !important;
}

.stream-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  font-size: 0.95em;
  padding: 6px 0;
}

.stream-date {
  white-space: nowrap;
  color: #666;
  font-size: 0.9em;
}

.stream-title {
  width: 450px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.stream-icon img {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

.share-button {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.9em;
  cursor: pointer;
  background-color: var(--bg) !important;
  color: var(--main-dark) !important;
}

.fav-count {
  white-space: nowrap;
  font-weight: bold;
  color: #c00;
}

.recommend-toggle {
  display: flex;
  justify-content: flex-end; /* 🔹 右端に寄せる */
  width: 100%;               /* 🔹 親要素の幅を最大にする */
  margin-top: 6px;
}

.recommend-button {
  background-color: var(--main-mid);
  color: var(--main-dark);
  border: none;
  padding: 6px 12px;
  font-size: 0.9em;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;

  display: inline-block;     /* 🔹 中身に応じたサイズにする */
  width: auto;               /* 🔹 横幅を自動にする（広がり防止） */
  max-width: 100%;           /* 🔹 念のための制限 */
  box-sizing: border-box;    /* 🔹 パディング込みで制御 */
}

.recommend-button:hover {
  background-color: var(--main-dark);
  color: white;
}

.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  padding: 1em;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.modal-content textarea {
  width: 100%;
  font-size: 1em;
  margin-top: 0.5em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1em;
  margin-top: 1em;
}

#share-confirm {
  background-color: var(--main-mid);
  color: var(--main-dark);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#share-confirm:hover {
  background-color: var(--main-light);
  color: var(--main-dark);
}

#share-cancel {
  background-color: var(--main-mid);
  color: var(--main-dark);
  border: none;
  font-weight: bold;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#share-cancel:hover {
  background-color: var(--main-light);
  color: var(--main-dark);
}

/* 🔷 favorite-ranking-stats 対応：限定セレクタの拡張 */
/* 🔷 favorite-ranking-stats 対応：セレクタ拡張 */
#favorite-ranking .ranking-item,
#favorite-ranking-stats .ranking-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  padding: 12px;
  background: #fff;
  border-left: 4px solid #ccc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#favorite-ranking .recommend-toggle,
#favorite-ranking-stats .recommend-toggle {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  margin-top: 6px;
}

#favorite-ranking .recommend-button,
#favorite-ranking-stats .recommend-button {
  background-color: var(--main-mid);
  color: var(--main-dark);
  border: none;
  padding: 6px 12px;
  font-size: 0.9em;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: inline-block;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
}

#favorite-ranking .recommend-button:hover,
#favorite-ranking-stats .recommend-button:hover {
  background-color: var(--main-dark);
  color: white;
}

#favorite-ranking .stream-detail,
#favorite-ranking-stats .stream-detail {
  margin-left: 1em;
  margin-top: 0.5em;
}

#favorite-ranking .stream-detail.hidden,
#favorite-ranking-stats .stream-detail.hidden {
  display: none;
}

#favorite-ranking .stream-row,
#favorite-ranking-stats .stream-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  font-size: 0.95em;
  padding: 6px 0;
}

#favorite-ranking .stream-date,
#favorite-ranking-stats .stream-date {
  white-space: nowrap;
  color: #666;
  font-size: 0.9em;
}

#favorite-ranking .stream-title,
#favorite-ranking-stats .stream-title {
  width: 450px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

#favorite-ranking .stream-icon img,
#favorite-ranking-stats .stream-icon img {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

#favorite-ranking .share-button,
#favorite-ranking-stats .share-button {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.9em;
  cursor: pointer;
  background-color: var(--bg) !important;
  color: var(--main-dark) !important;
}

#favorite-ranking .fav-count,
#favorite-ranking-stats .fav-count {
  white-space: nowrap;
  font-weight: bold;
  color: #c00;
}

.fav-button {
  margin: 4px 0px 0px 0px !important;
  padding: 0 !important;
  vertical-align: middle;
  background-color: var(--bg) !important;
}

.favorite-ranking-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  padding: 12px;
  background: #fff;
  border-left: 4px solid #ccc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ranking-note {
  font-size: 0.85em !important;
  text-align: right !important;
}

