* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: #1f2933;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #f3f6f9;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #e85d04;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
}

.home-link,
button,
.coupon-action {
  border: 0;
  border-radius: 8px;
  background: #e85d04;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.home-link {
  padding: 10px 14px;
  white-space: nowrap;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid #d8e1ea;
  border-radius: 8px;
  background: #ffffff;
}

.search-field {
  display: grid;
  gap: 8px;
  color: #52616f;
  font-size: 13px;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #c8d3df;
  border-radius: 8px;
  color: #1f2933;
  font: inherit;
  outline: none;
}

.search-field input:focus {
  border-color: #e85d04;
  box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.15);
}

.toolbar button {
  height: 42px;
  padding: 0 20px;
}

.summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
  color: #52616f;
  font-size: 14px;
}

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

.coupon-card {
  display: grid;
  grid-template-rows: 176px minmax(0, 1fr);
  overflow: hidden;
  min-height: 360px;
  border: 1px solid #d8e1ea;
  border-radius: 8px;
  background: #ffffff;
}

.coupon-image {
  width: 100%;
  height: 176px;
  object-fit: cover;
  background: linear-gradient(135deg, #ffe8d3, #dbeafe);
}

.coupon-image.placeholder {
  display: grid;
  place-items: center;
  color: #8b99a7;
  font-weight: 700;
}

.coupon-body {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 14px;
}

.coupon-title {
  display: -webkit-box;
  overflow: hidden;
  min-height: 48px;
  margin: 0;
  color: #17212b;
  font-size: 17px;
  line-height: 1.4;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.coupon-subtitle {
  display: -webkit-box;
  overflow: hidden;
  min-height: 40px;
  margin: 0;
  color: #667789;
  font-size: 13px;
  line-height: 1.55;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.coupon-meta {
  display: grid;
  align-content: start;
  gap: 7px;
  color: #52616f;
  font-size: 13px;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.price {
  color: #d9480f;
  font-size: 22px;
  font-weight: 800;
}

.origin-price {
  color: #8b99a7;
  text-decoration: line-through;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f7;
  color: #52616f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coupon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 12px;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.detail-button {
  min-height: 40px;
  padding: 9px 12px;
}

.coupon-action.disabled {
  background: #a9b6c2;
  pointer-events: none;
}

.load-more {
  display: block;
  min-width: 160px;
  height: 44px;
  margin: 22px auto 0;
  padding: 0 18px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.state-card {
  grid-column: 1 / -1;
  padding: 32px;
  border: 1px dashed #c8d3df;
  border-radius: 8px;
  background: #ffffff;
  color: #667789;
  text-align: center;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
}

.modal-panel {
  position: absolute;
  top: 5vh;
  right: max(20px, calc((100vw - 1180px) / 2));
  bottom: 5vh;
  width: min(720px, calc(100vw - 40px));
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e3e9ef;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #eef3f7;
  color: #1f2933;
  font-size: 24px;
  line-height: 1;
}

.modal-content {
  height: calc(100% - 67px);
  overflow: auto;
  padding: 18px;
}

.detail-hero {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.detail-hero img,
.detail-image-placeholder {
  width: 160px;
  height: 120px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef3f7;
}

.detail-image-placeholder {
  display: grid;
  place-items: center;
  color: #8b99a7;
}

.detail-meta {
  display: grid;
  gap: 8px;
  color: #52616f;
}

.detail-section {
  margin-top: 18px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.link-list {
  display: grid;
  gap: 8px;
}

.link-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e3e9ef;
  border-radius: 8px;
  background: #f8fafc;
}

.link-row code {
  overflow: hidden;
  color: #334155;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row a {
  color: #e85d04;
  font-weight: 700;
  text-decoration: none;
}

.raw-detail {
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #d1d5db;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.store-list {
  display: grid;
  gap: 8px;
}

.store-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e3e9ef;
  border-radius: 8px;
  background: #ffffff;
}

.store-row strong {
  color: #1f2933;
}

.store-row span {
  grid-column: 2;
  color: #52616f;
  font-size: 13px;
}

.store-logo {
  grid-row: 1 / span 5;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #eef3f7;
  object-fit: cover;
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 20px;
  }

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

  h1 {
    font-size: 26px;
  }

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

  .summary {
    flex-direction: column;
  }

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

  .card-actions {
    grid-template-columns: 1fr;
  }

  .modal-panel {
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

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

  .detail-hero img,
  .detail-image-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

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