/* ============================================================
 * LOAN CRAFT ENGINE v5.0 - デザインシステム
 * 銀行審査逆算型・融資獲得総合プラットフォーム
 * ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+JP:wght@300;400;500;600;700;800&display=swap');

/* --- CSS カスタムプロパティ --- */
:root {
  /* プライマリカラー */
  --primary: #6C63FF;
  --primary-light: #8B83FF;
  --primary-dark: #4A42DB;
  --primary-glow: rgba(108, 99, 255, 0.3);

  /* アクセントカラー */
  --accent-gold: #F5A623;
  --accent-green: #27AE60;
  --accent-red: #E74C3C;
  --accent-blue: #3498DB;
  --accent-cyan: #00D2FF;
  --accent-purple: #9B59B6;
  --accent-orange: #E67E22;

  /* 格付けカラー */
  --grade-sp: #FFD700;
  --grade-s: #6C63FF;
  --grade-a: #27AE60;
  --grade-b: #3498DB;
  --grade-c: #F5A623;
  --grade-d: #E67E22;
  --grade-e: #E74C3C;
  --grade-f: #8B0000;

  /* ダークテーマ背景 */
  --bg-primary: #0A0E1A;
  --bg-secondary: #111827;
  --bg-tertiary: #1A2035;
  --bg-card: rgba(26, 32, 53, 0.8);
  --bg-glass: rgba(17, 24, 39, 0.6);
  --bg-hover: rgba(108, 99, 255, 0.08);
  --bg-active: rgba(108, 99, 255, 0.15);
  --bg-input: rgba(26, 32, 53, 0.9);

  /* テキスト */
  --text-primary: #F0F2F5;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --text-accent: #6C63FF;

  /* ボーダー */
  --border-primary: rgba(108, 99, 255, 0.35);
  --border-secondary: rgba(255, 255, 255, 0.15);
  --border-glow: rgba(108, 99, 255, 0.5);
  --bg-input: rgba(255, 255, 255, 0.08);

  /* シャドウ */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(108, 99, 255, 0.2);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.05);

  /* レイアウト */
  --sidebar-width: 280px;
  --header-height: 64px;
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --border-radius-xl: 20px;

  /* フォント */
  --font-primary: 'Inter', 'Noto Sans JP', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* トランジション */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- リセット・ベース --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 背景の装飾グラデーション */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(108, 99, 255, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(0, 210, 255, 0.04) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(155, 89, 182, 0.03) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

/* --- レイアウト --- */
.app-container {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- サイドバー --- */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-secondary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: transform var(--transition-slow);
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-secondary);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 16px var(--primary-glow);
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.sidebar-logo .version {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: scroll;
  padding: 8px;
  min-height: 0;
}

/* サイドバーのスクロールバーを常に表示 */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* --- ステップベース・サイドバー --- */
.nav-step {
  margin-bottom: 2px;
}

.nav-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.nav-step-header:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-step-header.active {
  color: var(--text-primary);
  background: rgba(108, 99, 255, 0.06);
}

.step-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.nav-step-header.active .step-indicator {
  border-color: var(--primary);
  background: var(--primary);
}

.nav-step-header.done .step-indicator {
  border-color: var(--accent-green);
  background: var(--accent-green);
}

.step-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

.nav-step-header.active .step-num,
.nav-step-header.done .step-num {
  color: #fff;
}

.step-label {
  flex: 1;
}

.step-check {
  font-size: 12px;
}

.step-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  width: 14px;
  text-align: center;
}

/* 折りたたみ本体 */
.nav-step-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 0;
  padding-left: 22px;
}

.nav-step-body.open {
  max-height: 300px;
  opacity: 1;
  padding-bottom: 4px;
}

/* sidebarのnav-item（ステップの子要素） */
.nav-step-body .nav-item {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  margin: 1px 0;
}

/* ツール用ヘッダー（step-indicatorなし） */
.nav-step-header.tools-header {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 12px;
}

/* 区切り線 */
.nav-divider {
  height: 1px;
  background: var(--border-secondary);
  margin: 8px 12px;
}

/* 旧セクションタイトル（後方互換） */
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 13px;
  color: var(--text-secondary);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--primary-light);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-secondary);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* --- メインコンテンツ --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ヘッダー */
.main-header {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-secondary);
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
  z-index: 10;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-secondary);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  font-family: var(--font-primary);
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-primary);
}

