:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --card: rgba(22, 26, 36, 0.86);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #eef1f6;
  --muted: #9aa4b5;
  --line: rgba(255, 255, 255, 0.11);
  --input: #11151d;
  --accent: #ffb454;
  --accent-2: #ff7a59;
  --accent-ink: #201306;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 18px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(255, 180, 84, 0.16), transparent 60%),
    radial-gradient(900px 460px at 92% 8%, rgba(255, 122, 89, 0.10), transparent 55%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.55;
}

[v-cloak] { display: none !important; }
[hidden] { display: none !important; }

#app {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px 18px calc(32px + env(safe-area-inset-bottom));
}

.site-shell {
  display: grid;
  grid-template-columns: minmax(0, 860px);
  gap: 18px;
  align-items: start;
  justify-content: center;
}

.site-main { min-width: 0; }
/* 没有接入广告时广告位带 hidden，不占位；接入后去掉 hidden 自动恢复三栏 */
.site-shell:has(.ad-rail:not([hidden])) {
  grid-template-columns: 160px minmax(0, 860px) 160px;
}

.ad-rail {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 160px;
  min-height: 600px;
  padding: 16px 10px;
  overflow: hidden;
  text-align: center;
  border: 1px dashed rgba(255, 180, 84, 0.28);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 180, 84, 0.045), rgba(255, 255, 255, 0.015));
  color: var(--muted);
}
.ad-rail .ad-label { font-size: 12px; color: rgba(255, 255, 255, 0.72); }
.ad-rail .ad-size { font-size: 11px; opacity: 0.7; }
.ad-rail img { display: block; max-width: 100%; height: auto; }

.preload-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}
.preload-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7ee0a6;
  box-shadow: 0 0 8px rgba(126, 224, 166, 0.55);
}
.preload-warn { color: #ffb454; }

.hero { padding: 12px 4px 22px; }

/* 广告位：预留固定高度，避免加载广告后页面跳动 */
.ad-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 0 auto;
  padding: 10px;
  overflow: hidden;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.022);
  color: var(--muted);
}
.ad-slot-top { margin-bottom: 16px; }
.ad-label { font-size: 11px; font-weight: 700; letter-spacing: 0.18em; }
.ad-size { font-size: 10.5px; letter-spacing: 0.08em; opacity: 0.65; }
.ad-mobile { display: none; }
.ad-slot img { display: block; max-width: 100%; height: auto; }
@media (max-width: 1100px) {
  .site-shell { display: block; }
  .ad-rail { display: none; }
}
@media (min-width: 1101px) {
  .ad-slot-top, .ad-slot-inline, .ad-slot-bottom { display: none; }
}
@media (max-width: 560px) {
  .ad-slot { max-width: 320px; min-height: 100px; }
  .ad-desktop { display: none; }
  .ad-mobile { display: inline; }
}


.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 8px;
  font-size: clamp(30px, 7vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.sub { margin: 0; max-width: 56ch; color: var(--muted); font-size: 15px; }

main { display: grid; gap: 16px; }

.card {
  border: 1px solid var(--card-border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.space { justify-content: space-between; }
.row.gap { margin: 12px 0 14px; }

h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint.warn { color: #ffd58a; }
.hint.ok { color: var(--ok); }
.hint.concurrency-note { color: #b7c4d8; }
.pool-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pool-line a { color: var(--accent-2); text-decoration: none; border-bottom: 1px dotted currentColor; }
.hint { margin: 8px 0 12px; color: var(--muted); font-size: 13px; }
.error { margin: 10px 0 0; color: var(--bad); font-size: 13px; }

.regions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 12px; }

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s ease;
}
.chip:hover { border-color: rgba(255, 180, 84, 0.45); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

select, input {
  appearance: none;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 34px 11px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  outline: none;
}
select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select:focus-visible, input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid rgba(255, 180, 84, 0.8);
  outline-offset: 2px;
}
select:disabled { opacity: 0.55; }

.rolls { display: grid; gap: 9px; }

.roll {
  display: grid;
  grid-template-columns: 18px 32px minmax(92px, 0.9fr) minmax(0, 2fr) 34px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 14px;
}

.drag-handle {
  display: grid;
  place-items: center;
  width: 18px;
  height: 34px;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; color: var(--accent); }
.roll.dragging { opacity: 0.55; border-color: rgba(255, 180, 84, 0.55); }
.roll.drag-over { border-color: rgba(255, 180, 84, 0.8); background: rgba(255, 180, 84, 0.06); }

.idx {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(255, 180, 84, 0.13);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.roll select { padding-top: 9px; padding-bottom: 9px; font-size: 13.5px; }
.roll select.unit { padding-right: 30px; }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  transition: 0.18s ease;
}
button:disabled { cursor: not-allowed; opacity: 0.5; }

.primary {
  width: 100%;
  margin-top: 6px;
  padding: 14px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 26px rgba(255, 140, 70, 0.2);
}
.primary:not(:disabled):hover { transform: translateY(-1px); }

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}
.ghost:not(:disabled):hover { border-color: rgba(255, 180, 84, 0.45); }
.ghost.small { padding: 7px 11px; font-size: 12.5px; }

.icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.icon:not(:disabled):hover { color: var(--bad); background: rgba(251, 113, 133, 0.08); }

.badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.queued { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }
.badge.running { color: var(--accent); border-color: rgba(255, 180, 84, 0.4); }
.badge.done { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); }
.badge.failed { color: var(--bad); border-color: rgba(251, 113, 133, 0.4); }

.progress {
  height: 10px;
  margin: 14px 0 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}
.bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s ease;
}

