:root {
  --bg: #05070f;
  --bg-alt: #0a0e1c;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-solid: #10142a;
  --ink: #f4f5f7;
  --ink-soft: #9aa1b2;
  --ink-faint: #6b7182;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --blue: #2f56d9;
  --blue-soft: #7b95f2;
  --amber: #ff9548;
  --shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.65), 0 10px 24px -14px rgba(0, 0, 0, 0.5);
  --radius-lg: 24px;
  --radius-md: 14px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  font-size: 16px;
}

* { box-sizing: border-box; }

html { scrollbar-color: var(--blue) var(--bg); scrollbar-width: thin; }
::-webkit-scrollbar { width: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--blue); border-radius: 999px; border: 3px solid var(--bg); }
::selection { background: var(--blue); color: #fff; }

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

.glow {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  top: -260px;
  left: 50%;
  transform: translateX(-50%);
  width: min(2400px, 220vw);
  height: 1100px;
  opacity: 0.55;
  background:
    radial-gradient(circle at 50% 28%, rgba(47, 86, 217, 0.42), rgba(47, 86, 217, 0.16) 22%, transparent 46%),
    radial-gradient(ellipse 900px 700px at 50% 40%, rgba(47, 86, 217, 0.14), transparent 60%);
  animation: glow-pulse 10s var(--ease-out) infinite;
}
@keyframes glow-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.7; }
}
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */
.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  padding: 40px 24px 0;
  animation: fade-up 0.7s var(--ease-out) both;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(155deg, #1a1d27, #0b0c10);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  position: relative;
  box-shadow:
    0 6px 16px -6px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    -1px 0 0 0 rgba(255, 149, 72, 0.5),
    1px 0 0 0 rgba(61, 108, 255, 0.6);
}
.logo-word {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* ---------- hero intro ---------- */
.hero-intro {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 24px 8px;
  animation: fade-up 0.8s var(--ease-out) both;
  animation-delay: 0.06s;
}
.hero-intro h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4.6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  color: var(--ink);
}
.hero-intro h1 .accent {
  background: linear-gradient(120deg, var(--blue-soft), var(--blue) 75%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-intro p {
  margin: 16px 0 0;
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ---------- layout ---------- */
.hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 36px 20px 80px;
}

/* ---------- card ---------- */
.card {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 30px;
  animation: fade-up 0.8s var(--ease-out) both;
  animation-delay: 0.12s;
}

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}
.field-row .field { flex: 1; min-width: 0; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field label .optional {
  font-weight: 400;
  color: var(--ink-faint);
}

input, select {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  width: 100%;
  font-variant-numeric: tabular-nums;
  caret-color: var(--blue);
}
input::placeholder { color: var(--ink-faint); font-weight: 400; }
input:focus, select:focus {
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 4px rgba(61, 108, 255, 0.18);
}
select { appearance: auto; cursor: pointer; color-scheme: dark; }
select option { background: var(--panel-solid); color: var(--ink); }

.select-shell { position: relative; }
.flag-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 15px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  pointer-events: none;
  background: rgba(255, 255, 255, 0.06);
}
.select-shell select {
  appearance: none;
  -webkit-appearance: none;
  padding-left: 42px;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%237b95f2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

#swap-btn {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--blue-soft);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  margin-bottom: 2px;
  transition: transform 0.35s var(--ease-out), background 0.2s ease, border-color 0.2s ease;
}
#swap-btn:hover {
  background: rgba(61, 108, 255, 0.12);
  border-color: var(--blue);
}
#swap-btn.spin { transform: rotate(180deg); }

.compare-btn {
  width: 100%;
  margin-top: 4px;
  padding: 15px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #0a0b0e;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.25s ease, opacity 0.2s ease, background 0.2s ease;
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.6);
}
.compare-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}
.compare-btn:not(:disabled):hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 18px 36px -14px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(61, 108, 255, 0.18);
}
.compare-btn:not(:disabled):active { transform: translateY(0); }

.btn-spinner[hidden] { display: none; }
.btn-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  margin-left: 8px;
  border: 2px solid rgba(10, 11, 14, 0.25);
  border-top-color: #0a0b0e;
  border-radius: 50%;
  vertical-align: -3px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  margin: 14px 0 0;
  color: #ffb4bd;
  background: rgba(255, 90, 110, 0.1);
  border: 1px solid rgba(255, 90, 110, 0.28);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

/* ---------- results ---------- */
.result {
  width: 100%;
  max-width: 440px;
}
.result-card {
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 30px 32px;
  animation: reveal 0.55s var(--ease-out) both;
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat { flex: 1; text-align: center; }
.stat-vs {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-weight: 600;
}
.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.spread-headline {
  text-align: center;
  margin: 24px 0 6px;
}
.spread-number {
  display: block;
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(120deg, var(--blue-soft), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.spread-caption {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.meter { margin: 20px 0 4px; }
.meter-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: visible;
}
.meter-track::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--blue-soft) 45%, var(--amber) 100%);
  opacity: 0.9;
}
.meter-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bg);
  transform: translate(-50%, -50%);
  transition: left 0.9s var(--ease-out);
  box-shadow: 0 0 0 1px var(--border-strong), 0 4px 12px rgba(0, 0, 0, 0.5);
}
.meter-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 8px;
}

.cost-sentence {
  margin: 22px 0 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
}
.cost-sentence strong { color: var(--blue-soft); font-weight: 700; }

.rate-date-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ---------- footer ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 24px 48px;
  color: var(--ink-faint);
  font-size: 0.78rem;
  max-width: 560px;
  margin: 0 auto;
}
.credit-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  transition: color 0.2s ease;
}
.credit-link:hover { color: var(--blue-soft); }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 520px) {
  .card, .result-card { padding: 22px 20px; }
  .logo-word { font-size: 1.1rem; }
}
