/**
 * 雲林縣少子化脆弱度數位地圖決策平台 - AI 評估對話助手樣式表
 * 版本號碼：v2.0.5
 * 修改紀錄:
 * - v2.0.4 -> v2.0.5: 新增討論項目卡片「移除」按鈕 (.btn-delete-item) 與彈性對齊樣式，改善多輪對話項目重複時之清理操作體驗。
 * - v2.0.3 -> v2.0.4: 新增「使用說明與佐證代碼指引」Modal 彈窗樣式，設計 D/I/C/T 四大專屬識別色卡片與 SOP 步驟引導。
 * - v2.0.2 -> v2.0.3: 優化前端思考與分析載入體驗，新增多階段動態進度、骨架微光動畫（Shimmer）與跳動反饋。
 * - v2.0.1 -> v2.0.2: 增強「摘要面板」收合與抽屜遮罩（Backdrop）效果，支援全螢幕尺寸下點擊即時反饋。
 */

:root {
  --font-sans: "Plus Jakarta Sans", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* 品牌核心色彩 (深邃森林綠與翠綠高亮) */
  --c-sidebar-bg: #0d2822;
  --c-sidebar-hover: #164037;
  --c-sidebar-active: #1d5246;
  --c-sidebar-border: rgba(255, 255, 255, 0.08);
  --c-sidebar-text: #e2f1ea;
  --c-sidebar-muted: #8ca89c;

  --c-primary: #123e35;
  --c-primary-light: #1c5b4e;
  --c-primary-dark: #0a241f;
  --c-accent-emerald: #10b981;
  --c-accent-lime: #d8f34e;

  --c-bg-app: #f4f7f4;
  --c-bg-surface: #ffffff;
  --c-bg-surface-subtle: #f8faf8;
  --c-bg-chat: #f9fbf9;

  --c-border: #e2ebe4;
  --c-border-subtle: #edf3ee;
  --c-border-focus: #10b981;

  --c-text-main: #142823;
  --c-text-muted: #5e776e;
  --c-text-light: #8ba299;

  /* 陰影與毛玻璃 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(18, 62, 53, 0.08);
  --shadow-lg: 0 12px 32px -4px rgba(18, 62, 53, 0.12);
  --shadow-floating: 0 20px 40px -8px rgba(18, 62, 53, 0.16);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body.agent-body {
  font-family: var(--font-sans);
  background: var(--c-bg-app);
  color: var(--c-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden; /* 確保全螢幕單頁無外層捲動條 */
  position: relative;
}

/* 抽屜背景半透明遮罩 */
.agent-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 36, 31, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.agent-drawer-backdrop.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* 跳至內容無障礙連結 */
.assistant-skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 999;
  padding: 0.75rem 1.25rem;
  background: var(--c-bg-surface);
  color: var(--c-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition-fast);
}
.assistant-skip-link:focus {
  top: 1rem;
}

/* 隱藏輔助文字 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 全域工作台三欄網格佈局 (100dvh 單頁高) */
.agent-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 380px;
  grid-template-areas: "sidebar main inspector";
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  background: var(--c-bg-app);
  transition: grid-template-columns var(--transition-smooth);
}

/* 桌面端收合摘要面板時的佈局 */
.agent-layout.is-summary-collapsed {
  grid-template-columns: 240px minmax(0, 1fr) 0px !important;
}

.agent-layout.is-summary-collapsed .agent-inspector {
  visibility: hidden;
  opacity: 0;
  padding: 0;
  border-left: none;
  pointer-events: none;
  overflow: hidden;
}

/* 桌面端收合左側導覽側欄時的佈局 (中間 main 對話區自動向左擴展) */
.agent-layout.is-sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr) 380px !important;
}

.agent-layout.is-sidebar-collapsed.is-summary-collapsed {
  grid-template-columns: 0px minmax(0, 1fr) 0px !important;
}

.agent-layout.is-sidebar-collapsed .agent-sidebar {
  visibility: hidden;
  opacity: 0;
  padding: 0;
  border-right: none;
  pointer-events: none;
  overflow: hidden;
}

/* ==========================================================================
   1. 左側側邊欄 (Sidebar)
   ========================================================================== */
