/* ========================================
   物理实验数据处理 - 共享样式
   ======================================== */
:root {
  --brand: #4CAF50;
  --brand-dark: #388E3C;
  --brand-text: #2E7D32;
  --brand-soft: #E8F5E9;
  --brand-line: #C8E6C9;
  --bg: #f5f7fa;
  --surface: #fff;
  --text: #333;
  --muted: #666;
  --line: #e0e0e0;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* 顶部导航栏 */
.navbar {
  background: #4CAF50;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.navbar .back-btn {
  color: #fff;
  font-size: 20px;
  text-decoration: none;
  margin-right: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}
.navbar .back-btn:active { background: rgba(255,255,255,.2); }
.navbar .nav-title { font-size: 17px; font-weight: 600; flex: 1; }

/* 页面容器 */
.page-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

/* 表单元素 */
.input-group {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.input-group label {
  font-size: 14px;
  color: #555;
  min-width: 80px;
  flex-shrink: 0;
}
.input-group input, input.form-input, textarea.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #fafafa;
  outline: none;
  transition: border-color .2s;
}
.input-group input:focus, input.form-input:focus, textarea.form-input:focus {
  border-color: #4CAF50;
  background: #fff;
}
textarea.form-input {
  resize: vertical;
  min-height: 80px;
  font-family: monospace;
  line-height: 1.5;
}

/* 按钮 */
.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  background: #4CAF50;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  margin-top: 12px;
}
.btn-primary:active { background: #388E3C; }
.btn-secondary {
  display: block;
  width: 100%;
  padding: 10px;
  background: #fff;
  color: #4CAF50;
  border: 1.5px solid #4CAF50;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  margin-top: 8px;
}
.btn-secondary:active { background: #E8F5E9; }

/* 结果区域 */
.result-box {
  background: #E8F5E9;
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.8;
  word-break: break-all;
}
.result-box.error {
  background: #FFEBEE;
  color: #c62828;
}
.result-label {
  font-weight: 600;
  color: #2E7D32;
}
.result-box.error .result-label {
  color: #c62828;
}

/* 数据表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
}
.data-table th, .data-table td {
  padding: 6px 4px;
  text-align: center;
  border: 1px solid #e0e0e0;
}
.data-table th {
  background: #E8F5E9;
  font-weight: 600;
  color: #2E7D32;
  font-size: 12px;
}
.data-table td input {
  width: 100%;
  border: none;
  text-align: center;
  font-size: 13px;
  padding: 4px 2px;
  background: transparent;
  outline: none;
}
.data-table td input:focus {
  background: #FFF9C4;
}

/* Canvas 容器 */
.canvas-wrap {
  width: 100%;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.canvas-wrap canvas {
  display: block;
  width: 100%;
}

/* 提示文字 */
.hint-text {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
  line-height: 1.5;
}

/* 分隔线 */
.divider {
  height: 1px;
  background: #eee;
  margin: 16px 0;
}

/* 开关/复选框 */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.toggle-row label { font-size: 14px; color: #555; }

/* 小数位数选择器 */
.decimal-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.decimal-selector label { font-size: 14px; color: #555; }
.decimal-selector select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

/* ========================================
   桌面端适配 (>=768px)
   ======================================== */
@media (min-width: 768px) {
  /* 页面容器加宽 */
  .page-container {
    max-width: 860px;
    padding: 24px 32px;
  }

  /* 导航栏 */
  .navbar {
    padding: 14px 32px;
  }
  .navbar .back-btn {
    font-size: 22px;
    padding: 6px 12px;
  }
  .navbar .back-btn:hover {
    background: rgba(255,255,255,.18);
  }
  .navbar .nav-title {
    font-size: 18px;
  }

  /* 卡片 */
  .card {
    padding: 20px 24px;
    border-radius: 14px;
  }
  .card-title {
    font-size: 16px;
  }

  /* 表单 */
  .input-group label {
    font-size: 15px;
    min-width: 100px;
  }
  .input-group input, input.form-input, textarea.form-input {
    font-size: 15px;
    padding: 10px 14px;
  }
  textarea.form-input {
    min-height: 100px;
  }

  /* 按钮 hover */
  .btn-primary {
    font-size: 16px;
    padding: 13px;
    transition: background .2s, transform .1s;
  }
  .btn-primary:hover { background: #43A047; }
  .btn-primary:active { background: #388E3C; transform: scale(0.98); }

  .btn-secondary {
    font-size: 15px;
    transition: all .2s;
  }
  .btn-secondary:hover {
    background: #E8F5E9;
    border-color: #388E3C;
  }

  /* 表格 */
  .data-table {
    font-size: 14px;
  }
  .data-table th {
    font-size: 13px;
    padding: 8px 6px;
  }
  .data-table th, .data-table td {
    padding: 8px 6px;
  }
  .data-table td input {
    font-size: 14px;
    padding: 6px 4px;
  }

  /* 结果区域 */
  .result-box {
    font-size: 15px;
    padding: 18px 20px;
    border-radius: 12px;
  }

  /* Canvas */
  .canvas-wrap {
    border-radius: 12px;
  }

  /* 提示文字 */
  .hint-text {
    font-size: 13px;
  }

  /* 选择器 */
  .decimal-selector select {
    font-size: 15px;
    padding: 8px 12px;
  }
}

/* 大屏进一步优化 (>=1200px) */
@media (min-width: 1200px) {
  .page-container {
    max-width: 960px;
  }
}

/* ========================================
   统一交互组件
   ======================================== */

/* 导航栏右侧快捷操作（复制结果 / 打印 / 清除草稿） */
.navbar .nav-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
}
.navbar .nav-action {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  opacity: .9;
  transition: background .15s, opacity .15s;
}
.navbar .nav-action:hover { background: rgba(255,255,255,.18); opacity: 1; }
.navbar .nav-action:active { background: rgba(255,255,255,.28); }
.navbar .nav-action svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 统一 Toast（由 common.js 注入，避免各页样式冲突） */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(8px);
  max-width: 82vw;
  padding: 10px 20px;
  border-radius: 22px;
  background: rgba(33,33,33,.9);
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 平均值符号：上横线 */
.avg { text-decoration: overline; }

/* 键盘焦点可见 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
}

/* 宽表格横向滚动容器 */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 打印：只保留内容与结果 */
@media print {
  .navbar,
  .nav-actions,
  .app-toast,
  .btn-primary,
  .btn-secondary,
  .btn-calc,
  .btn-reset,
  .tab-bar {
    display: none !important;
  }
  body { background: #fff; }
  .card,
  .result-card,
  .result-box {
    box-shadow: none !important;
    border: 1px solid #ddd;
  }
}
