/* ==========================================================================
   AkiLive 共通 UI — YouTube 風デザイン
   body.yt-page を持つ全ページに適用（色の定義・ベース・マストヘッド・共通部品）。
   視聴画面固有のレイアウトは watch.css、各一覧画面は pages.css にある。
   style.css の既存ルールを上書きするため、セレクタは body.yt-page から始める。
   ========================================================================== */

body.yt-page {
  --yt-bg: #ffffff;
  --yt-text: #0f0f0f;
  --yt-text-2: #606060;
  --yt-tonal: rgba(0, 0, 0, 0.05);
  --yt-tonal-hover: rgba(0, 0, 0, 0.1);
  --yt-border: rgba(0, 0, 0, 0.1);
  --yt-red: #ff0000;
  --yt-live: #cc0000;
  --yt-blue: #065fd4;
  --yt-avatar-bg: #5c6bc0;
  --yt-masthead-h: 56px;

  margin: 0;
  background: var(--yt-bg);
  color: var(--yt-text);
  font-family: "Roboto", "Arial", "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "メイリオ", "Meiryo", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

html:has(body.yt-page) {
  background: #ffffff;
}

body.yt-page button {
  font-family: inherit;
}

/* グローバルの a:hover / label:hover の灰色背景を打ち消す */
body.yt-page a:hover,
body.yt-page label:hover {
  background-color: transparent;
}

/* --------------------------------------------------------------------------
   マストヘッド
   -------------------------------------------------------------------------- */
body.yt-page .yt-masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--yt-masthead-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--yt-bg);
  box-sizing: border-box;
}

body.yt-page .yt-masthead-start {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* メニューボタンが無いページ（未ログインのトップなど）はロゴを少し内側に */
body.yt-page .yt-masthead-start:not(:has(.menu-icon)) {
  padding-left: 8px;
}

body.yt-page .yt-icon-btn {
  position: static;
  width: 40px;
  height: 40px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--yt-text);
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: background-color 0.15s ease;
}

body.yt-page .yt-icon-btn:hover {
  background-color: var(--yt-tonal-hover);
}

body.yt-page .yt-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--yt-text);
  line-height: 1;
}

body.yt-page .yt-logo-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--yt-red);
  box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.18);
}

body.yt-page .yt-masthead-end.profile-container {
  width: auto;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

body.yt-page .yt-masthead-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

body.yt-page .yt-masthead-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

body.yt-page .yt-masthead .mypage-link {
  height: auto;
  font-size: 14px;
  font-weight: 500;
  color: var(--yt-text);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.yt-page .yt-masthead .login-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px 0 11px;
  border: 1px solid var(--yt-border);
  border-radius: 18px;
  color: var(--yt-blue);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  box-sizing: border-box;
}

body.yt-page .yt-masthead .login-link:hover {
  background-color: #def1ff;
  border-color: transparent;
  color: var(--yt-blue);
}

/* ガイド（ドロワーメニュー）は全ページ共通のため style.css 末尾で定義 */

@media (max-width: 1030px) {
  body.yt-page {
    --yt-masthead-h: 48px;
  }

  body.yt-page .yt-masthead {
    padding: 0 12px 0 4px;
  }

  body.yt-page .yt-masthead-start {
    gap: 4px;
  }

  body.yt-page .yt-logo {
    font-size: 18px;
  }

  body.yt-page .yt-masthead .mypage-link {
    max-width: 120px;
    font-size: 13px;
  }

  body.yt-page .yt-masthead-avatar {
    width: 28px;
    height: 28px;
  }

  body.yt-page .yt-masthead .login-link {
    height: 34px;
    font-size: 13px;
  }
}

/* マストヘッド右側のロールバッジ（配信者画面の HOST など） */
body.yt-page .yt-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--yt-tonal);
  color: var(--yt-text-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
}

/* --------------------------------------------------------------------------
   ページ枠（一覧系ページ）
   -------------------------------------------------------------------------- */
body.yt-page .yt-main {
  max-width: 1284px;
  margin: 0 auto;
  padding: calc(var(--yt-masthead-h) + 24px) 24px 48px;
  box-sizing: border-box;
}

body.yt-page .yt-main-narrow {
  max-width: 856px;
}

body.yt-page .yt-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 24px;
}

body.yt-page .yt-page-title {
  margin: 0;
  font-size: 28px;
  line-height: 36px;
  font-weight: 700;
  color: var(--yt-text);
  text-align: left;
}

