/* ─── カラー変数 ─── */
:root {
  --qc-green:     #16a34a;
  --qc-green-lt:  #4ade80;
  --qc-yellow:    #facc15;
  --qc-header-h:  52px;
  --qc-hint-h:    34px;
  --qc-input-h:   48px;
  --qc-bot-w:     320px;
}

/* ─── リセット ─── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; overflow: hidden; background: #f0fdf4; font-family: -apple-system,"Segoe UI",system-ui,sans-serif; }

/* ─── ヘッダー ─── */
.qc-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--qc-header-h);
  background: #004d00;
  color: #fff;
  z-index: 1000;
  user-select: none;
}

.qc-project-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,0.5);
  padding: 0 2px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qc-project-name:hover { border-bottom-color: #fff; }

.qc-room-badge {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
}

.qc-room-copy-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 2px 3px;
  cursor: pointer;
  border-radius: 3px;
  display: flex; align-items: center;
  transition: color 0.15s, background 0.15s;
}
.qc-room-copy-btn:hover { color: #fff; background: rgba(255,255,255,0.15); }

.qc-account-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.qc-account-btn:hover,
.qc-account-btn[aria-expanded="true"] {
  background: rgba(255,255,255,0.3);
  border-color: #ffffff;
}

/* ─── ステップゲージ ─── */
.step-gauge-cell {
  width: 28px; height: 28px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.step-gauge-cell.done   { background: rgba(255,255,255,0.25); color: #fff; }
.qc-recopy-btn {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 4px;
  color: #fff;
  padding: 0;
}
.qc-recopy-btn:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.qc-recopy-btn:disabled { opacity: 0.35; cursor: default; }
.step-gauge-cell.locked { cursor: default; }
.step-gauge-ai { width: 32px; margin-left: 4px; }
.step-gauge-ai.disabled { opacity: 0.35; cursor: default; }
.step-gauge-ai.active { background: #ffffff; color: #166534; border-color: #ffffff; }
.step-gauge-cell.active { background: var(--qc-yellow); color: #1a1a1a; border-color: var(--qc-yellow); }

/* ─── キャンバスエリア ─── */
#canvasContainer {
  position: fixed;
  top: var(--qc-header-h);
  left: 0; right: 0;
  bottom: calc(var(--qc-hint-h) + var(--qc-input-h));
  /* ブラウザを拡大してキャンバスが入りきらないときはスクロール */
  overflow: auto;
  scrollbar-color: #9ca3af #f3f4f6;   /* Firefox */
}
/* スクロールバーを常に表示（Windows の Edge/Chrome は自動で隠れることがあるため） */
#canvasContainer::-webkit-scrollbar { width: 12px; height: 12px; }
#canvasContainer::-webkit-scrollbar-track { background: #f3f4f6; }
#canvasContainer::-webkit-scrollbar-thumb { background: #9ca3af; border-radius: 6px; border: 2px solid #f3f4f6; }
#canvasContainer::-webkit-scrollbar-thumb:hover { background: #6b7280; }
#canvasContainer::-webkit-scrollbar-corner { background: #f3f4f6; }

/* ─── ヒントバー ─── */
.qc-hint-bar {
  position: fixed;
  bottom: var(--qc-input-h);
  left: 0; right: 0;
  height: var(--qc-hint-h);
  background: #dcfce7;
  border-top: 1px solid #bbf7d0;
  display: flex; align-items: center;
  padding: 0 16px;
  font-size: 0.8rem;
  color: #166534;
  z-index: 100;
}

/* ─── テキスト入力バー（1行） ─── */
.qc-input-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--qc-input-h);
  background: #fff;
  border-top: 1px solid #e5e7eb;
  z-index: 100;
}
/* textInput は flex:1 で伸びる */
.qc-input-bar input {
  flex: 1;
  min-width: 0;
}

/* Material Icons のサイズ統一 */
.qc-tool-icon {
  font-size: 20px;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}

/* ツールアイコンボタン */
.qc-tool-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 1.05rem;
  color: #374151;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
}
.qc-tool-btn:hover {
  background: #e9ecef;
  border-color: #ced4da;
}

.qc-next-color-btn {
  --next-box-color: #d5f5e3;
  --next-box-border-color: #52b77a;
  background: var(--next-box-color);
  border: 2px solid var(--next-box-border-color);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.65);
}

