/* ==========================================================================
   ART RAG - 現代藝術互動教學風格設計系統
   支援雙主題風格：明亮模式 (Light Mode，預設) 與 黑暗模式 (Dark Mode)
   ========================================================================== */

:root, [data-theme="light"] {
  /* 明亮美術館藝術風格 (Artistic Modern Light - 預設) */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-translucent: rgba(255, 255, 255, 0.88);
  --border-color: rgba(15, 23, 42, 0.08);
  --border-highlight: rgba(79, 70, 229, 0.35);

  /* 主色與藝術代表色 */
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
  --accent-soft: rgba(79, 70, 229, 0.08);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* 藝術類別專屬強調色 */
  --color-op-art: #6366f1;
  --color-minimalism: #0284c7;
  --color-neoplasticism: #d97706;
  --color-hard-edge: #db2777;
  --color-constructivism: #ea580c;
  --color-futurism: #059669;

  /* 陰影與圓角 */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.12);
  --backdrop-blur: blur(16px);

  /* 主題專屬背景與表面元件 */
  --bg-gradient: 
    radial-gradient(at 15% 15%, rgba(79, 70, 229, 0.06) 0px, transparent 50%),
    radial-gradient(at 85% 85%, rgba(219, 39, 119, 0.05) 0px, transparent 50%);
  --welcome-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.9) 100%);
  --scrollbar-thumb: rgba(15, 23, 42, 0.15);
  --scrollbar-thumb-hover: rgba(15, 23, 42, 0.28);
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-hover-bg: #ffffff;
  --ai-bubble-bg: #ffffff;
  --ai-avatar-bg: #e2e8f0;
  --ai-avatar-border: rgba(15, 23, 42, 0.1);
  --table-header-bg: #f8fafc;
  --table-stripe-bg: rgba(241, 245, 249, 0.6);
  --modal-overlay-bg: rgba(15, 23, 42, 0.45);
  --notice-bg: rgba(234, 179, 8, 0.1);
  --notice-border: rgba(202, 138, 4, 0.3);
  --notice-text: #854d0e;

  /* 字體系統 */
  --font-sans: 'Outfit', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  /* 現代暗黑玻璃擬態 (Artistic Dark Glassmorphism) */
  --bg-primary: #0d0f17;
  --bg-surface: #141824;
  --bg-surface-elevated: #1c2234;
  --bg-surface-translucent: rgba(20, 24, 36, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.3);

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --accent-soft: rgba(99, 102, 241, 0.15);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0d0f17;

  --color-op-art: #818cf8;
  --color-minimalism: #38bdf8;
  --color-neoplasticism: #facc15;
  --color-hard-edge: #f472b6;
  --color-constructivism: #fb923c;
  --color-futurism: #34d399;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.6);

  --bg-gradient: 
    radial-gradient(at 15% 15%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
    radial-gradient(at 85% 85%, rgba(236, 72, 153, 0.08) 0px, transparent 50%);
  --welcome-bg: linear-gradient(180deg, rgba(30, 36, 56, 0.6) 0%, rgba(20, 24, 36, 0.4) 100%);
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-hover-bg: rgba(99, 102, 241, 0.08);
  --ai-bubble-bg: #1c2234;
  --ai-avatar-bg: #252b42;
  --ai-avatar-border: rgba(255, 255, 255, 0.15);
  --table-header-bg: rgba(255, 255, 255, 0.05);
  --table-stripe-bg: rgba(255, 255, 255, 0.02);
  --modal-overlay-bg: rgba(0, 0, 0, 0.7);
  --notice-bg: rgba(234, 179, 8, 0.1);
  --notice-border: rgba(234, 179, 8, 0.25);
  --notice-text: #fef08a;
}

/* 全域重設 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-image: var(--bg-gradient);
  transition: background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 滾動條客製美化 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ==========================================================================
   頂部導航列 (App Header)
   ========================================================================== */
.app-header {
  height: 68px;
  background: var(--bg-surface-translucent);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 20;
  flex-shrink: 0;
  transition: background-color 0.3s, border-color 0.3s;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* 幾何藝術風格 Logo */
.brand-icon {
  width: 38px;
  height: 38px;
  position: relative;
  background: #181c2b;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.brand-icon .shape {
  position: absolute;
}
.brand-icon .s1 {
  width: 20px;
  height: 20px;
  background: #ef4444; /* 蒙德里安紅 */
  top: 0;
  left: 0;
}
.brand-icon .s2 {
  width: 16px;
  height: 16px;
  background: #3b82f6; /* 蒙德里安藍 */
  bottom: 0;
  right: 0;
  border-radius: 50%;
}
.brand-icon .s3 {
  width: 14px;
  height: 8px;
  background: #eab308; /* 蒙德里安黃 */
  bottom: 0;
  left: 0;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title span {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-secondary);
  border-left: 1px solid var(--border-color);
  padding-left: 8px;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

/* 按鈕元件系統 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  outline: none;
  background: transparent;
  color: var(--text-primary);
}

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

.btn-outline {
  border-color: var(--border-color);
  background: var(--bg-surface);
}
.btn-outline:hover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

/* 主題切換按鈕專屬微動畫 */
.theme-toggle-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.theme-toggle-btn:hover {
  border-color: var(--accent-primary);
}
.theme-icon {
  transition: transform 0.3s ease;
}
.theme-toggle-btn:hover .theme-icon {
  transform: rotate(25deg);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
}
.status-dot.configured {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}
.status-dot.unconfigured {
  background: #eab308;
  box-shadow: 0 0 8px #eab308;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}
.icon-btn:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   主版面佈局 (App Layout)
   ========================================================================== */
.app-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 68px);
  position: relative;
  overflow: hidden;
}

/* 側邊目錄抽屜 (Drawer) */
.category-sidebar {
  width: 320px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 15;
}

.category-sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-category-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.sidebar-category-card:hover {
  border-color: var(--border-highlight);
  background: var(--card-hover-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.sidebar-cat-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-cat-artists {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.artist-tag {
  font-size: 0.75rem;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  border: 1px solid var(--border-color);
}
.artist-tag:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

/* ==========================================================================
   對話核心區域 (Chat Main) - 上方歷史、下方輸入
   ========================================================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* 上方：歷史記錄滾動區 */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 12px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* 歡迎引言橫幅 */
.welcome-banner {
  max-width: 820px;
  margin: 10px auto 20px auto;
  background: var(--welcome-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
}

.welcome-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-primary);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
}

.welcome-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.welcome-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 0;
}
.welcome-desc b {
  color: var(--text-primary);
}

.scope-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--notice-text);
  margin-bottom: 22px;
}
.scope-notice svg {
  flex-shrink: 0;
  stroke: #eab308;
}

