* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #111318;
  color: #eee;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", -apple-system, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #1b1e26;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid #2a2e38;
}

.video-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

.video-form input {
  flex: 1;
  padding: 7px 10px;
  border-radius: 4px;
  border: 1px solid #3a3f4b;
  background: #22262f;
  color: #fff;
  font-size: 14px;
}

.video-form button,
.comment-form button {
  padding: 7px 16px;
  border-radius: 4px;
  border: none;
  background: #29a3a3;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.video-form button:hover,
.comment-form button:hover:not(:disabled) {
  background: #33bcbc;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 4px;
  border: 1px solid #dadce0;
  background: #fff;
  color: #3c4043;
  font-family: Roboto, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.google-btn:hover {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  background: #f8f9fa;
  text-decoration: none;
}

.google-btn:active {
  background: #f1f3f4;
}

.google-btn__icon {
  display: inline-flex;
  flex: 0 0 auto;
}

.auth-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.auth-area a:not(.google-btn) {
  color: #29a3a3;
  text-decoration: none;
}

.auth-area a:not(.google-btn):hover {
  text-decoration: underline;
}

/* YouTube API Services ブランドの取り扱いガイドライン準拠の "Developed with
   YouTube" ロゴ。 */
.yt-brand-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.yt-brand-badge img {
  display: block;
  height: 52px;
  width: auto;
}

.yt-brand-badge:hover {
  opacity: 0.85;
  text-decoration: none;
}

.user-name {
  color: #ccc;
}

.home-logo-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #22262f;
  color: #29a3a3;
  cursor: pointer;
}

.home-logo-btn:hover {
  background: #2a2f3a;
  color: #33bcbc;
}

.home-logo-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.home-view {
  width: 80%;
  margin: 0 auto;
  padding: 20px 14px 40px;
}

.home-view[hidden] {
  display: none;
}

.home-view__status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
}

.home-view__status {
  min-height: 1.2em;
  font-size: 13px;
  color: #999;
  margin: 0;
}

.subscriptions-refresh-btn {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #3a3f4b;
  background: #22262f;
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
}

.subscriptions-refresh-btn:hover {
  background: #2a2f3a;
}

.subscriptions-refresh-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.home-view__layout {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.home-view__channels {
  flex: 0 0 220px;
}

.home-view__channels h2 {
  font-size: 15px;
  color: #ccc;
  margin: 0 0 8px;
  font-weight: 600;
  border-bottom: 1px solid #2a2e38;
  padding-bottom: 6px;
}

.home-view__channels-count {
  font-size: 12px;
  font-weight: 400;
  color: #777;
  margin-left: 4px;
}

.channel-search-input {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 4px;
  border: 1px solid #3a3f4b;
  background: #22262f;
  color: #fff;
  font-size: 13px;
}

.channel-search-input::placeholder {
  color: #777;
}

.home-view__content {
  flex: 1;
  min-width: 0;
}

.home-view__section h2 {
  font-size: 15px;
  color: #ccc;
  margin: 0 0 8px;
  font-weight: 600;
  border-bottom: 1px solid #2a2e38;
  padding-bottom: 6px;
}

.home-view__section + .home-view__section {
  margin-top: 22px;
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
  /* スクロールできることが分かりにくいと「全部表示されていない」ように
     見えてしまうため、常に見えるスクロールバーにしておく。 */
  scrollbar-width: thin;
  scrollbar-color: #444a58 #1b1e26;
}

.channel-list::-webkit-scrollbar {
  width: 8px;
}

.channel-list::-webkit-scrollbar-track {
  background: #1b1e26;
}

.channel-list::-webkit-scrollbar-thumb {
  background: #444a58;
  border-radius: 4px;
}

.channel-list::-webkit-scrollbar-thumb:hover {
  background: #565d6e;
}

.channel-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.channel-list__item:hover {
  background: #22262f;
}

.channel-list__item[hidden] {
  display: none;
}

.channel-list__item.is-active {
  background: #22343a;
}

.channel-list__item.is-active .channel-list__name {
  color: #29a3a3;
  font-weight: 600;
}

.channel-list__item--all {
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2a2e38;
}

.channel-list__item--all .channel-list__icon {
  display: none;
}

.channel-list__icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
}

.channel-list__name {
  min-width: 0;
  flex: 1;
  font-size: 13px;
  color: #ddd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-list__empty {
  font-size: 13px;
  color: #777;
  padding: 6px 2px;
}

@media (max-width: 860px) {
  .home-view__layout {
    flex-direction: column;
  }

  .home-view__channels {
    flex-basis: auto;
    width: 100%;
  }

  .channel-list {
    max-height: 240px;
  }
}

.subscriptions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px 12px;
}

