/* ================================================
   施工安全问答助手 - 样式表
   工程行业风格：沉稳、专业、简洁
   ================================================ */

/* ========== CSS 变量 ========== */
:root {
  /* 主色调 - 工程蓝 */
  --color-primary: #1a3a5c;
  --color-primary-light: #2c5282;
  --color-primary-dark: #0f2438;
  
  /* 安全色 */
  --color-safety: #f5a623;
  --color-safety-light: #fbd38d;
  --color-safety-dark: #d69e2e;
  
  /* 状态色 */
  --color-success: #38a169;
  --color-danger: #e53e3e;
  --color-warning: #d69e2e;
  --color-info: #3182ce;
  
  /* 中性色 */
  --color-bg: #f0f2f5;
  --color-bg-card: #ffffff;
  --color-bg-sidebar: #1a2b3c;
  --color-bg-hover: #f7fafc;
  --color-border: #e2e8f0;
  --color-border-dark: #2d3e50;
  
  /* 文字色 */
  --color-text: #2d3748;
  --color-text-secondary: #718096;
  --color-text-light: #a0aec0;
  --color-text-inverse: #ffffff;
  --color-text-sidebar: #cbd5e0;
  
  /* 尺寸 */
  --header-height: 60px;
  --sidebar-width: 280px;
  --input-area-height: auto;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
  
  /* 过渡 */
  --transition: all 0.2s ease;
}

/* ========== 基础重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", 
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ========== 顶部标题栏 ========== */
.app-header {
  height: var(--header-height);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: var(--shadow);
  z-index: 100;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-title h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-subtitle {
  font-size: 11px;
  color: var(--color-text-sidebar);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-badge {
  display: flex;
  gap: 6px;
}

.badge-item {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(245, 166, 35, 0.2);
  color: var(--color-safety-light);
  border: 1px solid rgba(245, 166, 35, 0.3);
}

.api-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-sidebar);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-warning);
  display: inline-block;
}

.api-status.connected .status-dot {
  background: var(--color-success);
}

.api-status.disconnected .status-dot {
  background: var(--color-danger);
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-inverse);
  cursor: pointer;
  padding: 4px;
}

/* ========== 主体布局 ========== */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ========== 左侧侧边栏 ========== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 50;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* 滚动条样式 */
.sidebar-content::-webkit-scrollbar {
  width: 4px;
}
.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--color-border-dark);
}

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-sidebar);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.sidebar-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sidebar-title-row .sidebar-title {
  margin-bottom: 0;
}

/* 功能模块标签 */
.module-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.module-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--color-text-sidebar);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  text-align: left;
  width: 100%;
}

.module-tab:hover {
  background: rgba(255,255,255,0.08);
  color: var(--color-text-inverse);
}

.module-tab.active {
  background: var(--color-safety);
  color: var(--color-primary-dark);
  font-weight: 600;
}

/* 设置项 */
.setting-item {
  margin-bottom: 14px;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--color-text-sidebar);
  margin-bottom: 6px;
  font-weight: 500;
}

.setting-hint {
  font-size: 10px;
  color: var(--color-text-light);
  font-weight: 400;
}

.setting-input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: var(--color-text-inverse);
  font-size: 13px;
  transition: var(--transition);
}

.setting-input:focus {
  outline: none;
  border-color: var(--color-safety);
  background: rgba(255,255,255,0.12);
}

.setting-input option {
  background: var(--color-bg-sidebar);
  color: var(--color-text-inverse);
}

.setting-textarea {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: var(--color-text-inverse);
  font-size: 12px;
  resize: vertical;
  margin-top: 6px;
  font-family: inherit;
  line-height: 1.5;
}

.setting-textarea:focus {
  outline: none;
  border-color: var(--color-safety);
}

.api-key-input-group {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.api-key-input-group .setting-input {
  flex: 1;
}

.btn-icon {
  padding: 6px 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: var(--color-text-sidebar);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background: rgba(255,255,255,0.15);
  color: var(--color-text-inverse);
}

/* 开关 */
.setting-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-toggle .setting-label {
  margin-bottom: 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 22px;
  transition: var(--transition);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.switch input:checked + .slider {
  background: var(--color-safety);
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
}

/* 按钮 */
.btn-small {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.btn-primary {
  background: var(--color-safety);
  color: var(--color-primary-dark);
}

.btn-primary:hover {
  background: var(--color-safety-dark);
}

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--color-text-sidebar);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.2);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  background: #c53030;
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-safety-light);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  transition: var(--transition);
}

.btn-text:hover {
  color: var(--color-safety);
  text-decoration: underline;
}

