:root {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #4f46e5;
  --accent-2: #06b6d4;
  --accent-soft: #eef0fd;
  --accent-glow: rgba(79, 70, 229, 0.14);
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --bg-elevated: #1a1d23;
    --text: #e8e9ec;
    --text-muted: #9aa0aa;
    --border: #2a2d34;
    --accent: #818cf8;
    --accent-2: #22d3ee;
    --accent-soft: #262a3a;
    --accent-glow: rgba(129, 140, 248, 0.18);
    --accent-text: #0f1115;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elevated: #1a1d23;
  --text: #e8e9ec;
  --text-muted: #9aa0aa;
  --border: #2a2d34;
  --accent: #818cf8;
  --accent-2: #22d3ee;
  --accent-soft: #262a3a;
  --accent-glow: rgba(129, 140, 248, 0.18);
  --accent-text: #0f1115;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

header.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 8px;
}

header.site-header h1 {
  font-size: 22px;
  margin: 0;
}

header.site-header a.home-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
}

header.site-header a.home-link:hover {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  opacity: 1;
  border-color: var(--accent);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.hero {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero-badge {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.toolbar input {
  flex: 1;
  max-width: 260px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.toolbar input:focus {
  outline: none;
  border-color: var(--accent);
}

.tool-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.tool-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 28px var(--accent-glow);
}

.tool-card .icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.tool-card .name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}

.tool-card .desc {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.empty-tip {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 48px 0;
}

.tool-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

textarea {
  min-height: 200px;
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  opacity: 0.9;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.field {
  margin-bottom: 16px;
}

.result {
  margin-top: 8px;
  font-size: 14px;
}

.error {
  color: #e11d48;
}

footer.site-footer {
  margin-top: 48px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
