:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --text: #2e2a24;
  --muted: #766f65;
  --border: #ded5c8;
  --border-strong: #cfc1ae;
  --accent: #e88b17;
  --accent-strong: #c96d00;
  --accent-soft: #fff1d7;
  --profit: #d94436;
  --profit-soft: #fff0ee;
  --loss: #16855a;
  --loss-soft: #eaf8f1;
  --shadow: 0 24px 70px rgba(93, 67, 31, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(115, 78, 34, 0.022) 1px, transparent 1px) 0 0 / 46px 46px,
    linear-gradient(rgba(115, 78, 34, 0.018) 1px, transparent 1px) 0 0 / 46px 46px,
    radial-gradient(circle at 10% 10%, #fffaf2 0, transparent 30%),
    var(--bg);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(232, 139, 23, 0.32);
  outline-offset: 2px;
}

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

.page-glow-one {
  top: -220px;
  right: -140px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.17), transparent 68%);
}

.page-glow-two {
  bottom: -260px;
  left: -180px;
  background: radial-gradient(circle, rgba(180, 115, 45, 0.10), transparent 68%);
}

.site-header {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #f5aa2b, #d97806);
  box-shadow: 0 10px 24px rgba(217, 120, 6, 0.25);
  font-size: 26px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.privacy-pill,
.rate-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border: 1px solid rgba(232, 139, 23, 0.24);
  color: #87500c;
  background: rgba(255, 241, 215, 0.82);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.privacy-pill {
  padding: 9px 13px;
}

.privacy-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: #1d9d65;
  box-shadow: 0 0 0 4px rgba(29, 157, 101, 0.11);
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: 22px;
  align-items: start;
}

