/* ============================================================
   style.css — DrivePlayer ダークテーマ / モバイルファースト
   ============================================================ */

/* ── CSS 変数 ─────────────────────────────────────────────── */
:root {
  --bg:            #0d0d0d;
  --surface:       #1a1a1a;
  --surface2:      #242424;
  --border:        #333333;
  --primary:       #4285f4;
  --primary-dim:   #1a3a7a;
  --accent:        #ff6b35;
  --danger:        #ea4335;
  --text:          #ffffff;
  --text-dim:      #b0b0b0;
  --text-muted:    #666666;
  --nav-height:    60px;
  --header-height: 52px;
  --radius:        10px;
  --radius-sm:     6px;
  --transition:    0.2s ease;
  --sub-panel-w:   260px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input[type=range] { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ── アプリ全体 ──────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ── ビュー ──────────────────────────────────────────────────── */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  height: calc(100dvh - var(--nav-height));
}
.view.active { display: flex; }

/* ── ヘッダー ─────────────────────────────────────────────────── */
.view-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.view-header h2 { font-size: 17px; font-weight: 600; }

/* ── ボタン共通 ──────────────────────────────────────────────── */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition);
}
.btn-icon:active { background: rgba(255,255,255,0.12); }
.btn-icon svg { width: 22px; height: 22px; fill: currentColor; }

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-primary:active { opacity: 0.8; transform: scale(0.97); }

.btn-small {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 13px;
  border: 1px solid var(--border);
}
.btn-small:active { opacity: 0.7; }

