html, body, main, header, footer {
  margin: 0;
  padding: 0;
}

/* ─── 应用容器 ─── */
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#app-title {
  text-align: center;
  font-size: 28px;
  color: #1e40af;
  margin: 0 0 8px 0;
}

#app-subtitle {
  text-align: center;
  color: #64748b;
  font-size: 14px;
  margin: 0 0 24px 0;
}

/* ─── 卡片 ─── */
.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  padding: 24px;
  margin-bottom: 20px;
}

/* ─── 计算区域 ─── */
.calc-section {
  margin-bottom: 20px;
}

.calc-section h3 {
  font-size: 16px;
  color: #1e293b;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

/* ─── 输入组 ─── */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 14px;
  color: #475569;
  margin-bottom: 6px;
  font-weight: 500;
}

.input-group input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

.input-group input[type="number"]::-webkit-inner-spin-button,
.input-group input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-group input[type="number"]:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-row input {
  flex: 1;
}

#btn-swap {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 20px;
  color: #475569;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#btn-swap:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* ─── 错误消息 ─── */
.error-msg {
  display: block;
  font-size: 13px;
  color: #dc2626;
  min-height: 20px;
  margin-top: 4px;
}

/* ─── 操作按钮 ─── */
#action-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

#btn-calc {
  flex: 1;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  background: #2563eb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

#btn-calc:hover {
  background: #1d4ed8;
}

#btn-calc:active {
  background: #1e40af;
}

#btn-clear {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

#btn-clear:hover {
  background: #e2e8f0;
}

/* ─── 结果区域 ─── */
.result-area {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 16px;
  min-height: 40px;
}

.result-item {
  margin-bottom: 12px;
}

.result-item:last-child {
  margin-bottom: 0;
}

.result-item h4 {
  font-size: 14px;
  color: #0284c7;
  margin: 0 0 6px 0;
}

.result-value {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  word-break: break-all;
  padding: 8px 0;
  display: none;
}

.result-value.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-process {
  font-size: 13px;
  color: #475569;
  margin-top: 8px;
}

.result-process details {
  cursor: pointer;
}

.result-process summary {
  color: #2563eb;
  font-weight: 500;
}

.result-process p {
  margin: 4px 0;
  padding-left: 12px;
}

/* ─── 历史记录 ─── */
#history-card h3 {
  font-size: 16px;
  color: #1e293b;
  margin: 0 0 12px 0;
}

#history-list {
  list-style: none;
  margin: 0 0 12px 0;
  padding: 0;
}

.history-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  padding: 16px 0;
}

.history-item {
  padding: 10px 12px;
  font-size: 14px;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}

.history-item:hover {
  background: #f8fafc;
}

.history-item:last-child {
  border-bottom: none;
}

#btn-clear-history {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  color: #94a3b8;
  background: none;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

#btn-clear-history:hover {
  color: #dc2626;
  border-color: #dc2626;
}

/* ─── 改编按钮 ─── */
#__fork {
  text-align: center;
  margin: 16px 0;
}

#__fork button {
  padding: 10px 28px;
  font-size: 14px;
  color: #2563eb;
  background: none;
  border: 2px solid #2563eb;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

#__fork button:hover {
  background: #2563eb;
  color: #ffffff;
}

/* ─── 简介/场景/FAQ 区域 ─── */
#features,
#scenarios,
#FAQ {
  max-width: 720px;
  margin: 0 auto 24px auto;
  padding: 0 16px;
}

#features h2,
#scenarios h2,
#FAQ h2 {
  font-size: 20px;
  color: #1e293b;
  margin: 0 0 10px 0;
}

#features p {
  font-size: 14px;
  color: #475569;
  line-height: 1.7;
  margin: 0;
}

#scenarios ul {
  margin: 0;
  padding-left: 20px;
}

#scenarios li {
  font-size: 14px;
  color: #475569;
  line-height: 1.8;
}

#FAQ dl {
  margin: 0;
}

#FAQ dt {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin-top: 12px;
}

#FAQ dd {
  font-size: 14px;
  color: #475569;
  line-height: 1.7;
  margin: 4px 0 8px 0;
}

/* ─── 响应式：移动端 ─── */
@media (max-width: 480px) {
  #app {
    padding: 16px 12px;
  }

  #app-title {
    font-size: 22px;
  }

  .card {
    padding: 16px;
  }

  #action-bar {
    flex-direction: column;
  }

  #btn-clear {
    width: 100%;
  }

  .result-value {
    font-size: 16px;
  }
}
