:root {
  --bg: #f3f7f6;
  --bg-tint: #e6f3f0;
  --surface: #ffffff;
  --text: #13242b;
  --muted: #4d636c;
  --primary: #0f766e;
  --primary-hover: #0b5d57;
  --primary-soft: #d7f3ee;
  --accent: #0e7490;
  --border: #d4e4e0;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --shadow: 0 12px 32px rgba(16, 52, 58, 0.08);
  --radius: 18px;
  --focus: #0f766e;
  --header-h: 72px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 420px at 8% -10%, var(--bg-tint), transparent 60%),
    radial-gradient(900px 380px at 100% 0%, #e7f2f6, transparent 55%),
    var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: #fff; }

.wrap {
  width: min(1100px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243, 247, 246, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(212, 228, 224, 0.9);
}
.header-inner {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary);
  color: #f4fffc;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-en { font-size: 0.78rem; color: var(--muted); }
.back-link {
  text-decoration: none;
  color: var(--primary);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
}
.back-link:hover { background: #c6ece6; color: var(--primary-hover); }

.hero { padding: 40px 0 20px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
}
.hero p {
  margin: 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.search-panel { margin: 28px 0 8px; }
.search-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}
.search-box {
  position: relative;
}
.search-box input[type="search"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 48px 14px 16px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.search-box input[type="search"]:focus-visible {
  outline-offset: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.search-clear:hover { color: var(--text); background: var(--bg-tint); }
.search-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 1.4em;
}

.catalog { padding: 12px 0 64px; flex: 1; }
.category { margin: 28px 0; }
.category h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  min-height: 160px;
}
.tool-card:hover {
  transform: translateY(-2px);
  border-color: #b7d8d2;
  box-shadow: 0 16px 36px rgba(16, 52, 58, 0.12);
  color: inherit;
}
.tool-card h3 {
  margin: 0;
  font-size: 1.12rem;
}
.tool-card p {
  margin: 0;
  color: var(--muted);
  flex: 1;
}
.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}
.card-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty-state, .error-banner {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--muted);
}
.error-banner {
  border-style: solid;
  border-color: #f5c2c0;
  background: var(--danger-bg);
  color: var(--danger);
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 24px 0 32px;
  color: var(--muted);
  font-size: 0.92rem;
}
.site-footer p { margin: 0; }

.tool-main { padding: 32px 0 64px; width: min(860px, calc(100% - 32px)); }
.tool-main h1 { margin: 0 0 8px; letter-spacing: -0.03em; }
.lead, .local-note { color: var(--muted); margin: 0 0 12px; }
.local-note {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-hover);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.86rem;
  margin-bottom: 22px;
}

label.field-label { display: block; font-weight: 600; margin: 0 0 8px; }
textarea, input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, var(--font);
  font-size: 0.95rem;
}
textarea:focus-visible, input[type="text"]:focus-visible {
  outline-offset: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-tint); color: var(--text); }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.stat b {
  display: block;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.stat span { color: var(--muted); font-size: 0.86rem; }
.output-block {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95rem;
}
.message {
  margin: 8px 0 0;
  min-height: 1.4em;
  font-size: 0.95rem;
}
.message.error { color: var(--danger); }
.message.ok { color: var(--ok); }
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #123138;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 640px) {
  .hero { padding-top: 24px; }
  .header-inner { min-height: 64px; }
  .tool-card { min-height: 0; }
  textarea { min-height: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tool-card, .toast { transition: none; }
  .tool-card:hover { transform: none; }
}
