[data-yen] { font-variant-numeric: tabular-nums; }
[data-yen]:empty, [data-yen][hidden] { display: none !important; }
.fx-inline { font-size: .88em; font-weight: 500; white-space: normal; }

button[data-currency-settings] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 7px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid #b9c6b8;
  border-radius: 7px;
  background: #f7f6ee;
  color: #2c5046;
  font: 700 13px/1 var(--font, system-ui);
  cursor: pointer;
}
button[data-currency-settings]:is(:hover, :focus-visible) { background: #e7ede2; }
.fx-code { letter-spacing: .035em; }

#currency-settings {
  --fx-ink: #172e32;
  --fx-muted: #53625b;
  --fx-line: #d8d7c9;
  --fx-accent: #25574a;
  --fx-pad: clamp(15px, 4vw, 24px);
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  width: min(420px, calc(100% - 26px));
  max-width: none;
  max-height: min(595px, calc(100dvh - 28px));
  overflow: hidden;
  color-scheme: light;
  color: var(--fx-ink);
  background: #fffbf2;
  border: 1px solid #cacdbd;
  border-radius: 15px;
  box-shadow: 0 20px 70px #0e202148;
  font: 500 16px/1.4 var(--font, system-ui);
}
#currency-settings[open] { display: flex; flex-direction: column; animation: fx-appear .16s ease-out; }
#currency-settings::backdrop { background: #101e2bb3; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
html:has(#currency-settings[open]) { overflow: hidden; }
@keyframes fx-appear { from { opacity: 0; transform: translateY(5px); } }
#currency-settings [hidden] { display: none !important; }
#currency-settings :is(button, a):focus-visible { outline: 2px solid var(--fx-accent); outline-offset: 2px; }
#currency-settings .fx-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex: none;
  gap: 10px;
  padding: var(--fx-pad) var(--fx-pad) 0;
}
#fx-title {
  margin: 0;
  padding: 0;
  font: 730 clamp(26px, 4vw, 31px)/1.07 var(--font, system-ui);
  letter-spacing: -.048em;
  color: var(--fx-ink);
  outline: none;
}
#fx-intro { margin: 8px 0 0; font-size: 14px; line-height: 1.4; color: var(--fx-muted); }
#currency-settings .fx-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--fx-line);
  border-radius: 50%;
  color: var(--fx-ink);
  background: transparent;
}
#currency-settings .fx-close:hover { background: #efede1; }
#currency-settings .fx-search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px var(--fx-pad) 10px;
  padding-inline: 12px;
  border: 1px solid #b5c1b5;
  border-radius: 7px;
  background: #fffdf7;
  color: var(--fx-accent);
}
#currency-settings .fx-search:focus-within { outline: 2px solid var(--fx-accent); outline-offset: 1px; }
#currency-settings input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fx-ink);
  font: 550 16px/1.35 var(--font, system-ui);
  outline: none;
}
#currency-settings input::placeholder { opacity: 1; color: var(--fx-muted); }
#fx-options {
  min-height: 0;
  height: min(282px, 45dvh);
  margin: 0 6px 0 0;
  padding: 0 calc(var(--fx-pad) - 6px) 10px var(--fx-pad);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b9c3b5 transparent;
}
#fx-options [role="option"] {
  display: grid;
  grid-template-columns: 47px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 5px 10px;
  border-radius: 5px;
  color: var(--fx-ink);
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}
.fx-iso {
  display: grid;
  place-items: center;
  height: 26px;
  background: #eceee5;
  color: #3c534a;
  border-radius: 4px;
  font: 700 12px/1 var(--label, ui-monospace, monospace);
  letter-spacing: .055em;
}
#fx-options [role="option"] svg { visibility: hidden; color: var(--fx-accent); }
#fx-options [aria-selected="true"] { color: #1b4a3d; font-weight: 750; }
#fx-options [aria-selected="true"] .fx-iso { background: #245247; color: #fff8e9; }
#fx-options [aria-selected="true"] svg { visibility: visible; }
#fx-options [role="option"]:hover, #fx-options .is-active { background: #e9efe4; }
#currency-settings .fx-empty { flex: 1; margin: 0; padding: 14px var(--fx-pad) 24px; color: var(--fx-muted); font-size: 15px; }
#fx-options:empty { height: 0; padding-bottom: 0; }
#currency-settings .fx-rate {
  display: flex;
  align-items: center;
  flex: none;
  gap: 10px;
  min-height: 58px;
  padding: 10px var(--fx-pad);
  border-top: 1px solid var(--fx-line);
  background: #f0f1e7;
  color: var(--fx-accent);
}
.fx-rate-info { display: grid; gap: 1px; }
.fx-rate-info [role="status"] { color: #34483e; font-weight: 650; font-size: 13px; }
.fx-rate-info a { color: #486354; font-size: 12px; text-underline-offset: 3px; }
.fx-rate-info a svg { display: inline; vertical-align: -.12em; }
#currency-settings .fx-retry {
  display: inline-flex; align-items: center; gap: 5px; min-height: 38px; margin-left: auto; padding: 0 3px;
  font: 700 13px var(--font, system-ui); color: var(--fx-accent); text-decoration: underline; text-underline-offset: 3px;
}
@media (max-height: 360px) {
  #currency-settings { --fx-pad: 12px; }
  #currency-settings .fx-search { margin-block: 9px 6px; }
}
@media (prefers-reduced-motion: reduce) { #currency-settings[open] { animation: none; } }
@media (forced-colors: active) {
  #fx-options .is-active { outline: 2px solid Highlight; outline-offset: -2px; }
}

@media (pointer: coarse) {
  button[data-currency-settings] { min-height: 44px; }
  #currency-settings .fx-close { width: 44px; height: 44px; }
}
#currency-settings[data-keyboard] {
  inset: calc(var(--dialog-visible-top) + 6px) 0 auto;
  margin: 0 auto;
  max-height: calc(var(--dialog-visible-height) - 12px);
}
#currency-settings[data-keyboard] #fx-options { height: auto; }
#currency-settings[data-keyboard-compact] :is(#fx-intro, .fx-rate) { display: none; }
#currency-settings[data-keyboard-compact] .fx-header { padding-top: 8px; }
#currency-settings[data-keyboard-compact] .fx-search { margin-block: 6px; }
