/* ==========================================================================
   基本変数とテーマ (デフォルト: ライト)
   ========================================================================== */
:root {
  --color-bg: #f9f9f9;
  --color-bg-light: #ffffff;
  --color-fg: #0f0f0f;
  --color-accent: #ff0000;
  --color-muted: #606060;
  --color-border: #e5e5e5;
  --color-card-bg: #ffffff;
  --color-hover: #f2f2f2;
  --color-bg-secondary: #eeeeee;

  /* ボタンのテキスト/背景 (テーマにより反転) */
  --btn-bg: #0f0f0f;
  --btn-fg: #ffffff;

  --sidebar-width: 240px;
  --sidebar-width-min: 72px;
  --header-height: 56px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

/* ダークモード上書き */
body.dark-mode {
  --color-bg: #0f0f0f;
  --color-bg-light: #272727;
  --color-fg: #f1f1f1;
  --color-accent: #ff0000;
  --color-muted: #aaaaaa;
  --color-border: #3f3f3f;
  --color-card-bg: #0f0f0f;
  --color-hover: #3e3e3e;
  --color-bg-secondary: #1f1f1f;

  --btn-bg: #ffffff;
  --btn-fg: #0f0f0f;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-fg);
  font-family: Roboto, Arial, sans-serif;
  overflow-x: hidden;
  box-sizing: border-box;
  /* Global box-sizing */
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* トグルスイッチ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: #4CAF50;
}

input:checked+.slider:before {
  transform: translateX(20px);
}

/* ナビゲーションアイコン (モノクロ) */
.nav-header .fas,
.nav-header .far,
.nav-header .fab,
.nav-header .fa-solid,
.nav-header .fa-regular,
.nav-header .fa-brands,
.sidebar .fas,
.sidebar .far,
.sidebar .fab,
.sidebar .fa-solid,
.sidebar .fa-regular,
.sidebar .fa-brands,
.chips-bar .fas,
.search-btn .fas {
  color: var(--color-fg);
}

/* Global Scroll Reset for App-like feel */
html,
body {
  height: 100%;
  overflow: hidden;
  /* Prevent body scroll */
}

/* サイドバーは、画面外からスライドインする形に */
/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--color-bg-light);
  border-right: 1px solid var(--color-border);
  transform: translateX(-100%);
  /* Default hidden on mobile? Check media queries */
  transition: transform 0.2s ease;
  z-index: 900;
  display: flex;
  flex-direction: column;
}

/* Desktop: Show sidebar by default */
@media (min-width: 1201px) {
  .sidebar {
    transform: none;
  }
}

/* Trash Icon Color Override */
.fa-trash,
.fa-trash-can {
  color: #ff6b6b !important;
}

/* プライマリ/アクセントボタン内のアイコンはコントラスト確保のため色を継承 (白/黒) */
.nav-btn-primary .fas,
.nav-btn-primary .far,
.nav-btn-primary .fab,
.btn-save-thumb .fas,
.btn-save-thumb .far,
.btn-save-thumb .fab,
.hybrid-btn.primary .fas,
.hybrid-btn.primary .far,
.hybrid-btn.primary .fab {
  color: inherit !important;
}

/* 編集ボタン (大) */
.btn-edit-large {
  padding: 10px 24px;
  font-size: 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-fg);
  transition: background 0.2s, transform 0.1s;
}

.btn-edit-large:hover {
  background: var(--color-hover);
  transform: scale(1.05);
}

/* ==========================================================================
   レイアウト構造
   ========================================================================== */
.app-layout {
  display: flex;
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
  /* Fixed height */
  overflow: hidden;
  /* Container non-scrollable */
  transition: margin-left 0.2s ease;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  box-sizing: border-box;
  transition: margin-left 0.2s ease;

  /* Flexbox for internal scrolling */
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  /* Allow vertical scrolling */
  overscroll-behavior-y: contain;
  /* Improve mobile feel */

  /* width: 100%; -> Removed to prevent overflow with margin-left */
  min-width: 0;
  /* Ensure constraints */
  /* サイドバーの開閉に合わせる */
}

/* サイドバーが閉じている(toggled)ときのメインコンテンツ調整 */
/* PCサイズ以上 (1201px~) */
@media (min-width: 1201px) {

  /* サイドバーにtoggledがつくと、非表示になるのでmargin-leftを0にする */
  body:has(.sidebar.toggled) .main-content {
    margin-left: 0;
  }
}

/* モバイルサイズ (1200px以下) */
@media (max-width: 1200px) {

  /* デフォルトで隠れているのでmargin-leftは0 */
  .main-content {
    margin-left: 0;
  }

  /* サイドバー表示時はオーバーレイまたはコンテンツを押し出すなら調整が必要だが */
  /* 今回の仕様では「表示時は狭くする」とのことだが、モバイルで狭くすると見づらいので */
  /* 重ねる(position:absolute)か、PC同様に押し出すか。 */
  /* ここでは、もしtoggled(モバイルでは表示状態)ならコンテンツを右にずらすか？ */
  /* 一般的にはモバイルはオーバーレイだが、要望に従い「表示領域を狭く」なら押し出し。 */
}

/* ==========================================================================
   ヘッダーとナビゲーション
   ========================================================================== */
.nav-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
  z-index: 10010;
  /* Boosted */
  border-bottom: 1px solid var(--color-border);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--color-fg);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
}

.menu-btn:hover {
  background-color: var(--color-hover);
}

.logo {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
  color: var(--color-fg);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.logo svg {
  width: 28px;
  height: 28px;
  margin-right: 4px;
}

/* 検索バー (自動テーマ) */
.nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 720px;
  margin: 0 10px;
  /* 隣接要素との接触を防ぐためのマージン */
}

