:root,
[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-deep: #e2e8f0;
  --panel: #ffffff;
  --panel-raised: #f8fafc;
  --panel-soft: #f4f7fb;
  --thumb-well: #1e2632;
  --line: #d5e0eb;
  --line-soft: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #475569;
  --dim: #7c8ba1;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-soft: rgba(13, 148, 136, 0.11);
  --accent: #0284c7;
  --danger: #e11d48;
  --card-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
  --plate-shadow: drop-shadow(0 18px 34px rgba(15, 23, 42, 0.24));
  --ui: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;

  /* 280x512 原生坐标系下人物背景实测平行四边形路径：(29,56)->(257,2)->(257,440)->(29,494) */
  --plate-clip: polygon(10.36% 10.94%, 91.79% 0.39%, 91.79% 85.94%, 10.36% 96.48%);
}

[data-theme="dark"] {
  --bg: #11161d;
  --bg-deep: #18202a;
  --panel: #171e27;
  --panel-raised: #1f2834;
  --panel-soft: #131921;
  --thumb-well: #0e1319;
  --line: #2b3746;
  --line-soft: rgba(168, 195, 214, 0.12);
  --text: #eef3f8;
  --muted: #8e9fae;
  --dim: #5e6e7d;
  --teal: #38cbb8;
  --teal-dark: #22998a;
  --teal-soft: rgba(56, 203, 184, 0.14);
  --accent: #7ec8ff;
  --danger: #f43f5e;
  --card-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  --plate-shadow: drop-shadow(0 20px 38px rgba(0, 0, 0, 0.56));
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; }
body {
  height: 100dvh;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }

/* ==================== 顶部导航栏 ==================== */
.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  position: relative;
  z-index: 10;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 900;
  transform: skew(-8deg);
  box-shadow: 0 3px 10px rgba(13, 148, 136, 0.28);
}
[data-theme="dark"] .brand-mark { color: #061514; }
.brand-lockup h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: 0.01em; }
.brand-lockup p { margin: 2px 0 0; color: var(--dim); font-size: 9.5px; font-weight: 600; letter-spacing: 0.1em; }

.mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 9px;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
}
.mode-tab {
  height: 34px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  transition: 0.16s ease;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active {
  background: var(--panel);
  color: var(--teal);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.tab-index {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--line-soft);
  color: var(--dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.mode-tab.active .tab-index {
  background: var(--teal-soft);
  color: var(--teal);
}

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-button, .secondary-button, .export-button, .reset-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: 0.16s ease;
}
.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--panel-raised);
  color: var(--muted);
  font-size: 15px;
}
.icon-button:hover,
.secondary-button:hover {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--teal-soft);
}
.secondary-button {
  height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
}
.export-button:disabled,
.secondary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}
.export-button {
  height: 36px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #ffffff;
  border: 0;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(13, 148, 136, 0.28);
}
[data-theme="dark"] .export-button { color: #051614; }
.export-button:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* ==================== 主工作区与左侧预览台 ==================== */
.workspace {
  height: calc(100dvh - 62px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 432px;
}

.preview-area {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 28px 16px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.92) 0%, rgba(235, 242, 249, 0.88) 65%, rgba(224, 233, 243, 0.95) 100%),
    linear-gradient(90deg, rgba(15, 23, 42, 0.028) 1px, transparent 1px),
    linear-gradient(180deg, rgba(15, 23, 42, 0.028) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px, 24px 24px;
  position: relative;
  overflow: hidden;
}
[data-theme="dark"] .preview-area {
  background:
    radial-gradient(circle at 50% 35%, rgba(39, 49, 64, 0.94) 0%, rgba(23, 30, 39, 0.96) 68%, rgba(16, 21, 28, 0.99) 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px, 24px 24px;
}

.preview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; }
.eyebrow, .section-kicker { color: var(--teal); font-size: 10px; letter-spacing: 0.14em; font-weight: 800; }
.preview-head h2 { margin: 4px 0 0; font-size: 20px; font-weight: 800; }
.preview-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.meta-divider { height: 12px; width: 1px; background: var(--line); }

.preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow: auto;
}

/* ==================== 模式 1：单人角色加载铭牌（严格 280:512 原生坐标系 = 306x560） ==================== */
.preview-grid.is-role-mode {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.role-plate-card {
  position: relative;
  width: 306px;
  height: 560px;
  transform-origin: center center;
  user-select: none;
  cursor: grab;
  filter: var(--plate-shadow);
}
.role-plate-card:active { cursor: grabbing; }

/* 内层平行四边形画框：与 280x512 背景/边框共享 1:1 满铺坐标系，零偏移误差 */
.role-plate-inner {
  position: absolute;
  inset: 0;
  clip-path: var(--plate-clip);
  background: #141920;
  overflow: hidden;
  z-index: 1;
}

.role-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 1;
  pointer-events: none;
}

