:root {
  color-scheme: light;
  --ink: #243044;
  --muted: #6b7485;
  --line: #dbe3ee;
  --surface: #ffffff;
  --surface-soft: #f5f8fb;
  --mist: #eaf4fb;
  --blue: #67a6d8;
  --blue-deep: #2d6f9d;
  --mint: #8fcfb8;
  --coral: #ee8e83;
  --sun: #f1c76b;
  --shadow: 0 20px 60px rgba(52, 79, 105, 0.14);
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(103, 166, 216, 0.2), transparent 26rem),
    linear-gradient(135deg, #f7fbfd 0%, #edf6f9 42%, #fff8f4 100%);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label.icon-button,
select {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 9rem;
}

.brand-logo {
  width: 9rem;
  height: 9rem;
  object-fit: contain;
  margin-left: -1.4rem;
  filter: drop-shadow(0 0.35rem 0.65rem rgba(52, 79, 105, 0.16));
}

.brand > div {
  min-width: 0;
  flex: 1;
  margin-left: -1.15rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--blue-deep);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.brand h1 {
  white-space: nowrap;
  word-break: keep-all;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.progress-panel,
.quick-notes {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  margin-bottom: 1rem;
}

.completion-ring {
  display: grid;
  place-items: center;
  width: 9rem;
  height: 9rem;
  margin: 0.75rem auto 1rem;
  border: 0.9rem solid var(--mist);
  border-top-color: var(--blue);
  border-right-color: var(--mint);
  border-radius: 50%;
  background: var(--surface-soft);
}

.completion-ring span {
  font-size: 2rem;
  font-weight: 900;
}

.progress-track {
  height: 0.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--mist);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--mint));
  transition: width 180ms ease;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 0;
}

.stats-grid div {
  padding: 0.75rem;
  border-radius: 0.45rem;
  background: var(--surface-soft);
}

.stats-grid dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.stats-grid dd {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  font-weight: 850;
}

textarea {
  resize: vertical;
}

.quick-notes textarea {
  width: 100%;
  min-height: 8.5rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.7rem 0.75rem;
  outline: none;
  background: var(--surface);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(103, 166, 216, 0.18);
}

.workspace {
  min-width: 0;
  padding: 1.25rem;
}

.topbar,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.top-actions,
.dialog-actions,
.dialog-actions div {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.tools-menu {
  position: relative;
}

.tools-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  cursor: pointer;
}

.tools-menu summary::-webkit-details-marker {
  display: none;
}

.tools-menu-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 30;
  display: grid;
  width: min(14rem, calc(100vw - 2rem));
  gap: 0.45rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tools-menu-panel .secondary-button {
  justify-content: flex-start;
  width: 100%;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 2.55rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  padding: 0 0.9rem;
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.55rem;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button input {
  display: none;
}

.backup-button input {
  display: none;
}

.hidden-file-input {
  display: none;
}

.primary-button {
  background: var(--blue-deep);
  color: #fff;
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-button {
  color: #b03b35;
  background: #fff2f0;
}

.toolbar {
  align-items: center;
  flex-wrap: wrap;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.toolbar > .segmented:not(.category-filters) {
  display: none;
}

.search-box {
  display: flex;
  align-items: center;
  flex: 0 1 22rem;
  max-width: 34%;
  min-width: 14rem;
  gap: 0.6rem;
  min-height: 2.55rem;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface);
}

.search-box input {
  border: 0;
  min-height: 2.2rem;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 0;
  box-shadow: none;
}

.segmented {
  display: flex;
  flex: 0 0 auto;
  gap: 0.25rem;
  padding: 0.22rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface-soft);
}

.category-filters {
  flex: 1 1 26rem;
  display: flex;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.category-filters button {
  flex: 0 0 auto;
  min-height: 2.15rem;
  min-width: 5.2rem;
  scroll-snap-align: start;
}

.back-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--blue-deep);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 1.25rem;
  font-weight: 900;
}