.mobile-menu-btn {
  display: none;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
}

/* コンテンツエリア */
.content-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* --- チャットビュー --- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(108, 99, 255, 0.2);
  border-radius: 3px;
}

.message {
  max-width: 800px;
  animation: messageIn 0.3s ease;
}

.message.system {
  width: 100%;
  max-width: 100%;
}

.message.user {
  align-self: flex-end;
}

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

.message-content {
  padding: 16px 20px;
  border-radius: var(--border-radius-md);
  line-height: 1.7;
  font-size: 14px;
}

.message.system .message-content {
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  border-radius: var(--border-radius-md) var(--border-radius-md) 4px var(--border-radius-md);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.message-header .avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.message-header .avatar.system-avatar {
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
}

.message-header .avatar.user-avatar {
  background: var(--accent-gold);
}

.message-header .name {
  font-weight: 600;
  color: var(--text-secondary);
}

.message-header .time {
  margin-left: auto;
}

/* チャット入力 */
.chat-input-container {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border-secondary);
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(20px);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.chat-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-secondary);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-primary);
  resize: none;
  outline: none;
  transition: border-color var(--transition-fast);
  max-height: 120px;
  line-height: 1.5;
}

.chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--border-radius-md);
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

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

/* ヒント */
.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

.input-hint kbd {
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--border-secondary);
}

/* --- コマンドパレット --- */
.command-palette-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.command-palette-overlay.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.command-palette {
  width: 560px;
  max-height: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  overflow: hidden;
  animation: paletteIn 0.2s ease;
}

@keyframes paletteIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.palette-input-container {
  padding: 16px;
  border-bottom: 1px solid var(--border-secondary);
}

.palette-input {
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-primary);
  outline: none;
}

.palette-input::placeholder {
  color: var(--text-muted);
}

.palette-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.palette-item:hover,
.palette-item.selected {
  background: var(--bg-hover);
}

.palette-item .cmd-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary-light);
  min-width: 120px;
  font-family: var(--font-mono);
}

.palette-item .cmd-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- カード・パネル --- */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  border-radius: var(--border-radius-md);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  padding: 24px;
  transition: all var(--transition-normal);
}

.glass-card:hover {
  border-color: var(--border-primary);
}

.glass-card.highlight {
  border-color: var(--primary);
  box-shadow: var(--shadow-card), 0 0 20px var(--primary-glow);
}

/* --- 起動メッセージ --- */
.boot-message {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
}

.boot-message .boot-header {
  text-align: center;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border-primary);
  border-radius: var(--border-radius-md);
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.1), rgba(0, 210, 255, 0.05));
}

.boot-message .boot-title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
  margin-bottom: 4px;
  font-family: var(--font-primary);
}

.boot-message .boot-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-primary);
}

.boot-section {
  margin: 16px 0;
}

.boot-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-gold);
  margin-bottom: 8px;
  font-family: var(--font-primary);
}

.boot-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-primary);
}

.boot-item .check {
  color: var(--accent-green);
}

.boot-item .icon {
  font-size: 14px;
}

.boot-cta {
  margin-top: 20px;
  padding: 14px;
  text-align: center;
  background: rgba(108, 99, 255, 0.08);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-primary);
  font-family: var(--font-primary);
  font-size: 14px;
  color: var(--text-primary);
}

/* --- データテーブル --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-secondary);
  background: rgba(0, 0, 0, 0.2);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-secondary);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.data-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* --- スコアカード --- */
.score-card {
  text-align: center;
  padding: 24px;
}

.score-value {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.score-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-grade {
  display: inline-block;
  font-size: 28px;
  font-weight: 800;
  padding: 8px 24px;
  border-radius: var(--border-radius-sm);
  margin-top: 12px;
  letter-spacing: 2px;
}

/* --- プログレスバー --- */
.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan));
}

.progress-bar.danger .progress-fill {
  background: linear-gradient(90deg, var(--accent-red), var(--accent-orange));
}

.progress-bar.warning .progress-fill {
  background: linear-gradient(90deg, var(--accent-orange), var(--accent-gold));
}

.progress-bar.success .progress-fill {
  background: linear-gradient(90deg, var(--accent-green), #2ECC71);
}

/* --- 格付けバッジ --- */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 12px;
  border-radius: 6px;
  letter-spacing: 1px;
}