.agent-sidebar {
  grid-area: sidebar;
  background: var(--c-sidebar-bg);
  border-right: 1px solid var(--c-sidebar-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.25rem 0.9rem;
  color: var(--c-sidebar-text);
  overflow-y: auto;
  z-index: 40;
  min-width: 0;
}

.sidebar-header {
  padding: 0.25rem 0.35rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--c-sidebar-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #185a49, #0d3229);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-accent-lime);
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--c-sidebar-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.brand-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.sidebar-action {
  margin-bottom: 1.25rem;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.68rem 1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-new-chat:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

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

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-sidebar-muted);
  padding: 0.5rem 0.65rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  color: var(--c-sidebar-text);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-item svg {
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--c-sidebar-hover);
  color: #ffffff;
}

.nav-item.is-active {
  background: var(--c-sidebar-active);
  color: #ffffff;
  font-weight: 600;
}

.nav-item.is-active svg {
  opacity: 1;
  color: var(--c-accent-lime);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  background: rgba(216, 243, 78, 0.18);
  color: var(--c-accent-lime);
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--c-sidebar-border);
}

.agent-model-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.model-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-accent-emerald);
  box-shadow: 0 0 8px var(--c-accent-emerald);
  flex-shrink: 0;
}

.model-info {
  display: flex;
  flex-direction: column;
}

.model-name {
  font-size: 0.74rem;
  font-weight: 600;
  color: #ffffff;
}

.model-desc {
  font-size: 0.65rem;
  color: var(--c-sidebar-muted);
}

/* ==========================================================================
   2. 中央對話主視窗 (Chat Main Stream)
   ========================================================================== */
.agent-main {
  grid-area: main;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--c-bg-chat);
  overflow: hidden;
}

/* 頂部功能導航列 */
.agent-header {
  height: 62px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 30;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.sidebar-toggle-btn {
  display: flex;
}

.header-btn {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.72rem;
  color: var(--c-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--c-bg-surface-subtle);
  color: var(--c-primary);
  border-color: #bad5c5;
}

.header-btn.is-active {
  background: #eef8f3;
  border-color: #10b981;
  color: #114e3e;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-primary);
  letter-spacing: -0.01em;
}

.header-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.6rem;
  background: #eef7f2;
  border: 1px solid #d3e8dc;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  color: #1a634e;
  font-weight: 500;
}

.status-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent-emerald);
  animation: pulse-ring 2s infinite ease-out;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.9; }
  50% { transform: scale(1.4); opacity: 0.4; }
  100% { transform: scale(0.9); opacity: 0.9; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* 學校選擇器下拉元件 (鄉鎮 + 學校雙層聯動) */
.school-selector-wrapper {
  display: flex;
  align-items: center;
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.school-selector-wrapper:focus-within {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.selector-divider {
  width: 1px;
  height: 18px;
  background: var(--c-border);
  margin: 0 0.5rem;
}

.school-select-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--c-text-muted);
  margin-right: 0.35rem;
  user-select: none;
}

.school-select {
  border: none;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-text-main);
  outline: none;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  max-width: 170px;
}

.township-select {
  max-width: 110px;
}

/* 獨立訊息滾動區 */
.agent-chat-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.5rem 8.5rem; /* 底部預留懸浮輸入列空間 */
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 初始歡迎畫面 (Zero State) */
.welcome-container {
  width: 100%;
  max-width: 760px;
  margin: auto 0;
  text-align: center;
  padding: 2rem 1rem;
  animation: fadeIn 0.4s ease-out;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  background: #edf7ed;
  border: 1px solid #d0e7d5;
  border-radius: var(--radius-full);
  color: #1a5e46;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.welcome-headline {
  margin: 0 0 1rem;
  font-size: clamp(1.45rem, 3.2vw, 2.1rem);
  font-weight: 700;
  color: var(--c-primary);
  line-height: 1.35;
  letter-spacing: -0.025em;
}

.welcome-lead {
  margin: 0 auto 2.25rem;
  max-width: 580px;
  font-size: 0.92rem;
  color: var(--c-text-muted);
  line-height: 1.7;
}

/* 快捷問題晶片卡片 */
.prompt-chips-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  text-align: left;
}

.prompt-chip {
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.prompt-chip:hover {
  background: #ffffff;
  border-color: #10b981;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.prompt-chip:active {
  transform: translateY(0);
}

.chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #eef8f3;
  color: #125e46;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.chip-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chip-content strong {
  font-size: 0.86rem;
  color: var(--c-text-main);
  font-weight: 600;
}

