* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root {
  --accent: #2962FF;
  --accent-grad: linear-gradient(145deg, #4A8CFF, #1F55E6);
  --text: #0f0f0f;
  --text-2: #606060;
  --line: #e5e5e5;
  --chip: #f2f2f2;
  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
  --shadow-2: 0 6px 16px rgba(16, 24, 40, .16);
}
body {
  font-family: Roboto, "Noto Sans JP", system-ui, sans-serif;
  background: #fff;
  color: var(--text);
}

/* ヘッダー */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 16px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text); flex: none;
}
.brand-badge, .hero-badge {
  display: inline-block; width: 32px; height: 22px;
  background: var(--accent-grad);
  border-radius: 7px; position: relative;
  box-shadow: 0 2px 6px rgba(41, 98, 255, .40);
}
.brand-badge::after, .hero-badge::after {
  content: ""; position: absolute; left: 55%; top: 50%;
  transform: translate(-50%, -50%);
  border-left: 9px solid #fff;
  border-top: 5.5px solid transparent;
  border-bottom: 5.5px solid transparent;
}
.brand-name, .hero-name {
  font-family: "Oswald", "Noto Sans JP", sans-serif;
  font-weight: 600; letter-spacing: 0.2px;
}
.brand-name { font-size: 22px; }

/* 検索バー(検索前はヒーロー中央、検索後はヘッダーへ移動。マイクは今のYouTube同様バーの右外) */
.searchbar { display: flex; align-items: center; gap: 10px; }
.bar {
  position: relative;
  flex: 1; display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 0 0 18px;
  background: #fff;
  border: 1px solid #ccc; border-radius: 999px;
  transition: border-color .15s ease;
}
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: #fff; border-radius: 16px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .18);
  padding: 8px 0; text-align: left;
}
.suggest-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 18px; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 15px; color: var(--text); text-align: left;
}
.suggest-text { text-align: left; }
.suggest-row:hover { background: var(--chip); }
.suggest-row svg { width: 18px; height: 18px; fill: var(--text-2); flex: none; }
.suggest-text {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.suggest-del { color: var(--text-2); padding: 0 4px; font-size: 16px; line-height: 1; }
.suggest-del:hover { color: var(--text); }
.bar:focus-within { border-color: #1c62b9; }
.bar input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px;
  border: none; background: transparent; outline: none; height: 100%;
}
.bar-btn.go {
  display: grid; place-items: center; flex: none;
  width: 64px; height: 100%;
  border: none; border-left: 1px solid #ccc;
  border-radius: 0 999px 999px 0;
  background: #f8f8f8; cursor: pointer;
}
.bar-btn.go:hover { background: var(--chip); }
.bar-btn.go svg { width: 22px; height: 22px; fill: var(--text); }
.mic-round {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--chip); cursor: pointer;
}
.mic-round:hover { background: var(--line); }
.mic-round svg { width: 22px; height: 22px; fill: var(--text); }
.mic-round.listening { background: var(--accent-grad); animation: pulse 1.2s ease infinite; }
.mic-round.listening svg { fill: #fff; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(41, 98, 255, .45); }
  50% { box-shadow: 0 0 0 8px rgba(41, 98, 255, 0); }
}
.topbar .searchbar { flex: 1; max-width: 600px; margin: 0 auto; }
.hero .searchbar { max-width: 640px; margin: 36px auto 0; }
.hero .bar { height: 48px; }
.hero .bar input { font-size: 17px; }
.hero .mic-round { width: 48px; height: 48px; }

/* チャンネル表示バー */
.channel-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 24px 0;
}
.channel-bar .avatar { width: 40px; height: 40px; }
#channel-bar-name { font-weight: 700; font-size: 16px; }
#channel-close { width: 34px; height: 34px; }
#channel-close svg { width: 20px; height: 20px; fill: var(--text-2); }
#channel-close:hover svg { fill: var(--text); }

/* 並びかえチップ */
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 12px 24px 0;
}
.chip {
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 7px 14px; border: none; border-radius: 8px;
  background: var(--chip); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease;
}
.chip:hover { background: var(--line); }
.chip.active { background: var(--text); color: #fff; }

/* 検索前のヒーロー */
.hero {
  text-align: center; padding: 108px 16px 56px;
}
.hero-badge {
  width: 88px; height: 61px; border-radius: 18px;
  box-shadow: 0 3px 10px rgba(41, 98, 255, .30);
}
.hero-badge::after {
  border-left-width: 27px;
  border-top-width: 16px;
  border-bottom-width: 16px;
}
.hero-name { display: block; font-size: 54px; margin-top: 14px; }

.message { text-align: center; font-size: 15px; color: var(--text-2); padding: 32px 16px; }

/* 検索結果グリッド */
.results {
  list-style: none;
  display: grid;
  /* 本家同様: 画面幅いっぱいに敷き詰め、広いほどカードが大きくなる(最大4列) */
  grid-template-columns: repeat(auto-fill, minmax(max(340px, 22%), 1fr));
  gap: 40px 16px;
  padding: 24px;
}
.results a {
  display: block; text-decoration: none; color: inherit;
  padding: 8px; margin: -8px; border-radius: 16px;
  transition: background .15s ease;
}
.results a:hover { background: var(--chip); }
.thumb { position: relative; display: block; }
.thumb img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  border-radius: var(--radius); background: var(--chip);
}
.star-btn {
  position: absolute; right: 6px; bottom: 6px;
  display: grid; place-items: center;
  width: 27px; height: 27px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}
