:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --purple: #7c3aed;
  --blue: #0ea5e9;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Outfit, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.portal {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 9vh 18px 48px;
  position: relative;
  overflow-x: hidden;
}

.soft-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(124, 58, 237, 0.045), transparent 34%),
    radial-gradient(circle at 86% 78%, rgba(14, 165, 233, 0.045), transparent 35%),
    linear-gradient(rgba(15, 23, 42, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 44px 44px, 44px 44px;
}

.shell {
  width: min(100%, 540px);
  position: relative;
  z-index: 1;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
  transition: transform 0.35s ease, margin 0.35s ease;
}

.hero.compact {
  transform: scale(0.94);
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(42px, 10vw, 56px);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 800;
}

.load-panel {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-top: 20px;
}

.load-dots {
  display: grid;
  grid-template-columns: repeat(10, 6px);
  gap: 7px;
}

.load-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.load-dots.load-green span.active {
  background: var(--green);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.55);
}

.load-dots.load-yellow span.active {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.55);
}

.load-dots.load-red span.active {
  background: var(--red);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.55);
}

#loadText {
  color: #cbd5e1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
}

.query-panel {
  display: grid;
  gap: 15px;
}

.query-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 8px;
  display: flex;
  align-items: center;
  transition: border 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.query-box:focus-within {
  background: var(--surface);
  border-color: var(--purple);
  box-shadow: 0 18px 40px rgba(124, 58, 237, 0.12);
}

.query-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 12px 18px;
  font-size: 17px;
  font-weight: 600;
}

.query-box input::placeholder {
  color: #a8b3c4;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: white;
  background: var(--ink);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.icon-btn:hover,
.batch-link:hover,
.btn-submit:hover,
.download-btn:hover {
  transform: translateY(-1px);
}

.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.search-icon,
.search-icon::after {
  display: block;
  border: 2px solid currentColor;
}

.search-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  position: relative;
}

.search-icon::after {
  content: "";
  width: 7px;
  height: 0;
  border-width: 1px;
  position: absolute;
  right: -6px;
  bottom: -4px;
  transform: rotate(45deg);
}

.batch-link {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--faint);
  padding: 10px 23px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s ease, border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.batch-link:hover {
  color: var(--purple);
  border-color: #c4b5fd;
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.08);
}

.stack-icon,
.arrow-icon {
  width: 14px;
  height: 14px;
  position: relative;
  display: inline-block;
}

.stack-icon::before,
.stack-icon::after {
  content: "";
  position: absolute;
  inset: 2px 1px auto;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.stack-icon::after {
  top: 7px;
  opacity: 0.55;
}

.arrow-icon::before {
  content: "";
  position: absolute;
  inset: 4px 3px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}

.result-panel {
  margin-top: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid #f1f5f9;
  border-radius: 34px;
  box-shadow: var(--shadow);
  padding: 30px;
  overflow: hidden;
  position: relative;
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 12px;
  background: #f5f3ff;
  color: var(--purple);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.card h2,
.card h3 {
  margin: 12px 0 7px;
  line-height: 1.2;
  letter-spacing: 0;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.timeline {
  display: grid;
  gap: 0;
  margin: 24px 0 12px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 16px;
  padding-bottom: 22px;
  opacity: 0.32;
}

.timeline-item.done,
.timeline-item.current {
  opacity: 1;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 22px;
  bottom: 0;
  width: 2px;
  background: #eef2f7;
}

.timeline-item.done::before {
  background: var(--purple);
}

.timeline-item:last-child::before {
  display: none;
}

.dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #eef2f7;
  margin-top: 2px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 12px;
  z-index: 1;
}

.done .dot {
  background: var(--purple);
}

.current .dot {
  background: var(--ink);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
}

.info-grid {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.info-label {
  display: block;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.info-value {
  display: block;
  margin-top: 5px;
  font-weight: 800;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
}

.status-pill.success {
  color: var(--green);
  background: #f0fdf4;
}

.status-pill.pending {
  color: #0891b2;
  background: #ecfeff;
}

.status-pill.failed {
  color: var(--red);
  background: #fef2f2;
}

.code-highlight {
  color: var(--purple);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 31px;
  letter-spacing: 4px;
}

.download-row,
.card-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.download-btn,
.outline-btn,
.primary-btn {
  flex: 1;
  border: 0;
  border-radius: 16px;
  padding: 14px 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.download-btn {
  color: var(--green);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.outline-btn {
  color: var(--faint);
  background: var(--surface-soft);
}

.primary-btn {
  color: white;
  background: var(--ink);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(100%, 480px);
  border: 1px solid #f1f5f9;
  border-radius: 32px;
  background: white;
  box-shadow: 0 40px 80px rgba(15, 23, 42, 0.14);
  padding: 30px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.close-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  color: var(--faint);
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.modal-copy {
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.modal-input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  outline: 0;
  background: var(--surface-soft);
  padding: 15px 17px;
  color: var(--ink);
}

textarea {
  min-height: 150px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.token-preview {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-soft);
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
}

.token-preview.valid {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.token-preview.invalid {
  background: #fef2f2;
  border-color: #fecaca;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.btn-cancel,
.btn-submit {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 800;
  cursor: pointer;
}

.btn-cancel {
  flex: 1;
  color: var(--muted);
  background: #f1f5f9;
}

.btn-submit {
  flex: 2;
  color: white;
  background: var(--ink);
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 30;
  transform: translate(-50%, -16px);
  opacity: 0;
  pointer-events: none;
  background: var(--red);
  color: white;
  border-radius: 16px;
  padding: 12px 20px;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(239, 68, 68, 0.22);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 560px) {
  .portal {
    padding-top: 7vh;
  }

  .card,
  .modal {
    border-radius: 26px;
    padding: 24px;
  }

  .download-row,
  .card-actions,
  .modal-actions {
    flex-direction: column;
  }

  .query-box input {
    font-size: 15px;
    padding-left: 12px;
  }
}