/* 历史对话列表 */
.sidebar-history {
  flex: 1;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item {
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.conversation-item:hover {
  background: rgba(255,255,255,0.1);
}

.conversation-item.active {
  background: rgba(245, 166, 35, 0.15);
  border-left: 3px solid var(--color-safety);
}

.conversation-title {
  font-size: 12px;
  color: var(--color-text-sidebar);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conversation-delete {
  background: none;
  border: none;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  opacity: 0;
  transition: var(--transition);
  flex-shrink: 0;
}

.conversation-item:hover .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  color: var(--color-danger);
  background: rgba(229, 62, 62, 0.15);
}

.conversation-empty {
  font-size: 12px;
  color: var(--color-text-light);
  text-align: center;
  padding: 20px;
}

/* 遮罩层 */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

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

/* ========== 主内容区 ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

/* 模块面板 */
.module-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.module-panel.active {
  display: flex;
}

/* ========== 对话区 ========== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

/* 欢迎屏 */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  max-width: 700px;
  margin: 0 auto;
}

.welcome-icon {
  margin-bottom: 20px;
}

.welcome-screen h2 {
  font-size: 24px;
  color: var(--color-primary);
  margin-bottom: 10px;
}

.welcome-screen > p {
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 30px;
}

.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.suggestion-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.suggestion-card:hover {
  border-color: var(--color-safety);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.suggestion-icon {
  font-size: 20px;
}

.suggestion-card span:last-child {
  font-size: 13px;
  color: var(--color-text);
}

.image-suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.img-sugg-item {
  padding: 12px 20px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--color-text);
}

/* 消息气泡 */
.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  color: white;
}

.message.ai .message-avatar {
  background: var(--color-primary);
}

.message.user .message-avatar {
  background: var(--color-safety);
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message.user .message-content {
  align-items: flex-end;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.message.ai .message-bubble {
  background: var(--color-bg-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-top-left-radius: 4px;
}

.message.user .message-bubble {
  background: var(--color-primary);
  color: white;
  border-top-right-radius: 4px;
}

.message-bubble p {
  margin-bottom: 8px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}

.message-bubble code {
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  font-family: "Courier New", monospace;
}

.message-bubble pre code {
  background: none;
  padding: 0;
}

.message-bubble ul, .message-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
}

.message-bubble th, .message-bubble td {
  border: 1px solid var(--color-border);
  padding: 6px 10px;
  text-align: left;
  font-size: 13px;
}

.message-bubble th {
  background: var(--color-bg);
  font-weight: 600;
}

.message-bubble strong {
  font-weight: 600;
}

.message-bubble blockquote {
  border-left: 3px solid var(--color-safety);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--color-text-secondary);
}

.message-image {
  max-width: 300px;
  border-radius: var(--radius);
  margin-top: 8px;
}

.message-time {
  font-size: 11px;
  color: var(--color-text-light);
}

/* 打字指示器 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-light);
  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); }
}

/* ========== 底部输入区 ========== */
.input-area {
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  padding: 12px 20px;
  flex-shrink: 0;
}

.input-container {
  max-width: 900px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px;
  transition: var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--color-safety);
  box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.1);
}

.message-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  outline: none;
  padding: 6px 4px;
  line-height: 1.5;
  color: var(--color-text);
}

.message-input::placeholder {
  color: var(--color-text-light);
}

.input-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.input-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--color-primary);
}

