/* ===== CSS 变量定义 ===== */
:root {
  /* 主题色彩 */
  --primary-color: #6366f1;
  --primary-hover: #5856f9;
  --primary-light: #e0e7ff;
  --secondary-color: #64748b;
  --accent-color: #f59e0b;
  
  /* 背景颜色 */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-quaternary: #e2e8f0;
  --bg-dark: #0f172a;
  --bg-card: #ffffff;
  
  /* 文本颜色 */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-white: #ffffff;
  
  /* 边框颜色 */
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --border-focus: #6366f1;
  
  /* 状态颜色 */
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --info-color: #3b82f6;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* 字体 */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  
  /* 圆角 */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* 动画 */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 暗色主题 */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --border-color: #334155;
  --border-hover: #475569;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: var(--transition);
}

/* ===== 加载动画 ===== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

.loading-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== 导航栏 ===== */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 4rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-icon {
  font-size: 1.5rem;
}

.nav-menu {
  display: flex;
  gap: 1rem;
}

.nav-item {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}

.nav-item:hover,
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-color);
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
}

.action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ===== 主容器 ===== */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 4rem);
}

/* ===== 标签页内容 ===== */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== 工具容器 ===== */
.tool-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  min-height: calc(100vh - 8rem);
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== 控制面板 ===== */
.control-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: fit-content;
}

.panel-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.panel-header h2,
.panel-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-actions {
  display: flex;
  gap: 0.75rem;
}

/* ===== 区域标题 ===== */
.section-header {
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
}

h4.section-title {
  font-size: 1rem;
}

.section-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===== 输入组 ===== */
.input-group {
  margin-bottom: 1.5rem;
}

.input-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.label-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ===== 正则表达式输入 ===== */
.regex-section {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.regex-input-wrapper {
  display: flex;
  align-items: stretch;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
}

.regex-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.regex-delimiter {
  background: var(--primary-color);
  color: var(--text-white);
  padding: 1rem 0.75rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
}

.regex-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-primary);
  resize: vertical;
  min-height: 2.5rem;
  max-height: 6rem;
  outline: none;
}

.regex-input::placeholder {
  color: var(--text-muted);
}

.regex-flags {
  border: none;
  background: var(--bg-tertiary);
  padding: 1rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-primary);
  width: 80px;
  text-align: center;
  outline: none;
}

.regex-flags::placeholder {
  color: var(--text-muted);
}

.regex-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.info-item {
  text-align: center;
}

