/* =====================================================
   Multi-Agent AI — style.css v4.0
   ===================================================== */

/* ─── CSS Variables ──────────────────────────────────── */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface2:     #21262d;
  --border:       #30363d;
  --accent:       #58a6ff;
  --accent-dim:   #1f6feb;
  --accent-glow:  rgba(88,166,255,0.12);
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #484f58;
  --user-bg:      #1f6feb;
  --ai-bg:        #21262d;
  --error-bg:     #3d1a1a;
  --error-text:   #f85149;
  --success:      #3fb950;
  --warning:      #d29922;

  /* diff */
  --diff-add-bg:  rgba(63,185,80,0.15);
  --diff-del-bg:  rgba(248,81,73,0.15);
  --diff-add-txt: #3fb950;
  --diff-del-txt: #f85149;
  --diff-hunk-bg: rgba(88,166,255,0.10);
  --diff-hunk-txt:#58a6ff;
  --diff-head-bg: rgba(255,255,255,0.04);

  --radius:       12px;
  --radius-sm:    8px;
  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

/* ─── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; height: 100dvh; overflow: hidden; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
button { cursor: pointer; font-family: inherit; }
textarea { font-family: inherit; resize: none; }
ul { list-style: none; }

/* ─── App Layout ─────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

/* ─── Header ─────────────────────────────────────────── */
.header { background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; z-index: 100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 56px; max-width: 1400px; margin: 0 auto; width: 100%; }
.header-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; white-space: nowrap; }
.header-icon { font-size: 20px; }
.version-badge { font-size: 10px; background: var(--accent-dim); color: #fff; padding: 2px 7px; border-radius: 20px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 14px; }

/* ─── Tabs ───────────────────────────────────────────── */
.tab-group { display: flex; gap: 4px; background: var(--bg); border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--border); }
.tab-btn { background: transparent; border: none; color: var(--text-muted); padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; transition: all .15s; white-space: nowrap; }
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { background: var(--accent-dim); color: #fff; }

/* ─── Status Badge ───────────────────────────────────── */
.status-badge { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); transition: background .3s; }
.status-dot.idle    { background: var(--success); }
.status-dot.running { background: var(--warning); animation: pulse 1s infinite; }
.status-dot.error   { background: var(--error-text); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* ─── Panel ──────────────────────────────────────────── */
.panel { display: none; flex: 1; flex-direction: column; overflow: hidden; min-height: 0; }
.panel.active { display: flex; min-height: 0; }

/* ═══════════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════════ */
.chat-area { flex: 1; overflow-y: auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; min-height: 0; }
.chat-area::-webkit-scrollbar { width: 6px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.welcome { text-align: center; padding: 40px 20px; max-width: 560px; margin: auto; }
.welcome-icon { font-size: 48px; margin-bottom: 16px; }
.welcome h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.welcome p { color: var(--text-muted); margin-bottom: 24px; }
.example-prompts { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.example-label { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.example-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 8px 16px; border-radius: var(--radius); font-size: 13px; transition: all .15s; width: 100%; max-width: 420px; text-align: left; }
.example-btn:hover { border-color: var(--accent); background: var(--surface); }
/* v8.15: テンプレートボタンバー（入力欄下部） */
.template-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 2px;
}
.tmpl-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.tmpl-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface);
}


