:root {
  color-scheme: light;
  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-strong: #fffaf1;
  --ink: #1d2630;
  --muted: #68737f;
  --line: #ded8cd;
  --accent: #0f7b80;
  --accent-dark: #075c61;
  --accent-soft: #d9f0ef;
  --warn: #a4432f;
  --shadow: 0 18px 50px rgba(45, 39, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 4vw, 48px);
  background: rgba(247, 245, 241, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.topbar-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--accent-dark);
  background: var(--surface);
  font-weight: 700;
}

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

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: #c78d80;
  color: var(--warn);
  margin-right: auto;
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-text-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: currentColor;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(130px, 1fr)) minmax(190px, auto);
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quick-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quick-filters .button {
  min-height: 42px;
  padding-inline: 12px;
}

.quick-filters .is-active {
  border-color: var(--accent);
  background: rgba(35, 80, 92, 0.1);
  color: var(--accent);
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

.price-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr);
  gap: 8px;
}

.field-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.price-row :disabled {
  cursor: not-allowed;
  background: #eef2f4;
  color: #62717c;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

.summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 2px;
  color: var(--muted);
}

.summary strong {
  color: var(--ink);
  font-size: 24px;
}

#summaryHint {
  margin-left: auto;
}

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.listing-card {
  min-width: 0;
}

.card-hit {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  text-align: left;
  background: var(--surface);
  color: inherit;
  box-shadow: 0 8px 24px rgba(45, 39, 31, 0.08);
}

.card-hit:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.card-photo {
  display: grid;
  min-height: 230px;
  aspect-ratio: 4 / 3;
  place-items: center;
  overflow: hidden;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.prts-link-preview {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 230px;
  gap: 12px;
  place-items: center;
  align-content: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(236, 243, 245, 0.76)),
    repeating-linear-gradient(45deg, rgba(35, 80, 92, 0.08) 0 1px, transparent 1px 12px);
  color: var(--ink);
}

.prts-link-preview {
  padding: 18px;
}

.prts-preview-label {
  z-index: 1;
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.prts-preview-label strong {
  font-size: 16px;
}

.prts-preview-label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.prts-link-preview a {
  z-index: 1;
  min-height: 36px;
  padding: 0 14px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.prts-link-preview a:hover {
  background: rgba(35, 80, 92, 0.08);
}

.card-content {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.card-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.card-title-row h3 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.3;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.presale {
  background: #f4dfcd;
  color: #8f4a18;
}

.status-pill.wanted {
  background: #e7e5f4;
  color: #4d478c;
}

.meta-line,
.description-line,
.wechat {
  color: var(--muted);
  line-height: 1.45;
}

.description-line {
  display: -webkit-box;
  min-height: 42px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.price {
  color: var(--warn);
  font-size: 20px;
}

.dialog {
  width: min(980px, calc(100% - 24px));
  max-height: 92vh;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(29, 38, 48, 0.45);
}

.dialog form,
.detail-dialog {
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

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

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

.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.photo-chip {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 1;
  background: var(--surface-strong);
}

.photo-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-chip button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(29, 38, 48, 0.76);
  color: #fff;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 20px;
}

.detail-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-photos img,
.detail-photos .empty-photo,
.detail-photos .prts-link-preview {
  width: 100%;
  min-height: 220px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-strong);
}

.empty-photo {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.detail-body {
  display: grid;
  align-content: start;
  gap: 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-row span:first-child {
  color: var(--muted);
  font-weight: 700;
}

.selection-panel,
.copy-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.selection-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.selection-header h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.share-option {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.share-option input {
  width: 18px;
  min-height: 18px;
}

.selection-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.selection-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.selection-item input {
  width: 18px;
  min-height: 18px;
}

.selection-item strong {
  display: block;
  line-height: 1.35;
}

.selection-item span {
  color: var(--muted);
  font-size: 13px;
}

.selection-item .price {
  color: var(--warn);
  font-size: 16px;
  white-space: nowrap;
}

.copy-panel textarea {
  min-height: 260px;
  line-height: 1.6;
}

.copy-rich {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.55;
  white-space: pre-wrap;
}

.copy-rich img {
  display: block;
  max-width: min(100%, 420px);
  height: auto;
  margin: 10px 0;
  border-radius: 8px;
}

.poster-preview {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f5ef;
}

.poster-preview img {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.poster-preview p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.58);
}

.empty-state h3 {
  margin-bottom: 8px;
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .form-grid,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-photos {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  #summaryHint {
    display: none;
  }
}

@media (max-width: 520px) {
  main {
    width: min(100% - 20px, 1180px);
    margin-top: 16px;
  }

  .topbar-actions,
  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions .primary,
  .dialog-actions .primary {
    grid-column: 1 / -1;
  }

  .price-row {
    grid-template-columns: 1fr;
  }

  .button.danger {
    margin-right: 0;
  }
}
