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

:root {
  --sidebar-w: 220px;
  --header-h: 60px;
  --color-bg: #f0f2f7;
  --color-surface: #ffffff;
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-primary-light: #e0e7ff;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;
  --color-text: #1e293b;
  --color-text-muted: #94a3b8;
  --color-border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --transition: all .2s ease;
}

html, body { height: 100%; font-family: 'Noto Sans JP', 'Inter', sans-serif; font-size: 14px; color: var(--color-text); background: var(--color-bg); }

/* ============================================================
   レイアウト
   ============================================================ */
#app-layout { display: flex; height: 100vh; overflow: hidden; }

/* サイドバー */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: #1e1b4b;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 100;
}
#sidebar-logo {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1);
  letter-spacing: .5px;
}
#sidebar-logo i { color: var(--color-primary); font-size: 1.4rem; }
#sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: rgba(99,102,241,.25); border-left-color: var(--color-primary); }
.nav-item i { width: 18px; text-align: center; font-size: 1rem; }
#sidebar-footer { padding: 14px 18px; color: rgba(255,255,255,.35); font-size: .72rem; border-top: 1px solid rgba(255,255,255,.1); }

/* メインエリア */
#main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ヘッダー */
#top-header {
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
#sidebar-toggle { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--color-text); }
#page-title { font-size: 1.05rem; font-weight: 700; flex: 1; }
#header-actions { display: flex; align-items: center; gap: 8px; }

/* コンテンツスクロール */
#page-wrap { flex: 1; overflow-y: auto; }

/* ============================================================
   ページ共通
   ============================================================ */
