:root {
  --primary: #1a6fb5;
  --primary-light: #e8f2fb;
  --primary-dark: #0e4d80;
  --success: #2e8b57;
  --success-light: #e8f5e9;
  --danger: #cc3333;
  --danger-light: #fce4ec;
  --warning: #d4a017;
  --bg: #f0f4f8;
  --card: #ffffff;
  --border: #e0e4ea;
  --text: #2c3e50;
  --text-light: #6b7c93;
  --sidebar-bg: #1b2838;
  --sidebar-text: #c5cdd8;
  --sidebar-hover: #253445;
  --sidebar-active: #2a4a6b;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
}

/* ========== Layout ========== */
.app-layout {
  display: flex;
  height: 100vh;
}

/* ========== Sidebar ========== */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  transition: margin-left 0.3s;
}

.sidebar.collapsed {
  margin-left: -280px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover { background: rgba(255,255,255,0.1); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-empty {
  text-align: center;
  color: rgba(255,255,255,0.3);
  padding: 40px 18px;
  font-size: 13px;
}

.history-item {
  padding: 12px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.history-item:hover { background: var(--sidebar-hover); }
.history-item.active { background: var(--sidebar-active); border-left-color: var(--primary); }

.history-item .hi-name {
  font-size: 13px;
  font-weight: 500;
  color: #e0e6ed;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.history-item .hi-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

.history-item .hi-badge {
  background: var(--primary);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

/* ========== Main ========== */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.top-bar h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  flex: 1;
}

.sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ========== Mode Switch ========== */
.mode-switch {
  display: flex;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.mode-btn {
  padding: 7px 18px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:first-child { border-right: 1px solid var(--border); }
.mode-btn.active { color: var(--primary); background: var(--primary-light); }
.mode-btn:hover:not(.active) { background: #f8f9fa; }

/* ========== Card ========== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.section-title { font-size: 17px; margin-bottom: 12px; }

/* ========== Upload ========== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.upload-area:hover, .upload-area.dragover { border-color: var(--primary); background: var(--primary-light); }
.upload-area .icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.upload-area h3 { font-size: 15px; margin-bottom: 4px; }
.upload-area p { font-size: 12px; color: var(--text-light); }
.upload-area input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary-light);
  border-radius: 8px;
  margin-top: 12px;
}
.file-info .name { font-weight: 600; font-size: 13px; }
.file-info .size { font-size: 11px; color: var(--text-light); }

.image-preview { margin-top: 12px; text-align: center; }
.image-preview img { max-width: 100%; max-height: 200px; border-radius: 8px; border: 1px solid var(--border); object-fit: contain; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #a0b4c8; cursor: not-allowed; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #236b43; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ========== Progress ========== */
.progress-section { display: none; }
.progress-section.active { display: block; }

.progress-bar-wrapper { background: #e9ecef; border-radius: 20px; height: 7px; overflow: hidden; margin: 12px 0; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); border-radius: 20px; transition: width 0.4s; width: 0%; }
.progress-text { font-size: 13px; color: var(--text-light); }

.log-area {
  max-height: 180px;
  overflow-y: auto;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", monospace;
}
.log-area .log-entry { padding: 3px 0; border-bottom: 1px solid #eee; }
.log-area .log-entry:last-child { border-bottom: none; }
.log-entry.info { color: var(--primary); }
.log-entry.success { color: var(--success); }
.log-entry.error { color: var(--danger); }

/* ========== Results ========== */
.result-section { display: none; }
.result-section.active { display: block; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.result-header h2 { font-size: 18px; color: var(--success); }

.stats { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-item { text-align: center; flex: 1; min-width: 100px; padding: 14px 10px; border-radius: 10px; border: 1px solid var(--border); }
.stat-item .number { font-size: 26px; font-weight: 700; }
.stat-item .label { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.stat-item.total { background: var(--primary-light); }
.stat-item.total .number { color: var(--primary); }
.stat-item.cat { background: var(--success-light); }
.stat-item.cat .number { color: var(--success); }

/* Tabs */
.result-tabs { display: flex; gap: 0; margin-bottom: 14px; border-bottom: 2px solid var(--border); }
.tab-btn {
  padding: 9px 20px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Category Cards */
.category-card { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.category-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.category-header:hover { background: #fafbfc; }
.category-header .cat-left { display: flex; align-items: center; gap: 10px; }
.category-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  padding: 0 7px;
}
.category-header .cat-title { font-size: 14px; font-weight: 600; }
.category-header .arrow { font-size: 11px; color: var(--text-light); transition: transform 0.2s; }
.category-card.open .arrow { transform: rotate(90deg); }
.category-body { display: none; }
.category-card.open .category-body { display: block; }

.issue-item { padding: 12px 16px; border-top: 1px solid #f0f0f0; font-size: 13px; line-height: 1.7; }
.issue-item:hover { background: #fafbfc; }
.issue-location { font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 3px; }
.issue-problem { color: var(--text); margin-bottom: 3px; }
.issue-original {
  color: var(--text-light);
  font-size: 12px;
  background: #f5f5f5;
  padding: 5px 10px;
  border-radius: 6px;
  margin-bottom: 3px;
  border-left: 3px solid var(--border);
}
.issue-suggestion { color: var(--success); font-size: 12px; }
.issue-suggestion::before { content: "建议："; font-weight: 600; }

/* Markdown Preview */
.preview-area {
  padding: 20px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 600px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.8;
}
.preview-area h1 { font-size: 18px; margin: 14px 0 8px; color: var(--primary-dark); }
.preview-area h2 { font-size: 16px; margin: 16px 0 8px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.preview-area h3 { font-size: 14px; margin: 10px 0 4px; }
.preview-area p { margin: 4px 0; }
.preview-area strong { color: var(--text); }
.preview-area hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.preview-area ul { padding-left: 16px; }
.preview-area li { margin: 2px 0; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 100; height: 100vh; left: 0; top: 0; }
  .sidebar.collapsed { margin-left: -280px; }
  .main-content { padding: 16px; }
  .top-bar { padding: 10px 16px; }
  .stats { flex-direction: column; }
  .btn-group { flex-direction: column; }
  .btn { width: 100%; justify-content: center; }
}