.segmented button {
  border: 0;
  border-radius: 0.35rem;
  padding: 0 0.62rem;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active {
  background: var(--surface);
  color: var(--blue-deep);
  box-shadow: 0 0.25rem 0.8rem rgba(48, 83, 112, 0.12);
}

.toolbar select {
  max-width: 11rem;
}

.catalog-grid {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.catalog-section {
  min-width: 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.15rem 0 0.25rem;
}

.pagination button {
  min-height: 2.3rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0 0.9rem;
  background: var(--surface);
  color: var(--ink);
  font-weight: 850;
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.pagination span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
  padding: 0 0.15rem;
}

.section-heading h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.section-heading span {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: rgba(255, 255, 255, 0.82);
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 850;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  justify-content: start;
  gap: 0.6rem;
}

.mine-section .section-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.plush-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.plush-card.batch-selected {
  outline: 3px solid var(--blue-deep);
  outline-offset: -3px;
}

.batch-select {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  border: 1px solid rgba(45, 111, 157, 0.35);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--blue-deep);
  font-size: 0.72rem;
  font-weight: 900;
}

.batch-selected .batch-select {
  background: var(--blue-deep);
  color: #fff;
}

.plush-card:hover {
  transform: translateY(-2px);
  border-color: rgba(45, 111, 157, 0.45);
}

.plush-card.unlit .photo-wrap img,
.plush-card.unlit .placeholder-face {
  opacity: 0.45;
}

.plush-card.unlit .card-body {
  opacity: 0.62;
}

.plush-card.lit {
  border-color: rgba(143, 207, 184, 0.8);
  box-shadow: 0 20px 60px rgba(65, 128, 103, 0.18);
}

.photo-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  padding: 0;
  aspect-ratio: 1 / 1;
  background:
    linear-gradient(135deg, rgba(103, 166, 216, 0.18), rgba(143, 207, 184, 0.18)),
    var(--surface-soft);
  cursor: zoom-in;
}

.photo-wrap img {
  display: block;
  width: auto;
  height: auto;
  max-width: 72%;
  max-height: 72%;
  object-fit: contain;
}

.mine-section .photo-wrap img {
  max-width: 68%;
  max-height: 68%;
}

.plush-card[data-series="铁牌"] .photo-wrap img {
  max-width: 68%;
  max-height: 68%;
  object-position: center top;
}

.plush-card[data-series="鐵牌"] .photo-wrap img {
  max-width: 68%;
  max-height: 68%;
  object-position: center top;
}

.placeholder-face {
  position: relative;
  width: 6.8rem;
  height: 5.9rem;
  border: 2px solid var(--ink);
  border-radius: 48% 52% 45% 55%;
  background: #fff;
}

.placeholder-face::before,
.placeholder-face::after {
  position: absolute;
  top: -0.65rem;
  width: 1.55rem;
  height: 1.8rem;
  content: "";
  border: 2px solid var(--ink);
  border-bottom: 0;
  background: var(--blue);
}

.placeholder-face::before {
  left: 0.75rem;
  border-radius: 80% 30% 0 0;
  transform: rotate(-18deg);
}

.placeholder-face::after {
  right: 0.75rem;
  border-radius: 30% 80% 0 0;
  transform: rotate(18deg);
}

.card-body {
  display: flex;
  flex-direction: column;
  padding: 0.48rem;
  min-height: 13.4rem;
}

.card-top {
  display: grid;
  gap: 0.4rem;
}

.card-title {
  display: -webkit-box;
  min-height: 2.35rem;
  margin-bottom: 0.12rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.78rem;
  line-height: 1.35;
}

.series {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.status-pill {
  width: fit-content;
  border-radius: 999px;
  padding: 0.18rem 0.42rem;
  font-size: 0.64rem;
  font-weight: 850;
}

.status-owned {
  background: #e7f6ee;
  color: #31795e;
}

.status-wanted {
  background: #fff4d8;
  color: #8b650d;
}

.status-reserved {
  background: #eaf2ff;
  color: #315f9a;
}

.meta-list {
  display: grid;
  gap: 0.22rem;
  margin: 0.45rem 0;
  min-height: 2.2rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.meta-list span:nth-child(1),
.meta-list span:nth-child(2) {
  display: none;
}

.memo {
  display: -webkit-box;
  min-height: 2.9rem;
  margin-bottom: 0.45rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--ink);
  font-size: 0.66rem;
  line-height: 1.45;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
  margin-top: auto;
}

.price-fields select {
  min-width: 0;
}

.edit-btn,
.name-btn,
.light-btn {
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  min-height: 1.85rem;
  padding: 0 0.38rem;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.6rem;
  font-weight: 800;
  width: 100%;
}

.name-btn {
  background: #fff8e7;
  color: #8b650d;
}

.light-btn {
  border-color: rgba(143, 207, 184, 0.7);
  background: #e7f6ee;
  color: #31795e;
}

.plush-card.unlit .light-btn {
  border-color: #d2d9e2;
  background: #eef2f5;
  color: #667181;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 24rem;
  padding: 2rem;
  border: 1px dashed #b9c8d8;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.empty-illustration {
  width: 8rem;
  height: 6rem;
  margin-bottom: 1rem;
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  background:
    linear-gradient(90deg, transparent 47%, rgba(36, 48, 68, 0.12) 48% 52%, transparent 53%),
    linear-gradient(135deg, #eaf4fb, #fff8f4);
}

.item-dialog,
.batch-dialog {
  width: min(46rem, calc(100vw - 2rem));
  border: 0;
  border-radius: 0.65rem;
  padding: 0;
  box-shadow: 0 1.4rem 5rem rgba(24, 42, 63, 0.28);
}

.image-dialog {
  width: min(44rem, calc(100vw - 2rem));
  border: 0;
  border-radius: 0.65rem;
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1.4rem 5rem rgba(24, 42, 63, 0.28);
}

.image-dialog::backdrop {
  background: rgba(28, 43, 60, 0.62);
  backdrop-filter: blur(3px);
}

.image-dialog img {
  display: block;
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
}

.image-nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-50%);
}

