:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-grad: linear-gradient(135deg, #3b82f6, #2563eb);
  --bg: #f6f8fc;
  --card: #ffffff;
  --text: #17233d;
  --muted: #7a869a;
  --border: #e8edf5;
  --accent: #f0f6ff;
  --shadow: 0 2px 12px rgba(37, 99, 235, .06);
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ===== 两栏布局：侧边栏 + 内容区 ===== */
.layout { display: flex; height: 100vh; max-width: 1320px; margin: 0 auto; gap: 18px; padding: 14px 18px; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo {
  font-size: 26px; width: 46px; height: 46px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-grad); border-radius: 14px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}
.side-brand h1 {
  font-size: 19px; font-weight: 800; letter-spacing: .3px;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.side-brand p { font-size: 11.5px; color: var(--muted); }
.nav-scroll { flex: 1 1 auto; overflow-y: auto; padding: 10px; }
.nav-item {
  display: block; padding: 10px 14px; border-radius: 10px;
  color: var(--text); font-size: 13.5px; cursor: pointer;
  user-select: none; transition: all .18s; margin-bottom: 2px;
}
.nav-item:hover { background: var(--accent); color: var(--primary); transform: translateX(3px); }
.nav-item.active { background: var(--primary-grad); color: #fff; font-weight: 600; box-shadow: 0 4px 10px rgba(37, 99, 235, .28); }
.side-admin {
  display: block; margin: 8px 12px; padding: 9px 14px; flex-shrink: 0;
  text-align: center; font-size: 13px; color: var(--muted);
  text-decoration: none; border: 1px dashed var(--border); border-radius: 10px;
  transition: all .15s;
}
.side-admin:hover { color: var(--primary); border-color: var(--primary); }

/* ===== 内容区 ===== */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tool { display: none; }
.tool.active { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
.tool h2 { font-size: 22px; font-weight: 800; margin-bottom: 3px; letter-spacing: .3px; flex: 0 0 auto; }
.tool .desc { color: var(--muted); font-size: 13px; margin-bottom: 10px; max-width: 820px; flex: 0 0 auto; }
.tool h3 { font-size: 15px; margin: 4px 0 10px; font-weight: 700; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--border);
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 22px; overflow: hidden;
}
.card-inputs { overflow-y: auto; padding-right: 8px; }
.card-outputs {
  overflow-y: auto; border-left: 1px solid var(--border); padding-left: 22px; min-width: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.card.single { display: block; overflow-y: auto; }
.card hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ===== 表单 ===== */
.form-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 150px; flex: 1; }
.field.grow { flex: 2; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field input, .field select {
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; background: #fbfcfe; color: var(--text); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); background: #fff;
}
.field input[type="range"] { padding: 0; accent-color: var(--primary); background: transparent; border: none; }
.field input[type="color"] { padding: 3px; height: 42px; cursor: pointer; }
.field.checks { flex-direction: row; align-items: center; gap: 16px; flex-wrap: wrap; }
.field.checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; font-weight: 500; }
.field.checks input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.hidden { display: none !important; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border: 1.5px solid var(--border); background: #fff;
  border-radius: 22px; font-size: 13px; cursor: pointer; color: var(--muted); font-weight: 500; transition: all .18s;
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active { background: var(--primary-grad); color: #fff; border-color: transparent; font-weight: 600; box-shadow: 0 3px 8px rgba(37, 99, 235, .25); }

/* ===== 结果展示：突出重点 ===== */
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 4px; }
.result-item {
  background: var(--accent); border-radius: 12px; padding: 12px 14px;
  border: 1px solid transparent; transition: transform .15s;
}
.result-item:hover { transform: translateY(-2px); }
.result-item .k { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.result-item .v { font-size: 19px; font-weight: 700; color: var(--primary-dark); word-break: break-all; line-height: 1.35; }
.result-item .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.result-item.highlight {
  background: var(--primary-grad); box-shadow: 0 6px 16px rgba(37, 99, 235, .32);
}
.result-item.highlight .k { color: rgba(255, 255, 255, .82); }
.result-item.highlight .v { color: #fff; font-size: 23px; font-weight: 800; }
.result-item.highlight .v small { color: rgba(255, 255, 255, .8); }

.note {
  font-size: 12px; color: var(--muted); margin-top: 12px;
  background: #fafbfd; border-left: 3px solid #c7d7f5;
  padding: 8px 12px; border-radius: 0 8px 8px 0;
}

.btn {
  background: var(--primary-grad); color: #fff; border: none;
  padding: 10px 22px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 4px 10px rgba(37, 99, 235, .25);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(37, 99, 235, .35); }
.btn.ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); box-shadow: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.card-outputs .result-grid, .card-outputs .output, .card-outputs .table-wrap,
.card-outputs .note, .card-outputs .actions { margin-top: 0; }
.output {
  background: #fafbfd; border: 1.5px dashed #d4dff0; border-radius: 12px;
  padding: 14px; font-size: 14px; min-height: 48px; word-break: break-all;
  white-space: pre-wrap; line-height: 1.9;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.output.big { font-size: 18px; font-weight: 700; color: var(--primary-dark); font-family: inherit; }

.rates summary { cursor: pointer; font-size: 13px; color: var(--primary); margin-bottom: 12px; font-weight: 600; }
.rates .field { min-width: 100px; }

.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { background: var(--accent); font-weight: 700; position: sticky; top: 0; }
tr:last-child td, tr:last-child th { border-bottom: none; }

/* ===== 亲戚称谓工具 ===== */
.rel-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.rel-btn {
  padding: 8px 16px; border: 1.5px solid var(--border); background: #fff;
  border-radius: 10px; font-size: 14px; cursor: pointer; color: var(--text); transition: all .15s;
}
.rel-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--accent); }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 8px 12px; background: #fafbfd; border: 1px dashed #d4dff0; border-radius: 10px; }
.chain-empty { color: var(--muted); font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--primary-grad);
  color: #fff; padding: 5px 10px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.chip .x { cursor: pointer; opacity: .8; font-weight: 700; }
.chip .x:hover { opacity: 1; }
.chain .arrow { color: var(--muted); font-weight: 700; }

/* ===== 签名转手写 ===== */
.sig-preview {
  background: repeating-conic-gradient(#f4f6fb 0% 25%, #fff 0% 50%) 50% / 22px 22px;
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; align-items: center; justify-content: center; min-height: 160px;
}
.sig-preview canvas { max-width: 100%; height: auto; }

/* ===== 广告位：与站点风格统一 ===== */
.ad-slot { display: none; position: relative; }
.ad-slot.has-ad { display: block; }
.ad-slot .ad-tag {
  position: absolute; top: 6px; right: 8px; font-size: 10px; color: #b7c3d6;
  background: rgba(255, 255, 255, .85); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 8px; pointer-events: none; z-index: 2; letter-spacing: 1px;
}
.ad-slot a { display: block; }
.ad-slot img { display: block; width: 100%; border-radius: 12px; }
.ad-inner { border-radius: 12px; overflow: hidden; }
.ad-top { flex-shrink: 0; margin-bottom: 12px; }
.ad-top .ad-inner { box-shadow: var(--shadow); border: 1px solid var(--border); }
.ad-side { flex-shrink: 0; margin: 4px 12px 10px; }
.ad-side .ad-inner { border: 1px solid var(--border); }
.ad-bottom { flex-shrink: 0; margin-top: 12px; }
.ad-bottom .ad-inner { box-shadow: var(--shadow); border: 1px solid var(--border); }
.ad-text {
  background: linear-gradient(135deg, #f0f6ff, #eef2ff);
  padding: 14px 18px; font-size: 13px; color: var(--text); border-radius: 12px;
}
.ad-text a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* ===== 移动端：回退为可滚动单栏 ===== */
@media (max-width: 800px) {
  body { overflow: auto; }
  .layout { flex-direction: column; height: auto; min-height: 0; padding: 12px; }
  .sidebar { width: 100%; height: auto; overflow: visible; }
  .nav-scroll { max-height: none; display: flex; flex-wrap: wrap; gap: 6px; }
  .nav-item { margin-bottom: 0; }
  .ad-side { margin: 8px 0; }
  .content { overflow: visible; }
  .tool.active { display: block; height: auto; }
  .card { display: block; overflow: visible; height: auto; }
  .card-outputs { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
}