.message-row { display: flex; gap: 10px; align-items: flex-start; animation: fadeIn .2s ease; }
.message-row.user { flex-direction: row-reverse; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.message-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; background: var(--surface2); border: 1px solid var(--border); }
.message-bubble { max-width: 72%; background: var(--ai-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.message-row.user .message-bubble { background: var(--user-bg); border-color: var(--accent-dim); }
.message-text { white-space: pre-wrap; word-break: break-word; }
.message-meta { margin-top: 6px; font-size: 11px; color: var(--text-muted); }

.loading-bubble { background: var(--ai-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.loading-dots { display: flex; gap: 4px; }
.loading-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce .8s infinite; }
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100% { transform:scale(0); } 40% { transform:scale(1); } }
.loading-label { font-size: 12px; color: var(--text-muted); }

.error-bubble { background: var(--error-bg); border: 1px solid var(--error-text); border-radius: var(--radius); padding: 10px 14px; color: var(--error-text); max-width: 72%; }

.task-list { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.task-list-title { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.task-item { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0; }
.task-status.done    { color: var(--success); }
.task-status.failed  { color: var(--error-text); }
.task-status.pending { color: var(--warning); }

.log-accordion { margin-top: 8px; }
.log-toggle { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 4px 10px; border-radius: var(--radius-sm); font-size: 11px; transition: all .15s; }
.log-toggle:hover { border-color: var(--accent); color: var(--text); }
.log-content { display: none; margin-top: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; max-height: 200px; overflow-y: auto; font-family: var(--font-mono); font-size: 11px; }
.log-content.open { display: block; }
.log-line { padding: 1px 0; color: var(--text-muted); }
.log-line.error { color: var(--error-text); }
.log-line.warn  { color: var(--warning); }
.log-line.info  { color: var(--text); }

/* Stream Panel */
.stream-panel { flex-shrink: 0; background: var(--surface); border-top: 1px solid var(--border); overflow: hidden; max-height: 200px; transition: max-height .3s ease; }
.stream-panel.collapsed { max-height: 40px; }
.stream-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; cursor: pointer; user-select: none; }
.stream-panel-title { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stream-toggle-btn { background: none; border: none; color: var(--text-dim); font-size: 10px; padding: 2px 6px; border-radius: 4px; transition: all .15s; }
.stream-toggle-btn:hover { background: var(--surface2); color: var(--text); }
.stream-log { height: 152px; overflow-y: auto; padding: 4px 16px 8px; font-family: var(--font-mono); font-size: 11px; line-height: 1.6; }
.stream-log::-webkit-scrollbar { width: 4px; }
.stream-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.stream-entry { display: flex; gap: 8px; padding: 2px 0; animation: fadeIn .15s ease; }
.stream-entry-time    { color: var(--text-dim); flex-shrink: 0; }
.stream-entry-agent   { color: var(--accent); font-weight: 600; flex-shrink: 0; min-width: 70px; }
.stream-entry-content { color: var(--text-muted); flex: 1; word-break: break-word; }
.stream-entry.type-error .stream-entry-content { color: var(--error-text); }
.stream-entry.type-done  .stream-entry-content { color: var(--success); }
.stream-entry.type-plan  .stream-entry-agent   { color: var(--warning); }

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Input Area */
.input-area { border-top: 1px solid var(--border); padding: 12px 20px 16px; background: var(--surface); flex-shrink: 0; position: sticky; bottom: 0; z-index: 10; }
.input-inner { display: flex; gap: 8px; align-items: flex-end; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; transition: border-color .15s; }
.input-inner:focus-within { border-color: var(--accent); }
.message-input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 14px; line-height: 1.6; max-height: 160px; overflow-y: auto; }
.message-input::placeholder { color: var(--text-dim); }
.input-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stream-mode-toggle { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); cursor: pointer; user-select: none; white-space: nowrap; }
.stream-mode-toggle input { accent-color: var(--accent); }
.send-btn { width: 36px; height: 36px; background: var(--accent-dim); border: none; border-radius: var(--radius-sm); color: #fff; display: flex; align-items: center; justify-content: center; transition: all .15s; flex-shrink: 0; }
.send-btn:hover:not(:disabled) { background: var(--accent); transform: scale(1.05); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.input-hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; text-align: center; }
.clear-history-btn { background: none; border: none; color: var(--text-dim); font-size: 11px; cursor: pointer; padding: 1px 5px; border-radius: 4px; transition: color .2s, background .2s; }
.clear-history-btn:hover { color: var(--error-text); background: rgba(248,81,73,0.1); }

/* ═══════════════════════════════════════════════════════
   UPLOAD PANEL
   ═══════════════════════════════════════════════════════ */
.upload-panel { display: flex; gap: 20px; height: 100%; padding: 20px; overflow: hidden; }
.upload-left { flex: 0 0 360px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.upload-left::-webkit-scrollbar { width: 4px; }
.upload-left::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.upload-right { flex: 1; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; min-width: 0; }
.upload-right::-webkit-scrollbar { width: 4px; }
.upload-right::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.pane-title { font-size: 15px; font-weight: 700; color: var(--text); padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 20px; text-align: center; cursor: pointer; transition: all .2s; background: var(--surface); }
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: var(--accent-glow); }
.drop-zone-icon { font-size: 36px; margin-bottom: 10px; }
.drop-zone-text { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.drop-zone-hint { font-size: 11px; color: var(--text-muted); }

.selected-files { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.selected-files-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.clear-btn { background: none; border: none; color: var(--error-text); font-size: 12px; padding: 2px 6px; border-radius: 4px; transition: background .15s; }
.clear-btn:hover { background: var(--error-bg); }
.file-list { list-style: none; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.file-item:last-child { border-bottom: none; }
.file-icon { font-size: 16px; flex-shrink: 0; }
.file-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-muted); flex-shrink: 0; }
.file-remove-btn { background: none; border: none; color: var(--text-dim); font-size: 14px; padding: 2px 4px; border-radius: 4px; transition: all .15s; flex-shrink: 0; }
.file-remove-btn:hover { color: var(--error-text); background: var(--error-bg); }

.upload-message-row { display: flex; flex-direction: column; gap: 6px; }
.upload-message-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.upload-message-input { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; padding: 8px 10px; transition: border-color .15s; }
.upload-message-input:focus { outline: none; border-color: var(--accent); }
.upload-message-input::placeholder { color: var(--text-dim); }

.upload-btn { background: var(--accent-dim); border: none; border-radius: var(--radius-sm); color: #fff; font-size: 14px; font-weight: 600; padding: 12px; transition: all .15s; width: 100%; }
.upload-btn:hover:not(:disabled) { background: var(--accent); }
.upload-btn:active:not(:disabled) { transform: scale(.98); }
.upload-btn:disabled { opacity: .4; cursor: not-allowed; }

.upload-progress { display: flex; flex-direction: column; gap: 6px; }
.progress-bar-wrap { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; width: 0%; transition: width .3s ease; }
.progress-label { font-size: 12px; color: var(--text-muted); text-align: center; }

.result-summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 13px; line-height: 1.7; }
.result-summary-card .summary-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.result-summary-card .summary-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.summary-meta-item { display: flex; align-items: center; gap: 4px; }

.result-tasks { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.result-tasks-title { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text-muted); }
.result-tasks ul { list-style: none; }
.result-tasks li { padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.result-tasks li:last-child { border-bottom: none; }

/* ═══════════════════════════════════════════════════════
   DIFF 表示（色付き）
   ═══════════════════════════════════════════════════════ */
.diff-section { display: flex; flex-direction: column; gap: 12px; }

.diff-section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.diff-section-title { font-size: 13px; font-weight: 700; }

.diff-legend-row { display: flex; gap: 10px; flex-wrap: wrap; }
.diff-legend { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; font-family: var(--font-mono); }
.diff-legend.added   { background: var(--diff-add-bg); color: var(--diff-add-txt); }
.diff-legend.removed { background: var(--diff-del-bg); color: var(--diff-del-txt); }
.diff-legend.context { background: var(--surface2); color: var(--text-dim); }

.diff-file-block { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }

.diff-file-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; background: var(--diff-head-bg); border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.diff-file-name { font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.diff-file-stats { display: flex; gap: 10px; font-size: 12px; }
.diff-stat-added   { color: var(--diff-add-txt); font-weight: 600; }
.diff-stat-removed { color: var(--diff-del-txt); font-weight: 600; }
.diff-no-change    { color: var(--text-dim); font-size: 12px; font-style: italic; }

.diff-body { overflow-x: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; }
.diff-body::-webkit-scrollbar { height: 4px; }
.diff-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.diff-line { display: flex; min-width: 0; padding: 0 14px; }
.diff-line.added   { background: var(--diff-add-bg); }
.diff-line.removed { background: var(--diff-del-bg); }
.diff-line.hunk    { background: var(--diff-hunk-bg); }
.diff-line.header  { background: var(--diff-head-bg); }

.diff-line-num { min-width: 40px; color: var(--text-dim); user-select: none; flex-shrink: 0; padding-right: 12px; border-right: 1px solid var(--border); margin-right: 12px; text-align: right; }
.diff-line-prefix { min-width: 14px; flex-shrink: 0; font-weight: 700; }
.diff-line.added   .diff-line-prefix { color: var(--diff-add-txt); }
.diff-line.removed .diff-line-prefix { color: var(--diff-del-txt); }
.diff-line.hunk    .diff-line-prefix { color: var(--diff-hunk-txt); }

.diff-line-content { flex: 1; white-space: pre; overflow: hidden; }
.diff-line.added   .diff-line-content { color: var(--diff-add-txt); }
.diff-line.removed .diff-line-content { color: var(--diff-del-txt); }
.diff-line.hunk    .diff-line-content { color: var(--diff-hunk-txt); }
.diff-line.header  .diff-line-content { color: var(--text-dim); }

.download-section { display: flex; flex-direction: column; gap: 8px; }
.download-section-title { font-size: 13px; font-weight: 700; }
.download-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; padding: 8px 14px; cursor: pointer; text-decoration: none; transition: all .15s; margin-right: 8px; margin-bottom: 4px; }
.download-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }

.preview-link-section { margin-top: 4px; }
.preview-link-btn { background: rgba(88,166,255,.1); border: 1px solid var(--accent); border-radius: var(--radius-sm); color: var(--accent); font-size: 13px; font-weight: 600; padding: 10px 16px; cursor: pointer; transition: background .15s; width: 100%; }
.preview-link-btn:hover { background: rgba(88,166,255,.2); }

/* ═══════════════════════════════════════════════════════
   PREVIEW PANEL
   ═══════════════════════════════════════════════════════ */
#panelPreview { flex-direction: column; }

.preview-panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.preview-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; gap: 10px; }

.preview-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.preview-select { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; padding: 6px 10px; cursor: pointer; min-width: 200px; outline: none; }
.preview-select:focus { border-color: var(--accent); }

.preview-refresh-btn,
.preview-open-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 13px; padding: 6px 12px; cursor: pointer; transition: all .15s; white-space: nowrap; }
.preview-refresh-btn:hover,
.preview-open-btn:hover { background: var(--surface); color: var(--text); border-color: var(--accent); }

.preview-container { flex: 1; overflow: hidden; position: relative; }

.preview-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); color: var(--text-muted); text-align: center; padding: 40px; }
.preview-empty-icon { font-size: 48px; }
.preview-empty p    { font-size: 14px; line-height: 1.7; }
.preview-empty-hint { font-size: 12px; color: var(--text-dim); }

