:root {
  color-scheme: light;
  --ink: #10283d;
  --ink-soft: #526574;
  --navy: #0b2a43;
  --marine: #176b87;
  --marine-dark: #0e536d;
  --mint: #248a78;
  --mint-soft: #dff1ec;
  --coral: #dd5a42;
  --canvas: #eef4f5;
  --surface: #ffffff;
  --line: #cddadd;
  --line-strong: #aebfc4;
  --focus: #f09a33;
  --shadow: 0 18px 45px rgba(11, 42, 67, 0.1);
  font-family:
    "Aptos", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.55rem;
  color: #fff;
  background: var(--navy);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100% - 2rem, 46rem);
  margin-inline: auto;
  padding: 1.25rem 0 3rem;
}

.top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.home-link,
.settings-summary {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  color: var(--ink);
  background: transparent;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.home-link:hover,
.settings-summary:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.settings {
  position: relative;
}

.settings-summary {
  list-style: none;
}

.settings-summary::-webkit-details-marker {
  display: none;
}

.settings-summary::before {
  content: "⚙";
  color: var(--marine);
  font-size: 1rem;
}

.settings-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: min(18rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-panel label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-panel select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 2.2rem 0.55rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.55rem;
  color: var(--ink);
  background: var(--surface);
}

.settings-panel p {
  display: flex;
  justify-content: space-between;
  margin: 0.8rem 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.hero {
  padding: 2.25rem 0 1.4rem;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.65rem;
  color: var(--marine-dark);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-meta::before {
  width: 1.6rem;
  height: 0.25rem;
  border-radius: 999px;
  background: var(--coral);
  content: "";
}

.hero h1 {
  max-width: 14ch;
  margin: 0;
  font-family:
    "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  font-size: clamp(2rem, 7vw, 3.35rem);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.02;
}

.hero p:last-child {
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-size: clamp(0.95rem, 2.4vw, 1.08rem);
}

.converter-panel {
  position: relative;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-top: 0.32rem solid var(--marine);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.rate-status {
  display: flex;
  min-height: 1.85rem;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 650;
}

.status-dot {
  width: 0.58rem;
  height: 0.58rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0.25rem var(--mint-soft);
}

.rate-status[data-source="loading"] .status-dot {
  background: var(--focus);
  box-shadow: 0 0 0 0.25rem #fff0da;
  animation: status-pulse 1.2s ease-in-out infinite;
}

.rate-status[data-source="fallback"] .status-dot {
  background: var(--coral);
  box-shadow: 0 0 0 0.25rem #fbe6e1;
}

@keyframes status-pulse {
  50% {
    opacity: 0.4;
    transform: scale(0.78);
  }
}

.field-label,
.section-label {
  display: block;
  margin: 0 0 0.45rem;
  color: var(--ink-soft);
  font-size: 0.77rem;
  font-weight: 850;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.money-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(12rem, 0.78fr);
  gap: 0.65rem;
}

.amount-input,
.currency-select {
  width: 100%;
  min-width: 0;
  height: 3.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.72rem;
  color: var(--ink);
  background: #fbfdfd;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.amount-input {
  padding: 0.5rem 0.85rem;
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  font-weight: 740;
  font-variant-numeric: tabular-nums;
}

.amount-input::placeholder {
  color: #83929a;
  font-weight: 500;
}

.currency-select {
  padding: 0.55rem 2.2rem 0.55rem 0.8rem;
  font-weight: 700;
  text-overflow: ellipsis;
}

.amount-input:hover,
.currency-select:hover {
  border-color: var(--marine);
  background: #fff;
}

.field-error {
  min-height: 1.35rem;
  margin: 0.35rem 0 0;
  color: #a43725;
  font-size: 0.82rem;
  font-weight: 650;
}

.field-error:empty {
  visibility: hidden;
}

.swap-rail {
  position: relative;
  display: grid;
  height: 3.15rem;
  place-items: center;
}

.swap-rail::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--line);
  content: "";
}

.swap-button {
  position: relative;
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  place-items: center;
  color: #fff;
  background: var(--marine);
  box-shadow: 0 0 0 1px var(--marine);
  transition:
    transform 180ms ease,
    background-color 180ms ease;
}

.swap-button:hover {
  background: var(--marine-dark);
  transform: translateY(-1px);
}

.swap-button.is-swapping {
  transform: rotate(180deg);
}

.target-field {
  margin-bottom: 0.8rem;
}

.target-field .currency-select {
  background: var(--surface);
}

.result-panel {
  position: relative;
  min-height: 7.25rem;
  padding: 1rem 1.1rem;
  overflow: hidden;
  border-radius: 0.82rem;
  color: #fff;
  background: var(--navy);
}

.result-panel::after {
  position: absolute;
  right: -1.8rem;
  bottom: -2.7rem;
  width: 7rem;
  height: 7rem;
  border: 1.2rem solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.result-label {
  display: block;
  margin-bottom: 0.3rem;
  color: #bdd4dd;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-output {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-family:
    "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-line {
  position: relative;
  z-index: 1;
  margin: 0.38rem 0 0;
  color: #bdd4dd;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.quick-amounts {
  margin-top: 1rem;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
}

.quick-button {
  min-width: 0;
  min-height: 2.5rem;
  padding: 0.35rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  color: var(--marine-dark);
  background: #f5f9f9;
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.quick-button:hover,
.quick-button[aria-pressed="true"] {
  border-color: var(--marine);
  color: #fff;
  background: var(--marine);
}

.popular-section {
  margin-top: 1.4rem;
  padding: 1.2rem 0 0;
  border-top: 1px solid var(--line);
}

.popular-section h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.popular-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.popular-button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  min-width: 0;
  min-height: 3.55rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease;
}

.popular-button:hover,
.popular-button[aria-current="true"] {
  border-color: var(--marine);
  background: var(--surface);
  transform: translateY(-1px);
}

.popular-flag {
  font-size: 1.3rem;
}

.popular-code {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popular-rate {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.app-notes {
  margin-top: 1.25rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.app-notes p {
  margin: 0.35rem 0;
}

.provider-link {
  color: var(--marine-dark);
  font-weight: 750;
  text-underline-offset: 0.2em;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.amount-input:focus-visible,
.currency-select:focus-visible,
.settings-panel select:focus-visible {
  border-color: var(--marine);
  outline: 3px solid rgba(240, 154, 51, 0.45);
  outline-offset: 1px;
  box-shadow: 0 0 0 1px var(--marine);
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 1.25rem, 46rem);
    padding-top: 0.55rem;
  }

  .top-bar {
    min-height: 2.5rem;
  }

  .home-link,
  .settings-summary {
    min-height: 2.5rem;
    padding: 0.4rem 0.55rem;
  }

  .hero {
    padding: 1rem 0 0.8rem;
  }

  .hero-meta {
    margin-bottom: 0.42rem;
    font-size: 0.7rem;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(1.75rem, 9vw, 2.25rem);
  }

  .hero p:last-child {
    margin-top: 0.35rem;
    font-size: 0.9rem;
  }

  .converter-panel {
    padding: 0.8rem;
    border-radius: 0.8rem;
  }

  .rate-status {
    min-height: 1.5rem;
    margin-bottom: 0.65rem;
    font-size: 0.74rem;
  }

  .money-entry {
    grid-template-columns: minmax(0, 1fr) minmax(7.6rem, 0.72fr);
    gap: 0.45rem;
  }

  .amount-input,
  .currency-select {
    height: 3.35rem;
  }

  .amount-input {
    padding-inline: 0.65rem;
    font-size: 1.3rem;
  }

  .currency-select {
    padding-left: 0.55rem;
    font-size: 0.88rem;
  }

  .field-error {
    min-height: 1.1rem;
    margin-top: 0.2rem;
    font-size: 0.74rem;
  }

  .swap-rail {
    height: 2.55rem;
  }

  .swap-button {
    width: 2.25rem;
    height: 2.25rem;
  }

  .target-field {
    margin-bottom: 0.55rem;
  }

  .result-panel {
    min-height: 6rem;
    padding: 0.78rem 0.85rem;
  }

  .result-output {
    font-size: clamp(1.8rem, 10vw, 2.4rem);
  }

  .rate-line {
    margin-top: 0.2rem;
    font-size: 0.76rem;
  }

  .quick-amounts {
    margin-top: 0.7rem;
  }

  .quick-grid {
    gap: 0.3rem;
  }

  .quick-button {
    min-height: 2.25rem;
    font-size: 0.73rem;
  }

  .popular-grid {
    gap: 0.45rem;
  }

  .popular-button {
    grid-template-columns: auto 1fr;
    gap: 0.4rem;
    padding: 0.55rem 0.6rem;
  }

  .popular-rate {
    grid-column: 2;
    text-align: left;
  }
}

@media (max-width: 350px) {
  .money-entry {
    grid-template-columns: minmax(0, 1fr) 7rem;
  }

  .popular-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .app-shell {
    width: min(100% - 1.25rem, 46rem);
    padding-top: 0.35rem;
  }

  .hero {
    display: flex;
    align-items: baseline;
    gap: 0.8rem;
    padding: 0.25rem 0 0.45rem;
  }

  .hero-meta {
    display: none;
  }

  .hero h1 {
    max-width: none;
    font-size: 1.55rem;
  }

  .hero p:last-child {
    margin: 0;
    font-size: 0.82rem;
  }

  .converter-panel {
    padding: 0.7rem;
  }

  .rate-status,
  .quick-amounts {
    margin-top: 0;
    margin-bottom: 0.45rem;
  }

  .amount-input,
  .currency-select {
    height: 3rem;
  }

  .swap-rail {
    height: 2.2rem;
  }

  .swap-button {
    width: 2rem;
    height: 2rem;
  }

  .result-panel {
    min-height: 5.25rem;
    padding: 0.6rem 0.8rem;
  }

  .result-output {
    font-size: 1.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
