:root {
  --font: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --num-font: "Cairo", "Segoe UI", Arial, sans-serif;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --appbar-h: 60px;
  --bottomnav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shell: min(1120px, calc(100% - 24px));
}

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --bg-glow-1: rgba(56, 189, 248, 0.16);
  --bg-glow-2: rgba(251, 191, 36, 0.08);
  --surface: #0d1b2e;
  --surface-2: #12243b;
  --text: #f8fafc;
  --muted: #9fb0c7;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #38bdf8;
  --accent-ink: #03101c;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --euro: #a78bfa;
  --euro-soft: rgba(167, 139, 250, 0.16);
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.16);
  --silver: #cbd5e1;
  --silver-soft: rgba(203, 213, 225, 0.14);
  --danger: #fb7185;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --bar-bg: rgba(7, 17, 31, 0.82);
  --skeleton: rgba(255, 255, 255, 0.08);
  --skeleton-hi: rgba(255, 255, 255, 0.18);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-glow-1: rgba(2, 132, 199, 0.1);
  --bg-glow-2: rgba(217, 119, 6, 0.07);
  --surface: #ffffff;
  --surface-2: #f1f5fa;
  --text: #0f172a;
  --muted: #56657b;
  --line: rgba(15, 23, 42, 0.1);
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --euro: #7c3aed;
  --euro-soft: rgba(124, 58, 237, 0.1);
  --gold: #b45309;
  --gold-soft: rgba(217, 119, 6, 0.12);
  --silver: #475569;
  --silver-soft: rgba(71, 85, 105, 0.1);
  --danger: #e11d48;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  --bar-bg: rgba(243, 246, 251, 0.86);
  --skeleton: rgba(15, 23, 42, 0.06);
  --skeleton-hi: rgba(15, 23, 42, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--appbar-h) + var(--safe-top) + 12px);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom));
  background:
    radial-gradient(circle at 15% 0%, var(--bg-glow-1), transparent 30rem),
    radial-gradient(circle at 90% 100%, var(--bg-glow-2), transparent 28rem),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  text-align: start;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s ease, color 0.25s ease;
}

html[lang="ur"] body {
  line-height: 2;
}

.hidden {
  display: none !important;
}

noscript {
  display: block;
  width: var(--shell);
  margin: 12px auto 0;
  color: var(--muted);
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
.rate-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* App bar */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: var(--safe-top);
  border-bottom: 1px solid var(--line);
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
}

.app-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: var(--shell);
  height: var(--appbar-h);
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-inline-end: auto;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--num-font);
  font-weight: 900;
}

.app-bar-nav {
  display: none;
  gap: 4px;
}

.app-bar-nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.app-bar-nav a:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.app-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon-btn-plain {
  border-color: transparent;
  background: transparent;
  font-size: 1.4rem;
}

:root[data-theme="dark"] .icon-moon,
:root[data-theme="light"] .icon-sun {
  display: none;
}

.lang-current {
  font-family: var(--num-font);
}

/* Language menu */
.lang-menu {
  position: relative;
}

.lang-menu > summary {
  list-style: none;
}

.lang-menu > summary::-webkit-details-marker {
  display: none;
}

.lang-list {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 40;
  min-width: 190px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  list-style: none;
}

.lang-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
}

.lang-list a:hover {
  background: var(--accent-soft);
}

.lang-list a[aria-current="true"] {
  color: var(--accent);
}

.lang-code {
  color: var(--muted);
  font-family: var(--num-font);
  font-size: 0.72rem;
  font-weight: 700;
}

/* Language suggestion banner */
.lang-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: var(--shell);
  margin: 12px auto 0;
  padding: 8px;
  padding-inline-start: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.lang-banner p {
  flex: 1;
  margin: 0;
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.btn svg {
  width: 16px;
  height: 16px;
}

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

.btn-ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.85rem;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn:disabled .btn-spinner {
  display: inline-block;
}

.alerts-btn[data-state="on"] {
  border-color: var(--accent);
  color: var(--accent);
}

.alerts-btn[data-state="blocked"] {
  border-style: dashed;
  color: var(--muted);
}

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

/* Page */
.page-shell {
  width: var(--shell);
  margin: 0 auto;
  padding: 20px 0 32px;
}

.hero {
  padding: 4px 0 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 5.5vw, 3.2rem);
  font-weight: 900;
  line-height: 1.25;
}

html[lang="ur"] h1 {
  line-height: 1.8;
}

.subtitle {
  max-width: 70ch;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  line-height: 1.7;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 8px;
  padding-inline-start: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  transition: opacity 0.4s ease;
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--accent);
}

.status.fade-out {
  opacity: 0;
}

.toolbar-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