.grade-badge.sp { background: rgba(255, 215, 0, 0.15); color: var(--grade-sp); border: 1px solid rgba(255, 215, 0, 0.3); }
.grade-badge.s  { background: rgba(108, 99, 255, 0.15); color: var(--grade-s); border: 1px solid rgba(108, 99, 255, 0.3); }
.grade-badge.a  { background: rgba(39, 174, 96, 0.15); color: var(--grade-a); border: 1px solid rgba(39, 174, 96, 0.3); }
.grade-badge.b  { background: rgba(52, 152, 219, 0.15); color: var(--grade-b); border: 1px solid rgba(52, 152, 219, 0.3); }
.grade-badge.c  { background: rgba(245, 166, 35, 0.15); color: var(--grade-c); border: 1px solid rgba(245, 166, 35, 0.3); }
.grade-badge.d  { background: rgba(230, 126, 34, 0.15); color: var(--grade-d); border: 1px solid rgba(230, 126, 34, 0.3); }
.grade-badge.e  { background: rgba(231, 76, 60, 0.15); color: var(--grade-e); border: 1px solid rgba(231, 76, 60, 0.3); }
.grade-badge.f  { background: rgba(139, 0, 0, 0.15); color: var(--grade-f); border: 1px solid rgba(139, 0, 0, 0.3); }

/* --- アラートカード --- */
.alert-card {
  padding: 14px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0;
}

.alert-card .alert-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-card.critical {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.25);
  color: #F08080;
}

.alert-card.warning {
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.25);
  color: #F5C77E;
}

.alert-card.success {
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.25);
  color: #7EDCB0;
}

.alert-card.info {
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.25);
  color: #A09BFF;
}

/* --- マトリックスグリッド --- */
.matrix-grid {
  display: grid;
  gap: 2px;
  margin: 16px 0;
}

.matrix-cell {
  padding: 12px;
  text-align: center;
  font-size: 11px;
  border-radius: 4px;
  transition: transform var(--transition-fast);
}

.matrix-cell:hover {
  transform: scale(1.05);
  z-index: 2;
}

.matrix-cell.sure   { background: rgba(39, 174, 96, 0.25); color: var(--accent-green); }
.matrix-cell.likely  { background: rgba(52, 152, 219, 0.25); color: var(--accent-blue); }
.matrix-cell.marginal { background: rgba(245, 166, 35, 0.25); color: var(--accent-gold); }
.matrix-cell.difficult { background: rgba(231, 76, 60, 0.25); color: var(--accent-red); }
.matrix-cell.impossible { background: rgba(139, 0, 0, 0.2); color: #C0392B; }
.matrix-cell.header { background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 600; }
.matrix-cell.active-result { box-shadow: 0 0 0 2px var(--primary), var(--shadow-glow); }

/* --- フォームコントロール --- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-secondary);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* --- ボタン --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--border-radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-primary);
  color: var(--primary-light);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* --- タグ --- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.tag-primary {
  background: rgba(108, 99, 255, 0.15);
  color: var(--primary-light);
}

.tag-success {
  background: rgba(39, 174, 96, 0.15);
  color: var(--accent-green);
}

.tag-warning {
  background: rgba(245, 166, 35, 0.15);
  color: var(--accent-gold);
}

.tag-danger {
  background: rgba(231, 76, 60, 0.15);
  color: var(--accent-red);
}

/* --- レポートスタイル --- */
.report-section {
  margin: 24px 0;
}

.report-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-subtitle {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 10px;
  color: var(--text-primary);
}

.report-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-secondary);
  font-size: 13px;
}

.report-row .label {
  color: var(--text-secondary);
}

.report-row .value {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* --- ヒアリングクイックボタン --- */
.quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.quick-option {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--primary);
  background: rgba(108, 99, 255, 0.08);
  color: #FFFFFF;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-primary);
  font-weight: 500;
}

.quick-option:hover {
  background: var(--bg-active);
  border-color: var(--primary-light);
  box-shadow: 0 0 12px var(--primary-glow);
  color: #FFFFFF;
}

/* --- レーダーチャート（Canvas代替・CSSのみ） --- */
.radar-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.radar-item {
  text-align: center;
}

.radar-bar {
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 8px;
}

.radar-fill {
  width: 40px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(to top, var(--primary), var(--accent-cyan));
  transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.radar-fill .radar-score {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-light);
  white-space: nowrap;
}

.radar-item-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- フローチャート --- */
.flow-chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 16px 0;
}