.calculator-card,
.results-card {
  position: relative;
  border: 1px solid rgba(207, 193, 174, 0.78);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.calculator-card {
  padding: 28px;
  position: sticky;
  top: 18px;
}

.results-card {
  padding: 28px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

h1 {
  max-width: 430px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.18;
}

h2 {
  font-size: 24px;
}

.rate-badge {
  padding: 7px 11px;
}

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

.field {
  display: block;
  min-width: 0;
}

.field > span {
  display: block;
  margin-bottom: 8px;
  color: #504a43;
  font-size: 14px;
  font-weight: 750;
}

.field select,
.input-with-unit {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field select {
  padding: 0 38px 0 13px;
  color: var(--text);
  appearance: auto;
}

.field select:hover,
.input-with-unit:hover {
  border-color: var(--border-strong);
}

.field select:focus,
.input-with-unit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(232, 139, 23, 0.10);
}

.input-with-unit {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.input-with-unit input {
  min-width: 0;
  flex: 1;
  height: 44px;
  border: 0;
  padding: 0 10px 0 13px;
  color: var(--text);
  background: transparent;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.input-with-unit em {
  flex: none;
  padding: 0 12px 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.field-hint {
  display: block;
  min-height: 17px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.field-hint.warning {
  color: #b75d00;
}

.fee-settings {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(252, 249, 244, 0.78);
  overflow: hidden;
}

.fee-settings summary,
.formula-note summary {
  list-style: none;
  cursor: pointer;
}

.fee-settings summary::-webkit-details-marker,
.formula-note summary::-webkit-details-marker {
  display: none;
}

.fee-settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 66px;
  padding: 13px 16px;
}

.fee-settings summary strong,
.fee-settings summary small {
  display: block;
}

.fee-settings summary strong {
  font-size: 14px;
}

.fee-settings summary small {
  max-width: 310px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.summary-action {
  flex: none;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.fee-settings[open] .summary-action {
  font-size: 0;
}

.fee-settings[open] .summary-action::after {
  content: "收起";
  font-size: 12px;
}

.fee-grid {
  padding: 4px 16px 18px;
  border-top: 1px dashed var(--border);
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: #b3261e;
  font-size: 13px;
  font-weight: 700;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.button,
.copy-button {
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.button:hover,
.copy-button:hover {
  transform: translateY(-1px);
}

.button:active,
.copy-button:active {
  transform: translateY(0);
}

.button {
  min-height: 46px;
  padding: 0 17px;
}

.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: linear-gradient(145deg, #f5a721, #de7e08);
  box-shadow: 0 10px 23px rgba(222, 126, 8, 0.24);
}

.button-primary:hover {
  box-shadow: 0 13px 26px rgba(222, 126, 8, 0.30);
}

.button-secondary {
  color: #5b5248;
  background: #f4eee5;
}

.remember-setting {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.remember-setting input {
  accent-color: var(--accent);
}

.result-heading-row {
  align-items: center;
}

.copy-button {
  min-height: 36px;
  padding: 0 13px;
  color: #7c4a0b;
  background: var(--accent-soft);
}

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

.metric {
  min-height: 126px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.84);
}

.metric-primary {
  background: linear-gradient(145deg, #fff8ed, #fff);
  border-color: #efd5ad;
}

.metric span,
.metric small,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  margin-top: 10px;
  font-size: clamp(23px, 3.2vw, 32px);
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.metric small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.value-profit {
  color: var(--profit) !important;
}

.value-loss {
  color: var(--loss) !important;
}

.value-flat {
  color: #6d6257 !important;
}

.gross-strip {
  margin-top: 13px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 12px;
  border: 1px dashed #dbc8ab;
  border-radius: 14px;
  background: rgba(255, 247, 234, 0.72);
}

.gross-strip > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.gross-strip strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.gross-strip > span:last-child {
  justify-self: end;
  color: #675b4f;
  font-size: 12px;
  text-align: right;
}

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

.detail-panel {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eee7dd;
}

.detail-icon {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 900;
}

.buy-icon {
  color: #a94439;
  background: var(--profit-soft);
}

.sell-icon {
  color: #16724f;
  background: var(--loss-soft);
}

.detail-title h3,
.detail-title p {
  margin: 0;
}

.detail-title h3 {
  font-size: 15px;
}

.detail-title p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.detail-panel dl {
  margin: 12px 0 0;
}

.detail-panel dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
}

.detail-panel dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-panel dd {
  margin: 0;
  color: #3e3831;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.detail-panel .detail-total {
  margin-top: 6px;
  padding-top: 11px;
  border-top: 1px dashed var(--border);
}

.detail-panel .detail-total dt,
.detail-panel .detail-total dd {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.formula-note {
  margin-top: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(248, 245, 240, 0.72);
}

.formula-note summary {
  padding: 13px 15px;
  color: #5e554c;
  font-size: 12px;
  font-weight: 800;
}

.formula-note summary::after {
  content: "+";
  float: right;
  color: var(--accent-strong);
  font-size: 17px;
  line-height: 1;
}

.formula-note[open] summary::after {
  content: "−";
}

.formula-note > div {
  padding: 0 15px 13px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.formula-note p {
  margin: 6px 0;
}

.site-footer {
  width: min(1160px, calc(100% - 32px));
  margin: 18px auto 0;
  padding: 0 0 calc(28px + env(safe-area-inset-bottom));
  color: #81786d;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 20;
  padding: 11px 15px;
  border-radius: 999px;
  color: #fff;
  background: rgba(40, 35, 29, 0.92);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  font-size: 12px;
  font-weight: 750;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 760px;
  }

  .calculator-card {
    position: static;
  }
}

@media (max-width: 640px) {
  .site-header,
  .app-shell,
  .site-footer {
    width: min(100% - 20px, 760px);
  }

  .site-header {
    padding-top: 16px;
  }

  .privacy-pill {
    display: none;
  }

  .calculator-card,
  .results-card {
    padding: 20px;
    border-radius: 20px;
  }

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

  .rate-badge {
    display: none;
  }

  .form-grid,
  .summary-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .primary-fields {
    gap: 13px;
  }

  .fee-grid {
    gap: 13px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .button {
    width: 100%;
  }

  .remember-setting {
    grid-column: 1 / -1;
    margin: 4px 0 0;
  }

  .metric {
    min-height: 112px;
  }

  .gross-strip {
    grid-template-columns: 1fr auto;
  }

  .gross-strip > span:last-child {
    grid-column: 1 / -1;
    justify-self: start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
