/* ============================================================
   PresentAI – メインスタイルシート
   ============================================================ */

:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --border: #2a3347;
  --text: #e8ecf1;
  --text2: #8b96a8;
  --text3: #5a6478;
  --accent: #4f8ef7;
  --accent2: #6366f1;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font: 'Inter', 'Noto Sans JP', sans-serif;
  --sidebar-w: 280px;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── スクロールバー ────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── スクリーン ───────────────────────────────── */
.screen { display: flex; height: 100vh; }
.screen.hidden { display: none !important; }

/* ════════════════════════════════════════════════
   認証画面
════════════════════════════════════════════════ */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1a2544 0%, var(--bg) 60%);
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  justify-content: center;
}
.logo-icon { font-size: 28px; }
.logo-text { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }

.auth-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}
.auth-desc {
  color: var(--text2);
  text-align: center;
  margin-bottom: 28px;
  font-size: 13px;
}

.tab-group {
  display: flex;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}
.tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}
.tab.active {
  background: var(--accent);
  color: #fff;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form.hidden { display: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text2); font-weight: 500; }
.field input {
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.field input:focus { border-color: var(--accent); }

.btn-primary {
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.full { width: 100%; }

.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 8px;
}

/* ════════════════════════════════════════════════
   アプリ本体レイアウト
════════════════════════════════════════════════ */
#app-screen {
  overflow: hidden;
}

/* ── サイドバー ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  transition: width 0.3s ease, min-width 0.3s ease, transform 0.3s ease, border 0.3s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header .logo-text { font-size: 18px; font-weight: 700; flex: 1; }
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
}

/* ── モード切替 ───────────────────────────────── */
.mode-selector {
  padding: 12px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}
.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  transition: var(--transition);
}
.mode-btn.active {
  background: rgba(79, 142, 247, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.mode-icon { font-size: 16px; }

/* ── アップロードセクション ────────────────────── */
/* ドキュメントフォーマット選択 */
.doc-format-section {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.format-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.format-option {
  cursor: pointer;
}
.format-option input[type="radio"] {
  display: none;
}
.format-chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text2);
  transition: var(--transition);
}
.format-option input[type="radio"]:checked + .format-chip {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.1);
  color: var(--accent);
}
.format-chip:hover {
  border-color: var(--accent);
}

.upload-section {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.upload-label {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
  font-weight: 500;
}
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 12px;
  cursor: pointer;
  transition: var(--transition);
}
.upload-area:hover { border-color: var(--accent); background: rgba(79, 142, 247, 0.05); }
.upload-icon { font-size: 24px; }
.upload-text { font-size: 13px; color: var(--text2); }
.upload-sub { font-size: 11px; color: var(--text3); }

.file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}
.file-name-display {
  flex: 1;
  font-size: 12px;
  color: var(--success);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

/* ── 会話履歴 ─────────────────────────────────── */
.history-section { flex: 1; overflow-y: auto; padding: 12px 8px; }
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 10px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.new-chat-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  padding: 4px 8px;
  transition: var(--transition);
}
.new-chat-btn:hover { color: var(--text); border-color: var(--accent); }

.history-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.history-item:hover { background: var(--bg3); color: var(--text); }
.history-item.active { background: rgba(79, 142, 247, 0.15); color: var(--accent); }
.history-item-icon { flex-shrink: 0; }
.history-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.history-delete-btn {
  display: block;
  opacity: 0;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: var(--transition);
}
.history-item:hover .history-delete-btn { opacity: 1; }
.history-delete-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

/* ── サイドバー折りたたみ ──────────────────────── */
.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
}
.sidebar-collapse-btn:hover { background: var(--bg3); color: var(--text); }

.sidebar-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
  margin-right: 4px;
}
.sidebar-expand-btn.hidden { display: none !important; }
.sidebar-expand-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--accent); }

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

