/* YouTube ダウンローダ Web版 スタイル（ダークテーマ・モバイル対応） */
:root {
  --bg: #1a1a1a;
  --panel: #252525;
  --card: #2a2a2a;
  --accent: #5b9bd5;
  --accent-hover: #3b8ed0;
  --text: #dddddd;
  --text-dim: #888888;
  --text-faint: #555555;
  --header-bg: #12122a;
  /* ステータス色（デスクトップ版を踏襲） */
  --st-wait: #888888;
  --st-dl: #3b8ed0;
  --st-conv: #f0a500;
  --st-done: #2fa855;
  --st-err: #e05252;
  --st-cancel: #666666;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  font-size: 14px;
}

.app-header {
  background: var(--header-bg);
  padding: 14px 18px;
}
.app-header h1 {
  margin: 0;
  font-size: 20px;
  color: var(--accent);
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
}

/* URL入力 */
.url-panel {
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 18px;
}
.url-panel label {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 6px;
}
.url-row {
  display: flex;
  gap: 8px;
}
#url-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
#url-input:focus { outline: none; border-color: var(--accent); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  padding: 0 18px;
  height: 40px;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { background: #444; cursor: default; }

.btn-secondary {
  background: #3a3a3a;
  font-weight: normal;
}
.btn-secondary:hover { background: #4a4a4a; }

/* タブ */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.tab {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid #3a3a3a;
  border-radius: 6px 6px 0 0;
  border-bottom: none;
  padding: 0 18px;
  height: 36px;
  font-weight: normal;
  font-size: 13px;
}
.tab:hover { background: #2a2a2a; color: var(--text); }
.tab.active {
  background: var(--panel);
  color: var(--accent);
  font-weight: bold;
}
.url-panel {
  border-radius: 0 8px 8px 8px;
}
.hidden { display: none !important; }

/* グローバル保存先セレクタ */
.dest-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel);
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  flex-wrap: wrap;
}
.dest-label { color: var(--text-dim); white-space: nowrap; margin-right: 4px; }
.dest-btn {
  background: #333;
  color: var(--text-dim);
  height: auto;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: normal;
  border-radius: 20px;
}
.dest-btn:hover { background: #444; color: var(--text); }
.dest-btn.dest-active {
  background: var(--accent);
  color: #fff;
  font-weight: bold;
}

/* 検索結果カード */
.search-result {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 6px;
  background: #1e1e1e;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.search-result:hover { border-color: var(--accent); background: #232333; }
.search-thumb {
  width: 100px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  background: #2a2a2a;
  flex-shrink: 0;
}
.search-info { flex: 1; min-width: 0; }
.search-title {
  font-size: 13px;
  font-weight: bold;
  word-break: break-word;
  margin-bottom: 4px;
}
.search-meta { font-size: 11px; color: var(--text-dim); }
.search-dl-icon {
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
  padding: 0 4px;
}
.search-url {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.8;
}
.search-url:hover { opacity: 1; text-decoration: underline; }

/* Musicフォルダ保存済みバッジ */
.card-music-saved {
  display: inline-block;
  color: var(--st-done);
  font-size: 12px;
  font-weight: bold;
}

/* キュー */
.queue-title {
  font-size: 14px;
  color: var(--text-dim);
  margin: 8px 0;
}
.queue { display: flex; flex-direction: column; gap: 10px; }
.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 40px 0;
}

/* ダウンロードカード */
.card {
  background: var(--card);
  border-radius: 8px;
  padding: 12px 14px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.card-title {
  flex: 1;
  font-weight: bold;
  font-size: 13px;
  word-break: break-word;
}
.card-fmt { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.card-cancel {
  background: #555;
  width: 28px; height: 24px;
  padding: 0;
  font-weight: normal;
  line-height: 1;
}
.card-cancel:hover { background: #c0392b; }

.progress {
  height: 8px;
  background: #1a1a1a;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0 6px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.card-status-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.card-status { font-weight: bold; }
.card-detail { color: var(--text-dim); }

/* カード内保存先セレクタ（カード生成時から表示） */
.card-dest-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.cdr-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.cdr-btn {
  background: #333;
  color: var(--text-dim);
  height: auto;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: normal;
  border-radius: 4px;
}
.cdr-btn:hover { background: #444; color: var(--text); }
.cdr-btn.cdr-active {
  background: var(--accent);
  color: #fff;
  font-weight: bold;
}

/* 完了後アクションスロット */
.card-dl-slot {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.card-dl {
  display: inline-block;
  background: var(--st-done);
  color: #fff;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
}

.card-music-btn {
  background: #2a5a3a;
  color: #fff;
  height: auto;
  padding: 6px 14px;
  font-size: 12px;
}
.card-music-btn:hover { background: #3a7a4a; }
.card-music-btn:disabled { background: #444; }

.card-browse-btn {
  background: #3a3a5a;
  color: #fff;
  height: auto;
  padding: 6px 14px;
  font-size: 12px;
}
.card-browse-btn:hover { background: #4a4a7a; }
.card-browse-btn:disabled { background: #444; }

/* フォルダブラウザモーダル */
.browser-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.browser-crumb {
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}
.browser-crumb:hover { text-decoration: underline; }
.browser-crumb-cur { color: var(--text-dim); font-size: 12px; }

.browser-save-btn {
  width: 100%;
  background: var(--st-done);
  margin-bottom: 12px;
  font-size: 13px;
}
.browser-save-btn:hover { background: #28a745; }

.browser-dirs { margin-top: 4px; }
.browser-dir {
  padding: 10px 12px;
  border-radius: 6px;
  background: #1e1e1e;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.browser-dir:hover { border-color: var(--accent); background: #232333; }
.browser-empty { color: var(--text-dim); font-size: 12px; padding: 8px 0; }

/* モーダル */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.overlay.hidden { display: none; }
.modal {
  background: #1f1f1f;
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  padding: 16px 18px 10px;
  font-size: 15px;
  font-weight: bold;
  color: var(--accent);
  border-bottom: 1px solid #333;
}
.modal-sub { font-size: 11px; color: var(--text-dim); font-weight: normal; margin-top: 4px; }
.modal-body {
  padding: 12px 18px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #333;
}

/* フォーマット行 */
.fmt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 6px;
  background: #222;
  margin-bottom: 6px;
  cursor: pointer;
}
.fmt-row.preset { background: #252538; }
.fmt-row input { accent-color: var(--accent); }
.fmt-label { flex: 1; }
.fmt-label.preset { color: #6aabf7; }
.fmt-meta { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

/* プレイリスト行 */
.pl-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.pl-count { color: var(--text-dim); font-size: 12px; }
.pl-numbering { font-size: 12px; color: var(--text-dim); margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  background: #1e1e1e;
  margin-bottom: 3px;
  cursor: pointer;
}
.pl-row:nth-child(even) { background: #222; }
.pl-idx { color: var(--text-faint); font-size: 11px; width: 28px; text-align: right; }
.pl-thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 4px; background: #2a2a2a; flex-shrink: 0; }
.pl-row-title { flex: 1; font-size: 12px; word-break: break-word; }
.pl-dur { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

.error-msg { color: var(--st-err); padding: 20px; text-align: center; }
.loading { color: var(--text-dim); padding: 30px; text-align: center; }
