:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --ink: #1b2428;
  --muted: #5f6b70;
  --brand: #0e7490;
  --brand-dark: #155e75;
  --accent: #d97706;
  --line: #dfe5e7;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

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

button,
input,
select {
  font-family: inherit;
}

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 20px;
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand {
  color: var(--brand);
  font-weight: 700;
}

.brand-slash {
  color: var(--line);
}

.brand-block h1 {
  margin: 0;
  font-size: 22px;
}

.header-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #eef2f3;
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}

.toolbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  min-height: 42px;
}

.search-box:focus-within {
  border-color: var(--brand);
}

.search-icon {
  position: relative;
  width: 16px;
  height: 16px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  flex: 0 0 auto;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 2px;
  background: var(--muted);
  transform: rotate(45deg);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
  color: var(--ink);
}

.filters {
  display: grid;
  gap: 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.select-wrap select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
  cursor: pointer;
}

.result-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px 60px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.formula-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 232px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #e8eff2;
  color: var(--brand-dark);
}

.tag-diff {
  background: #fdf1e0;
  color: #b45309;
}

.formula-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.formula-expr {
  margin: 0 0 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: #f0f6f7;
  color: #134e4a;
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.formula-desc,
.formula-apply {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.formula-tip {
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  color: #7c5a2e;
  font-size: 13px;
  flex: 1;
}

.copy-btn {
  align-self: flex-start;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.copy-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}

.empty p {
  margin: 0 0 6px;
  font-size: 18px;
}

.empty-sub {
  font-size: 13px;
}

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 26px 20px;
  color: var(--muted);
  font-size: 13px;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.footer p {
  margin: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: #111c20;
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  z-index: 30;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .result-count {
    margin-left: 0;
  }
}
