:root {
  --bg: #faf3ea;
  --surface: #fffdf9;
  --surface-2: #faf3ea;
  --ink: #2f241b;
  --muted: #7d6d5f;
  --line: #e9dccb;
  --primary: #c2410c;
  --primary-strong: #9a3412;
  --primary-soft: #fde7d4;
  --accent: #b45309;
  --accent-soft: #fdf0df;
  --info: #a16207;
  --info-soft: #fbf0d8;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --success: #3f6212;
  --success-soft: #edf3d9;
  --shadow-sm: 0 1px 2px rgba(72, 45, 24, 0.08);
  --shadow-md: 0 6px 18px -8px rgba(72, 45, 24, 0.22);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", "Microsoft YaHei", "PingFang SC",
    "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  letter-spacing: 0;
}

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

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #4a2c1a;
  color: #fff;
  box-shadow: 0 2px 10px rgba(58, 30, 16, 0.3);
}

.topbar-inner {
  max-width: 1220px;
  margin: 0 auto;
  min-height: 62px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.brand-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fdbb74;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 0.98rem;
  font-weight: 700;
  white-space: nowrap;
}

.brand-text small {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.main-nav a {
  flex: 0 0 auto;
  height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.72);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.main-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main-nav a.active {
  background: #b3562a;
  color: #fff;
  font-weight: 600;
}

/* ---------- Page scaffolding ---------- */
.page {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 20px 46px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.breadcrumb a:hover {
  color: var(--primary);
}

.tool-hero {
  background: linear-gradient(135deg, #54280f 0%, #9a3c15 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 28px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-md);
}

.tool-hero h1 {
  font-size: 1.55rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.tool-hero h1 svg {
  width: 24px;
  height: 24px;
  color: #fdbb74;
  flex: 0 0 auto;
}

.tool-hero p {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.78);
  max-width: 860px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: #fdf0e3;
  font-size: 0.74rem;
  white-space: nowrap;
}

.hero-tag svg {
  width: 13px;
  height: 13px;
}

.section {
  margin-bottom: 26px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--primary);
}

.section-title .section-note {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Formula band ---------- */
.formula-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  margin-bottom: 22px;
}

.formula-band-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-strong);
  margin-bottom: 10px;
}

.formula-line {
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 1.08rem;
  text-align: center;
  color: var(--ink);
  margin: 8px 0;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.formula-vars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 4px 22px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.7;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 5fr) minmax(330px, 4fr);
  gap: 20px;
  align-items: start;
}

.workspace.single {
  grid-template-columns: 1fr;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.panel-header svg {
  width: 17px;
  height: 17px;
  color: var(--primary);
  flex: 0 0 auto;
}

.panel-body {
  padding: 16px;
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: 14px;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.label-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.label-row .unit {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  height: 40px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf9;
  color: var(--ink);
  font-size: 0.94rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.18);
}

input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

.field-hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 5px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

/* ---------- Buttons ---------- */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.93rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s,
    transform 0.05s;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(194, 65, 12, 0.3);
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.btn-block {
  width: 100%;
}

/* ---------- Results ---------- */
.result-hero {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  text-align: center;
  margin-bottom: 14px;
}

.result-hero .label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.result-hero .value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--primary-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.result-hero .sub {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 4px;
}

.kv-list {
  margin: 0 0 14px;
}

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 0.86rem;
}

.kv:last-child {
  border-bottom: 0;
}

.kv .k {
  color: var(--muted);
  flex: 0 0 auto;
}

.kv .v {
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.kv .v strong {
  color: var(--primary-strong);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 420px;
}

.data-table th {
  background: #f4ead9;
  color: var(--ink);
  font-weight: 600;
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: #fbf4ea;
}

.data-table td.center,
.data-table th.center {
  text-align: center;
}

.data-table .hit {
  background: var(--primary-soft) !important;
  box-shadow: inset 0 0 0 1px var(--primary);
  font-weight: 700;
  color: var(--primary-strong);
}

.table-caption {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.55;
}

/* ---------- Presets / chips / callouts ---------- */
.preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.preset-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.preset-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip svg {
  width: 13px;
  height: 13px;
}

.chip-success {
  background: var(--success-soft);
  color: var(--success);
}

.chip-warn {
  background: var(--accent-soft);
  color: #8a5208;
}

.chip-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-info {
  background: var(--info-soft);
  color: var(--info);
}

.chip-neutral {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.callout {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.83rem;
  line-height: 1.65;
  margin-top: 14px;
}

.callout-warn {
  background: var(--accent-soft);
  border: 1px solid #ecd9bb;
  color: #7c4a0d;
}

.callout-info {
  background: #f0f1dc;
  border: 1px solid #d8dcae;
  color: #5a6b1f;
}

.callout-danger {
  background: var(--danger-soft);
  border: 1px solid #f0caca;
  color: #991b1b;
}

/* ---------- Home ---------- */
.home-hero {
  background: linear-gradient(135deg, #54280f 0%, #9a3c15 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 30px 30px 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.home-hero h1 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.home-hero h1 svg {
  width: 28px;
  height: 28px;
  color: #fdbb74;
  flex: 0 0 auto;
}

.home-hero p {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.8);
  max-width: 900px;
  line-height: 1.7;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 30px;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stage-card .stage-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.stage-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.stage-card p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.stage-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage-links a {
  font-size: 0.76rem;
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 4px 9px;
  font-weight: 600;
}

.stage-links a:hover {
  background: #f4d3b8;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}

.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.tool-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.tool-icon svg {
  width: 21px;
  height: 21px;
}

.tool-category {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--info);
  background: var(--info-soft);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.tool-card h3 {
  font-size: 1rem;
  font-weight: 700;
}

.tool-card .tool-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
  flex: 1 1 auto;
}

.tool-formula {
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 0.84rem;
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
  line-height: 1.6;
}

.tool-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  transition: all 0.15s;
}

.tool-link svg {
  width: 15px;
  height: 15px;
}

.tool-link:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 20px 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
  line-height: 1.8;
}

.site-footer strong {
  color: var(--ink);
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .tool-grid,
  .stage-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 14px;
    gap: 8px;
  }

  .main-nav {
    padding-bottom: 2px;
  }

  .brand-text small {
    display: none;
  }

  .page {
    padding: 16px 14px 36px;
  }

  .tool-hero,
  .home-hero {
    padding: 20px 18px;
  }

  .tool-hero h1,
  .home-hero h1 {
    font-size: 1.3rem;
  }

  .tool-grid,
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .btn-row {
    flex-direction: column;
  }
}
