:root {
  --bg: #f4f6f8;
  --surface: #fff;
  --line: #dfe5ea;
  --text: #17212b;
  --muted: #6b7785;
  --blue: #135d83;
  --blue-dark: #0d405b;
  --green: #3c795c;
  --shadow: 0 8px 28px rgba(27, 49, 63, .07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.header-inner {
  max-width: 1240px;
  margin: auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border: 2px solid var(--blue);
  color: var(--blue);
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.header-actions,
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.header-button,
.back-button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
}

.header-button:hover,
.back-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.main {
  max-width: 1240px;
  margin: auto;
  padding: 56px 28px 72px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  max-width: 820px;
  margin-bottom: 44px;
}

.kicker {
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hero h2 {
  max-width: 760px;
  margin: 12px 0 17px;
  font-size: clamp(35px, 5vw, 62px);
  line-height: 1.08;
  letter-spacing: -.8px;
}

.hero p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.home-info {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 27px;
  color: var(--muted);
  font-size: 13px;
}

.home-info strong {
  margin-right: 5px;
  color: var(--text);
  font-size: 20px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 14px;
}

.section-title h2,
.detail-head h2 {
  margin: 0;
  font-size: 24px;
}

.section-title p,
.detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.category-button {
  min-height: 160px;
  padding: 20px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: .18s;
}

.category-button:hover {
  border-color: var(--blue);
  transform: translateY(-3px);
}

.category-code {
  display: block;
  margin-bottom: 32px;
  color: var(--blue);
  font: 12px monospace;
  letter-spacing: 1px;
}

.category-button h3 {
  margin: 0 0 5px;
  font-size: 19px;
}

.category-button p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.home-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 58px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.back-top {
  margin-bottom: 27px;
}

.detail-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 28px;
}

.detail-head h2 {
  margin-top: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.1;
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px;
  gap: 10px;
  margin-bottom: 24px;
}

.input,
.select {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
}

.input:focus,
.select:focus {
  outline: 2px solid rgba(19, 93, 131, .16);
  border-color: var(--blue);
}

.resource-summary {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.resource-card {
  display: flex;
  flex-direction: column;
  min-height: 250px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: .18s;
}

.resource-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
}

.resource-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.resource-type {
  padding: 2px 7px;
  border: 1px solid #c6dbe5;
  border-radius: 3px;
  color: var(--blue);
  font-size: 11px;
}

.favorite {
  padding: 0;
  border: 0;
  background: transparent;
  color: #aab5bd;
  font-size: 22px;
  line-height: 1;
}

.favorite.active {
  color: #c4862b;
}

.resource-card h3 {
  margin: 18px 0 8px;
  font-size: 19px;
  line-height: 1.3;
}

.resource-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.resource-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
}

.resource-meta span {
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.resource-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 20px;
}

.resource-label {
  color: var(--green);
  font-size: 12px;
}

.resource-link {
  color: var(--blue);
  font-size: 13px;
  text-decoration: none;
}

.resource-link:hover {
  text-decoration: underline;
}

.empty {
  grid-column: 1 / -1;
  padding: 52px;
  border: 1px dashed var(--line);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.formula-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.formula-filter {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
}

.formula-filter.active,
.formula-filter:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.formula-card {
  min-height: 245px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.formula-category {
  color: var(--blue);
  font: 10px monospace;
  letter-spacing: 1px;
}

.formula-card h3 {
  margin: 15px 0 12px;
  font-size: 16px;
}

.formula-expression {
  min-height: 64px;
  display: flex;
  align-items: center;
  margin-bottom: 13px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--blue-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.formula-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.formula-use {
  display: block;
  margin-top: 16px;
  color: var(--green);
  font-size: 11px;
}

@media (max-width: 1050px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .formula-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 820px) {
  .resource-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .control-bar {
    grid-template-columns: 1fr 1fr;
  }

  .control-bar .input {
    grid-column: 1 / -1;
  }

  .detail-head {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 570px) {
  .header-inner,
  .main {
    padding-right: 17px;
    padding-left: 17px;
  }

  .header-inner {
    align-items: start;
  }

  .main {
    padding-top: 38px;
  }

  .category-grid,
  .resource-grid,
  .formula-grid,
  .control-bar {
    grid-template-columns: 1fr;
  }

  .control-bar .input {
    grid-column: auto;
  }

  .resource-summary,
  .home-footer {
    display: block;
  }

  .resource-summary span,
  .home-footer span {
    display: block;
    margin-top: 5px;
  }

  .formula-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .formula-filter {
    white-space: nowrap;
  }
}