body.yt-page .yt-page-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--yt-text-2);
}

body.yt-page .yt-section-title {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 28px;
  font-weight: 700;
  color: var(--yt-text);
}

@media (max-width: 1030px) {
  body.yt-page .yt-main {
    padding: calc(var(--yt-masthead-h) + 16px) 12px 32px;
  }

  body.yt-page .yt-page-header {
    margin-bottom: 16px;
  }

  body.yt-page .yt-page-title {
    font-size: 20px;
    line-height: 28px;
  }
}

/* --------------------------------------------------------------------------
   ボタン
   -------------------------------------------------------------------------- */
body.yt-page .yt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  margin: 0;
  padding: 0 16px;
  border: none;
  border-radius: 18px;
  background: var(--yt-tonal);
  color: var(--yt-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 36px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: none;
  transform: none;
  transition: background-color 0.15s ease;
}

body.yt-page .yt-btn:hover {
  background: var(--yt-tonal-hover);
  color: var(--yt-text);
  transform: none;
  box-shadow: none;
}

body.yt-page .yt-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

body.yt-page .yt-btn-primary {
  background: var(--yt-text);
  color: #fff;
}

body.yt-page .yt-btn-primary:hover {
  background: #272727;
  color: #fff;
}

body.yt-page .yt-btn-blue {
  background: var(--yt-blue);
  color: #fff;
}

body.yt-page .yt-btn-blue:hover {
  background: #0556bf;
  color: #fff;
}

body.yt-page .yt-btn-text {
  background: transparent;
  color: var(--yt-blue);
}

body.yt-page .yt-btn-text:hover {
  background: #def1ff;
  color: var(--yt-blue);
}

body.yt-page .yt-btn-danger {
  background: transparent;
  color: #cc0000;
}

body.yt-page .yt-btn-danger:hover {
  background: rgba(204, 0, 0, 0.08);
  color: #cc0000;
}

body.yt-page .yt-btn:disabled,
body.yt-page .yt-btn[disabled] {
  background: var(--yt-tonal);
  color: #909090;
  cursor: default;
}

/* --------------------------------------------------------------------------
   チップ（絞り込み・タブ）
   -------------------------------------------------------------------------- */
body.yt-page .yt-chipbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

body.yt-page .yt-chipbar::-webkit-scrollbar {
  display: none;
}

body.yt-page .yt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  width: auto;
  height: 32px;
  margin: 0;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: var(--yt-tonal);
  color: var(--yt-text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 32px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  box-sizing: border-box;
  user-select: none;
  transition: background-color 0.15s ease;
}

body.yt-page .yt-chip:hover {
  background: var(--yt-tonal-hover);
  color: var(--yt-text);
}

/* style.css のグローバル .active { height: 100% } を打ち消すため height も指定 */
body.yt-page .yt-chip.active,
body.yt-page .yt-chip.selected,
body.yt-page .yt-chip[aria-selected="true"] {
  height: 32px;
  background: var(--yt-text);
  color: #fff;
}

@media (max-width: 1030px) {
  body.yt-page .yt-chipbar {
    gap: 8px;
    margin: 0 -12px 16px;
    padding: 0 12px;
  }
}

/* --------------------------------------------------------------------------
   アバター
   -------------------------------------------------------------------------- */
body.yt-page .yt-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--yt-avatar-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}

body.yt-page .yt-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --------------------------------------------------------------------------
   LIVE バッジ
   -------------------------------------------------------------------------- */
body.yt-page .yt-live-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--yt-live);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  line-height: 18px;
}

/* --------------------------------------------------------------------------
   お知らせ（Django messages）— YouTube のスナックバー風
   -------------------------------------------------------------------------- */
body.yt-page .yt-snackbar,
body.yt-page #registered-message {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 1800;
  max-width: min(480px, calc(100vw - 48px));
  margin: 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: #0f0f0f;
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  animation: yt-snackbar 5s ease forwards;
  pointer-events: none;
}

@keyframes yt-snackbar {
  0% { opacity: 0; transform: translateY(16px); }
  6% { opacity: 1; transform: translateY(0); }
  88% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(16px); visibility: hidden; }
}

@media (max-width: 1030px) {
  body.yt-page .yt-snackbar,
  body.yt-page #registered-message {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-width: none;
  }
}

/* --------------------------------------------------------------------------
   空の状態
   -------------------------------------------------------------------------- */