/* Responsive adjustments - Force Icon Only for header actions to prevent overflow */
@media (max-width: 768px) {
  .nav-center {
    flex: 1;
    /* Keep search flexible */
  }

  .nav-right .user-info {
    display: none;
    /* Hide user name to save space */
  }

  .nav-text {
    display: none !important;
    /* Always hide text labels (Icon Only) */
  }

  .nav-btn-primary {
    padding: 0 10px;
  }
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  /* Prevent wrapping */
  flex-shrink: 0;
  /* Don't shrink right menu */
  height: 100%;
}

.nav-btn-primary,
.menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  /* Explicit height */
  line-height: normal;
  /* Reset line-height */
}

/* Ensure icons and text are centered vertically */
.nav-text {
  display: inline-block;
  vertical-align: middle;
}

@media (max-width: 600px) {

  /* 非常に小さい画面では一時的に検索を非表示にするか、折り畳み式にする */
  /* 今のところ、縮小してユーザー情報を完全に隠すことにします。 */
  .nav-center {
    display: none;
    /* 非常に小さい画面では一時的に検索を非表示にするか、折り畳み式にする */
  }

  /* あるいは、表示したままで小さくする */
}

.search-box {
  display: flex;
  align-items: center;
  width: 100%;
}

.search-box input {
  flex: 1;
  padding: 0 16px;
  font-size: 16px;
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: 40px 0 0 40px;
  outline: none;
  background-color: var(--color-bg);
  /* 適応型背景 */
  color: var(--color-fg);
  /* 適応型テキスト */
  height: 40px;
}

.search-box input:focus {
  border-color: #1c62b9;
}

.search-btn {
  background-color: var(--color-bg-light);
  /* 適応型ボタン背景 */
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 40px 40px 0;
  height: 40px;
  width: 64px;
  color: var(--color-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-btn:hover {
  background-color: var(--color-hover);
}

/* ヘッダー右側アクション */
.nav-right {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 225px;
  justify-content: flex-end;
}

.nav-right a {
  text-decoration: none;
  color: var(--color-fg);
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 500;
}

.nav-right a:hover {
  background-color: var(--color-hover);
}

/* 非公開アイコン（斜線付きの目）を表現するためのスタイル（index.phpで使用） */
.icon-eye-slash {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #fff;
  vertical-align: middle;
}

.icon-eye-slash::before {
  content: "👁️";
  font-size: 16px;
  filter: brightness(0) invert(1);
}

.icon-eye-slash::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: #fff;
  transform: rotate(-45deg);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

/* モーダル用ローディングスピナー */
.modal-loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: white;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* プライマリアクションボタン (アップロード等) */
.nav-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--btn-bg) !important;
  color: var(--btn-fg) !important;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  /* ピル型から角丸四角に変更 */
  font-weight: 500;
  margin-left: 8px;
  text-decoration: none;
  white-space: nowrap;
  /* 縦書き防止 */
}

.nav-btn-primary:hover {
  opacity: 0.9;
}

/* サイドバー */
.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  position: fixed;
  top: var(--header-height);
  left: 0;
  background: var(--color-bg);
  overflow-y: auto;
  transition: transform 0.2s ease;
  z-index: 10000;
  border-right: 1px solid var(--color-border);
}

.sidebar-inner {
  padding: 8px;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu li {
  margin-bottom: 2px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  padding: 0 8px;
  height: 32px;
  text-decoration: none;
  color: var(--color-fg);
  border-radius: 6px;
}

.sidebar-menu a:hover,
.sidebar-menu li.active a {
  background-color: var(--color-hover);
}

.sidebar-menu li.active a {
  font-weight: 500;
}

.sidebar-menu .icon {
  margin-right: 12px;
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 12px 0;
}

/* サイドバー切り替えロジック */
@media (min-width: 1201px) {
  .sidebar.toggled {
    transform: translateX(-100%);
  }
}

/* User Dropdown Menu */
.user-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 180px;
  display: none;
  z-index: 10011;
  /* Boosted to beat sidebar/toolbar */
  margin-top: 8px;
  padding: 4px 0;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--color-fg);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.1s;
}

.dropdown-item:hover {
  background: var(--color-hover);
}

.dropdown-divider {
  border-top: 1px solid var(--color-border);
  margin: 4px 0;
}

/* Dropdown Toggle Button Styling */
.dropdown-toggle {
  background: transparent !important;
  color: var(--color-fg) !important;
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  font-size: 14px;
}

.dropdown-toggle:hover,
.dropdown-toggle.active {
  background: var(--color-hover) !important;
  border-color: var(--color-border);
}

@media (max-width: 1200px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.toggled {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }
}

/* ==========================================================================
   YouTube風グリッド & アイテム
   ========================================================================== */
/* Grid Layout - レスポンシブ対応 */
.yt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding-bottom: 20px;
}

/* スマホ: 1列表示 (画面幅いっぱい) */
@media (max-width: 600px) {
  .yt-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* タブレット: 2列表示 (画面幅いっぱい) */
@media (min-width: 601px) and (max-width: 1024px) {
  .yt-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* PC: auto-fillによる最適列数 (280px基準) */
@media (min-width: 1025px) {
  .yt-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
  }
}

.yt-item {
  width: 100%;
  background: transparent;
  cursor: pointer;
  transition: transform 0.2s;
}

.yt-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  overflow: hidden;
  background-color: #000;
  margin-bottom: 12px;
}

.yt-thumb img,
.yt-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-icon-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-light);
  color: var(--color-muted);
  font-size: 48px;
}

.yt-info {
  display: flex;
  gap: 12px;
  padding-right: 24px;
}

/* タイトル & リンクのメンテナンス */
.yt-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-fg);
  /* 青色を削除 */
  margin-bottom: 4px;
  line-height: 1.4;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  text-decoration: none;
  /* 下線を削除 */
}

a.yt-link {
  text-decoration: none;
  color: inherit;
}

.yt-meta {
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.4;
}