/* Rates: list rows on phones */
.rates {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.rate-card {
  --tone: var(--accent);
  --tone-soft: var(--accent-soft);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.25s ease;
}

.rate-card:hover {
  border-color: var(--tone);
}

.rate-card:active {
  transform: scale(0.985);
}

.rate-card.euro {
  --tone: var(--euro);
  --tone-soft: var(--euro-soft);
}

.rate-card.gold {
  --tone: var(--gold);
  --tone-soft: var(--gold-soft);
}

.rate-card.silver {
  --tone: var(--silver);
  --tone-soft: var(--silver-soft);
}

.rate-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--tone-soft);
  color: var(--tone);
  font-family: var(--num-font);
  font-size: 1.05rem;
  font-weight: 900;
}

.rate-label {
  display: block;
  color: var(--tone);
  font-size: 0.75rem;
  font-weight: 800;
}

.rate-title {
  overflow: hidden;
  margin: 1px 0 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-unit {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-value {
  min-width: 4ch;
  margin: 0;
  font-family: var(--num-font);
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-align: end;
  white-space: nowrap;
}

.rate-value.unavailable {
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0;
}

.rate-value.skeleton {
  width: 5.5ch;
  height: 1.3em;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-hi) 50%, var(--skeleton) 100%);
  background-size: 200% 100%;
  color: transparent;
  animation: shimmer 1.4s ease-in-out infinite;
}

.rate-chevron {
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.updated-at {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Content */
.content-section {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.content-section h2 {
  margin: 0 0 10px;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 800;
  line-height: 1.4;
}

.content-section > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.85;
}

html[lang="ur"] .content-section > p,
html[lang="ur"] .faq-item p {
  line-height: 2.2;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

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

.faq-item summary::after {
  content: "+";
  flex-shrink: 0;
  color: var(--accent);
  font-family: var(--num-font);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  transform: rotate(45deg);
}

.faq-item h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.faq-item p {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--muted);
  line-height: 1.85;
}

/* Footer */
.site-footer {
  margin-top: 28px;
  padding: 20px 4px 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.footer-brand {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
}

.footer-nav,
.footer-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.footer-nav a,
.footer-langs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.footer-nav a:hover,
.footer-langs a:hover {
  text-decoration: underline;
}

.footer-langs .lang-code {
  display: none;
}

.footer-langs-title {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.footer-note {
  margin: 0;
  font-size: 0.85rem;
}

/* Detail view */
.detail-view {
  width: min(720px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 32px;
  animation: sheet-in 0.22s ease;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-title {
  margin: 0;
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  font-weight: 900;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-label {
  color: var(--muted);
  font-weight: 700;
}

.detail-value {
  font-family: var(--num-font);
  font-size: 1.3rem;
  font-weight: 900;
  white-space: nowrap;
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Bottom tab bar (phones) */
.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--line);
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item[aria-current="page"],
.nav-item[data-state="on"] {
  color: var(--accent);
}

.nav-item:disabled {
  cursor: default;
  opacity: 0.5;
}

@media (max-width: 600px) {
  .toolbar {
    flex-wrap: wrap;
    padding-inline-start: 8px;
  }

  .status {
    flex-basis: 100%;
    max-height: 8em;
    overflow: hidden;
    padding-inline: 6px;
    transition: opacity 0.4s ease, max-height 0.4s ease;
  }

  .status.fade-out {
    max-height: 0;
  }

  .toolbar:has(.status.fade-out) {
    row-gap: 0;
  }

  .toolbar-actions {
    flex: 1;
  }

  .toolbar-actions .btn {
    flex: 1;
  }
}

@media (min-width: 720px) {
  .rates {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .rate-card {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "icon info chevron"
      "value value value";
    align-content: space-between;
    min-height: 190px;
    padding: 20px;
  }

  .rate-card:hover {
    transform: translateY(-3px);
  }

  .rate-icon {
    grid-area: icon;
  }

  .rate-info {
    grid-area: info;
  }

  .rate-chevron {
    grid-area: chevron;
    align-self: start;
  }

  .rate-title,
  .rate-unit {
    white-space: normal;
  }

  .rate-value {
    grid-area: value;
    margin-top: 18px;
    font-size: clamp(2rem, 3.4vw, 2.8rem);
    text-align: start;
  }

  .rate-value.unavailable {
    font-size: 1rem;
  }

  .content-section {
    padding: 28px;
  }
}

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
  }

  .bottom-nav {
    display: none;
  }

  .app-bar-nav {
    display: flex;
  }

  .page-shell {
    padding-top: 36px;
  }
}

@media (min-width: 1100px) {
  .rates {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .brand-name {
    font-size: 1rem;
  }

  .rate-value {
    font-size: 1.25rem;
  }
}

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

  .rate-value.skeleton {
    background: var(--skeleton-hi);
  }
}
