:root {
  --ink: #15212b;
  --muted: #67747d;
  --soft-muted: #89949a;
  --paper: #fbfaf7;
  --panel: rgba(255, 255, 255, 0.94);
  --line: #dfe4e2;
  --line-strong: #cfd7d3;
  --teal: #087f72;
  --teal-dark: #05665d;
  --teal-pale: #e4f3ef;
  --orange: #e98149;
  --orange-pale: #fceee5;
  --red: #b6453e;
  --shadow: 0 24px 70px rgba(24, 43, 40, 0.09);
  --radius: 24px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(rgba(21, 33, 43, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 33, 43, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  overflow-x: hidden;
}

button, textarea, select, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}

.ambient-one {
  top: -230px;
  right: -170px;
  background: radial-gradient(circle, rgba(8,127,114,.12), rgba(8,127,114,0) 68%);
}

.ambient-two {
  top: 580px;
  left: -330px;
  background: radial-gradient(circle, rgba(233,129,73,.10), rgba(233,129,73,0) 70%);
}

.topbar {
  width: min(1180px, calc(100% - 40px));
  height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--teal);
  border-radius: 12px;
  box-shadow: 0 7px 18px rgba(8,127,114,.22);
}

.brand-mark svg { width: 25px; height: 25px; }

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  color: #53625f;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(207,215,211,.78);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #2ca67d;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(44,166,125,.12);
}

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding-top: 22px; }

.hero {
  padding: 68px 0 58px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(400px, .8fr);
  gap: 68px;
  align-items: end;
}

.hero > * { min-width: 0; }
.hero > :not(.formula-card) { grid-column: 1; }

