:root {
  color-scheme: light;
  --ink: #173b34;
  --ink-soft: #31554d;
  --canvas: #f1f2ea;
  --paper: #fbfbf6;
  --line: #d7ddd2;
  --muted: #6b7973;
  --accent: #d1a64e;
  --accent-pale: #f8efd9;
  --danger: #a84437;
  --shadow: 0 22px 50px rgba(31, 59, 51, 0.09);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background-color: var(--canvas);
  background-image:
    linear-gradient(rgba(23, 59, 52, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 59, 52, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
}

button,
input { font: inherit; }

button { cursor: pointer; }
[hidden] { display: none !important; }

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 42px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 740;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 7px);
  gap: 2px;
  width: 16px;
  height: 16px;
  padding: 1px;
  border: 1px solid var(--ink);
}

.brand-mark i { background: var(--ink); }
.brand-mark i:last-child { background: var(--accent); }

.back-link {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--ink);
  text-decoration: underline;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 48px;
  padding: 0 2px 38px;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 12px 0 0;
  font-size: clamp(34px, 5vw, 60px);
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: -0.06em;
}

.intro-copy {
  width: min(330px, 100%);
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 0.98fr) minmax(0, 1.02fr);
  gap: 18px;
  align-items: stretch;
}

.parameter-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.parameter-panel {
  padding: clamp(22px, 3vw, 34px);
  background: var(--paper);
}

.result-panel {
  display: flex;
  min-width: 0;
  min-height: 610px;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(22px, 3vw, 34px);
  color: #f8faef;
  background: var(--ink);
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading h2 {
  margin: 7px 0 0;
  font-size: 22px;
  letter-spacing: -0.035em;
}

.result-heading .section-label { color: #b7c9bd; }

.unit-switch {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f2f4ec;
}

.result-heading .unit-switch {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.unit-button {
  min-height: 28px;
  min-width: 38px;
  border: 0;
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.unit-button:hover { color: var(--ink); }
.unit-button:active { transform: translateY(1px); }

.unit-button.is-pressed {
  color: var(--paper);
  background: var(--ink);
}

.result-heading .unit-button { color: #e0e9e2; }
.result-heading .unit-button:hover { color: #fff; }

.result-heading .unit-button.is-pressed {
  color: var(--ink);
  background: var(--accent);
}

.method-control {
  margin-top: 30px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.method-control > p {
  margin: 0 0 9px;
  font-size: 13px;
  font-weight: 700;
}

.method-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eef1e9;
}

.method-switch button {
  min-height: 48px;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink-soft);
  background: transparent;
  text-align: left;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.method-switch button span,
.method-switch button small { display: block; }

.method-switch button span {
  font-size: 13px;
  font-weight: 760;
}

.method-switch button small {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.4;
}

.method-switch button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.method-switch button:active { transform: translateY(1px); }

.method-switch button.is-pressed {
  border-color: rgba(23, 59, 52, 0.08);
  color: var(--ink);
  background: #fffefa;
  box-shadow: 0 3px 9px rgba(23, 59, 52, 0.08);
}

.method-switch button.is-pressed small { color: var(--ink-soft); }

.parameter-form { margin-top: 25px; }

.form-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.form-title h3 {
  margin: 0;
  font-size: 14px;
}

.form-title span {
  color: var(--muted);
  font-size: 10px;
}

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

.field { min-width: 0; }

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

.input-wrap { position: relative; }

.input-wrap input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 48px 0 13px;
  color: var(--ink);
  background: #fffefa;
  font-size: 16px;
  font-weight: 650;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-wrap input:hover { border-color: #aebbb2; }

.input-wrap input:focus {
  border-color: var(--ink-soft);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(23, 59, 52, 0.09);
}

.input-wrap input:focus-visible {
  outline: 3px solid #173b34;
  outline-offset: 2px;
}

.input-wrap input::placeholder {
  color: #abb4ad;
  font-weight: 500;
  opacity: 0.78;
}

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

.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 27px;
  padding-top: 19px;
  border-top: 1px solid var(--line);
}

.reset-button {
  min-height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 15px;
  color: var(--ink);
  background: #fffefa;
  font-size: 13px;
  font-weight: 750;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.reset-button:hover {
  border-color: var(--ink-soft);
  background: var(--accent-pale);
  transform: translateY(-1px);
}

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

.form-status {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.empty-state,
.error-state {
  display: grid;
  min-height: 400px;
  flex: 1;
  place-content: center;
  text-align: center;
}

.state-index {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.empty-state h3,
.error-state h3 {
  margin: 14px 0 10px;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.empty-state p,
.error-state p {
  max-width: 310px;
  margin: 0;
  color: #b7c9bd;
  font-size: 13px;
  line-height: 1.7;
}

.error-state {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid rgba(220, 102, 85, 0.45);
  border-radius: 12px;
  background: rgba(168, 68, 55, 0.13);
}

.error-state .state-index { color: #f2ac9e; }

.result-state {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  padding-top: 32px;
}

.recommendation {
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04));
}

.recommendation p {
  margin: 0 0 9px;
  color: #d3dfd5;
  font-size: 13px;
  font-weight: 680;
}

.recommendation div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.recommendation output {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--accent);
  font-size: clamp(52px, 7vw, 76px);
  font-weight: 760;
  line-height: 0.95;
  letter-spacing: -0.08em;
}

.recommendation div span {
  flex: 0 0 auto;
  font-size: 20px;
  font-weight: 750;
}

.recommendation small {
  display: block;
  margin-top: 13px;
  color: #b7c9bd;
  font-size: 11px;
  line-height: 1.5;
}

.breakdown-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
  margin: 24px 0 0;
}

.breakdown-list > div {
  min-width: 0;
  padding: 13px 0 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.breakdown-list dt {
  color: #b7c9bd;
  font-size: 11px;
}

.breakdown-list dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.calculation-notice {
  margin: auto 0 0;
  padding: 16px 18px;
  border-left: 2px solid var(--accent);
  color: #d3dfd5;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  line-height: 1.65;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid #173b34;
  outline-offset: 2px;
}

.result-panel .unit-button:focus-visible {
  outline: 3px solid #f8efd9;
  outline-offset: 2px;
}

footer {
  margin: 27px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 28px, 620px);
    padding-top: 20px;
  }

  .topbar { padding-bottom: 32px; }

  .intro {
    display: block;
    padding-bottom: 28px;
  }

  .intro h1 { font-size: clamp(35px, 11vw, 49px); }
  .intro-copy { margin-top: 19px; }
  .workbench { grid-template-columns: 1fr; }

  .parameter-panel,
  .result-panel { border-radius: 13px; }

  .result-panel { min-height: 490px; }

  .empty-state,
  .error-state { min-height: 330px; }
}

@media (max-width: 420px) {
  .page-shell { width: calc(100% - 20px); }

  .panel-heading,
  .form-title,
  .form-actions {
    align-items: flex-start;
  }

  .form-title,
  .form-actions { flex-direction: column; }

  .method-switch,
  .form-grid,
  .breakdown-list { grid-template-columns: 1fr; }

  .method-switch button { text-align: center; }
  .result-state { padding-top: 24px; }
  .recommendation { padding: 20px 17px; }
  .recommendation output { font-size: clamp(48px, 18vw, 63px); }
  .breakdown-list { gap: 0; }
}

@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;
  }
}