.preview-iframe { width: 100%; height: 100%; border: none; background: #fff; }

/* ═══════════════════════════════════════════════════════
   LOG PANEL
   ═══════════════════════════════════════════════════════ */
#panelLog { flex-direction: column; }

.log-container { display: flex; flex-direction: column; height: 100%; overflow: hidden; padding: 20px; gap: 12px; }

.log-header { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; flex-wrap: wrap; gap: 8px; }

.log-controls { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-muted); }
.log-controls label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.log-controls input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

.clear-log-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; padding: 3px 10px; cursor: pointer; transition: all .15s; }
.clear-log-btn:hover { background: var(--surface2); color: var(--text); }

.log-viewer { flex: 1; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-family: var(--font-mono); font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.log-viewer::-webkit-scrollbar { width: 4px; }
.log-viewer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.log-empty { color: var(--text-dim); text-align: center; padding: 40px; font-family: inherit; font-size: 13px; }

.log-entry { display: flex; gap: 8px; line-height: 1.5; padding: 2px 0; }
.log-entry .le-time  { color: var(--text-dim); flex-shrink: 0; min-width: 80px; }
.log-entry .le-level { font-weight: 700; flex-shrink: 0; min-width: 45px; }
.log-entry.INFO  .le-level { color: var(--accent); }
.log-entry.WARN  .le-level { color: var(--warning); }
.log-entry.ERROR .le-level { color: var(--error-text); }
.log-entry .le-msg { color: var(--text-muted); word-break: break-word; flex: 1; }

/* ─── Scrollbar Global ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Header: 2行レイアウト */
  .header { position: sticky; top: 0; z-index: 200; }
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 6px;
  }
  .header-title {
    font-size: 14px;
    flex: 1;
    min-width: 0;
  }
  .header-right {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  /* タブをスクロール可能に */
  .tab-group {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .tab-group::-webkit-scrollbar { display: none; }
  .tab-btn {
    font-size: 12px;
    padding: 6px 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  /* ユーザー情報を折り返し */
  .user-email {
    display: none; /* スマホでは非表示 */
  }
  .user-plan {
    font-size: 10px;
    padding: 2px 5px;
  }
  .auth-btn {
    font-size: 11px;
    padding: 5px 8px;
  }
  .auth-btn-admin {
    display: none; /* スマホでは管理パネルボタン非表示 */
  }
  /* 使用回数バッジ */
  .usage-badge {
    font-size: 11px;
    padding: 3px 7px;
  }
  /* ステータスバッジ */
  .status-badge span:last-child {
    display: none; /* テキスト非表示、ドットのみ */
  }
  /* チャットエリア */
  .chat-area {
    padding: 12px;
    gap: 12px;
  }
  .message-bubble {
    max-width: 88%;
    font-size: 13px;
  }
  /* 入力エリア */
  .input-area {
    padding: 8px 12px env(safe-area-inset-bottom, 10px);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
    z-index: 50;
  }
  .input-inner {
    padding: 8px 10px;
  }
  .message-input {
    font-size: 16px; /* iOS ズーム防止 */
  }
  .stream-mode-toggle {
    display: none; /* スマホでは非表示 */
  }
  .input-hint {
    font-size: 10px;
  }
  /* ウェルカム画面 */
  .welcome {
    padding: 24px 12px;
  }
  .welcome h2 {
    font-size: 17px;
  }
  .example-btn {
    font-size: 12px;
    padding: 8px 12px;
    max-width: 100%;
  }
  /* アップロードパネル */
  .upload-panel {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
    overflow-y: auto;
  }
  .upload-left {
    flex: none;
    width: 100%;
  }
  .upload-right {
    flex: none;
    width: 100%;
  }
  /* プレビュー */
  .preview-select { min-width: 120px; font-size: 12px; }
  .preview-header {
    flex-wrap: wrap;
    gap: 6px;
  }
  .preview-controls {
    flex-wrap: wrap;
    gap: 4px;
  }
  /* ログ */
  .log-header {
    flex-wrap: wrap;
    gap: 6px;
  }
  .log-controls {
    flex-wrap: wrap;
    gap: 6px;
  }
  /* モーダル */
  .modal-box {
    width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px 16px;
  }
  /* 管理パネル */
  .admin-panel-box {
    width: 98vw;
    max-height: 95vh;
    overflow-y: auto;
    padding: 16px 12px;
  }
  .admin-table th,
  .admin-table td {
    font-size: 11px;
    padding: 6px 8px;
  }
  .admin-cell-email {
    max-width: 120px;
  }
  /* ストリームパネル */
  .stream-panel {
    max-height: 140px;
  }
  .stream-log {
    height: 100px;
  }
  /* アップグレードモーダル */
  .upgrade-box {
    width: 95vw;
    padding: 24px 16px;
  }
  .upgrade-features {
    grid-template-columns: 1fr;
  }
}

/* ─── Auth Buttons (Header) ──────────────────────────── */
#authButtons {
  display: flex;
  align-items: center;
  gap: 6px;
}
#userInfo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-email {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-plan {
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--accent);
}
.auth-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 5px 10px;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.auth-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}
.auth-btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}
.auth-btn-primary:hover {
  background: var(--accent);
}

