/* ========== CSS Variables ========== */
:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-sidebar: #1e1b4b;
  --bg-sidebar-hover: #312e81;
  --bg-chat: #f8fafc;
  --bg-message-user: #4f46e5;
  --bg-message-bot: #ffffff;

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;
  --text-sidebar: #c7d2fe;
  --text-sidebar-active: #ffffff;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --sidebar-width: 280px;
  --topbar-height: 60px;
  --input-height: 80px;

  --transition: all 0.2s ease;

  --risk-high-bg: #fef2f2;
  --risk-high-border: #fecaca;
  --risk-high-text: #dc2626;
  --risk-medium-bg: #fffbeb;
  --risk-medium-border: #fde68a;
  --risk-medium-text: #d97706;
  --risk-low-bg: #f0fdf4;
  --risk-low-border: #bbf7d0;
  --risk-low-text: #16a34a;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-sidebar: #0c0a1d;
  --bg-sidebar-hover: #1e1b4b;
  --bg-chat: #0f172a;
  --bg-message-user: #4f46e5;
  --bg-message-bot: #1e293b;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --border: #334155;
  --border-light: #1e293b;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);

  --risk-high-bg: #2d1215;
  --risk-high-border: #7f1d1d;
  --risk-medium-bg: #2d2305;
  --risk-medium-border: #78350f;
  --risk-low-bg: #052e16;
  --risk-low-border: #14532d;
}

/* ========== Base Reset ========== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

/* ========== App Layout ========== */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========== Sidebar ========== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: white;
  letter-spacing: 1px;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-sidebar);
  opacity: 0.7;
}

.new-chat-btn {
  margin: 16px 16px 8px;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  font-family: inherit;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.5);
}

.sidebar-section {
  padding: 8px 16px;
  flex: 1;
  overflow-y: auto;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-sidebar);
  opacity: 0.5;
  margin-bottom: 8px;
  padding: 0 4px;
}


.nav-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.nav-item.active {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
  font-weight: 500;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  position: relative;
}

.history-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.history-item.active {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.history-item i {
  width: 16px;
  text-align: center;
  font-size: 12px;
  flex-shrink: 0;
}

.history-item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item .delete-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-sidebar);
  cursor: pointer;
  padding: 4px;
  font-size: 11px;
  opacity: 0.6;
  flex-shrink: 0;
}

.history-item:hover .delete-btn {
  display: block;
}

.history-item .delete-btn:hover {
  opacity: 1;
  color: var(--danger);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: var(--text-sidebar);
  opacity: 0.5;
  line-height: 1.5;
}

.disclaimer i {
  margin-top: 2px;
  flex-shrink: 0;
}

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-chat);
}

/* ========== Top Bar ========== */
.top-bar {
  height: var(--topbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.menu-toggle:hover {
  background: var(--bg-tertiary);
}

.top-bar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  max-width: 180px;
}

.user-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ========== Chat Area ========== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* ========== Welcome Screen ========== */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(64px, 10vh, 118px) 20px 40px;
  width: 100%;
}