/* 快速探索卡片網格 */
.quick-starter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.starter-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.starter-card:hover {
  border-color: var(--accent-primary);
  background: var(--card-hover-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.category-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
}
.tag-op { background: rgba(99, 102, 241, 0.15); color: var(--color-op-art); }
.tag-minimal { background: rgba(2, 132, 199, 0.15); color: var(--color-minimalism); }
.tag-neo { background: rgba(217, 119, 6, 0.15); color: var(--color-neoplasticism); }

.starter-card h4 {
  font-size: 0.92rem;
  color: var(--text-primary);
  font-weight: 600;
}
.starter-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 對話訊息列表 */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* 訊息行 */
.message-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* 頭像 */
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.ai-avatar {
  background: var(--ai-avatar-bg);
  border: 1px solid var(--ai-avatar-border);
}
.user-avatar {
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

/* 訊息氣泡 */
.bubble {
  max-width: 82%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  position: relative;
  line-height: 1.7;
  word-break: break-word;
}

/* AI 氣泡樣式 */
.ai-bubble {
  background: var(--ai-bubble-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* 使用者氣泡樣式 */
.user-bubble {
  background: var(--accent-gradient);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

/* AI Markdown 內容美化 */
.ai-bubble h1, .ai-bubble h2, .ai-bubble h3, .ai-bubble h4 {
  color: var(--text-primary);
  margin: 12px 0 6px 0;
  font-weight: 600;
}
.ai-bubble h1 { font-size: 1.3rem; border-bottom: 1px solid var(--border-color); padding-bottom: 4px; }
.ai-bubble h2 { font-size: 1.15rem; }
.ai-bubble h3 { font-size: 1.05rem; color: var(--accent-primary); }

.ai-bubble p {
  margin-bottom: 10px;
}
.ai-bubble p:last-child {
  margin-bottom: 0;
}

.ai-bubble ul, .ai-bubble ol {
  margin: 8px 0 12px 20px;
}
.ai-bubble li {
  margin-bottom: 4px;
}

.ai-bubble strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Markdown 表格美化 */
.ai-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.88rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.ai-bubble th, .ai-bubble td {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}
.ai-bubble th {
  background: var(--table-header-bg);
  color: var(--text-primary);
  font-weight: 600;
}
.ai-bubble tr:nth-child(even) {
  background: var(--table-stripe-bg);
}

/* 訊息下方操作列 (複製、時間) */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.copy-btn:hover {
  color: var(--text-primary);
  background: var(--accent-soft);
}

/* 導師思考指示器 */
.message-row.typing {
  opacity: 0.9;
}
.dots-pulse {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}
.dots-pulse span {
  width: 6px;
  height: 6px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: pulse 1.4s infinite ease-in-out both;
}
.dots-pulse span:nth-child(1) { animation-delay: -0.32s; }
.dots-pulse span:nth-child(2) { animation-delay: -0.16s; }

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

.typing-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   下方固定輸入窗 (Bottom Fixed Input Bar)
   ========================================================================== */
.chat-input-bar {
  background: var(--bg-surface-translucent);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-top: 1px solid var(--border-color);
  padding: 12px 24px 16px 24px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 10;
  transition: background-color 0.3s, border-color 0.3s;
}

/* 推薦提問 Chips */
.chips-container {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.chips-container::-webkit-scrollbar {
  display: none;
}

.chips-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: inherit;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* 輸入框主體 */
.input-wrapper {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.input-box-container {
  flex: 1;
  display: flex;
}

.chat-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 140px;
  min-height: 24px;
  padding: 4px 0;
}
.chat-textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.input-footer-info {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   設定 Modal 視窗
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 22px;
}
.modal-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}
.modal-desc code {
  background: var(--bg-surface-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-hard-edge);
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.key-input-wrapper {
  display: flex;
  gap: 8px;
}
.key-input-wrapper input {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}
.key-input-wrapper input:focus {
  border-color: var(--accent-primary);
}

.key-test-status {
  font-size: 0.82rem;
  margin-top: 8px;
}
.key-test-status.success { color: #10b981; }
.key-test-status.error { color: #ef4444; }

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   響應式設計 (Responsive)
   ========================================================================== */
@media (max-width: 768px) {
  .app-header {
    padding: 0 16px;
  }
  .brand-title span, .brand-subtitle {
    display: none;
  }
  .btn-text {
    display: none;
  }
  .category-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    box-shadow: var(--shadow-lg);
  }
  .chat-history {
    padding: 16px 16px 8px 16px;
  }
  .bubble {
    max-width: 90%;
  }
  .chat-input-bar {
    padding: 10px 16px 14px 16px;
  }
  .quick-starter-grid {
    grid-template-columns: 1fr;
  }
}
