:root {
  --bg-main: #0f172a;
  --bg-card: #161f33;
  --bg-table-header: #131c31;
  --bg-table-row-hover: #1e293b;
  --border-color: #26334d;
  --accent-cyan: #00d2ff;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;

  /* 6指標専用カラーパレット */
  --yt-views: #ef4444;    /* 赤: YouTube再生 */
  --yt-likes: #f97316;    /* 橙: YouTube高評価 */
  --yt-comments: #eab308; /* 黄: YouTubeコメント */
  --nc-views: #3b82f6;    /* 青: ニコ動再生 */
  --nc-mylists: #06b6d4;  /* 水色: ニコ動マイリス */
  --nc-comments: #8b5cf6; /* 紫: ニコ動コメント */

  --yt-color: #f87171;
  --nc-color: #60a5fa;
  --up-green: #4ade80;
  --down-red: #f87171;
  --stay-gray: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  line-height: 1.6;
}

/* 商標 TM マーク（VOCALOID右上） */
.tm-mark {
  font-size: 0.45em;
  font-weight: 700;
  vertical-align: super;
  line-height: 0;
  margin-left: 0.08em;
  margin-right: 0.08em;
  letter-spacing: 0;
}

/* 記念マイルストーン感謝バナー */
.milestone-banner {
  background: linear-gradient(90deg, rgba(0, 210, 255, 0.16) 0%, rgba(59, 130, 246, 0.22) 50%, rgba(0, 210, 255, 0.16) 100%);
  border-bottom: 1px solid var(--accent-cyan);
  padding: 0.6rem 1.25rem;
}

.milestone-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.milestone-badge {
  background: var(--accent-cyan);
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.5rem;
  border-radius: 0;
  flex-shrink: 0;
}

.milestone-text {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.milestone-close-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
}

.milestone-close-btn:hover {
  color: var(--text-primary);
}

/* Header */
.site-header {
  background: linear-gradient(180deg, #131c31 0%, #0f172a 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 1.5rem 0;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  margin-bottom: 0.25rem;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
}

.site-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.header-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.period-box,
.archive-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.5rem 0.9rem;
  display: flex;
  flex-direction: column;
}

.period-label,
.archive-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.period-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.archive-select {
  background: transparent;
  color: var(--text-primary);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.archive-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Tabs & 動的スクロールヒント */
.tab-nav-wrapper {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-nav-wrapper.has-overflow-right::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 56px;
  height: calc(100% - 3px);
  background: linear-gradient(90deg, rgba(15, 23, 42, 0) 0%, #0f172a 85%);
  pointer-events: none;
}

.tab-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tab-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

/* スクロール誘導バッジ */
.scroll-hint-pill {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(19, 28, 49, 0.95);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.45);
  border-radius: 2px;
  padding: 0.18rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.scroll-hint-pill.visible {
  opacity: 1;
  pointer-events: auto;
}

.table-scroll-indicator {
  display: none;
  justify-content: flex-end;
  margin-bottom: 0.45rem;
}

.table-scroll-indicator span {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 210, 255, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.4);
  border-radius: 2px;
  padding: 0.2rem 0.7rem;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.table-scroll-indicator.visible {
  display: flex;
}

.vertical-scroll-hint {
  position: fixed;
  bottom: 1.1rem;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(19, 28, 49, 0.92);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.5);
  border-radius: 2px;
  padding: 0.35rem 0.95rem;
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(6px);
}

.vertical-scroll-hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Main */
.main-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section-header {
  margin-bottom: 1rem;
}

.section-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  border-left: 4px solid var(--accent-cyan);
  padding-left: 0.75rem;
}

/* クイックアクションバー */
.quick-action-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.action-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.yt-playlist-btn {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.yt-playlist-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ffffff;
}

/* 便利ツールバー */
.utility-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
}

.search-box-wrap {
  flex: 1;
  min-width: 220px;
}

.ranking-search-input {
  width: 100%;
  background: #0f172a;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.45rem 0.75rem;
  font-size: 0.86rem;
  outline: none;
}