/* ── ログイン画面 ─────────────────────────────────────────────── */
#view-login {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  height: 100dvh;
}
.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: var(--surface2);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo svg { width: 48px; height: 48px; fill: var(--primary); }
#view-login h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
#view-login .subtitle { color: var(--text-dim); margin-bottom: 48px; font-size: 15px; }
.btn-google {
  background: #fff;
  color: #333;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.btn-google svg { width: 20px; height: 20px; }
.login-note { margin-top: 16px; color: var(--text-muted); font-size: 12px; }

/* ── ドライブブラウザ ─────────────────────────────────────────── */
.breadcrumb {
  flex: 1;
  font-size: 14px;
  color: var(--text-dim);
  overflow-x: auto;
  white-space: nowrap;
  text-overflow: clip;
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE */
}
.breadcrumb::-webkit-scrollbar { display: none; }

/* タップ可能なパンくず */
.bc-link {
  color: var(--accent, #5b8dee);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 4px 2px;
  -webkit-tap-highlight-color: transparent;
}
.bc-link:active { opacity: 0.65; }
.bc-current {
  color: var(--text-primary, #e0e0e0);
  font-weight: 500;
  padding: 4px 2px;
}
.bc-sep {
  color: var(--text-muted, #666);
  user-select: none;
}
.search-bar {
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-bar input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus { border-color: var(--primary); }

.file-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.file-item:active { background: var(--surface2); }
.file-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-icon.folder { background: #2a3a5c; }
.file-icon.video  { background: #2a3a2a; }
.file-icon.audio  { background: #3a2a4c; }
.file-icon svg    { width: 22px; height: 22px; }
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.file-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.file-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.btn-fav {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  transition: color var(--transition);
}
.btn-fav.active { color: #ffcc00; }
.btn-fav svg { width: 20px; height: 20px; }

/* タグボタン (ファイルアクション内) */
.btn-tag {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  transition: color var(--transition);
  flex-shrink: 0;
}
.btn-tag svg { width: 18px; height: 18px; fill: currentColor; }
.btn-tag.has-tags { color: var(--primary); }
.btn-tag:active { background: rgba(255,255,255,0.1); }

/* タグバッジ (ファイル名下のインライン表示) */
.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}
.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(66,133,244,0.15);
  border: 1px solid rgba(66,133,244,0.35);
  color: #82aef8;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.folder-play-bar {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-play-folder {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-play-folder svg { width: 18px; height: 18px; }

/* 一括タグ付けボタン (フォルダプレイバー内) */
.btn-bulk-tag {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-bulk-tag svg { width: 16px; height: 16px; fill: currentColor; }
.btn-bulk-tag:active { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }

/* 空・ローディング・エラー */
.state-empty, .state-loading, .state-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
  color: var(--text-muted);
}
.state-error { color: var(--danger); }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── プレイヤービュー ─────────────────────────────────────────── */
#view-player {
  background: #000;
  overflow: hidden;
}

/* プレイヤーとサブパネルのラッパー */
#player-wrapper {
  display: flex;
  flex: 1;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
}

/* 縦画面: プレイヤー上 / サブパネル下 */
@media (orientation: portrait) {
  #player-wrapper { flex-direction: column; }
  .sub-panel {
    width: 100% !important;
    max-height: 40vh;
    border-top: 1px solid var(--border);
    border-left: none !important;
  }
  .sub-panel--closed { max-height: 0 !important; }
}

.player-container {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: #000;
  overflow: hidden;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  /* iOS Safari: prevent native video controls from intercepting taps on overlay */
  pointer-events: none;
}

/* ── サブパネル ──────────────────────────────────────────────── */
.sub-panel {
  width: var(--sub-panel-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.25s ease, max-height 0.25s ease;
  flex-shrink: 0;
}
.sub-panel--closed {
  width: 0;
  border-left: none;
}
.sub-panel-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  padding: 0 0 0 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  min-width: 0;
}
.sub-panel-header > span { flex: 1; overflow: hidden; text-overflow: ellipsis; padding: 8px 6px 8px 12px; }
.sub-panel-header .btn-icon { width: 34px; height: auto; flex-shrink: 0; align-self: center; }
.sub-panel-header .btn-icon svg { width: 16px; height: 16px; }

/* ── サブパネル タブ ──────────────────────────────────────── */
.sp-tabs {
  flex: 1;
  display: flex;
  min-width: 0;
}
.sp-tab {
  flex: 1;
  padding: 9px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.sp-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.sp-tab:active { opacity: 0.65; }

/* ── サブパネル フォルダブラウザ ─────────────────────────── */
.sp-folder-browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sp-folder-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px 5px 4px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sp-folder-nav .btn-icon { width: 26px; height: 26px; flex-shrink: 0; }
.sp-folder-nav .btn-icon svg { width: 15px; height: 15px; }
.sp-breadcrumb {
  flex: 1;
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sp-folder-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sp-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
}
.sp-item:active { background: var(--surface2); }
.sp-item--folder { color: var(--text-dim); }
.sp-item-icon { flex-shrink: 0; display: flex; align-items: center; color: var(--text-muted); }
.sp-item--folder .sp-item-icon { color: #5b8dee; }
.sp-item-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sp-item-dur { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.sp-state { padding: 16px; text-align: center; color: var(--text-muted); font-size: 12px; }
.sub-panel-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* サブパネル内アイテム */
.sub-panel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
}
.sub-panel-item:active { background: var(--surface2); }
.sub-panel-item.active {
  background: var(--primary-dim);
  border-left: 3px solid var(--primary);
}
.sub-panel-item-num {
  width: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sub-panel-item.active .sub-panel-item-num { color: var(--primary); }
.sub-panel-item-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sub-panel-item-dur {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── プレイヤーオーバーレイ ─────────────────────────────────────── */
.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.player-overlay.visible { pointer-events: all; }
.player-overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
  pointer-events: all;
}
.overlay-top .now-playing-title {
  flex: 1;
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 4px;
}
.btn-overlay {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  /* iOS Safari: ボタンのクリック遅延を解消 */
  touch-action: manipulation;
}
.btn-overlay:active { background: rgba(255,255,255,0.15); }

.gesture-zone {
  flex: 1;
  pointer-events: all;
}

.overlay-bottom {
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  padding: 8px 8px 12px;
  pointer-events: all;
}

/* プログレスバー */
.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.time-current, .time-total {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 38px;
}
.time-total { text-align: right; }

input[type=range].progress-bar {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.3);
  outline: none;
  position: relative;
  /* iOS: スライダー操作中にスクロールが干渉しないようにする */
  touch-action: none;
}
input[type=range].progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

/* コントロール行 */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}
.controls-row .btn-icon { width: 44px; height: 44px; }
.btn-play-main {
  width: 56px !important;
  height: 56px !important;
  background: rgba(255,255,255,0.15);
  border-radius: 50% !important;
}
.btn-play-main svg { width: 28px; height: 28px; }
.btn-skip-label {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.controls-row-2 {
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-speed {
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
input[type=range].volume-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.3);
  outline: none;
  touch-action: none; /* iOS: スライダー干渉防止 */
}
input[type=range].volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
}

/* ── ジェスチャーフィードバック ──────────────────────────────── */
.gesture-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}
.gesture-feedback.show { opacity: 1; }

/* ── 速度ポップアップ ─────────────────────────────────────────── */
.speed-popup {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 100;
  min-width: 120px;
}
.speed-popup-inner {
  display: flex;
  flex-direction: column;
}
.speed-btn {
  padding: 11px 20px;
  text-align: center;
  font-size: 15px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.speed-btn:last-child { border-bottom: none; }
.speed-btn:active { background: var(--surface2); }
.speed-btn.active { color: var(--primary); font-weight: 700; }

/* ── プレイリストパネル (フルスクリーン時フローティング) ──────── */
.playlist-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-height: 55%;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-radius: var(--radius) var(--radius) 0 0;
}
.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.playlist-items {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.playlist-item:active { background: var(--surface2); }
.playlist-item.active {
  background: var(--primary-dim);
  border-left: 3px solid var(--primary);
}
.playlist-item-num {
  width: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.playlist-item.active .playlist-item-num { color: var(--primary); }
.playlist-item-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.playlist-item-dur {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── 自動次動画 ──────────────────────────────────────────────── */
.auto-next {
  position: absolute;
  bottom: 90px;
  right: 16px;
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-width: 280px;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.auto-next-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.auto-next-countdown {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.auto-next-countdown span { color: var(--primary); }
.auto-next-actions { display: flex; gap: 8px; }
.auto-next-actions button {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
#btn-auto-next-cancel { background: var(--surface2); border: 1px solid var(--border); }
#btn-auto-next-now    { background: var(--primary); color: #fff; }

/* ── 設定画面 ─────────────────────────────────────────────────── */
.settings-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
}
.settings-section { margin-top: 24px; }
.settings-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 16px 6px;
  border-bottom: 1px solid var(--border);
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  gap: 12px;
}
.settings-item select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 4px 8px;
  font-size: 14px;
}

/* トグルスイッチ */
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border-radius: 26px;
  transition: background var(--transition);
  border: 1px solid var(--border);
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before {
  transform: translate(20px, -50%);
  background: #fff;
}

/* ── ボトムナビ ──────────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 1 0 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
  padding: 6px 0;
  transition: color var(--transition);
}
.nav-btn svg { width: 22px; height: 22px; fill: currentColor; }
.nav-btn.active { color: var(--primary); }
.nav-btn:active { opacity: 0.7; }

/* 7ボタン時のコンパクト表示 */
.bottom-nav:has(.nav-btn:nth-child(7)) .nav-btn {
  flex: 1 0 40px;
}
.bottom-nav:has(.nav-btn:nth-child(7)) .nav-btn span {
  font-size: 9px;
}
.bottom-nav:has(.nav-btn:nth-child(7)) .nav-btn svg {
  width: 20px; height: 20px;
}

/* ── ダウンロードボタン ──────────────────────────────────────────── */
.btn-dl {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
  flex-shrink: 0;
}
.btn-dl:hover   { color: var(--accent); }
.btn-dl.downloaded  { color: #4ade80; }
.btn-dl.downloading {
  color: #fb923c;
  animation: dl-pulse 0.9s ease-in-out infinite alternate;
}
@keyframes dl-pulse {
  from { opacity: 1; }
  to   { opacity: 0.35; }
}

/* ── ストレージ使用量バー ─────────────────────────────────────────── */
.storage-bar-wrap { width: 100%; margin: 2px 0 4px; }
.storage-bar {
  height: 10px;
  background: var(--surface2, #2a2a3a);
  border-radius: 5px;
  overflow: hidden;
  display: flex;
  position: relative;
}
.storage-bar-video {
  height: 100%;
  background: #8b5cf6;
  transition: width 0.4s;
  border-radius: 5px 0 0 5px;
}
.storage-bar-other {
  height: 100%;
  background: #4a4a5c;
  transition: width 0.4s;
}
.storage-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ── オフラインファイル一覧 ──────────────────────────────────────── */
.offline-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
}
.offline-file-item:last-child { border-bottom: none; }
.offline-file-info    { flex: 1; min-width: 0; }
.offline-file-name    {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.offline-file-meta    { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.offline-file-delete  {
  flex-shrink: 0;
  background: rgba(248,113,113,0.12);
  color: #f87171;
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.offline-file-delete:hover { background: rgba(248,113,113,0.28); }

/* ── iOS ホーム画面追加ガイドカード ─────────────────────────────── */
.ios-guide-card {
  margin-top: 14px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.ios-guide-title {
  font-size: 13px;
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 8px;
}
.ios-guide-body {
  font-size: 12px;
  color: var(--text-dim, #aaa);
  line-height: 1.6;
}
.ios-guide-body p { margin: 0 0 8px; }
.ios-guide-steps {
  padding-left: 18px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ios-guide-steps li { font-size: 12px; }
.ios-share-icon {
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0px 3px;
  font-size: 11px;
  margin: 0 2px;
  line-height: 1.4;
}

/* ── トースト通知 ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── フルスクリーン時 ─────────────────────────────────────────── */
:fullscreen #view-player,
:-webkit-full-screen #view-player { height: 100vh; }
:fullscreen .bottom-nav,
:-webkit-full-screen .bottom-nav { display: none !important; }

/* ── スクロールバー ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── ビューモード切替ボタン ─────────────────────────────── */
.view-mode-toggle {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 2px;
  flex-shrink: 0;
}
.view-mode-btn {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.view-mode-btn svg { width: 16px; height: 16px; fill: currentColor; }
.view-mode-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.view-mode-btn.active { background: var(--primary); color: #fff; }

/* ── ソートバー ─────────────────────────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.sort-bar::-webkit-scrollbar { display: none; }
.sort-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sort-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── サムネイルグリッド ─────────────────────────────────── */
.file-list--thumb {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.thumb-item {
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface2);
  transition: transform 0.15s, opacity 0.15s;
}
.thumb-item:active { transform: scale(0.95); opacity: 0.8; }
.thumb-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  position: relative;
  overflow: hidden;
}
.thumb-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
}
.thumb-placeholder svg { width: 38%; height: 38%; opacity: 0.5; }
.thumb-duration {
  position: absolute;
  bottom: 4px; right: 5px;
  background: rgba(0,0,0,0.78);
  color: #fff;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
}
.thumb-fav {
  position: absolute;
  top: 3px; right: 3px;
  width: 26px; height: 26px;
  padding: 4px;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  border: none;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.thumb-item:hover .thumb-fav,
.thumb-fav.active { opacity: 1; }
.thumb-fav svg { width: 16px; height: 16px; fill: currentColor; }
.thumb-name {
  font-size: 12px;
  padding: 5px 7px 7px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* ── 詳細表示 ──────────────────────────────────────────── */
.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.detail-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── 音量ブーストボタン ─────────────────────────────────── */
.btn-boost {
  min-width: 32px;
  font-size: 11px;
  padding: 4px 6px;
  transition: background var(--transition), color var(--transition);
}
.btn-boost.active {
  color: #ff6b35;
  border-color: rgba(255,107,53,0.5);
}

/* ── モーダルオーバーレイ (汎用) ───────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 20px 32px;
  border-top: 1px solid var(--border);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-sheet-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.modal-sheet-header span { flex: 1; }

/* ── お気に入りビュー共通 ─────────────────────────────────── */
/* fav-folders-list / fav-files-list は .file-list を再利用 */
/* drag-sortable アイテム */
.fav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.fav-item:active { background: var(--surface2); }
.fav-item.drag-over-top    { border-top: 2px solid var(--primary); }
.fav-item.drag-over-bottom { border-bottom: 2px solid var(--primary); }
.fav-item.dragging { opacity: 0.35; }

.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  color: var(--text-muted);
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 18px; height: 18px; fill: currentColor; }

.fav-item-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fav-item-icon.folder { background: #2a3a5c; }
.fav-item-icon.video  { background: #2a3a2a; }
.fav-item-icon.audio  { background: #3a2a4c; }
.fav-item-icon svg { width: 20px; height: 20px; }

.fav-item-info { flex: 1; min-width: 0; }
.fav-item-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fav-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.fav-item-remove {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  flex-shrink: 0;
}
.fav-item-remove:active { background: rgba(255,255,255,0.12); color: var(--danger); }
.fav-item-remove svg { width: 18px; height: 18px; fill: currentColor; }

/* ── お気に入りタブ (動画 / 音楽) ──────────────────────────── */
.fav-tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.fav-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.fav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.fav-tab:active { opacity: 0.65; }

/* ── タグエディタモーダル ──────────────────────────────────── */
.tag-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  margin-bottom: 14px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  border-radius: 14px;
  background: var(--primary-dim);
  border: 1px solid rgba(66,133,244,0.5);
  color: var(--text);
  font-size: 13px;
}
.tag-chip__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
}
.tag-chip__remove:hover { background: rgba(255,255,255,0.3); }

.tag-no-tags {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  align-self: center;
}

.tag-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.tag-text-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  user-select: text;
}
.tag-text-input:focus { border-color: var(--primary); }
.tag-text-input::placeholder { color: var(--text-muted); }

/* 既存タグのサジェスト (タグ編集モーダル下部) */
.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.tag-suggest-btn {
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tag-suggest-btn:active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── タグビュー ────────────────────────────────────────────── */
/* タグ一覧 */
.tag-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.tag-list-item:active { background: var(--surface2); }

.tag-list-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tag-list-icon svg { width: 20px; height: 20px; fill: var(--primary); }

.tag-list-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tag-count-badge {
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* タグ絞り込みビューのサブヘッダー */
.tag-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--primary-dim);
  border-bottom: 1px solid rgba(66,133,244,0.4);
  font-size: 13px;
  flex-shrink: 0;
}
.tag-filter-bar-name {
  flex: 1;
  font-weight: 600;
  color: #82aef8;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tag-filter-bar-count {
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
}

/* ── メディアクエリ (タブレット/PC) ─────────────────────────── */
@media (min-width: 600px) {
  .file-list    { max-width: 700px; margin: 0 auto; width: 100%; }
  .bottom-nav   { max-width: 700px; margin: 0 auto; width: 100%; }
  .modal-sheet  { margin-bottom: 0; }
}

/* ── iOS CSS 疑似フルスクリーン ─────────────────────────────── */
/* iOS Safari は div の requestFullscreen() を非対応のため CSS で代替 */
.player-container.ios-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 10000;
  border-radius: 0 !important;
  background: #000;
  max-width: none !important;
}
/* iOS フルスクリーン中はナビバーを非表示 */
html.ios-video-fs #bottom-nav { display: none !important; }
html.ios-video-fs body { overflow: hidden; }
