:root {
  --bg: #ffffff;
  --surface: #faf8f8;
  --ink: #211b1c;
  --muted: #746a6c;
  --faint: #9f9698;
  --line: #e5dfe0;
  --accent: #86172b;
  --accent-strong: #6f1021;
  --accent-soft: #f5e9eb;
  --danger: #c6383f;
  --success: #49715d;
  --radius: 16px;
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(134, 23, 43, 0.24);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  padding-bottom: var(--safe-bottom);
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  min-height: 60px;
  padding-top: env(safe-area-inset-top);
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid rgba(229, 223, 224, 0.75);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 680;
  text-align: center;
  letter-spacing: -0.01em;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 2px;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: var(--ink);
  background: transparent;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.page {
  padding: 20px 18px 28px;
}

.page-intro {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.system-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 13px 14px;
  border: 1px solid #e9cfd4;
  border-radius: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 610;
  line-height: 1.4;
}

.system-banner svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

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

.product-card {
  overflow: hidden;
  min-width: 0;
  padding: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  background: var(--bg);
}

.product-card-image {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--surface);
}

.product-card-image.image-unavailable,
.detail-image.image-unavailable,
.confirm-image.image-unavailable {
  display: grid;
  place-items: center;
}

.product-card-image.image-unavailable::after,
.detail-image.image-unavailable::after,
.confirm-image.image-unavailable::after {
  content: "图片暂不可用";
  padding: 16px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

.product-card-image img,
.detail-image img,
.confirm-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.favorite-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 16px rgba(44, 30, 34, 0.12);
}

.favorite-button svg {
  width: 20px;
  height: 20px;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.8;
}

.favorite-button[aria-pressed="true"] {
  color: var(--accent);
}

.favorite-button[aria-pressed="true"] svg {
  fill: currentColor;
}

.product-card-body {
  padding: 12px 11px 13px;
}

.product-name {
  display: -webkit-box;
  min-height: 41px;
  margin: 0 0 5px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-brand {
  overflow: hidden;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.product-price {
  margin: 0;
  color: var(--accent);
  font-size: 16px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.card-time {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.stock-text {
  margin: 4px 0 0;
  color: var(--success);
  font-size: 12px;
  font-weight: 640;
}

.detail-image {
  overflow: hidden;
  aspect-ratio: 1.14 / 1;
  margin: 0 -2px 18px;
  border-radius: 18px;
  background: var(--surface);
}

.detail-title {
  margin: 0 0 7px;
  font-size: 23px;
  font-weight: 720;
  line-height: 1.28;
  letter-spacing: -0.02em;
}

.detail-brand,
.detail-code {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.detail-price {
  margin: 16px 0;
  color: var(--accent);
  font-size: 24px;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
}

.description {
  margin: 0 0 18px;
  color: #52494b;
  font-size: 14px;
  line-height: 1.75;
}

.info-list {
  margin: 0;
  border-top: 1px solid var(--line);
}

.info-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.65fr) 1fr;
  gap: 18px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.info-row dt {
  color: var(--muted);
}

.info-row dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.text-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 620;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.text-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.sticky-action {
  position: sticky;
  bottom: 0;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(229, 223, 224, 0.8);
  background: #fff;
  box-shadow: 0 -8px 20px rgba(50, 31, 37, 0.04);
}

.button {
  display: inline-flex;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 680;
  text-decoration: none;
  cursor: pointer;
}

.button svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

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

.button-primary:active {
  background: var(--accent-strong);
}

.button-secondary {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg);
}

.button-neutral {
  color: var(--ink);
  border-color: #a9a0a2;
  background: var(--bg);
}

.button-danger {
  color: var(--danger);
  border-color: #df6f74;
  background: #fff;
}

.confirm-product {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 16px;
  align-items: start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.confirm-image {
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: 14px;
  background: var(--surface);
}

.confirm-product h2 {
  margin: 3px 0 7px;
  font-size: 18px;
  line-height: 1.35;
}

.confirm-product p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.confirm-product .product-price {
  margin-top: 13px;
  color: var(--accent);
  font-size: 19px;
}

.confirm-sections {
  margin-top: 4px;
}

.confirm-total dd {
  color: var(--accent);
  font-size: 21px;
  font-weight: 750;
}

.safe-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 18px 0;
  padding: 14px;
  color: var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 620;
  line-height: 1.5;
  text-align: center;
}

.safe-note svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 12px;
  margin-top: 18px;
}

.confirm-actions .button {
  width: 100%;
}

.microcopy {
  margin: 14px 6px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.task-meta {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.task-meta strong {
  color: var(--ink);
}

.timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  position: absolute;
  top: 16px;
  bottom: 24px;
  left: 13px;
  width: 1px;
  content: "";
  background: var(--line);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  min-height: 68px;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 2px solid #bbb2b4;
  border-radius: 50%;
  color: #fff;
  background: #fff;
}

.timeline-dot svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.timeline-item.done .timeline-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.timeline-item.current .timeline-dot {
  border-color: var(--accent);
}

.timeline-item.current .timeline-dot::after {
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 50%;
  background: var(--accent);
}

.timeline-copy {
  padding: 1px 0 18px;
}

.timeline-copy h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.timeline-item.current .timeline-copy h3 {
  color: var(--accent);
}

.timeline-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.task-actions {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.danger-zone {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.danger-zone .button {
  width: 100%;
}

.danger-zone p {
  margin: 10px 8px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.task-list button {
  display: grid;
  width: 100%;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  background: transparent;
}

.task-list img {
  width: 58px;
  height: 68px;
  object-fit: cover;
  border-radius: 9px;
  background: var(--surface);
}

.task-list h3 {
  margin: 0 0 5px;
  font-size: 14px;
}

.task-list p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.task-status {
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.settings-group {
  margin-bottom: 28px;
}

.settings-group h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
}

.setting-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.setting-row small {
  display: block;
  max-width: 290px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 30px;
}

.switch input {
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: #d5ced0;
  transition: 160ms ease;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  content: "";
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(39, 25, 29, 0.2);
  transition: 160ms ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.switch input:disabled + span {
  opacity: 0.5;
}

.field {
  width: 132px;
  min-height: 42px;
  padding: 0 11px;
  text-align: right;
  border: 1px solid #cfc7c9;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

.empty-state,
.error-state,
.loading-screen {
  display: grid;
  min-height: 70vh;
  padding: 40px 24px;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.empty-state h2,
.error-state h2 {
  margin: 14px 0 8px;
  font-size: 20px;
}

.empty-state p,
.error-state p,
.loading-screen p {
  max-width: 320px;
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.state-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
}

.state-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.loading-mark {
  width: 28px;
  height: 28px;
  margin-bottom: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 520px;
  margin: auto;
  padding: 13px 16px;
  color: #fff;
  border-radius: 12px;
  background: #2c2526;
  box-shadow: 0 12px 28px rgba(40, 25, 30, 0.22);
  font-size: 13px;
  line-height: 1.45;
  animation: toast-in 180ms ease-out;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (min-width: 700px) {
  body {
    background: #f2eeef;
  }

  .app-shell {
    min-height: calc(100vh - 32px);
    margin-top: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 18px 56px rgba(50, 31, 37, 0.1);
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