/* 3点リーダーメニュー (適応色) */
.item-menu {
  color: var(--color-fg);
  /* ライトモードで黒、ダークモードで白 */
  cursor: pointer;
}

/* ==========================================================================
   ファイルリスト (テーブル表示)
   ==========================================================================*/
/* ファイルリストテーブルのスタイル */
.file-list-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.file-list-table th,
.file-list-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.file-list-table th {
  background-color: var(--color-bg-light);
  font-weight: 600;
}

.file-list-table tr:hover {
  background-color: var(--color-hover);
}

/* その他ファイルリストのリンクスタイル */
.file-list-table a {
  color: var(--color-fg);
  text-decoration: none;
}

.file-list-table a:hover {
  text-decoration: underline;
}

/* スターアイコンのスタイル */
.fav-star {
  color: var(--color-muted);
  font-size: 20px;
  transition: color 0.2s;
  cursor: pointer;
}

.fav-star.active {
  color: #ffd700;
}

/* ==========================================================================
   チップ / フィルター
   ========================================================================== */
.chips-bar {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 12px;
  margin-bottom: 24px;
  scrollbar-width: none;
}

.chip {
  background-color: var(--color-bg-light);
  color: var(--color-fg);
  border: 1px solid var(--color-border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s;
}

.chip:hover {
  background-color: var(--color-hover);
}

.chip.active {
  background-color: var(--color-fg);
  color: var(--color-bg);
}

/* ==========================================================================
   フォーム (ログイン / アップロード / 管理)
   ========================================================================== */
.upload-form {
  max-width: 500px;
  margin: 40px auto;
  background: var(--color-bg-light);
  /* 統一カードスタイル */
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
  /* ログイン用にコンテンツを中央揃え */
}

.upload-form h2 {
  margin-bottom: 24px;
  color: var(--color-fg);
}

.upload-form input[type="text"],
.upload-form input[type="password"] {
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background-color: var(--color-bg);
  color: var(--color-fg);
  box-sizing: border-box;
}

.upload-form button {
  width: 100%;
  padding: 12px;
  background-color: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
  border-radius: var(--radius-pill);
  font-weight: bold;
  cursor: pointer;
}

.upload-form button:hover {
  opacity: 0.9;
}

/* 管理者リンクのカスタマイズ */
.sidebar-menu a[href="admin.php"] {
  color: var(--color-fg);
  /* "ダークモードで明るく" は var(--color-fg) がダークモードで #f1f1f1 (既に明るい/可視) であることで処理されます */
  opacity: 0.8;
}

.sidebar-menu a[href="admin.php"]:hover {
  opacity: 1;
}

/* ==========================================================================
   モーダル (動画/画像)
   ========================================================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  /* 100vw causes scrollbars */
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.9);
  /* backdrop-filter: blur(5px);  <- レンダリング負荷が高いため削除 */
  /* Flexboxによる中央配置 (二重の保証) */
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 1200px;
  text-align: center;
}

.modal-video,
.modal-image {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
  image-rendering: -webkit-optimize-contrast;
  contain: paint;
}

/* フィルムストリップ (コマ送り) */
.film-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0;
  margin-top: 10px;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--color-muted) transparent;
}

.film-strip::-webkit-scrollbar {
  height: 6px;
}

.film-strip::-webkit-scrollbar-thumb {
  background-color: var(--color-muted);
  border-radius: 3px;
}

.film-strip-item {
  flex: 0 0 100px;
  height: 60px;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
  background: #000;
}

.film-strip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.film-strip-item:hover {
  transform: scale(1.05);
  border-color: var(--color-accent);
  z-index: 1;
}

.film-strip-item:hover img {
  opacity: 1;
}

/* 周辺フレーム (ファインシーク) */
.fine-strip {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-top: 10px;
}

.fine-strip-item {
  flex: 0 0 120px;
  height: 68px;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  border: 2px solid var(--color-border);
  transition: transform 0.2s, border-color 0.2s;
  background: #000;
}

.fine-strip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fine-strip-item:hover {
  transform: scale(1.1);
  border-color: var(--color-accent);
  z-index: 2;
}

.fine-strip-item.current {
  border-color: #ffd700;
  /* 現在位置を強調 */
  transform: scale(1.05);
}

.close {
  position: absolute;
  top: -50px;
  right: 0;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.5);
  width: 44px;
  height: 44px;
  line-height: 44px;
  text-align: center;
  border-radius: 50%;
  transition: transform 0.2s;
}

.close:hover {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.8);
}

/* Context Menu */
.context-menu {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  color: var(--color-fg);
}

.context-menu li:hover {
  background-color: var(--color-hover);
}

.progress-wrapper {
  max-width: 600px;
  margin: 0 auto 20px;
}

/* ============================= */
/* Custom Video Player           */
/* ============================= */
.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

/* ============================= */
/* サムネイル オーバーレイ (星・鍵・非公開) */
/* ============================= */
.yt-thumb-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
  z-index: 5;
}

.overlay-icon {
  width: 28px;
  height: 28px;
  background-color: rgba(60, 60, 60, 0.8);
  /* 半透明なグレー背景 */
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* お気に入りスター (右上へ) */
.yt-thumb .fav-star {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background-color: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s, background-color 0.2s;
  color: #fff;
  /* Default: white (not fav) */
  font-size: 18px;
  text-shadow: 0 0 2px #000;
}

.fav-star:hover {
  background-color: rgba(0, 0, 0, 0.7);
  transform: scale(1.1);
}

.fav-star.active {
  color: #ffd700;
  /* Gold */
}

/* パスワード入力フィールド (Masking Toggle) */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-wrapper input {
  flex: 1;
  padding-right: 40px;
  /* Space for eye icon */
}

.password-toggle-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  font-size: 18px;
}

/* Video Player Wrapper (for non-overlapping controls) */
.video-player-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: #000;
}