.welcome-center {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-greeting {
  margin-bottom: 12px;
  font-size: 18px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
  opacity: 1;
}
.welcome-greeting .greeting-time {
  font-weight: 600;
  color: var(--text-primary);
}
.welcome-greeting .greeting-name {
  color: var(--text-secondary);
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-center h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome-center > p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

/* Welcome File Preview */
.welcome-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.welcome-file-preview i {
  font-size: 20px;
  color: var(--primary);
}

.welcome-file-info {
  flex: 1;
  min-width: 0;
}

.welcome-file-name {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.welcome-file-size {
  font-size: 11px;
  color: var(--text-tertiary);
}

.welcome-file-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  transition: var(--transition);
}

.welcome-file-remove:hover {
  color: var(--danger);
}

/* Welcome Input Box */
.welcome-input-box {
  width: 100%;
  height: 196px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.welcome-input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.welcome-input-box textarea {
  width: 100%;
  flex: 1;
  border: none;
  background: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.6;
  min-height: 0;
  height: auto;
  padding: 0;
  overflow-y: auto;
}

.welcome-input-box textarea::placeholder {
  color: var(--text-tertiary);
}

.welcome-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  flex-shrink: 0;
}

.welcome-input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.welcome-upload-btn {
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 15px;
}

.welcome-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.welcome-input-hint {
  min-width: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.welcome-send-btn {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.welcome-send-btn:hover {
  background: var(--primary-dark);
}

/* Chat Input Bar (conversation mode) */
.chat-input-bar {
  padding: 12px 24px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

.chat-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.chat-file-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.chat-file-preview-item i {
  font-size: 18px;
  color: var(--primary);
}

.chat-file-info {
  flex: 1;
  min-width: 0;
}

.chat-file-name {
  display: block;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-file-size {
  font-size: 11px;
  color: var(--text-tertiary);
}

.chat-file-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  transition: var(--transition);
}

.chat-file-remove:hover {
  color: var(--danger);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  transition: var(--transition);
  max-width: 720px;
  margin: 0 auto;
}

.chat-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.chat-upload-btn {
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 16px;
  flex-shrink: 0;
}

.chat-upload-btn:hover {
  color: var(--primary);
}

.chat-action-btn {
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: var(--transition);
  font-size: 14px;
  flex-shrink: 0;
}

.chat-action-btn:hover:not(:disabled) {
  color: var(--primary);
}

.chat-action-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.chat-action-btn.stop {
  color: var(--danger);
}

.chat-input-field {
  flex: 1;
  border: none;
  background: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  padding: 6px 0;
}

.chat-input-field::placeholder {
  color: var(--text-tertiary);
}

/* Nav Badge */
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  font-weight: 500;
}

.nav-badge.pro {
  background: #2c3e50;
  color: #fff;
  border-color: #2c3e50;
}

.quick-questions {
  width: 100%;
  text-align: center;
}

.quick-title {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.quick-chip {
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.quick-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

/* ========== Messages ========== */
.messages-container {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.message {
  display: flex;
  gap: 12px;
  animation: messageIn 0.3s ease;
}

.message.user {
  flex-direction: row-reverse;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 4px;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.message.bot .message-avatar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.message-sender {
  font-size: 13px;
  font-weight: 600;
}

.message-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
  max-width: 100%;
}

.message.user .message-content {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
}

.message.user .message-header {
  flex-direction: row-reverse;
}

.message.user .message-bubble {
  background: var(--bg-message-user);
  color: var(--text-inverse);
  border-bottom-right-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-lg);
}

.message.bot .message-bubble {
  background: var(--bg-message-bot);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

/* ===== Markdown rich content within bot messages ===== */
.message.bot .message-bubble {
  font-size: 14px;
  line-height: 1.8;
}

.message.bot .message-bubble h2.md-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin: 22px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  line-height: 1.4;
}

.message.bot .message-bubble h3.md-heading {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 22px 0 10px;
  padding: 8px 14px;
  background: #f1f5f9;
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}

.message.bot .message-bubble h4.md-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 6px;
  padding: 4px 10px;
  border-left: 3px solid #94a3b8;
  line-height: 1.5;
}

.message.bot .message-bubble h4.md-bold-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 14px 0 4px;
  padding: 0;
  border-left: none;
}

.message.bot .message-bubble h5.md-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 12px 0 6px;
}

.md-heading-num {
  color: var(--primary);
  margin-right: 4px;
}

.message.bot .message-bubble p {
  margin: 6px 0;
  line-height: 1.85;
}

.message.bot .message-bubble ul {
  margin: 6px 0 12px;
  padding-left: 26px;
}

.message.bot .message-bubble li {
  margin: 5px 0;
  line-height: 1.85;
  padding-left: 2px;
  word-break: break-word;
}

.message.bot .message-bubble blockquote {
  margin: 10px 0;
  padding: 10px 16px;
  border-left: 4px solid var(--primary);
  background: rgba(45, 123, 244, 0.06);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.message.bot .message-bubble blockquote p {
  margin: 3px 0;
}

.md-table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 340px;
}

.message-bubble table th {
  background: #eef2ff;
  font-weight: 600;
  color: #3730a3;
  padding: 10px 14px;
  text-align: left;
  border: 1px solid #c7d2fe;
  white-space: nowrap;
}

.message-bubble table td {
  padding: 9px 14px;
  border: 1px solid #e2e8f0;
  vertical-align: top;
  line-height: 1.65;
  color: var(--text-primary);
}

.message-bubble table tr:nth-child(even) td {
  background: #f8fafc;
}

.message-bubble table tr:hover td {
  background: #eef2ff;
}

.stream-bubble {
  white-space: pre-wrap;
  word-break: break-word;
}

.stream-consult-card {
  margin-top: 0;
}

.stream-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.stream-error i {
  margin-top: 3px;
}

.stream-cursor {
  animation: blink 0.7s infinite;
  color: var(--primary);
  font-weight: bold;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
}

.message-file i {
  font-size: 20px;
}

/* ========== Risk Report Card ========== */
.report-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 8px;
}

.report-header {
  padding: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.report-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-header p {
  font-size: 13px;
  opacity: 0.85;
}

.report-stats {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.stat-item {
  flex: 1;
  text-align: center;
  padding: 10px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-value.high { color: var(--danger); }
.stat-value.medium { color: var(--warning); }
.stat-value.low { color: var(--success); }

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.risk-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.risk-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.risk-item:hover {
  box-shadow: var(--shadow-md);
}

.risk-item-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.risk-item.high .risk-item-header {
  background: var(--risk-high-bg);
  border-bottom: 1px solid var(--risk-high-border);
}

.risk-item.medium .risk-item-header {
  background: var(--risk-medium-bg);
  border-bottom: 1px solid var(--risk-medium-border);
}

.risk-item.low .risk-item-header {
  background: var(--risk-low-bg);
  border-bottom: 1px solid var(--risk-low-border);
}

.risk-badge {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.risk-badge.high {
  background: var(--danger);
  color: white;
}

.risk-badge.medium {
  background: var(--warning);
  color: white;
}

.risk-badge.low {
  background: var(--success);
  color: white;
}

.risk-item-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.risk-item-toggle {
  color: var(--text-tertiary);
  font-size: 12px;
  transition: transform 0.2s;
}

.risk-item.expanded .risk-item-toggle {
  transform: rotate(180deg);
}

.risk-item-body {
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.risk-item.expanded .risk-item-body {
  padding: 16px;
  max-height: 800px;
}

.risk-detail-section {
  margin-bottom: 14px;
}

.risk-detail-section:last-child {
  margin-bottom: 0;
}

.risk-detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.risk-detail-label i {
  font-size: 11px;
}

.risk-detail-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary-light);
}

.risk-suggestion {
  padding: 10px 14px;
  background: #ecfdf5;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success);
  font-size: 13px;
  line-height: 1.7;
}

[data-theme="dark"] .risk-suggestion {
  background: #052e16;
}

.report-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ========== Consultation Answer Card ========== */
.consult-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 8px;
}

.consult-answer {
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
}

.legal-refs {
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legal-ref {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 13px;
}

.legal-ref-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--primary);
}

.legal-ref-content {
  color: var(--text-secondary);
  line-height: 1.6;
}

.offline-guide {
  margin: 4px 20px 18px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #eef6ff 0%, #e0ecff 100%);
  border: 1px solid #93c5fd;
  border-radius: var(--radius-md);
  border-left: 5px solid #2563eb;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
}

.offline-guide-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 12px;
}

.offline-guide-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.offline-guide-content {
  font-size: 14px;
  color: #1e3a8a;
  line-height: 1.85;
  white-space: pre-wrap;
}

.offline-institution-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.offline-institution-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(147, 197, 253, 0.8);
  border-radius: var(--radius-md);
}

.offline-institution-rank {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.offline-institution-main {
  flex: 1;
  min-width: 0;
}

.offline-institution-name {
  font-size: 14px;
  font-weight: 700;
  color: #172554;
  margin-bottom: 5px;
}

.offline-institution-address,
.offline-institution-meta {
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
}

.offline-institution-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.offline-nav-button {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.offline-nav-button:hover {
  background: #1d4ed8;
}

[data-theme="dark"] .offline-guide {
  background: linear-gradient(135deg, #172554 0%, #1e1b4b 100%);
  border-color: #1d4ed8;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
}

[data-theme="dark"] .offline-guide-title {
  color: #93c5fd;
}

[data-theme="dark"] .offline-guide-content {
  color: #bfdbfe;
}

[data-theme="dark"] .offline-institution-card {
  background: rgba(15, 23, 42, 0.78);
  border-color: #1d4ed8;
}

[data-theme="dark"] .offline-institution-name {
  color: #dbeafe;
}

[data-theme="dark"] .offline-institution-address,
[data-theme="dark"] .offline-institution-meta {
  color: #bfdbfe;
}

/* ========== Follow-up Suggestions ========== */
.followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.followup-chip {
  padding: 7px 14px;
  background: var(--primary-bg);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.followup-chip:hover {
  background: var(--primary);
  color: white;
}

/* ========== Typing Indicator ========== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30%           { opacity: 1;   transform: scale(1);   }
}

/* ========== Buttons ========== */
.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-bg);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ========== Drop Overlay ========== */
.drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(79, 70, 229, 0.1);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.drop-overlay.active {
  display: flex;
}

.drop-content {
  background: var(--bg-primary);
  padding: 48px;
  border-radius: var(--radius-xl);
  text-align: center;
  border: 3px dashed var(--primary);
  box-shadow: var(--shadow-xl);
}

.drop-content i {
  font-size: 56px;
  color: var(--primary);
  margin-bottom: 16px;
}

.drop-content p {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.drop-content span {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========== Module B Multi-file Upload ========== */
body.module-b .welcome-upload-btn,
body.module-b .chat-upload-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

body.module-b .welcome-upload-btn:hover,
body.module-b .chat-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

.b-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
  max-height: 64px;
  overflow-y: auto;
  padding: 0;
  margin-bottom: 8px;
}

.welcome-input-box .b-file-chips {
  flex-shrink: 0;
  min-height: 32px;
}

.b-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-primary);
  max-width: 220px;
}

.b-file-chip i {
  font-size: 12px;
  color: var(--primary);
  flex-shrink: 0;
}

.b-file-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.b-file-chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0;
  line-height: 1;
  font-size: 11px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.b-file-chip-remove:hover {
  color: var(--danger);
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header h2 i {
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--bg-tertiary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 3px;
  opacity: 0.5;
}

::-webkit-scrollbar-thumb:hover {
  opacity: 1;
}

/* ========== Export Button ========== */
.export-btn {
  width: auto !important;
  padding: 0 12px !important;
  gap: 5px;
  border-radius: var(--radius-full);
  background: var(--primary-bg);
  border: 1px solid var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
}

.export-btn:hover {
  background: var(--primary);
  color: white;
}

.export-label {
  font-size: 12px;
  line-height: 1;
}

@media (max-width: 480px) {
  .export-label {
    display: none;
  }
  .export-btn {
    width: 32px !important;
    padding: 0 !important;
  }
}

/* ========== Voice Input Button ========== */
.voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.voice-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary-light);
}

.voice-btn.recording {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  animation: voicePulse 1.2s ease-in-out infinite;
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    z-index: 200;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .feature-cards {
    grid-template-columns: 1fr;
  }

  .feature-cards-dual {
    grid-template-columns: 1fr;
  }

  .feature-card-large {
    padding: 22px 18px;
  }

  .report-stats {
    flex-wrap: wrap;
  }

  .stat-item {
    min-width: calc(33% - 8px);
  }
}

@media (max-width: 480px) {
  .welcome-screen h2 {
    font-size: 22px;
  }

  .quick-chips {
    flex-direction: column;
  }

  .quick-chip {
    text-align: left;
  }

  .top-bar-title {
    font-size: 14px;
  }

  .user-chip span {
    display: none;
  }
}

/* ========== Mobile: chat bubbles & input ========== */
@media (max-width: 768px) {
  .main-content {
    width: 100vw;
  }

  .message-content {
    max-width: 92vw;
  }

  .chat-input-bar {
    padding: 8px 10px;
  }

  .chat-input-wrapper {
    gap: 6px;
  }

  .welcome-input-box {
    width: 95%;
  }

  .welcome-input-box textarea {
    font-size: 15px;
  }

  .legal-ref-card {
    padding: 10px;
  }

  .followup-chips {
    flex-direction: column;
    align-items: stretch;
  }

  .followup-chip {
    text-align: left;
  }

  .modal-content.report-modal {
    width: 96vw;
    max-width: 96vw;
    height: 90vh;
    max-height: 90vh;
    margin: 5vh 2vw;
    border-radius: var(--radius-md);
  }

  .top-bar-actions {
    gap: 4px;
  }

  .action-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}

/* ========== Desktop Pet ========== */
@keyframes petFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.desktop-pet {
  position: fixed;
  z-index: 900;
  width: 180px;
  height: 180px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.15s ease, filter 0.15s ease;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.18));
}

