/* 名笺 · 宣纸 / 朱砂 / 宋体 */
:root {
  --paper: #f3eee2;
  --paper-deep: #e9e1cf;
  --paper-card: #fbf8f1;
  --ink: #1b1611;
  --ink-soft: #453c31;
  --muted: #7d705d;
  --line: rgba(27, 22, 17, 0.14);
  --line-strong: rgba(27, 22, 17, 0.3);
  --cinnabar: #a8382a;
  --cinnabar-deep: #86271c;
  --gold: #a8894f;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 8px 20px -16px rgba(27, 22, 17, 0.5);
  --shadow-lift: 0 18px 40px -28px rgba(27, 22, 17, 0.55);
  --radius: 4px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  background:
    radial-gradient(1100px 600px at 82% -10%, rgba(168, 56, 42, 0.07), transparent 60%),
    radial-gradient(900px 700px at -10% 20%, rgba(168, 137, 79, 0.1), transparent 55%),
    var(--paper);
  padding: 0 clamp(16px, 4vw, 48px) 96px;
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  z-index: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(27, 22, 17, 0.032) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(27, 22, 17, 0.022) 0 1px, transparent 1px 4px),
    radial-gradient(120% 90% at 20% 0%, rgba(255, 255, 255, 0.35), transparent 60%);
  mix-blend-mode: multiply;
}

/* ---------- 页头 ---------- */
.masthead {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 52px) 0 clamp(20px, 3vw, 32px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 18px; }

.seal {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  display: grid;
  grid-template-rows: 1fr 1fr;
  place-items: center;
  background: var(--cinnabar);
  color: #f7f1e4;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1;
  border-radius: 3px;
  box-shadow: 0 6px 16px -10px rgba(134, 39, 28, 0.9);
  transform: rotate(-2.5deg);
}

.seal span { display: block; }

.brand-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 3.6vw, 40px);
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.1;
}

.brand-text p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.stats {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-align: right;
  white-space: nowrap;
}
.stats b { color: var(--ink-soft); font-weight: 600; }

/* ---------- 主体 ---------- */
.workbench {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding-top: clamp(24px, 4vw, 40px);
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}

.panel { min-width: 0; }

.form-panel {
  background: linear-gradient(180deg, rgba(251, 248, 241, 0.92), rgba(247, 241, 230, 0.72));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px 20px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 20px;
}

.panel-head { margin-bottom: 20px; }

.eyebrow {
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--cinnabar);
  margin-bottom: 4px;
}

.panel h2,
.result-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.field { margin-bottom: 20px; }

.field-label,
label.field-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 8px;
  font-weight: 600;
}
.field-label em { font-style: normal; color: var(--muted); font-weight: 400; margin-left: 4px; }

.letter-wrap {
  display: flex;
  align-items: baseline;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 6px;
  gap: 10px;
}

.letter-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 0;
  outline: none;
}
.letter-input::placeholder { color: rgba(27, 22, 17, 0.22); }
.letter-input:focus { color: var(--cinnabar); }

.letter-suffix {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--cinnabar-deep);
  background: rgba(168, 56, 42, 0.07);
  border-left: 2px solid rgba(168, 56, 42, 0.5);
  padding: 8px 10px;
  border-radius: 0 3px 3px 0;
}

/* 姓氏候选 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-surname { margin-top: 10px; }

.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink-soft);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.chip:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.75); }
.chip.is-on {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
  background: rgba(168, 56, 42, 0.06);
  font-weight: 600;
}
.chip-sep {
  align-self: center;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--cinnabar);
  opacity: 0.75;
  padding: 0 2px;
}
.chip-new { border-style: dashed; }
.chip-new.is-on { border-style: solid; }

.chip .mini-tag {
  font-size: 9px;
  letter-spacing: 0.08em;
  margin-left: 3px;
  padding: 1px 3px;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: 0.72;
  vertical-align: 1px;
}

/* 分段控件 */
.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.35);
}
.seg {
  flex: 1;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 8px 0;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.seg:last-child { border-right: 0; }
.seg:hover { color: var(--ink); background: rgba(255, 255, 255, 0.5); }
.seg.is-on { background: var(--ink); color: #f6f1e6; }

.actions { display: flex; gap: 10px; margin-top: 24px; }

.btn {
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.08em;
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}
.btn.primary { flex: 1; background: var(--ink); color: #f7f2e7; }
.btn.primary:hover { background: var(--cinnabar); border-color: var(--cinnabar); transform: translateY(-1px); }
.btn.ghost { border-color: var(--line-strong); color: var(--ink-soft); }
.btn.ghost:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.small { padding: 7px 12px; font-size: 12px; flex: 1; }

.lore {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.lore-title {
  display: inline-block;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--cinnabar);
  margin-bottom: 8px;
}
.lore p {
  margin: 0 0 8px;
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--muted);
}
.lore b { color: var(--ink-soft); font-weight: 600; }

.form-foot {
  margin: 14px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- 结果区 ---------- */
.result-panel { padding-top: 2px; }

.result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.meta-tag {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.08em;
  border: 1px solid rgba(168, 56, 42, 0.5);
  color: var(--cinnabar);
  border-radius: 2px;
  padding: 0 3px;
  margin-left: 4px;
  vertical-align: 1px;
}

.result-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  line-height: 1.5;
}
.result-meta b { color: var(--ink-soft); }

.notice {
  border: 1px dashed rgba(168, 56, 42, 0.45);
  background: rgba(168, 56, 42, 0.05);
  color: var(--cinnabar-deep);
  font-size: 13px;
  line-height: 1.7;
  padding: 12px 14px;
  border-radius: 3px;
  margin-bottom: 18px;
}
.notice b { font-weight: 600; }

.empty {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(28px, 6vw, 56px) 24px;
  text-align: center;
  background: rgba(251, 248, 241, 0.5);
}
.empty-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 30px;
  color: var(--cinnabar);
}
.empty-title {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.08em;
}
.empty-sub { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.9; }
.empty-examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.example {
  border: 1px solid var(--line);
  background: transparent;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  padding: 5px 10px;
  border-radius: 2px;
  cursor: pointer;
}
.example:hover { border-color: var(--cinnabar); color: var(--cinnabar); }

.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 14px;
}

