* {
  box-sizing: border-box;
}

:root {
  --primary: #0d47a1;
  --primary-2: #1565c0;
  --primary-light: #42a5f5;
  --primary-soft: #eaf3ff;
  --cyan: #00b5b0;
  --green: #43b649;
  --orange: #ff8a00;
  --gray-900: #1f2937;
  --gray-800: #333333;
  --gray-700: #4b5563;
  --gray-600: #6b7280;
  --gray-500: #757575;
  --gray-300: #d8dee8;
  --gray-200: #e9edf3;
  --gray-100: #f2f2f2;
  --white: #ffffff;
  --page-bg: #f5f8fc;
  --card-shadow: 0 12px 34px rgba(13, 71, 161, 0.08);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html {
  width: 100%;
  background: var(--page-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 100% 0, rgba(66, 165, 245, 0.10), transparent 24rem),
    var(--page-bg);
  color: var(--gray-900);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  color: var(--white);
  background:
    linear-gradient(130deg, rgba(13, 71, 161, 0.98), rgba(21, 101, 192, 0.96) 62%, rgba(66, 165, 245, 0.94));
  box-shadow: 0 8px 24px rgba(13, 71, 161, 0.18);
}

.site-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.16);
}

.site-header-inner {
  width: min(100%, 1040px);
  min-height: 68px;
  margin: 0 auto;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  text-decoration: none;
}

.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.brand-logo img {
  width: 40px;
  height: 40px;
}