/* Overlay Controls (Always Overlay) */
.custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 40px 12px 0 12px;
  /* Bottom padding handled by row height */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Removing gap between progress and row */
  z-index: 20;

  /* Smoother Gradient for text readability */
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.3) 60%, transparent 100%);

  /* Usage: Hide by default, show on hover */
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Show controls on hover over video container */
.video-container:hover .custom-controls,
.video-container.paused .custom-controls,
.custom-controls:hover {
  opacity: 1;
}

/* Fullscreen special handling */
/* Fullscreen special handling */
.video-container:fullscreen .custom-controls,
.video-container:-webkit-full-screen .custom-controls,
.video-player-wrapper:fullscreen .custom-controls,
.video-player-wrapper:-webkit-full-screen .custom-controls {
  position: absolute !important;
  bottom: 0px;
  z-index: 2147483647;
  /* Max z-index for fullscreen */
}

/* Container for Seekbar */
/* Container for Seekbar */
.progress-container {
  width: 100%;
  height: 4px;
  /* Default slightly thicker */
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  position: relative;
  transition: height 0.1s linear;
  margin-bottom: 8px;
  /* Space between bar and buttons */
}

.progress-container:hover {
  height: 8px;
  /* Much thicker on hover for easier grabbing */
}

.progress-bar {
  height: 100%;
  background: #f00;
  /* YouTube Red */
  width: 0%;
  position: relative;
}

/* Progress Handle (The Red Dot) */
.progress-handle {
  width: 16px;
  height: 16px;
  background: #f00;
  border-radius: 50%;
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  /* Hidden by default */
  transition: transform 0.1s;
  pointer-events: none;
}

.progress-container:hover .progress-handle {
  transform: translateY(-50%) scale(1);
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  height: 48px;
  /* Consistency */
}

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
  /* Wider spacing */
}

/* 中央スキップボタンコンテナ（フルスクリーン時のみ） */
.controls-center {
  position: fixed;
  top: 45%;
  /* より上に配置 */
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  /* モバイルで表示 */
  align-items: center;
  gap: 40px;
  z-index: 25;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* タップ時に表示 */
.controls-center.show {
  opacity: 1;
}

.controls-center>* {
  pointer-events: auto;
  /* ボタン自体はクリック可能 */
}

/* モバイルのみ表示 */
.mobile-only {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .mobile-only {
    display: flex !important;
  }
}

/* スキップボタン */
.skip-btn {
  background: rgba(60, 60, 60, 0.6);
  /* より半透明に */
  border: none;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  padding: 0;
  width: 60px;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
  position: relative;
}

.skip-btn:hover {
  background: rgba(80, 80, 80, 0.9);
  transform: scale(1.1);
}

.skip-btn:active {
  transform: scale(0.95);
}

.skip-btn i {
  font-size: 20px;
  margin-bottom: 2px;
}

.skip-label {
  font-size: 11px;
  font-weight: bold;
  position: absolute;
  bottom: 12px;
}

/* 中央再生ボタン */
.play-center {
  width: 70px;
  height: 70px;
  background: rgba(60, 60, 60, 0.6);
  /* より半透明に */
  backdrop-filter: blur(10px);
}

.play-center i {
  font-size: 32px;
}

.ctrl-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
  width: 36px;
  /* Slightly larger targets */
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  /* Ripple effect constraint */
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  /* Subtle hover background */
}

.ctrl-btn svg {
  width: 28px;
  /* Standard icon size */
  height: 28px;
  fill: #fff;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
}

.time-display {
  font-size: 13px;
  font-family: "Roboto", Arial, sans-serif;
  font-weight: 500;
  margin-left: 4px;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.volume-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  transition: width 0.2s;
}




/* ==========================================================================
   Hybrid Video Modal Styles (Standard Player + Pro Tools)
   ========================================================================== */
.modal-video {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  margin: 0 auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  background: #000;
}

/* Hide the 3-dots menu in Chrome/Edge */
.modal-video::-webkit-media-controls-overflow-button {
  display: none !important;
}

.modal-video::-webkit-media-controls-enclosure {
  overflow: hidden;
}

.hybrid-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-top: 15px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  backdrop-filter: blur(5px);
}

.hybrid-btn-group {
  display: flex;
  gap: 5px;
  align-items: center;
}

.ul-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--color-bg-light) !important;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-fg) !important;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.ul-input:disabled {
  background: var(--color-bg) !important;
  color: var(--color-muted) !important;
  cursor: not-allowed;
  opacity: 0.6;
}

select.ul-input option {
  background-color: var(--color-bg-light);
  color: var(--color-fg);
}

.dark-mode select.ul-input option {
  background-color: var(--color-bg-light);
  color: var(--color-fg);
}

select.ul-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
  padding-right: 35px;
}

.dark-mode select.ul-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23aaa' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
}

.hybrid-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Consolidated under .active rule below */

.hybrid-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.hybrid-btn.active:hover {
  background: #008cff !important;
  /* Slightly brighter blue on hover */
}

.hybrid-btn:active {
  transform: translateY(1px);
}

.hybrid-btn.active,
.hybrid-btn.active:hover {
  background: #007bff !important;
  color: #fff !important;
  box-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
  border-color: #0056b3 !important;
  transform: translateY(-1px);
}

.hybrid-btn.primary {
  background: var(--color-accent);
  /* Orange/Red */
  border-color: var(--color-accent);
  font-weight: bold;
}

.hybrid-btn.primary:hover {
  filter: brightness(1.1);
}

.hybrid-info {
  color: #aaa;
  font-size: 12px;
  margin-left: 10px;
  font-family: monospace;
}

.shortcuts-help {
  margin-top: 8px;
  font-size: 11px;
  color: #666;
  text-align: center;
}

