/* ===== 全局变量 & 深色模式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f5f7fb;
  --card-bg: #ffffff;
  --text-primary: #1e1f2a;
  --text-secondary: #5e6072;
  --border-light: #edf0f5;
  --input-bg: #fafbfc;
  --input-border: #e2e6ec;
  --btn-bg: #ffffff;
  --btn-border: #d0d5dd;
  --btn-hover-bg: #f1f3f7;
  --shadow: 0 4px 12px rgba(0,0,0,0.04);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.08);
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --error: #c2410c;
  --success: #0f7b4e;
  --radius-card: 16px;
  --radius-input: 12px;
  --radius-btn: 30px;
  --tab-active-bg: #ffffff;
  --tab-active-text: #4f46e5;
}

body.dark {
  --bg: #0f1117;
  --card-bg: #1a1e29;
  --text-primary: #eef2fb;
  --text-secondary: #9aa1b3;
  --border-light: #2a3040;
  --input-bg: #252b3b;
  --input-border: #3a4359;
  --btn-bg: #252b3b;
  --btn-border: #3f485e;
  --btn-hover-bg: #2f374b;
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.5);
  --primary: #6366f1;
  --primary-hover: #8183f4;
  --error: #f87171;
  --success: #4ade80;
  --tab-active-bg: #2a3040;
  --tab-active-text: #a78bfa;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* 头部 */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.title-section h1 {
  font-size: 2rem;
  font-weight: 650;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

.icon-btn {
  background: var(--card-bg);
  border: 1px solid var(--input-border);
  border-radius: 30px;
  padding: 8px 16px;
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: 0.15s;
  box-shadow: var(--shadow);
}

.icon-btn:hover {
  background: var(--btn-hover-bg);
}

/* 分类标签栏 */
.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
  height: 4px;
}

.category-tabs::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.tab-item {
  padding: 8px 20px;
  background: var(--card-bg);
  border: 1px solid var(--input-border);
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  box-shadow: var(--shadow);
}

.tab-item:hover {
  background: var(--btn-hover-bg);
}

.tab-item.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

body.dark .tab-item.active {
  background: var(--primary);
  color: white;
}

/* 主视图区域 */
.main-view {
  flex: 1;
}

/* 卡片网格 */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.tool-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 24px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: transform 0.15s, box-shadow 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* 工具详情容器 */
.tool-detail {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  max-width: 800px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.back-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.back-btn:hover {
  background: var(--btn-hover-bg);
}

.detail-header h2 {
  font-size: 1.8rem;
  font-weight: 600;
}

/* 通用表单样式 */
.tool-body textarea,
.tool-body input[type="text"],
.tool-body input[type="number"],
.tool-body select {
  width: 100%;
  padding: 12px 14px;
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-input);
  background: var(--input-bg);
  color: var(--text-primary);
  margin-bottom: 16px;
  resize: vertical;
}

.tool-body textarea:focus,
.tool-body input:focus,
.tool-body select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-btn);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  margin-right: 8px;
  margin-bottom: 8px;
}

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

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

.btn-outline:hover {
  background: var(--btn-hover-bg);
}

.message {
  font-size: 0.8rem;
  margin-top: 8px;
  min-height: 20px;
  color: var(--error);
}

.message.success {
  color: var(--success);
}

.preview-area {
  margin-top: 16px;
  text-align: center;
}

.preview-area img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

/* 页脚 */
.app-footer {
  margin-top: 48px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* 空状态 */
.empty-tip {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 20px;
  font-size: 1rem;
}

@media (max-width: 600px) {
  #app { padding: 16px; }
  .tool-grid { grid-template-columns: 1fr; }
  .category-tabs { gap: 6px; }
  .tab-item { padding: 6px 16px; font-size: 0.85rem; }
}