:root {
  --pink: #ff6b9d;
  --pink-soft: #ffd6e7;
  --pink-light: #ffb3d1;
  --purple: #9b59ff;
  --purple-dark: #6c3ce0;
  --card: rgba(255, 255, 255, 0.92);
  --shadow: 0 8px 28px rgba(108, 60, 224, 0.08);
  --shadow-hover: 0 14px 36px rgba(108, 60, 224, 0.14);
  --text: #3d2c4a;
  --muted: #8a7a96;
  --line: rgba(255, 179, 209, 0.65);
  --radius: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --rail: 252px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 8% -8%, rgba(255, 182, 209, 0.55), transparent 60%),
    radial-gradient(700px 420px at 92% 0%, rgba(196, 168, 255, 0.45), transparent 55%),
    radial-gradient(640px 380px at 70% 100%, rgba(160, 220, 255, 0.35), transparent 50%),
    linear-gradient(160deg, #fff7fb 0%, #eef6ff 48%, #f5efff 100%);
}

a { color: var(--purple); text-decoration: none; }

/* —— App shell: no page scroll —— */
.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0.9rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  min-height: 0;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}
.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  background: linear-gradient(145deg, #fff0f6, #efe6ff);
  border: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
}
.rail-brand .brand-avatar,
.rail-brand .avatar-ring.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  padding: 2px;
}
.rail-brand .brand-avatar img,
.rail-brand .brand-avatar .ph,
.rail-brand .avatar-ring.logo-mark img,
.rail-brand .avatar-ring.logo-mark .ph {
  border-radius: 10px;
}
.rail-brand h1 {
  font-family: "Ma Shan Zheng", cursive;
  font-size: 1.35rem;
  line-height: 1.15;
  background: linear-gradient(100deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11.5rem;
}
.rail-brand p {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}
.rail-meta {
  flex-wrap: wrap;
  white-space: normal;
  overflow: visible;
}
.rail-block .tags {
  margin-top: 0.15rem;
}

.rail-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex-shrink: 0;
}

.nav-pill {
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--pink-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--purple-dark);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s var(--ease);
}
.nav-pill:hover {
  border-color: var(--purple);
  box-shadow: 0 4px 12px rgba(155, 89, 255, 0.12);
  transform: translateY(-1px);
}

.rail-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.rail-actions {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.rail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--purple-dark);
  letter-spacing: 0.04em;
}

.rail input,
.rail select {
  width: 100%;
  padding: 0.58rem 0.9rem;
  border: 1.5px solid var(--pink-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  font: inherit;
  font-size: 0.84rem;
  outline: none;
  color: var(--text);
}
.rail input:focus,
.rail select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(155, 89, 255, 0.12);
}

button, .btn {
  padding: 0.5rem 0.95rem;
  border: 1.5px solid var(--pink-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--purple-dark);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s, background 0.2s;
}
button:hover:not(:disabled),
.btn:hover:not(:disabled) {
  border-color: var(--purple);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(155, 89, 255, 0.12);
}
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  box-shadow: 0 6px 16px rgba(155, 89, 255, 0.2);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.04);
  background: linear-gradient(135deg, var(--pink), var(--purple));
}
.btn-sm {
  padding: 0.32rem 0.75rem;
  font-size: 0.76rem;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--pink-soft);
}

.rail-block button {
  width: 100%;
  text-align: center;
  line-height: 1.25;
  white-space: normal;
}

.muted { color: var(--muted); font-size: 0.84rem; }
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.84rem;
  cursor: pointer;
  user-select: none;
}
.check-label input { accent-color: var(--purple); width: 1rem; height: 1rem; }
.pack-status {
  display: block;
  font-size: 0.72rem;
  line-height: 1.4;
  min-height: 1em;
  word-break: break-word;
}

/* —— Stage (right) —— */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0.85rem 1rem 0.85rem;
}
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.15rem 0.2rem 0.7rem;
}
.stage-bar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}
.stage-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 0.2rem;
  overscroll-behavior: contain;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-top: 0.65rem;
  padding: 0.65rem 0.5rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pagination.hidden { display: none; }