.name-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.72), rgba(250, 245, 234, 0.6));
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  opacity: 0;
  transform: translateY(8px);
  animation: rise 0.42s cubic-bezier(0.22, 0.68, 0.24, 1) forwards;
  animation-delay: calc(var(--i, 0) * 28ms);
}
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

.name-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.name-card.is-picked { border-color: var(--cinnabar); background: linear-gradient(170deg, rgba(255, 250, 240, 0.95), rgba(253, 240, 232, 0.8)); }

.card-hit {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 16px 16px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: block;
  border-radius: var(--radius);
}
.card-hit:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }

.name {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  white-space: nowrap;
}

.picker {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: transparent;
  flex: 0 0 22px;
  margin-top: 6px;
  transition: all 0.18s ease;
}
.name-card.is-picked .picker {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fdf6ea;
  transform: rotate(-4deg);
}

.py {
  font-size: 11.5px;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 4px;
  text-transform: lowercase;
}

.meter {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 10px 0 12px;
}
.meter i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.04em;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
}
.meter i.ping { border-color: rgba(63, 93, 82, 0.4); color: #3f5d52; }
.meter i.ze { border-color: rgba(168, 56, 42, 0.35); color: var(--cinnabar); }
.meter .score {
  margin-left: auto;
  width: auto;
  height: auto;
  border: 0;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.gloss {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 4px;
}
.gloss li {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  display: flex;
  gap: 7px;
}
.gloss b {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
  flex: 0 0 auto;
  font-weight: 600;
}
.gloss span { color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.tag {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
}

/* ---------- 已选托盘 ---------- */
.tray {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: 24px;
  width: 268px;
  z-index: 6;
  background: var(--paper-card);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 24px 50px -30px rgba(27, 22, 17, 0.7);
  padding: 14px;
  animation: rise 0.3s ease forwards;
}

.tray-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.tray-head b { color: var(--cinnabar); font-size: 15px; }
.tray-tools { display: flex; gap: 10px; }
.tray.is-collapsed .tray-list { display: none; }
.tray.is-collapsed .tray-actions { display: none; }
.tray.is-collapsed { padding: 10px 14px; }
.tray.is-collapsed .tray-head { border-bottom: 0; padding-bottom: 0; }
.tray-clear {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}
.tray-clear:hover { color: var(--cinnabar); }

.tray-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  max-height: 34vh;
  overflow: auto;
  display: grid;
  gap: 2px;
}
.tray-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px;
  border-bottom: 1px dotted var(--line);
}
.tray-list .tn {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.06em;
}
.tray-list .tp { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; margin-left: 8px; }
.tray-list button {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
}
.tray-list button:hover { color: var(--cinnabar); }

.tray-actions { display: flex; gap: 8px; }

/* ---------- 页脚 / 提示 ---------- */
.site-foot {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 56px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.site-foot b { color: var(--ink-soft); font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: #f7f2e7;
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 9px 18px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 20;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .result-head { flex-wrap: wrap; align-items: flex-start; }
  .result-meta { text-align: left; width: 100%; }
  .workbench { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .masthead { flex-direction: column; align-items: flex-start; gap: 12px; }
  .stats { text-align: left; }
  .tray { left: 12px; right: 12px; width: auto; bottom: 12px; }
  .tray-list { max-height: 22vh; }
  body { padding-bottom: 180px; }
}

@media (max-width: 520px) {
  .name-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .name { font-size: 23px; }
  .card-hit { padding: 12px 12px 10px; }
  .gloss li { font-size: 11px; }
  .tags { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
