/* ========== Dev工具箱 - 设计系统 ========== */
:root {
  --bg: #f0f4f8;
  --bg-alt: #e8eef5;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --text: #1a2332;
  --text-secondary: #5a6a7e;
  --text-muted: #8a9aac;
  --border: #d4dde8;
  --border-light: #e8eef5;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --accent-glow: rgba(13, 148, 136, 0.25);
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(26, 35, 50, 0.04);
  --shadow: 0 4px 16px rgba(26, 35, 50, 0.06);
  --shadow-lg: 0 12px 40px rgba(26, 35, 50, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Outfit", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  --nav-h: 64px;
  --max-w: 1120px;
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(13, 148, 136, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(14, 116, 144, 0.06), transparent),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

/* ========== 导航 ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.logo:hover { color: var(--text); }

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #0e7490 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.nav-toggle:hover { background: var(--accent-soft); }

.nav-toggle svg { width: 22px; height: 22px; }

/* ========== Hero ========== */
.hero {
  padding: 56px 0 40px;
  text-align: center;
}

.hero-brand {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 12px;
}

.hero-brand span {
  background: linear-gradient(135deg, var(--accent), #0e7490);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 28px;
}

.search-box {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
}

.search-box input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}

.search-box svg {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 50;
  text-align: left;
}

.search-results.show { display: block; }

.search-results a {
  display: block;
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.95rem;
}

.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--accent-soft); color: var(--accent); }
.search-results .empty { padding: 16px; color: var(--text-secondary); text-align: center; }

/* ========== 分类与工具卡片 ========== */
.section {
  padding: 32px 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.section-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  animation: fadeUp 0.45s ease both;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
  color: var(--text);
}

.tool-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 4px;
}

.tool-card h3 {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.tool-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.tools-grid .tool-card:nth-child(1) { animation-delay: 0.02s; }
.tools-grid .tool-card:nth-child(2) { animation-delay: 0.05s; }
.tools-grid .tool-card:nth-child(3) { animation-delay: 0.08s; }
.tools-grid .tool-card:nth-child(4) { animation-delay: 0.11s; }
.tools-grid .tool-card:nth-child(5) { animation-delay: 0.14s; }
.tools-grid .tool-card:nth-child(6) { animation-delay: 0.17s; }
.tools-grid .tool-card:nth-child(7) { animation-delay: 0.2s; }
.tools-grid .tool-card:nth-child(8) { animation-delay: 0.23s; }

/* ========== 工具页布局 ========== */
.breadcrumb {
  padding: 20px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 6px; color: var(--border); }

.tool-page {
  padding: 24px 0 48px;
  flex: 1;
}

.tool-header {
  margin-bottom: 28px;
}

.tool-header h1 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.tool-header p {
  color: var(--text-secondary);
  max-width: 640px;
}

.tool-panel {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-danger:hover { background: #fee2e2; }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

.textarea {
  min-height: 160px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.55;
}

.textarea-lg { min-height: 240px; }

.output-area {
  position: relative;
}

.output-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 12px 0;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"],
.checkbox-group input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin-top: 12px;
}

.stat-item strong {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat-item span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--code-bg);
  color: #fff;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.related-tools {
  margin-top: 8px;
}

.related-tools h2 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

/* ========== SEO 说明区 ========== */
.seo-content {
  margin-top: 32px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}

.seo-content h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
}

.seo-content h3 {
  font-size: 1rem;
  margin: 18px 0 8px;
}

.seo-content p,
.seo-content li {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.seo-content ul {
  padding-left: 1.2em;
  list-style: disc;
}

.seo-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ========== 页脚 ========== */
.site-footer {
  margin-top: auto;
  padding: 36px 0 28px;
  border-top: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.5);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 28px;
}

.footer-brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.footer-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 320px;
}

.footer-col h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  padding: 4px 0;
}

.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ========== 颜色预览等特殊 ========== */
.color-preview {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.swatch {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--transition);
}

.swatch:hover { transform: scale(1.08); }

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.data-table th {
  background: var(--surface-2);
  font-weight: 650;
  white-space: nowrap;
}

.data-table tr:hover td { background: var(--accent-soft); }

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.password-display {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  padding: 16px;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  word-break: break-all;
  text-align: center;
  letter-spacing: 0.05em;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn:hover { color: var(--accent); }

.hidden { display: none !important; }

.hl-match {
  background: #fef08a;
  border-radius: 2px;
}

.error-msg {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 8px;
}

.success-msg {
  color: var(--success);
  font-size: 0.875rem;
  margin-top: 8px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    gap: 4px;
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
    box-shadow: var(--shadow);
  }

  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-links a {
    padding: 12px 16px;
  }

  .hero { padding: 36px 0 28px; }

  .form-row { grid-template-columns: 1fr; }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .tool-panel { padding: 16px; }
}

/* ========== AI 提问 ========== */
.ai-chat-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 20px;
}

.ai-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.ai-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.ai-messages {
  min-height: 320px;
  max-height: 520px;
  overflow-y: auto;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(13, 148, 136, 0.04), transparent 120px),
    var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 92%;
  animation: fadeUp 0.3s ease both;
}

.ai-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.ai-msg-user .ai-avatar {
  background: var(--text);
  color: #fff;
}

.ai-bubble {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
  line-height: 1.65;
  word-break: break-word;
}

.ai-msg-user .ai-bubble {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.ai-bubble pre {
  margin: 10px 0;
  padding: 12px;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.ai-bubble code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 1px 5px;
  border-radius: 4px;
}

.ai-msg-user .ai-bubble code {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.ai-bubble pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.ai-streaming::after {
  content: "▍";
  animation: blink 1s step-end infinite;
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

.ai-composer-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.ai-settings {
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .ai-messages {
    min-height: 260px;
    max-height: 420px;
  }

  .ai-msg { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