.subscriptions-list__empty {
  grid-column: 1 / -1;
  font-size: 13px;
  color: #777;
  padding: 6px 2px;
}

.subscriptions-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0 0 10px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  width: 100%;
  font: inherit;
}

.subscriptions-item:hover .subscriptions-item__thumb {
  filter: brightness(1.1);
}

.subscriptions-item__thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  margin-bottom: 8px;
}

.subscriptions-item__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.subscriptions-item__meta {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.subscriptions-item__channel-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
  margin-top: 1px;
}

.subscriptions-item__text {
  min-width: 0;
  flex: 1;
}

.subscriptions-item__title {
  font-size: 13px;
  color: #eee;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.subscriptions-item__channel {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subscriptions-item__live-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: inline-block;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

.subscriptions-item__upcoming-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: inline-block;
  background: #1e88e5;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

.watch-layout {
  width: 80%;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.watch-layout[hidden] {
  display: none;
}

.player-wrap {
  flex: 1 1 640px;
  min-width: 0;
}

#player-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

/* フルスクリーンAPIは #player-container(iframeの親)に対して呼ぶ(JS参照)。
   これにより弾幕レイヤー・カスタム操作バーもフルスクリーン内に含まれる。
   aspect-ratio を固定したままだと画面サイズによって余白ができてしまうため
   解除し、画面いっぱいに広げる。角丸・影も画面端では不要なので消す。 */
#player-container:fullscreen,
#player-container:-webkit-full-screen,
#player-container:-moz-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}

#yt-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* iframeにマウスが乗るとYouTube純正のホバーUI(共有・関連動画・ロゴ等)が
   出てきてしまうため、透明な層を1枚重ねてマウスイベントがiframeに
   到達しないようにする。 */
.hover-blocker {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#danmaku-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  font-weight: bold;
}

.custom-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.55) 55%, rgba(0, 0, 0, 0));
  z-index: 5;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.custom-controls.is-hidden {
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
}

.custom-controls__btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.custom-controls__btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  transition: transform 0.1s ease;
}

.custom-controls__btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #29a3a3;
}

.custom-controls__btn:active svg {
  transform: scale(0.88);
}

.custom-controls__time {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
  color: #eee;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  margin: 0 6px;
}

.custom-controls__seek {
  flex: 1;
  min-width: 0;
  height: 16px;
  margin: 0 4px;
  cursor: pointer;
  appearance: none;
  background: transparent;
}

.custom-controls__seek:disabled {
  opacity: 0.4;
  cursor: default;
}

/* input[type=range] はブラウザ既定のトラック/つまみでは丸みや太さを揃えられない
   ため、track/thumb を個別にスタイルする(WebKit/Geckoでプレフィックスが必要)。 */
.custom-controls__seek::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    #e53935 var(--seek-progress, 0%),
    rgba(255, 255, 255, 0.28) var(--seek-progress, 0%)
  );
  transition: height 0.12s ease;
}

.custom-controls__seek::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4px;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 0 4px rgba(229, 57, 53, 0);
  transition: box-shadow 0.15s ease;
}

.custom-controls__seek:hover::-webkit-slider-runnable-track {
  height: 7px;
}

.custom-controls__seek:hover::-webkit-slider-thumb {
  box-shadow: 0 0 0 6px rgba(229, 57, 53, 0.25);
}

.custom-controls__seek::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.28);
}

.custom-controls__seek::-moz-range-progress {
  height: 5px;
  border-radius: 3px;
  background: #e53935;
}

.custom-controls__seek::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 0 4px rgba(229, 57, 53, 0);
  transition: box-shadow 0.15s ease;
}

.custom-controls__seek:hover::-moz-range-track,
.custom-controls__seek:hover::-moz-range-progress {
  height: 7px;
}

.custom-controls__seek:hover::-moz-range-thumb {
  box-shadow: 0 0 0 6px rgba(229, 57, 53, 0.25);
}

.custom-controls__volume-wrap {
  position: relative;
  flex: 0 0 auto;
  display: flex;
}