/* ==========================================================================
   Bulk Setting Toggle & Thumbnail Editor
   ========================================================================== */

/* Toggle Container */
.upload-tool-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.upload-tool-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out, padding 0.3s ease;
  opacity: 0;
  padding: 0 20px;
  /* Horizontal padding constant */
}

.upload-tool-content.open {
  max-height: 500px;
  /* Enough height */
  opacity: 1;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 5px;
}

/* Common Thumbnail Editor Component */
.thumb-editor-component-container {
  display: flex;
  flex-direction: column;
  height: 80vh;
  /* Adjust height for modal */
  max-height: 800px;
  width: 100%;
  gap: 0;
  overflow: hidden;
  background: #000;
  border-radius: 12px;
}

.thumb-editor-video-wrapper {
  flex: 1;
  background: #000;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  width: 100%;
  /* Ensure width in fullscreen */
}

.common-thumb-video {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

.thumb-editor-ui-controls {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--color-bg-light);
  border-top: 1px solid var(--color-border);
}

/* フルスクリーン時のスタイル */
.thumb-editor-component-container:fullscreen,
.thumb-editor-component-container:-webkit-full-screen {
  max-height: none;
  height: 100vh;
}

.thumb-editor-component-container:fullscreen .thumb-editor-video-wrapper,
.thumb-editor-component-container:-webkit-full-screen .thumb-editor-video-wrapper {
  flex: 1;
  width: 100vw;
  height: auto;
  min-height: 0;
}

.thumb-editor-component-container:fullscreen .common-thumb-video,
.thumb-editor-component-container:-webkit-full-screen .common-thumb-video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.thumb-editor-component-container:fullscreen .thumb-editor-ui-controls,
.thumb-editor-component-container:-webkit-full-screen .thumb-editor-ui-controls {
  flex-shrink: 0;
  position: relative;
}

/* 管理画面モーダル用フルスクリーン設定 */
#modal:fullscreen,
#modal:-webkit-full-screen {
  background: #000;
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
}

#modal:fullscreen .modal-content,
#modal:-webkit-full-screen .modal-content {
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

#modal:fullscreen #modal-body,
#modal:-webkit-full-screen #modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

#modal:fullscreen #modal-body>div,
#modal:-webkit-full-screen #modal-body>div {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#modal:fullscreen video.modal-video,
#modal:-webkit-full-screen video.modal-video {
  flex: 1;
  max-height: none !important;
  width: 100% !important;
  height: auto !important;
  object-fit: contain;
}

/* 閉じるボタンなどを隠す */
#modal:fullscreen .close,
#modal:-webkit-full-screen .close {
  display: none;
}


.thumb-seek-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.common-thumb-seek-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #444;
  outline: none;
  cursor: pointer;
}

.custom-check .label-text {
  font-size: 13px;
  color: var(--color-fg);
}

.common-thumb-time {
  font-size: 11px;
  color: #888;
  text-align: right;
  font-family: monospace;
}

.thumb-action-buttons {
  display: flex;
  gap: 10px;
}