.chip-content span {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  line-height: 1.4;
}

/* 對話訊息串流卡片 */
.chat-message-row {
  width: 100%;
  max-width: 820px;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.9rem;
  animation: messageIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.chat-avatar--ai {
  background: linear-gradient(135deg, #164d3e, #0c2b23);
  color: #d8f34e;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-avatar--user {
  background: #276251;
  color: #ffffff;
}

.chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.chat-message-row--user .chat-bubble-wrap {
  align-items: flex-end;
}

.chat-bubble {
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.7;
}

.chat-bubble--user {
  background: #143e33;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(20, 62, 51, 0.18);
}

.chat-bubble--ai {
  background: var(--c-bg-surface);
  color: var(--c-text-main);
  border: 1px solid var(--c-border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-md);
}

/* 思考中載入狀態與動態視覺 */
.thinking-row {
  opacity: 1;
  transition: opacity 0.25s ease-out;
}

.chat-bubble--thinking {
  background: linear-gradient(135deg, #ffffff 0%, #f7faf8 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.08);
  min-width: 260px;
  max-width: 440px;
  position: relative;
  overflow: hidden;
}

.thinking-content {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ai-typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  opacity: 0.8;
  animation: typingDotBounce 1.4s infinite ease-in-out both;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0s; }

.thinking-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #10b981;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.thinking-stage-wrap {
  min-height: 1.5rem;
  display: flex;
  align-items: center;
}

.thinking-stage-text {
  font-size: 0.86rem;
  color: var(--c-text-main);
  font-weight: 500;
  line-height: 1.4;
  animation: textFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.thinking-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(16, 185, 129, 0.12);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.thinking-progress-line {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, #10b981, #d8f34e, transparent);
  border-radius: 99px;
  animation: progressIndeterminate 1.6s infinite ease-in-out;
}

.thinking-shimmer {
  position: absolute;
  top: -50%;
  left: -50%;
  right: -50%;
  bottom: -50%;
  background: linear-gradient(
    60deg,
    transparent 30%,
    rgba(16, 185, 129, 0.04) 50%,
    transparent 70%
  );
  animation: shimmerMove 3s infinite linear;
  pointer-events: none;
}

@keyframes typingDotBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

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

@keyframes progressIndeterminate {
  0% {
    left: -40%;
  }
  100% {
    left: 100%;
  }
}

@keyframes shimmerMove {
  0% {
    transform: translate(-30%, -30%) rotate(0deg);
  }
  100% {
    transform: translate(30%, 30%) rotate(0deg);
  }
}


.ai-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--c-border-subtle);
}

.ai-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1b5d49;
  letter-spacing: 0.02em;
}

.ai-direction-card {
  margin: 0.4rem 0 0.85rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08) 0%, rgba(59, 130, 246, 0.14) 100%);
  border: 1px solid rgba(2, 132, 199, 0.28);
  border-left: 4.5px solid #0284c7;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08);
}

.ai-direction-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: #0284c7;
  letter-spacing: 0.04em;
}

.ai-direction-content {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

.ai-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1a4f40;
  margin: 0.85rem 0 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ai-action-list {
  margin: 0.4rem 0;
  padding-left: 1.25rem;
}

.ai-action-list li {
  margin-bottom: 0.35rem;
}

.ai-references-card {
  margin-top: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: #f2f7f3;
  border-radius: var(--radius-sm);
  border-left: 3px solid #10b981;
  font-size: 0.75rem;
  color: #405e54;
}

.ai-disclaimer {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.68rem;
  color: var(--c-text-light);
}

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

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

/* ==========================================================================
   3. 底部懸浮質感輸入區 (Composer Bar)
   ========================================================================== */
.agent-composer-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1.5rem 1rem;
  background: linear-gradient(to top, rgba(249, 251, 249, 0.98) 70%, rgba(249, 251, 249, 0) 100%);
  display: flex;
  justify-content: center;
  z-index: 25;
  pointer-events: none; /* 穿透至滾動區 */
}

.agent-composer-card {
  pointer-events: auto; /* 恢復輸入框點擊 */
  width: 100%;
  max-width: 820px;
  background: var(--c-bg-surface);
  border: 1px solid #d0dfd6;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-floating);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.agent-composer-card:focus-within {
  border-color: #10b981;
  box-shadow: 0 20px 48px -6px rgba(18, 62, 53, 0.22), 0 0 0 2px rgba(16, 185, 129, 0.18);
}