.ranking-search-input:focus {
  border-color: var(--accent-cyan);
}

.filter-controls-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ranking-sort-select {
  background: #0f172a;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.45rem 0.7rem;
  font-size: 0.84rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.fav-filter-btn {
  background: #0f172a;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.45rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.fav-filter-btn.active,
.fav-filter-btn:hover {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.1);
}

/* 週間ランキング TOP 20 カード */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.rank-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.rank-card:hover {
  border-color: #3b4f73;
}

.rank-card-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.rank-number-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 82px;
  gap: 0.2rem;
}

.rank-number {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary);
}

.rank-number small {
  font-size: 0.8rem;
  margin-left: 2px;
}

.rank-diff {
  font-size: 0.72rem;
  font-weight: 700;
}

.diff-up {
  color: var(--up-green);
}

.diff-down {
  color: var(--down-red);
}

.diff-stay {
  color: var(--stay-gray);
}

.diff-new {
  color: var(--accent-cyan);
}

.chart-in-mini {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.rank-thumb-col {
  flex-shrink: 0;
}

.rank-thumb {
  width: 112px;
  height: 63px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--border-color);
  display: block;
}

.rank-info-col {
  flex: 1;
  min-width: 0;
}

.song-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.song-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.fav-star-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.1rem 0.45rem;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.2;
}

.fav-star-btn.favorited,
.fav-star-btn:hover {
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.1);
}

