/* ── リセット & ベース ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #232733;
    --border: #2a2e3a;
    --text: #e4e6eb;
    --text-muted: #8b8fa3;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --red: #ef4444;
    --green: #22c55e;
    --yellow: #eab308;
    --blue: #3b82f6;
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── ヘッダー ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left { display: flex; align-items: baseline; gap: 12px; }
.logo { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.subtitle { font-size: 0.85rem; color: var(--text-muted); }

.header-right { display: flex; align-items: center; gap: 12px; }

.stats-bar { display: flex; gap: 16px; }
.stat {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 4px;
}

/* ── ボタン ── */
.btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }

/* ── メインレイアウト ── */
.main {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 0;
    min-height: calc(100vh - 56px);
}

/* ── パネル ── */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 16px;
    overflow: hidden;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-panel {
    margin-right: 0;
}

/* ── フィルター ── */
.filter-row { display: flex; gap: 8px; }
.filter-row select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.8rem;
}

/* ── タイムライン ── */
.timeline {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--bg);
    border-radius: var(--radius);
    border-left: 3px solid var(--border);
    transition: background 0.15s;
}
.timeline-item:hover { background: var(--bg-hover); }
.timeline-item.type-collab { border-left-color: var(--accent); }
.timeline-item.type-sudden { border-left-color: var(--red); }
.timeline-item.type-news { border-left-color: var(--blue); }
.timeline-item.type-stream { border-left-color: var(--green); }

.tl-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.tl-icon.collab { background: rgba(99, 102, 241, 0.2); color: var(--accent); }
.tl-icon.sudden { background: rgba(239, 68, 68, 0.2); color: var(--red); }
.tl-icon.news { background: rgba(59, 130, 246, 0.2); color: var(--blue); }
.tl-icon.stream { background: rgba(34, 197, 94, 0.2); color: var(--green); }

.tl-content { flex: 1; min-width: 0; }
.tl-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tl-title a { color: var(--text); text-decoration: none; }
.tl-title a:hover { color: var(--accent); }
.tl-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.tl-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-collab { background: rgba(99, 102, 241, 0.2); color: var(--accent); }
.badge-sudden { background: rgba(239, 68, 68, 0.2); color: var(--red); }
.badge-news { background: rgba(59, 130, 246, 0.2); color: var(--blue); }
.badge-event { background: rgba(234, 179, 8, 0.2); color: var(--yellow); }

.confidence-bar {
    display: inline-block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    vertical-align: middle;
}
.confidence-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

/* ── ライブリスト ── */
.live-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.live-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
}
.live-item:hover { background: var(--bg-hover); }

.live-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.live-info { flex: 1; min-width: 0; }
.live-name { font-size: 0.8rem; font-weight: 600; }
.live-title-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.live-viewers { font-size: 0.7rem; color: var(--red); font-weight: 600; white-space: nowrap; }
.live-platform {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
}
.platform-youtube { background: rgba(255, 0, 0, 0.15); color: #f00; }
.platform-twitch { background: rgba(145, 70, 255, 0.15); color: #9146ff; }

/* ── 配信者リスト ── */
.streamer-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.streamer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.streamer-item:hover { background: var(--bg-hover); }

.streamer-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.streamer-name { flex: 1; font-size: 0.85rem; }

.streamer-platforms {
    display: flex;
    gap: 4px;
}
.platform-icon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
}

.streamer-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.15s;
}
.streamer-item:hover .streamer-delete { opacity: 1; }
.streamer-delete:hover { color: var(--red); }

/* ── 空状態 ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state p { font-size: 0.9rem; margin-bottom: 8px; }

/* ── モーダル ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 450px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.1rem; }
.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
}
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}
.form-group input[type="color"] {
    height: 36px;
    padding: 2px;
    cursor: pointer;
}
.required { color: var(--red); }

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

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

/* ── レスポンシブ ── */
@media (max-width: 768px) {
    .main {
        grid-template-columns: 1fr;
    }
    .header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px;
    }
    .stats-bar { display: none; }
    .panel { margin: 8px; }
    .timeline-panel { margin-right: 8px; }
}