.brand-text-wrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand-title {
  overflow: hidden;
  font-size: clamp(16px, 4.7vw, 20px);
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-subtitle {
  margin-top: 3px;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.2;
  opacity: 0.82;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-link {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.10);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.header-link svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-container {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 14px max(12px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.brand-hero,
.detail-hero {
  position: relative;
  isolation: isolate;
  min-height: 150px;
  padding: 24px 22px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  color: var(--white);
  background:
    linear-gradient(125deg, rgba(13, 71, 161, 1), rgba(21, 101, 192, 0.98) 52%, rgba(66, 165, 245, 0.95));
  box-shadow: var(--card-shadow);
}

.brand-hero::before,
.detail-hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 210px;
  height: 210px;
  right: -76px;
  bottom: -130px;
  border: 24px solid rgba(255, 255, 255, 0.09);
  border-radius: 50%;
}

.brand-hero::after,
.detail-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 170px;
  height: 44px;
  right: 36px;
  top: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.11);
  transform: rotate(-12deg);
  filter: blur(2px);
}

.hero-kicker,
.section-eyebrow {
  font-size: 10px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.hero-kicker {
  color: rgba(255, 255, 255, 0.72);
}

.brand-hero h1,
.detail-hero h1 {
  margin: 8px 0 7px;
  font-size: clamp(23px, 7vw, 34px);
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.brand-hero p,
.detail-hero p {
  max-width: 610px;
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 13px;
  line-height: 1.65;
}

.hero-orb,
.detail-hero-decoration {
  position: absolute;
  right: 24px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border: 9px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  box-shadow:
    -46px -12px 0 -13px var(--cyan),
    -18px -38px 0 -13px var(--green),
    12px -37px 0 -13px var(--orange);
}

.search-card,
.result-card,
.detail-info-card,
.detail-image-card {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid rgba(13, 71, 161, 0.08);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--card-shadow);
}

.search-card {
  padding: 18px;
}

.section-heading,
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2,
.result-title {
  margin: 3px 0 0;
  color: var(--gray-900);
  font-size: 18px;
  line-height: 1.3;
}

.section-eyebrow {
  color: var(--primary-2);
}

.section-badge,
.result-count {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.section-badge {
  color: var(--primary);
  background: var(--primary-soft);
}

.result-count {
  color: #087f7b;
  background: rgba(0, 181, 176, 0.11);
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.field-smart {
  grid-column: 1 / -1;
}

.field-item {
  min-width: 0;
}

.field-label,
.detail-calc-label {
  display: block;
  margin: 0 0 7px;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}

.field-control,
#class_chexing select,
#class_carcolor select {
  width: 100%;
  min-width: 0;
  height: 47px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  outline: none;
  color: var(--gray-900);
  background: var(--white);
  font-size: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

select.field-control,
#class_chexing select,
#class_carcolor select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%),
    linear-gradient(135deg, var(--primary) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 20px,
    calc(100% - 13px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.field-control:focus,
#class_chexing select:focus,
#class_carcolor select:focus,
.detail-calc-input:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 4px rgba(21, 101, 192, 0.11);
}

.input-with-icon {
  position: relative;
}

.input-with-icon .field-control {
  padding-left: 42px;
}

.field-icon {
  position: absolute;
  z-index: 2;
  left: 13px;
  top: 50%;
  width: 19px;
  height: 19px;
  color: var(--primary-2);
  transform: translateY(-50%);
  pointer-events: none;
}

.field-icon svg,
.query-btn svg,
.result-arrow svg,
.back-btn svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-actions {
  margin-top: 16px;
}

.query-btn {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--white);
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 18px rgba(13, 71, 161, 0.20);
  cursor: pointer;
  font-size: 15px;
  font-weight: 750;
}

.query-btn svg {
  width: 18px;
  height: 18px;
}

.query-btn:active {
  transform: translateY(1px);
}

.result-head {
  padding: 17px 18px 14px;
  border-bottom: 1px solid var(--gray-200);
}

.result-list {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.formula-result-item {
  position: relative;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  display: block;
  color: inherit;
  background: var(--white);
  text-decoration: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.formula-result-item:active {
  border-color: rgba(13, 71, 161, 0.28);
  background: #f9fbff;
  transform: translateY(1px);
}

.result-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.color-code-chip {
  max-width: calc(100% - 38px);
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  color: var(--white);
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.color-code-chip-light {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.94);
}

.result-arrow {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 6px;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
}

.result-color-name {
  margin-top: 11px;
  color: var(--gray-900);
  font-size: 17px;
  line-height: 1.45;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.result-meta-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.result-meta-item,
.detail-meta-item {
  min-width: 0;
  padding: 10px 11px;
  border-radius: 12px;
  background: var(--gray-100);
}

.result-meta-item span,
.detail-meta-item span,
.formula-metrics span,
.detail-summary span {
  display: block;
  color: var(--gray-600);
  font-size: 11px;
  line-height: 1.35;
}

.result-meta-item strong,
.detail-meta-item strong {
  display: block;
  margin-top: 4px;
  color: var(--gray-900);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.empty-box {
  padding: 38px 20px;
  color: var(--gray-600);
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}

.data-end {
  padding: 14px 16px 18px;
  color: #8a96a6;
  text-align: center;
  font-size: 11px;
}

.page-container-detail {
  width: min(100%, 820px);
}

.detail-hero {
  min-height: 138px;
  display: flex;
  align-items: center;
}

.detail-hero-content {
  min-width: 0;
  width: 100%;
}

.detail-hero h1 {
  max-width: calc(100% - 70px);
  overflow-wrap: anywhere;
}

.detail-meta-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-meta-item {
  background: #f7f9fc;
  border: 1px solid var(--gray-200);
}

.detail-meta-wide {
  grid-column: 1 / -1;
}

.detail-image-wrap {
  padding: 14px;
  text-align: center;
}

.detail-image-wrap img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 380px;
  margin: 0 auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--gray-100);
  object-fit: contain;
}

.formula-form {
  margin: 0;
}

.detail-table-card {
  margin-top: 14px;
}

.formula-list {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.formula-row {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}

.formula-row-head {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.formula-seq {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--cyan);
  font-size: 12px;
  font-weight: 800;
}

.formula-code {
  min-width: 0;
  padding-top: 4px;
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.formula-metrics {
  margin-top: 11px;
  margin-left: 41px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.formula-metrics > div {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--primary-soft);
}

.formula-metrics > div:nth-child(2) {
  background: rgba(67, 182, 73, 0.10);
}

.formula-metrics strong {
  display: block;
  margin-top: 4px;
  color: var(--primary);
  font-size: 15px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.formula-metrics > div:nth-child(2) strong {
  color: #25852a;
}

.detail-summary {
  margin: 0 12px;
  padding: 12px;
  border: 1px dashed rgba(13, 71, 161, 0.25);
  border-radius: 13px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  background: #f8fbff;
}

.detail-summary strong {
  display: block;
  margin-top: 3px;
  color: var(--primary);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.detail-calc-bar {
  padding: 14px 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
}

.detail-calc-label {
  grid-column: 1 / -1;
  margin-bottom: -2px;
}

.calc-input-wrap {
  position: relative;
  min-width: 0;
}

.detail-calc-input {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0 40px 0 12px;
  outline: none;
  color: var(--gray-900);
  background: var(--white);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.calc-input-wrap span {
  position: absolute;
  right: 13px;
  top: 50%;
  color: var(--gray-600);
  font-size: 13px;
  transform: translateY(-50%);
  pointer-events: none;
}

.detail-calc-btn {
  width: auto;
  min-width: 94px;
  min-height: 46px;
}

.detail-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.back-btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(13, 71, 161, 0.20);
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--primary);
  background: var(--white);
  box-shadow: 0 7px 18px rgba(13, 71, 161, 0.08);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.back-btn svg {
  width: 17px;
  height: 17px;
}

/* Registration page compatibility */
.search-form .query-btn[style] {
  min-width: 96px !important;
}

@media (min-width: 700px) {
  .page-container {
    padding-top: 20px;
  }

  .brand-hero {
    min-height: 178px;
    padding: 32px;
  }

  .search-card {
    padding: 22px;
  }

  .search-grid {
    grid-template-columns: 1.35fr repeat(3, minmax(0, 1fr));
  }

  .field-smart {
    grid-column: auto;
  }

  .search-actions {
    display: flex;
    justify-content: flex-end;
  }

  .query-btn {
    width: auto;
    min-width: 156px;
  }

  .result-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 16px;
  }

  .detail-meta-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .detail-meta-wide {
    grid-column: span 3;
  }

  .formula-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 16px;
  }

  .detail-summary {
    margin: 0 16px;
  }

  .detail-calc-bar {
    padding: 16px;
    grid-template-columns: auto minmax(180px, 260px) auto;
    align-items: center;
  }

  .detail-calc-label {
    grid-column: auto;
    margin: 0;
  }
}

@media (max-width: 480px) {
  .site-header-inner {
    min-height: 64px;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .brand-logo img {
    width: 36px;
    height: 36px;
  }

  .header-link {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .brand-hero,
  .detail-hero {
    padding: 21px 17px;
    border-radius: 19px;
  }

  .search-card,
  .result-card,
  .detail-info-card,
  .detail-image-card {
    border-radius: 19px;
  }

  .search-card {
    padding: 15px;
  }

  .search-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .field-smart {
    grid-column: auto;
  }

  .result-meta-grid,
  .detail-meta-grid {
    grid-template-columns: 1fr;
  }

  .detail-meta-wide {
    grid-column: auto;
  }

  .result-meta-item {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
  }

  .result-meta-item strong {
    margin-top: 0;
  }

  .detail-hero h1 {
    max-width: calc(100% - 36px);
  }
}

@media (max-width: 360px) {
  .brand-subtitle {
    display: none;
  }

  .brand-title {
    font-size: 16px;
  }

  .page-container {
    padding-left: 9px;
    padding-right: 9px;
  }

  .brand-hero h1,
  .detail-hero h1 {
    font-size: 22px;
  }

  .hero-orb,
  .detail-hero-decoration {
    right: 14px;
    bottom: 15px;
    transform: scale(0.82);
    transform-origin: right bottom;
  }

  .result-head {
    padding-left: 14px;
    padding-right: 14px;
  }

  .formula-metrics {
    margin-left: 0;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }

  .detail-calc-bar {
    grid-template-columns: minmax(0, 1fr) 84px;
  }

  .detail-calc-btn {
    min-width: 84px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .formula-result-item:hover {
    border-color: rgba(13, 71, 161, 0.25);
    box-shadow: 0 10px 24px rgba(13, 71, 161, 0.10);
    transform: translateY(-1px);
  }

  .header-link:hover,
  .query-btn:hover {
    filter: brightness(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
