:root {
  color-scheme: light;
  --background: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #17243c;
  --muted: #66758d;
  --line: #dfe6f0;
  --accent: #3468d4;
  --accent-hover: #3a55c4;
  --success: #13795b;
  --success-soft: #e8f6f1;
  --danger: #bd3d56;
  --danger-soft: #fff0f3;
  --focus: rgba(73, 103, 220, .2);
  --shadow: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

.portal-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 18px;
}

.query-card {
  width: min(560px, 100%);
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid rgba(223, 230, 240, .92);
  border-radius: 10px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  box-shadow: none;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: .04em;
}

.eyebrow,
.result-label {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -.025em;
}

h1 {
  font-size: clamp(24px, 6vw, 30px);
}

h2 {
  font-size: 17px;
}

.intro {
  margin: 24px 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

form label {
  display: inline-block;
  margin-bottom: 8px;
  color: #34445f;
  font-size: 14px;
  font-weight: 750;
}

.query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #ced8e7;
  border-radius: 6px;
  background: #fbfcfe;
  color: var(--text);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:hover {
  border-color: #b9c6da;
}

input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px var(--focus);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(189, 61, 86, .11);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 6px;
  font-weight: 800;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

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

.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: none;
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: #42516a;
}

.secondary-button:hover:not(:disabled) {
  background: #edf1f7;
}

.field-hint,
.status-message,
.expiry-message {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.field-hint {
  margin: 8px 0 0;
}

.status-message {
  min-height: 20px;
  margin: 14px 0 0;
}

.status-message.is-error {
  color: var(--danger);
  font-weight: 700;
}

.status-message.is-success {
  color: var(--success);
  font-weight: 700;
}

.result-panel {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #dce4f1;
  border-radius: 8px;
  background: var(--surface-soft);
}

.result-panel[hidden] {
  display: none;
}

.result-heading,
.countdown-row,
.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.validity-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.otp-code {
  display: block;
  margin: 22px 0 20px;
  color: #172d57;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(38px, 11vw, 54px);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  letter-spacing: .13em;
  line-height: 1;
  overflow-wrap: anywhere;
  text-align: center;
}

.countdown-row {
  color: var(--muted);
  font-size: 13px;
}

.countdown-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.countdown-track {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e2e8f1;
  appearance: none;
  -webkit-appearance: none;
}

.countdown-track::-webkit-progress-bar {
  border-radius: inherit;
  background: #e2e8f1;
}

.countdown-track::-webkit-progress-value {
  border-radius: inherit;
  background: linear-gradient(90deg, #4d6ce0, #2ea985);
  transition: inline-size .2s linear;
}

.countdown-track::-moz-progress-bar {
  border-radius: inherit;
  background: linear-gradient(90deg, #4d6ce0, #2ea985);
}

.expiry-message {
  min-height: 19px;
  margin: 9px 0 18px;
}

.result-actions {
  justify-content: flex-start;
}

.result-actions .primary-button {
  min-width: 132px;
}

.result-panel.is-expired {
  border-color: #ead6da;
  background: var(--danger-soft);
}

.result-panel.is-expired .validity-badge {
  background: #f5dce2;
  color: var(--danger);
}

.result-panel.is-expired .otp-code {
  color: #7d6870;
}

.result-panel.is-expired .countdown-track::-webkit-progress-value,
.result-panel.is-expired .countdown-track::-moz-progress-bar {
  background: var(--danger);
}

.result-panel.is-expired .expiry-message {
  color: var(--danger);
  font-weight: 750;
}

.clipboard-helper {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 520px) {
  .portal-shell {
    align-items: start;
    padding: 16px 12px;
  }

  .query-card {
    padding: 24px 18px;
    border-radius: 10px;
  }

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

  .query-row .primary-button,
  .result-actions .primary-button,
  .result-actions .secondary-button {
    width: 100%;
  }

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

  .otp-code {
    letter-spacing: .08em;
  }
}

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

/* Keep the result controls inside the card on the narrowest supported phones. */
@media (max-width: 380px) {
  .query-card,
  .result-panel {
    min-width: 0;
  }

  .result-panel {
    padding: 16px;
  }

  .result-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .result-actions .primary-button,
  .result-actions .secondary-button {
    width: 100%;
    min-width: 0;
  }
}