.btn-thumb-back {
  flex: 1;
  background: #444;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-thumb-capture {
  flex: 2;
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Horizontal File Selection Area - Refined */
.file-select-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  /* Prevent overflow */
  gap: 15px;
  /* Spacing when wrapped */
  margin-bottom: 25px;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px 25px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.file-select-left {
  display: block;
  /* Vertical layout for buttons */
}

.file-select-label {
  font-weight: bold;
  font-size: 14px;
  color: var(--color-fg);
  /* Fixed: Match theme foreground */
}

.file-select-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* ==========================================================================
   Responsive Header Adjustments
   ========================================================================== */
@media (max-width: 600px) {
  .nav-header {
    padding: 0 8px;
  }

  .nav-left .logo span,
  .nav-left .logo {
    font-size: 16px;
  }

  .nav-center {
    display: none;
    /* Hide search bar on mobile to save space */
  }

  .nav-right {
    min-width: auto;
    gap: 5px;
  }

  .nav-right .user-info {
    display: none;
    /* Hide username on small screens */
  }

  .nav-btn-primary {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ==========================================================================
   Upload Tool Panel
   ========================================================================== */
.upload-tool-panel {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.upload-tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

/* Large Modal for Thumbnail Editor */
.modal-content-styled.large-modal {
  width: 95vw;
  max-width: 1200px;
  height: auto;
  min-height: 85vh;
  transition: all 0.3s ease;
  top: 50%;
  /* Ensure centering logic remains */
}

/* Upload Message Box */
#uploadMessageBox {
  margin-top: 20px;
  font-weight: bold;
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 8px;
  /* Dark mode visibility improvement */
  border: 1px solid var(--color-border);
  background-color: rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Sortable Table Headers */
.file-list-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.file-list-table th.sortable:hover {
  background-color: var(--color-hover);
}

.file-list-table th.sortable::after {
  content: '↕';
  font-size: 10px;
  color: var(--color-muted);
  margin-left: 5px;
  opacity: 0.5;
}

.file-list-table th.sortable.asc::after {
  content: '▲';
  opacity: 1;
  color: var(--color-accent);
}

.file-list-table th.sortable.desc::after {
  content: '▼';
  opacity: 1;
  color: var(--color-accent);
}

/* ==========================================================================
   Video Modal Styles (Integrated from video_modal.php)
   ========================================================================== */


.modal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 20px;
  z-index: 10001;
  transition: all 0.2s ease;
  user-select: none;
}

.modal-nav:hover {
  color: rgba(255, 255, 255, 0.9);
  transform: translateY(-50%) scale(1.1);
  background: transparent;
}

.modal-nav.prev {
  left: 20px;
}

.modal-nav.next {
  right: 20px;
}

/* Override modal-content for precise layout in video modal */
#modal .modal-content {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
}

#modal-body {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close {
  z-index: 10002;
  color: #fff;
  opacity: 0.5;
  top: 20px;
  right: 30px;
  font-size: 40px;
  font-weight: 300;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  position: absolute;
  /* Added position absolute to ensure it stays in corner */
}

.close:hover {
  opacity: 1;
}


/* ==========================================================================
   Upload Page Styles (Integrated from upload.php)
   ========================================================================== */
/* Custom Checkbox Style (Mini) */
.custom-check {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.custom-check input {
  display: none;
}

.custom-check .check-box {
  width: 18px;
  height: 18px;
  border: 2px solid #666;
  border-radius: 4px;
  margin-right: 8px;
  position: relative;
  transition: all 0.2s;
}

.custom-check input:checked+.check-box {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.custom-check input:checked+.check-box:after {
  content: '';
  position: absolute;
  top: 1px;
  left: 5px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.custom-check .label-text {
  font-size: 13px;
  color: var(--color-fg);
}

/* Page Drop Overlay */
#pageDropOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 123, 255, 0.2);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: none;
}

.drop-overlay-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  text-align: center;
}

/* ==========================================================================
   Video Player Progress Bar
   ========================================================================== */

/* Added from Refactoring (index.php styles) */

/* 統合ドロップダウンUI */
.toolbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.display-options-wrapper {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  width: 260px;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: none;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.dropdown-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.dropdown-section h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sort Items */
.dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  color: var(--color-fg);
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 2px;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item.active {
  background: rgba(var(--color-accent-rgb), 0.1);
  color: var(--color-accent);
  font-weight: bold;
}

.dropdown-item i.check-icon {
  color: var(--color-accent);
}

/* Filter Items */
.filter-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.1);
}

.checkbox-item {
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 8px;
}

.checkbox-item input[type="checkbox"] {
  transform: scale(1.1);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-apply {
  width: 100%;
  padding: 8px;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: opacity 0.2s;
}

.btn-apply:hover {
  opacity: 0.9;
}

/* Scrollbar for filter list */
.filter-list::-webkit-scrollbar {
  width: 6px;
}

.filter-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.filter-list::-webkit-scrollbar-track {
  background: transparent;
}

/* トースト通知 */
#toast-notification {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: rgba(30, 30, 30, 0.95);
  /* Deeper dark */
  color: #fff;
  text-align: center;
  border-radius: 50px;
  /* Pill shape for premium feel */
  padding: 12px 24px;
  position: fixed;
  z-index: 20000;
  left: 50%;
  bottom: 50px;
  /* Raised slightly */
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  /* Stronger shadow */
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  /* Glassmorphism */
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: translateY(20px);
}

#toast-notification.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

/*==========================================================================*/
.progress-container {
  width: 100%;
  height: 8px;
  /* Taller hit area default */
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  position: relative;
  border-radius: 4px;
  margin-bottom: 0px;
  /* Layout adj */
  transition: height 0.1s ease;
}

.progress-container:hover {
  height: 12px;
  /* Expand on hover */
}

.progress-bar {
  height: 100%;
  background: #ff0000;
  width: 0%;
  position: relative;
  border-radius: 4px;
}

.progress-handle {
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  /* Hidden by default */
  transition: transform 0.1s;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.progress-container:hover .progress-handle {
  transform: translateY(-50%) scale(1);
  /* Show on hover */
}

/* ==========================================================================
   Custom Volume Slider (YouTube-like)
   ========================================================================== */
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 0;
  /* Default hidden width (expanded on hover) */
  height: 4px;
  /* Track height */
  background: rgba(255, 255, 255, 0.2);
  /* Default unfilled track (overridden by JS gradient) */
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: width 0.2s ease, background 0.1s, opacity 0.2s;
  vertical-align: middle;
  opacity: 0;
  pointer-events: none;
}

/* Thumb Styling - WebKit */
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  margin-top: -4px;
  /* Adjust to center on 4px track */
}

/* Thumb Styling - Firefox */
.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Track Styling - WebKit */
.volume-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: transparent;
  /* Main background handled by inline style in JS */
  border-radius: 2px;
}

/* Track Styling - Firefox */
.volume-slider::-moz-range-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: transparent;
  border-radius: 2px;
}

/* Hover State - Expand on hover */
.volume-container:hover .volume-slider {
  width: 80px;
  /* Expanded width */
  margin-left: 10px;
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Speed Settings Menu (Scrollable + Sticky Slider)
   ========================================================================== */
#speedMenu.settings-menu {
  display: none;
  /* Toggled via JS */
  position: absolute;
  bottom: 50px;
  /* Adjusted to be above the cog button */
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 4px;
  width: 140px;
  z-index: 20;
  overflow: hidden;
  /* Container hides overflow */
  flex-direction: column;
  /* Normal direction, JS logic reverses list if needed or HTML structure handles it */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  padding-bottom: 0;
  /* Sticky container handles bottom padding */
}

/* Scrollable Area for Options */
#speedMenu .speed-opt-container {
  max-height: 160px;
  /* ~4 items (40px each) */
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  /* High speed at top logic */
  scrollbar-width: thin;
  scrollbar-color: #666 transparent;
}

/* Quality Menu Specifics (Share styles with speedMenu) */
#qualityMenu.settings-menu {
  display: none;
  /* Hidden by default */
  position: absolute;
  bottom: 50px;
  /* Open upwards */
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 4px;
  width: 140px;
  z-index: 20;
  overflow: hidden;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  padding-bottom: 0;
}

/* Quality List Container */
#qualityList {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  /* Normal order */
  scrollbar-width: thin;
  scrollbar-color: #666 transparent;
}

#speedMenu .speed-opt-container::-webkit-scrollbar {
  width: 4px;
}

#speedMenu .speed-opt-container::-webkit-scrollbar-track {
  background: transparent;
}

#speedMenu .speed-opt-container::-webkit-scrollbar-thumb {
  background-color: #666;
  border-radius: 2px;
}

