:root {
  --sidebar-width: 220px;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-active: #6366f1;
  --sidebar-text: #ffffff;
  --sidebar-text-muted: rgba(255,255,255,0.7);
  --sidebar-text-dim: rgba(255,255,255,0.4);
  --sidebar-border: rgba(255,255,255,0.1);
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #222633;
  --border: #2a2e3d;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f97316;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }

/* ===== サイドバー ===== */
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh; background: var(--sidebar-bg); display: flex; flex-direction: column; z-index: 50; }
.sidebar-header { padding: 20px 16px; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-header h1 { font-size: 18px; color: var(--accent); margin: 0; }
.sidebar-header .subtitle { font-size: 11px; color: var(--sidebar-text-dim); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section { font-size: 10px; text-transform: uppercase; color: var(--sidebar-text-dim); padding: 16px 16px 4px; letter-spacing: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; margin: 2px 8px; color: var(--sidebar-text-muted); border-radius: 8px; text-decoration: none; font-size: 13px; transition: all 0.15s; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--sidebar-border); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.user-name { font-size: 13px; color: var(--sidebar-text); }
.logout-btn { display: block; width: 100%; text-align: center; padding: 8px; background: rgba(255,255,255,0.1); color: var(--sidebar-text-muted); border-radius: 6px; font-size: 12px; text-decoration: none; transition: all 0.15s; }
.logout-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.menu-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 60; font-size: 24px; border: none; background: none; color: var(--text); cursor: pointer; }

/* ===== メインコンテンツ ===== */
.main-content { margin-left: var(--sidebar-width); min-height: 100vh; }
.page-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.page-header h2 { font-size: 18px; font-weight: 600; }
.header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.content { padding: 24px; }

/* レスポンシブ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .page-header { padding-left: 48px; }
}

/* ボタン */
.btn { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: all 0.15s; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; text-align: center; }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

/* ドラッグ&ドロップ */
.draggable { cursor: default; transition: transform 0.15s, box-shadow 0.15s; }
.draggable.dragging { opacity: 0.4; transform: scale(0.98); }
.draggable.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.drag-handle { cursor: grab; color: var(--text-dim); font-size: 16px; padding: 0 8px 0 0; user-select: none; }
.drag-handle:active { cursor: grabbing; }

/* 検索 */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: 13px; }
.search-bar input:focus { outline: none; border-color: var(--accent); }

