:root {
  --bg: #100e14;
  --bg-raise: #18151e;
  --bg-card: #1c1924;
  --bg-card-hover: #221e2c;
  --line: rgba(226, 196, 132, 0.16);
  --line-strong: rgba(232, 200, 122, 0.55);
  --gold: #e4c37a;
  --gold-soft: #c9a45a;
  --text: #f3ead8;
  --text-dim: #9b9180;
  --text-mute: #6f675b;
  --danger: #d27a6a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Source Han Sans SC",
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-width: 960px;
  background-image:
    radial-gradient(ellipse at top, rgba(228, 195, 122, 0.08), transparent 42%),
    radial-gradient(circle at 100% 0, rgba(120, 70, 40, 0.12), transparent 30%),
    linear-gradient(180deg, #141218 0%, #0c0b10 100%);
}

button,
input {
  font-family: inherit;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(28, 24, 34, 0.92), rgba(16, 14, 20, 0.8));
  flex: 0 0 auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.brand p {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search input {
  width: 280px;
  height: 38px;
  padding: 0 14px 0 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(8, 7, 11, 0.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239b9180' stroke-width='1.6' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3-3'/%3E%3C/svg%3E") no-repeat 12px 50%;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

.search input::placeholder {
  color: var(--text-mute);
}

.search input:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(228, 195, 122, 0.12);
}

.count {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

.gallery {
  position: relative;
  overflow: auto;
  padding: 18px 20px 28px;
  min-width: 0;
}

.grid-wrap {
  position: relative;
}

#spacer {
  width: 100%;
  pointer-events: none;
}

#grid {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  min-height: 100%;
}

.card {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #211c28 0%, #16131c 100%);
  color: inherit;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
  will-change: transform;
}

.card:hover,
.card:focus-visible {
  border-color: rgba(228, 195, 122, 0.42);
  background: var(--bg-card-hover);
  outline: none;
}

.card.is-selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(228, 195, 122, 0.35), 0 10px 28px rgba(0, 0, 0, 0.28);
}

.card-stage {
  position: relative;
  flex: 1 1 auto;
  margin: 8px 8px 0;
  border-radius: 10px;
  background:
    radial-gradient(ellipse at 50% 70%, rgba(228, 195, 122, 0.08), transparent 55%),
    linear-gradient(180deg, #0b0a10, #14121a);
  overflow: hidden;
  min-height: 0;
}

.card-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.card-state {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-mute);
  pointer-events: none;
}

.card.is-loading .card-state,
.card.is-error .card-state {
  display: flex;
}

.card.is-error .card-state {
  color: var(--danger);
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 10px;
}

.card-label {
  font-size: 13px;
  letter-spacing: 0.04em;
}

.card-tag {
  font-size: 11px;
  color: var(--text-mute);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  flex: 0 0 auto;
}

.card-tag.is-anim {
  color: var(--gold-soft);
  border-color: rgba(228, 195, 122, 0.28);
}

.empty {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 14px;
}

.detail {
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 21, 30, 0.96), rgba(12, 11, 16, 0.96));
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.detail h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.16em;
}

.preview-frame {
  position: relative;
  height: 230px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 60%, rgba(228, 195, 122, 0.14), transparent 58%),
    linear-gradient(180deg, #0a090e 0%, #16131c 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.preview-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.preview-frame.is-loading::after {
  content: "载入中…";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  font-size: 13px;
  pointer-events: none;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.detail-name {
  margin: 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-name strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.kind-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}

.kind-pill.is-anim {
  color: var(--gold);
  border-color: rgba(228, 195, 122, 0.4);
}

.info-list {
  margin: 0;
  display: grid;
  grid-template-columns: 64px 1fr;
  row-gap: 8px;
  column-gap: 8px;
  font-size: 13px;
}

.info-list dt {
  margin: 0;
  color: var(--text-mute);
}

.info-list dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.actions button {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #3a3124, #2a241b);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.actions button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.actions button.secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.actions button:disabled {
  opacity: 0.4;
  cursor: default;
}

.hint {
  margin-top: auto;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-mute);
}

.detail-empty {
  color: var(--text-dim);
  font-size: 14px;
  padding: 28px 8px;
  text-align: center;
}

.boot {
  margin: 80px auto;
  max-width: 520px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-raise);
  color: var(--text);
  line-height: 1.7;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: rgba(20, 17, 24, 0.95);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
  box-shadow: var(--shadow);
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.gallery::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 10px;
}

.gallery::-webkit-scrollbar-thumb {
  background: rgba(228, 195, 122, 0.28);
  border-radius: 10px;
}

.gallery::-webkit-scrollbar-track {
  background: transparent;
}
