/* ========== 配色系统 ========== */
:root {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-elevated: #eef1f6;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --accent-text: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --btn-bg: #eef1f6;
  --btn-text: #334155;
  --btn-hover: #e2e8f0;
  --btn-shadow: #d1d8e0;
  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(37, 99, 235, 0.06);
  --shadow-md: 0 4px 16px rgba(37, 99, 235, 0.08);
  --shadow-lg: 0 12px 40px rgba(37, 99, 235, 0.10);
  --shadow-card: 0 2px 20px rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] {
  --bg: #0c0f1a;
  --bg-card: #141827;
  --bg-elevated: #1c2133;
  --text: #e8ecf4;
  --text-secondary: #b4bdd0;
  --text-muted: #6b7a99;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-text: #ffffff;
  --border: #232940;
  --border-strong: #343d5c;
  --btn-bg: #1c2133;
  --btn-text: #b4bdd0;
  --btn-hover: #232940;
  --btn-shadow: #080a12;
  --input-bg: #0e1120;
  --input-border: #232940;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 2px 30px rgba(0, 0, 0, 0.3);
}

/* ========== 基础重置 ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* ========== 主题切换 ========== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  font-size: 1.2rem;
}

.theme-toggle:hover {
  transform: scale(1.06);
  box-shadow: var(--shadow-md);
}

.toggle-icon { display: none; line-height: 1; }
[data-theme="dark"] .toggle-icon.sun { display: block; }
[data-theme="light"] .toggle-icon.moon { display: block; }

/* ========== 工具卡片 ========== */
.tool-card {
  max-width: 920px;
  width: 100%;
  background: var(--bg-card);
  border-radius: 24px;
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  animation: fadeUp 0.4s ease;
}

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

/* ========== 卡片头部 ========== */
.card-header {
  text-align: center;
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent), #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ========== 按钮系统 ========== */
.btn {
  height: 50px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn-emoji { font-size: 1.15rem; line-height: 1; }

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-outline {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-soft);
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-soft);
}

.flex-1 { flex: 1; }

/* ========== 文本输入 ========== */
.textarea-wrap {
  margin-bottom: 14px;
}

.text-input {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.text-input::placeholder {
  color: var(--text-muted);
}

/* ========== 操作栏 ========== */
.action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.action-bar .btn {
  flex: 1;
}

/* ========== 统计网格 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  background: var(--bg-elevated);
  border-radius: 14px;
  border: 1px solid var(--border);
  text-align: center;
  transition: border-color 0.15s;
}
.stat-item:hover {
  border-color: var(--accent);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-bottom: 4px;
}

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

/* ========== 响应式 ========== */
@media (min-width: 750px) {
  body { padding: 32px 24px; }
  .tool-card { padding: 36px; border-radius: 28px; }
  .btn { height: 54px; font-size: 1rem; }
  .card-title { font-size: 1.8rem; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .text-input { min-height: 260px; }
  .stat-value { font-size: 1.7rem; }
}

@media (max-width: 400px) {
  body { padding: 12px 8px; }
  .tool-card { padding: 18px; border-radius: 20px; }
  .btn { height: 44px; font-size: 0.9rem; }
  .card-title { font-size: 1.3rem; }
  .stats-grid { gap: 8px; }
  .stat-item { padding: 12px 6px; }
  .stat-value { font-size: 1.2rem; }
  .text-input { min-height: 160px; padding: 12px; }
}
