/* CSS Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
body {
  background-color: #F7F7F7;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #333;
  -webkit-tap-highlight-color: transparent;
}

/* App 容器：最大宽度 480px，居中 */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  position: relative;
}

/* 导航栏 */
.nav-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 44px;
  background-color: #2c3e50;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  z-index: 100;
}

.nav-bar .nav-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
}

.nav-bar .nav-btn {
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  background: none;
  border: none;
  padding: 0 8px;
}

/* 页面内容区域（避免被导航栏遮挡） */
.page-content {
  padding: 44px 0 0 0;
}

/* 列表项 */
.list-item {
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.list-item:active {
  background: #f5f5f5;
}

/* 主按钮 */
.btn-primary {
  background: #2c3e50;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}

.btn-primary:active {
  opacity: 0.85;
}

/* 输入框 */
.form-input {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  font-size: 14px;
  width: 100%;
  outline: none;
}

.form-input:focus {
  border-color: #2c3e50;
}

/* 结果区域 */
.result-area {
  background: #f0f0f0;
  border-radius: 4px;
  padding: 12px;
  margin-top: 12px;
}

/* 首页网格 */
.home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
}

/* 首页网格项 */
.home-grid-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  cursor: pointer;
  border-radius: 4px;
}

/* 完成状态角标 */
.home-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.home-badge--done {
  background-color: #27ae60;
}

.home-badge--todo {
  background-color: #e74c3c;
}

.home-grid-item:active {
  background: #f0f0f0;
}

.home-grid-item img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.home-grid-item span {
  font-size: 12px;
  color: #333;
  margin-top: 4px;
  text-align: center;
}

/* 示意图区域 */
.diagram-area {
  text-align: center;
  padding: 12px;
  background: #fff;
}

.diagram-area img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
}

/* 表单行 */
.form-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid #eee;
}

/* 表单标签 */
.form-label {
  flex: 0 0 auto;
  min-width: 80px;
  font-size: 14px;
  color: #333;
}

/* 表单输入包裹 */
.form-input-wrap {
  flex: 1;
}

/* 分组标题 */
.group-title {
  background: #F7F7F7;
  padding: 8px 16px;
  font-size: 13px;
  color: #888;
  border-bottom: 1px solid #eee;
}

/* 圆弧接点网格（每行3列） */
.arc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: #eee;
  border-top: 1px solid #eee;
}

.arc-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  background: #fff;
  cursor: pointer;
  gap: 4px;
}

.arc-grid-item:active {
  background: #f5f5f5;
}

.arc-grid-item img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.arc-grid-item span {
  font-size: 11px;
  color: #333;
  text-align: center;
  line-height: 1.3;
}

/* 错误提示 */
.error-tip {
  color: #e74c3c;
  font-size: 13px;
  padding: 8px 16px;
}

/* 结果行 */
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}

.result-label {
  color: #666;
}

.result-value {
  color: #333;
  font-weight: 500;
}

/* 螺纹对照表 */
.thread-cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}

.thread-cmp-table th,
.thread-cmp-table td {
  border: 1px solid #ccc;
  text-align: center;
  padding: 4px 2px;
  line-height: 1.3;
  word-break: break-all;
}

.thread-cmp-table thead th {
  background: #f0f0f0;
  font-weight: 600;
}

.tct-group-left {
  background: #e8e8e8 !important;
}

.tct-group-right {
  background: #e8e8e8 !important;
}

.tct-sub {
  background: #f5f5f5 !important;
  font-size: 10px;
}

.tct-red {
  color: #e74c3c;
}

.tct-alt {
  background: #fafafa;
}

.tct-metric {
  font-weight: 500;
}

.tct-usnom {
  color: #e74c3c;
}

/* 三角函数表 */
.trig-page {
  background: #f0f0f0;
  min-height: 100vh;
  padding: 68px 24px 24px;
}

.trig-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.trig-label {
  font-size: 15px;
  color: #333;
  flex: 0 0 auto;
}

.trig-input {
  width: 160px;
  height: 40px;
  border: none;
  border-radius: 6px;
  background: #fff;
  text-align: center;
  font-size: 16px;
  color: #333;
  outline: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.trig-tip {
  color: #e74c3c;
  font-size: 14px;
  text-align: center;
  margin: 8px 0 24px;
}

.trig-btn-row {
  display: flex;
  gap: 16px;
}

.trig-btn {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: #e0e0e0;
  font-size: 16px;
  color: #333;
  cursor: pointer;
}

.trig-btn:active {
  background: #d0d0d0;
}

/* ── 材料重量页面 ── */
.mat-page {
  background: #f7f7f7;
}

.mat-top-row,
.mat-shape-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  gap: 8px;
}

.mat-field-label {
  font-size: 14px;
  color: #333;
  white-space: nowrap;
}

.mat-select {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  background: #fff;
  outline: none;
  min-width: 0;
  flex: 1;
  max-width: 200px;
}

.mat-density-label {
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.mat-density-input {
  width: 60px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 14px;
  text-align: center;
  outline: none;
}

.mat-density-input:focus {
  border-color: #2c3e50;
}

.mat-diagram {
  text-align: center;
  padding: 16px;
  background: #fff;
  margin-bottom: 8px;
}

.mat-diagram img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
}

.mat-fields {
  background: #fff;
}

.mat-input-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  gap: 8px;
}

.mat-input-label {
  font-size: 14px;
  color: #333;
  min-width: 72px;
  flex-shrink: 0;
}

.mat-num-input {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 14px;
  width: 90px;
  outline: none;
  text-align: center;
}

.mat-num-input:focus {
  border-color: #2c3e50;
}

.mat-unit-select {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 7px 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
  flex: 1;
  min-width: 0;
}

.mat-btn-wrap {
  padding: 16px;
  background: #fff;
  margin-top: 8px;
}

.mat-calc-btn {
  width: 100%;
  height: 44px;
  background: #1abc9c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  letter-spacing: 2px;
}

.mat-calc-btn:active {
  opacity: 0.85;
}

.mat-result {
  margin: 8px 16px;
  background: #fff;
  border-radius: 6px;
  padding: 12px 16px;
  border: 1px solid #eee;
}

.mat-result-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 15px;
  border-bottom: 1px solid #f0f0f0;
}

.mat-result-row:last-child {
  border-bottom: none;
}

.mat-result-label {
  color: #666;
}

.mat-result-value {
  color: #333;
  font-weight: 600;
}

.mat-result-err {
  color: #e74c3c;
  font-size: 13px;
}

.mat-hint {
  text-align: center;
  font-size: 13px;
  color: #888;
  padding: 8px 0 4px;
  background: #fff;
}

.mat-ibeam-spec {
  text-align: center;
  font-size: 14px;
  color: #333;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  line-height: 1.8;
}