.detail-toggle-btn {
  background: rgba(0, 210, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.35);
  border-radius: 2px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.detail-toggle-btn:hover,
.detail-toggle-btn.open {
  background: rgba(0, 210, 255, 0.22);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

.song-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}

.metric-stacked-bar {
  height: 6px;
  background: #0f172a;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  width: 100%;
}

.bar-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.seg-yt-views {
  background-color: var(--yt-views);
}

.seg-yt-likes {
  background-color: var(--yt-likes);
}

.seg-yt-comments {
  background-color: var(--yt-comments);
}

.seg-nc-views {
  background-color: var(--nc-views);
}

.seg-nc-mylists {
  background-color: var(--nc-mylists);
}

.seg-nc-comments {
  background-color: var(--nc-comments);
}

.rank-points-col {
  text-align: right;
  min-width: 170px;
}

.total-points {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.total-points small {
  font-size: 0.8rem;
  font-weight: 600;
}

.points-sub-row {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.2rem;
}

/* 詳細パネル */
.rank-detail-panel {
  display: none;
  border-top: 1px solid var(--border-color);
  background: #11192b;
  padding: 1.25rem;
}

.rank-detail-panel.open {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.detail-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 1rem;
}

.detail-box h4 {
  font-size: 0.92rem;
  margin-bottom: 0.65rem;
}

.yt-detail-box h4 {
  color: var(--yt-color);
}

.nc-detail-box h4 {
  color: var(--nc-color);
}

.detail-box ul {
  list-style: none;
  font-size: 0.86rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.detail-box li span {
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 0;
  flex-shrink: 0;
}

.video-link {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 2px;
}

.yt-link {
  background: rgba(248, 113, 113, 0.15);
  color: var(--yt-color);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.nc-link {
  background: rgba(96, 165, 250, 0.15);
  color: var(--nc-color);
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.detail-share-row {
  margin-top: 0.85rem;
  display: flex;
  justify-content: flex-end;
}

.share-song-x-btn {
  background: rgba(0, 210, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.35);
  border-radius: 2px;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.share-song-x-btn:hover {
  background: rgba(0, 210, 255, 0.22);
  color: #ffffff;
}

.commentary-box {
  margin-top: 1rem;
  background: rgba(0, 210, 255, 0.06);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.85rem 1rem;
  border-radius: 0;
}

.commentary-box h5 {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  margin-bottom: 0.35rem;
}

/* ランキングインサイト・解説カード */
.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.insight-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  border-left: 4px solid var(--accent-cyan);
  padding-left: 0.75rem;
  margin-bottom: 1.25rem;
  line-height: 1.3;
}

.insight-section-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.chart-wrapper {
  position: relative;
  height: 480px;
  width: 100%;
}

/* フォールバック用HTMLグラフ */
.fallback-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.fallback-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.fallback-chart-rows {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.fallback-chart-row {
  display: grid;
  grid-template-columns: 220px 1fr 110px;
  align-items: center;
  gap: 0.85rem;
}

.fallback-chart-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fallback-chart-bar-track {
  height: 18px;
  background: #0b1120;
  border-radius: 0;
  overflow: hidden;
}

.fallback-chart-bar-fill {
  height: 100%;
  display: flex;
}

.fallback-chart-pt {
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-cyan);
  white-space: nowrap;
}

/* テーブル */
.table-responsive {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.insight-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border-color);
  font-size: 0.92rem;
}

.insight-table th,
.insight-table td {
  padding: 0.9rem 1rem;
  text-align: left;
  border: 1px solid var(--border-color);
  vertical-align: middle;
}

.insight-table thead th {
  background-color: var(--bg-table-header);
  color: var(--accent-cyan);
  font-weight: 700;
  white-space: nowrap;
}

.insight-table tbody tr {
  background-color: var(--bg-card);
  transition: background-color 0.15s ease;
}

.insight-table tbody tr:hover {
  background-color: var(--bg-table-row-hover);
}

.col-rank {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  width: 68px;
}

.col-song {
  min-width: 240px;
}

.insight-song-title {
  color: var(--text-primary);
  font-weight: 500;
  margin-right: 0.35rem;
}

.insight-song-producer {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.col-total-pt {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.col-pt-ratio {
  font-weight: 700;
  white-space: nowrap;
}

.pt-ratio-up {
  color: var(--up-green);
  font-weight: 700;
}

.pt-ratio-down {
  color: var(--down-red);
  font-weight: 700;
}

.pt-ratio-stay {
  color: var(--stay-gray);
  font-weight: 600;
}

.pt-ratio-new {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.4);
  background: rgba(0, 210, 255, 0.1);
  border-radius: 2px;
}

.col-chart-in {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.col-yt-ratio {
  color: var(--yt-color);
  font-weight: 500;
  white-space: nowrap;
}

.col-nc-ratio {
  color: var(--nc-color);
  font-weight: 500;
  white-space: nowrap;
}

/* ランキングについて（背景解説文） */
.method-lead {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  line-height: 1.75;
}

.method-background-text {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.8;
}

.trademark-note {
  margin-top: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.84rem;
  color: var(--text-secondary);
}

/* 「ランキングについて」最下部のコンパクトな TOTAL VIEWS カード */
.site-stats-card {
  padding: 0.9rem 1.25rem;
  margin-bottom: 0;
}

.site-stats-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.site-stats-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.view-counter-small {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.view-counter-small strong {
  color: var(--accent-cyan);
  font-weight: 700;
}

/* 解説セクション */
.overall-commentary-box {
  font-size: 0.95rem;
  line-height: 1.75;
}

.commentary-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.commentary-card {
  border: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 1.1rem;
  background: #121b2d;
}

.commentary-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.commentary-rank-badge {
  background: var(--accent-cyan);
  color: #0f172a;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 0.15rem 0.55rem;
  border-radius: 0;
}

.commentary-song-title {
  font-size: 1rem;
  flex: 1;
}

.commentary-song-title small {
  color: var(--text-secondary);
  font-weight: 400;
}

.commentary-song-pt {
  font-weight: 700;
  color: var(--accent-cyan);
}

/* ページ上部へ戻るボタン & トースト通知 */
.back-to-top-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  background: rgba(19, 28, 49, 0.92);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
  border-radius: 2px;
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.back-to-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.toast-notification {
  position: fixed;
  bottom: 3.8rem;
  right: 1.25rem;
  background: #131c31;
  color: var(--text-primary);
  border-left: 4px solid var(--accent-cyan);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-radius: 2px;
  padding: 0.6rem 1rem;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.toast-notification.visible {
  opacity: 1;
}

.loading-cell,
.loading-state,
.empty-state,
.error-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: 3rem;
}

/* ==========================================================================
   スマートフォン専用UI（画面幅 640px 以下のみ適用 / タブレット縦向き 768px 等は除外）
   ========================================================================== */
@media (max-width: 640px) {
  .site-header {
    padding: 1rem 0.9rem 0;
  }

  .header-inner {
    margin-bottom: 0.85rem;
    gap: 0.75rem;
  }

  .brand-badge {
    font-size: 0.68rem;
  }

  .site-title {
    font-size: clamp(1.22rem, 5.4vw, 1.55rem);
    line-height: 1.25;
    white-space: nowrap;
  }

  .site-subtitle {
    font-size: 0.78rem;
  }

  .header-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .period-box,
  .archive-box {
    width: 100%;
    padding: 0.45rem 0.75rem;
  }

  .period-value,
  .archive-select {
    font-size: 0.82rem;
  }

  .tab-btn {
    padding: 0.65rem 0.9rem;
    font-size: 0.84rem;
  }

  .main-container {
    margin: 1.15rem auto;
    padding: 0 0.75rem;
  }

  .section-title,
  .insight-section-title {
    font-size: 1.08rem;
  }

  .quick-action-bar {
    width: 100%;
  }

  .action-btn {
    flex: 1;
    text-align: center;
    padding: 0.4rem 0.5rem;
    font-size: 0.74rem;
  }

  .utility-toolbar {
    padding: 0.6rem;
    gap: 0.5rem;
  }

  .filter-controls-wrap {
    width: 100%;
    justify-content: space-between;
  }

  .ranking-sort-select {
    flex: 1;
    font-size: 0.78rem;
  }

  .fav-filter-btn {
    font-size: 0.78rem;
  }

  .ranking-list {
    gap: 0.75rem;
  }

  .rank-card-summary {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-areas:
      "rank thumb points"
      "info info info";
    align-items: center;
    gap: 0.65rem 0.7rem;
    padding: 0.85rem 0.9rem;
  }

  .rank-number-col {
    grid-area: rank;
    min-width: 54px;
    align-items: flex-start;
    gap: 0.1rem;
  }

  .rank-number {
    font-size: 1.3rem;
    line-height: 1.1;
  }

  .rank-diff,
  .chart-in-mini {
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .rank-thumb-col {
    grid-area: thumb;
  }

  .rank-thumb {
    width: 84px;
    height: 47px;
    border-radius: 2px;
  }

  .rank-points-col {
    grid-area: points;
    min-width: 0;
    text-align: right;
    justify-self: end;
  }

  .total-points {
    font-size: 1.12rem;
    line-height: 1.2;
  }

  .total-points small {
    font-size: 0.72rem;
  }

  .points-sub-row {
    font-size: 0.7rem;
    margin-top: 0.1rem;
  }

  .rank-info-col {
    grid-area: info;
    width: 100%;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(38, 51, 77, 0.7);
  }

  .song-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    flex-wrap: nowrap;
    margin-bottom: 0.25rem;
  }

  .song-title {
    font-size: 1rem;
    line-height: 1.38;
    flex: 1;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
  }

  .detail-toggle-btn {
    flex-shrink: 0;
    padding: 0.22rem 0.55rem;
    font-size: 0.72rem;
  }

  .song-meta {
    font-size: 0.78rem;
    gap: 0.35rem 0.65rem;
    margin-bottom: 0.45rem;
    line-height: 1.35;
  }

  .metric-stacked-bar {
    height: 7px;
  }

  .rank-detail-panel {
    padding: 0.9rem;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .detail-box {
    padding: 0.8rem;
  }

  .insight-card {
    padding: 1.1rem 0.9rem;
    margin-bottom: 1.1rem;
  }

  .site-stats-card {
    padding: 0.75rem 0.9rem;
  }

  .chart-wrapper {
    height: 380px;
  }

  .insight-table th,
  .insight-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.82rem;
  }

  .col-song {
    min-width: 180px;
  }

  .fallback-chart-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
