*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #111827;
  background: #f8fafc;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

a { color: #2563eb; text-decoration: none; }
a:hover { color: #1d4ed8; }

/* ── Top Navigation ── */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
}
.site-header .container {
  display: flex;
  align-items: center;
  height: 64px;
  gap: 32px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  text-decoration: none;
  flex-shrink: 0;
}
.logo:hover { color: #111827; }
.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #2563eb;
  border-radius: 8px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.site-nav { margin-left: auto; }
.site-nav ul {
  list-style: none;
  display: flex;
  gap: 4px;
}
.site-nav a {
  display: block;
  padding: 8px 16px;
  font-size: .9rem;
  font-weight: 500;
  color: #4b5563;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.site-nav a:hover, .site-nav a.active {
  color: #2563eb;
  background: #eff6ff;
}
.nav-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 4px; color: #4b5563; }

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #fff 0%, #f8fafc 50%, #eff6ff 100%);
  text-align: center;
  padding: 64px 0 56px;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.hero p {
  font-size: 1.15rem;
  color: #4b5563;
  margin-bottom: 32px;
}
.search-box {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}
.search-box input {
  width: 100%;
  height: 54px;
  padding: 0 20px 0 48px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.search-box input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.search-box .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: #6b7280;
  pointer-events: none;
}

/* ── Main ── */
.main-content { flex: 1; padding: 40px 0 56px; }

/* ── Breadcrumb ── */
.breadcrumb {
  margin-bottom: 24px;
  font-size: .85rem;
  color: #6b7280;
}
.breadcrumb a { color: #2563eb; }
.breadcrumb span { color: #6b7280; }

/* ── Home Page ── */
.home-section { padding-top: 0; }
.calculator-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.calc-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.calc-card:hover {
  transform: translateY(-3px);
  border-color: #2563eb;
  box-shadow: 0 8px 24px rgba(37,99,235,.10);
}
.calc-card .card-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  line-height: 1;
}
.calc-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
  line-height: 1.4;
}
.calc-card p {
  font-size: .85rem;
  color: #6b7280;
  line-height: 1.5;
  flex: 1;
}
.calc-card .card-category {
  font-size: .75rem;
  color: #2563eb;
  background: #eff6ff;
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  margin-top: 12px;
  align-self: flex-start;
}

/* ── Tool Detail Page (2-column) ── */
.tool-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}
.tool-main {
  flex: 1;
  min-width: 0;
}
.tool-sidebar {
  width: 280px;
  flex-shrink: 0;
}

.tool-header { margin-bottom: 28px; }
.tool-header h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 8px; }
.tool-header .tool-desc { font-size: 1rem; color: #4b5563; line-height: 1.6; }

/* ── Calculator Form ── */
.calculator-form {
  background: #fff;
  border: 1px solid #2563eb;
  border-radius: 22px;
  padding: 28px;
  margin-bottom: 32px;
  box-shadow: 0 4px 16px rgba(37,99,235,.08);
}
.calc-form { max-width: 100%; }
.calc-form .form-group { margin-bottom: 18px; }
.calc-form label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.calc-form input, .calc-form select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: .95rem;
  font-family: inherit;
  color: #111827;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.calc-form input:focus, .calc-form select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.calc-form .calc-hint { font-size: .8rem; color: #6b7280; margin-top: 4px; }
.calc-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.calc-form .btn-calc {
  height: 44px;
  padding: 0 32px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.calc-form .btn-calc:hover { background: #1d4ed8; }

/* ── Results ── */
.calc-results {
  margin-top: 24px;
  padding: 20px;
  background: #f8fafc;
  border: 2px dashed #93c5fd;
  border-radius: 16px;
}
.calc-results h3 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; color: #111827; }
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}
.result-row:last-child { border-bottom: none; }
.result-row .label { color: #6b7280; font-size: .9rem; }
.result-row .value { font-size: 1.15rem; font-weight: 700; color: #111827; }
.result-row .value.primary { color: #2563eb; }
.result-row .value.success { color: #16a34a; }
.result-row .value.warning { color: #dc2626; }
.result-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .875rem; }
.result-table th, .result-table td { padding: 10px 14px; text-align: left; border: 1px solid #e5e7eb; }
.result-table th { background: #f3f4f6; font-weight: 600; font-size: .85rem; }
.result-table td { font-size: .85rem; }

/* ── Content Area ── */
.tool-content {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 32px;
}
.tool-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #111827;
  margin: 32px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}
.tool-content h2:first-child { margin-top: 0; }
.tool-content h3 { font-size: 1.1rem; font-weight: 600; color: #111827; margin: 24px 0 10px; }
.tool-content p { margin-bottom: 14px; color: #4b5563; line-height: 1.8; }
.tool-content ul, .tool-content ol { margin: 10px 0 18px; padding-left: 24px; }
.tool-content li { margin-bottom: 6px; color: #4b5563; }
.tool-content table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .9rem; }
.tool-content th, .tool-content td { padding: 10px 14px; border: 1px solid #e5e7eb; text-align: left; }
.tool-content th { background: #f3f4f6; font-weight: 600; }

/* ── Sidebar ── */
.sidebar-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
}
.sidebar-section h3 {
  font-size: .95rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}
.sidebar-tools { list-style: none; }
.sidebar-tools li { margin-bottom: 2px; }
.sidebar-tools a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: .875rem;
  color: #4b5563;
  transition: background .15s;
}
.sidebar-tools a:hover { background: #eff6ff; color: #2563eb; }
.sidebar-tools .st-icon { font-size: 1rem; }
.sidebar-notice { font-size: .8rem; color: #6b7280; line-height: 1.6; }

/* ── Footer ── */
.site-footer {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 40px 0 32px;
  margin-top: 56px;
  color: #6b7280;
  font-size: .85rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 28px;
}
.footer-col h4 { font-size: .9rem; font-weight: 700; color: #111827; margin-bottom: 14px; }
.footer-col p { line-height: 1.7; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 6px; }
.footer-col ul a { color: #6b7280; }
.footer-col ul a:hover { color: #2563eb; }
.footer-bottom {
  border-top: 1px solid #e5e7eb;
  padding-top: 18px;
  text-align: center;
  font-size: .8rem;
}

/* ── Category Section Headers ── */
.category-section { margin-bottom: 40px; }
.category-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 16px;
  padding-left: 16px;
  border-left: 4px solid #2563eb;
}

/* ── Hidden (for search) ── */
.calc-card.hidden { display: none; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .calculator-grid { grid-template-columns: repeat(3, 1fr); }
}

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

@media (max-width: 768px) {
  .site-nav { display: none; }
  .site-nav.open {
    display: block;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 24px 16px;
    box-shadow: 0 8px 16px rgba(0,0,0,.08);
  }
  .site-nav.open ul { flex-direction: column; gap: 2px; }
  .nav-toggle { display: block; }
  .hero { padding: 40px 0 36px; }
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1rem; margin-bottom: 24px; }
  .search-box input { height: 48px; font-size: .9rem; padding-left: 42px; }
  .search-box .search-icon { font-size: 1rem; left: 14px; }
  .calculator-grid { grid-template-columns: 1fr; gap: 14px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .tool-layout { flex-direction: column; }
  .tool-sidebar { width: 100%; }
  .calculator-form { padding: 20px; border-radius: 16px; }
  .calc-form .form-row { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
  .main-content { padding: 24px 0 40px; }
  .tool-content { padding: 20px; border-radius: 16px; }
  .tool-content table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.5rem; }
  .calc-card { padding: 18px; }
  .calc-card .card-icon { font-size: 1.5rem; }
}
