/* ===== リセット & 基本設定 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f9f9f9;
  --bg-card: #ffffff;
  --text-primary: #0f0f0f;
  --text-secondary: #606060;
  --border-color: #e5e5e5;
  --chip-bg: #f2f2f2;
  --chip-active-bg: #0f0f0f;
  --chip-active-text: #ffffff;
  --header-bg: #ffffff;
  --shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
  --banner-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --accent: #ff0000;
}

[data-theme="dark"] {
  --bg-primary: #0f0f0f;
  --bg-secondary: #181818;
  --bg-card: #212121;
  --text-primary: #f1f1f1;
  --text-secondary: #aaaaaa;
  --border-color: #383838;
  --chip-bg: #383838;
  --chip-active-bg: #f1f1f1;
  --chip-active-text: #0f0f0f;
  --header-bg: #202020;
  --shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

body {
  font-family: "Segoe UI", "Noto Sans JP", "Hiragino Sans", sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

/* ===== ヘッダー ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 0;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-center {
  flex: 1;
  max-width: 540px;
  margin: 0 24px;
}

.search-box {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: 40px;
  overflow: hidden;
}

.search-box input {
  flex: 1;
  padding: 8px 16px;
  border: none;
  outline: none;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.search-btn {
  padding: 0 20px;
  border: none;
  background: var(--chip-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background-color 0.2s;
}

.search-btn:hover {
  background: var(--border-color);
}

.search-btn svg path {
  fill: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background: var(--chip-bg);
}

.theme-toggle svg path {
  fill: var(--text-secondary);
}

/* ===== チャンネルバナー ===== */
.channel-banner {
  background: var(--banner-bg);
  padding: 48px 24px 32px;
}

.banner-overlay {
  max-width: 1200px;
  margin: 0 auto;
}

.channel-info {
  display: flex;
  align-items: center;
  gap: 24px;
}

.channel-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 3px solid rgba(255, 255, 255, 0.5);
}

.channel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.channel-details {
  color: #ffffff;
}

.channel-name {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 2px;
}

.channel-handle {
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.channel-stats {
  font-size: 13px;
  opacity: 0.7;
  margin-bottom: 8px;
}

.channel-description {
  font-size: 14px;
  opacity: 0.9;
  max-width: 700px;
  white-space: pre-wrap;
  line-height: 1.7;
}

/* ===== カテゴリバー ===== */
.category-bar {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  max-width: 1248px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.category-chip {
  padding: 6px 16px;
  border: none;
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.category-chip:hover {
  background: var(--border-color);
}

.category-chip.active {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
}

/* ===== 動画グリッド ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 24px;
  max-width: 1248px;
  margin: 0 auto;
}

.video-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.video-card:hover .video-thumbnail img {
  transform: scale(1.05);
}

.video-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
}

.video-info {
  padding: 12px;
}

.video-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.video-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.video-category-tag {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  background: var(--chip-bg);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* 動画が見つからない場合 */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
  font-size: 16px;
}

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

.modal-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.modal-video iframe {
  width: 100%;
  height: 100%;
}

.modal-info {
  padding: 20px;
}

.modal-info h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal-info #modalMeta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.modal-info #modalDescription {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ===== フッター ===== */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
  .logo-text {
    font-size: 15px;
  }

  .header-icon {
    width: 28px;
    height: 28px;
  }

  .header-center {
    margin: 0 8px;
  }

  .channel-info {
    flex-direction: column;
    text-align: center;
  }

  .channel-description {
    max-width: 100%;
  }

  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    padding: 16px;
  }

  .category-bar {
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  .logo-text {
    font-size: 13px;
  }

  .header-icon {
    width: 24px;
    height: 24px;
  }

  .header {
    padding: 0 8px;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .channel-name {
    font-size: 22px;
  }
}