.composer-top {
  display: flex;
  align-items: center;
}

.file-attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  background: #edf6f0;
  border: 1px solid #c7e2d1;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  color: #175440;
}

.btn-remove-file {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.95rem;
  color: #658479;
  cursor: pointer;
  line-height: 1;
}

.btn-remove-file:hover {
  color: #b91c1c;
}

.composer-main {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

.composer-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f1f6f2;
  border: 1px solid #d8e5dd;
  color: #276251;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 2px;
  transition: all var(--transition-fast);
}

.composer-action-btn:hover {
  background: #e4efe7;
  color: #104436;
}

.file-attach-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.composer-textarea {
  flex: 1;
  min-height: 24px;
  max-height: 160px;
  padding: 0.4rem 0.35rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--c-text-main);
  resize: none;
  outline: none;
}

.composer-textarea::placeholder {
  color: #92aca1;
}

.composer-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--c-primary);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 2px;
  transition: all var(--transition-fast);
}

.composer-send-btn:hover:not(:disabled) {
  background: var(--c-primary-light);
  transform: scale(1.04);
}

.composer-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem 0.1rem;
  font-size: 0.68rem;
  color: var(--c-text-light);
}

.composer-hint {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-keyboard-hint kbd {
  padding: 0.1rem 0.3rem;
  background: #edf2ee;
  border: 1px solid #d4dfd7;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.65rem;
  color: #557268;
}

/* ==========================================================================
   4. 右側評估脈絡面板 (Context Inspector)
   ========================================================================== */
.agent-inspector {
  grid-area: inspector;
  min-width: 0;
  background: #f6faf7;
  border-left: 1px solid var(--c-border);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}

.inspector-header {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.inspector-close-btn:hover {
  background: #edf3ee;
  color: #b91c1c;
}

.inspector-eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #537d6f;
  display: block;
}

.inspector-title {
  margin: 0.2rem 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-primary);
}

.inspector-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.inspector-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--c-text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #eaf3ed;
  color: #538173;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.85rem;
}

.inspector-empty-state p {
  font-size: 0.8rem;
  line-height: 1.6;
  margin: 0;
}

/* 學校卡片 */
.inspector-school-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}

.school-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.school-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--c-primary);
}

.level-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.school-card-township {
  font-size: 0.74rem;
  color: var(--c-text-muted);
}

/* 摘要項目列表 */
.inspector-section {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.inspector-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.inspector-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #276251;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.inspector-value {
  font-size: 0.76rem;
  color: var(--c-text-muted);
  line-height: 1.5;
}

.inspector-report-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--c-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(18, 62, 53, 0.15);
}

.inspector-report-btn:hover {
  background: var(--c-primary-light);
  transform: translateY(-1px);
}

.inspector-report-note {
  font-size: 0.72rem;
  color: #2e6b59;
  background: #e4f2ea;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  margin: 0;
  border: 1px solid #c9e4d5;
}

/* ==========================================================================
   5. 響應式佈局 (Responsive Breakpoints)
   ========================================================================== */
@media (max-width: 1100px) {
  .agent-layout {
    grid-template-columns: 220px minmax(0, 1fr) !important;
    grid-template-areas: "sidebar main" !important;
  }
  
  .inspector-close-btn {
    display: flex;
  }

  .agent-inspector {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    box-shadow: -8px 0 28px rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    transition: transform var(--transition-smooth);
    z-index: 100;
    display: flex !important;
  }

  .agent-inspector.is-open {
    transform: translateX(0);
  }
}

@media (max-width: 768px) {
  .agent-layout {
    grid-template-columns: 1fr !important;
    grid-template-areas: "main" !important;
  }

  .agent-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.25);
    transform: translateX(-100%);
    transition: transform var(--transition-smooth);
    z-index: 100;
  }

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

  .sidebar-close-btn {
    display: flex;
  }

  .sidebar-toggle-btn {
    display: flex;
  }

  .prompt-chips-grid {
    grid-template-columns: 1fr;
  }

  .composer-keyboard-hint {
    display: none;
  }

  .header-status-tag {
    display: none;
  }
  
  .agent-chat-viewport {
    padding: 1rem 1rem 7.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   5. 討論與確認面板 (Discussion & Confirmation Panel) 專屬樣式
   ========================================================================== */

.inspector-sub {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  margin-top: 0.2rem;
  display: block;
}

/* 學校現況摘要卡 */
.discussion-school-card {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.school-title-wrap .school-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--c-primary);
}