/* Speed Option Item */
.speed-opt {
  padding: 10px 15px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: background 0.2s;
  flex-shrink: 0;
  /* Prevent shrinking */
}

.speed-opt:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Sticky Speed Range Container */
.speed-range-container {
  position: sticky;
  bottom: 0;
  background: #1a1a1a;
  /* Distinct background */
  padding: 10px;
  border-top: 1px solid #333;
  z-index: 21;
}

.speed-range-val {
  color: #fff;
  font-size: 11px;
  font-weight: bold;
}

/* Added from Refactoring (index.php styles) */

/* 統合ドロップダウンUI */
.toolbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.display-options-wrapper {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 8px;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  width: 260px;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: none;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.dropdown-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.dropdown-section h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sort Items */
.dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  color: var(--color-fg);
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 2px;
  cursor: pointer;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dropdown-item.active {
  background: rgba(var(--color-accent-rgb), 0.1);
  color: var(--color-accent);
  font-weight: bold;
}

.dropdown-item i.check-icon {
  color: var(--color-accent);
}

/* Filter Items */
.filter-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.1);
}

.checkbox-item {
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 8px;
}

.checkbox-item input[type='checkbox'] {
  transform: scale(1.1);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-apply {
  width: 100%;
  padding: 8px;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: opacity 0.2s;
}

.btn-apply:hover {
  opacity: 0.9;
}

/* Scrollbar for filter list */
.filter-list::-webkit-scrollbar {
  width: 6px;
}

.filter-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.filter-list::-webkit-scrollbar-track {
  background: transparent;
}

/* トースト通知 */
#toast-notification {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: rgba(30, 30, 30, 0.95);
  /* Deeper dark */
  color: #fff;
  text-align: center;
  border-radius: 50px;
  /* Pill shape for premium feel */
  padding: 12px 24px;
  position: fixed;
  z-index: 20000;
  left: 50%;
  bottom: 50px;
  /* Raised slightly */
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  /* Stronger shadow */
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  /* Glassmorphism */
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: translateY(20px);
}

#toast-notification.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}


/* Fix for Modal Z-Index (Roadmap 7-1) */
.modal,
.modal-backdrop {
  z-index: 20000 !important;
}

/* Slide-over Panel (Added Properly) */
.slide-panel {
  position: fixed;
  top: 0;
  right: -100%;
  /* Hidden off-screen */
  width: 90%;
  max-width: 1000px;
  /* Or 100% for mobile, limited for desktop */
  height: 100%;
  background: var(--color-bg);
  z-index: 2000;
  transition: right 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  box-shadow: -4px 0 15px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.slide-panel.open {
  right: 0;
}

.slide-panel-header {
  padding: 15px 20px;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}

.slide-panel-back-btn {
  background: none;
  border: none;
  color: var(--color-fg);
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.slide-panel-back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.slide-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Admin List Header - Standardized */
.list-header {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.list-header h2 {
  margin: 0;
  font-size: 1.5em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.list-header h3 {
  margin: 0;
  font-size: 1.3em;
}

/* ==========================================================================
   Modal Loading & Unlock Styles
   ========================================================================== */
.modal-loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  gap: 15px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top: 5px solid var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.modal-unlock-input:focus {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 5px var(--color-accent);
}

/* ==========================================================================
   ページネーション (Stylish)
   ========================================================================== */
.pagination-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 40px;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--color-bg-light);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

@media (min-width: 768px) {
  .pagination-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .pagination-nav {
    order: 2;
    /* 中央に配置したい場合は調整、今回は右寄せまたは中央 */
    flex: 1;
    display: flex;
    justify-content: center;
  }

  .pagination-limit {
    order: 1;
  }

  .pagination-info {
    order: 3;
  }
}

.pagination-limit {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-muted);
}

.limit-select {
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-fg);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.limit-select:hover,
.limit-select:focus {
  border-color: var(--color-accent);
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-link,
.nav-btn-primary,
.nav-btn-disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-width: 36px;
  padding: 0 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

/* ページ番号リンク */
.page-link {
  background: transparent;
  color: var(--color-fg);
  border: 1px solid transparent;
}

.page-link:hover {
  background: var(--color-hover);
  color: var(--color-accent);
}

.page-link.active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--color-accent-rgb), 0.4);
  /* アクセントカラーの影を擬似的に */
}

/* 省略リーダー */
.pagination-ellipsis {
  color: var(--color-muted);
  padding: 0 4px;
}

/* 前へ/次へ ボタン (nav-btn-primaryの上書き含む) */
.pagination-nav .nav-btn-primary {
  background: var(--color-bg);
  color: var(--color-fg);
  border: 1px solid var(--color-border);
  margin: 0;
  /* リセット */
}

.pagination-nav .nav-btn-primary:hover {
  background: var(--color-hover);
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

.nav-btn-disabled {
  background: var(--color-bg-light);
  color: var(--color-muted);
  border: 1px solid transparent;
  cursor: not-allowed;
  opacity: 0.6;
}

.pagination-info {
  font-size: 13px;
  color: var(--color-muted);
  white-space: nowrap;
}


/* Kebab Menu (3-dot) */
.kebab-container {
  position: relative;
  display: inline-block;
}

.kebab-btn {
  background: none;
  border: none;
  color: var(--color-fg);
  font-size: 20px;
  cursor: pointer;
  padding: 0 10px;
  line-height: 1;
}

.kebab-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 100;
  min-width: 120px;
}

.kebab-dropdown.show {
  display: block;
}

.kebab-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: none;
  border: none;
  color: var(--color-fg);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}

.kebab-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.kebab-item.delete {
  color: #ff5252;
}


/* D&D Overlay */
#pageDropOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20000;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#pageDropOverlay.active {
  display: flex !important;
}