.volume-popup {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 6px;
  background: rgba(27, 30, 38, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.volume-popup[hidden] {
  display: none;
}

.volume-popup__mute-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #eee;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.volume-popup__mute-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.volume-popup__mute-btn svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.volume-popup__slider {
  flex: 1;
  min-width: 0;
  accent-color: #29a3a3;
  height: 4px;
  cursor: pointer;
}

.custom-controls__btn.is-active {
  color: #29a3a3;
}

.custom-controls__btn--cc {
  width: auto;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 15px;
  line-height: 1;
}

.custom-controls__btn--cc.is-active {
  color: #111318;
  background: #29a3a3;
  border-color: #29a3a3;
}

.custom-controls__settings-wrap {
  position: relative;
  flex: 0 0 auto;
  display: flex;
}

.settings-menu {
  position: absolute;
  bottom: 44px;
  right: 0;
  min-width: 110px;
  background: rgba(27, 30, 38, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.settings-menu[hidden] {
  display: none;
}

.settings-menu__label {
  font-size: 11px;
  color: #999;
  padding: 4px 8px 4px;
}

.settings-menu__item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #eee;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.settings-menu__item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.settings-menu__item.is-active {
  color: #29a3a3;
}

@media (max-width: 600px) {
  .custom-controls__time {
    display: none;
  }
}

.danmaku-comment {
  position: absolute;
  top: 0;
  left: 0;
  white-space: nowrap;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  text-shadow:
    1px 1px 1px rgba(0, 0, 0, 0.9),
    -1px -1px 1px rgba(0, 0, 0, 0.9),
    1px -1px 1px rgba(0, 0, 0, 0.9),
    -1px 1px 1px rgba(0, 0, 0, 0.9);
}

.danmaku-comment.is-self {
  color: #ffe066;
}

.danmaku-comment.is-system {
  color: #ff6b6b;
}

/* スーパーチャット: YouTube側の金額帯カラー(--danmaku-color、JSから設定)を
   背景色にした帯状の見た目にして、通常コメントと明確に区別する。動画本編の上に
   重なるため、背景は半透明にして視聴の妨げになりにくくしている(その分、文字は
   通常の弾幕と同じ縁取り(text-shadow)を付けて明るい映像の上でも読めるようにする)。 */
.danmaku-comment.is-superchat {
  background: color-mix(in srgb, var(--danmaku-color, #1565c0) 65%, transparent);
  color: #fff;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  text-shadow:
    1px 1px 1px rgba(0, 0, 0, 0.9),
    -1px -1px 1px rgba(0, 0, 0, 0.9),
    1px -1px 1px rgba(0, 0, 0, 0.9),
    -1px 1px 1px rgba(0, 0, 0, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.status-line {
  min-height: 1.2em;
  margin: 6px 2px 0;
  font-size: 13px;
  color: #999;
}

.video-info {
  margin-top: 10px;
  padding: 12px 14px;
  background: #1b1e26;
  border: 1px solid #2a2e38;
  border-radius: 8px;
}

.video-info[hidden] {
  display: none;
}

.video-info__title {
  font-size: 16px;
  font-weight: 600;
  color: #eee;
  margin: 0 0 6px;
}

.video-info__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: #999;
  margin-bottom: 10px;
}

.video-info__channel {
  color: #ccc;
  font-weight: 600;
  text-decoration: none;
  cursor: default;
}

.video-info__channel--link {
  cursor: pointer;
}

.video-info__channel--link:hover {
  color: #fff;
  text-decoration: underline;
}

.video-info__description {
  font-size: 13px;
  color: #ccc;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.video-info__description.is-expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.video-info__toggle {
  margin-top: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: #29a3a3;
  font-size: 12px;
  cursor: pointer;
}

.video-info__toggle:hover {
  text-decoration: underline;
}

.video-info__toggle[hidden] {
  display: none;
}

.chat-panel {
  flex: 0 0 320px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #1b1e26;
  border: 1px solid #2a2e38;
  border-radius: 6px;
  overflow: hidden;
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
}

.chat-message {
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-message .chat-author {
  color: #7fd7d7;
  font-weight: 600;
  margin-right: 6px;
}

.chat-message.is-self .chat-author {
  color: #ffe066;
}

.chat-message.is-system {
  color: #ff8c8c;
}

.chat-message.is-superchat {
  background: var(--danmaku-color, #1565c0);
  color: #fff;
  border-radius: 6px;
  margin: 2px 6px;
  padding: 6px 10px;
}

.chat-message.is-superchat .chat-author {
  color: #fff;
  opacity: 0.9;
}

.chat-superchat-amount {
  font-weight: 700;
  margin-right: 6px;
}

.comment-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #2a2e38;
}

.comment-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 20px;
  border: 1px solid #3a3f4b;
  background: #22262f;
  color: #fff;
  font-size: 15px;
}

.comment-form input:disabled {
  opacity: 0.5;
}

.comment-form button {
  border-radius: 20px;
  padding: 0 22px;
}

.comment-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 860px) {
  .watch-layout {
    flex-direction: column;
  }

  .chat-panel {
    flex: 1 1 auto;
    height: 360px;
  }
}

@media (max-width: 600px) {
  .danmaku-comment {
    font-size: 16px;
  }
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 16px;
  font-size: 12px;
}

.site-footer a {
  color: #888;
  text-decoration: none;
}

.site-footer a:hover {
  color: #7fd7d7;
  text-decoration: underline;
}