.desktop-pet-bubble {
  position: absolute;
  right: 104px;
  bottom: 154px;
  width: max-content;
  max-width: 230px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  box-shadow: var(--shadow-md);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  transform: translate(6px, 8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}

.desktop-pet-bubble::after {
  content: '';
  position: absolute;
  right: 14px;
  bottom: -7px;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}

.desktop-pet.show-bubble .desktop-pet-bubble {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.desktop-pet:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 6px 16px rgba(79, 70, 229, 0.35));
}

.desktop-pet.dragging {
  cursor: grabbing;
  transform: scale(1.08);
  filter: drop-shadow(0 8px 20px rgba(79, 70, 229, 0.45));
  transition: none;
}

.desktop-pet.dragging .desktop-pet-bubble {
  opacity: 0;
}

.desktop-pet img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.desktop-pet.dragging img {
  animation: none;
}

.pet-mini-panel {
  position: fixed;
  z-index: 980;
  width: min(560px, calc(100vw - 24px));
  height: min(680px, 72vh);
  min-width: min(360px, calc(100vw - 24px));
  min-height: 420px;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  animation: messageIn 0.18s ease;
}

.pet-mini-panel.expanded {
  width: min(760px, calc(100vw - 24px));
  height: min(780px, 82vh);
}

.pet-mini-panel[hidden] {
  display: none;
}

