:root {
  color-scheme: light;
  --bg: #eef3f0;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --ink: #17202a;
  --muted: #62707c;
  --line: #d6dfdc;
  --accent: #19766f;
  --accent-dark: #105d58;
  --manual: #fff2c8;
  --manual-line: #d9ad3d;
  --danger: #b13c48;
  --danger-bg: #fff1f2;
  --ok: #287a43;
  --ok-bg: #f0faf3;
  --warning-bg: #fff8e8;
  --shadow: 0 14px 34px rgba(28, 48, 54, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(25, 118, 111, 0.1), transparent 280px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.mobile-shell {
  width: calc(100vw - 24px);
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 0 34px;
  min-width: 0;
}

.mobile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 780;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.15;
  font-weight: 800;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 780;
}

.desktop-link,
.quick-actions a,
.quick-actions button {
  min-height: 40px;
  border: 1px solid rgba(25, 118, 111, 0.28);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 14px;
  font-weight: 760;
}

.desktop-link {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 8px 12px;
}

.hero-summary,
.input-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-summary {
  margin: 14px 0 12px;
}

.signal-tile {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-bottom: 1px solid rgba(40, 122, 67, 0.18);
  background: var(--ok-bg);
}

.signal-tile.danger {
  border-color: rgba(177, 60, 72, 0.26);
  background: var(--danger-bg);
}

.signal-tile span,
.summary-list span,
output > span,
label > span,
.section-head span,
.signal-tile small,
.summary-list small,
output small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 680;
}

.signal-tile strong {
  color: var(--ok);
  font-size: 34px;
  line-height: 1;
  font-weight: 820;
}

.signal-tile.danger strong,
.danger-text {
  color: var(--danger);
}

.summary-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.summary-list article {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface);
}

.summary-list strong {
  font-size: 22px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.quick-actions {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  width: calc(100vw - 24px);
  max-width: 560px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  background: rgba(238, 243, 240, 0.94);
  backdrop-filter: blur(12px);
}

.quick-actions button,
.quick-actions a {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 8px 10px;
}

.input-panel {
  margin-top: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.section-head span {
  flex: 0 0 auto;
}

.field-stack,
.result-stack {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
}

.result-stack {
  padding-top: 0;
}

label,
output {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.formula-note,
output > span,
label > span,
.section-head span,
.signal-tile span,
.summary-list span {
  overflow-wrap: anywhere;
}

input,
select {
  width: 100%;
  min-height: 50px;
  border: 1px solid #c6d4d1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
  font-size: 17px;
  font-weight: 760;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 118, 111, 0.14);
}

.manual-field {
  position: relative;
  padding: 11px;
  border: 1px solid var(--manual-line);
  border-radius: 8px;
  background: var(--manual);
}

.manual-field::after {
  content: "手填";
  position: absolute;
  top: -7px;
  right: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #9c7422;
  color: #fff;
  font-size: 11px;
  font-weight: 760;
}

.manual-field input,
.manual-field select {
  border-color: rgba(157, 116, 34, 0.35);
}

.input-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: stretch;
}

.input-suffix input {
  border-radius: 8px 0 0 8px;
}

.input-suffix em {
  display: grid;
  place-items: center;
  border: 1px solid rgba(157, 116, 34, 0.35);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: #f8df9c;
  color: #624a16;
  font-style: normal;
  font-weight: 780;
}

output {
  min-height: 82px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

output strong {
  font-size: 19px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.fixed-output {
  background: #f7faf9;
}

.formula-note span {
  display: block;
}

.formula-note span + span {
  margin-top: 3px;
  color: #798692;
}

body.formula-collapsed .formula-note {
  display: none;
}

.risk-highlight {
  border-color: rgba(177, 60, 72, 0.66) !important;
  box-shadow: 0 0 0 3px rgba(177, 60, 72, 0.12);
}

.manual-field.risk-highlight input,
.manual-field.risk-highlight select,
input.risk-highlight {
  border-color: rgba(177, 60, 72, 0.72) !important;
  background: #fff8ef;
}

.danger-output {
  border-color: rgba(177, 60, 72, 0.38);
  background: var(--danger-bg);
}

.danger-output strong,
.danger-output small {
  color: var(--danger);
}

.risk-panel .section-head {
  background: #fffafa;
}

.risk-list {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
}

.risk-item,
.risk-empty {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.risk-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.risk-title em {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 780;
}

.risk-title strong {
  font-size: 14px;
}

.risk-item > span,
.risk-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.risk-item.high {
  border-color: rgba(177, 60, 72, 0.35);
  background: var(--danger-bg);
}

.risk-item.high strong {
  color: var(--danger);
}

.risk-item.high em {
  background: #d94b58;
  color: #fff;
}

.risk-item.medium {
  border-color: rgba(186, 126, 28, 0.35);
  background: var(--warning-bg);
}

.risk-item.medium strong {
  color: #9c6810;
}

.risk-item.medium em {
  background: #d89418;
  color: #fff;
}

.risk-item.low {
  border-color: rgba(25, 118, 111, 0.26);
  background: #f4fbfa;
}

.risk-item.low strong {
  color: var(--accent);
}

.risk-item.low em {
  background: #268f78;
  color: #fff;
}

@media (max-width: 360px) {
  .mobile-shell {
    width: calc(100vw - 16px);
  }

  .quick-actions {
    width: calc(100vw - 16px);
  }

  h1 {
    font-size: 24px;
  }

  .signal-tile strong {
    font-size: 30px;
  }

  .summary-list strong {
    font-size: 20px;
  }
}