.school-title-wrap .school-sub {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  margin-top: 0.15rem;
  display: block;
}

.discussion-counts-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.count-pill {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
}

.count-pill--confirmed { background: #e8f7ee; color: #166534; border: 1px solid #bbf7d0; }
.count-pill--suggested { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.count-pill--needs-data { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* 討論完成度進度條 */
.discussion-progress-section {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
}

.progress-title {
  font-weight: 600;
  color: var(--c-text-main);
}

.progress-stat {
  color: var(--c-primary);
}

.progress-track {
  height: 6px;
  background: #e2ece6;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* 狀態篩選標籤 */
.discussion-filters {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.filter-tab {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  color: var(--c-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.filter-tab:hover {
  background: #f0fdf4;
  color: var(--c-primary);
}

.filter-tab.is-active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #ffffff;
  font-weight: 600;
}

/* 討論項目清單與群組 */
.discussion-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1;
}

.discussion-empty-notice {
  text-align: center;
  padding: 2rem 1rem;
  background: #ffffff;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-md);
  color: var(--c-text-muted);
}

.discussion-empty-notice p {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.discussion-empty-notice .sub-hint {
  font-size: 0.75rem;
  line-height: 1.5;
}

.category-group-title {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.category-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent-lime);
}

.category-items-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* 單一討論項目卡片 */
.discussion-item-card {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.8rem;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.discussion-item-card:hover {
  border-color: #94d3a2;
  box-shadow: var(--shadow-sm);
}

.discussion-item-card.is-confirmed {
  border-left: 3px solid #16a34a;
  background: #fbfdfb;
}

.discussion-item-card.is-rejected {
  opacity: 0.6;
  background: #fafafa;
}

.item-primary-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.btn-delete-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  opacity: 0.7;
  transition: all 0.15s ease;
}

.btn-delete-item:hover {
  opacity: 1;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.item-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  flex: 1;
}

.discussion-item-checkbox {
  width: 15px;
  height: 15px;
  accent-color: #16a34a;
  margin-top: 0.15rem;
  cursor: pointer;
  flex-shrink: 0;
}

.item-title {
  font-size: 0.84rem;
  color: var(--c-text-main);
  line-height: 1.45;
  font-weight: 500;
}

.discussion-item-card.is-confirmed .item-title {
  color: #14532d;
  font-weight: 600;
}

.item-meta-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  flex-wrap: wrap;
}

.discussion-status-badge {
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.discussion-status--suggested { background: #eff6ff; color: #1d4ed8; }
.discussion-status--discussing { background: #fefce8; color: #a16207; }
.discussion-status--confirmed { background: #f0fdf4; color: #15803d; }
.discussion-status--needs_data { background: #fff7ed; color: #c2410c; }
.discussion-status--rejected { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }

.item-source-tag {
  color: var(--c-text-muted);
}

.btn-toggle-detail {
  margin-left: auto;
  background: transparent;
  border: none;
  font-size: 0.68rem;
  color: #52796f;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.btn-toggle-detail:hover {
  background: #edf4ef;
}

/* 展開抽屜區塊 */
.item-expanded-drawer {
  padding-top: 0.45rem;
  margin-top: 0.35rem;
  border-top: 1px dashed var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.75rem;
}

.item-detail-block strong {
  color: var(--c-primary);
}

.item-detail-block p {
  margin: 0.2rem 0 0;
  color: var(--c-text-main);
  line-height: 1.5;
}

.item-status-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.actions-label {
  color: var(--c-text-muted);
}

.btn-status-action {
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.68rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-status-action:hover {
  background: #f8fafc;
}

.btn-status-action--discussing:hover { background: #fefce8; border-color: #facc15; }
.btn-status-action--needs-data:hover { background: #fff7ed; border-color: #fdba74; }
.btn-status-action--rejected:hover { background: #fee2e2; border-color: #fca5a5; }

.item-note-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.note-label {
  font-size: 0.68rem;
  color: var(--c-text-muted);
}

.item-note-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  background: #fafdfa;
  outline: none;
}

.item-note-input:focus {
  border-color: #10b981;
  background: #ffffff;
}

/* Sticky 底部產報按鈕區 */
.discussion-sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(246, 250, 247, 0.8) 0%, rgba(246, 250, 247, 1) 40%);
  padding: 0.75rem 0 0.25rem;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 10;
}

.btn-generate-report {
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-generate-report.is-ready {
  background: var(--c-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(13, 41, 43, 0.25);
}

.btn-generate-report.is-ready:hover {
  background: var(--c-primary-light);
  transform: translateY(-1px);
}

.btn-generate-report.is-disabled {
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.75;
}

.panel-report-notice {
  font-size: 0.72rem;
  color: #166534;
  margin: 0;
  text-align: center;
}

/* 尚未達成產報門檻提示區塊美化 */
.report-missing-requirements {
  margin-top: 0.55rem;
  padding: 0.6rem 0.75rem;
  background: #fffaf0;
  border: 1px solid #fbd38d;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(194, 65, 12, 0.05);
  animation: fadeIn 0.25s ease-out;
}

.missing-header {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #9c4221;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.missing-icon {
  color: #dd6b20;
  flex-shrink: 0;
}

.missing-title {
  letter-spacing: 0.02em;
}

.missing-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.missing-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: #7b341e;
  background: rgba(254, 235, 200, 0.55);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px dashed #f6ad55;
  transition: all 0.15s ease;
}

.missing-item:hover {
  background: rgba(254, 235, 200, 0.85);
  border-color: #ed8936;
}

.missing-bullet {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #dd6b20;
  flex-shrink: 0;
}

.missing-text {
  line-height: 1.35;
  font-weight: 500;
}

/* ==========================================================================
   使用指南與佐證代碼說明彈窗 (Guide Modal)
   ========================================================================== */

.guide-toggle-btn {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #10b981;
  font-weight: 600;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.guide-toggle-btn:hover {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #059669;
  transform: translateY(-1px);
}

.guide-btn-text {
  font-size: 0.82rem;
}

.nav-item--button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

/* Modal 遮罩與主體 */
.guide-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 32, 26, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.guide-modal-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.guide-modal {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.guide-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.guide-modal-dialog {
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border);
  border-radius: 18px;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 48px rgba(10, 32, 26, 0.28), 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.guide-modal.is-visible .guide-modal-dialog {
  transform: scale(1) translateY(0);
}

.guide-modal-header {
  padding: 1.25rem 1.6rem;
  border-bottom: 1px solid var(--c-border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(180deg, #f8faf8 0%, #ffffff 100%);
}

.guide-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.guide-badge-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.guide-modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-text-main);
  letter-spacing: -0.01em;
}

.guide-modal-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

.guide-modal-close-btn {
  background: transparent;
  border: none;
  color: var(--c-text-muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.guide-modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--c-text-main);
}

.guide-modal-body {
  padding: 1.5rem 1.6rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.guide-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.guide-section-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--c-text-main);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.guide-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #123e35;
  color: #d8f34e;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

.guide-step-card {
  background: #f8faf8;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.guide-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.step-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: #10b981;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.step-card-title {
  font-size: 0.9rem;
  color: var(--c-text-main);
}

.step-card-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--c-text-muted);
  line-height: 1.5;
}

.guide-lead-text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--c-text-muted);
}

/* 來源代碼清單卡片 */
.guide-source-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.source-item-card {
  display: flex;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--c-border);
  background: #ffffff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.source-item-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.source-item-badge {
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  font-family: monospace;
  height: fit-content;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 各代碼識別色彩 */
.source-item--data {
  border-left: 4.5px solid #10b981;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.04) 0%, #ffffff 100%);
}
.source-item--data .source-item-badge {
  background: #10b981;
  color: #ffffff;
}

.source-item--interview {
  border-left: 4.5px solid #0284c7;
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.04) 0%, #ffffff 100%);
}
.source-item--interview .source-item-badge {
  background: #0284c7;
  color: #ffffff;
}

.source-item--confirmation {
  border-left: 4.5px solid #d97706;
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.04) 0%, #ffffff 100%);
}
.source-item--confirmation .source-item-badge {
  background: #d97706;
  color: #ffffff;
}

.source-item--topic {
  border-left: 4.5px solid #6366f1;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.04) 0%, #ffffff 100%);
}
.source-item--topic .source-item-badge {
  background: #6366f1;
  color: #ffffff;
}

.source-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.source-item-name {
  font-size: 0.9rem;
  color: var(--c-text-main);
}

.source-item-detail {
  margin: 0;
  font-size: 0.81rem;
  color: var(--c-text-muted);
  line-height: 1.5;
}

.source-item-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--c-text-light);
  margin-top: 0.15rem;
}

/* 注意事項方塊 */
.guide-notice-box {
  background: #fdfbf7;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.notice-item {
  font-size: 0.81rem;
  color: #7c2d12;
  line-height: 1.55;
}

.notice-item strong {
  color: #9a3412;
}

.guide-modal-footer {
  padding: 1rem 1.6rem;
  border-top: 1px solid var(--c-border-subtle);
  display: flex;
  justify-content: flex-end;
  background: #fafcfa;
}

.btn-guide-confirm {
  background: linear-gradient(135deg, #123e35 0%, #1c5b4e 100%);
  color: #ffffff;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(18, 62, 53, 0.2);
}

.btn-guide-confirm:hover {
  background: linear-gradient(135deg, #164d42 0%, #237262 100%);
  box-shadow: 0 4px 12px rgba(18, 62, 53, 0.3);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .guide-cards-grid {
    grid-template-columns: 1fr;
  }
  .guide-modal {
    padding: 0.5rem;
  }
  .guide-modal-dialog {
    max-height: 95vh;
  }
  .guide-btn-text {
    display: none;
  }
}


/* v2.1.0 — 公開資料標準化證據狀態 */
.school-public-evidence-row { display:block; margin-top:.45rem; }
.public-evidence-badge { display:inline-flex; align-items:center; gap:.28rem; border:1px solid rgba(14,116,144,.2); background:rgba(14,165,233,.09); color:#075985; border-radius:999px; padding:.22rem .55rem; font-size:.72rem; font-weight:700; line-height:1.35; }
.public-evidence-badge::before { content:'D'; display:inline-grid; place-items:center; width:1.15rem; height:1.15rem; border-radius:50%; background:#0e7490; color:#fff; font-size:.62rem; font-weight:800; }
.public-evidence-badge--missing { color:#64748b; background:#f8fafc; border-color:#cbd5e1; }
.public-evidence-badge--missing::before { background:#94a3b8; }

/* v3 live AI status */
.header-status-tag.is-ready .status-pulse{background:#22c55e;box-shadow:0 0 0 4px rgba(34,197,94,.12)}
.header-status-tag.is-warning .status-pulse{background:#f59e0b;box-shadow:0 0 0 4px rgba(245,158,11,.12)}
.header-status-tag.is-error .status-pulse{background:#ef4444;box-shadow:0 0 0 4px rgba(239,68,68,.12)}
.file-attachment-badge{max-width:100%;}
.file-name-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:420px;}
.assistant-config-link{text-decoration:none;display:inline-flex;align-items:center;gap:6px;white-space:nowrap}

/* Research workspace: allow selectors to wrap instead of squeezing the title. */
@media (max-width: 768px) {
  .agent-header { height: auto; min-height: 62px; flex-wrap: wrap; gap: .5rem; padding: .65rem 1rem; }
  .header-left { min-width: 0; width: 100%; }
  .header-title-group { min-width: 0; }
  .header-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-right { width: 100%; min-width: 0; gap: .4rem; }
  .school-selector-wrapper { min-width: 0; flex: 1; padding: .35rem; gap: .25rem; }
  .school-select { min-width: 0; max-width: 42vw; flex: 1; }
  .school-select-label { white-space: nowrap; }
  .summary-toggle-btn { flex-shrink: 0; }
}
@media (max-width: 768px) {
  .agent-header { position: relative; }
  .header-left { padding-right: 104px; }
  .header-right { display: block; }
  .summary-toggle-btn { position: absolute; right: 1rem; top: .65rem; }
  .school-selector-wrapper { width: 100%; box-sizing: border-box; }
  .school-select-label span { display: none; }
  .school-select { max-width: none; }
  #assistant-township { flex: 0 1 105px; width: 105px; }
  #assistant-school { flex: 1 1 155px; width: 155px; }
}
