/* ── デザイントークン ────────────────────────────────────────────────────────── */
:root {
  /* 背景・サーフェス */
  --c-bg:       #0d1117;
  --c-surface:  #161b22;
  --c-elevated: #21262d;
  --c-border:   #30363d;

  /* テキスト */
  --c-muted:     #484f58;
  --c-secondary: #8b949e;
  --c-text:      #c9d1d9;
  --c-heading:   #e6edf3;

  /* アクセント */
  --c-blue:      #58a6ff;
  --c-blue-dk:   #1f6feb;
  --c-green:     #3fb950;
  --c-red:       #f85149;
  --c-yellow:    #e3b341;
  --c-orange:    #ff7b72;
  --c-purple:    #a371f7;

  /* 共通 */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 10px;
}

* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background:var(--c-bg); color:var(--c-text); }
::-webkit-scrollbar { width:4px; height:4px; }
::-webkit-scrollbar-thumb { background:var(--c-border); border-radius:2px; }

.nav-link { display:flex; align-items:center; gap:8px; padding:6px 10px; border-radius:6px;
            font-size:13px; color:var(--c-secondary); cursor:pointer; transition:all .15s; user-select:none; position:relative; }
.nav-link:hover { background:var(--c-surface); color:var(--c-text); }
.nav-link.active { background:#1f6feb22; color:var(--c-blue); }
.nav-badge { position:absolute; top:5px; right:6px; width:7px; height:7px; border-radius:50%;
             background:var(--c-yellow); border:1.5px solid #010409; }
.nav-section { font-size:10px; color:var(--c-muted); text-transform:uppercase; letter-spacing:0.6px;
               padding:12px 10px 3px; font-weight:600; }

.issue-row { display:flex; align-items:center; gap:10px; padding:14px 16px;
             border-bottom:1px solid var(--c-elevated); cursor:pointer; transition:background .1s; }
.issue-row:hover { background:var(--c-surface); }
.issue-row:last-child { border-bottom:none; }

.badge { display:inline-flex; align-items:center; gap:4px; font-size:11px; font-weight:500;
         padding:2px 8px; border-radius:20px; white-space:nowrap; }
.badge-open   { background:#1f6feb22; color:var(--c-blue); border:1px solid #1f6feb44; }
.badge-closed { background:#3fb95018; color:var(--c-green); border:1px solid #3fb95040; }
.badge-warn   { background:#d29922aa; color:var(--c-yellow); border:1px solid #d2992244; }

.btn { display:inline-flex; align-items:center; gap:6px; padding:5px 14px; border-radius:6px;
       font-size:13px; font-weight:500; cursor:pointer; border:1px solid transparent; transition:opacity .15s; }
.btn:hover { opacity:.85; } .btn:disabled { opacity:.4; cursor:default; }
.btn-primary { background:#238636; color:#fff; border-color:#2ea04322; }
.btn-blue    { background:#1f6feb; color:#fff; }
.btn-outline { background:transparent; color:var(--c-text); border-color:var(--c-border); }
.btn-outline:hover { background:var(--c-surface); }
.btn-danger  { background:transparent; color:var(--c-red); border-color:#f8514930; }
.btn-danger:hover { background:#f8514910; }
.btn-gh { background:#24292f; color:#fff; border-color:#444c56; font-size:14px; padding:10px 20px; }
.btn-gh:hover { background:#2d333b; }
.btn-sm { padding:3px 10px; font-size:12px; }

.input { width:100%; background:var(--c-bg); border:1px solid var(--c-border); border-radius:6px;
         padding:8px 12px; font-size:14px; color:var(--c-text); outline:none; transition:border-color .15s; }
.input:focus { border-color:var(--c-blue); }
.input::placeholder { color:var(--c-muted); }
textarea.input { resize:vertical; }
select.input { cursor:pointer; }

.tag { display:inline-flex; align-items:center; gap:4px; background:#1f6feb22; color:var(--c-blue);
       border:1px solid #1f6feb44; border-radius:20px; padding:2px 10px; font-size:12px; white-space:nowrap; }

.comment-box { background:var(--c-surface); border:1px solid var(--c-border); border-radius:8px; overflow:hidden; }
.comment-header { padding:8px 14px; background:var(--c-elevated); border-bottom:1px solid var(--c-border);
                  font-size:12px; color:var(--c-secondary); display:flex; justify-content:space-between; align-items:center; }

/* Issue 本文（依頼内容）: コメントと区別するための控えめなアクセント */
.comment-box[data-issue-body="1"] {
  border-left: 3px solid var(--c-blue-dk);
  background: #131c2b; /* フォールバック */
  background: color-mix(in srgb, var(--c-surface) 95%, var(--c-blue-dk) 5%);
}

.prose { color:var(--c-text); font-size:14px; line-height:1.7; }
.prose h1 { color:var(--c-heading); font-size:18px; font-weight:600; margin:0 0 12px; }
.prose h2 { color:var(--c-heading); font-size:15px; font-weight:600; margin:20px 0 8px; }
.prose h3 { color:var(--c-text); font-size:14px; font-weight:600; margin:16px 0 6px; }
.prose p  { margin:0 0 10px; }
.prose ul { padding-left:20px; margin:0 0 10px; list-style-type:disc; }
.prose ol { padding-left:20px; margin:0 0 10px; list-style-type:decimal; }
.prose li { margin:3px 0; }
.prose code { background:var(--c-elevated); color:var(--c-orange); padding:1px 5px; border-radius:4px; font-size:13px; }
.prose pre  { background:var(--c-surface); border:1px solid var(--c-border); border-radius:6px; padding:14px; overflow:auto; margin:10px 0; }
.prose pre code { background:none; color:var(--c-text); padding:0; }
.prose a  { color:var(--c-blue); } .prose hr { border:none; border-top:1px solid var(--c-border); margin:16px 0; }
.prose table { width:100%; border-collapse:collapse; font-size:13px; margin:10px 0; }
.prose th { border:1px solid var(--c-border); padding:6px 10px; background:var(--c-elevated); color:var(--c-secondary); text-align:left; }
.prose td { border:1px solid var(--c-border); padding:6px 10px; }
.prose blockquote { border-left:3px solid var(--c-border); padding-left:12px; color:var(--c-secondary); margin:10px 0; }

.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:50;
                 display:flex; align-items:center; justify-content:center; padding:24px; }
.modal { background:var(--c-surface); border:1px solid var(--c-border); border-radius:12px;
         width:100%; max-width:680px; max-height:90vh; overflow-y:auto; }

.spinner { width:16px; height:16px; border:2px solid var(--c-border); border-top-color:var(--c-blue);
           border-radius:50%; animation:spin .7s linear infinite; display:inline-block; }
@keyframes spin { to { transform:rotate(360deg); } }
.fade { animation:fadeIn .15s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

.tab-bar { display:flex; gap:0; border-bottom:1px solid var(--c-border); margin-bottom:20px; }
.tab-btn { padding:8px 16px; font-size:13px; cursor:pointer; background:none; border:none;
           color:var(--c-secondary); border-bottom:2px solid transparent; margin-bottom:-1px; transition:color .15s; }
.tab-btn:hover { color:var(--c-text); }
.tab-btn.active { color:var(--c-blue); border-bottom-color:var(--c-blue); }

.stat-card { background:var(--c-surface); border:1px solid var(--c-border); border-radius:8px; padding:16px 20px; }
.stat-num { font-size:28px; font-weight:700; color:var(--c-heading); line-height:1; }
.stat-label { font-size:12px; color:var(--c-secondary); margin-top:4px; }

.kanban-col { background:var(--c-surface); border:1px solid var(--c-border); border-radius:8px; flex:1; min-width:0; }
.kanban-header { padding:10px 14px; border-bottom:1px solid var(--c-elevated); font-size:13px; font-weight:600; color:var(--c-heading);
                 display:flex; align-items:center; justify-content:space-between; }
.kanban-card { padding:10px 14px; border-bottom:1px solid var(--c-elevated); font-size:13px; color:var(--c-text); cursor:pointer; }
.kanban-card:last-child { border-bottom:none; }
.kanban-card:hover { background:var(--c-elevated); }

/* チュートリアルオーバーレイ */
#tutorial-overlay {
  position: fixed; inset: 0; z-index: 9000;
  pointer-events: none;
}
#tutorial-overlay.active { pointer-events: all; }

.tutorial-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9001;
}

.tutorial-spotlight {
  position: fixed;
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.7);
  z-index: 9002;
  pointer-events: none;
  transition: all 0.3s ease;
}

.tutorial-tooltip {
  position: fixed;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 16px;
  max-width: 280px;
  z-index: 9003;
  color: var(--c-text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.tutorial-tooltip h4 { margin: 0 0 8px; color: var(--c-blue); font-size: 14px; }
.tutorial-tooltip p  { margin: 0 0 12px; font-size: 13px; line-height: 1.5; }
.tutorial-progress { font-size: 11px; color: var(--c-secondary); margin-bottom: 8px; }
.tutorial-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ロール選択モーダル */
#role-select-modal {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
}
.role-card {
  background: var(--c-surface); border: 2px solid var(--c-border);
  border-radius: 12px; padding: 24px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  width: 200px; text-align: center;
}
.role-card:hover { border-color: var(--c-blue); background: #1f6feb22; }

.security-notice { background:var(--c-surface); border:1px solid var(--c-border); border-radius:8px; padding:10px 14px;
                    font-size:12px; color:var(--c-secondary); display:flex; align-items:flex-start; gap:8px; }

/* 外部サービスを表示するパネル（Issues等）— 素通しレイヤーであることを視覚で伝える */
.ext-panel {
  background: var(--c-surface);
  border: 1px solid #3d444d;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset, 0 4px 20px rgba(0,0,0,0.35);
}
.ext-panel[data-provider] {
  border-top: 2px solid var(--ext-accent-color, #444c56);
}
.ext-panel[data-provider="github"]  { --ext-accent-color: #444c56; }
/* .ext-panel[data-provider="linear"]  { --ext-accent-color: #5e6ad2; } */
/* .ext-panel[data-provider="jira"]    { --ext-accent-color: #0052cc; } */

/* #1: FABグループ — 垂直スタック配置（通知ベルのホバーで上方展開） */
#fb-trigger {
  position: fixed; bottom: 82px; right: 24px; z-index: 9200;
  display: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--c-surface); border: 1px solid var(--c-border);
  color: var(--c-secondary); font-size: 14px; padding: 0;
  cursor: pointer; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.2s, transform 0.2s;
  transform: translateY(12px);
  user-select: none;
}
#fb-trigger:hover { background: #1c2128; border-color: var(--c-blue); }
/* Ask FAB */
#ask-fab-btn {
  position: fixed; bottom: 132px; right: 24px; z-index: 9200;
  display: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--c-surface); border: 1px solid var(--c-border);
  color: var(--c-secondary); font-size: 16px; padding: 0;
  cursor: pointer; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.2s, transform 0.2s;
  transform: translateY(12px);
  user-select: none;
}
#ask-fab-btn:hover { background: #1c2128; border-color: var(--c-yellow); }

#app { display:flex; height:100vh; overflow:hidden; }
#login-screen { display:none; position:fixed; inset:0; background:var(--c-bg);
                align-items:center; justify-content:center; z-index:100; }

/* コールドスタート / JS 初期化待ちのローディング画面 */
#loading-screen {
  position:fixed; inset:0; background:var(--c-bg);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  z-index:200; gap:20px;
  transition:opacity .25s ease;
}
#loading-screen.hidden { opacity:0; pointer-events:none; }
.loading-logo {
  width:56px; height:56px; border-radius:14px;
  animation:loadingPulse 2s ease-in-out infinite;
}
@keyframes loadingPulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.6; transform:scale(.96); }
}
.loading-bar-track {
  width:120px; height:2px; background:var(--c-elevated); border-radius:2px; overflow:hidden;
}
.loading-bar-fill {
  height:100%; width:40%; background:#1f6feb;
  border-radius:2px;
  animation:loadingSlide 1.4s ease-in-out infinite;
}
@keyframes loadingSlide {
  0%   { transform:translateX(-100%); }
  100% { transform:translateX(350%); }
}

/* ── ユーティリティクラス ─────────────────────────────────────── */

/* フォームラベル */
.form-label {
  font-size: 12px;
  color: var(--c-secondary);
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

/* ヒントテキスト（グレー小文字） */
.hint {
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 4px;
}

/* 小さいミュートテキスト */
.text-sm-muted {
  font-size: 11px;
  color: var(--c-secondary);
}

/* エラー/危険色テキスト */
.text-danger {
  color: var(--c-red);
}

/* パネル（カード型コンテナ） */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
}

/* セクションタイトル */
.section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--c-heading);
  margin: 0;
}

/* モーダルタイトル */
.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-heading);
  margin: 0;
}

/* インフォボックス（青ボーダー） */
.info-box {
  padding: 10px 12px;
  background: #111820;
  border: 1px solid #1f6feb;
  border-radius: 6px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 11px;
  color: var(--c-secondary);
  line-height: 1.6;
  margin-top: 10px;
}
.info-box strong { color: var(--c-text); }

/* ドロップゾーン */
.dropzone {
  border: 2px dashed var(--c-border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--c-muted);
  cursor: pointer;
  transition: border-color .15s;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--c-blue); }

