/* ================================================================
   YouTube Channel Analyzer
   ================================================================ */

.yt-hero {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
    color: #fff;
    padding: 2rem 1.5rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}
.yt-hero h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .3rem; }
.yt-hero p  { opacity: .85; margin: 0; font-size: .95rem; }

.yt-search-form {
    display: flex;
    gap: .5rem;
    margin-top: 1.2rem;
}
.yt-search-form input {
    flex: 1;
    padding: .6rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}
.yt-search-form button {
    padding: .6rem 1.4rem;
    background: #222;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
}
.yt-search-form button:hover { background: #444; }

/* ---- stat cards ---- */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.stat-card .val { font-size: 1.7rem; font-weight: 700; color: #cc0000; }
.stat-card .lbl { font-size: .8rem; color: #666; margin-top: .2rem; }

/* ---- channel header ---- */
.ch-header {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    margin-bottom: 1.5rem;
}
.ch-header img       { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.ch-header .ch-name  { font-size: 1.3rem; font-weight: 700; }
.ch-header .ch-desc  { font-size: .85rem; color: #555; margin-top: .2rem; max-height: 3.5em; overflow: hidden; }

/* ---- section card ---- */
.section-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.4rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    margin-bottom: 2rem;
}
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    border-left: 4px solid #cc0000;
    padding-left: .7rem;
    margin-bottom: 1.2rem;
}

/* ---- chart ---- */
.chart-container { position: relative; height: 260px; }

/* ---- tabs ---- */
.tab-btns { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab-btn {
    padding: .35rem .9rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    cursor: pointer;
    font-size: .85rem;
}
.tab-btn.active { background: #cc0000; color: #fff; border-color: #cc0000; }

/* ---- video table ---- */
.video-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.video-table th { background: #f3f3f3; padding: .5rem .7rem; text-align: left; border-bottom: 2px solid #ddd; }
.video-table td { padding: .45rem .7rem; border-bottom: 1px solid #eee; vertical-align: middle; }
.video-table tr:hover td { background: #fafafa; }
.video-thumb       { width: 80px; height: 45px; object-fit: cover; border-radius: 4px; }
.video-title-link  { color: #222; text-decoration: none; font-weight: 500; }
.video-title-link:hover { color: #cc0000; }
.rank-badge { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 50%; font-size: .75rem; font-weight: 700; background: #eee; }
.rank-badge.r1 { background: #ffd700; }
.rank-badge.r2 { background: #c0c0c0; }
.rank-badge.r3 { background: #cd7f32; color: #fff; }

/* ---- short / normal badge ---- */
.badge-short  { display: inline-block; padding: .1rem .45rem; font-size: .7rem; font-weight: 700; border-radius: 4px; background: #ff0000; color: #fff; vertical-align: middle; margin-left: .3rem; line-height: 1.4; }
.badge-normal { display: inline-block; padding: .1rem .45rem; font-size: .7rem; font-weight: 700; border-radius: 4px; background: #1a73e8; color: #fff; vertical-align: middle; margin-left: .3rem; line-height: 1.4; }

/* ---- playlist ---- */
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.playlist-card { border: 1px solid #eee; border-radius: 8px; padding: .9rem; font-size: .88rem; }
.playlist-card .pl-title { font-weight: 600; margin-bottom: .3rem; }
.playlist-card .pl-count { color: #888; }

/* ---- cache notice ---- */
.cache-notice {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: #888;
    margin-bottom: 1rem;
}
.cache-notice.from-db  { color: #2e7d32; }
.cache-notice.from-api { color: #1565c0; }

.num { font-variant-numeric: tabular-nums; }

@media (max-width: 768px) {
    .yt-hero { padding: 1.2rem 1rem 1rem; }
    .yt-hero h1 { font-size: 1.2rem; }
    .ch-header { flex-direction: column; text-align: center; gap: 0.8rem; }
    .ch-header img { width: 56px; height: 56px; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .stat-card .val { font-size: 1.3rem; }
    .section-card { padding: 1rem; }
    .video-table { font-size: .8rem; }
    .video-table th, .video-table td { padding: .35rem .4rem; }
    .playlist-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (max-width: 600px) {
    .yt-search-form { flex-direction: column; }
    .video-thumb    { width: 60px; height: 34px; }
    .stat-cards { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
}

/* ================================================================
   YouTube Index Page - Inline Styles
   ================================================================ */

.yt-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    max-width: 1300px;
    margin: 0 auto;
    padding: 1rem;
}
/* サイドパネル */
.yt-side {
    width: 240px;
    flex-shrink: 0;
}
.yt-side-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 1rem;
}
.yt-side-card h3 {
    font-size: .85rem;
    font-weight: 700;
    color: #555;
    margin: 0 0 10px;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.yt-creator-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.yt-creator-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-radius: 6px;
    transition: background .15s;
}
.yt-creator-list li:hover {
    background: #f3f4f6;
}
.yt-creator-list li img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.yt-creator-list li a {
    font-size: .82rem;
    color: #333;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.yt-creator-list li a:hover {
    color: #cc0000;
}
.yt-creator-list .fav-star {
    font-size: .9rem;
    color: #fbbf24;
    flex-shrink: 0;
}
/* メインコンテンツ */
.yt-main {
    flex: 1;
    min-width: 0;
}
/* お気に入りボタン */
.btn-fav {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #fbbf24;
    background: #fff;
    color: #92400e;
    font-size: .85rem;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.btn-fav:hover,
.btn-fav.active {
    background: #fbbf24;
    color: #fff;
}
.btn-fav .star {
    font-size: 1rem;
}
/* AI分析ボタン */
.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid #6366f1;
    background: #fff;
    color: #4338ca;
    font-size: .75rem;
    cursor: pointer;
    transition: background .2s, color .2s;
    flex-shrink: 0;
}
.btn-ai:hover {
    background: #6366f1;
    color: #fff;
}
/* データポートカード */
.yt-port-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 1rem;
}
.yt-port-card h3 {
    font-size: .85rem; font-weight: 700; color: #555;
    margin: 0 0 10px; letter-spacing: .03em; text-transform: uppercase;
}
.port-btn-row { display: flex; flex-direction: column; gap: 6px; }
.btn-port {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 10px; border-radius: 6px;
    font-size: .8rem; font-weight: 600; cursor: pointer;
    text-decoration: none; border: 1px solid; transition: all .15s;
    justify-content: center;
}
.btn-port-export { background: #fff; border-color: #6366f1; color: #4338ca; }
.btn-port-export:hover { background: #6366f1; color: #fff; }
.btn-port-import { background: #fff; border-color: #10b981; color: #065f46; }
.btn-port-import:hover { background: #10b981; color: #fff; }
.import-result {
    font-size: .78rem; margin-top: 6px; padding: 6px 8px;
    border-radius: 5px; display: none;
}
.import-result.ok  { background: #d1fae5; color: #065f46; }
.import-result.err { background: #fee2e2; color: #991b1b; }
/* AI分析モーダル */
.ai-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.ai-modal-overlay.open {
    display: flex;
}
.ai-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 780px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,.2);
    overflow: hidden;
}
.ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
}
.ai-modal-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}
.ai-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.ai-modal-body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}
.ai-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: #6366f1;
}
.ai-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e7ff;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-result-content {
    font-size: .9rem;
    line-height: 1.75;
    color: #333;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-result-content h3 {
    font-size: 1rem;
    color: #4338ca;
    margin: 1.25rem 0 .5rem;
    padding-bottom: 4px;
    border-bottom: 2px solid #e0e7ff;
}
/* レスポンシブ */
@media (max-width: 768px) {
    .yt-layout { flex-direction: column; }
    .yt-side { width: 100%; }
}
