* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --text: #222222;
  --muted: #666666;
  --faint: #999999;
  --border: #e8eefb;
  --border-strong: #b3c6ef;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --shadow: rgba(0,0,0,0.04);
  --header-grad: linear-gradient(135deg, #2563eb, #3b82f6);
}
[data-theme="dark"] {
  --bg: #16181c;
  --card: #23272d;
  --text: #e8e8e8;
  --muted: #b2b5ba;
  --faint: #8b8f96;
  --border: #2a313d;
  --border-strong: #3d4a66;
  --accent: #3b82f6;
  --accent-text: #ffffff;
  --shadow: rgba(0,0,0,0.35);
  --header-grad: linear-gradient(135deg, #1e40af, #2563eb);
}
body {
  font-family: -apple-system, "PingFang SC", "Segoe UI", "Microsoft YaHei", "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}
.container { width: 100%; max-width: 820px; padding: 0 20px; }

.site-header {
  width: 100%;
  background: var(--header-grad);
  border-bottom: 1px solid rgba(255,255,255,0.15);
  padding: 14px 0;
  position: sticky; top: 0; z-index: 10;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 auto; }
.back { color: #ffffff; text-decoration: none; font-size: 14px; }
.back:hover { text-decoration: underline; }
.controls { display: flex; gap: 8px; align-items: center; }
.controls button,
.controls select {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.controls select option { color: #222222; }

main.container { padding-top: 20px; padding-bottom: 40px; }

.crumbs { font-size: 13px; color: var(--faint); margin-bottom: 10px; }
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 700; margin-bottom: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px var(--shadow);
}

/* 转换器 */
.conv-grid { display: flex; align-items: flex-end; gap: 12px; }
.conv-field { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.conv-field label { flex: 0 0 100%; font-size: 13px; color: var(--muted); }
input, select {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.conv-field input { order: 1; flex: 1 1 0; min-width: 0; width: auto; font-size: 18px; }
.conv-field select { order: 2; flex: 0 1 auto; width: auto; max-width: 170px; }
.swap-btn {
  flex: none;
  width: 44px; height: 44px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  margin-bottom: 4px;
}
.swap-btn:hover { border-color: var(--accent); }
.rate { font-size: 13px; color: var(--faint); margin-top: 14px; text-align: center; }

/* 解释区 */
.explain-block { margin-bottom: 20px; }
.explain-block:last-child { margin-bottom: 0; }
.explain-block h2 { font-size: 16px; margin: 0 0 8px; }
.explain-block p { font-size: 14px; color: var(--muted); line-height: 1.7; margin-bottom: 6px; }
.explain-block .label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }

/* 相关换算器（纵向排列） */
.related h2 { font-size: 16px; margin-bottom: 14px; }
.links { display: flex; flex-direction: column; gap: 0; }
.links a {
  display: block;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}
.links a:hover { color: var(--accent); background: var(--bg); }

/* 响应式：移动端 */
@media (max-width: 640px) {
  .container { padding: 0 14px; }
  h1 { font-size: 19px; }
  .card { padding: 18px; }
  .conv-grid { flex-direction: column; align-items: stretch; }
  .swap-btn { align-self: center; transform: rotate(90deg); }
}