/* 立绘层底部收在铭牌横梁内，防止默认框或半截框底部露出手脚 */
.role-skin-clip {
  position: absolute;
  inset: 0 0 28.2% 0;
  overflow: hidden;
  z-index: 2;
  pointer-events: none;
}

.role-skin-img {
  position: absolute;
  transform: translate(-50%, -50%);
  height: auto;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
}

/* 仅在未选任何边框时兜底显示的暗色底条 */
.role-nameplate-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30.3%;
  background: linear-gradient(180deg, rgba(14, 18, 23, 0.94) 0%, rgba(8, 10, 14, 0.98) 100%);
  border-top: 1.5px solid rgba(255, 255, 255, 0.16);
  z-index: 3;
  pointer-events: none;
}

/* 所有 280x512 边框 1:1 满铺对齐（半截边框、单边边框、外溢花朵全部像素级归位） */
.role-border-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 4;
  pointer-events: none;
}

.role-player-avatar {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -50%);
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: #0f1318;
  pointer-events: none;
}

.role-text-group {
  position: absolute;
  z-index: 6;
  transform: translateY(-50%);
  max-width: 64%;
  text-align: right;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.96), 0 0 8px rgba(0, 0, 0, 0.72);
}
.role-skin-title {
  display: block;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}
.role-player-name {
  display: block;
  margin-top: 3px;
  color: #ffffff;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.role-side-badges {
  position: absolute;
  left: 14.2%;
  top: 13.8%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.role-badge-weapon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9));
}
.role-badge-trait {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.75);
}
.role-badge-trait.havoc { background: radial-gradient(circle, #ef4444 25%, #450a0a 90%); }
.role-badge-trait.chaos { background: radial-gradient(circle, #c084fc 25%, #3b0764 90%); }
.role-badge-trait.fort { background: radial-gradient(circle, #38bdf8 25%, #082f49 90%); }
.role-badge-trait.support { background: radial-gradient(circle, #4ade80 25%, #052e16 90%); }

/* ==================== 模式 2：队伍大厅（前端几何去阴影黑缝 + S10 CNJ 实机框对齐） ==================== */
.preview-grid.is-team-mode {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  height: min(600px, calc(100dvh - 200px));
}

.team-lobby-slot {
  position: relative;
  height: 100%;
  aspect-ratio: 282 / 643;
  background: transparent;
  filter: var(--plate-shadow);
  overflow: hidden;
}

.team-bg-img {
  position: absolute;
  left: -2.837%;
  top: 0;
  width: 114.184%;
  height: 106.376%;
  max-width: none;
  object-fit: fill;
  z-index: 1;
  pointer-events: none;
}

.team-status-tag {
  position: absolute;
  top: 3.4%;
  left: 4.5%;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
  color: #65f77b;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.team-status-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #65f77b;
}
.team-status-tag.busy { color: #38bdf8; }
.team-status-tag.busy::before { background: #38bdf8; }

.team-avatar-box {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  aspect-ratio: 1;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}
.team-avatar-box img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.team-name-tag {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 4.8%;
  padding: 0 11px;
  max-width: 88%;
  border-radius: 2px;
  color: #ffffff;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.88);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.24);
}
.team-name-tag > span {
  display: block;
  transform: translateY(-0.5px);
}

.team-lobby-slot.is-closed {
  background: rgba(15, 23, 42, 0.12);
  border: 1px dashed var(--line);
  border-radius: 6px;
  filter: none;
  display: grid;
  place-items: center;
}
[data-theme="dark"] .team-lobby-slot.is-closed {
  background: rgba(18, 23, 29, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.closed-watermark {
  color: var(--dim);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  opacity: 0.55;
}

.preview-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--muted); font-size: 11px; }
.footer-note { display: inline-flex; align-items: center; gap: 8px; }
.footer-marker { color: var(--teal); font-weight: 800; }
kbd {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  font-size: 10px;
  font-weight: 600;
}

/* ==================== 右侧控制面板 ==================== */
.control-panel {
  background: var(--panel-soft);
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.panel-scroll { flex: 1; overflow-y: auto; padding: 18px 16px 14px; }
.editor-section[hidden] { display: none; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-heading h3 { margin: 3px 0 0; font-size: 16px; font-weight: 800; }
.section-count {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.slot-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.slot-tab {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  transition: 0.14s ease;
}
.slot-tab:hover { border-color: var(--teal); color: var(--text); }
.slot-tab.active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.24);
}
[data-theme="dark"] .slot-tab.active { color: #051614; }
.slot-tab:not(.active).enabled::after {
  content: "";
  display: inline-block;
  margin-left: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.editor-card {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
  display: grid;
  gap: 13px;
}
.editor-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.field { display: grid; gap: 6px; }
.field-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.font-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
.font-bar.has-custom {
  grid-template-columns: 1.1fr 0.9fr;
}
.field > label, .field-label { color: var(--text); font-size: 11.5px; font-weight: 700; }

input[type="text"], input[type="search"], select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="color"] {
  width: 36px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  cursor: pointer;
  flex-shrink: 0;
}
input:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

/* 修复潜能下拉框文字被裁切问题：预留充足内边距与自适应宽度 */
.trait-select-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
select.trait-select {
  width: auto;
  min-width: 92px;
  height: 31px;
  padding: 0 24px 0 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.position-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--panel-soft);
}
.position-details summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--teal);
  user-select: none;
}
.mini-reset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.mini-reset-btn {
  height: 25px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.14s ease;
}
.mini-reset-btn:hover {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--teal-soft);
}
.mini-reset-hint {
  margin-left: auto;
  align-self: center;
  color: var(--dim);
  font-size: 9.5px;
}
.position-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; margin-top: 9px; }
.range-field { display: grid; gap: 4px; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.range-field span { display: flex; justify-content: space-between; }
.range-field output { color: var(--teal); font-weight: 700; font-variant-numeric: tabular-nums; }
.range-full { grid-column: 1 / -1; }
input[type="range"] { width: 100%; accent-color: var(--teal); cursor: pointer; }

.skin-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.skin-toggle button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  transition: 0.14s ease;
}
.skin-toggle button:hover { border-color: var(--teal); color: var(--text); }
.skin-toggle button.active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}
[data-theme="dark"] .skin-toggle button.active { color: #051614; }

.picker-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.picker-head-right { display: inline-flex; align-items: center; gap: 6px; }
.picker-count { color: var(--dim); font-size: 10.5px; font-weight: 600; }
.picker-collapse-btn {
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-raised);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.14s ease;
}
.picker-collapse-btn:hover { color: var(--teal); border-color: var(--teal); }
.picker.is-collapsed .picker-search,
.picker.is-collapsed .asset-grid { display: none; }

/* 定制精致细滚动条（日夜双主题自适应） */
.panel-scroll,
.asset-grid,
.preview-stage {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.36) transparent;
}
.panel-scroll::-webkit-scrollbar,
.asset-grid::-webkit-scrollbar,
.preview-stage::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.panel-scroll::-webkit-scrollbar-track,
.asset-grid::-webkit-scrollbar-track,
.preview-stage::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.05);
  border-radius: 4px;
}
.panel-scroll::-webkit-scrollbar-thumb,
.asset-grid::-webkit-scrollbar-thumb,
.preview-stage::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 4px;
}
.panel-scroll::-webkit-scrollbar-thumb:hover,
.asset-grid::-webkit-scrollbar-thumb:hover,
.preview-stage::-webkit-scrollbar-thumb:hover {
  background: var(--teal);
}
.panel-scroll::-webkit-scrollbar-button,
.asset-grid::-webkit-scrollbar-button,
.preview-stage::-webkit-scrollbar-button {
  display: none;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: max-content;
  gap: 7px;
  max-height: 224px;
  overflow-y: auto;
  padding: 3px 4px 3px 2px;
}
.picker[data-picker-kind="skin"] .asset-grid,
.picker[data-picker-kind="border"] .asset-grid,
.picker[data-picker-kind="roleBackground"] .asset-grid,
.picker[data-picker-kind="background"] .asset-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.asset-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-raised);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}
.asset-option:hover {
  border-color: var(--teal);
  color: var(--text);
  transform: translateY(-1px);
}
.asset-option.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--text);
  box-shadow: 0 0 0 1.5px var(--teal-soft);
}
.asset-option img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 5px;
  background: var(--thumb-well);
}
.picker[data-picker-kind="roleBackground"] .asset-option img,
.picker[data-picker-kind="border"] .asset-option img {
  aspect-ratio: 280 / 512;
  object-fit: contain;
}
.picker[data-picker-kind="background"] .asset-option { overflow: hidden; }
.picker[data-picker-kind="background"] .asset-option img {
  aspect-ratio: 282 / 643;
  object-fit: cover;
  object-position: 24% 0%;
}
.picker[data-picker-kind="avatar"] .asset-option img { object-fit: contain; }

.asset-option span {
  display: block;
  width: 100%;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.asset-empty { grid-column: 1 / -1; padding: 18px 4px; text-align: center; color: var(--dim); font-size: 11px; }

.switch-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--text); cursor: pointer; }
.switch-label input { accent-color: var(--teal); width: 15px; height: 15px; cursor: pointer; }

.panel-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
}
.reset-button {
  height: 30px;
  padding: 0 11px;
  background: var(--panel-raised);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.reset-button:hover { color: var(--danger); border-color: var(--danger); }
.asset-count { color: var(--dim); font-size: 11px; font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid var(--teal);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .workspace { display: flex; flex-direction: column; }
  .preview-area { flex: 0 0 46dvh; padding: 14px; }
  .control-panel { flex: 1; border-left: 0; border-top: 1px solid var(--line-soft); }
}