.page { display: none; }
.page.active { display: block; }
.page-inner { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ============================================================
   カード
   ============================================================ */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title { font-size: .95rem; font-weight: 700; flex: 1; }
.card-title i { color: var(--color-primary); margin-right: 6px; }
.card-body { padding: 20px; }

/* ============================================================
   ボタン
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-secondary { background: #f1f5f9; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: #e2e8f0; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* ============================================================
   フォーム
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-label { display: block; margin-bottom: 5px; font-size: .82rem; font-weight: 600; color: #475569; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  transition: var(--transition);
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
textarea.form-control { resize: vertical; }

/* ============================================================
   統計カード
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-body { flex: 1; }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--color-text-muted); margin-top: 3px; }

/* ============================================================
   アップロードUI
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: #fafbff;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--color-primary); background: var(--color-primary-light); }
.upload-icon { font-size: 3rem; color: var(--color-primary); display: block; margin-bottom: 12px; }
.upload-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.upload-sub { color: var(--color-text-muted); font-size: .85rem; margin-top: 4px; }
.upload-preview-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; background: #f8fafc; border-radius: var(--radius); border: 1px solid var(--color-border); }
.upload-file-info { display: flex; align-items: center; gap: 10px; }
.file-name { font-weight: 600; }
.file-size { color: var(--color-text-muted); font-size: .82rem; }

.options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.option-item { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); }
.option-item:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.option-item input[type=checkbox] { accent-color: var(--color-primary); width: 16px; height: 16px; }
.option-item span { font-size: .88rem; font-weight: 500; }

/* 進捗 */
.progress-bar-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.progress-bar { flex: 1; height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-primary); border-radius: 99px; transition: width .5s ease; }
.analysis-steps { display: flex; flex-direction: column; gap: 10px; }
.step-item { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--color-text-muted); }
.step-item.active { color: var(--color-primary); font-weight: 600; }
.step-item.done { color: var(--color-success); }
.step-icon.waiting { color: #e2e8f0; }
.step-icon.active { color: var(--color-primary); animation: spin 1s linear infinite; }
.step-icon.done { color: var(--color-success); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   プロジェクトグリッド
   ============================================================ */
.page-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.search-wrap { position: relative; flex: 1; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); }
.search-input { padding-left: 32px; }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.project-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--color-primary-light); }
.pc-thumb { height: 120px; background: linear-gradient(135deg, #1e1b4b, #312e81); display: flex; align-items: center; justify-content: center; position: relative; }
.pc-thumb-icon { font-size: 2.5rem; color: rgba(255,255,255,.3); }
.pc-status-badge { position: absolute; top: 8px; right: 8px; }
.pc-body { padding: 14px; }
.pc-title { font-weight: 700; font-size: .95rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-meta { color: var(--color-text-muted); font-size: .78rem; display: flex; gap: 10px; flex-wrap: wrap; }
.pc-footer { padding: 10px 14px; border-top: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }

/* ステータスバッジ */
.badge { padding: 3px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.badge-analyzing { background: #fef3c7; color: #b45309; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-knowledge { background: var(--color-primary-light); color: var(--color-primary); }

/* ============================================================
   エディタ
   ============================================================ */
#page-editor { display: none; }
#page-editor.active { display: flex; flex-direction: column; height: 100%; }
#editor-wrap { display: flex; flex-direction: column; height: 100%; }
#editor-header {
  padding: 12px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
#editor-title-wrap { flex: 1; }
#editor-project-title { font-size: 1rem; font-weight: 700; }
#editor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#scene-table-wrap { flex: 1; overflow: auto; }

.scene-table { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.scene-table th { background: #f8fafc; padding: 10px 8px; text-align: left; font-weight: 700; color: #475569; border-bottom: 2px solid var(--color-border); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.scene-table td { padding: 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.scene-table tr:hover td { background: #fafbff; }

/* テキスト系セルは最低高さを確保して読みやすく */
.scene-table td textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: .82rem;
  font-family: inherit;
  background: transparent;
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.scene-table td input,
.scene-table td select {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: .82rem;
  font-family: inherit;
  background: transparent;
}
.scene-table td input:focus,
.scene-table td textarea:focus,
.scene-table td select:focus { outline: none; border-color: var(--color-primary); background: #fff; box-shadow: 0 0 0 2px rgba(99,102,241,.1); }

/* 台本・撮影指示は特に広く */
.scene-table td.col-script textarea  { min-height: 120px; }
.scene-table td.col-shooting textarea { min-height: 100px; }

.scene-num { font-weight: 700; color: var(--color-primary); text-align: center; }

/* スクリーンショットセル */
.scene-ss-cell { width: 140px; min-width: 140px; vertical-align: middle; }

/* コンテナ: 幅固定・高さは動画のアスペクト比で自動決定 */
.scene-screenshot {
  width: 128px;
  background: #e2e8f0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
/* 画像: 幅100%で高さは自然比率のまま（object-fit不要） */
.scene-screenshot img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}
.scene-screenshot i { color: #94a3b8; font-size: 1.5rem; padding: 20px 0; }

/* ローディングシマー: 仮の16:9比率で表示 */
.scene-ss-loading {
  width: 128px;
  height: 72px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* 星評価 */
.star-rating { display: flex; gap: 3px; }
.star { font-size: 1.1rem; cursor: pointer; color: #e2e8f0; transition: var(--transition); }
.star.active { color: #f59e0b; }

/* ナレッジ */
.knowledge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.knowledge-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-left: 4px solid var(--color-primary);
}
.kc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.kc-title { font-weight: 700; font-size: .92rem; }
.kc-meta { color: var(--color-text-muted); font-size: .78rem; margin-bottom: 8px; }
.kc-content { font-size: .83rem; line-height: 1.6; color: #475569; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kc-footer { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.kc-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { padding: 2px 8px; background: #f1f5f9; border-radius: 99px; font-size: .72rem; color: #64748b; }

/* ============================================================
   AIモードバッジ
   ============================================================ */
.ai-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
}
.ai-mode-badge.real { background: #d1fae5; color: #065f46; }
.ai-mode-badge.demo { background: #fef3c7; color: #b45309; }

/* AI状態バー */
.ai-status-bar {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.demo-bar { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.demo-bar a { color: #92400e; font-weight: 700; }

/* ============================================================
   モーダル
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-lg { max-width: 860px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; flex-shrink: 0; }
.modal-title { font-size: 1rem; font-weight: 700; flex: 1; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #94a3b8; padding: 4px; border-radius: 6px; }
.modal-close:hover { background: #f1f5f9; color: var(--color-text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.modal-two-col { display: grid; grid-template-columns: 1fr 1.6fr; gap: 20px; }
.scene-screenshot-wrap { width: 100%; height: 120px; background: #f1f5f9; border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.scene-screenshot-wrap img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   トースト
   ============================================================ */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: .88rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 400px;
  animation: toast-in .3s ease;
}
.toast.success { background: #d1fae5; color: #065f46; }
.toast.error { background: #fee2e2; color: #991b1b; }
.toast.warning { background: #fef3c7; color: #92400e; }
.toast.info { background: #dbeafe; color: #1e40af; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }

/* ============================================================
   ガイド
   ============================================================ */
.guide-steps { display: flex; flex-direction: column; gap: 16px; }
.guide-step { display: flex; align-items: flex-start; gap: 16px; }
.step-num { width: 32px; height: 32px; background: var(--color-primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.guide-step p { color: var(--color-text-muted); font-size: .85rem; margin-top: 3px; }

/* ============================================================
   その他
   ============================================================ */
.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }
.empty-state i { font-size: 2.5rem; opacity: .4; display: block; margin-bottom: 12px; }
.empty-state p { margin-bottom: 12px; }
.link-more { color: var(--color-primary); text-decoration: none; font-size: .85rem; font-weight: 600; }
.link-more:hover { text-decoration: underline; }
.icon-btn { background: none; border: 1px solid var(--color-border); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: .85rem; color: var(--color-text-muted); transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #f1f5f9; color: var(--color-text); }
.icon-btn.danger:hover { background: #fee2e2; color: var(--color-danger); border-color: var(--color-danger); }
.info-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.info-table td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); }
.info-table td:first-child { color: var(--color-text-muted); width: 140px; }
.project-list-item { padding: 12px 16px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 12px; cursor: pointer; transition: var(--transition); }
.project-list-item:hover { background: #fafbff; }
.project-list-item:last-child { border-bottom: none; }

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 768px) {
  #sidebar { position: fixed; left: -220px; height: 100%; }
  #sidebar.open { left: 0; }
  #sidebar-toggle { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  #editor-actions { gap: 4px; }
  #editor-actions .btn span { display: none; }
  .modal-two-col { grid-template-columns: 1fr; }
  .options-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-inner { padding: 16px; }
}

/* ============================================================
   SPP (Split Page Panel) - 企業情報・レギュレーション共通
   ============================================================ */
#page-company, #page-regulation { display: none; }
#page-company.active, #page-regulation.active { display: flex; flex-direction: column; height: 100%; }

.spp-wrap { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.spp-topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 16px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; min-height: 52px;
}
.spp-tabs-scroll { display: flex; align-items: center; gap: 6px; flex: 1; overflow-x: auto; padding: 8px 0; }
.spp-tabs { display: flex; gap: 4px; }
.spp-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: .83rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; border: 1px solid transparent;
  background: transparent; color: var(--color-text-muted);
  transition: var(--transition);
}
.spp-tab:hover { background: #f1f5f9; color: var(--color-text); }
.spp-tab.active { background: var(--color-primary-light); color: var(--color-primary); border-color: #c7d2fe; font-weight: 700; }
.spp-tab-del {
  width: 16px; height: 16px; border-radius: 50%; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .6rem; color: var(--color-text-muted); background: transparent; cursor: pointer;
}
.spp-tab-del:hover { background: rgba(0,0,0,.12); color: var(--color-text); }

.spp-body { display: flex; flex: 1; overflow: hidden; }

.spp-left {
  width: 280px; min-width: 280px;
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  background: var(--color-surface);
}
.spp-left-toolbar {
  padding: 10px 12px; border-bottom: 1px solid var(--color-border);
  display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap;
}
.spp-items-list { flex: 1; overflow-y: auto; }
.spp-empty-small { padding: 24px 14px; color: var(--color-text-muted); font-size: .83rem; text-align: center; }

.spp-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid #f1f5f9;
  cursor: pointer; transition: var(--transition);
  border-left: 3px solid transparent;
}
.spp-item:hover { background: #fafbff; }
.spp-item.active { background: #eef2ff; border-left-color: var(--color-primary); }
.spp-item-num {
  width: 22px; height: 22px; border-radius: 50%; background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: var(--color-text-muted); flex-shrink: 0; margin-top: 1px;
}
.spp-item.active .spp-item-num { background: var(--color-primary); color: #fff; }
.spp-item-body { flex: 1; min-width: 0; }
.spp-item-label { font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spp-item-sub { font-size: .74rem; color: var(--color-text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spp-item-badges { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.spp-badge { font-size: .63rem; padding: 1px 6px; border-radius: 3px; font-weight: 700; }
.spp-badge.ng-word { background: #fee2e2; color: #991b1b; }
.spp-badge.ng-rule { background: #fef3c7; color: #92400e; }
.spp-badge.imp-high { background: #fee2e2; color: #991b1b; }
.spp-badge.imp-mid  { background: #fef3c7; color: #b45309; }
.spp-badge.imp-low  { background: #f1f5f9; color: #64748b; }

.spp-right { flex: 1; overflow-y: auto; background: #f8fafc; display: flex; flex-direction: column; }
.spp-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; text-align: center; }

.spp-detail { padding: 24px; max-width: 700px; width: 100%; }
.spp-detail-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border);
}
.spp-detail-title { font-size: .95rem; font-weight: 700; color: var(--color-text-muted); }

.imp-selector { display: flex; gap: 6px; }
.imp-btn {
  padding: 5px 14px; border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--color-border); background: #f8fafc; transition: var(--transition);
  color: var(--color-text-muted);
}
.imp-btn:hover { border-color: #94a3b8; }
.imp-btn.active.high { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.imp-btn.active.mid  { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.imp-btn.active.low  { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }

.type-selector { display: flex; gap: 6px; }
.type-btn {
  padding: 5px 14px; border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--color-border); background: #f8fafc; transition: var(--transition);
  color: var(--color-text-muted);
}
.type-btn:hover { border-color: #94a3b8; }
.type-btn.active.ng-word { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.type-btn.active.ng-rule { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

/* ============================================================
   エージェントモーダル
   ============================================================ */
.agent-upload-zone {
  border: 2px dashed var(--color-border); border-radius: var(--radius);
  padding: 32px 24px; text-align: center; transition: var(--transition);
  background: #fafbff; cursor: pointer;
}
.agent-upload-zone:hover, .agent-upload-zone.drag-over { border-color: var(--color-primary); background: var(--color-primary-light); }
.agent-file-selected {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #f0fdf4; border-radius: var(--radius-sm);
  border: 1px solid #86efac; margin-top: 10px;
}
.agent-chat-history {
  max-height: 260px; overflow-y: auto; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); background: #fff; margin-bottom: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.agent-chat-msg { display: flex; gap: 8px; align-items: flex-start; }
.agent-chat-msg.user-msg { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 80%; padding: 8px 12px; border-radius: 12px;
  font-size: .85rem; line-height: 1.5;
}
.agent-chat-msg.ai-msg .chat-bubble { background: #f1f5f9; color: var(--color-text); border-radius: 4px 12px 12px 12px; }
.agent-chat-msg.user-msg .chat-bubble { background: var(--color-primary); color: #fff; border-radius: 12px 4px 12px 12px; }
.chat-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: .75rem; flex-shrink: 0;
}
.agent-chat-msg.ai-msg .chat-avatar { background: #e0e7ff; color: var(--color-primary); }
.agent-chat-msg.user-msg .chat-avatar { background: var(--color-primary); color: #fff; }
.agent-chat-input-wrap { display: flex; gap: 8px; margin-top: 6px; }
.agent-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 0 10px; padding-top: 16px; border-top: 1px solid var(--color-border);
}
.agent-preview-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.agent-preview-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 12px; background: #f8fafc; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}
.agent-preview-item-name { font-weight: 700; min-width: 100px; color: #475569; font-size: .82rem; flex-shrink: 0; }
.agent-preview-item-content { flex: 1; font-size: .84rem; color: var(--color-text); }

/* ============================================================
   NGハイライト（エディタ）
   ============================================================ */
tr.ng-violation > td {
  background: linear-gradient(to right, #fff1f2, #fffafa) !important;
  border-left: 3px solid var(--color-danger) !important;
}
.ng-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px; font-size: .68rem; font-weight: 700;
  background: #fee2e2; color: #991b1b; margin-top: 4px; cursor: help; white-space: nowrap;
}