/* フィルタ */
.filter-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); padding: 4px 12px; border-radius: 16px; cursor: pointer; font-size: 12px; transition: all 0.15s; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-options { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-options select { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px; font-size: 12px; }
.custom-date-range { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; font-size: 13px; }
.custom-date-range input { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12px; }

/* タイムライン */
.timeline { position: relative; }
.timeline::before { content: ''; position: absolute; left: 20px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.event { position: relative; margin-left: 44px; margin-bottom: 16px; padding: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; transition: border-color 0.15s; }
.event:hover { border-color: var(--accent); }
.event::before { content: ''; position: absolute; left: -30px; top: 20px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.event.importance-important::before { background: var(--yellow); }
.event.importance-critical::before { background: var(--red); }
.event.pinned { border-left: 3px solid var(--orange); }
.event-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.event-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.event-date { font-size: 13px; color: var(--text-dim); }
.event-project { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; color: #fff; }
.event-source { font-size: 10px; color: var(--text-dim); background: var(--bg-hover); padding: 1px 6px; border-radius: 4px; }
.event-hash { font-family: 'SF Mono', 'Consolas', monospace; font-size: 12px; color: var(--accent); cursor: pointer; }
.event-hash:hover { text-decoration: underline; }
.event-message { font-size: 14px; margin-bottom: 6px; white-space: pre-line; word-break: break-word; }
.event-message .first-line { font-weight: 600; }
.event-author { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.event-note { background: var(--bg-hover); padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; border-left: 3px solid var(--yellow); }
.event-actions { display: flex; gap: 8px; }
.event-actions .btn { font-size: 11px; padding: 3px 8px; }

/* タグ */
.event-tags { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tag-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; color: #fff; }
.tag-toggle { padding: 6px 14px; border-radius: 16px; border: 2px solid var(--tag-color); background: transparent; color: var(--text); cursor: pointer; font-size: 12px; margin: 3px; transition: all 0.15s; }
.tag-toggle.active { background: var(--tag-color); color: #fff; }
.tag-toggle:hover { opacity: 0.8; }

/* 差分 */
.diff-list { max-height: 400px; overflow-y: auto; }
.diff-file { padding: 6px 10px; border-bottom: 1px solid var(--border); font-family: monospace; font-size: 13px; }
.diff-added { color: var(--green); }
.diff-removed { color: var(--red); }
.diff-modified { color: var(--yellow); }
.diff-stats { font-size: 11px; color: var(--text-dim); margin-left: 8px; }

/* モーダル */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; width: 90%; max-width: 480px; padding: 20px; }
.modal-wide { max-width: 640px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; }
.modal-body textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 13px; resize: vertical; margin-bottom: 12px; }
.form-row { display: flex; align-items: center; gap: 10px; }
.form-row label { font-size: 13px; }
.form-row select { background: var(--bg); color: var(--text); border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px; font-size: 13px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.load-more { text-align: center; margin: 20px 0; }
.loading { text-align: center; color: var(--text-dim); padding: 40px; }
.empty { text-align: center; color: var(--text-dim); padding: 24px; background: var(--bg-card); border: 1px dashed var(--border); border-radius: 8px; }
.error { color: var(--red); padding: 12px; }

/* トースト */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--bg-card); border: 1px solid var(--border); padding: 12px 20px; border-radius: 8px; font-size: 13px; z-index: 200; animation: fadeIn 0.2s; }
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } }

/* ===== ログイン ===== */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 90%; max-width: 380px; }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-error { background: rgba(239,68,68,0.1); border: 1px solid var(--red); color: var(--red); padding: 8px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; text-align: center; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .form-group label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.login-card .form-group input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 14px; }
.login-card .form-group input:focus { outline: none; border-color: var(--accent); }
.login-card .btn { margin-top: 8px; padding: 10px; font-size: 14px; }
.login-tabs { display: flex; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.login-tab { flex: 1; background: none; border: none; color: var(--text-dim); padding: 10px; font-size: 13px; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; }
.login-tab:hover { color: var(--text); }
.login-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== 設定タブ ===== */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.settings-tab { background: none; border: none; color: var(--text-dim); padding: 10px 20px; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; }
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== 設定画面 ===== */
.section { margin-bottom: 32px; }
.section h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.form-group input, .form-group select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); }
.form-actions { display: flex; gap: 8px; }
.test-result { margin-top: 12px; padding: 10px; border-radius: 6px; font-size: 13px; background: var(--bg-hover); }
.test-result.success { border-left: 3px solid var(--green); }
.test-result.error { border-left: 3px solid var(--red); }

.card-list { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.card:hover { border-color: var(--accent); }
.card-title { font-size: 14px; font-weight: 600; }
.card-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.card-actions { display: flex; gap: 6px; }

/* 2カラムリポジトリ設定 */
.repo-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.repo-columns h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
@media (max-width: 768px) { .repo-columns { grid-template-columns: 1fr; } }
.section-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.repo-list-full { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; }
.repo-list { max-height: 400px; overflow-y: auto; }
.repo-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); gap: 8px; }
.repo-info { flex: 1; min-width: 0; overflow: hidden; }
.repo-item:last-child { border-bottom: none; }
.repo-item.watched { opacity: 0.6; }
.repo-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repo-action { flex-shrink: 0; }
.repo-desc { font-size: 12px; color: var(--text-dim); }
.repo-branch { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.badge-watched { font-size: 11px; color: var(--green); border: 1px solid var(--green); padding: 2px 8px; border-radius: 10px; }

/* ===== ダッシュボード ===== */
.summary-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.summary-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.summary-text { font-size: 14px; line-height: 1.8; }
.summary-text h3 { font-size: 16px; margin: 8px 0; }

.chart-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; max-height: 400px; overflow-y: auto; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bar-label { font-size: 11px; color: var(--text-dim); width: 50px; text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 18px; background: var(--bg-hover); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; min-width: 2px; }
.bar-value { font-size: 11px; color: var(--text-dim); width: 30px; flex-shrink: 0; }

.compare-form, .export-form { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.compare-form input, .export-form input, .compare-form select { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.compare-list { display: flex; flex-direction: column; gap: 12px; }
.compare-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.compare-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.compare-project { font-weight: 600; }
.compare-count { color: var(--accent); font-weight: 600; }
.compare-messages { font-size: 12px; color: var(--text-dim); max-height: 100px; overflow-y: auto; }

.export-report { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.export-report h3 { margin-bottom: 12px; }
.report-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.report-table th, .report-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
.report-table th { color: var(--text-dim); font-weight: 600; }
details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-bottom: 8px; }
.export-details { max-height: 400px; overflow-y: auto; }
.export-event { font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.export-date { color: var(--text-dim); margin-right: 8px; }
.export-proj { color: var(--accent); margin-right: 8px; font-weight: 600; }