/* ── サイドバーフッター ────────────────────────── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-email {
  font-size: 12px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--danger); }

/* ── 利用状況バー ─────────────────────────────── */
.usage-bar {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.usage-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.usage-label {
  font-size: 11px;
  color: var(--text3);
}
.usage-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}
.usage-track {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.usage-fill.warning { background: var(--warning); }
.usage-fill.danger  { background: var(--danger); }
.usage-sub {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
}

/* ── 会社のテンプレート ───────────────────────── */
.brand-panel {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.brand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.brand-title { font-size: 11px; font-weight: 400; color: var(--text2); }
.brand-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
}
.brand-switch input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.brand-switch.hidden, .brand-info.hidden, .brand-logo.hidden, .brand-btn.hidden, .brand-note.hidden { display: none; }
.brand-note { font-size: 11px; color: var(--text2); line-height: 1.5; margin-bottom: 8px; }
.brand-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.brand-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.brand-logo {
  max-width: 96px;
  height: 22px;
  object-fit: contain;
  padding: 2px 4px;
  background: #fff;
  border-radius: 4px;
}
.brand-meta {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--text2);
  overflow-wrap: anywhere;
}
.brand-actions { display: flex; gap: 8px; }
.brand-btn {
  padding: 5px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
}
.brand-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.brand-btn:disabled { opacity: 0.5; cursor: wait; }
.brand-btn-quiet { color: var(--text2); }
.brand-btn-quiet:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.brand-btn:focus-visible, .brand-switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand-status { font-size: 11px; color: var(--text2); margin-top: 6px; }
.brand-status:empty { display: none; }
.brand-status.is-error { color: var(--danger); }

.admin-link {
  color: var(--text3);
  font-size: 16px;
  padding: 4px;
  text-decoration: none;
  transition: color var(--transition);
}
.admin-link:hover { color: var(--accent); }

/* ── メインコンテンツ ─────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  position: relative; /* ドロップ案内オーバーレイの基準 */
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
}
.header-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.research-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  transition: var(--transition);
}
.research-toggle.active {
  background: rgba(79, 142, 247, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.toggle-state { font-weight: 700; }

/* ── チャットエリア ───────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
}

/* ── ウェルカム画面 ───────────────────────────── */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 20px;
  text-align: center;
}
.welcome-icon { font-size: 64px; margin-bottom: 20px; }
.welcome-title { font-size: 26px; font-weight: 700; margin-bottom: 10px; }
.welcome-desc { color: var(--text2); font-size: 15px; margin-bottom: 36px; }

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 560px;
  width: 100%;
}
.suggestion-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: var(--transition);
}
.suggestion-card:hover {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.08);
  transform: translateY(-2px);
}
.sug-icon { font-size: 20px; }
.sug-title { font-size: 13px; font-weight: 600; color: var(--text); }
.sug-desc { font-size: 12px; color: var(--text2); }

/* ── メッセージ ───────────────────────────────── */
.messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.message.user .message-avatar { background: var(--accent2); }
.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  font-size: 18px;
}

.message-body { flex: 1; max-width: 85%; }

.message-bubble {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
}
.message.user .message-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.assistant .message-bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* マークダウン風スタイル */
.message-bubble strong { color: #93c5fd; font-weight: 600; }
.message-bubble a { color: var(--accent); text-decoration: underline; }
.message-bubble ul, .message-bubble ol { padding-left: 20px; margin: 8px 0; }
.message-bubble li { margin: 4px 0; }
.message-bubble p + p { margin-top: 10px; }
.message-bubble code {
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}
.message-bubble pre {
  background: var(--bg3);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
}
.message-bubble pre code { background: none; padding: 0; }

/* ダウンロードカード */
.download-card {
  margin-top: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.download-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.download-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}
.dl-btn.pptx { background: rgba(34, 197, 94, 0.15); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3); }
.dl-btn.pdf  { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.dl-btn.html { background: rgba(79, 142, 247, 0.15); color: var(--accent); border: 1px solid rgba(79, 142, 247, 0.3); }
.dl-btn.design-reuse { background: rgba(245, 158, 11, 0.15); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.35); }
.dl-btn.design-reuse:hover { background: rgba(245, 158, 11, 0.25); }
.dl-btn.preview { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.3); }
.dl-btn:hover { opacity: 0.8; transform: translateY(-1px); }