.pet-mini-panel.dragging {
  transition: none;
  user-select: none;
}

.pet-mini-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  cursor: move;
  font-size: 14px;
  font-weight: 600;
}

.pet-mini-header span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pet-mini-header i {
  color: var(--primary);
}

.pet-mini-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pet-mini-header button,
.pet-mini-input-row button,
.pet-mini-view-full,
.pet-mini-candidate-action,
.pet-mini-secondary-action {
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.pet-mini-header button {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
}

.pet-mini-header button:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.pet-mini-body {
  flex: 1;
  min-height: 170px;
  padding: 14px;
  overflow-y: auto;
  background: var(--bg-primary);
}

.pet-mini-home {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pet-mini-home-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.pet-mini-home-head > span {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--primary-bg);
  color: var(--primary);
}

.pet-mini-home-head strong,
.pet-mini-home-head small,
.pet-mini-home-card strong,
.pet-mini-home-card small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pet-mini-home-head strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
}

.pet-mini-home-head small {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.pet-mini-home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pet-mini-home-card {
  min-height: 88px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.pet-mini-home-card:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.pet-mini-home-card.primary {
  grid-column: 1 / -1;
  min-height: 72px;
  background: var(--primary);
  color: var(--text-inverse);
}

.pet-mini-home-card.primary:hover {
  background: var(--primary-dark);
}

.pet-mini-home-card i {
  margin-top: 2px;
  color: var(--primary);
  font-size: 15px;
}

.pet-mini-home-card.primary i,
.pet-mini-home-card.primary small {
  color: rgba(255, 255, 255, 0.78);
}

.pet-mini-home-card span {
  min-width: 0;
}

.pet-mini-home-card strong {
  font-size: 12px;
  font-weight: 700;
}

.pet-mini-home-card small {
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.35;
}

.pet-mini-query {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.pet-mini-progress-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
}

.pet-mini-progress-head,
.pet-mini-progress-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pet-mini-progress-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.pet-mini-progress-title span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#petMiniProgressPercent {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.pet-mini-progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.pet-mini-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.28s ease;
}

.pet-mini-progress-sub {
  color: var(--text-tertiary);
  font-size: 12px;
}

.pet-mini-progress-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.pet-mini-progress-event {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.pet-mini-progress-event span {
  width: 48px;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.pet-mini-progress-event strong {
  font-weight: 500;
  color: var(--text-secondary);
}

.pet-mini-progress-event.muted strong {
  color: var(--text-tertiary);
  font-weight: 400;
}

.pet-mini-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.pet-mini-candidate-state {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
}

.pet-mini-candidate-state strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.pet-mini-candidate-state p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.pet-mini-candidate-state > i {
  margin-top: 2px;
  color: var(--primary);
  font-size: 18px;
}

.pet-mini-candidate-state.empty > i {
  color: var(--warning);
}

.pet-mini-muted {
  margin-top: 6px !important;
  color: var(--text-tertiary) !important;
  overflow-wrap: anywhere;
}

.pet-mini-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.pet-mini-action-row .pet-mini-secondary-action {
  margin-top: 0;
}

.pet-mini-footer-actions {
  padding-top: 2px;
}

.pet-mini-wechat-workbench {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pet-mini-workbench-primary,
.pet-mini-workbench-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.pet-mini-workbench-primary {
  display: grid;
  grid-template-columns: 40px minmax(0, auto);
  align-items: center;
  column-gap: 10px;
  padding: 12px;
  background: var(--primary);
  color: var(--text-inverse);
}

.pet-mini-workbench-primary span {
  grid-row: span 2;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
}

.pet-mini-workbench-primary strong,
.pet-mini-workbench-primary small,
.pet-mini-workbench-card strong,
.pet-mini-workbench-card small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pet-mini-workbench-primary strong {
  font-size: 13px;
  font-weight: 700;
}

.pet-mini-workbench-primary small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 11px;
}

.pet-mini-workbench-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.pet-mini-workbench-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pet-mini-workbench-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 74px;
  padding: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.pet-mini-workbench-card:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.pet-mini-workbench-card > i {
  margin-top: 2px;
  color: var(--primary);
  font-size: 15px;
}

.pet-mini-workbench-card span {
  min-width: 0;
}

.pet-mini-workbench-card strong {
  font-size: 12px;
  font-weight: 700;
}

.pet-mini-workbench-card small {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.35;
}

.pet-mini-candidates {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pet-mini-candidates-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-primary);
  font-size: 13px;
}

.pet-mini-candidates-head strong {
  font-weight: 600;
}

.pet-mini-candidates-head span {
  color: var(--text-tertiary);
  font-size: 12px;
  white-space: nowrap;
}

.pet-mini-candidate-dir {
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.pet-mini-candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pet-mini-candidate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
}

.pet-mini-staging-candidate {
  border-color: rgba(245, 158, 11, 0.38);
  background: rgba(245, 158, 11, 0.06);
}

.pet-mini-candidate-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.pet-mini-candidate-main i {
  margin-top: 3px;
  color: var(--primary);
  font-size: 16px;
}

.pet-mini-candidate-main div {
  min-width: 0;
}

.pet-mini-candidate-main strong,
.pet-mini-candidate-main span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pet-mini-candidate-main strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.pet-mini-candidate-main span {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.45;
}

.pet-mini-candidate-main .pet-mini-candidate-snippet {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.pet-mini-wechat-recent .pet-mini-candidate-list {
  gap: 10px;
}

.pet-mini-recent-item {
  gap: 10px;
}

.pet-mini-recent-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.pet-mini-candidate-main .pet-mini-recent-line span {
  margin-top: 0;
}

.pet-mini-status-chip {
  display: inline-flex !important;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary) !important;
  font-size: 11px !important;
  font-weight: 600;
  line-height: 1.4 !important;
}

.pet-mini-status-chip.primary {
  border-color: rgba(79, 70, 229, 0.28);
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary) !important;
}

.pet-mini-status-chip.success {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(16, 185, 129, 0.08);
  color: var(--success) !important;
}

.pet-mini-status-chip.warning {
  border-color: rgba(245, 158, 11, 0.32);
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning) !important;
}

