:root {
  --bg: #ffffff;
  --text: #0f0f0f;
  --muted: #606060;
  --hover: #f2f2f2;
  /* 公式 / 個人ファン / KPOPファン（非特定）の区別に使う色 */
  --official: #065fd4;
  --fan: #137333;
  /* 白文字が乗るように濃いオレンジ。赤茶（色相が赤寄り）にはしない */
  --kpop: #c05600;
  --new: #c5221f;
  --badge-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --text: #f1f1f1;
    --muted: #aaaaaa;
    --hover: #272727;
    --official: #3ea6ff;
    --fan: #81c995;
    --kpop: #f5b56b;
    --new: #f28b82;
    --badge-text: #0f0f0f;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    "Hiragino Sans",
    sans-serif;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 240px;
  height: 100vh;
  padding: 12px;
  overflow-y: auto;
  border-right: 1px solid var(--hover);
  transition: flex-basis 0.2s;
}

html[data-nav="collapsed"] .sidebar {
  flex-basis: 72px;
}

.sidebar-toggle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 40px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 20px;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--hover);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}

.site-brand:hover {
  background: var(--hover);
}

.site-brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.site-brand-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.site-brand-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1.35;
}

.site-brand-tagline {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.35;
}

html[data-nav="collapsed"] .site-brand-copy {
  display: none;
}

/* サイドメニューを開いている広い画面では、左のブランドと重複させない */
.site-banner {
  display: none;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 0;
  color: inherit;
  text-decoration: none;
}

html[data-nav="collapsed"] .site-banner,
.site-banner:hover {
  color: inherit;
}

html[data-nav="collapsed"] .site-banner {
  display: flex;
}