body.yt-page .yt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 64px 16px;
  color: var(--yt-text-2);
  text-align: center;
}

body.yt-page .yt-empty svg {
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
  color: #909090;
}

body.yt-page .yt-empty-title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  color: var(--yt-text);
}

body.yt-page .yt-empty-text {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

/* --------------------------------------------------------------------------
   ダイアログ（style.css の .modal-* / .confirm-modal-* を YouTube 風に）
   -------------------------------------------------------------------------- */
body.yt-page .modal-overlay,
body.yt-page .confirm-modal-overlay {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.yt-page .modal-container,
body.yt-page .confirm-modal-container {
  border-radius: 12px;
  background: var(--yt-bg);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.2);
}

body.yt-page .modal-header {
  padding: 20px 16px 8px 24px;
  border-bottom: none;
}

body.yt-page .modal-title,
body.yt-page .confirm-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--yt-text);
}

body.yt-page .modal-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--yt-text);
  background: transparent;
}

body.yt-page .modal-close:hover {
  background: var(--yt-tonal-hover);
  color: var(--yt-text);
}

body.yt-page .modal-body {
  padding: 8px 24px 16px;
}

body.yt-page .modal-description,
body.yt-page .confirm-modal-message {
  color: var(--yt-text-2);
  font-size: 14px;
  line-height: 20px;
}

body.yt-page .modal-label {
  color: var(--yt-text);
  font-size: 14px;
  font-weight: 500;
}

body.yt-page .modal-label:hover {
  background: transparent;
}

body.yt-page .modal-input,
body.yt-page .modal-textarea,
body.yt-page .yt-input {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: var(--yt-bg);
  color: var(--yt-text);
  font-family: inherit;
  font-size: 15px;
  box-shadow: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

body.yt-page .modal-input,
body.yt-page .yt-input {
  height: 44px;
  padding: 0 14px;
}

body.yt-page .modal-textarea {
  padding: 10px 14px;
}

body.yt-page .modal-input:focus,
body.yt-page .modal-textarea:focus,
body.yt-page .yt-input:focus {
  outline: none;
  border-color: var(--yt-blue);
  box-shadow: 0 0 0 1px var(--yt-blue);
}

body.yt-page .modal-input::placeholder,
body.yt-page .modal-textarea::placeholder,
body.yt-page .yt-input::placeholder {
  color: #909090;
}

body.yt-page .modal-footer,
body.yt-page .confirm-modal-buttons {
  gap: 8px;
  padding: 8px 16px 16px;
  border-top: none;
  background: transparent;
}

body.yt-page .modal-btn,
body.yt-page .confirm-modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
  transform: none;
}

body.yt-page .modal-btn-cancel,
body.yt-page .confirm-modal-btn-cancel {
  background: transparent;
  color: var(--yt-text);
}

body.yt-page .modal-btn-cancel:hover,
body.yt-page .confirm-modal-btn-cancel:hover {
  background: var(--yt-tonal-hover);
}

body.yt-page .modal-btn-submit {
  background: var(--yt-blue);
  color: #fff;
}

body.yt-page .modal-btn-submit:hover {
  background: #0556bf;
  transform: none;
  box-shadow: none;
}

body.yt-page .confirm-modal-btn-remove {
  background: var(--yt-text);
  color: #fff;
}

body.yt-page .confirm-modal-btn-remove:hover {
  background: #272727;
}

/* チャンネルタイプ選択（作成ダイアログ） */
body.yt-page .type-option:hover {
  background: transparent;
}

body.yt-page .type-option-content {
  border: 1px solid #ccc;
  border-radius: 12px;
  background: var(--yt-bg);
  box-shadow: none;
}

body.yt-page .type-option:hover .type-option-content {
  border-color: #909090;
  background: var(--yt-bg);
}

body.yt-page .type-option input:checked + .type-option-content {
  border-color: var(--yt-blue);
  background: #f2f8ff;
  box-shadow: 0 0 0 1px var(--yt-blue);
}

body.yt-page .type-option-icon,
body.yt-page .type-icon-rtc,
body.yt-page .type-icon-live {
  background: var(--yt-tonal);
  color: var(--yt-text);
}

body.yt-page .type-option-title {
  color: var(--yt-text);
}

body.yt-page .type-option-desc {
  color: var(--yt-text-2);
}

body.yt-page .required-mark {
  color: #cc0000;
}

body.yt-page .optional-mark {
  color: var(--yt-text-2);
}
