/* ===== 全局变量 ===== */
:root {
  --bg: #0f1117;
  --bg-alt: #161822;
  --bg-card: #1a1d2e;
  --bg-input: #12141f;
  --border: #2a2d3e;
  --border-focus: #6366f1;
  --text: #e2e4f0;
  --text-muted: #8b8fa3;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-bg: rgba(99, 102, 241, 0.12);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 16px rgba(0,0,0,0.35);
}

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

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

a { color: inherit; text-decoration: none; }

/* ===== 导航栏 ===== */
.tool-navbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.tool-navbar .back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  transition: color 0.2s;
  flex-shrink: 0;
}
.tool-navbar .back-link:hover { color: var(--primary-hover); }
.tool-navbar .tool-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.tool-navbar .tool-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ===== 主页 ===== */
body.home {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.site-header {
  text-align: center;
  padding: 48px 24px 28px;
}
.site-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.site-header .subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  max-width: 1100px;
  width: 100%;
  padding: 0 24px 48px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.tool-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15);
}
.tool-card .tool-icon { font-size: 2rem; }
.tool-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
.tool-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.site-footer {
  margin-top: auto;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== 工具页公共布局 ===== */
.tool-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.tool-container h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.tool-container .desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ===== 通用组件 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* textarea / input */
textarea, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", "Monaco", monospace;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
  line-height: 1.6;
}
textarea:focus, input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--border-focus);
}
textarea { min-height: 180px; }

/* 面板 */
.panel {
  margin-bottom: 16px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.panel-header label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 两栏布局 */
.split-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 680px) {
  .split-pane { grid-template-columns: 1fr; }
}

/* 操作栏 */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

/* toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  animation: toastIn 0.25s ease;
  pointer-events: none;
}
.toast.success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.toast.error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 高亮代码输出 */
.code-output {
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", "Monaco", monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 120px;
  max-height: 500px;
  overflow-y: auto;
}

/* 颜色预览块 */
.color-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-right: 4px;
}

/* 正则匹配高亮 */
.regex-highlight {
  background: rgba(99, 102, 241, 0.35);
  border-radius: 2px;
  padding: 0 1px;
}

/* diff 样式 */
.diff-line {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 0 8px;
}
.diff-add { background: rgba(52, 211, 153, 0.12); color: #34d399; }
.diff-del { background: rgba(248, 113, 113, 0.12); color: #f87171; }
.diff-eq  { color: var(--text-muted); }

/* 标签/徽标 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* UUID 列表 */
.uuid-list {
  list-style: none;
  padding: 0;
}
.uuid-list li {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 13px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.uuid-list li:last-child { border-bottom: none; }