.star-btn svg { width: 15px; height: 15px; fill: #fff; }
.star-btn:hover { background: rgba(0, 0, 0, .75); }
.star-btn.faved svg { fill: #FFC400; }
.results .info { display: flex; gap: 10px; margin-top: 10px; align-items: flex-start; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  object-fit: cover; background: var(--chip);
}
.results .avatar { cursor: pointer; }
.results .avatar:hover { opacity: .85; }
.txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.results .title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 15px; font-weight: 500; line-height: 1.45;
}
.results .channel { font-size: 13px; color: var(--text-2); }
.results .meta { font-size: 13px; color: var(--text-2); }
#sentinel { height: 1px; }

/* ヘッダーのおきにいりボタン */
.icon-btn.fav { margin-left: auto; width: 44px; height: 44px; background: var(--chip); }
.icon-btn.fav:hover { background: var(--line); }
.icon-btn.fav svg { fill: var(--text); }
.icon-btn.fav.active svg { fill: #FFC400; }

/* アイコンボタン */
.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--chip); }
.icon-btn svg { width: 24px; height: 24px; fill: var(--text); }

/* 再生ページ */
.watch-main { max-width: 1120px; margin: 0 auto; padding: 24px 16px; }
.player-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: var(--radius); overflow: hidden; background: #000;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .22);
}
.player-wrap iframe { width: 100%; height: 100%; display: block; }

/* 埋め込みプレーヤー内のYouTube行きリンクを遮断する透明シールド */
.shield { position: absolute; z-index: 5; }
.shield-top { top: 0; left: 0; right: 0; height: 64px; }
.shield-logo { bottom: 0; right: 0; width: 130px; height: 44px; }

/* 一時停止中は「その他の動画」等が埋め込み内に出るため全面を覆う。タップでどこでも再生再開 */
.pause-shield {
  position: absolute; inset: 0; z-index: 5;
  border: none; cursor: pointer;
  background: rgba(15, 15, 15, .35);
}

/* 自前の全画面(シールドごと全画面にする) */
.player-wrap:fullscreen { border-radius: 0; aspect-ratio: auto; }

/* 動画下の情報エリア */
.watch-info { padding-top: 14px; }
.watch-info h1 { font-size: 19px; font-weight: 700; line-height: 1.45; }
.watch-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.watch-row .avatar { width: 40px; height: 40px; }
.watch-ch { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.watch-row .icon-btn.fav { margin-left: 0; }
.watch-ch-name { font-size: 15px; font-weight: 500; }
.watch-ch-subs { font-size: 12px; color: var(--text-2); }
.watch-box {
  margin-top: 14px; padding: 12px 14px;
  background: var(--chip); border-radius: var(--radius);
  font-size: 14px; line-height: 1.6; cursor: pointer;
}
.watch-meta { font-weight: 700; display: block; }
.watch-desc {
  margin-top: 4px; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.watch-box.open .watch-desc { display: block; -webkit-line-clamp: unset; }

/* 終了オーバーレイ(核心機能: 関連動画の壁を隠す) */
.overlay {
  position: absolute; inset: 0; z-index: 6;
  background: radial-gradient(600px 400px at 50% 40%, rgba(30, 34, 48, .96), rgba(10, 11, 15, .98));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
}
.overlay[hidden] { display: none; }
.overlay p { color: #fff; font-size: 24px; font-weight: 700; }
.overlay-buttons { display: flex; gap: 20px; }
.circle-btn {
  display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 50%;
  border: none; cursor: pointer; text-decoration: none;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  transition: transform .12s ease;
}
.circle-btn svg { width: 30px; height: 30px; fill: var(--text); }
.circle-btn.primary { background: var(--accent-grad); box-shadow: 0 6px 18px rgba(41, 98, 255, .45); }
.circle-btn.primary svg { fill: #fff; }
.circle-btn:hover { transform: scale(1.08); }
/* スマホ: YouTube同様の1列フルブリード表示 */
@media (max-width: 550px) {
  .results { grid-template-columns: 1fr; padding: 16px 0 24px; gap: 28px; }
  .results a { padding: 0; margin: 0; border-radius: 0; }
  .results a:hover { background: none; }
  .thumb img { border-radius: 0; }
  .results .info { padding: 0 12px; }
  .star-btn { right: 10px; bottom: 10px; }
  .chips { padding: 10px 12px 0; }
  .channel-bar { padding: 12px 12px 0; }
  .hero { padding-top: 72px; }
  .hero-name { font-size: 42px; }
  .brand-name { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .circle-btn:hover { transform: none; }
  .bar-btn.mic.listening { animation: none; }
}
