/* ─── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: #0f0e1a;
  overflow-x: hidden;
}

/* ─── Animated background blobs ────────────────────────────── */
.background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: float 12s ease-in-out infinite;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #6c63ff, #3b82f6);
  top: -150px;
  left: -100px;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ec4899, #f97316);
  bottom: -120px;
  right: -80px;
  animation-delay: -6s;
}

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(30px) scale(1.05); }
}

/* ─── Layout ────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* ─── Header ────────────────────────────────────────────────── */
header {
  text-align: center;
  color: #fff;
}

.logo {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.4rem;
  filter: drop-shadow(0 4px 12px rgba(108, 99, 255, 0.5));
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.55);
}

/* ─── Card ──────────────────────────────────────────────────── */
.card {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ─── Currency row ──────────────────────────────────────────── */
.currency-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.85rem 1.1rem 0.75rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s, background 0.2s;
}

.currency-row:focus-within {
  border-color: rgba(108, 99, 255, 0.7);
  background: rgba(108, 99, 255, 0.08);
}

/* ─── Currency label (below the amount) ────────────────────── */
.currency-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.flag {
  font-size: 1.3rem;
  line-height: 1;
  user-select: none;
}

select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  /* show a subtle caret */
  padding-right: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}

select option {
  background: #1e1b33;
  color: #fff;
}

/* ─── Amount input ──────────────────────────────────────────── */
.amount-input {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 2.4rem;
  font-weight: 700;
  font-family: inherit;
  text-align: right;
  outline: none;
  line-height: 1.1;
}

.amount-input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

/* hide browser spinner arrows */
.amount-input::-webkit-inner-spin-button,
.amount-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.amount-input[type=number] { -moz-appearance: textfield; }

/* ─── Mid section (rate + swap) ─────────────────────────────── */
.mid-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.25rem;
}

.rate-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.rate-text {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.01em;
}

.stale-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 99px;
  background: rgba(249, 115, 22, 0.25);
  color: #f97316;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Swap button ───────────────────────────────────────────── */
.swap-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6c63ff, #3b82f6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.5);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.swap-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 28px rgba(108, 99, 255, 0.65);
}

.swap-btn:active {
  transform: scale(0.95);
}

.swap-btn.spin {
  animation: spin-once 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes spin-once {
  from { transform: rotate(0deg) scale(1.1); }
  to   { transform: rotate(180deg) scale(1); }
}

/* ─── Error message ─────────────────────────────────────────── */
.error-msg {
  margin-top: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 0.85rem;
  text-align: center;
}

/* ─── Loading shimmer on amount ─────────────────────────────── */
.amount-input.loading {
  opacity: 0.4;
  pointer-events: none;
}

/* ─── Footer ────────────────────────────────────────────────── */
.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.28);
  text-align: center;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 360px) {
  .amount-input { font-size: 1.9rem; }
  .flag         { font-size: 1.1rem; }
  select        { font-size: 0.8rem; }
}

/* ─── Safe area for iPhone notch / home bar ─────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  }
}
