/* ===== リセット & 変数 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:    #ff0000;
  --red2:   #cc0000;
  --green:  #16a34a;
  --blue:   #4f46e5;
  --blue2:  #4338ca;
  --bg:     #0f0f0f;
  --card:   #1a1a1a;
  --card2:  #242424;
  --input:  #2a2a2a;
  --border: #333;
  --blight: #3d3d3d;
  --text:   #e8e8e8;
  --muted:  #888;
  --dim:    #555;
  --r:      10px;
  --font:   'Noto Sans JP', sans-serif;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; min-height: 100vh; }
a { color: #7c9eff; }

/* ===== ヘッダー ===== */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,15,15,.93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { max-width: 1100px; margin: 0 auto; padding: 0 20px; height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo .fa-youtube { color: var(--red); font-size: 22px; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* ===== ボタン ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--r); border: none; cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 500; white-space: nowrap; transition: .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue2); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover:not(:disabled) { background: var(--red2); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { background: #15803d; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--blight); }
.btn-ghost:hover:not(:disabled) { background: var(--card2); color: var(--text); }

.hidden { display: none !important; }

/* ===== アカウントメニュー ===== */
.account-menu { position: relative; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.connected { background: #4ade80; box-shadow: 0 0 5px #4ade80; }
.dropdown { position: absolute; top: calc(100% + 8px); right: 0; min-width: 200px; background: var(--card); border: 1px solid var(--blight); border-radius: var(--r); box-shadow: 0 8px 32px rgba(0,0,0,.6); overflow: hidden; z-index: 200; animation: fadeDown .15s ease; }
@keyframes fadeDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.dropdown-ch { padding: 10px 14px; font-size: 11px; color: var(--muted); }
.dropdown hr { border: none; border-top: 1px solid var(--border); }
.dropdown-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: none; border: none; color: var(--muted); font-family: var(--font); font-size: 13px; cursor: pointer; text-align: left; transition: .15s; }
.dropdown-item:hover { background: var(--card2); color: var(--text); }
.dropdown-item.danger:hover { background: #2d1515; color: #f87171; }

/* ===== メイン ===== */
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 18px; }

/* ===== カード ===== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 22px; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.desc { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ===== Setup フォーム ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input { background: var(--input); border: 1px solid var(--blight); border-radius: 7px; color: var(--text); font-family: var(--font); font-size: 13px; padding: 8px 11px; outline: none; transition: .15s; }
.form-grid input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,70,229,.18); }
.form-grid input::placeholder { color: var(--dim); }
.setup-footer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check-label input { accent-color: var(--blue); cursor: pointer; }

/* ===== 取得フォーム ===== */
.fetch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.ch-info { display: flex; align-items: center; gap: 10px; }
.ch-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--blight); }
.ch-icon { font-size: 36px; color: var(--red); }
.ch-name { font-size: 14px; font-weight: 700; }
.ch-id { font-size: 11px; color: var(--muted); }
.fetch-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ym-picker { display: flex; align-items: center; gap: 6px; background: var(--input); border: 1px solid var(--blight); border-radius: 7px; padding: 6px 12px; font-size: 13px; }
.ym-picker select { background: transparent; border: none; color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 600; outline: none; cursor: pointer; }
.ym-picker select option { background: #1a1a1a; }
.options-row { display: flex; gap: 18px; flex-wrap: wrap; }

/* ===== プログレス ===== */
.progress { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.progress-bar { height: 5px; background: var(--input); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--red), #ff6b6b); border-radius: 99px; transition: width .3s; }
.progress p { font-size: 12px; color: var(--muted); text-align: center; }

/* ===== 結果カード ===== */
.result-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.result-title { font-size: 15px; font-weight: 700; }
.result-count { font-size: 12px; color: var(--muted); margin-left: 8px; }
.result-actions { display: flex; gap: 8px; }

/* ===== タブ ===== */
.tab-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: thin; }
.tab-list::-webkit-scrollbar { height: 3px; }
.tab-list::-webkit-scrollbar-thumb { background: #333; border-radius: 99px; }
.tab-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 99px; border: 1px solid var(--blight); background: transparent; color: var(--muted); font-family: var(--font); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: .15s; flex-shrink: 0; }
.tab-btn:hover { background: var(--card2); color: var(--text); }
.tab-btn.active { background: var(--red); border-color: var(--red); color: #fff; }
.tab-cnt { background: rgba(255,255,255,.18); font-size: 11px; padding: 1px 6px; border-radius: 99px; font-weight: 700; }
.tab-btn:not(.active) .tab-cnt { background: var(--input); color: var(--muted); }

/* ===== サマリー ===== */
.summary { display: flex; background: #16213e; border: 1px solid #2d3561; border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.sum-item { display: flex; align-items: center; gap: 10px; padding: 12px 20px; flex: 1; border-right: 1px solid #2d3561; }
.sum-item:last-child { border-right: none; }
.sum-item > .fa-film, .sum-item > .fa-clock, .sum-item > .fa-chart-bar, .sum-item > .fa-eye { font-size: 18px; color: #7c9eff; flex-shrink: 0; }
.sum-item p { font-size: 10px; color: #6b7db3; text-transform: uppercase; letter-spacing: .4px; }
.sum-item b { font-size: 16px; color: #e0e8ff; font-variant-numeric: tabular-nums; }

/* ===== フィルター ===== */
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.search-box { position: relative; flex: 1; min-width: 180px; }
.search-box .fa-magnifying-glass { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--dim); font-size: 12px; pointer-events: none; }
.search-box input { width: 100%; background: var(--input); border: 1px solid var(--blight); border-radius: 7px; color: var(--text); font-family: var(--font); font-size: 13px; padding: 7px 10px 7px 30px; outline: none; transition: .15s; }
.search-box input:focus { border-color: var(--blue); }
.search-box input::placeholder { color: var(--dim); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { padding: 4px 11px; border-radius: 99px; border: 1px solid var(--blight); background: transparent; color: var(--muted); font-family: var(--font); font-size: 12px; cursor: pointer; transition: .15s; }
.chip:hover { background: var(--card2); color: var(--text); }
.chip.active { background: var(--red); border-color: var(--red); color: #fff; }

/* ===== テーブル ===== */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); }
#tbl { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
#tbl thead { background: var(--card2); position: sticky; top: 0; }
#tbl th { padding: 9px 13px; text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .3px; border-bottom: 1px solid var(--border); }
#tbl th:first-child { width: 38px; text-align: center; }
#tbl th.sort { cursor: pointer; user-select: none; }
#tbl th.sort:hover { color: var(--text); }
#tbl th.sort::after { content: ' ⇅'; opacity: .4; font-size: 10px; }
#tbl th.sort.asc::after  { content: ' ↑'; opacity: 1; color: var(--red); }
#tbl th.sort.desc::after { content: ' ↓'; opacity: 1; color: var(--red); }
#tbl td { padding: 9px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
#tbl tr:last-child td { border-bottom: none; }
#tbl tbody tr:hover { background: var(--card2); }
#tbl td:first-child { text-align: center; color: var(--dim); font-size: 11px; }

.td-title { max-width: 320px; white-space: normal; word-break: break-word; }
.title-link { color: var(--text); font-weight: 500; }
.title-link:hover { color: #7c9eff; text-decoration: none; }
.ch-badge { display: inline-block; background: #2a2a4a; color: #9ba8e8; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; margin-right: 5px; border: 1px solid #3d3d7a; vertical-align: middle; white-space: nowrap; }
.vid-badge { font-family: monospace; font-size: 11px; background: var(--input); padding: 2px 6px; border-radius: 4px; color: var(--muted); cursor: pointer; transition: .15s; }
.vid-badge:hover { background: var(--blight); color: var(--text); }
.td-views { text-align: right; font-weight: 500; }
.td-dur { font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-public   { background: #16a34a22; color: #4ade80; border: 1px solid #16a34a44; }
.badge-private  { background: #dc262622; color: #f87171; border: 1px solid #dc262644; }
.badge-unlisted { background: #d9770622; color: #fbbf24; border: 1px solid #d9770644; }
.badge-other    { background: var(--input); color: var(--muted); border: 1px solid var(--blight); }

.no-result { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; }

/* ===== モーダル ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(6px); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--card); border: 1px solid var(--blight); border-radius: var(--r); max-width: 540px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: slideUp .18s; }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: var(--input); }
.help-ol { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; counter-reset: h; list-style: none; }
.help-ol li { display: flex; gap: 10px; font-size: 13px; color: var(--muted); line-height: 1.7; counter-increment: h; }
.help-ol li::before { content: counter(h); width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 3px; }
.help-ol li strong, .help-ol li a { color: var(--text); }
.help-note { margin: 0 20px 14px; background: #1e293b; border: 1px solid #334155; border-radius: 7px; padding: 10px 13px; font-size: 12px; color: #94a3b8; display: flex; gap: 8px; }
.help-note .fa-circle-info { color: #60a5fa; margin-top: 2px; }
.help-note.warn { background: #1c1917; border-color: #44403c; }
.help-note.warn .fa-chart-bar { color: #f59e0b; margin-top: 2px; }

/* ===== トースト ===== */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 400; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 15px; border-radius: var(--r); background: var(--card2); border: 1px solid var(--blight); box-shadow: 0 6px 20px rgba(0,0,0,.5); font-size: 13px; min-width: 220px; max-width: 360px; pointer-events: all; animation: toastIn .2s; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut .2s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }
.toast.success { border-left: 3px solid #4ade80; }
.toast.success i { color: #4ade80; }
.toast.error   { border-left: 3px solid #f87171; }
.toast.error   i { color: #f87171; }
.toast.info    { border-left: 3px solid #60a5fa; }
.toast.info    i { color: #60a5fa; }
.toast.warning { border-left: 3px solid #fbbf24; }
.toast.warning i { color: #fbbf24; }

/* ===== スクロールバー ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 99px; }

/* ===== レスポンシブ ===== */
@media (max-width: 700px) {
  .logo span { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.full { grid-column: 1; }
  .fetch-row { flex-direction: column; align-items: flex-start; }
  .summary { flex-wrap: wrap; }
  .sum-item { flex: 1 1 45%; border-right: none; border-bottom: 1px solid #2d3561; }
  .sum-item:last-child { border-bottom: none; }
  #toasts { left: 12px; right: 12px; }
  .toast { max-width: 100%; }
}
