@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --page: #f4f7f5;
  --surface: #ffffff;
  --surface-muted: #f6f8f7;
  --text: #10231c;
  --muted: #60716a;
  --subtle: #86938e;
  --border: #dce4e0;
  --border-strong: #b8c7c0;
  --green: #16815f;
  --green-dark: #0c5f45;
  --green-soft: #e3f4ed;
  --danger: #b42318;
  --shadow: 0 22px 60px rgba(26, 58, 47, .10), 0 2px 8px rgba(26, 58, 47, .05);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0, rgba(38, 161, 123, .10), transparent 34rem),
    var(--page);
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.shell {
  width: min(100% - 32px, 720px);
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  inset-block-start: 8px;
  inset-inline-start: -999px;
  z-index: 20;
  padding: 8px 14px;
  border-radius: 10px;
  color: #fff;
  background: var(--green-dark);
  text-decoration: none;
}

.skip-link:focus { inset-inline-start: 8px; }

.site-header { padding-block: 22px 12px; }

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #fff;
}

.brand-mark svg {
  display: block;
  width: 40px;
  height: 40px;
  stroke: none;
  shape-rendering: geometricPrecision;
}

.refresh-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, .75);
  cursor: pointer;
  transition: border-color .18s, color .18s, transform .18s, background .18s;
}

.refresh-button:hover { color: var(--green-dark); border-color: var(--border-strong); background: #fff; }
.refresh-button:active { transform: scale(.94); }
.refresh-button.loading svg { animation: spin .75s linear infinite; }
.refresh-button:focus-visible, .swap-button:focus-visible, .currency-badge:focus-visible,
.dialog-close:focus-visible, .asset-option:focus-visible, input:focus-visible {
  outline: 3px solid rgba(22, 129, 95, .20);
  outline-offset: 2px;
}

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

.page-main { padding: 50px 0 72px; }

.intro {
  max-width: 620px;
  margin: 0 auto 28px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 700;
}

.intro h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 54px);
  line-height: 1.25;
  letter-spacing: -.035em;
}

.intro-copy {
  max-width: 540px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 16px;
}

.converter-card {
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(184, 199, 192, .75);
  border-radius: 28px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.rate-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 16px;
  margin-bottom: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.rate-value {
  grid-column: 1;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.35;
  letter-spacing: -.02em;
}

.rate-status {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.rate-status.error { color: var(--danger); }
.rate-status.error .status-dot { background: var(--danger); box-shadow: 0 0 0 4px #fee4e2; }

.currency-field label {
  display: inline-block;
  margin: 0 8px 8px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-control {
  display: flex;
  flex-direction: row-reverse;
  min-height: 92px;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  transition: border-color .18s, box-shadow .18s, background .18s;
}

.field-control:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 129, 95, .10);
}

.output-control { background: var(--surface-muted); }

.field-control input {
  width: 100%;
  min-width: 0;
  padding: 8px 4px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: clamp(25px, 6vw, 34px);
  font-weight: 700;
  line-height: 1.2;
  direction: ltr;
  text-align: left;
  letter-spacing: -.02em;
}

.field-control input::placeholder { color: var(--subtle); }

.currency-badge {
  display: flex;
  min-width: 132px;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  user-select: none;
  cursor: pointer;
  text-align: start;
  transition: background .18s;
}

.currency-badge:hover { background: var(--surface-muted); }

.currency-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  overflow: hidden;
  background: #eef4f1;
}

.currency-icon img { width: 100%; height: 100%; object-fit: cover; }
.currency-icon.letter-icon { color: var(--green-dark); background: var(--green-soft); font-size: 12px; direction: ltr; }

.currency-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.currency-text strong { font-size: 15px; direction: ltr; }
.currency-text small { color: var(--muted); font-size: 12px; }

.currency-chevron {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--subtle);
}

.currency-chevron svg { width: 17px; height: 17px; stroke-width: 2; }

.swap-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}

.swap-divider > span { height: 1px; flex: 1; background: var(--border); }

.swap-button {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--green-dark);
  background: #fff;
  box-shadow: 0 5px 14px rgba(26, 58, 47, .10);
  cursor: pointer;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), background .18s, border-color .18s;
}

.swap-button:hover { border-color: var(--green); background: var(--green-soft); }
.swap-button:active { transform: scale(.92); }
.swap-button.turned { transform: rotate(180deg); }

.dialog-open { overflow: hidden; }

.asset-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.asset-dialog[hidden] { display: none; }

.asset-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 28, 21, .48);
  backdrop-filter: blur(4px);
}

.asset-dialog-panel {
  position: relative;
  display: flex;
  width: min(100%, 520px);
  max-height: min(720px, calc(100dvh - 48px));
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(8, 28, 21, .24);
}

.asset-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.asset-dialog-head h2 { margin: 0; font-size: 22px; }
.asset-dialog-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
}

.asset-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 12px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  color: var(--subtle);
  background: var(--surface-muted);
}

.asset-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 4px rgba(22, 129, 95, .10); }
.asset-search svg { width: 19px; height: 19px; flex: 0 0 auto; }

.asset-search input {
  width: 100%;
  padding: 13px 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.asset-list {
  min-height: 100px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.asset-option {
  display: grid;
  width: 100%;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  text-align: right;
}

.asset-option:hover, .asset-option[aria-selected="true"] { background: var(--green-soft); }
.asset-option-icon { width: 40px; height: 40px; }

.asset-option-label { display: flex; min-width: 0; flex-direction: column; line-height: 1.35; }
.asset-option-label strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.asset-option-label small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.asset-option-code { color: var(--muted); font-size: 13px; direction: ltr; }
.asset-empty { margin: 28px 0; color: var(--muted); text-align: center; }

@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 720px); }
  .site-header { padding-top: 16px; }
  .page-main { padding-top: 28px; padding-bottom: 40px; }
  .intro { margin-bottom: 22px; }
  .intro-copy { font-size: 14px; }
  .converter-card { border-radius: 22px; }
  .rate-summary { grid-template-columns: 1fr; align-items: start; }
  .rate-value { grid-column: 1; }
  .rate-status { grid-column: 1; grid-row: auto; margin-top: 8px; }
  .field-control { min-height: 82px; gap: 8px; padding-inline: 9px; }
  .currency-badge { min-width: 106px; gap: 7px; padding: 7px 8px; }
  .currency-icon { width: 32px; height: 32px; font-size: 17px; }
  .currency-text strong { font-size: 13px; }
  .currency-text small { font-size: 11px; }
  .swap-divider { padding-inline: 8px; }
  .asset-dialog { align-items: end; padding: 0; }
  .asset-dialog-panel {
    width: 100%;
    max-height: min(82dvh, 720px);
    padding: 20px 16px max(18px, env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
  }
}

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