.pet-mini-status-chip.muted {
  border-color: var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-tertiary) !important;
}

.pet-mini-inbox-item {
  align-items: stretch;
  flex-direction: column;
}

.pet-mini-case-folder-input {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  outline: none;
}

.pet-mini-case-folder-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.pet-mini-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.pet-mini-toggle-row input {
  flex-shrink: 0;
}

.pet-mini-candidate-action,
.pet-mini-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--text-inverse);
  font-size: 12px;
  font-weight: 600;
}

.pet-mini-secondary-action {
  margin-top: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.pet-mini-candidate-action:hover {
  background: var(--primary-dark);
}

.pet-mini-secondary-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pet-mini-result,
.pet-mini-error-wrap,
.pet-mini-error {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pet-mini-error-wrap {
  min-height: 100%;
}

.pet-mini-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
}

.pet-mini-summary {
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.75;
  word-break: break-word;
}

.pet-mini-summary p {
  margin: 4px 0;
}

.pet-mini-summary ul,
.pet-mini-summary ol {
  margin: 4px 0 4px 18px;
  padding: 0;
}

.pet-mini-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pet-mini-meta span {
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pet-mini-view-full {
  position: sticky;
  bottom: 0;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--text-inverse);
  font-size: 13px;
  font-weight: 600;
}

.pet-mini-view-full:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.pet-mini-error {
  flex-direction: row;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid rgba(239, 68, 68, 0.24);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
  color: var(--text-primary);
  font-size: 13px;
}

.pet-mini-error i {
  margin-top: 2px;
  color: var(--danger);
  flex-shrink: 0;
}

.pet-mini-error strong {
  display: block;
  margin-bottom: 4px;
}

.pet-mini-error-content {
  min-width: 0;
}

.pet-mini-error p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.pet-mini-error-hint {
  margin-top: 8px !important;
  color: var(--text-tertiary) !important;
}

.pet-mini-error-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: auto;
  padding: 10px 0 0;
  background: var(--bg-primary);
}