.flow-node {
  padding: 14px 20px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  font-size: 13px;
  position: relative;
  transition: all var(--transition-fast);
}

.flow-node:hover {
  border-color: var(--border-primary);
}

.flow-node.active {
  background: rgba(108, 99, 255, 0.1);
  border-color: var(--primary);
}

.flow-node.result {
  background: rgba(39, 174, 96, 0.1);
  border-color: var(--accent-green);
}

.flow-connector {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  padding: 2px 0;
}

/* --- ステップインジケーター --- */
.steps-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 20px 0;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-secondary);
  transition: all var(--transition-fast);
}

.step-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.step-dot.completed {
  background: var(--accent-green);
  border-color: var(--accent-green);
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border-secondary);
}

.step-line.completed {
  background: var(--accent-green);
}

/* --- 印刷可能なドキュメント --- */
.doc-preview {
  background: #fff;
  color: #1a1a1a;
  padding: 40px;
  border-radius: var(--border-radius-md);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 13px;
  line-height: 1.8;
  max-width: 800px;
  margin: 20px auto;
  box-shadow: var(--shadow-lg);
}

.doc-preview h1 {
  font-size: 20px;
  text-align: center;
  border-bottom: 2px solid #333;
  padding-bottom: 12px;
  margin-bottom: 24px;
}

.doc-preview h2 {
  font-size: 16px;
  border-left: 4px solid var(--primary);
  padding-left: 12px;
  margin: 24px 0 12px;
}

.doc-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.doc-preview table th,
.doc-preview table td {
  padding: 8px 12px;
  border: 1px solid #ddd;
  font-size: 12px;
}

.doc-preview table th {
  background: #f0f0f0;
  font-weight: 600;
}

/* --- ローディング --- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* --- ステータスバー --- */
.status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  font-size: 12px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(39, 174, 96, 0.5);
}

/* ============================================================
 * ヒアリングチャットUI
 * ============================================================ */

/* チャットコンテナ全体 */
.interview-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - var(--header-height));
  position: relative;
}

/* メッセージエリア（スクロール） */
.interview-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  padding-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* --- メッセージ共通 --- */
.iv-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}

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

/* ボットメッセージ（左） */
.iv-msg-bot {
  align-self: flex-start;
  align-items: flex-start;
}

.iv-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.iv-msg-bubble {
  padding: 12px 16px;
  border-radius: 4px 16px 16px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.iv-msg-card {
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  border-left: 3px solid var(--primary);
}

/* ユーザーメッセージ（右） */
.iv-msg-user {
  align-self: flex-end;
  justify-content: flex-end;
}

.iv-msg-user .iv-msg-bubble {
  background: linear-gradient(135deg, var(--primary), #5b52e0);
  border: none;
  color: #fff;
  border-radius: 16px 4px 16px 16px;
  box-shadow: 0 2px 12px rgba(108, 99, 255, 0.3);
}

/* アラートメッセージ */
.iv-msg-alert {
  align-self: center;
  max-width: 90%;
}

.iv-alert {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.iv-alert-success {
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.3);
  color: var(--accent-green);
}

.iv-alert-warning {
  background: rgba(241, 196, 15, 0.1);
  border: 1px solid rgba(241, 196, 15, 0.3);
  color: #f1c40f;
}

.iv-alert-critical {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: #e74c3c;
}

.iv-alert-info {
  background: rgba(52, 152, 219, 0.1);
  border: 1px solid rgba(52, 152, 219, 0.3);
  color: #3498db;
}

/* --- ステップインジケーター --- */
.iv-step-header {
  text-align: center;
}

.iv-step-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.iv-step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--border-secondary);
  color: var(--text-muted);
  background: transparent;
  transition: all 0.3s;
}

.iv-step-badge.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.4);
}

.iv-step-badge.done {
  border-color: var(--accent-green);
  background: var(--accent-green);
  color: #fff;
}

.iv-step-line {
  width: 30px;
  height: 2px;
  background: var(--border-secondary);
}

/* --- 入力バー（固定フッター） --- */
.interview-chat-input {
  flex-shrink: 0;
  border-top: 1px solid var(--border-secondary);
  background: var(--bg-secondary);
  padding: 8px 12px 12px;
}

/* クイックオプション（選択肢ボタン） */
.interview-quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
  max-height: 200px;
  overflow-y: auto;
}

.iv-quick-btn {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-secondary);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.iv-quick-btn:hover {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.1);
  color: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.2);
}