.image-nav span,
.image-close span {
  display: block;
  line-height: 1;
  transform: translateY(-0.08em);
}

.image-prev span {
  transform: translate(-0.04em, -0.08em);
}

.image-next span {
  transform: translate(0.04em, -0.08em);
}

.image-prev {
  left: 0.7rem;
}

.image-next {
  right: 0.7rem;
}

.image-nav:disabled {
  display: none;
}

.image-count {
  margin-top: 0.65rem;
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.image-cover-btn {
  display: block;
  margin: 0.75rem auto 0;
}

.image-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.item-dialog::backdrop,
.batch-dialog::backdrop {
  background: rgba(28, 43, 60, 0.42);
  backdrop-filter: blur(3px);
}

.item-dialog form,
.batch-dialog form {
  padding: 1.2rem;
}

.batch-dialog {
  width: min(32rem, calc(100vw - 2rem));
}

.batch-hint {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.batch-grid {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 0.8rem 0.9rem;
  align-items: center;
}

.batch-grid .wide {
  grid-column: 1 / -1;
}

.batch-grid label,
.batch-label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.batch-label {
  align-self: center;
}

.batch-grid textarea {
  min-height: 7rem;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.form-grid label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.price-fields {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.55rem;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-grid textarea {
  min-height: 6.5rem;
}

.photo-dropzone {
  display: grid;
  place-items: center;
  gap: 0.75rem;
  min-height: 4.6rem;
  border: 1px dashed #a9bed1;
  border-radius: 0.5rem;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  padding: 0.8rem;
}

.photo-dropzone.dragging,
.photo-dropzone:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(103, 166, 216, 0.18);
}

.photo-dropzone input {
  display: none;
}

.photo-preview-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.photo-preview-item {
  position: relative;
}

.photo-preview-item img {
  width: 3.8rem;
  height: 3.8rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  object-fit: cover;
  background: #fff;
}

.photo-preview-item button {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border: 1px solid rgba(176, 59, 53, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #9f2f29;
  box-shadow: 0 0.35rem 0.8rem rgba(31, 44, 58, 0.14);
}

.photo-preview-item button svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dialog-actions {
  justify-content: space-between;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .progress-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 1rem;
    align-items: center;
  }

  .progress-panel .panel-heading,
  .progress-track,
  .stats-grid {
    grid-column: 2;
  }

  .completion-ring {
    grid-row: 1 / span 3;
    width: 7.2rem;
    height: 7.2rem;
    margin: 0;
  }

  .topbar,
  .toolbar {
    flex-wrap: wrap;
  }

  .section-grid,
  .mine-section .section-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .sidebar,
  .workspace {
    padding: 0.85rem;
  }

  .progress-panel {
    display: block;
  }

  .completion-ring {
    margin: 0.75rem auto 1rem;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    align-items: stretch;
  }

  .primary-button {
    flex: 1;
  }

  .tools-menu {
    flex: 0 0 auto;
  }

  .tools-menu summary {
    min-width: 4.4rem;
  }

  .tools-menu-panel {
    right: 0;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .segmented,
  .toolbar select,
  .search-box {
    width: 100%;
    max-width: none;
  }

  .category-filters {
    width: calc(100vw - 1.7rem);
    max-width: calc(100vw - 1.7rem);
    margin-right: -0.3rem;
    padding-bottom: 0.15rem;
  }

  .segmented button {
    flex: 1;
    min-height: 2.25rem;
  }

  .category-filters button {
    flex: 0 0 auto;
    min-width: auto;
    padding: 0 0.85rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-grid,
  .mine-section .section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