/* ─── Auth Modal ─────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }
.modal-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 20px;
}
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.form-group input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  box-sizing: border-box;
  transition: border-color 0.15s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent);
}
.form-error {
  color: var(--error-text);
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 10px;
}
.form-submit-btn {
  width: 100%;
  background: var(--accent-dim);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 11px;
  transition: background 0.15s;
  margin-bottom: 14px;
}
.form-submit-btn:hover {
  background: var(--accent);
}
.form-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.form-switch a {
  color: var(--accent);
  text-decoration: none;
}
.form-switch a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════
   UPGRADE MODAL — Pro誘導モーダル
   ═══════════════════════════════════════════════════════ */
.upgrade-modal-box {
  text-align: center;
  max-width: 420px;
}
.upgrade-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}
.upgrade-title {
  color: #f59e0b;
  margin-bottom: 0.75rem;
}
.upgrade-desc {
  color: #94a3b8;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}
.upgrade-features {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  text-align: left;
}
.upgrade-feature {
  color: #e2e8f0;
  padding: 0.3rem 0;
  font-size: 0.9rem;
}
.upgrade-btn {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 0.75rem;
}
.upgrade-btn:hover {
  opacity: 0.9;
}
.upgrade-note {
  color: #64748b;
  font-size: 0.78rem;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════
   使用回数バッジ
   ═══════════════════════════════════════════════════════ */
.usage-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  min-width: 48px;
  cursor: default;
  transition: background 0.3s, color 0.3s;
}
.usage-badge.usage-ok {
  background: rgba(34, 197, 94, 0.18);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.35);
}
.usage-badge.usage-warn {
  background: rgba(251, 146, 60, 0.18);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.35);
}
.usage-badge.usage-limit {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
  animation: pulse-red 1.5s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* 文字カウンター */
.char-counter {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: right;
  padding: 2px 4px 0 0;
  transition: color 0.2s, font-weight 0.2s;
  user-select: none;
}

/* ═══════════════════════════════════════════════════════
   管理者パネル CSS
   ═══════════════════════════════════════════════════════ */
.user-role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0 4px;
}
.user-role-badge.role-owner { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.user-role-badge.role-admin { background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; }

.auth-btn-admin {
  background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
  color: #fff !important;
  border: none !important;
}
.auth-btn-admin:hover { opacity: 0.9; }

.admin-modal-box {
  background: #1e1e2e;
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.1);
}
.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 8px;
}
.admin-tab {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #a0a0b0;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.admin-tab.active { background: #6366f1; color: #fff; border-color: #6366f1; }
.admin-tab-content { display: block; }
.admin-actions { margin-bottom: 12px; }
.admin-refresh-btn {
  background: #374151; color: #e5e7eb; border: none;
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.admin-refresh-btn:hover { background: #4b5563; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  background: rgba(255,255,255,0.05); color: #9ca3af;
  padding: 8px 12px; text-align: left; font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.05); color: #e5e7eb; }
.admin-table tr:hover td { background: rgba(255,255,255,0.03); }
.admin-cell-email { font-family: monospace; font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.admin-cell-date { color: #6b7280; font-size: 12px; }
.admin-plan-badge, .admin-role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700;
}
.admin-plan-badge.plan-pro { background: #f59e0b; color: #000; }
.admin-plan-badge.plan-free { background: #374151; color: #9ca3af; }
.admin-role-badge.role-owner { background: #f59e0b; color: #000; }
.admin-role-badge.role-admin { background: #6366f1; color: #fff; }
.admin-role-badge.role-user { background: #374151; color: #9ca3af; }
.admin-select {
  background: #374151; color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 3px 6px; border-radius: 6px; font-size: 12px; cursor: pointer; margin-right: 4px;
}
.admin-loading { color: #6b7280; text-align: center; padding: 20px; }
.admin-error { color: #ef4444; text-align: center; padding: 20px; }
.admin-count { color: #6b7280; font-size: 12px; text-align: right; margin-top: 8px; }

/* ─── 成果物カード（Outcome Loop v6）─────────────────────────── */
.artifacts-section {
  margin-top: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}
.artifacts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #eef2ff;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
  gap: 6px;
}
.artifacts-title {
  font-size: 13px;
  font-weight: 600;
  color: #4338ca;
}
.outcome-score-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.outcome-score-badge.achieved {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.outcome-score-badge.not-achieved {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}
.artifacts-cards {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.artifact-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  transition: box-shadow 0.15s;
}
.artifact-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.artifact-card-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.artifact-card-info {
  flex: 1;
  min-width: 0;
}
.artifact-card-name {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifact-card-type {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}
.artifact-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.artifact-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.artifact-btn:hover {
  opacity: 0.8;
}
.artifact-btn-preview {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
}
.artifact-btn-download {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}
/* ─── 失敗分析 ─────────────────────────────────────────────── */
.failure-analysis {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
}
.failure-title {
  font-size: 13px;
  font-weight: 600;
  color: #c2410c;
  margin-bottom: 6px;
}
.failure-content {
  font-size: 12px;
  color: #431407;
  white-space: pre-wrap;
  margin: 0;
  font-family: inherit;
}
.improvement-suggestion {
  font-size: 12px;
  color: #065f46;
  margin-top: 6px;
  padding: 6px 8px;
  background: #d1fae5;
  border-radius: 6px;
}
/* ─── モバイル対応 ───────────────────────────────────────── */
@media (max-width: 480px) {
  .artifact-card {
    flex-wrap: wrap;
  }
  .artifact-card-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .artifacts-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ═══════════════════════════════════════════════════════
   プロジェクト管理 UI
   ═══════════════════════════════════════════════════════ */
.projects-panel { display: flex; flex-direction: column; height: 100%; padding: 16px; overflow-y: auto; gap: 16px; }
.projects-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.projects-header h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0; }
.projects-list { display: flex; flex-direction: column; gap: 12px; }
.projects-empty, .projects-loading, .projects-error { text-align: center; color: var(--text-muted); font-size: 0.9rem; padding: 24px; }
.projects-error { color: var(--error-text); }
.project-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: box-shadow 0.2s, transform 0.1s; }
.project-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3); transform: translateY(-1px); border-color: var(--accent); }
.project-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.project-card-name { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.project-card-date { font-size: 0.75rem; color: var(--text-muted); }
.project-card-goal { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 10px; line-height: 1.4; }
.project-card-footer { display: flex; justify-content: flex-end; gap: 8px; }
.project-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.project-modal-inner { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 640px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.project-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.project-modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; color: var(--text); }
.project-modal-header button { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.project-modal-header button:hover { background: var(--surface2); color: var(--text); }
.project-modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.project-modal-section h4 { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 8px; }
.project-modal-section p { font-size: 0.9rem; color: var(--text); margin: 0; line-height: 1.5; }
.project-modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.artifact-group { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.artifact-group-name { background: var(--surface2); padding: 8px 12px; font-weight: 600; font-size: 0.85rem; color: var(--text); }
.artifact-versions { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.artifact-version { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; border-radius: 6px; background: var(--bg); }
.artifact-version.latest { background: rgba(63,185,80,0.1); border: 1px solid rgba(63,185,80,0.3); }
.version-badge { font-size: 0.78rem; font-weight: 700; color: var(--success); background: rgba(63,185,80,0.15); padding: 2px 8px; border-radius: 20px; }
.version-date { font-size: 0.75rem; color: var(--text-muted); flex: 1; }
.version-actions { display: flex; gap: 6px; }
.execution-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface2); font-size: 0.82rem; flex-wrap: wrap; }
.execution-status.done { color: var(--success); font-weight: 700; }
.execution-status.partial { color: var(--warning); font-weight: 700; }
.execution-goal { flex: 1; color: var(--text); }
.execution-date { color: var(--text-muted); font-size: 0.75rem; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2); cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; transition: background 0.15s; display: inline-flex; align-items: center; gap: 4px; }
.btn-sm:hover { background: var(--surface); border-color: var(--accent); }
.btn-sm.btn-primary { background: var(--accent-dim); color: #fff; border-color: var(--accent-dim); }
.btn-sm.btn-primary:hover { background: var(--accent); }
.btn-sm.btn-danger { background: rgba(248,81,73,0.15); color: var(--error-text); border-color: var(--error-text); }
.btn-sm.btn-danger:hover { background: rgba(248,81,73,0.3); }
.btn-sm.btn-warning { background: rgba(210,153,34,0.15); color: var(--warning); border-color: var(--warning); }
.btn-sm.btn-warning:hover { background: rgba(210,153,34,0.3); }

/* ═══════════════════════════════════════════════════════
   チャットモード — 提案カード (v8.2)
   ═══════════════════════════════════════════════════════ */
.chat-reply-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; max-width: 480px; }
.chat-reply-card .message-text { font-size: 0.92rem; line-height: 1.6; color: var(--text); margin-bottom: 12px; white-space: pre-wrap; }
.suggestions-container { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.suggestion-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; cursor: pointer; text-align: left; transition: background 0.15s, border-color 0.15s, transform 0.1s; font-family: inherit; width: 100%; }
.suggestion-btn:hover { background: var(--accent-dim); border-color: var(--accent); transform: translateY(-1px); }
.suggestion-btn:active { transform: translateY(0); }
.suggestion-label { font-size: 0.88rem; color: var(--text); font-weight: 500; flex: 1; }
.suggestion-action { font-size: 1.1rem; color: var(--accent); font-weight: 700; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════
   finalResponse バブル (v8.3)
   ═══════════════════════════════════════════════════════ */
.fr-bubble {
  background: linear-gradient(135deg, #1a2a3a 0%, #0f1e2e 100%);
  border: 1px solid var(--accent-dim);
  border-radius: 16px;
  padding: 18px 20px;
  max-width: 520px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.fr-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #58a6ff;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fr-title::before { content: "\2705"; font-size: 1rem; }
.fr-summary {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  border-left: 3px solid var(--accent-dim);
}
.fr-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.fr-artifacts { margin-bottom: 14px; }
.fr-artifact-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  transition: background 0.15s;
}
.fr-artifact-card:hover { background: rgba(255,255,255,0.09); }
.fr-artifact-icon { font-size: 1.3rem; flex-shrink: 0; }
.fr-artifact-info { flex: 1; min-width: 0; }
.fr-artifact-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fr-artifact-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.fr-artifact-btn {
  font-size: 0.78rem;
  padding: 4px 10px;
  background: var(--accent-dim);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.fr-artifact-btn:hover { background: var(--accent); }
.fr-artifact-btns { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.fr-artifact-btn-dl { background: rgba(88,166,255,0.2); border: 1px solid var(--accent-dim); }
.fr-artifact-btn-dl:hover { background: var(--accent); }
.fr-artifact-btn-preview { background: rgba(63,185,80,0.15); border: 1px solid rgba(63,185,80,0.4); color: #3fb950; }
.fr-artifact-btn-preview:hover { background: rgba(63,185,80,0.3); color: #fff; }
.fr-next-actions { margin-top: 4px; }
.fr-next-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.fr-next-btn {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  background: rgba(88,166,255,0.12);
  border: 1px solid var(--accent-dim);
  border-radius: 20px;
  color: #58a6ff;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.fr-next-btn:hover { background: rgba(88,166,255,0.25); transform: translateY(-1px); }
.fr-next-btn:active { transform: translateY(0); }

/* ══════════════════════════════════════════════════════
   品質ステータス & ベンチマーク UI
   ══════════════════════════════════════════════════════ */
.quality-gate-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.qg-good    { background: #e8f5e9; color: #2e7d32; border: 2px solid #4caf50; }
.qg-warning { background: #fff8e1; color: #f57f17; border: 2px solid #ffc107; }
.qg-bad     { background: #ffebee; color: #c62828; border: 2px solid #f44336; }
.qg-unknown { background: #f5f5f5; color: #616161; border: 2px solid #9e9e9e; }

.quality-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.quality-stat-card {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.qs-label { font-size: 0.75rem; color: #888; margin-bottom: 4px; }
.qs-value { font-size: 1.4rem; font-weight: 700; color: #333; }

.quality-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  margin: 16px 0 8px;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
}
.quality-gate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.quality-gate-table th,
.quality-gate-table td {
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  text-align: left;
}
.quality-gate-table th { background: #f5f5f5; font-weight: 600; }

.quality-error-list { display: flex; flex-direction: column; gap: 8px; }
.quality-error-item {
  background: #fff3f3;
  border: 1px solid #ffcdd2;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.qe-name  { font-weight: 600; color: #c62828; }
.qe-error { color: #555; flex: 1; }
.qe-time  { color: #999; font-size: 0.75rem; white-space: nowrap; }
.quality-no-error { color: #2e7d32; font-size: 0.9rem; }

/* ベンチマーク結果 */
.benchmark-status-text { font-size: 0.85rem; color: #666; margin-left: 12px; }
.benchmark-results-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.benchmark-result-item {
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
}
.bri-success { background: #f1f8f1; border-color: #a5d6a7; }
.bri-fail    { background: #fff8f8; border-color: #ef9a9a; }
.bri-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.bri-num    { font-weight: 700; color: #888; font-size: 0.85rem; }
.bri-name   { font-weight: 600; flex: 1; }
.bri-score  { font-size: 0.85rem; color: #555; }
.bri-status { font-size: 0.85rem; font-weight: 600; }
.bri-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: #666;
  margin-bottom: 4px;
}
.bri-error       { font-size: 0.8rem; color: #c62828; margin-top: 4px; }
.bri-failure     { font-size: 0.8rem; color: #e65100; margin-top: 2px; }
.bri-improvement { font-size: 0.8rem; color: #1565c0; margin-top: 2px; }

/* ══════════════════════════════════════════════════════════
   ⑧ 長期記憶コンテキストバー
   ══════════════════════════════════════════════════════════ */
.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #1a1f3a 0%, #0d1117 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  padding: 10px 16px;
  margin: 8px 16px;
  gap: 12px;
  animation: contextBarSlideIn 0.3s ease;
}

@keyframes contextBarSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ctx-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ctx-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.ctx-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ctx-project {
  font-size: 11px;
  color: #6366f1;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ctx-goal {
  font-size: 13px;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctx-resume-badge {
  display: inline-block;
  background: #6366f1;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.ctx-resume-btn {
  flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ctx-resume-btn:hover {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.ctx-resume-btn:active {
  transform: translateY(0);
}

/* v8.16: ストリーミングUX - 計画表示スタイル */
.stream-entry.type-planning {
  background: rgba(137, 180, 250, 0.08);
  border-left: 3px solid #89b4fa;
  padding-left: 8px;
  font-style: italic;
  color: #89b4fa;
}
.stream-entry.type-plan-ready {
  background: rgba(166, 227, 161, 0.08);
  border-left: 3px solid #a6e3a1;
  padding-left: 8px;
  color: #a6e3a1;
  font-weight: 600;
}

/* ─── v8.17 Phase1: 紹介リンクパネル ─────────────────────────────────────── */
.referral-panel {
  margin: 8px 12px;
  padding: 12px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 10px;
  font-size: 12px;
}
.referral-title {
  color: #a5b4fc;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.3px;
}
.referral-link-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.referral-link-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 6px;
  color: #e2e8f0;
  padding: 5px 8px;
  font-size: 10px;
  outline: none;
  min-width: 0;
}
.referral-copy-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.referral-copy-btn:hover { opacity: 0.85; }
.referral-stats {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 10px;
}