.iv-quick-btn:active {
  transform: translateY(0);
}

/* 入力行（テキストエリア + 送信ボタン） */
.interview-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.interview-input-row textarea {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input, #1a2035);
  border: 1px solid var(--border-secondary);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 42px;
  max-height: 100px;
}

.interview-input-row textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.15);
}

.interview-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), #5b52e0);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.interview-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.5);
}

.interview-send-btn:active {
  transform: scale(0.95);
}

/* --- レスポンシブ --- */
@media (max-width: 768px) {
  /* サイドバー：モバイルではオフキャンバス */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 280px;
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ヘッダーをコンパクトに */
  .main-header {
    padding: 0 8px;
    height: 48px;
    position: relative;
    z-index: 5;
    overflow: hidden;
  }

  /* ヘッダー左側のgapを縮小 */
  .main-header > div:first-child {
    gap: 6px !important;
    overflow: hidden;
    min-width: 0;
  }

  .header-title {
    font-size: 12px;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    gap: 0;
    flex-shrink: 0;
  }

  .header-btn {
    padding: 6px;
    font-size: 11px;
    border: none;
    background: transparent;
  }

  /* コマンドパレットボタンはモバイルでは非表示 */
  .header-btn-cmdpalette {
    display: none !important;
  }

  /* ヘッダーボタンのテキスト部分をモバイルで非表示 */
  .header-btn-text {
    display: none;
  }

  /* アイコン部分 */
  .header-btn-icon {
    font-size: 18px;
    line-height: 1;
  }



  /* チャットエリア */
  .chat-messages {
    padding: 12px;
    gap: 12px;
  }

  .chat-input-wrapper {
    max-width: 100%;
  }

  .chat-input-container {
    padding: 10px 12px 16px;
  }

  .chat-input {
    padding: 10px 14px;
    font-size: 16px; /* iOSズーム防止 */
  }

  .send-btn {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .input-hint {
    font-size: 10px;
  }

  /* メッセージ */
  .message {
    max-width: 100%;
  }

  .message-content {
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
  }

  .message-header {
    font-size: 11px;
    gap: 6px;
  }

  /* コマンドパレット */
  .command-palette {
    width: 94%;
    margin: 0 3%;
    max-height: 70vh;
  }

  .command-palette-overlay.active {
    padding-top: 10vh;
  }

  .palette-input {
    font-size: 14px;
  }

  .palette-item {
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .palette-item .cmd-name {
    min-width: auto;
    font-size: 13px;
  }

  .palette-item .cmd-desc {
    font-size: 12px;
    width: 100%;
  }

  /* カード・パネル */
  .glass-card {
    padding: 14px;
  }

  /* データテーブル：横スクロール対応 */
  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* スコアカード */
  .score-value {
    font-size: 40px;
  }

  .score-grade {
    font-size: 22px;
    padding: 6px 18px;
  }

  /* 起動メッセージ */
  .boot-message .boot-title {
    font-size: 16px;
    letter-spacing: 1px;
  }

  .boot-message .boot-subtitle {
    font-size: 11px;
  }

  .boot-message .boot-header {
    padding: 12px;
    margin-bottom: 12px;
  }

  .boot-cta {
    padding: 10px;
    font-size: 13px;
  }

  /* レーダーチャート */
  .radar-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .radar-bar {
    height: 80px;
  }

  .radar-fill {
    width: 30px;
  }

  /* レポート */
  .report-title {
    font-size: 14px;
  }

  .report-row {
    font-size: 12px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .report-row .value {
    font-size: 12px;
  }

  /* ドキュメントプレビュー */
  .doc-preview {
    padding: 16px;
    font-size: 12px;
    margin: 10px 0;
  }

  .doc-preview h1 {
    font-size: 16px;
  }

  .doc-preview h2 {
    font-size: 14px;
  }

  .doc-preview table th,
  .doc-preview table td {
    padding: 4px 6px;
    font-size: 10px;
  }

  /* フォームコントロール */
  .form-input {
    font-size: 16px; /* iOSズーム防止 */
    padding: 10px 12px;
  }

  /* ボタン */
  .btn {
    padding: 8px 14px;
    font-size: 12px;
  }

  /* クイックオプション */
  .quick-options {
    gap: 6px;
  }

  .quick-option {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* フローチャート */
  .flow-node {
    padding: 10px 14px;
    font-size: 12px;
  }

  /* アラートカード */
  .alert-card {
    font-size: 12px;
    padding: 10px 12px;
  }

  /* ステータスバー */
  .status-bar {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
  }

  /* === JSインラインstyleで生成されるgridレイアウトをモバイルで上書き === */

  /* 2カラム以上のgridを1カラムに強制 */
  .message-content [style*="grid-template-columns: 1fr 1fr 1fr"],
  .message-content [style*="grid-template-columns:1fr 1fr 1fr"],
  .message-content [style*="grid-template-columns: 1fr 1fr"],
  .message-content [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* 4カラムgridも1カラムに */
  .message-content [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
  .message-content [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* auto-fitのminmaxを小さく調整 */
  .message-content [style*="minmax(200px"],
  .message-content [style*="minmax(220px"],
  .message-content [style*="minmax(240px"],
  .message-content [style*="minmax(250px"] {
    grid-template-columns: 1fr !important;
  }

  /* repeat(5,1fr) や repeat(7,1fr) のような多カラムgridを横スクロール対応 */
  .message-content [style*="repeat(5,1fr)"],
  .message-content [style*="repeat(7,1fr)"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* マトリックスグリッド */
  .matrix-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 10px;
  }

  .matrix-cell {
    padding: 8px 6px;
    font-size: 10px;
    min-width: 60px;
  }

  /* インラインstyleのmin-widthを持つ要素を横スクロール対応 */
  .message-content [style*="min-width"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* インラインstyleのflex要素をwrapに */
  .message-content [style*="display:flex"][style*="gap"] {
    flex-wrap: wrap !important;
  }

  /* タグバッジ */
  .tag {
    font-size: 10px;
    padding: 2px 8px;
  }

  /* progress-bar */
  .progress-bar {
    height: 6px;
  }

  /* ステップインジケーター */
  .step-line {
    width: 24px;
  }

  /* 印刷可能ドキュメント内のテーブル横スクロール */
  .doc-preview table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* KPIグリッド */
  .doc-preview .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* === 480px以下：さらに小さいスマホ向け === */
@media (max-width: 480px) {
  .main-header {
    padding: 0 8px;
    height: 50px;
  }

  .header-title {
    font-size: 12px;
    gap: 4px;
  }

  .header-btn {
    padding: 5px 6px;
    font-size: 10px;
  }

  .chat-messages {
    padding: 8px;
    gap: 8px;
  }

  .chat-input-container {
    padding: 8px;
  }

  .message-content {
    padding: 10px 12px;
    font-size: 12px;
  }

  .glass-card {
    padding: 10px;
    border-radius: 10px;
  }

  .boot-message .boot-title {
    font-size: 14px;
  }

  /* 2カラムも全て1カラムに */
  .message-content [style*="grid-template-columns: 1fr 1fr"],
  .message-content [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .message-content [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
  .message-content [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .radar-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .radar-bar {
    height: 60px;
  }

  .radar-fill {
    width: 24px;
  }

  .radar-item-label {
    font-size: 10px;
  }

  /* ドキュメントプレビュー */
  .doc-preview {
    padding: 12px;
  }

  .doc-preview h1 {
    font-size: 14px;
    padding-bottom: 8px;
    margin-bottom: 16px;
  }

  .doc-preview h2 {
    font-size: 13px;
  }

  /* クイックオプション：フル幅 */
  .quick-option {
    padding: 8px 12px;
    font-size: 12px;
    width: 100%;
    text-align: center;
  }

  /* スコア */
  .score-value {
    font-size: 32px;
  }

  .score-grade {
    font-size: 18px;
    padding: 5px 14px;
  }

  /* ナビステップ */
  .nav-step-header {
    padding: 10px;
    font-size: 13px;
  }

  .nav-step-body .nav-item {
    padding: 10px;
    font-size: 13px;
  }

  /* フォーム */
  .form-group {
    margin-bottom: 14px;
  }

  .form-label {
    font-size: 11px;
  }

  /* インラインstyleのindicatorGrid */
  #indicatorGrid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* ボタン群のレイアウト */
  .message-content [style*="display:flex"][style*="gap:8px"] {
    flex-direction: column !important;
  }

  .message-content [style*="display:flex"][style*="gap:8px"] .btn,
  .message-content [style*="display:flex"][style*="gap:8px"] button {
    width: 100% !important;
  }

  /* doc-previewのKPIグリッド */
  .doc-preview .kpi-grid {
    grid-template-columns: 1fr !important;
  }
}

/* --- 印刷 --- */
@media print {
  body {
    background: white;
    color: black;
  }

  .sidebar,
  .main-header,
  .chat-input-container,
  .command-palette-overlay {
    display: none !important;
  }

  .main-content {
    width: 100%;
  }

  .glass-card {
    background: white;
    border: 1px solid #ddd;
    box-shadow: none;
    backdrop-filter: none;
  }
}

/* --- モバイルオーバーレイ --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}

.sidebar-overlay.active {
  display: block;
}

/* --- セクション区切り --- */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-secondary);
}

/* --- アニメーションユーティリティ --- */
.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-up {
  animation: slideUp 0.4s ease;
}

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

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============================================================
 * ライトモード
 * ============================================================ */
body.light-theme {
  --bg-primary: #F5F7FA;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #EDF0F5;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.8);
  --bg-hover: rgba(108, 99, 255, 0.06);
  --bg-active: rgba(108, 99, 255, 0.10);
  --bg-input: rgba(237, 240, 245, 0.9);

  --text-primary: #1A202C;
  --text-secondary: #4A5568;
  --text-muted: #A0AEC0;

  --border-primary: rgba(108, 99, 255, 0.25);
  --border-secondary: rgba(0, 0, 0, 0.08);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255,255,255,0.9);
}

body.light-theme::before {
  background: radial-gradient(ellipse at 20% 50%, rgba(108, 99, 255, 0.04) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(0, 210, 255, 0.03) 0%, transparent 50%);
}

body.light-theme .main-header {
  background: rgba(255, 255, 255, 0.9);
}

body.light-theme .chat-input-container {
  background: rgba(255, 255, 255, 0.8);
}

body.light-theme .command-palette {
  background: var(--bg-secondary);
  border-color: rgba(0, 0, 0, 0.12);
}

body.light-theme .message.user .message-content {
  color: white;
}

body.light-theme .data-table th {
  background: rgba(108, 99, 255, 0.05);
  color: var(--text-secondary);
}

body.light-theme .doc-preview {
  background: #fff;
  color: #333;
  border-color: #ddd;
}

/* --- データテーブル --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-primary);
}
.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  background: rgba(108, 99, 255, 0.05);
}
.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
}
.data-table tr:hover {
  background: rgba(108, 99, 255, 0.03);
}

/* --- ローディングスピナー --- */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-secondary);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- ボタン追加バリエーション --- */
.btn-sm { padding: 6px 14px; font-size: 11px; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-secondary);
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-light); }

/* モバイル最適化（追加ルール） */
@media (max-width: 768px) {
  #indicatorGrid {
    grid-template-columns: 1fr 1fr !important;
  }
  .boot-message .glass-card {
    padding: 12px !important;
  }
  .nav-step-body .nav-item {
    padding: 10px 12px;
    font-size: 13px;
  }
  /* select要素のモバイル最適化 */
  select {
    font-size: 16px !important; /* iOSズーム防止 */
    padding: 10px 12px !important;
  }
  /* テキストエリアのモバイル最適化 */
  .glass-card textarea {
    font-size: 16px !important;
  }
}



/* ドロップダウン(select)のダークテーマ対応 */
select, select option {
  background: var(--bg-input, #1a2035) !important;
  color: var(--text-primary, #e0e0e0) !important;
  border: 1px solid var(--border-secondary, rgba(255,255,255,0.15)) !important;
  border-radius: 6px;
}
select:focus {
  border-color: var(--accent-primary, #4f8ef7) !important;
  outline: none;
}
/* input要素のダークテーマ強化 */
.glass-card input[type="text"],
.glass-card input[type="email"],
.glass-card input[type="password"],
.glass-card input[type="number"],
.glass-card textarea {
  background: var(--bg-input, #1a2035) !important;
  color: var(--text-primary, #e0e0e0) !important;
  border: 1px solid var(--border-secondary, rgba(255,255,255,0.15)) !important;
  border-radius: 6px;
}
.glass-card input:focus,
.glass-card textarea:focus {
  border-color: var(--accent-primary, #4f8ef7) !important;
  outline: none;
}

/* AIバッジ */
.ai-badge {
  display: inline-block;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  letter-spacing: 0.5px;
  vertical-align: middle;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: 0 0 6px rgba(124,58,237,0.4);
}