.drop-overlay-content {
  pointer-events: none;
  text-align: center;
  color: white;
  font-size: 24px;
  font-weight: bold;
}

#pageDropOverlay i {
  margin-bottom: 20px;
  display: block;
  font-size: 48px;
}

/* FIX: Ensure Toasts are above Modals (z-index 2000) */
.toastify {
  z-index: 2147483647 !important;
}

#toast-notification,
#globalToast {
  z-index: 2147483647 !important;
}

/* Fullscreen video sizing fix */
/* Fullscreen video sizing fix */
.video-player-wrapper:fullscreen #main-video,
.video-player-wrapper:fullscreen video,
.video-player-wrapper:-webkit-full-screen #main-video,
.video-player-wrapper:-moz-full-screen #main-video,
.video-player-wrapper:-ms-fullscreen #main-video,
video:fullscreen,
video:-webkit-full-screen {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
}

/* ==========================================================================
   List Page / Excel-like Table Styles (Re-applied)
   ========================================================================== */
.breadcrumbs {
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--color-bg-light);
  border-radius: 8px;
  font-size: 14px;
}

.breadcrumbs .crumb-item {
  cursor: pointer;
  color: var(--color-accent);
}

.breadcrumbs .crumb-item:hover {
  text-decoration: underline;
}

.breadcrumbs .crumb-item.active {
  color: var(--color-fg);
  font-weight: bold;
  cursor: default;
  text-decoration: none;
}

.breadcrumbs .crumb-sep {
  color: var(--color-muted);
  margin: 0 8px;
}

.table-container {
  overflow-x: auto;
  background: var(--color-card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.excel-table th,
.excel-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

.excel-table th:last-child,
.excel-table td:last-child {
  border-right: none;
}

.excel-table th {
  background-color: var(--color-bg-secondary);
  color: var(--color-fg);
  font-weight: 600;
  text-align: left;
  position: relative;
  user-select: none;
}

.th-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.th-content:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.sort-icon::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
}

.sort-asc .sort-icon::after {
  content: '▲';
  font-size: 10px;
}

.sort-desc .sort-icon::after {
  content: '▼';
  font-size: 10px;
}

.filter-btn {
  opacity: 0.3;
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--color-fg);
}

.filter-btn:hover,
.filter-active .filter-btn {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.1);
}

/* Filter Dropdown */
.filter-dropdown {
  position: absolute;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  width: 200px;
  z-index: 1000;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-search input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-fg);
  box-sizing: border-box;
}

.filter-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-fg);
}

.filter-item {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
}

.filter-item:hover {
  background: var(--color-hover);
}

.filter-item input {
  margin-right: 8px;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-micro {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-light);
  color: var(--color-fg);
  cursor: pointer;
}

.btn-micro.primary {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
}

/* Rows */
.file-name-link {
  color: var(--color-fg);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name-link:hover {
  text-decoration: underline;
  color: var(--color-accent);
}

.file-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.fa-folder {
  color: #fdd835;
}

.fa-image {
  color: #4caf50;
}

.fa-video {
  color: #f44336;
}

.fa-file-audio {
  color: #ff9800;
}


/* ==========================================================================
   List Page / Excel-like Table Styles (Re-applied)
   ========================================================================== */
.breadcrumbs {
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--color-bg-light);
  border-radius: 8px;
  font-size: 14px;
}

.crumb-item {
  cursor: pointer;
  color: var(--color-accent);
}

.crumb-item:hover {
  text-decoration: underline;
}

.crumb-item.active {
  color: var(--color-fg);
  font-weight: bold;
  cursor: default;
  text-decoration: none;
}

.crumb-sep {
  color: var(--color-muted);
  margin: 0 8px;
}

.table-container {
  overflow-x: auto;
  background: var(--color-card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.excel-table th,
.excel-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

.excel-table th:last-child,
.excel-table td:last-child {
  border-right: none;
}

.excel-table th {
  background-color: var(--color-bg-secondary);
  color: var(--color-fg);
  font-weight: 600;
  text-align: left;
  position: relative;
  user-select: none;
}

.th-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.th-content:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.sort-icon::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
}

.sort-asc .sort-icon::after {
  content: '▲';
  font-size: 10px;
}

.sort-desc .sort-icon::after {
  content: '▼';
  font-size: 10px;
}

.filter-btn {
  opacity: 0.3;
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--color-fg);
}

.filter-btn:hover,
.filter-active .filter-btn {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.1);
}

/* Filter Dropdown */
.filter-dropdown {
  position: absolute;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  width: 200px;
  z-index: 1000;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-search input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-fg);
  box-sizing: border-box;
}

.filter-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-fg);
}

.filter-item {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
}

.filter-item:hover {
  background: var(--color-hover);
}

.filter-item input {
  margin-right: 8px;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-micro {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-light);
  color: var(--color-fg);
  cursor: pointer;
}

.btn-micro.primary {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
}

/* Rows */
.file-name-link {
  color: var(--color-fg);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name-link:hover {
  text-decoration: underline;
  color: var(--color-accent);
}

.file-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.fa-folder {
  color: #fdd835;
}

.fa-image {
  color: #4caf50;
}

.fa-video {
  color: #f44336;
}

.fa-file-audio {
  color: #ff9800;
}

/* Table Container for horizontal scrolling */
/* Table Container for horizontal scrolling */
/* Table Container for horizontal AND vertical scrolling */
.table-container {
  display: block;
  /* Works as flex item */
  flex: 1;
  /* Grow to fill space */
  width: 100% !important;
  /* Ensure width constraints */
  overflow: auto !important;
  /* X and Y scroll */
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
  background: var(--color-bg);
  min-height: 0;
  /* Critical for nested flex scrolling */
}

.excel-table {
  width: 100% !important;
  min-width: 800px !important;
  border-collapse: collapse;
}

.excel-table th,
.excel-table td {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}