.input-send-btn {
  background: var(--color-primary);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.input-send-btn:hover {
  background: var(--color-primary-light);
  color: white;
}

.input-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-clear-btn:hover {
  color: var(--color-danger);
}

/* 图片预览栏 */
.image-preview-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-preview-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* ========== 单位换算模块 ========== */
.units-container, .calc-container, .questions-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.units-header, .calc-header, .questions-header {
  text-align: center;
  margin-bottom: 24px;
}

.units-header h2, .calc-header h2, .questions-header h2 {
  font-size: 22px;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.units-header p, .calc-header p, .questions-header p {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.units-category-tabs, .calc-type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.units-cat-tab, .calc-tab {
  padding: 8px 20px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--color-text-secondary);
}

.units-cat-tab:hover, .calc-tab:hover {
  border-color: var(--color-safety);
  color: var(--color-primary);
}

.units-cat-tab.active, .calc-tab.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.units-converter {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.units-input-group {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.units-field {
  flex: 1;
}

.units-field label {
  display: block;
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.units-field input, .units-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.units-field input:focus, .units-field select:focus {
  border-color: var(--color-safety);
}

.units-swap {
  padding: 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  flex-shrink: 0;
}

.units-swap:hover {
  background: var(--color-safety);
  color: white;
  border-color: var(--color-safety);
}

.units-result {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.units-result-table table {
  width: 100%;
  border-collapse: collapse;
}

.units-result-table th, .units-result-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.units-result-table th {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-weight: 600;
}

.units-result-table td:first-child {
  font-weight: 500;
  color: var(--color-primary);
}

.units-result-table .highlight {
  background: rgba(245, 166, 35, 0.1);
  font-weight: 600;
}

/* ========== 工程计算模块 ========== */
.calc-form-area {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.calc-form-group {
  margin-bottom: 16px;
}

.calc-form-group label {
  display: block;
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 6px;
  font-weight: 500;
}

.calc-form-group .hint {
  font-size: 11px;
  color: var(--color-text-light);
  font-weight: 400;
  margin-left: 6px;
}

.calc-form-group input,
.calc-form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.calc-form-group input:focus,
.calc-form-group select:focus {
  border-color: var(--color-safety);
}

.calc-form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.calc-btn {
  width: 100%;
  padding: 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  margin-top: 8px;
}

.calc-btn:hover {
  background: var(--color-primary-light);
}

.calc-result-area {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: none;
}

.calc-result-area.show {
  display: block;
}

.calc-result-area h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-safety);
}

.calc-result-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.calc-result-item:last-child {
  border-bottom: none;
}

.calc-result-label {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.calc-result-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
}

.calc-result-note {
  margin-top: 12px;
  padding: 12px;
  background: rgba(245, 166, 35, 0.08);
  border-left: 3px solid var(--color-safety);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

/* ========== 题目生成模块 ========== */
.questions-gen-panel {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.questions-gen-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  align-items: end;
}

.gen-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gen-control label {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.gen-control select {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  background: white;
}

.gen-control select:focus {
  border-color: var(--color-safety);
}

.btn-gen {
  height: 38px;
  white-space: nowrap;
}

.questions-display {
  display: none;
}

.questions-display.show {
  display: block;
}

.question-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.question-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-safety);
  background: rgba(245, 166, 35, 0.1);
  padding: 2px 10px;
  border-radius: 10px;
}

.question-type-badge {
  font-size: 11px;
  color: var(--color-text-secondary);
  padding: 2px 8px;
  background: var(--color-bg);
  border-radius: 10px;
}

.question-title {
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 12px;
  color: var(--color-text);
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.question-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
}

.question-option:hover {
  background: rgba(245, 166, 35, 0.08);
}

.question-option.selected {
  background: rgba(49, 130, 206, 0.1);
  border: 1px solid var(--color-info);
}

.question-option.correct {
  background: rgba(56, 161, 105, 0.1);
  border: 1px solid var(--color-success);
}

.question-option.wrong {
  background: rgba(229, 62, 62, 0.1);
  border: 1px solid var(--color-danger);
}

.question-option-label {
  font-weight: 600;
  color: var(--color-primary);
  flex-shrink: 0;
}

.question-answer-input {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  resize: vertical;
  outline: none;
  font-family: inherit;
  line-height: 1.6;
}

.question-answer-input:focus {
  border-color: var(--color-safety);
}

.question-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.question-actions button {
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.question-actions button:hover {
  border-color: var(--color-safety);
  color: var(--color-primary);
}

.question-actions .btn-submit-answer {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.question-actions .btn-submit-answer:hover {
  background: var(--color-primary-light);
}

.question-feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  display: none;
}

.question-feedback.show {
  display: block;
}

.question-feedback.correct {
  background: rgba(56, 161, 105, 0.08);
  border: 1px solid var(--color-success);
}

.question-feedback.wrong {
  background: rgba(229, 62, 62, 0.08);
  border: 1px solid var(--color-danger);
}

.question-feedback h4 {
  margin-bottom: 6px;
  font-size: 13px;
}

.question-feedback.correct h4 {
  color: var(--color-success);
}

.question-feedback.wrong h4 {
  color: var(--color-danger);
}

.questions-analysis {
  display: none;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}

.questions-analysis.show {
  display: block;
}

.questions-analysis h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.analysis-score {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-safety);
  margin-bottom: 8px;
}

.analysis-detail {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--color-text);
}

.modal-message {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ========== 加载提示 ========== */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--color-safety);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: white;
  font-size: 14px;
}

/* ========== Toast 提示 ========== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 300px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success {
  background: var(--color-success);
  color: white;
}

.toast.error {
  background: var(--color-danger);
  color: white;
}

.toast.warning {
  background: var(--color-warning);
  color: white;
}

.toast.info {
  background: var(--color-info);
  color: white;
}

/* ========== 响应式 - 平板 ========== */
@media (max-width: 1024px) {
  .header-badge {
    display: none;
  }
  
  .welcome-suggestions {
    grid-template-columns: 1fr;
  }
}

/* ========== 响应式 - 手机 ========== */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }
  
  .header-subtitle {
    display: none;
  }
  
  .header-title h1 {
    font-size: 16px;
  }
  
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-lg);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .message {
    max-width: 95%;
  }
  
  .input-area {
    padding: 10px 12px;
  }
  
  .units-container, .calc-container, .questions-container {
    padding: 12px;
  }
  
  .calc-form-row {
    grid-template-columns: 1fr;
  }
  
  .questions-gen-controls {
    grid-template-columns: 1fr 1fr;
  }
  
  .units-input-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .units-swap {
    transform: rotate(90deg);
    align-self: center;
    width: 42px;
  }
  
  .welcome-screen h2 {
    font-size: 20px;
  }
  
  .api-status .status-text {
    display: none;
  }
}
