/* 桌遊配件圖鑑 — 圖鑑冊風格 */
.comp-dex-list {
  --cd-ink: var(--text-main, #2c221e);
  --cd-muted: var(--text-muted, #6b5d52);
  --cd-paper: var(--card-bg, #fffdf8);
  --cd-surface: var(--bg-surface, #f3ebe0);
  --cd-brand: var(--color-brand, #1f5a85);
  --cd-line: var(--border-soft, #cbbba8);
  --cd-spine: color-mix(in srgb, var(--cd-ink) 18%, transparent);
  padding: 12px 10px 28px;
  color: var(--cd-ink);
  box-sizing: border-box;
}

.comp-dex-book {
  max-width: 720px;
  margin: 0 auto;
  background:
    linear-gradient(90deg, var(--cd-spine) 0 10px, transparent 10px),
    linear-gradient(165deg, var(--cd-paper) 0%, var(--cd-surface) 100%);
  border: 2px solid var(--cd-ink);
  border-radius: 4px 14px 14px 4px;
  box-shadow: 4px 4px 0 var(--cd-ink);
  min-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.comp-dex-book__chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--cd-line);
  background: color-mix(in srgb, var(--cd-paper) 88%, var(--cd-brand));
  flex-shrink: 0;
}

.comp-dex-book__title {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.comp-dex-book__meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--cd-muted);
  white-space: nowrap;
}

.comp-dex-book__body {
  flex: 1;
  padding: 16px 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.comp-dex-cover {
  text-align: center;
  padding: 28px 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: compDexIn 0.35s ease both;
}

.comp-dex-cover__mark {
  width: 72px;
  height: 72px;
  border: 2px solid var(--cd-ink);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--cd-surface);
  box-shadow: 2px 2px 0 var(--cd-ink);
}

.comp-dex-cover__mark svg {
  width: 36px;
  height: 36px;
  stroke: var(--cd-brand);
  fill: none;
}

.comp-dex-cover__h1 {
  margin: 0;
  font-size: clamp(26px, 6vw, 34px);
  font-weight: 900;
  line-height: 1.2;
}

.comp-dex-cover__lead {
  margin: 0;
  max-width: 34em;
  font-size: 14px;
  line-height: 1.55;
  color: var(--cd-muted);
}

.comp-dex-btn {
  appearance: none;
  border: 2px solid var(--cd-ink);
  background: var(--cd-brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--cd-ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.comp-dex-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--cd-ink);
}

.comp-dex-btn--ghost {
  background: var(--cd-paper);
  color: var(--cd-ink);
}

.comp-dex-btn--sm {
  padding: 6px 12px;
  font-size: 12px;
  box-shadow: 1px 1px 0 var(--cd-ink);
}

.comp-dex-toc {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: compDexIn 0.3s ease both;
}

.comp-dex-toc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.comp-dex-toc__h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.comp-dex-toc__progress {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.82;
}

.comp-dex-toc__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 520px) {
  .comp-dex-toc__grid {
    grid-template-columns: 1fr 1fr;
  }
}

.comp-dex-chapter {
  appearance: none;
  text-align: left;
  border: 2px solid var(--cd-ink);
  background: var(--cd-paper);
  border-radius: 12px;
  padding: 14px 14px 12px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--cd-ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comp-dex-chapter:hover {
  background: color-mix(in srgb, var(--cd-surface) 70%, var(--cd-paper));
}

.comp-dex-chapter__name {
  font-size: 15px;
  font-weight: 900;
}

.comp-dex-chapter__count {
  font-size: 12px;
  color: var(--cd-muted);
  font-weight: 700;
}

.comp-dex-grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.comp-dex-search {
  flex: 1 1 160px;
  min-width: 0;
  border: 1.5px solid var(--cd-line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  background: var(--cd-paper);
  color: var(--cd-ink);
}

.comp-dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  animation: compDexIn 0.28s ease both;
}

.comp-dex-card {
  appearance: none;
  border: 1.5px solid var(--cd-ink);
  background: var(--cd-paper);
  border-radius: 10px;
  padding: 10px 8px 12px;
  cursor: pointer;
  text-align: center;
  position: relative;
  box-shadow: 2px 2px 0 color-mix(in srgb, var(--cd-ink) 55%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 148px;
}

.comp-dex-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--cd-ink);
}

.comp-dex-card__img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 14px;
  background: color-mix(in srgb, var(--cd-surface) 70%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cd-ink) 8%, transparent);
}

.comp-dex-detail__img {
  width: 168px;
  height: 168px;
  object-fit: contain;
  border-radius: 22px;
  background: color-mix(in srgb, var(--cd-surface) 60%, var(--cd-paper));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--cd-ink) 18%, transparent);
}

.comp-dex-stamp--custom {
  left: 6px;
  right: auto;
  transform: rotate(-8deg);
  border-color: #0f766e;
  color: #0f766e;
  background: color-mix(in srgb, var(--cd-paper) 80%, #0f766e);
}

.comp-dex-cover__actions,
.comp-dex-toc__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.comp-dex-add__hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--cd-muted);
  font-weight: 650;
  line-height: 1.45;
}

.comp-dex-add__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comp-dex-add__label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--cd-brand);
}

.comp-dex-add__label input,
.comp-dex-add__label select,
.comp-dex-add__label textarea {
  border: 1.5px solid var(--cd-line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  background: var(--cd-paper);
  color: var(--cd-ink);
  font-family: inherit;
}

.comp-dex-artgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}

.comp-dex-artpick {
  appearance: none;
  border: 1.5px solid var(--cd-line);
  background: var(--cd-paper);
  border-radius: 12px;
  padding: 4px;
  cursor: pointer;
}

.comp-dex-artpick.is-active,
.comp-dex-artpick:hover {
  border-color: var(--cd-brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cd-brand) 25%, transparent);
}

.comp-dex-artpick img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.comp-dex-add__preview {
  display: flex;
  justify-content: center;
  padding: 8px;
}

.comp-dex-add__preview img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 16px;
  background: var(--cd-surface);
}

.comp-dex-card__name {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.comp-dex-card__tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--cd-muted);
}

.comp-dex-stamp {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border: 1.5px solid var(--cd-brand);
  color: var(--cd-brand);
  border-radius: 4px;
  transform: rotate(8deg);
  background: color-mix(in srgb, var(--cd-paper) 80%, var(--cd-brand));
  line-height: 1.2;
}

.comp-dex-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: compDexIn 0.28s ease both;
}

.comp-dex-detail__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1.5px dashed var(--cd-line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--cd-surface) 55%, var(--cd-paper));
  position: relative;
}

.comp-dex-detail__h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.comp-dex-detail__en {
  margin: 0;
  font-size: 13px;
  color: var(--cd-muted);
  font-weight: 700;
}

.comp-dex-detail__row {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.comp-dex-detail__label {
  font-weight: 800;
  color: var(--cd-brand);
  margin-right: 6px;
}

.comp-dex-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

.comp-dex-empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--cd-muted);
  font-weight: 700;
}

@keyframes compDexIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .comp-dex-cover,
  .comp-dex-toc,
  .comp-dex-grid,
  .comp-dex-detail {
    animation: none;
  }
  .comp-dex-btn:hover,
  .comp-dex-card:hover {
    transform: none;
  }
}

html[data-tm-scheme="dark"] .comp-dex-book,
html:not([data-tm-scheme="light"]) .comp-dex-book {
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--cd-brand) 50%, var(--cd-ink));
}