.eyebrow, .step-label {
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.eyebrow span {
  display: inline-block;
  margin-right: 8px;
  padding: 5px 8px;
  color: white;
  background: var(--teal);
  border-radius: 5px;
  letter-spacing: .06em;
}

h1 {
  margin: 20px 0 18px;
  font-size: clamp(46px, 6vw, 76px);
  line-height: 1.05;
  letter-spacing: -.065em;
  font-weight: 900;
}

h1 span { color: var(--teal); }

.hero-copy {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
}

.formula-card {
  grid-column: 2;
  grid-row: 1 / span 4;
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 26px 28px 28px;
  background: #17312f;
  color: white;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(21,49,47,.18);
  overflow: hidden;
}

.formula-card::after {
  content: "A";
  position: absolute;
  right: -10px;
  bottom: -55px;
  color: rgba(255,255,255,.045);
  font-family: Georgia, serif;
  font-size: 190px;
  font-weight: 700;
  line-height: 1;
}

.formula-label {
  position: relative;
  z-index: 1;
  margin-bottom: 26px;
  color: rgba(255,255,255,.6);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

.formula {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 13px;
  font-size: 14px;
  font-weight: 700;
}

.formula b { color: #75c8b8; font-size: 19px; }

.fraction {
  display: inline-flex;
  flex-direction: column;
  text-align: center;
  line-height: 1.5;
}

.fraction i { font-style: normal; white-space: nowrap; }
.fraction i:first-child { padding: 0 5px 4px; border-bottom: 1px solid rgba(255,255,255,.6); }
.fraction i:last-child { padding-top: 4px; color: rgba(255,255,255,.68); }

.workspace, .results {
  padding: clamp(24px, 4vw, 44px);
  background: var(--panel);
  border: 1px solid rgba(207,215,211,.8);
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.section-heading, .result-topline, .result-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

h2 {
  margin: 7px 0 5px;
  font-size: 27px;
  letter-spacing: -.035em;
}

.section-heading p, .result-topline p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

button:active { transform: translateY(1px); }
button:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid rgba(8,127,114,.22);
  outline-offset: 2px;
}

.ghost-button, .secondary-button, .primary-button {
  min-height: 46px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
}

.ghost-button {
  background: white;
  border: 1px solid var(--line-strong);
}

.ghost-button:hover, .secondary-button:hover { background: #f6f9f8; border-color: #aebcb6; }

.primary-button {
  min-height: 50px;
  padding-inline: 22px;
  color: white;
  background: var(--teal);
  box-shadow: 0 10px 24px rgba(8,127,114,.18);
}

.primary-button:hover { background: var(--teal-dark); box-shadow: 0 13px 28px rgba(8,127,114,.25); transform: translateY(-1px); }
.primary-button.small { min-height: 46px; }

.secondary-button {
  color: var(--teal-dark);
  background: white;
  border: 1px solid #bcd3ce;
}

button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.paste-shell {
  position: relative;
  min-height: 245px;
  margin-top: 27px;
  padding: 35px 30px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f8fbfa;
  border: 1.5px dashed #b5c8c2;
  border-radius: 20px;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
  overflow: hidden;
}

.paste-shell.is-active { background: #f2faf7; border-color: var(--teal); box-shadow: inset 0 0 0 1px rgba(8,127,114,.08); }
.paste-shell.has-data { align-items: stretch; justify-content: flex-start; padding-top: 26px; }
.paste-shell.has-data .paste-icon, .paste-shell.has-data > label, .paste-shell.has-data > p { display: none; }

.paste-icon {
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: var(--teal-pale);
  border-radius: 16px;
}

.paste-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.paste-shell > label { font-size: 16px; font-weight: 850; cursor: text; }
.paste-shell > p { margin: 9px 0 0; color: var(--soft-muted); font-size: 12px; }
kbd { padding: 3px 6px; background: white; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; font: inherit; font-size: 12px; }

textarea {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  min-height: 200px;
  padding: 26px 26px 46px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: inherit;
  resize: vertical;
  opacity: .015;
  cursor: text;
  white-space: pre;
  overflow: auto;
  line-height: 1.7;
}

.paste-shell.has-data textarea { position: relative; inset: auto; min-height: 200px; padding: 0 0 30px; opacity: 1; }
.paste-meta {
  position: absolute;
  z-index: 2;
  right: 20px;
  bottom: 14px;
  left: 20px;
  display: flex;
  justify-content: space-between;
  color: var(--soft-muted);
  font-size: 11px;
  pointer-events: none;
}

.paste-shell.has-data .paste-meta { left: 30px; right: 30px; }
#inputStatus { color: var(--teal); font-weight: 750; }

.controls-row {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.settings, .input-actions, .result-actions { display: flex; align-items: center; gap: 12px; }
.settings > label:first-child { color: var(--muted); font-size: 12px; font-weight: 750; }

.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 10px; top: 8px; color: var(--muted); pointer-events: none; }
select {
  min-width: 76px;
  height: 38px;
  padding: 0 27px 0 11px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  appearance: none;
}

.switch-control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.switch-control input { position: absolute; opacity: 0; }
.switch { position: relative; width: 36px; height: 20px; background: #cbd3d0; border-radius: 999px; transition: background .18s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: white; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.15); transition: transform .18s ease; }
.switch-control input:checked + .switch { background: var(--teal); }
.switch-control input:checked + .switch::after { transform: translateX(16px); }
.switch-control input:focus-visible + .switch { outline: 3px solid rgba(8,127,114,.22); outline-offset: 2px; }

.text-button { padding: 8px 6px; color: var(--teal-dark); background: transparent; font-size: 12px; font-weight: 800; }
.text-button:hover { color: var(--teal); }
.danger-text { color: var(--red); }

.notice {
  margin-top: 22px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border-radius: 12px;
  font-size: 13px;
}

.notice svg { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; }
.notice div { display: grid; gap: 3px; }
.notice strong { font-size: 13px; }
.error-notice { color: #893a34; background: #fdf0ed; border: 1px solid #f0cec9; }

.results { margin-top: 28px; }
.result-topline { align-items: center; }
.summary-grid {
  margin: 28px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.summary-card {
  min-width: 0;
  padding: 18px 19px;
  background: #f7f9f8;
  border: 1px solid #e6eae8;
  border-radius: 16px;
}

.summary-card.accent { color: white; background: var(--teal); border-color: var(--teal); }
.summary-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 750; }
.summary-card.accent .summary-label { color: rgba(255,255,255,.72); }
.summary-value { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 23px; font-weight: 900; letter-spacing: -.03em; white-space: nowrap; }
.summary-unit { margin-left: 3px; font-size: 12px; font-weight: 700; opacity: .65; }

.warning-list {
  margin: -4px 0 20px;
  padding: 13px 15px;
  color: #78502f;
  background: #fff8ee;
  border: 1px solid #f1ddc3;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.7;
}

.warning-list strong { color: #654127; }
.warning-list ul { margin: 5px 0 0; padding-left: 18px; }

.groups { display: grid; gap: 18px; }
.group-card { border: 1px solid var(--line); border-radius: 19px; overflow: hidden; }
.group-header {
  min-height: 72px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #f7faf9;
  border-bottom: 1px solid var(--line);
}

.group-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.group-number { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; color: var(--teal-dark); background: var(--teal-pale); border-radius: 10px; font-size: 12px; font-weight: 900; }
.group-title-text { min-width: 0; }
.group-title h3 { max-width: 520px; margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; font-size: 15px; white-space: nowrap; }
.group-title p { margin: 0; color: var(--soft-muted); font-size: 11px; }

.billing-editor { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap; }
.billing-editor input, .weight-input {
  color: var(--ink);
  background: white;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.billing-editor input { width: 88px; height: 37px; padding: 0 10px; text-align: right; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 14px 15px; text-align: left; border-bottom: 1px solid #edf0ef; }
th { color: #78847f; background: white; font-size: 10px; font-weight: 850; letter-spacing: .04em; white-space: nowrap; }
td { color: #34413f; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.cell-main { color: var(--ink); font-weight: 800; }
.cell-muted { color: var(--soft-muted); }
.number-cell { text-align: right; font-variant-numeric: tabular-nums; }
.weight-input { width: 86px; height: 34px; padding: 0 9px; text-align: right; }
.charge-value { color: var(--teal-dark); font-size: 14px; font-weight: 900; }
.share-track { width: 62px; height: 5px; margin-left: auto; background: #e6ece9; border-radius: 99px; overflow: hidden; }
.share-fill { height: 100%; background: var(--orange); border-radius: inherit; }
.share-number { display: inline-block; min-width: 51px; margin-top: 4px; color: var(--muted); font-size: 10px; }

.group-check {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  color: var(--muted);
  background: #fbfcfc;
  border-top: 1px solid #edf0ef;
  font-size: 11px;
}
.group-check strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.check-ok { color: var(--teal-dark); font-weight: 800; }
.check-ok::before { content: "✓"; margin-right: 5px; }
.check-bad { color: var(--red); font-weight: 800; }
.check-bad::before { content: "!"; margin-right: 5px; }

.result-footer {
  margin-top: 24px;
  padding-top: 22px;
  align-items: center;
  border-top: 1px solid var(--line);
}
.result-footer > div { display: grid; gap: 4px; }
.result-footer strong { font-size: 13px; }
.result-footer span { color: var(--soft-muted); font-size: 11px; }

footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 2px 42px;
  display: flex;
  justify-content: space-between;
  color: var(--soft-muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 28px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: white;
  background: #17312f;
  border-radius: 12px;
  box-shadow: 0 14px 35px rgba(21,49,47,.28);
  font-size: 13px;
  font-weight: 750;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 17px; height: 17px; fill: none; stroke: #77d4c2; stroke-width: 2.2; }

[hidden] { display: none !important; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 32px; padding-top: 44px; }
  .hero > :not(.formula-card), .formula-card { grid-column: 1; grid-row: auto; }
  .formula-card { max-width: 600px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .result-topline { align-items: flex-start; }
  .result-actions { flex-direction: column; align-items: stretch; }
}

@media (max-width: 680px) {
  .topbar, main, footer { width: min(100% - 24px, 1180px); }
  .topbar { height: 70px; }
  .privacy-badge { padding: 7px 9px; font-size: 10px; }
  .hero { padding: 36px 4px 38px; }
  h1 { margin-top: 16px; font-size: clamp(38px, 11.2vw, 48px); overflow-wrap: anywhere; }
  .hero-copy { font-size: 15px; }
  .formula-card { padding: 22px 20px; }
  .formula { min-width: 0; gap: 7px; font-size: 11.5px; }
  .workspace, .results { padding: 22px 16px; border-radius: 22px; }
  .section-heading, .result-topline { flex-direction: column; }
  .section-heading .ghost-button { align-self: stretch; }
  .paste-shell { min-height: 225px; padding-inline: 18px; }
  .controls-row { flex-direction: column; align-items: stretch; }
  .settings { flex-wrap: wrap; }
  .input-actions { display: grid; grid-template-columns: auto auto 1fr; }
  .primary-button { padding-inline: 15px; }
  .result-actions { width: 100%; display: grid; grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-card { padding: 15px; }
  .summary-value { font-size: 20px; }
  .group-header { align-items: flex-start; flex-direction: column; }
  .billing-editor { align-self: stretch; justify-content: space-between; }
  table { min-width: 680px; }
  .result-footer { align-items: stretch; flex-direction: column; }
  footer { gap: 12px; flex-direction: column; }
}

@media (max-width: 420px) {
  .privacy-badge { width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 0; }
  .fraction i { white-space: normal; }
}

@media print {
  body { background: white; }
  .topbar, .hero, .workspace, .result-actions, .result-footer, footer, .ambient, .toast { display: none !important; }
  main { width: 100%; }
  .results { margin: 0; padding: 0; border: 0; box-shadow: none; }
  .group-card { break-inside: avoid; }
}