.pet-mini-error-detail {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
}

.pet-mini-error-detail summary {
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 600;
}

.pet-mini-error-detail pre {
  max-height: 150px;
  margin: 0;
  padding: 0 10px 10px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pet-mini-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.pet-mini-input-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 156px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
  outline: none;
  resize: none;
  overflow-y: auto;
}

.pet-mini-input-row textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.pet-mini-input-row button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--primary);
  color: var(--text-inverse);
}

.pet-mini-input-row button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.pet-mini-input-row button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .pet-mini-panel {
    width: calc(100vw - 20px);
    height: min(72vh, calc(100vh - 20px));
    min-width: 0;
    max-height: calc(100vh - 20px);
  }

  .pet-mini-panel.expanded {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
  }

  .pet-mini-header {
    padding: 10px 12px;
  }

  .pet-mini-body {
    padding: 12px;
  }

  .pet-mini-candidate {
    align-items: stretch;
    flex-direction: column;
  }

  .pet-mini-candidate-action {
    width: 100%;
  }

  .pet-mini-workbench-grid {
    grid-template-columns: 1fr;
  }

  .pet-mini-home-grid {
    grid-template-columns: 1fr;
  }

  .pet-mini-home-card.primary {
    grid-column: auto;
  }
}

/* ========== Task Complete Modal ========== */
.task-complete-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInDown 0.25s ease;
}

.task-complete-modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: messageIn 0.3s ease;
}

.task-complete-modal img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin-bottom: 12px;
}

.task-complete-modal h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.task-complete-modal p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.task-complete-modal .btn {
  min-width: 120px;
}