.qc-next-color-btn .qc-tool-icon {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.qc-next-color-btn:hover {
  background: var(--next-box-color);
  border-color: var(--next-box-border-color);
  filter: brightness(0.97);
}

/* 投稿する種類の選択 */
.qc-kind-select {
  width: auto;
  max-width: 130px;
  font-size: 0.78rem;
  padding-top: 2px; padding-bottom: 2px;
}

/* ツールバー区切り線 */
.qc-tool-sep {
  width: 1px; height: 20px;
  background: #dee2e6;
  margin: 0 4px;
}

/* コネクタトグル */
.qc-tool-toggle {
  display: flex; align-items: center; gap: 4px;
  margin: 0; padding: 0 4px;
  font-size: 0.78rem;
  white-space: nowrap;
}
.qc-tool-toggle .form-check-input { margin: 0; }

/* ドロップダウン内のラベル */
.qc-drop-label {
  display: block;
  font-size: 0.7rem;
  color: #6c757d;
  padding: 4px 10px 2px;
}

/* カラードロップダウン（14色対応で幅を広げる） */
.qc-color-drop { min-width: 210px; padding: 4px 0; }

/* ─── BOX コンテキストメニュー / コネクタ選択パネル ─── */
.qc-box-menu,
.qc-conn-panel {
  position: fixed;
  z-index: 2000;
  min-width: 160px;
  max-width: 220px;
}
.qc-color-btn {
  width: 24px; height: 24px;
  padding: 0; border-radius: 4px;
  cursor: pointer;
}


/* ─── Offcanvas ─── */
.offcanvas { max-width: 260px; }

/* ─── search type の ×ボタンを非表示 ─── */
input[type="search"]::-webkit-search-cancel-button { display: none; }
input[type="search"]::-webkit-search-decoration { display: none; }

/* ─── ヒントバーの文字と「司会進行」チェック ─── */
.qc-hint-text {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qc-bot-toggle {
  display: flex; align-items: center; gap: 4px;
  margin-left: 12px;
  white-space: nowrap;
  cursor: pointer;
}

/* ─── 司会進行Bot パネル ─── */
.qc-bot-panel {
  position: fixed;
  top: var(--qc-header-h);
  right: 0;
  bottom: calc(var(--qc-hint-h) + var(--qc-input-h));
  width: var(--qc-bot-w);
  background: #ffffff;
  border-left: 1px solid #d1d5db;
  display: none;
  flex-direction: column;
  z-index: 90;
}
.qc-bot-tab {
  position: fixed;
  top: calc(var(--qc-header-h) + 12px);
  right: 0;
  width: 36px; height: 40px;
  border: 1px solid #d1d5db; border-right: none;
  border-radius: 8px 0 0 8px;
  background: #ffffff;
  font-size: 1.1rem;
  display: none;
  z-index: 90;
  box-shadow: -2px 2px 6px rgba(0,0,0,0.08);
}
body.qc-bot-on:not(.qc-bot-collapsed) .qc-bot-panel { display: flex; }
body.qc-bot-on.qc-bot-collapsed .qc-bot-tab { display: block; }
body.qc-bot-on:not(.qc-bot-collapsed) #canvasContainer { right: var(--qc-bot-w); }

.qc-bot-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  background: #dcfce7;
  border-bottom: 1px solid #bbf7d0;
  font-weight: 600; font-size: 0.85rem; color: #166534;
}
.qc-bot-head-btn {
  background: none; border: none; color: #166534;
  padding: 0 4px; cursor: pointer;
}
.qc-bot-log {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 0.8rem;
}
.qc-bot-msg {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 6px 8px;
  line-height: 1.5;
}
.qc-bot-intro  { background: #ecfdf5; border: 1px solid #bbf7d0; }
.qc-bot-active { background: #fefce8; border: 1px solid #fde68a; }
.qc-bot-warn   { background: #fff7ed; border: 1px solid #fdba74; }
.qc-bot-note   { color: #6b7280; margin-top: 2px; }
.qc-bot-btns   { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.qc-bot-btns .btn { font-size: 0.75rem; padding: 1px 8px; }
.qc-bot-answer {
  align-self: flex-end;
  max-width: 85%;
  background: #dbeafe;
  border-radius: 8px;
  padding: 4px 8px;
  word-break: break-word;
}
.qc-bot-kind {
  display: inline-block;
  font-size: 0.65rem;
  background: #374151; color: #fff;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 4px;
}
.qc-bot-action { color: #9ca3af; font-size: 0.72rem; text-align: right; }
.qc-bot-input {
  border-top: 1px solid #e5e7eb;
  padding: 6px 8px;
}
.qc-bot-input .qc-kind-select { max-width: none; flex: 1; }

/* スマホ幅：下からのシート（キャンバスは狭めない） */
@media (max-width: 767px) {
  .qc-bot-panel {
    top: auto; left: 0; width: auto;
    height: 45vh;
    border-left: none; border-top: 1px solid #d1d5db;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  }
  body.qc-bot-on:not(.qc-bot-collapsed) #canvasContainer { right: 0; }
  .qc-bot-tab { top: auto; bottom: calc(var(--qc-hint-h) + var(--qc-input-h) + 12px); }
}

/* 司会の表示 */
.qc-bot-role {
  font-size: 0.7rem; font-weight: 500;
  background: #ffffff; color: #6b7280;
  border: 1px solid #d1d5db; border-radius: 999px;
  padding: 0 8px;
}
.qc-bot-role-me { background: #166534; color: #ffffff; border-color: #166534; }

/* パネル内のアイコン（Bootstrap Icons） */
.qc-bot-ic      { margin-right: 4px; color: #166534; }
.qc-bot-ic-hint { color: #ca8a04; }
.qc-bot-ic-warn { color: #ea580c; }
.qc-bot-tab .bi { color: #166534; }

/* ─── ［AI］タブ：AI 集計分析の結果 ─── */
.qc-ai-view {
  position: fixed;
  top: var(--qc-header-h);
  left: 0; right: 0;
  bottom: calc(var(--qc-hint-h) + var(--qc-input-h));
  background: #ffffff;
  display: none;
  flex-direction: column;
  padding: 10px 16px;
  gap: 6px;
  z-index: 80;
}
body.qc-ai-open .qc-ai-view { display: flex; }
body.qc-bot-on:not(.qc-bot-collapsed) .qc-ai-view { right: var(--qc-bot-w); }
.qc-ai-view-head { display: flex; align-items: center; gap: 10px; color: #166534; }
.qc-ai-view-status:empty { display: none; }
.qc-ai-view-text {
  flex: 1; min-height: 0;
  resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  background: #fafafa;
}
@media (max-width: 767px) {
  body.qc-bot-on:not(.qc-bot-collapsed) .qc-ai-view { right: 0; }
}

/* パネル内の AI とのやり取り */
.qc-bot-ask { background: #ede9fe; }
.qc-bot-ai  { background: #f5f3ff; border: 1px solid #ddd6fe; }
.qc-bot-ai-head { font-size: 0.72rem; color: #5b21b6; margin-bottom: 2px; }

/* パネルの幅を変えるつまみ（左端） */
.qc-bot-panel { position: fixed; }
.qc-bot-resizer {
  position: absolute; left: -4px; top: 0; bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 1;
}
.qc-bot-resizer:hover, body.qc-bot-resizing .qc-bot-resizer { background: rgba(22, 101, 52, 0.25); }
body.qc-bot-resizing { cursor: col-resize; user-select: none; }
@media (max-width: 767px) { .qc-bot-resizer { display: none; } }

/* ─── ヘッダー：サーバーの状態と接続中のブラウザ数 ─── */
.qc-status {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff; font-size: 0.75rem;
  white-space: nowrap;
  cursor: default;
}
.qc-status-dot { width: 9px; height: 9px; border-radius: 50%; }
.qc-status-ok   .qc-status-dot { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.qc-status-wait .qc-status-dot { background: #facc15; animation: qc-blink 1s infinite; }
.qc-status-down .qc-status-dot { background: #ef4444; }
.qc-status-down { border-color: #fca5a5; }
.qc-status-sep { width: 1px; height: 12px; background: rgba(255,255,255,0.35); }
@keyframes qc-blink { 50% { opacity: 0.3; } }

/* ─── Markdown の書式付き表示（AI の結果・AI の回答） ─── */
.qc-ai-view-doc {
  flex: 1; min-height: 0;
  overflow: auto;
  padding: 12px 20px;
  border: 1px solid #d1d5db; border-radius: 6px;
  background: #ffffff;
}
.qc-md { font-size: 0.9rem; line-height: 1.75; color: #1f2937; word-break: break-word; }
.qc-md h1 { font-size: 1.4rem; margin: 0.4em 0 0.6em; padding-bottom: 0.3em; border-bottom: 2px solid #bbf7d0; color: #166534; }
.qc-md h2 { font-size: 1.2rem; margin: 1.4em 0 0.5em; padding-bottom: 0.2em; border-bottom: 1px solid #e5e7eb; color: #166534; }
.qc-md h3 { font-size: 1.05rem; margin: 1.1em 0 0.4em; }
.qc-md h4, .qc-md h5, .qc-md h6 { font-size: 0.95rem; margin: 1em 0 0.3em; }
.qc-md p { margin: 0 0 0.7em; }
.qc-md ul, .qc-md ol { margin: 0 0 0.7em; padding-left: 1.5em; }
.qc-md li { margin: 0.15em 0; }
.qc-md table { border-collapse: collapse; margin: 0.5em 0 1em; font-size: 0.85rem; }
.qc-md th, .qc-md td { border: 1px solid #d1d5db; padding: 4px 10px; vertical-align: top; }
.qc-md th { background: #f0fdf4; }
.qc-md blockquote { margin: 0.5em 0 1em; padding: 4px 12px; border-left: 4px solid #bbf7d0; background: #f9fafb; color: #374151; }
.qc-md code { background: #f3f4f6; padding: 0 4px; border-radius: 3px; font-size: 0.85em; }
.qc-md pre { background: #f3f4f6; padding: 8px 12px; border-radius: 6px; overflow: auto; }
.qc-md pre code { background: none; padding: 0; }
.qc-md hr { margin: 1.2em 0; border-color: #e5e7eb; }
/* パネルの AI の回答は小さめに */
.qc-md-compact { font-size: 0.8rem; line-height: 1.6; }
.qc-md-compact h1, .qc-md-compact h2, .qc-md-compact h3 { font-size: 0.9rem; margin: 0.6em 0 0.3em; border: none; padding: 0; }
.qc-md-compact > :last-child { margin-bottom: 0; }