.pagination-info {
  font-size: 0.78rem;
  color: var(--muted);
}
.pagination button,
.pagination select,
.pagination input {
  padding: 0.28rem 0.65rem;
  border: 1.5px solid var(--pink-soft);
  border-radius: 999px;
  background: #fff;
  color: var(--purple-dark);
  font-size: 0.76rem;
  cursor: pointer;
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pagination button.active {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  border-color: transparent;
}
.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.pagination-jump input {
  width: 3.2rem;
  text-align: center;
  border-radius: 8px;
  padding: 0.28rem 0.35rem;
}
.pagination-jump select {
  min-width: 5.5rem;
  border-radius: 8px;
  cursor: pointer;
}
.page-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.page-size-wrap select {
  cursor: pointer;
}

/* —— Character rows —— */
.char-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.char-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s, background 0.2s;
}
.char-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
  border-color: var(--pink-soft);
}
.char-row.selected {
  border-color: rgba(155, 89, 255, 0.55);
  background: linear-gradient(120deg, rgba(255, 248, 252, 0.98), rgba(247, 240, 255, 0.98));
}
.char-row .pick {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 1.35rem;
  cursor: pointer;
}
.char-row .pick input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--purple);
  cursor: pointer;
}

.avatar-ring {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  padding: 2px;
  background: linear-gradient(145deg, var(--pink-light), var(--purple));
}
.avatar-ring img,
.avatar-ring .ph {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
  display: block;
}
.avatar-ring .ph {
  display: grid;
  place-items: center;
  color: var(--purple);
  font-weight: 700;
  font-size: 1.15rem;
  background: linear-gradient(145deg, #fff5fa, #f3eaff);
}

.char-main {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  color: inherit;
}
.char-info { min-width: 0; flex: 1; }
.char-info h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin-bottom: 0.22rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.74rem;
  color: var(--muted);
  align-items: center;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.char-meta::-webkit-scrollbar { display: none; }

.tags {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.28rem;
  align-items: center;
  flex-shrink: 0;
}
.tag {
  font-size: 0.68rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(243, 232, 255, 0.85);
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.tag.on {
  background: linear-gradient(135deg, rgba(255, 179, 209, 0.55), rgba(232, 213, 255, 0.85));
  color: var(--purple-dark);
  font-weight: 600;
  border-color: rgba(255, 179, 209, 0.5);
}
.tag.off { opacity: 0.55; }

.char-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.55rem;
  background: linear-gradient(135deg, var(--pink-light), #e8d5ff);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--purple-dark);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--muted);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-state .emoji { font-size: 2rem; margin-bottom: 0.5rem; display: block; }

/* —— Skin cards —— */
.skin-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.skin-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem 0.85rem;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s, background 0.2s;
}
.skin-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
  border-color: var(--pink-soft);
}
.skin-card.selected {
  border-color: rgba(155, 89, 255, 0.5);
  background: linear-gradient(120deg, rgba(255, 248, 252, 0.98), rgba(247, 240, 255, 0.98));
}
.skin-card .skin-check {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.skin-card .skin-check input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--purple);
  cursor: pointer;
}
.skin-body { min-width: 0; }
.skin-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.28rem;
  min-width: 0;
  flex-wrap: nowrap;
}
.skin-title-row .tags { flex-shrink: 0; }
.skin-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.skin-card .skin-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.skin-card .skin-meta::-webkit-scrollbar { display: none; }
.ops {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  justify-content: flex-end;
  flex-shrink: 0;
}
.btn-fix {
  border-color: #ffd0b8;
  color: #c45c26;
  background: #fff7f1;
}
.btn-fix:hover:not(:disabled) {
  border-color: #ff9a5c;
  background: #ffefe3;
}
.btn-fix.done,
.btn-fix:disabled.done {
  border-color: var(--pink-soft);
  color: var(--muted);
  background: #faf6ff;
  opacity: 1;
}

@media (max-width: 820px) {
  html, body { overflow: auto; height: auto; }
  .app {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    min-height: 100dvh;
  }
  .rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .rail-actions { overflow: visible; flex: none; }
  .stage {
    min-height: 60dvh;
  }
  .stage-scroll {
    max-height: calc(100dvh - 12rem);
  }
  .skin-card {
    grid-template-columns: auto 1fr;
  }
  .skin-card .ops {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .char-row { flex-wrap: wrap; }
  .char-actions { width: 100%; justify-content: flex-end; }
}
