:root {
  color-scheme: only light;
  --canvas: #f2f5f4;
  --surface: #ffffff;
  --ink: #17201e;
  --muted: #66736f;
  --line: #d7dfdc;
  --green: #17675f;
  --green-dark: #0f4e48;
  --amber: #a96314;
  --danger: #aa3b35;
  --focus: rgba(23, 103, 95, 0.2);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.query-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  margin-bottom: 28px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 680;
}

.service-state {
  flex: 0 0 auto;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 650;
}

.service-state::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: 1px;
}

.query-band {
  padding: 22px 0 26px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.query-form {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.query-field {
  min-width: 0;
}

.query-field input {
  width: 100%;
  height: 54px;
  border: 1px solid #aebbb7;
  border-radius: 7px;
  padding: 0 48px 0 16px;
  background: var(--surface);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 17px;
  text-transform: uppercase;
  outline: none;
}

.query-field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--focus);
}

.query-field input:disabled {
  background: #e6ebe9;
  color: #59645f;
  cursor: wait;
}

.clear-button {
  position: absolute;
  top: 7px;
  right: 109px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.clear-button:hover,
.clear-button:focus-visible {
  background: #edf1f0;
  color: var(--ink);
}

.query-button {
  height: 54px;
  border: 0;
  border-radius: 7px;
  background: var(--green);
  color: #ffffff;
  font-weight: 680;
  cursor: pointer;
}

.query-button:hover {
  background: var(--green-dark);
}

.query-button:focus-visible,
.clear-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.query-button:disabled {
  background: #83938e;
  cursor: wait;
}

.status-text {
  min-height: 22px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.status-text[data-state="success"] {
  color: var(--green-dark);
}

.status-text[data-state="loading"] {
  color: var(--amber);
}

.status-text[data-state="error"] {
  color: var(--danger);
}

.voucher-stage {
  position: relative;
  min-height: min(640px, calc(100vh - 240px));
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.voucher-stage::before {
  content: "凭证";
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  min-width: 58px;
  padding: 7px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #eef3f1;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  min-height: inherit;
  display: grid;
  place-items: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

#voucherFrame {
  display: block;
  width: 100%;
  min-height: min(720px, calc(100vh - 220px));
  margin-top: 32px;
  border: 0;
  background: #ffffff;
}

#voucherFrame[hidden],
.empty-state[hidden],
.clear-button[hidden] {
  display: none;
}

@media (max-width: 620px) {
  .query-shell {
    padding: 20px 14px 18px;
  }

  .page-header {
    align-items: flex-start;
    margin-bottom: 20px;
  }

  .page-header h1 {
    max-width: 11em;
    font-size: 22px;
  }

  .query-band {
    padding: 18px 0 22px;
  }

  .query-form {
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 8px;
  }

  .query-field input,
  .query-button {
    height: 50px;
  }

  .query-field input {
    padding-left: 13px;
    /* iPhone Safari 对小于 16px 的输入框会自动缩放页面。 */
    font-size: 16px;
  }

  .clear-button {
    top: 5px;
    right: 91px;
  }

  .voucher-stage {
    min-height: calc(100vh - 230px);
    margin-top: 20px;
  }

  #voucherFrame {
    min-height: calc(100vh - 242px);
  }
}

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