.info-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.info-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.match-count-number {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

.execution-time {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.status-indicator {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.status-indicator.valid {
  background: var(--success-color);
  color: var(--text-white);
}

.status-indicator.invalid {
  background: var(--error-color);
  color: var(--text-white);
}

/* ===== 测试文本输入 ===== */
.text-section {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  flex: 1;
}

/* ===== 文件上传区域 ===== */
.file-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1rem;
  background: var(--bg-secondary);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.file-upload-area:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.file-upload-area.dragover {
  border-color: var(--primary-color);
  background: var(--primary-light);
  transform: scale(1.02);
}

.upload-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.upload-icon {
  font-size: 3rem;
  color: var(--text-secondary);
}

.upload-text {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.upload-primary {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.upload-secondary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-btn {
  background: var(--primary-color);
  color: var(--text-white);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}

.upload-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* ===== 文件信息显示 ===== */
.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.file-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.file-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.remove-file-btn {
  background: var(--error-color);
  color: var(--text-white);
  border: none;
  border-radius: 50%;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.8rem;
}

.remove-file-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.text-input-wrapper {
  position: relative;
}

.test-text {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  resize: vertical;
  min-height: 300px;
  outline: none;
  transition: var(--transition);
  line-height: 1.6;
}

.test-text:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.test-text::placeholder {
  color: var(--text-muted);
}

.input-actions {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
}

.input-actions .action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* ===== 替换功能 ===== */
.replace-section {
  padding: 1.5rem;
}

.section-toggle {
  margin-bottom: 1rem;
}

.toggle-checkbox {
  margin-right: 0.5rem;
}

.toggle-label {
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.replace-controls {
  display: none;
}

.replace-controls.active {
  display: block;
}

.replace-input {
  flex: 1;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-secondary);
  outline: none;
  transition: var(--transition);
  margin-right: 1rem;
}

.replace-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.input-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ===== 按钮样式 ===== */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ===== 结果面板 ===== */
.results-panel {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
}

/* ===== 匹配结果可视化 ===== */
.matches-visualization {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  flex: 1;
  min-height: 300px;
  max-height: 400px;
  overflow-y: auto;
}

.highlighted-text {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.6;
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 200px;
  max-height: 350px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

.placeholder-text {
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  font-family: var(--font-sans);
}

.match-highlight {
  background: var(--primary-color);
  color: var(--text-white);
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
  position: relative;
  font-weight: 500;
}

.match-highlight:hover {
  background: var(--primary-hover);
  cursor: pointer;
}

.match-highlight::before {
  content: attr(data-match-index);
  position: absolute;
  top: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  color: var(--text-white);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.match-highlight:hover::before {
  opacity: 1;
}

/* ===== 匹配详情 ===== */
.matches-details {
  padding: 1.5rem;
  max-height: 250px;
  overflow-y: auto;
}


.matches-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.match-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: var(--transition);
}

.match-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

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

.match-index {
  background: var(--primary-color);
  color: var(--text-white);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}

.match-position {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.match-content {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--bg-primary);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
  word-break: break-all;
}

.match-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.group-item {
  background: var(--accent-color);
  color: var(--text-white);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

/* ===== 模板库样式 ===== */
.templates-container {
  max-width: 1200px;
  margin: 0 auto;
}

.templates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.templates-header h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.templates-search {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-input {
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  width: 300px;
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.search-btn {
  padding: 0.75rem;
  background: var(--primary-color);
  color: var(--text-white);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
}

.search-btn:hover {
  background: var(--primary-hover);
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  transition: var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

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

.template-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.template-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.template-pattern {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
  word-break: break-all;
}

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.template-tag {
  background: var(--primary-light);
  color: var(--primary-color);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

/* ===== 参考手册样式 ===== */
.reference-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.reference-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  height: fit-content;
  position: sticky;
  top: 6rem;
}

.reference-sidebar h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.reference-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ref-item {
  background: none;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
}

.ref-item:hover,
.ref-item.active {
  background: var(--primary-light);
  color: var(--primary-color);
}

.reference-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  min-height: 500px;
}

/* ===== 历史记录样式 ===== */
.history-container {
  max-width: 1000px;
  margin: 0 auto;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.history-header h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.history-actions {
  display: flex;
  gap: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  transition: var(--transition);
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.history-date {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.history-pattern {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  word-break: break-all;
}

.history-summary {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== 日志监控样式 ===== */
.logs-container {
  max-width: 1400px;
  margin: 0 auto;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.logs-header h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logs-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.log-filter-select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.log-filter-select:focus {
  border-color: var(--border-focus);
}

.log-search-input {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
  width: 200px;
}

.log-search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgb(99 102 241 / 0.1);
}

/* 日志统计面板 */
.logs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: 2rem;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* 日志列表 */
.logs-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.logs-list-container {
  max-height: 600px;
  overflow-y: auto;
}

.logs-list {
  display: flex;
  flex-direction: column;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
}

.log-item:hover {
  background: var(--bg-secondary);
}

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

.log-level {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  min-width: 60px;
  text-align: center;
  margin-top: 0.25rem;
}

.log-level.DEBUG {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.log-level.INFO {
  background: var(--info-color);
  color: var(--text-white);
}

.log-level.WARN {
  background: var(--warning-color);
  color: var(--text-white);
}

.log-level.ERROR,
.log-level.FATAL {
  background: var(--error-color);
  color: var(--text-white);
}

.log-timestamp {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 140px;
  margin-top: 0.25rem;
}

.log-content {
  flex: 1;
}

.log-message {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.log-category {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-color);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.log-preview {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 500px;
}

/* 日志详情弹窗 */
.log-detail-content {
  max-width: 800px;
  max-height: 80vh;
}

.log-detail-info {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
}

.log-detail-section {
  margin-bottom: 1.5rem;
}

.log-detail-section h4 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-family: var(--font-sans);
}

.log-detail-data {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.log-detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.log-meta-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.log-meta-value {
  color: var(--text-primary);
}

/* ===== 模态框样式 ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 2rem;
}

.setting-group {
  margin-bottom: 1.5rem;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
}

.setting-checkbox {
  width: 1rem;
  height: 1rem;
}

.setting-input {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  width: 100px;
  margin-left: 1rem;
}

.setting-input:focus {
  border-color: var(--border-focus);
}

/* ===== 提示框样式 ===== */
.toast-container {
  position: fixed;
  top: 5rem;
  right: 2rem;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  animation: slideIn 0.3s ease-out;
}

.toast.success {
  border-left: 4px solid var(--success-color);
}

.toast.error {
  border-left: 4px solid var(--error-color);
}

.toast.warning {
  border-left: 4px solid var(--warning-color);
}

.toast.info {
  border-left: 4px solid var(--info-color);
}

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

/* ===== 响应式设计 ===== */
@media (max-width: 1200px) {
  .tool-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    min-height: auto;
  }
  
  .reference-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .reference-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .main-container {
    padding: 1rem;
  }
  
  .nav-container {
    padding: 0 1rem;
    flex-wrap: wrap;
    height: auto;
    min-height: 4rem;
  }
  
  .nav-menu {
    order: 3;
    width: 100%;
    margin-top: 1rem;
    padding-bottom: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
  }
  
  .templates-grid {
    grid-template-columns: 1fr;
  }
  
  .templates-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .search-input {
    width: 100%;
  }
  
  .control-panel,
  .results-panel {
    border-radius: var(--radius-lg);
  }
  
  .panel-header {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .regex-section,
  .text-section,
  .replace-section {
    padding: 1rem;
  }
  
  .matches-visualization,
  .matches-details {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .regex-input-wrapper {
    flex-direction: column;
  }
  
  .regex-flags {
    width: 100%;
    text-align: left;
  }
  
  .regex-info {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .input-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .replace-input {
    margin-right: 0;
    margin-bottom: 1rem;
  }
  
  .panel-actions,
  .result-actions,
  .history-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .modal-content {
    width: 95%;
    margin: 1rem;
  }
  
  .toast-container {
    right: 1rem;
    left: 1rem;
  }
  
  .toast {
    min-width: auto;
  }
  
  /* 文件上传响应式 */
  .file-upload-area {
    padding: 1.5rem 1rem;
  }
  
  .upload-icon {
    font-size: 2.5rem;
  }
  
  .upload-primary {
    font-size: 1rem;
  }
  
  .upload-secondary {
    font-size: 0.8rem;
  }
  
  .upload-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
  
  .file-info {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }
  
  .file-details {
    text-align: center;
  }
  
  .remove-file-btn {
    align-self: center;
  }
}

/* ===== 深色模式切换动画 ===== */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ===== 焦点样式优化 ===== */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ===== 选择文本样式 ===== */
::selection {
  background: var(--primary-color);
  color: var(--text-white);
}

/* ===== 打印样式 ===== */
@media print {
  .navbar,
  .nav-actions,
  .panel-actions,
  .result-actions,
  .history-actions,
  .input-actions {
    display: none;
  }
  
  .main-container {
    padding: 0;
    max-width: none;
  }
  
  .tool-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .control-panel,
  .results-panel {
    box-shadow: none;
    border: 1px solid #000;
  }
}