/* ── ストリーミングバブル（カーソル点滅） ──────── */
.message-bubble.streaming::after {
  content: '▋';
  display: inline-block;
  color: var(--accent);
  animation: blink-cursor 0.8s step-end infinite;
  margin-left: 2px;
  font-size: 1em;
  line-height: 1;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── 生成ステップカード ──────────────────────── */
.progress-steps-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  padding: 16px 18px;
  width: fit-content;
  min-width: 260px;
}
.progress-steps-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.progress-steps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  transition: color 0.3s ease;
}
.progress-step.pending  { color: var(--text3); }
.progress-step.active   { color: var(--text); }
.progress-step.done     { color: var(--success); }
.progress-step .step-icon {
  width: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.progress-step .step-label { flex: 1; }

/* ステップスピナー */
.step-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── リアルフェーズ表示 ──────────────────── */
.progress-phase-live {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  color: var(--text);
  animation: fadeInPhase 0.3s ease;
}
.progress-phase-live .phase-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}
.progress-phase-live .phase-text-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.progress-phase-live .phase-text {
  font-size: 14px;
  font-weight: 600;
}
.progress-phase-live .phase-subtitle {
  font-size: 12px;
  color: var(--accent);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes fadeInPhase {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── プログレスバー ──────────────────────── */
.progress-bar-container {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px 0;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── フェーズ履歴 ────────────────────────── */
.progress-phase-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.phase-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
  animation: fadeInPhase 0.3s ease;
}
.phase-history-item .phase-history-icon {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
}

.progress-elapsed {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── リサーチソース履歴カード ─────── */
.research-sources-bubble {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05)) !important;
  border: 1px solid rgba(99, 102, 241, 0.15) !important;
}

.research-sources-header {
  font-weight: 600;
  font-size: 13px;
  color: var(--text1);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.research-sources-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.research-source-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  animation: fadeInPhase 0.3s ease;
}

.research-source-item:hover {
  background: rgba(99, 102, 241, 0.06);
}

.research-source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.research-source-link:hover {
  text-decoration: underline;
}

.research-source-domain::before {
  content: '🔗';
  margin-right: 4px;
  font-size: 11px;
}

.research-source-snippet {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
  padding-left: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── 旧ローディングドット（後方互換で残す） ─────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text3);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── 入力エリア ───────────────────────────────── */
.input-area {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color var(--transition);
  max-width: 780px;
  margin: 0 auto;
}
.input-wrapper:focus-within { border-color: var(--accent); }

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  outline: none;
  max-height: 160px;
  overflow-y: auto;
}
#message-input::placeholder { color: var(--text3); }

.btn-send {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.btn-send svg { width: 16px; height: 16px; }
.btn-send:hover { background: #6b9ff8; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── ファイル添付（ドラッグ&ドロップ / 📎） ───────────── */
.btn-attach {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.btn-attach svg { width: 18px; height: 18px; }
.btn-attach:hover { color: var(--accent); background: rgba(79, 142, 247, 0.1); }
.btn-attach:disabled { opacity: 0.5; cursor: not-allowed; }

.attached-file {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 780px;
  margin: 0 auto 8px;
  padding: 8px 10px 8px 12px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.attached-file-name {
  flex: 1;
  min-width: 0;
  color: var(--success);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attached-file.design-base {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}
.attached-file.design-base .attached-file-name { color: #fcd34d; white-space: normal; }
.attached-file-remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
}
.attached-file-remove:hover { color: var(--text); background: var(--bg3); }

/* この会話の資料の無料の作り直し・修正の残り */
.deck-usage {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 780px;
  margin: 0 auto 8px;
  padding: 6px 6px 6px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.deck-usage-text { flex: 1; min-width: 0; color: var(--text2); }
.deck-usage-redo {
  flex-shrink: 0;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
}
.deck-usage-redo:hover { border-color: var(--accent); color: var(--accent); }
.deck-usage-redo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 17, 23, 0.85);
  pointer-events: none; /* dragleave のちらつき防止。ドロップ判定は main-content 側で行う */
}
.drop-overlay-inner {
  width: 100%;
  max-width: 520px;
  padding: 40px 24px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(79, 142, 247, 0.08);
  text-align: center;
}
.drop-overlay-icon { font-size: 36px; margin-bottom: 8px; }
.drop-overlay-title { font-size: 16px; font-weight: 600; color: var(--text); }
.drop-overlay-sub { font-size: 12px; color: var(--text2); margin-top: 6px; }

.input-hint.is-error { color: var(--danger); }
.input-hint.is-info  { color: var(--accent); }

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  margin-top: 8px;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}

/* ── プレビューモーダル ─────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}
.modal-content {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90vw;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { flex: 1; font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--danger); }
.modal-body { flex: 1; overflow: hidden; }
#preview-frame { width: 100%; height: 100%; border: none; }

/* ── ユーティリティ ───────────────────────────── */
.hidden { display: none !important; }

/* ── レスポンシブ ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .hamburger { display: block; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; margin: 16px; }
  .download-btns { flex-direction: column; }
}
