/* ============================================================
 *  板材/型材重量查询工具 — 样式
 *  设计：移动优先 · 大字号 · 大按钮 · 玻璃拟态 · 亮/暗主题
 * ============================================================ */

:root {
  --bg: #eef2f7;
  --bg-grad-1: #e8eef6;
  --bg-grad-2: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --border: rgba(20, 40, 70, 0.10);
  --border-strong: rgba(20, 40, 70, 0.18);
  --text: #16202e;
  --text-soft: #4a5870;
  --text-mute: #7c8aa0;
  --primary: #1666c9;
  --primary-soft: #e3eefb;
  --accent: #f59e0b;
  --accent-soft: #fdeccb;
  --danger: #e0413b;
  --ok: #1f9d57;
  --shadow: 0 8px 30px rgba(20, 40, 70, 0.10);
  --shadow-lg: 0 18px 50px rgba(20, 40, 70, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 52px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui,
    -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #0e131b;
  --bg-grad-1: #0e131b;
  --bg-grad-2: #141b26;
  --surface: rgba(28, 36, 49, 0.66);
  --surface-solid: #1a2230;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);
  --text: #eef3fa;
  --text-soft: #b3c0d3;
  --text-mute: #8090a8;
  --primary: #4a9eff;
  --primary-soft: #16263c;
  --accent: #f7a823;
  --accent-soft: #2e2410;
  --danger: #ff6b66;
  --ok: #43c97a;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--bg-grad-2), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, var(--bg-grad-1), transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.3px;
}
.brand .logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 18px;
  box-shadow: var(--shadow);
}
.brand small { display:block; font-weight:500; font-size:11px; color:var(--text-mute); }

.theme-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.15s ease, background 0.2s ease;
}
.theme-btn:active { transform: scale(0.92); }

/* ---------- 主容器 ---------- */
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

/* 首页标题区 */
.hero {
  text-align: center;
  padding: 14px 6px 6px;
}
.hero h1 { font-size: 24px; margin: 0 0 6px; font-weight: 800; }
.hero p { margin: 0; color: var(--text-soft); font-size: 14px; }

/* ---------- 分类网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px 14px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s ease, border-color 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, var(--primary-soft));
  opacity: 0; transition: opacity 0.25s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card:hover::before { opacity: 0.5; }
.card:active { transform: scale(0.97); }

.card .icon {
  width: 76px; height: 76px;
  margin: 0 auto 8px;
  color: var(--primary);
  display: grid; place-items: center;
}
.card .icon svg { width: 100%; height: 100%; }
.card .name { font-weight: 700; font-size: 16px; color: var(--text); }
.card .desc { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* ---------- 详情视图 ---------- */
.detail { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.back {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-soft);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  min-height: var(--tap);
}
.back:active { transform: scale(0.96); }

.detail-head {
  display: flex; align-items: center; gap: 14px;
  margin: 16px 0 6px;
}
.detail-head .pic {
  width: 92px; height: 92px; flex: none;
  color: var(--primary);
}
.detail-head .pic svg { width: 100%; height: 100%; }
.detail-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.detail-head .sub { color: var(--text-mute); font-size: 13px; }

/* 画布卡片 */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-top: 14px;
}

/* SVG 形状线型 */
.shape { width: 100%; height: auto; color: var(--primary); }
.shape rect, .shape circle, .shape polygon, .shape path {
  fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linejoin: round; stroke-linecap: round;
}
.shape .dim { stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 4 3; }
.shape .dlabel { fill: var(--text-soft); font-size: 12px; font-weight: 700; font-family: var(--font); }

/* 输入框 */
.field { margin-bottom: 14px; }
.field label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; font-weight: 600; color: var(--text-soft);
  margin-bottom: 6px;
}
.field label .unit { font-size: 12px; color: var(--text-mute); font-weight: 500; }
.field input, .field select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-solid);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  appearance: none;
}
.field input:focus, .field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.field input::placeholder { color: var(--text-mute); font-weight: 500; }

/* 材质选择条 */
.seg {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.seg button {
  flex: 1 1 auto;
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text-soft);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}
.seg button.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

/* 大按钮 */
.btn-primary {
  width: 100%;
  min-height: 60px;
  margin-top: 6px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #0f4fa0);
  color: #fff;
  font-size: 20px; font-weight: 800; letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(22, 102, 201, 0.35);
  transition: transform 0.16s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s ease;
}
.btn-primary:active { transform: scale(0.975); box-shadow: 0 6px 16px rgba(22,102,201,0.30); }

/* 结果区 */
.result {
  margin-top: 16px;
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px 18px;
  text-align: center;
  display: none;
}
.result.show { display: block; animation: pop 0.3s cubic-bezier(0.16,1,0.3,1); }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.result .lbl { font-size: 13px; color: var(--text-soft); }
.result .val {
  font-size: 42px; font-weight: 900; color: var(--primary);
  line-height: 1.1; margin: 4px 0;
}
[data-theme="dark"] .result .val { color: var(--accent); }
.result .val small { font-size: 18px; font-weight: 700; color: var(--text-soft); margin-left: 4px; }
.result .sub-val { font-size: 14px; color: var(--text-soft); margin-top: 4px; }
.result .sub-val b { color: var(--text); }

.err {
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px; font-weight: 600;
  text-align: center;
  display: none;
}
.err.show { display: block; }

/* 最近记录 */
.history { margin-top: 22px; }
.history h3 { font-size: 15px; color: var(--text-soft); margin: 0 0 10px; display:flex; align-items:center; gap:8px; }
.history .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; font-size: 14px;
}
.history .row .meta { color: var(--text-soft); }
.history .row .w { font-weight: 800; color: var(--primary); }
[data-theme="dark"] .history .row .w { color: var(--accent); }
.history .empty { color: var(--text-mute); font-size: 13px; text-align:center; padding: 10px; }
.history .clear { background:none; border:none; color:var(--danger); font-size:13px; cursor:pointer; font-weight:600; }

/* 底部 */
.foot { text-align: center; color: var(--text-mute); font-size: 12px; margin-top: 30px; line-height: 1.7; }

/* 实时提示 */
.live-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
  background: var(--primary-soft);
  border-radius: 10px;
  padding: 9px;
  margin-bottom: 4px;
}

/* 复制提示 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 12px 22px; border-radius: 12px; font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
