:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #fbfcfb;
  --border: #e2e9e4;
  --border-strong: #d3ded7;
  --text: #202a25;
  --text-soft: #4f5c55;
  --muted: #6f7b74;
  --accent: #0d9f73;
  --accent-strong: #087a58;
  --accent-soft: #eaf8f1;
  --accent-line: #b8e6d5;
  --danger: #c94848;
  --shadow-sm: 0 1px 2px rgba(25, 55, 40, .04), 0 5px 18px rgba(25, 55, 40, .04);
  --shadow-md: 0 16px 45px rgba(25, 55, 40, .07);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -10%, rgba(13, 159, 115, .075), transparent 32%),
    radial-gradient(circle at 94% 3%, rgba(13, 159, 115, .04), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #c9f0e2; color: #123c2d; }
a { color: var(--accent-strong); }
a:focus-visible, button:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #13b986 0%, #067655 100%);
  box-shadow: 0 7px 18px rgba(13, 159, 115, .24), inset 0 1px 0 rgba(255, 255, 255, .28);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.08em;
}
.brand-title { display: block; font-size: 14px; font-weight: 680; letter-spacing: .01em; white-space: nowrap; }
.brand-subtitle { display: block; margin-top: 2px; color: #66726b; font-family: var(--mono); font-size: 8px; font-weight: 600; letter-spacing: .17em; white-space: nowrap; }
.primary-nav { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.primary-link {
  display: inline-flex;
  align-items: center;
  height: 31px;
  padding: 0 11px;
  border-radius: 7px;
  color: #5f6b64;
  font-size: 12px;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
}
.primary-link:hover { color: var(--text); background: #f2f7f4; }
.primary-link[aria-current="page"] { color: var(--accent-strong); background: var(--accent-soft); }
.top-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; flex: 0 0 auto; }
.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid #e0ebe5;
  border-radius: 999px;
  background: #f6faf8;
  color: #5b6860;
  font-size: 10.5px;
  font-weight: 550;
  white-space: nowrap;
}
.local-dot { width: 6px; height: 6px; border-radius: 50%; background: #11b47f; box-shadow: 0 0 0 3px rgba(17, 180, 127, .12); }
.workspace-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid #0c8d66;
  border-radius: 8px;
  background: linear-gradient(180deg, #11ab7d 0%, #0b8c65 100%);
  color: #fff;
  text-decoration: none;
  font-size: 11px;
  font-weight: 620;
  white-space: nowrap;
  box-shadow: 0 3px 9px rgba(13, 159, 115, .18), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.workspace-btn:hover { background: #087a58; }
.workspace-btn svg { width: 12px; height: 12px; }

.tool-shell {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 24px 22px 70px;
}
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 19px;
  color: #7b867f;
  font-size: 10.5px;
}
.breadcrumb a { color: #66726b; text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-strong); }
.breadcrumb .sep { color: #b4beb8; }

.tool-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}
.tool-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 1px solid #d7ebe1;
  border-radius: 12px;
  background: linear-gradient(145deg, #f7fcf9, #e9f7f1);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 #fff;
}
.tool-head-copy { min-width: 0; }
.tool-head h1 { margin: 0 0 5px; color: #17221c; font-size: 26px; font-weight: 700; line-height: 1.35; letter-spacing: -.02em; }
.tool-head p { max-width: 800px; margin: 0; color: #5a675f; font-size: 12.5px; line-height: 1.8; }

.tool-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.tool-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  min-height: 54px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf1ee;
  background: #fbfcfb;
}
.control-group { display: inline-flex; align-items: center; gap: 7px; }
.control-label { color: #66726b; font-size: 10.5px; font-weight: 620; white-space: nowrap; }
select {
  height: 31px;
  min-width: 118px;
  padding: 0 27px 0 9px;
  border: 1px solid #dce6df;
  border-radius: 7px;
  background: #fff;
  color: #3f4e45;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.check-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #5f6b64;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}
.check-control input { width: 13px; height: 13px; accent-color: var(--accent); }
.number-input {
  width: 66px;
  height: 31px;
  padding: 0 8px;
  border: 1px solid #dce6df;
  border-radius: 7px;
  background: #fff;
  color: #3f4e45;
  font-family: var(--mono);
  font-size: 11px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 400px;
}
.tool-pane { min-width: 0; display: flex; flex-direction: column; }
.tool-pane + .tool-pane { border-left: 1px solid #edf1ee; }
.tool-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid #f0f3f1;
  color: #66726b;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .05em;
}
.tool-pane-head .pane-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid #d8ebe2;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 700;
}
.tool-pane-body { position: relative; flex: 1 1 auto; min-height: 340px; }
.tool-input, .tool-output {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 340px;
  margin: 0;
  padding: 16px 18px 24px;
  border: 0;
  outline: none;
  resize: none;
  background: var(--surface-soft);
  color: #2b3931;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.tool-input { background: #fff; caret-color: var(--accent-strong); }
.tool-input::placeholder { color: #7c8780; }
.tool-output { background: #fbfcfb; white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-output:empty::before {
  content: "输出结果会显示在这里";
  color: #9aa59e;
  font-family: var(--sans);
  font-size: 12px;
}

.tool-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 9px 16px;
  min-height: 48px;
  padding: 8px 16px;
  border-top: 1px solid #edf1ee;
  background: #fbfcfb;
}
.tool-stats { color: #66726b; font-size: 10.5px; }
.tool-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 620;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, opacity .16s ease, transform .16s ease;
}
.btn svg { width: 13px; height: 13px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .4; transform: none; }
.btn-ghost { border-color: var(--border); background: #fff; color: #5d6962; }
.btn-ghost:hover:not(:disabled) { border-color: #c9d9d0; background: #f7faf8; color: var(--accent-strong); }
.btn-primary { border-color: #0c8d66; background: linear-gradient(180deg, #11ab7d 0%, #0b8c65 100%); color: #fff; box-shadow: 0 3px 9px rgba(13, 159, 115, .16); }
.btn-primary:hover:not(:disabled) { background: #087a58; }

.count-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(330px, .92fr);
  min-height: 430px;
}
.count-input-pane,
.count-stats-pane { min-width: 0; display: flex; flex-direction: column; }
.count-stats-pane { border-left: 1px solid #edf1ee; background: #fbfcfb; }
.count-input { flex: 1 1 auto; min-height: 390px; }
.count-stats-body { flex: 1 1 auto; padding: 22px 20px; }
.count-summary {
  padding: 18px 18px 17px;
  border: 1px solid #dcece4;
  border-radius: 10px;
  background: #f3faf6;
  text-align: center;
}
.count-total {
  display: block;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.04em;
}
.count-total-label {
  display: block;
  margin-top: 2px;
  color: #33433a;
  font-size: 12px;
  font-weight: 650;
}
.count-total-note {
  display: block;
  margin-top: 3px;
  color: #77847c;
  font-size: 10px;
}
.count-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.count-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid #e7eeea;
  border-radius: 8px;
  background: #fff;
}
.count-value {
  color: #26362d;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}
.count-label {
  color: #77847c;
  font-size: 9.5px;
  line-height: 1.45;
}
.count-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #edf1ee;
  color: #7b867f;
  font-size: 10px;
  line-height: 1.75;
}
.count-foot-note { color: #66726b; font-size: 10.5px; }

.tool-notes {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr);
  gap: 18px;
  margin-top: 20px;
}
.note-card {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow-sm);
}
.note-card h2 { margin: 0 0 10px; padding-left: 10px; border-left: 3px solid var(--accent); color: #1f2d25; font-size: 16px; font-weight: 680; line-height: 1.5; }
.note-card h3 { margin: 18px 0 7px; color: #2d3b33; font-size: 13px; font-weight: 680; }
.note-card p { margin: 0 0 10px; color: #536059; font-size: 12px; line-height: 1.85; }
.note-card ul { margin: 0 0 10px; padding-left: 19px; color: #536059; font-size: 12px; line-height: 1.85; }
.note-card li { margin: 4px 0; }
.note-card code { padding: 1px 5px; border-radius: 4px; background: #edf7f2; color: #0b6b50; font-family: var(--mono); font-size: .9em; }
.callout {
  margin: 12px 0;
  padding: 10px 13px;
  border: 1px solid #dcece4;
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: #f4faf7;
  color: #4d5e54;
  font-size: 11.5px;
  line-height: 1.8;
}
.callout.warning { border-color: #f1e2c8; border-left-color: #d39a3c; background: #fff8e9; color: #735321; }
.related-list { display: grid; gap: 7px; }
.related-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid #e8eeea;
  border-radius: 7px;
  background: #fbfcfb;
  color: #536059;
  font-size: 11px;
  text-decoration: none;
}
.related-list a:hover { border-color: #cfe4d8; color: var(--accent-strong); background: #f4faf7; }
.related-list a span:last-child { color: #a0aaa4; font-family: var(--mono); font-size: 10px; }

.footer {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 0 22px 38px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: #7b867f;
  font-size: 10px;
}
.footer-inner a { color: #66726b; text-decoration: none; }
.footer-inner a:hover { color: var(--accent-strong); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 14px; }

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  background: #203a2e;
  color: #f4fbf7;
  font-size: 11.5px;
  font-weight: 550;
  box-shadow: 0 12px 34px rgba(17, 45, 30, .22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}
.toast[data-visible="true"] { opacity: 1; visibility: visible; transform: translateY(0); }
.toast[data-kind="error"] { background: #5b2a2a; }
.toast-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: #57d4a7; }
.toast[data-kind="error"] .toast-dot { background: #ff9b9b; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 8px 14px; padding: 9px 14px; }
  .brand { margin-right: auto; }
  .brand-subtitle { display: none; }
  .local-badge { display: none; }
  .primary-link { height: 30px; padding: 0 8px; font-size: 11.5px; }
  .tool-shell { padding: 18px 12px 50px; }
  .tool-head h1 { font-size: 22px; }
  .tool-head p { font-size: 12px; }
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
  .tool-pane + .tool-pane { border-left: 0; border-top: 1px solid #edf1ee; }
  .tool-pane-body, .tool-input, .tool-output { min-height: 260px; }
  .count-layout { grid-template-columns: minmax(0, 1fr); }
  .count-stats-pane { border-left: 0; border-top: 1px solid #edf1ee; }
  .count-input { min-height: 300px; }
  .tool-notes { grid-template-columns: minmax(0, 1fr); }
  .tool-controls { padding: 9px 12px; }
  .tool-foot { padding: 8px 12px; }
  .footer { padding: 0 14px 30px; }
}

@media (max-width: 560px) {
  .brand-title { font-size: 12.5px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .workspace-btn span { display: none; }
  .workspace-btn { width: 32px; padding: 0; }
  .tool-head { gap: 10px; }
  .tool-icon { width: 38px; height: 38px; border-radius: 10px; font-size: 11px; }
  .tool-head h1 { font-size: 20px; }
  .tool-controls { gap: 8px 11px; }
  .control-group { width: 100%; justify-content: space-between; }
  select { flex: 1; }
  .tool-actions { width: 100%; }
  .tool-actions .btn { flex: 1; height: 40px; }
  .tool-stats { width: 100%; }
  .count-stats-body { padding: 16px 14px; }
  .count-total { font-size: 38px; }
  .count-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .count-grid .count-metric:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .note-card { padding: 17px 15px; }
  .toast { right: 16px; bottom: 16px; left: 16px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