/* チェックボックス・ラジオのアクセントカラー */
.accent-input { accent-color: var(--c-blue); }

/* ファイルアタッチバー（テキストエリア下部） */
.attach-bar {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.attach-bar-label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--c-secondary);
  font-size: 11px;
}

/* ── 共通コンポーネント ──────────────────────────────────────────────────────── */

/* パネル（カード型コンテナ） */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

/* カードヘッダー */
.card-header {
  padding: 8px 14px;
  border-bottom: 1px solid var(--c-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* カードボディ */
.card-body {
  padding: 10px 14px;
}

/* セクションラベル（右パネルのタイトル等） */
.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* インラインバッジ */
.badge-count {
  font-size: 11px;
  background: var(--c-elevated);
  color: var(--c-secondary);
  border-radius: 10px;
  padding: 1px 7px;
}

/* テキストカラーユーティリティ */
.text-muted    { color: var(--c-muted); }
.text-secondary{ color: var(--c-secondary); }
.text-heading  { color: var(--c-heading); }
.text-blue     { color: var(--c-blue); }
.text-green    { color: var(--c-green); }
.text-red      { color: var(--c-red); }
.text-yellow   { color: var(--c-yellow); }

/* サーフェスユーティリティ */
.bg-surface  { background: var(--c-surface); }
.bg-elevated { background: var(--c-elevated); }
.bg-bg       { background: var(--c-bg); }

/* フォームフィールドラベル */
.field-label {
  font-size: 12px;
  color: var(--c-secondary);
  display: block;
  margin-bottom: 5px;
}
.field-label-bold {
  font-size: 12px;
  color: var(--c-secondary);
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

/* テーブルセル */
.td-right {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-elevated);
  font-size: 13px;
  text-align: right;
}
.th-right {
  padding: 8px 12px;
  text-align: right;
  font-size: 11px;
  color: var(--c-secondary);
  font-weight: 600;
}
.th-left {
  text-align: left;
  padding: 8px 10px;
  color: var(--c-secondary);
  font-weight: 500;
}

/* ページヘッダータイトル */
.page-title { font-size: 20px; font-weight: 600; color: var(--c-heading); margin: 0; }

/* 空状態メッセージ */
.empty-state { padding: 16px; text-align: center; color: var(--c-muted); font-size: 13px; }

/* コードスニペット */
.code-chip {
  background: var(--c-elevated);
  padding: 1px 4px;
  border-radius: 3px;
}

/* テキストエリア・入力の非表示エラー */
.error-text { font-size: 12px; color: var(--c-red); display: none; }

/* ── SP（スマートフォン）レイアウト ────────────────────────────────────────── */
@media (max-width: 767px) {
  /* サイドバーを非表示 */
  #main-sidebar { display: none !important; }
  /* フローティングボタン群を非表示 */
  #tutorial-trigger-btn, #fb-trigger, #notif-btn, #ask-fab-btn { display: none !important; }
  /* コンテンツを全幅に */
  #app { flex-direction: column; }
  #content { padding-bottom: 0; }

  /* 各ページコンテナ（max-width + margin:0 auto）の左右余白を SP ではゼロに */
  #content [style*="margin:0 auto"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
  }

  /* #11: モバイルで固定幅パネルが画面幅を超えないよう横スクロール許可 */
  #wiki-layout, #wiki-layout > *, .fade[style*="display:flex"] { overflow-x: auto; }
  /* カンバンボード */
  [style*="flex:0 0 220px"] { flex: 0 0 180px !important; min-width: 0 !important; }
  /* Gantt行のタイトル列を縮小 */
  [style*="grid-template-columns:260px"] { grid-template-columns: 160px 1fr !important; }
  /* EditorサイドパネルをSPでは非表示 */
  #editor-chat-panel { display: none !important; }

  /* SP 折り畳みセクション */
  .sp-details {
    border: 1px solid var(--c-elevated);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
  }
  .sp-details > summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-secondary);
    background: var(--c-surface);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .sp-details > summary::-webkit-details-marker { display: none; }
  .sp-details > summary::before {
    content: '▶';
    font-size: 9px;
    color: var(--c-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
  }
  .sp-details[open] > summary::before { content: '▼'; }
  .sp-details > summary .sp-summary-meta {
    margin-left: auto;
    font-size: 11px;
    color: var(--c-muted);
    font-weight: 400;
  }
  .sp-details > .sp-details-body {
    padding: 12px 14px;
    background: var(--c-bg);
    border-top: 1px solid var(--c-elevated);
  }

  /* SP 固定チャットバー */
  #sp-chat-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--c-bg);
    border-top: 1px solid var(--c-border);
    z-index: 800;
  }
  #sp-chat-bar .sp-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 6px;
    border-bottom: 1px solid var(--c-elevated);
    cursor: pointer;
  }
  #sp-chat-messages-panel {
    max-height: 220px;
    overflow-y: auto;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  #sp-chat-messages-panel.collapsed { display: none; }
  .sp-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 8px 14px 12px;
    align-items: flex-end;
  }
  .sp-chat-input-row textarea {
    flex: 1;
    max-height: 80px;
    font-size: 16px; /* 16px未満だとiOS Safariが自動ズームするため */
    resize: none;
    border-radius: 20px;
    padding: 8px 14px;
    line-height: 1.4;
  }

  /* SP全体の横スクロール防止 */
  #content {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }
  body, html {
    overflow-x: hidden;
    max-width: 100vw;
  }
}
