:root {
  color-scheme: dark;
  --ink: #f5f6ee;
  --muted: #a5aca3;
  --canvas: #121713;
  --panel: #1a211c;
  --panel-2: #232c25;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #dfff53;
  --accent-ink: #172000;
  --error: #ff8f7d;
  font-family: "DM Sans", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 92% 10%, rgba(223, 255, 83, 0.10), transparent 25rem),
    var(--canvas);
  color: var(--ink);
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }

.shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar { display: flex; align-items: center; justify-content: space-between; }

.brand {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font: 800 20px/1 "Manrope", sans-serif;
  letter-spacing: -0.05em;
}

.brand-mark {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
}

.brand-mark svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #c4cac2;
  font-size: 12px;
  font-weight: 600;
}

.live-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(223, 255, 83, 0.09); }
.live-pill.cached span { background: #f7c85b; box-shadow: 0 0 0 4px rgba(247, 200, 91, 0.09); }
.live-pill.error span { background: var(--error); box-shadow: 0 0 0 4px rgba(255, 143, 125, 0.09); }

.intro { padding: clamp(56px, 11vh, 94px) 4px 34px; }
.eyebrow { margin: 0 0 14px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.18em; }
h1 { margin: 0; font: 700 clamp(43px, 12vw, 62px)/0.98 "Manrope", sans-serif; letter-spacing: -0.065em; }
h1 em { color: var(--accent); font-style: normal; }
.lede { margin: 18px 0 0; color: var(--muted); font-size: 15px; }

.converter { display: flex; flex-direction: column; }
.currency-card { border-radius: 22px; padding: 19px 20px 20px; }
.source-card { background: var(--panel); border: 1px solid var(--line); }
.result-card { background: var(--accent); color: var(--accent-ink); }
.card-label { margin-bottom: 15px; color: var(--muted); font-size: 12px; font-weight: 600; }
.result-card .card-label { color: rgba(23, 32, 0, 0.55); }
.result-header { min-height: 47px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-header .card-label { margin: 0; }

.currency-row { min-height: 53px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.amount-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.amount, .result { min-width: 0; width: 100%; border: 0; padding: 0; background: transparent; color: inherit; font: 700 clamp(30px, 9vw, 42px)/1 "Manrope", sans-serif; letter-spacing: -0.05em; }
.amount:focus { outline: 0; }
.amount::selection { background: var(--accent); color: var(--accent-ink); }
.result { white-space: nowrap; font-variant-numeric: tabular-nums; }
.result.compact { font-size: clamp(24px, 7.5vw, 34px); letter-spacing: -0.055em; }
.result.ultra-compact { font-size: clamp(18px, 5.8vw, 27px); letter-spacing: -0.04em; }
.currency-name { margin-top: 7px; font-size: 12px; font-weight: 600; color: rgba(23, 32, 0, 0.57); }
.input-error { min-height: 0; margin: 8px 0 0; color: var(--error); font-size: 12px; }
.input-error:empty { display: none; }

.select-wrap {
  position: relative;
  flex: 0 0 auto;
  height: 47px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel-2);
}

.select-wrap.light { border-color: rgba(23, 32, 0, 0.12); background: rgba(23, 32, 0, 0.09); }
.flag { font-size: 19px; line-height: 1; }
.currency-code { font-size: 14px; font-weight: 700; }
.select-wrap select { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.select-wrap:focus-within { outline: 2px solid rgba(223, 255, 83, 0.45); outline-offset: 2px; }
.select-wrap > :not(select) { pointer-events: none; }
.select-wrap svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.swap-line { height: 48px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.swap-line span { height: 1px; background: var(--line); }
.swap-button { width: 39px; height: 39px; border: 1px solid rgba(223, 255, 83, 0.35); border-radius: 50%; display: grid; place-items: center; background: #1d251f; color: var(--accent); transition: transform 180ms ease, background 180ms ease; }
.swap-button:hover { background: #273026; }
.swap-button:active { transform: rotate(180deg) scale(0.94); }
.swap-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.rate-card { margin-top: 12px; padding: 16px 18px; border-radius: 17px; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: rgba(255, 255, 255, 0.045); border: 1px solid var(--line); }
.rate-caption { display: block; margin-bottom: 4px; color: #7d857e; font-size: 9px; font-weight: 700; letter-spacing: 0.13em; }
.rate-card strong { font-size: 12px; font-weight: 600; }
.rate-meta { display: flex; align-items: center; gap: 8px; color: #7d857e; font-size: 10px; white-space: nowrap; }
.rate-meta button { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 9px; background: var(--panel-2); color: var(--muted); }
.rate-meta button:disabled { opacity: 0.45; cursor: wait; }
.rate-meta svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rate-meta button.loading svg { animation: spin 800ms linear infinite; }

.history-panel { margin-top: 12px; padding: 18px; border-radius: 19px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.history-eyebrow { display: block; margin-bottom: 4px; color: #707871; font-size: 9px; font-weight: 700; letter-spacing: 0.14em; }
.history-heading h2 { margin: 0; font: 700 15px/1.2 "Manrope", sans-serif; letter-spacing: -0.025em; }
.history-count { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 9px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); font-size: 11px; font-weight: 700; }
.history-list { margin-top: 14px; display: grid; gap: 8px; }
.history-empty { margin: 0; padding: 12px 0 2px; color: #6d746e; font-size: 12px; }
.history-item { padding: 13px 14px; border-radius: 14px; background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.06); }
.history-values { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 9px; font: 600 13px/1.25 "Manrope", sans-serif; }
.history-values span:first-child { min-width: 0; overflow-wrap: anywhere; color: #afb5ae; }
.history-values strong { min-width: 0; overflow-wrap: anywhere; text-align: right; color: var(--ink); }
.history-arrow { color: var(--accent); }
.history-pair { margin: 7px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #69716a; font-size: 9px; }

footer { margin-top: auto; padding-top: 38px; display: flex; justify-content: center; gap: 7px; color: #626963; font-size: 10px; }
footer a { color: inherit; text-underline-offset: 2px; }
footer a:hover { color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 600px) {
  .shell { padding-left: 28px; padding-right: 28px; }
}

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