/* ============================================================
   明日方舟小工具 · 公招计算器
   ============================================================ */

:root {
  --accent: #8b7bff;
  --accent-2: #59a5ff;
  --accent-3: #5eead4;
  --bg: #08070f;
  --text: #eef0f8;
  --muted: rgba(238, 240, 248, 0.64);
  --faint: rgba(238, 240, 248, 0.38);
  --glass: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.06);
  --radius: 24px;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", "Noto Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --star6: #ffb45e;
  --star5: #ffd166;
  --star4: #b9a6ff;
  --star3: #86909f;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; }

::selection { background: rgba(139, 123, 255, 0.32); }

/* ---------------------------- 背景 ---------------------------- */

.bg-layer { position: fixed; inset: 0; z-index: -3; overflow: hidden; background: #08070f; }

.bg-layer::before {
  content: "";
  position: absolute; inset: -14%;
  background:
    radial-gradient(38% 34% at 20% 16%, rgba(139, 123, 255, 0.5), transparent 68%),
    radial-gradient(32% 30% at 82% 12%, rgba(89, 165, 255, 0.42), transparent 70%),
    radial-gradient(38% 34% at 70% 88%, rgba(94, 234, 212, 0.18), transparent 70%),
    radial-gradient(34% 32% at 10% 82%, rgba(255, 122, 162, 0.16), transparent 70%);
  filter: blur(30px);
  animation: drift 30s ease-in-out infinite alternate;
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(2%, -1.6%, 0) scale(1.05); }
}

.bg-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8, 7, 15, 0.5), rgba(8, 7, 15, 0.72) 55%, rgba(8, 7, 15, 0.94));
}

.bg-grain {
  position: absolute; inset: 0; opacity: 0.32; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.32'/%3E%3C/svg%3E");
}

/* ---------------------------- 顶栏 ---------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(16px, 4vw, 34px);
  background: linear-gradient(180deg, rgba(10, 9, 18, 0.82), rgba(10, 9, 18, 0.46));
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 11px; font-weight: 600; min-width: 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 11px; overflow: hidden; flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-text {
  font-family: var(--serif); font-size: 16px; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.back-link {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--muted); padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.04);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.back-link:hover { color: #fff; background: rgba(255, 255, 255, 0.09); border-color: var(--line); }
.back-link svg { width: 14px; height: 14px; }

/* ---------------------------- 布局 ---------------------------- */

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px) 60px; }

.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(26px) saturate(1.3);
  -webkit-backdrop-filter: blur(26px) saturate(1.3);
  box-shadow: 0 30px 70px -44px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.intro { padding: 34px 0 20px; }
.intro h1 {
  font-family: var(--serif); font-size: clamp(26px, 4vw, 38px); font-weight: 600;
  margin: 0 0 10px; letter-spacing: -0.01em;
}
.intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; max-width: 60ch; }
.intro strong { color: #d9d4ff; font-weight: 600; }

/* ---------------------------- 选标签 ---------------------------- */

.picker { padding: 22px clamp(16px, 3vw, 26px) 18px; }

.slots { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }

.slot {
  height: 44px; border-radius: 13px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.02);
  display: grid; place-items: center;
  font-size: 12.5px; color: var(--faint);
  transition: all 0.22s;
  overflow: hidden;
}
.slot.filled {
  border-style: solid; border-color: rgba(139, 123, 255, 0.55);
  background: linear-gradient(150deg, rgba(139, 123, 255, 0.26), rgba(89, 165, 255, 0.12));
  color: #f0efff; font-weight: 500;
  box-shadow: 0 8px 22px -14px rgba(139, 123, 255, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  cursor: pointer;
}
.slot.filled:hover { border-color: rgba(255, 130, 130, 0.6); color: #ffd7d7; }
.slot .x { font-size: 11px; opacity: 0.55; margin-left: 4px; }

.tag-groups { display: flex; flex-direction: column; gap: 14px; }

.tg-row { display: flex; gap: 12px; align-items: flex-start; }
.tg-name {
  flex: 0 0 auto; width: 42px; padding-top: 7px;
  font-size: 11px; letter-spacing: 0.16em; color: var(--faint);
}
.tg-tags { display: flex; flex-wrap: wrap; gap: 7px; flex: 1; min-width: 0; }

.tag {
  padding: 7px 13px; border-radius: 10px; font-size: 12.5px;
  border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.035);
  color: rgba(238, 240, 248, 0.8); cursor: pointer;
  transition: transform 0.16s, background 0.2s, border-color 0.2s, color 0.2s;
}
.tag:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--line); color: #fff; transform: translateY(-1px); }
.tag.on {
  background: linear-gradient(150deg, rgba(139, 123, 255, 0.32), rgba(89, 165, 255, 0.16));
  border-color: rgba(139, 123, 255, 0.62); color: #fff;
  box-shadow: 0 10px 24px -16px rgba(139, 123, 255, 1);
}
.tag.senior { border-color: rgba(255, 209, 102, 0.28); color: #ffe6a8; }
.tag.senior.on { background: linear-gradient(150deg, rgba(255, 209, 102, 0.3), rgba(255, 157, 122, 0.16)); border-color: rgba(255, 209, 102, 0.7); }
.tag.top { border-color: rgba(255, 180, 94, 0.34); color: #ffcf9b; }
.tag.top.on { background: linear-gradient(150deg, rgba(255, 180, 94, 0.34), rgba(255, 120, 120, 0.14)); border-color: rgba(255, 180, 94, 0.8); }

.picker-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line-soft);
}
.picked-hint { font-size: 12px; color: var(--faint); }
.picker-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--text);
  font-size: 12.5px; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.11); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }

/* ---------------------------- 结果 ---------------------------- */

.results { margin-top: 26px; }

.results-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.results-head h2 { font-family: var(--serif); font-size: 20px; margin: 0 0 5px; font-weight: 600; }
.results-head .sub { margin: 0; font-size: 12.5px; color: var(--faint); }

.seg {
  display: inline-flex; padding: 3px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.035);
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 13px; border-radius: 999px; font-size: 12px; cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.seg button.on { background: rgba(139, 123, 255, 0.28); color: #fff; }

.combo-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.combo {
  padding: 16px 18px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 12px;
  animation: pop 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.combo.hi6 { border-color: rgba(255, 180, 94, 0.42); background: linear-gradient(160deg, rgba(255, 180, 94, 0.12), rgba(255, 255, 255, 0.03)); }
.combo.hi5 { border-color: rgba(255, 209, 102, 0.28); background: linear-gradient(160deg, rgba(255, 209, 102, 0.08), rgba(255, 255, 255, 0.03)); }

.combo-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ctag {
  padding: 3px 9px; border-radius: 7px; font-size: 11.5px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e6e6f5;
}
.ctag.sep { background: none; border: 0; color: var(--faint); padding: 0 1px; }

.combo-body { display: flex; align-items: flex-start; gap: 10px; }
.star {
  flex: 0 0 auto; min-width: 42px; height: 24px; padding: 0 8px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.star.r6 { background: linear-gradient(140deg, rgba(255, 180, 94, 0.9), rgba(255, 120, 60, 0.75)); color: #2a1400; }
.star.r5 { background: linear-gradient(140deg, rgba(255, 209, 102, 0.9), rgba(255, 180, 60, 0.7)); color: #2a1c00; }
.star.r4 { background: linear-gradient(140deg, rgba(185, 166, 255, 0.85), rgba(139, 123, 255, 0.65)); color: #130c2a; }
.star.r3 { background: rgba(255, 255, 255, 0.1); color: var(--muted); }

.ops { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.op {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.055); border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(238, 240, 248, 0.92);
}
.op.r6 { color: #ffd9ac; border-color: rgba(255, 180, 94, 0.32); }
.op.r5 { color: #ffe9b3; border-color: rgba(255, 209, 102, 0.26); }
.op.more { color: var(--faint); background: none; border-style: dashed; }

.empty-state {
  grid-column: 1 / -1; padding: 40px 22px; text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.12); border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
}
.empty-state h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.empty-state p { margin: 0 auto; max-width: 46ch; color: var(--faint); font-size: 12.5px; line-height: 1.8; }

/* ---------------------------- 说明 / 页脚 ---------------------------- */

.notes { margin-top: 26px; padding: 22px clamp(16px, 3vw, 26px); }
.notes h3 { margin: 0 0 12px; font-size: 15px; font-family: var(--serif); }
.notes ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.notes li { color: var(--faint); font-size: 12.5px; line-height: 1.8; }
.notes b { color: #d9d4ff; font-weight: 600; }

.foot {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 20px 16px 30px; font-size: 12px; color: var(--faint);
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.foot a { color: var(--muted); }
.foot a:hover { color: #fff; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); }

.toast-wrap {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  background: rgba(22, 20, 34, 0.94); border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 40px -20px #000; backdrop-filter: blur(14px);
  animation: toastIn 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------------------- 手机 ---------------------------- */

@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .brand-text { font-size: 14.5px; max-width: 46vw; }
  .back-link { padding: 6px 10px; font-size: 12px; }
  .intro { padding: 22px 0 14px; }
  .intro h1 { font-size: 25px; }
  .intro p { font-size: 13px; line-height: 1.7; }

  .picker { padding: 16px 14px 14px; }
  .slots { gap: 6px; margin-bottom: 16px; }
  .slot { height: 40px; font-size: 11.5px; border-radius: 11px; }
  .tag-groups { gap: 12px; }
  .tg-row { gap: 8px; }
  .tg-name { width: 100%; padding: 0; font-size: 10.5px; letter-spacing: 0.1em; }
  .tg-row { flex-direction: column; }
  .tag { padding: 8px 12px; font-size: 12px; }
  .picker-bar { gap: 10px; }
  .picked-hint { width: 100%; }
  .picker-actions { margin-left: 0; width: 100%; }
  .picker-actions .btn { flex: 1; }

  .results { margin-top: 20px; }
  .results-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .combo-list { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .combo { padding: 14px; }
  .notes { padding: 18px 16px; }
  .toast-wrap { bottom: 18px; width: calc(100vw - 32px); }
  .toast { font-size: 12.5px; text-align: center; }
}

@media (max-width: 360px) {
  .slot { font-size: 10.5px; }
  .tag { padding: 7px 10px; font-size: 11.5px; }
}