.site-banner-name {
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.site-banner-sub {
  flex-basis: 100%;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.site-banner-tagline {
  color: var(--muted);
  font-size: 0.8125rem;
}

.channel-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.channel-item:hover,
.channel-item[aria-current="true"] {
  background: var(--hover);
}

.channel-item[aria-current="true"] {
  font-weight: 600;
}

.nav-icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.nav-icon img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.nav-type-mark {
  position: absolute;
  right: -6px;
  bottom: -4px;
  padding: 0 5px;
  border-radius: 999px;
  color: var(--badge-text);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.nav-type-mark.is-official {
  background: var(--official);
}

.nav-type-mark.is-fan {
  background: var(--fan);
}

.nav-type-mark.is-kpop {
  background: var(--kpop);
}

.channel-section-title {
  margin: 16px 8px 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

/* 折りたたみ時は見出しの代わりに区切り線を出す */
html[data-nav="collapsed"] .channel-section-title {
  height: 0;
  margin: 8px 6px;
  overflow: hidden;
  border-top: 1px solid var(--muted);
}

.type-badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--badge-text);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.type-badge.is-official {
  background: var(--official);
}

.type-badge.is-fan {
  background: var(--fan);
}

.type-badge.is-kpop {
  background: var(--kpop);
}

.channel-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

html[data-nav="collapsed"] .channel-name {
  display: none;
}

.content {
  flex: 1;
  min-width: 0;
}

/* 狭い画面では開いたサイドメニューを本文に重ねて表示する */
@media (max-width: 768px) {
  .layout {
    padding-left: 72px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    z-index: 10;
    width: 240px;
    background: var(--bg);
    transition: width 0.2s;
  }

  html[data-nav="collapsed"] .sidebar {
    width: 72px;
  }
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 24px 16px 8px;
  max-width: 1280px;
  margin: 0 auto;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.channel-icon {
  flex: none;
  width: 40px;
  height: 40px;
  margin-right: -4px;
  border-radius: 50%;
}

/* 固定表示する見出しが狭い画面で場所を取りすぎないよう、アイコンと名前を1行に収める */
@media (max-width: 768px) {
  .header {
    gap: 0 12px;
    padding: 12px 16px 4px;
  }

  .header a {
    flex-basis: 100%;
    margin-left: 44px;
    font-size: 0.75rem;
  }

  .header .channel-sites a {
    flex-basis: auto;
    margin-left: 0;
  }

  .header h1 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 1.15rem;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .channel-icon {
    width: 32px;
    height: 32px;
    margin-right: 0;
  }
}

.header a {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.channel-sites {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 8px;
  flex-basis: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hover);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.channel-sites-note {
  flex: none;
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ececec;
  color: #9a9a9a;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}

.channel-host {
  flex-basis: 100%;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: nowrap;
}

.channel-sites a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
}

.channel-sites a svg {
  width: 28px;
  height: 28px;
  padding: 5px;
  box-sizing: border-box;
  border-radius: 50%;
  color: #ffffff;
}

.channel-sites a.is-x svg {
  background: #0f0f0f;
}

.channel-sites a.is-instagram svg {
  background: linear-gradient(135deg, #833ab4, #fd1d1d 52%, #fcb045);
}

.channel-sites a.is-tiktok svg {
  background: #111111;
  box-shadow:
    -1.5px 0 0 #25f4ee,
    1.5px 0 0 #fe2c55;
}

.channel-sites a.is-youtube svg {
  background: #cc0000;
}

@media (prefers-color-scheme: dark) {
  .channel-sites-note {
    background: #2a2a2a;
    color: #8a8a8a;
  }

  .channel-sites a.is-x svg {
    background: #f1f1f1;
    color: #0f0f0f;
  }

  .channel-sites a.is-tiktok svg {
    background: #1c1c1c;
    box-shadow:
      0 0 0 1px #3a3a3a,
      -1.5px 0 0 #25f4ee,
      1.5px 0 0 #fe2c55;
  }
}

/* 見出しとタブはスクロールしても上部に固定する（狭い画面のサイドメニュー z-index: 10 より下） */
.content-top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--hover);
}

.tabs {
  display: flex;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 16px 0;
}

.tabs button {
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

#tabs {
  overflow-x: auto;
}

#tabs button {
  display: inline-flex;
  flex: none;
  align-items: baseline;
  gap: 6px;
}

.tab-latest {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

/* ホームの種類タブ: タブ内にバッジを置き、選択中は下線も種類の色にする */
.tabs button.is-official,
.tabs button.is-fan,
.tabs button.is-kpop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 未選択タブのバッジは薄くして、選択中のタブを目立たせる */
.tabs button[aria-selected="false"] .type-badge {
  opacity: 0.5;
}

.tabs button.is-official[aria-selected="true"] {
  color: var(--official);
  border-bottom-color: var(--official);
}

.tabs button.is-fan[aria-selected="true"] {
  color: var(--fan);
  border-bottom-color: var(--fan);
}

.tabs button.is-kpop[aria-selected="true"] {
  color: var(--kpop);
  border-bottom-color: var(--kpop);
}

.tab-label-short {
  display: none;
}

@media (max-width: 768px) {
  .tab-label-long {
    display: none;
  }

  .tab-label-short {
    display: inline;
  }
}

.member-filter {
  display: flex;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px;
  overflow-x: auto;
}

.member-filter button {
  flex: none;
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--hover);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.member-filter button[aria-pressed="true"] {
  background: var(--fan);
  color: var(--badge-text);
}

.member-filter.is-kpop button[aria-pressed="true"] {
  background: var(--kpop);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}

.status {
  color: var(--muted);
}

.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.video-list.is-shorts {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.video-list.is-shorts .card img {
  aspect-ratio: 9 / 16;
}

@media (max-width: 768px) {
  .video-list.is-shorts {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

.card {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 12px;
}

.card:hover .card-title {
  text-decoration: underline;
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  background: var(--hover);
}

.card-thumb {
  position: relative;
}

.card-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.card-duration.is-live {
  background: #cc0000;
}

.card-title {
  margin: 8px 0 0;
  font-size: 0.95rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.new-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--new);
  color: var(--badge-text);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: 1px;
}

.home-section + .home-section {
  margin-top: 40px;
}

.home-section h3 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.home-section h3 button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.home-section h3 button:hover span {
  text-decoration: underline;
}

.home-section h3 img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.home-group + .home-group {
  margin-top: 24px;
}

/* ホームは画面幅に関係なく1行に並べ、はみ出す分は横スクロールにする */
.home-group .video-list {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: 240px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.home-group .video-list.is-shorts {
  grid-auto-columns: 160px;
}

.home-group h4 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.home-group h4 button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.home-group h4 button:hover {
  color: var(--text);
}

/* プレーヤー: is-modal（拡大表示）/ is-mini（右下の小窓）。どちらも同じ iframe のまま見た目だけ切り替える */
body.is-player-modal {
  overflow: hidden;
}

.player {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.player-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  pointer-events: auto;
}

.player.is-mini .player-backdrop {
  display: none;
}

.player-panel {
  position: absolute;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg);
  pointer-events: auto;
}

.player.is-modal .player-panel {
  top: 50%;
  left: 50%;
  width: min(960px, calc(100vw - 32px), calc((100vh - 120px) * 16 / 9));
  transform: translate(-50%, -50%);
}

.player.is-modal.is-shorts .player-panel {
  width: min(calc(100vw - 32px), calc((100vh - 120px) * 9 / 16));
}

.player.is-mini .player-panel {
  right: 16px;
  bottom: 16px;
  width: min(360px, 60vw);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.player.is-mini.is-shorts .player-panel {
  width: min(200px, 40vw);
}

.player-frame {
  aspect-ratio: 16 / 9;
  background: #000;
}

.player.is-shorts .player-frame {
  aspect-ratio: 9 / 16;
}

.player-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 6px 12px;
}

.player-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 0.875rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.player-bar button,
.player-bar a {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.player-bar button:hover,
.player-bar a:hover {
  background: var(--hover);
}

.player.is-modal [data-action="expand"],
.player.is-mini [data-action="mini"] {
  display: none;
}

/* ショートの小窓は幅が狭いので、タイトルを隠してボタンだけにする */
.player.is-mini.is-shorts .player-title {
  display: none;
}