.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.result:first-of-type { border-top: 0; }

.seed {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 7px 4px;
}
.link:hover { text-decoration: underline; }

footer {
  padding: 22px 4px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 560px) {
  #app { padding: 16px 12px 26px; }
  .card { padding: 15px; border-radius: 16px; }
  .roll {
    grid-template-columns: 18px 28px minmax(0, 1fr) 32px;
    grid-template-areas:
      "drag idx rarity del"
      "drag idx unit del";
    row-gap: 6px;
  }
  .drag-handle { grid-area: drag; align-self: stretch; height: auto; }
  .idx { grid-area: idx; }
  .roll select:not(.unit) { grid-area: rarity; }
  .roll .unit-pick { grid-area: unit; }
  .roll .icon { grid-area: del; align-self: start; }
  .result { align-items: flex-start; }
  .seed { font-size: 18px; }
}

.seed-card { border-color: rgba(255, 180, 84, 0.22); }
.seed-big {
  margin: 14px 0 4px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin-top: 0;
  padding: 11px 16px;
  text-decoration: none;
  font-size: 13.5px;
}
.seed-card .ghost { margin-top: 14px; }

/* ---------- 猫咪头像选择 ---------- */
.unit-pick {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  width: 100%;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  border-radius: 12px;
  text-align: left;
}
.unit-pick:hover { border-color: rgba(255, 180, 84, 0.45); }
.unit-pick .thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
}
.unit-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
}
.chev { margin-left: auto; color: var(--muted); font-size: 11px; }

.picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5, 7, 11, 0.74);
  backdrop-filter: blur(8px);
}
.picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(920px, 100%);
  max-height: min(92vh, 920px);
  padding: 16px 14px calc(12px + env(safe-area-inset-bottom));
  border: 1px solid var(--card-border);
  border-radius: 22px 22px 0 0;
  background: #121722;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}
.picker-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.picker-head h2 { font-size: 18px; }
.picker-head p { margin: 2px 0 0; }
.picker-close { flex: 0 0 auto; font-size: 22px; }
.picker-search { padding: 11px 12px; flex: 0 0 auto; }
.picker-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.picker-tabs::-webkit-scrollbar { display: none; }
.picker-tabs .chip { flex: 0 0 auto; padding: 7px 11px; font-size: 12px; }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 10px;
}
.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 8px 7px 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  text-align: center;
}
.cat-card:hover, .cat-card:focus-visible { border-color: rgba(255, 180, 84, 0.6); background: rgba(255, 180, 84, 0.06); }
.cat-card img {
  width: 100%;
  height: 62px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}
.cat-name {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}
.cat-meta { color: var(--muted); font-size: 10.5px; }
.picker-empty { grid-column: 1 / -1; margin: 24px 6px; color: var(--muted); font-size: 13px; text-align: center; }

@media (min-width: 640px) {
  .picker-backdrop { align-items: center; padding: 24px; }
  .picker { border-radius: 22px; padding: 18px; }
}
@media (max-width: 560px) {
  .roll .unit-pick { grid-area: unit; }
  .unit-pick .thumb { width: 38px; height: 38px; }
  .picker { padding-left: 11px; padding-right: 11px; }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .cat-card img { height: 50px; }
  .cat-name { font-size: 11.5px; }
}
