/* fxbyfox.com — currency converter. Mobile-first, app-like. Tokens follow byfox.dev */

:root {
  --bg: #0a0d10;
  --card: #151a1e;
  --card-2: #1c2227;
  --card-active: #18201f;
  --line: #232b31;
  --text: #e9eef1;
  --dim: #8c989f;
  --muted: #5f6b73;
  --accent: #4ecdc4;
  --accent-ink: #062321;
  --accent-soft: rgba(78, 205, 196, .14);
  --danger: #ff6b6b;
  --up: #4fd18b;
  --down: #ff7a7a;
  --adj: #f2c14e; /* the inflation-adjusted line */
  --key: #1d2328;
  --key-fn: #2a3238;
  --scrim: rgba(0, 0, 0, .55);
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);

  --r-card: 22px;
  --r-sheet: 26px;
  --pad: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Inter', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f3ef;
  --card: #ffffff;
  --card-2: #f0efea;
  --card-active: #effaf8;
  --line: #e1dfd7;
  --text: #15191c;
  --dim: #5f6b73;
  --muted: #8c989f;
  --accent: #1e8d85;
  --accent-ink: #ffffff;
  --accent-soft: rgba(30, 141, 133, .12);
  --up: #1d9b5a;
  --down: #d64545;
  --adj: #b07d10;
  --key: #ffffff;
  --key-fn: #e7e6df;
  --scrim: rgba(20, 22, 24, .35);
  --shadow: 0 18px 50px rgba(0, 0, 0, .14);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* no rubber-band / pull-to-refresh on the page itself (iOS 16+, Android Chrome read it on the root) */
html { -webkit-text-size-adjust: 100%; height: 100%; overscroll-behavior: none; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: hidden; /* a swiped card slides past the edge */
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ----- Top bar ----- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--sat) + 10px) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: .02em; }
.brand img { border-radius: 8px; }
.brand-arr { color: var(--accent); font-weight: 600; }
/* offline: the logo pulses red (saved rates on screen) */
.offline .brand img { animation: off-pulse 1.6s ease-in-out infinite; }
@keyframes off-pulse {
  0%, 100% { filter: none; }
  50% { filter: sepia(1) saturate(10) hue-rotate(-60deg); }
}
@media (prefers-reduced-motion: reduce) { .offline .brand img { animation: none; filter: sepia(1) saturate(10) hue-rotate(-60deg); } }
.bar-tools { display: flex; align-items: center; gap: 6px; }
.brand { flex: none; white-space: nowrap; }
/* phone: the header is the logo and seven buttons, as big as the width allows (44 px at most); the name goes to the
   footer (.foot-brand) */
@media (max-width: 959px) {
  .brand > span { display: none; }
  .brand img { width: 40px; height: 40px; border-radius: 10px; }
  body { --hb: clamp(34px, calc((100vw - 2 * var(--pad) - 40px - 6 * 5px - 6px) / 7), 44px); }
  /* the main card and its rate source stay under the header; only the other cards scroll (they pass under a plain
     backing that runs from the header down to the first card below) */
  /* will-change: its own layer, moved by the compositor with the scroll (as the header, layered by its blur); without it
     iOS Safari places it on the main thread and it twitches by a pixel as the page scrolls */
  /* the strip (units | banks, 38 px + 10 px) stays too: right under the header, the main card under it */
  .strips { position: sticky; top: calc(var(--sat) + max(40px, var(--hb)) + 26px); z-index: 6; will-change: transform; }
  .strips::before {
    content: ""; position: absolute; pointer-events: none;
    left: calc(-1 * var(--pad) - 2px); right: calc(-1 * var(--pad) - 2px); top: -8px; height: 8px; background: var(--bg);
  }
  .cards > .card:first-child { position: sticky; top: calc(var(--sat) + max(40px, var(--hb)) + 74px); z-index: 5; will-change: transform; }
  /* the backing runs up under the strip too: nothing shows through the gap and the strip's round corners */
  .cards > .card:first-child::before {
    content: ""; position: absolute; z-index: -2; pointer-events: none;
    left: calc(-1 * var(--pad) - 2px); right: calc(-1 * var(--pad) - 2px); top: -56px; bottom: -60px; background: var(--bg);
  }
  /* the backing covers the card's own face, so the face is painted again above it */
  .cards > .card:first-child::after {
    content: ""; position: absolute; z-index: -1; pointer-events: none; inset: -1.5px;
    border-radius: inherit; background: inherit; border: inherit;
  }
  .cards > .card.dragging:first-child::before, .cards > .card.swiping:first-child::before,
  .cards > .card.dragging:first-child::after, .cards > .card.swiping:first-child::after { display: none; }
  .bar-tools { gap: 5px; }
  .bar .icon-btn { width: var(--hb); height: var(--hb); }
  .bar .icon-btn svg { width: calc(var(--hb) * .52); height: calc(var(--hb) * .52); }
  .foot-brand + .meta { margin-top: 2px; } /* the name, then the rates line right under it */
}
@media (max-width: 374px) {
  .brand img { width: 36px; height: 36px; }
  .bar-tools { gap: 4px; }
}
.foot-brand { margin: 18px 4px 0; text-align: center; font-size: 15px; font-weight: 700; letter-spacing: .02em; color: var(--dim); }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); color: var(--text);
  transition: background .15s, transform .1s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg circle { fill: currentColor; stroke: none; }
/* the language you switch to, as letters: "EN" on the Russian screen */
.icon-btn.lang-btn { font: inherit; font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.icon-btn.add { background: var(--accent); color: var(--accent-ink); }
.icon-btn.add svg { stroke-width: 2.6; }
/* icon shows the view you switch to */
#btnLayout .ic-list, .compact #btnLayout .ic-grid { display: none; }
.compact #btnLayout .ic-list { display: block; }
#btnLayout svg rect { fill: none; }

/* ----- Layout ----- */
.layout { max-width: 1180px; margin: 0 auto; padding: 6px var(--pad) calc(var(--sab) + 24px); }
.only-desktop { display: none; }

/* ----- Currency cards ----- */
.cards { display: flex; flex-direction: column; gap: 10px; touch-action: pan-y; }
.card {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 92px;
  padding: 14px 18px;
  background: var(--card);
  border-radius: var(--r-card);
  border: 1.5px solid transparent;
  transition: border-color .2s, background .2s, box-shadow .2s;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card.active { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--card-active); }
.cards > .card:first-child { margin-bottom: 58px; }
.cards > .card:first-child.has-modes { margin-bottom: 104px; }

/* Rate source bar: one line under the main card, full width; a menu when the main currency has several sources */
.src-bar {
  position: absolute; left: 0; right: 0; top: calc(100% + 10px); height: 38px;
  display: flex; align-items: center; gap: 9px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 13px;
  font-size: 13px; color: var(--dim); white-space: nowrap; cursor: default;
  transition: background .15s, border-color .15s, opacity .15s;
}
.src-bar .ic { flex: none; display: grid; place-items: center; width: 20px; height: 20px; }
.src-bar .ic .flag { width: 20px; height: 20px; font-size: 8px; box-shadow: none; }
.src-bar .ic svg { width: 20px; height: 20px; }
.src-bar .tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.src-bar .tx i { font-style: normal; color: var(--dim); }
.src-bar > svg:last-child { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--dim); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.src-bar.pick { cursor: pointer; background: var(--card); border-color: transparent; }
.src-bar.pick.open > svg:last-child { transform: rotate(180deg); }
@media (hover: hover) { .src-bar.pick:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); } }
.src-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* RUB with bank rates: two halves — central bank / world | banks; the half in force is framed */
.src-bar.split { padding: 0; gap: 8px; border: 0; }
.src-bar .half {
  flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
  border: 1px solid transparent; border-radius: 13px; background: var(--card); cursor: pointer; overflow: hidden;
  transition: background .15s, border-color .15s, flex-grow .32s var(--ease), flex-basis .32s var(--ease), padding .32s var(--ease);
}
/* the official source: a square with its icon; its name is in the wide half, which always reads in full colour */
.src-bar .half.off { flex: 0 0 38px; padding: 0; justify-content: center; }
.src-bar .half.bk .tx { color: var(--text); }
.src-bar .half:not(.on) .tx { color: var(--dim); }
.src-bar .half.on { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--card-active); }
.src-bar .half > svg:last-child { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--dim); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.src-bar .half.open > svg:last-child { transform: rotate(180deg); }
@media (hover: hover) { .src-bar .half:not(.on):hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); } }
.src-bar .half:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* the banks' logos overlapping, while no bank is picked */
.src-bar .stk { flex: none; display: flex; }
.src-bar .stk svg { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--card); }
.src-bar .stk svg + svg { margin-left: -6px; }
.card.dragging .src-bar, .card.swiping .src-bar, .card.dragging .mode-bar, .card.swiping .mode-bar,
.card.dragging .ch-sq, .card.swiping .ch-sq { opacity: 0; }
/* the rate chart (phones): a square right of the bar, the bar makes room for it */
.ch-sq {
  position: absolute; right: 0; top: calc(100% + 10px); width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 13px; background: var(--card); color: var(--accent); transition: opacity .15s;
}
.ch-sq svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .ch-sq:hover { background: var(--accent-soft); } }
.ch-sq:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 959px) { .card > .src-bar { right: 46px; } }
/* the analytics: its own square right of the bar */
.src-bar .an-btn { flex: none; width: 38px; height: 100%; display: grid; place-items: center; border-radius: 13px; background: var(--card); color: var(--accent); }
.src-bar .an-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .src-bar .an-btn:hover { background: var(--accent-soft); } }
/* a bank in force: buy | sell and online | cash under the bar, two equal parts */
.mode-bar { position: absolute; left: 0; right: 0; top: calc(100% + 56px); height: 38px; display: flex; gap: 8px; transition: opacity .15s; }
.mode-bar .seg { flex: 1 1 0; min-width: 0; display: flex; gap: 0; padding: 3px; border-radius: 13px; background: var(--card); }
.mode-bar button {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 0 6px;
  border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .15s, color .15s, border-color .15s;
}
.mode-bar button.on { background: var(--card-active); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--text); }
.mode-bar button:disabled { opacity: .35; cursor: default; }
@media (hover: hover) { .mode-bar button:not(.on):not(:disabled):hover { color: var(--text); } }

svg.gl { fill: none; stroke: var(--dim); stroke-width: 1.8; }
.cur {
  display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto;
  column-gap: 12px; align-items: center; text-align: left;
  flex: 0 1 auto; min-width: 0; padding: 4px 0;
}
.flag {
  grid-row: 1 / 3; width: 42px; height: 42px; border-radius: 50%;
  background: var(--card-2) center / cover no-repeat;
  box-shadow: 0 0 0 1px rgba(127, 127, 127, .18);
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: var(--accent-ink);
  flex: none;
}
.flag img { width: 100%; height: 100%; border-radius: 50%; }
.flag.badge { background: linear-gradient(135deg, #e3c25d, #b8892b); color: #2d2204; font-size: 17px; }
.flag.badge.xag { background: linear-gradient(135deg, #e9edf0, #9ba6ad); color: #222; }
.flag.badge.xpt { background: linear-gradient(135deg, #d9dde3, #8f99a8); color: #222; }
.flag.badge.xpd { background: linear-gradient(135deg, #cfd3cf, #7f8a84); color: #222; }
.flag.badge.oil { background: linear-gradient(135deg, #4b5259, #16191c); color: #f2c14e; font-size: 14px; } /* oil: Brent, WTI */
.flag.badge.sym { background: var(--accent); color: var(--accent-ink); font-size: 14px; }
.code { display: flex; align-items: center; gap: 4px; font-size: 21px; font-weight: 600; letter-spacing: .01em; }
.code svg { width: 16px; height: 16px; fill: none; stroke: var(--dim); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sub { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.amt { flex: 0 1 auto; max-width: 72%; text-align: right; padding: 4px 0; }
.val { display: block; font-size: 27px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val.l1 { font-size: 23px; } .val.l2 { font-size: 19px; } .val.l3 { font-size: 16px; }
.rate { display: inline-block; margin-top: 3px; font-size: 13px; color: var(--dim); white-space: nowrap; }
.rate:empty { display: none; }
/* priced by the central bank while a bank is the source (the bank does not quote it) */
.code .tb-mark .flag { width: 20px; height: 20px; font-size: 8px; box-shadow: none; }
.rate .arr { opacity: .7; }

/* T-Bank logo next to the code of the currencies priced by T-Bank */
.tb { flex: none; width: 20px; height: 20px; stroke: none !important; }
img.tb { display: inline-block; object-fit: contain; vertical-align: middle; }
.code .tb-mark { display: inline-flex; margin-left: 3px; }
.code .tb-mark svg, .code .tb-mark img.tb { width: 20px; height: 20px; }
.src-pop {
  position: fixed; z-index: 60; padding: 6px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  animation: src-pop .14s var(--ease);
}
@keyframes src-pop { from { opacity: 0; transform: translateY(-4px); } }
.src-pop button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 11px; text-align: left; }
.src-pop button:hover, .src-pop button:focus-visible { background: var(--key-fn); outline: none; }
.src-pop button.on { background: var(--accent-soft); }
.src-pop .ic, .src-pop .ic svg, .src-pop .ic .flag { width: 26px; height: 26px; }
.src-pop .ic { flex: none; display: grid; place-items: center; }
.src-pop .ic .flag { font-size: 10px; }
.src-pop .tx { display: flex; flex-direction: column; min-width: 0; }
.src-pop b { font-weight: 600; font-size: 15px; }
.src-pop small { font-size: 13px; color: var(--dim); }
/* banks menu: a block per bank (two rows where there are cash and online prices), buy | sell of one unit; a tap
   anywhere on the block picks the bank; the best price of each column and kind is green */
/* chips: which of the list's currencies the table compares */
.bk-sheet .bk-refs { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 6px 10px; }
.bk-sheet .bk-refs button {
  width: auto; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.bk-sheet .bk-refs button.on { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); }
.bk-sheet .bk-refs .flag { width: 18px; height: 18px; font-size: 7px; box-shadow: none; }
/* one set of columns for the header, every bank and the official rows: the prices start on one left line */
.bk-sheet .bk-row { display: grid; grid-template-columns: minmax(0, 1fr) 86px 86px; align-items: center; column-gap: 6px; row-gap: 0; padding: 4px 6px 4px 10px; }
.bk-sheet .bk-row.two { grid-template-columns: minmax(0, 1fr) 74px 82px 82px; }
.bk-sheet button.bk-row { width: 100%; gap: 0; border: 1.5px solid transparent; text-align: left; }
.bk-sheet button.bk-row.on { background: var(--card-active); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
/* every bank and official row is a card, like the currencies on the main screen */
.bk-sheet .bk-b, .bk-sheet .bk-o { background: var(--card); border-radius: 18px; padding-top: 10px; padding-bottom: 10px; }
.bk-sheet .bk-b + .bk-b, .bk-sheet .bk-o + .bk-o { margin-top: 8px; }
.bk-sheet .bk-head { padding-top: 2px; padding-bottom: 6px; }
.bk-sheet .bk-h { padding-left: 8px; font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-sheet .bk-h:first-child { padding-left: 0; font-weight: 400; font-size: 12px; color: var(--dim); }
.bk-sheet .bk-n { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; font-size: 15px; }
/* a long name goes on a second line (Bank of America); the prices stay on their lines */
.bk-sheet .bk-n > span:last-child {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  line-height: 1.2; overflow-wrap: anywhere; /* bankTable() puts soft hyphens before «банк» / «bank» */
}
@media (max-width: 959px) { .bk-sheet .bk-n { gap: 8px; font-size: 14px; } .bk-sheet .bk-n svg, .bk-sheet .bk-n img.tb { width: 24px; height: 24px; } }
.bk-sheet .bk-n svg, .bk-sheet .bk-n img.tb { flex: none; width: 26px; height: 26px; }
.bk-sheet .bk-n .ic, .bk-sheet .bk-n .ic svg, .bk-sheet .bk-n .ic .flag { width: 24px; height: 24px; }
.bk-sheet .bk-k { font-size: 13px; color: var(--text); text-align: right; padding-right: 4px; white-space: nowrap; }
.bk-sheet .bk-v { display: flex; align-items: center; min-width: 0; padding: 5px 4px 5px 8px; border-radius: 9px; font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap; }
.bk-sheet .bk-v.none { color: var(--muted); font-weight: 400; }
.bk-sheet .bk-v.best { color: var(--up); }
.bk-sheet .bk-v.best::after { content: ''; flex: none; width: 6px; height: 6px; margin-left: 4px; border-radius: 50%; background: var(--up); }
/* the central bank and the world rate: one price under «I buy» */
.bk-sheet .bk-off { margin-top: 16px; }
.bk-sheet .bk-o .bk-n { grid-column: 1 / -3; }
.bk-sheet .bk-o .bk-v { grid-column: -3 / -1; }
.bk-sheet .bk-hint { padding: 8px 12px 4px; font-size: 12px; color: var(--dim); text-align: center; }

.bk-sheet { max-height: 88vh; padding-left: 10px; padding-right: 10px; }
.bk-sheet .bk-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.bk-sheet button { display: flex; align-items: center; width: 100%; text-align: left; }
.bk-sheet .bk-refs button { width: auto; }
.bk-sheet button.bk-row { display: grid; }
@media (hover: hover) { .bk-sheet button.bk-row:not(.on):hover { background: var(--card-2); } }
.bk-sheet .bk-b.off { opacity: .45; }
.bk-sheet .bk-o.on { background: var(--card-active); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
@media (min-width: 960px) {
  .bk-sheet { width: 480px; }
  .bk-sheet .bk-b:not(.on), .bk-sheet .bk-o:not(.on) { background: var(--card-2); }
  .bk-sheet button.bk-row:not(.on):hover { background: var(--key-fn); }
}

/* swipe right -> main currency */
.col-list { position: relative; }
.card.swiping { z-index: 2; }
.swipe-bg {
  position: absolute; z-index: 1; pointer-events: none; opacity: 0;
  display: flex; align-items: center; padding: 0 22px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 15px;
  transition: background .15s, color .15s;
}
.swipe-bg.armed { background: var(--accent); color: var(--accent-ink); }
.swipe-bg.to-del { justify-content: flex-end; background: rgba(255, 107, 107, .16); color: var(--danger); }
.swipe-bg.to-del.armed { background: var(--danger); color: #fff; }
.swipe-bg span { display: flex; align-items: center; gap: 8px; }
.swipe-bg svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* drag & drop */
.card.dragging {
  z-index: 10; background: var(--card-2);
  box-shadow: var(--shadow); transition: box-shadow .2s, background .2s;
  will-change: transform;
}
.card.lift { animation: lift .18s var(--ease); }
@keyframes lift { 50% { transform: scale(1.03); } }
body.is-dragging { cursor: grabbing; }
body.is-dragging .card:not(.dragging) { transition: transform .18s var(--ease); }
.del {
  position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--key-fn); color: var(--dim); display: none; place-items: center;
}
.del svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }
/* "make main" click zone on a card; desktop only */
.mk { display: none; }

/* compact: two (or more) columns */
.compact .cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.compact .cards > .card:first-child { grid-column: 1 / -1; }
.compact .card:not(:first-child) {
  min-height: 0; flex-direction: column; align-items: stretch; gap: 6px; padding: 12px 14px; border-radius: 18px;
}
.compact .card:not(:first-child) .flag { width: 28px; height: 28px; font-size: 12px; }
.compact .card:not(:first-child) .cur { column-gap: 8px; grid-template-columns: auto 1fr; grid-template-rows: auto; justify-items: start; padding: 0; }
.compact .card:not(:first-child) .amt { max-width: none; }
.compact .card:not(:first-child) .flag { grid-row: 1; }
.compact .card:not(:first-child) .code { font-size: 16px; }
.compact .card:not(:first-child) .sub { display: none; }
.compact .card:not(:first-child) .val { font-size: 20px; }
.compact .card:not(:first-child) .val.l1 { font-size: 17px; }
.compact .card:not(:first-child) .val.l2, .compact .card:not(:first-child) .val.l3 { font-size: 14px; }
.compact .card:not(:first-child) .rate { font-size: 11px; }
.compact .card:not(:first-child) .amt { padding: 0; }
.tsub { display: none; }
/* tile: the country bottom-left, on one line with the rate (it gives way to the rate) */
.compact .card:not(:first-child) .amt { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 6px; }
.compact .card:not(:first-child) .val { grid-column: 1 / -1; justify-self: end; max-width: 100%; }
.compact .card:not(:first-child) .tsub {
  display: block; text-align: left; font-size: 11px; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

.hint { margin: 16px 4px 0; font-size: 13px; color: var(--muted); text-align: center; }
.hint:empty { display: none; }
.meta { margin: 18px 4px 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
.meta a { color: var(--dim); border-bottom: 1px solid var(--line); }
.meta .warn { color: var(--down); }

/* ----- Sheets ----- */
.scrim {
  position: fixed; inset: 0; z-index: 40; background: var(--scrim);
  opacity: 0; transition: opacity .22s;
}
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  margin: 0 auto; max-width: 560px;
  background: var(--bg);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--shadow);
  padding: 8px var(--pad) calc(var(--sab) + 12px);
  transform: translateY(105%);
  transition: transform .28s var(--ease);
  display: flex; flex-direction: column;
}
[data-theme="light"] .sheet { background: var(--bg); }
.sheet.on { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; flex: none; }

/* keypad */
.kp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.kp-cur { display: flex; align-items: center; gap: 10px; }
.kp-cur .flag { width: 32px; height: 32px; font-size: 12px; }
.kp-cur b { font-size: 19px; }
.kp-cur span { font-size: 13px; color: var(--dim); }
.kp-display { padding: 6px 4px 10px; text-align: right; min-height: 82px; }
.kp-expr { font-size: 17px; color: var(--dim); min-height: 22px; word-break: break-all; }
.kp-expr .op { color: var(--accent); padding: 0 2px; }
.kp-value { font-size: 40px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; word-break: break-all; }
.kp-value.err { color: var(--down); }
.kp-value.l1 { font-size: 32px; } .kp-value.l2 { font-size: 26px; }
.kp-preview { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 10px; scrollbar-width: none; }
.kp-preview::-webkit-scrollbar { display: none; }
.kp-preview .kp-chip {
  flex: none; font-size: 13px; color: var(--dim); background: var(--card); padding: 6px 10px; border-radius: 999px; white-space: nowrap;
}
.kp-preview b { color: var(--text); font-weight: 600; }
.kp-preview .kp-chip:active { background: var(--key-fn); }
@media (hover: hover) { .kp-preview .kp-chip:hover { color: var(--accent); } }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keys button {
  height: clamp(50px, 7.4vh, 66px); border-radius: 16px;
  background: var(--key); font-size: 26px; font-weight: 500;
  display: grid; place-items: center;
  transition: transform .08s, background .12s;
}
[data-theme="light"] .keys button { box-shadow: 0 1px 0 rgba(0, 0, 0, .06); }
.keys button:active, .keys button.press { transform: scale(.94); background: var(--key-fn); }
.keys .k-fn { background: var(--key-fn); font-size: 22px; }
.keys .k-op { background: var(--accent-soft); color: var(--accent); font-size: 30px; }
.keys .k-op.on { background: var(--accent); color: var(--accent-ink); }
.keys .k-ok { background: var(--accent); color: var(--accent-ink); }
.keys svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* keypad header: currency, size toggle, close */
.kp-head { gap: 8px; }
.kp-cur { flex: 1; min-width: 0; }
.kp-cur div span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: 100%; }
.kp-size { flex: none; }
.kp-size .ic-grow, .kp-compact .kp-size .ic-shrink { display: none; }
.kp-ext .kp-size { display: none; } /* the route's keypad is always compact */
/* the page never scrolls through the keypad (its own gestures in app.js); the chips row still scrolls sideways */
.keypad-sheet { overscroll-behavior: contain; touch-action: none; }
.keypad-sheet .kp-preview { touch-action: pan-x; }
/* size change: the content fades in in the new layout while the sheet slides into place (morphKp in app.js) */
.kp-morph > :not(.grab) { animation: kp-in .28s ease-out; }
@keyframes kp-in { from { opacity: 0; } }
/* the sheet goes on below its bottom edge, so dragging it up never shows the page under it */
@media (max-width: 959px) {
  .keypad-sheet::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 70vh; background: inherit; }
}
.kp-compact .kp-size .ic-grow { display: block; }

/* compact keypad: about half the height; the page above stays visible and scrolls */
.kp-compact { padding-top: 6px; }
.kp-compact .grab { margin-bottom: 6px; }
.kp-compact .kp-head { margin-bottom: 0; }
.kp-compact .kp-head .icon-btn { width: 36px; height: 36px; }
.kp-compact .kp-cur .flag { width: 26px; height: 26px; }
.kp-compact .kp-cur b { font-size: 17px; }
.kp-compact .kp-cur br, .kp-compact .kp-cur div span { display: none; }
.kp-compact .kp-display { display: flex; align-items: baseline; justify-content: flex-end; gap: 10px; min-height: 0; padding: 2px 4px 8px; }
.kp-compact .kp-expr { min-height: 0; font-size: 14px; flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kp-compact .kp-value { font-size: 26px; flex: none; word-break: normal; }
.kp-compact .kp-value.l1 { font-size: 22px; } .kp-compact .kp-value.l2 { font-size: 19px; }
.kp-compact .kp-preview { display: none; }
.kp-compact .keys { grid-template-columns: repeat(5, 1fr); gap: 6px; }
.kp-compact .keys button { height: clamp(42px, 5.6vh, 50px); border-radius: 12px; font-size: 22px; }
.kp-compact .keys .k-fn { font-size: 18px; }
.kp-compact .keys .k-op { font-size: 24px; }
.kp-compact .keys svg { width: 22px; height: 22px; }
/* 7 8 9 ÷ ⌫ / 4 5 6 × % / 1 2 3 − C / 00 0 , + ✓ */
.kp-compact .keys [data-k="7"] { order: 1; } .kp-compact .keys [data-k="8"] { order: 2; } .kp-compact .keys [data-k="9"] { order: 3; }
.kp-compact .keys [data-k="/"] { order: 4; } .kp-compact .keys [data-k="back"] { order: 5; }
.kp-compact .keys [data-k="4"] { order: 6; } .kp-compact .keys [data-k="5"] { order: 7; } .kp-compact .keys [data-k="6"] { order: 8; }
.kp-compact .keys [data-k="*"] { order: 9; } .kp-compact .keys [data-k="%"] { order: 10; }
.kp-compact .keys [data-k="1"] { order: 11; } .kp-compact .keys [data-k="2"] { order: 12; } .kp-compact .keys [data-k="3"] { order: 13; }
.kp-compact .keys [data-k="-"] { order: 14; } .kp-compact .keys [data-k="C"] { order: 15; }
.kp-compact .keys [data-k="00"] { order: 16; } .kp-compact .keys [data-k="0"] { order: 17; } .kp-compact .keys [data-k="."] { order: 18; }
.kp-compact .keys [data-k="+"] { order: 19; } .kp-compact .keys [data-k="ok"] { order: 20; }

/* picker */
.picker-sheet { top: calc(var(--sat) + 10px); padding-bottom: 0; }
.pk-head { display: flex; align-items: center; gap: 10px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 0 12px; }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--dim); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { flex: 1; min-width: 0; height: 46px; background: none; border: 0; outline: none; font-size: 17px; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.txt-btn { color: var(--accent); font-size: 16px; padding: 8px 4px; }
.pk-replace { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 10px 14px; background: var(--card); border-radius: 14px; font-size: 14px; color: var(--dim); }
.pk-replace b { color: var(--text); }
.pk-replace button { color: var(--danger); font-weight: 600; padding: 6px 2px; }
.pk-acts { display: flex; gap: 16px; flex: none; }
.pk-replace .pk-main { color: var(--accent); }
.pk-filter { margin-top: 10px; flex: none; }
.pk-filter button { padding: 7px 0; font-size: 14px; }
.pk-list { flex: 1; overflow-y: auto; margin: 10px calc(var(--pad) * -1) 0; padding: 0 var(--pad) calc(var(--sab) + 20px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.pk-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 4px 6px; }
.pk-item {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 6px; border-radius: 14px;
}
.pk-item:active, .pk-item.kb { background: var(--card); }
.pk-item .flag { width: 38px; height: 38px; font-size: 13px; }
.pk-item .t { flex: 1; min-width: 0; }
.pk-item .t b { font-size: 17px; font-weight: 600; margin-right: 8px; }
.pk-item .t span { font-size: 15px; }
.pk-item .t small { display: block; font-size: 12.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-item mark { background: none; color: var(--accent); }
.pk-item .chk { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pk-item.added { opacity: .55; }
.pk-empty { text-align: center; color: var(--dim); padding: 40px 10px; }

/* chart */
.chart-sheet { padding-bottom: calc(var(--sab) + 18px); }
.ch-pair { display: flex; align-items: center; gap: 8px; }
.ch-pair .chip { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 999px; padding: 6px 12px 6px 6px; font-weight: 600; font-size: 16px; }
.ch-pair .chip .flag { width: 32px; height: 32px; font-size: 12px; }
.ch-pair .swap { width: 36px; height: 36px; }
.ch-pair .swap svg { width: 18px; height: 18px; }
.ch-pair .ch-share { margin-left: auto; width: 36px; height: 36px; }
.ch-pair .ch-share svg { width: 19px; height: 19px; }
.ch-now { margin: 14px 2px 2px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.ch-now b { font-size: 30px; font-weight: 600; letter-spacing: -.01em; }
.ch-now b small { font-size: 18px; font-weight: 600; color: var(--dim); letter-spacing: 0; }
.ch-pair .cc { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
/* room for "+10,85%" with even-width digits: the chip keeps its size while the finger moves over the chart */
.ch-pair .chg { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 7.2ch; text-align: left; }
.ch-pair .chg:empty { display: none; }
.ch-pair .chg.up { color: var(--up); } .ch-pair .chg.down { color: var(--down); }
/* the date of the point shown, in a small frame under the number: tap it to type a date (digits only).
   The field lies over the text, unseen until focused; 16px so iOS does not zoom in on it */
.ch-when {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-width: 150px; height: 32px;
  margin: 4px 0 0; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: border-color .15s;
}
.ch-when svg { flex: none; width: 15px; height: 15px; fill: none; stroke: var(--dim); stroke-width: 1.8; stroke-linecap: round; }
.ch-date { font-size: 13.5px; color: var(--dim); white-space: nowrap; }
.ch-find {
  position: absolute; inset: -1px; width: calc(100% + 2px); padding: 0 10px 0 31px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text); font-size: 16px; outline: none;
  opacity: 0; cursor: pointer; user-select: text; -webkit-user-select: text;
}
.ch-find::placeholder { color: var(--muted); font-size: 13.5px; }
.ch-find:focus { opacity: 1; cursor: text; border-color: var(--accent); }
.ch-when:focus-within .ch-date { visibility: hidden; }
.ch-find.bad { border-color: var(--down); }
@media (hover: hover) { .ch-when:hover { border-color: var(--dim); } }
/* the date and the period side by side; the period's field opens over both (js/app.js perApply) */
/* the row: the date and the period on the left, the breakdown on the right (its word goes when there is no room: fitTools) */
.ch-tools { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; }
.ch-dates { position: relative; flex: none; display: flex; align-items: center; gap: 8px; }
.ch-dates .ch-when { margin: 0; min-width: 136px; }
.ch-per { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--dim); font-size: 13.5px; white-space: nowrap; transition: border-color .15s; }
.ch-per svg { flex: none; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ch-per.on { border-color: var(--accent); color: var(--text); }
.ch-per.on svg { stroke: var(--accent); }
@media (hover: hover) { .ch-per:hover { border-color: var(--dim); } .ch-per.on:hover { border-color: var(--accent); } }
.ch-perin {
  position: absolute; inset: 0; width: 100%; height: 32px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--card); color: var(--text); font-size: 16px; outline: none; opacity: 0; pointer-events: none;
  user-select: text; -webkit-user-select: text;
}
.ch-perin::placeholder { color: var(--muted); font-size: 13.5px; }
.ch-perin:focus { opacity: 1; pointer-events: auto; }
.ch-perin.bad { border-color: var(--down); }
/* the breakdown (js/app.js openInfHelp): a round button right of the date (only where there are prices), the window in the middle */
.ch-help { flex: none; margin-left: auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 38px; height: 38px;
  padding: 0 14px 0 10px; border-radius: 19px; color: var(--adj); font-size: 13.5px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--adj) 14%, transparent); }
.ch-help.tight { width: 38px; padding: 0; }
.ch-help.tight span { display: none; }
.ch-help svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .ch-help:hover { background: color-mix(in srgb, var(--adj) 24%, transparent); } }
.ch-help[hidden] { display: inline-flex; visibility: hidden; }
.inf-pop { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 12px); background: rgba(0,0,0,.55);
  opacity: 0; transition: opacity .2s; touch-action: none; cursor: pointer; }
.inf-pop.on { opacity: 1; }
.inf-pop.away { visibility: hidden; } /* under the share sheet; back when it goes */
.inf-pop .box { width: 100%; max-width: 420px; max-height: 100%; overflow: hidden; padding: 16px 16px 14px; border-radius: 22px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); box-shadow: 0 16px 48px rgba(0,0,0,.45); transform: scale(.96); transition: transform .2s;
  font-size: 14px; line-height: 1.4; cursor: pointer;
  background-image: radial-gradient(120% 60% at 0 0, var(--accent-soft), transparent 70%); }
.inf-pop.on .box { transform: none; }
.inf-pop .hh { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.inf-pop h3 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.inf-pop .per { margin-top: 3px; font-size: 13.5px; font-weight: 500; color: color-mix(in srgb, var(--text) 74%, var(--card)); }
.inf-pop .hh .icon-btn { flex: none; width: 38px; height: 38px; }
.inf-pop .fl { flex: none; display: flex; width: 34px; }
.inf-pop .fl .flag { width: 22px; height: 22px; font-size: 8px; box-shadow: 0 0 0 2px var(--bg); }
.inf-pop .fl.two .flag + .flag { margin-left: -10px; }
.inf-pop .num { font-variant-numeric: tabular-nums; }
/* the rate */
.inf-pop .rates { padding: 0 12px; border-radius: 16px; background: var(--bg); }
.inf-pop .rates .hr { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.inf-pop .rates .hr + .hr { border-top: 1px solid var(--line); }
.inf-pop .rates .t { flex: 1; min-width: 0; color: var(--dim); text-wrap: pretty; }
.inf-pop .rates b { flex: none; font-size: 16px; font-weight: 700; }
.inf-pop b.up { color: var(--up); } .inf-pop b.down { color: var(--down); }
/* the prices in each country, counted in each money: a grid with lines, no frame */
.inf-pop .mx { margin-top: 10px; padding: 11px 12px 8px; border-radius: 16px; background: var(--bg); }
.inf-pop .cap { margin: 0 0 6px; font-size: 12.5px; color: var(--dim); }
.inf-pop .mg { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; } /* no column gap: the row lines run unbroken */
.inf-pop .mh { padding: 0 0 5px 12px; font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.inf-pop .mc { display: flex; align-items: center; gap: 0; min-width: 0; padding: 8px 0; border-top: 1px solid var(--line); }
.inf-pop .mc > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inf-pop .mv { padding: 8px 0 8px 12px; border-top: 1px solid var(--line); text-align: right; font-size: 15.5px; font-weight: 700; white-space: nowrap; }
.inf-pop .mv span { display: inline-block; padding: 1px 6px; border-radius: 8px; }
.inf-pop .mv i { font-style: normal; font-size: 12px; margin-right: 3px; }
.inf-pop .mv.home span, .inf-pop .leg span { background: color-mix(in srgb, var(--text) 9%, transparent); }
.inf-pop .rise { color: var(--down); } .inf-pop .fall { color: var(--up); } .inf-pop .flat { color: var(--dim); }
.inf-pop .leg { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.inf-pop .leg span { padding: 0 5px; border-radius: 6px; color: var(--dim); }
/* what happened, then each country against the other */
.inf-pop .out { margin-top: 10px; padding: 11px 14px 12px; border-radius: 16px; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.inf-pop .out small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.inf-pop .out > span { display: block; margin-top: 3px; font-weight: 500; text-wrap: pretty; }
.inf-pop .rel { margin-top: 8px; border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent); }
.inf-pop .rl { display: flex; align-items: center; gap: 0; padding-top: 8px; font-size: 13.5px; color: var(--dim); }
.inf-pop .rl .t { flex: 1; min-width: 0; text-wrap: pretty; }
.inf-pop .rl .flag { box-shadow: none; } /* the ring that parts stacked flags is a black halo on the tinted block */
.inf-pop .rl .t { font-size: 12.5px; line-height: 1.3; } /* the country, "относительно …" under it */
.inf-pop .rl em { display: block; font-style: normal; font-size: 14px; font-weight: 600; color: var(--text); }
.inf-pop .rl b { flex: none; margin-left: 8px; font-size: 14.5px; font-weight: 700; white-space: nowrap; text-align: right; line-height: 1.3; }
.inf-pop .rl b .w { display: block; font-size: 12.5px; font-weight: 500; } /* «стало дороже» over the percent, in its colour (not the block's accent caption) */
.inf-pop .note { margin: 10px 2px 0; font-size: 12.5px; color: var(--dim); text-wrap: pretty; }
.ch-plot { position: relative; height: 230px; margin: 10px 0 6px; touch-action: none; } /* the finger drives the cursor, never a scroll */
/* nothing on the chart selects as text (a stray selection broke the cursor drag) */
.chart-host, .col-chart { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
/* a dialog sheet (chart, picker, menu) is open: the page under it stays put; only the keypad lets it scroll */
html.lock, html.lock body { overflow: hidden; }
.ch-plot svg { width: 100%; height: 100%; overflow: visible; }
.ch-plot .area { fill: url(#fxGrad); }
.ch-plot .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
/* the inflation-adjusted rate: dashed, warm, over the rate */
.ch-plot .adj { fill: none; stroke: var(--adj); stroke-width: 2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
/* live crypto chart: the light running along the line (js: drawChart) */
.ch-plot svg.run {
  position: absolute; inset: 0; pointer-events: none;
  -webkit-mask: linear-gradient(90deg, transparent, #000 75%, transparent) no-repeat; mask: linear-gradient(90deg, transparent, #000 75%, transparent) no-repeat;
  -webkit-mask-size: 18% 100%; mask-size: 18% 100%;
  animation: line-run 4.6s linear infinite; /* it goes on past the right edge: that is the pause between runs */
}
@keyframes line-run { from { -webkit-mask-position: -25% 0; mask-position: -25% 0; } to { -webkit-mask-position: 160% 0; mask-position: 160% 0; } }
.ch-plot .run-core, .ch-plot .run-glow { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.ch-plot .run-core { stroke: color-mix(in srgb, var(--accent) 55%, #fff); stroke-width: 2.5; }
[data-theme="light"] .ch-plot .run-core { stroke: color-mix(in srgb, var(--accent) 75%, #000); }
.ch-plot .run-glow { stroke: var(--accent); stroke-width: 10; opacity: .4; }
.ch-plot.busy svg.run { display: none; }
.ch-plot .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ch-plot .cursor { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.ch-plot .adj-end { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--adj); transform: translate(-50%, -50%); pointer-events: none; }
.ch-plot .adj-end b { position: absolute; bottom: 8px; left: -4px; padding: 0 4px; border-radius: 6px; background: var(--bg); font-size: 11px; font-weight: 600; line-height: 16px; color: var(--adj); white-space: nowrap; }
.ch-plot .adj-end b.l { left: auto; right: -4px; }
.col-chart .ch-plot .adj-end b { background: var(--card); }
.ch-plot .ylab { position: absolute; right: 0; font-size: 11px; color: var(--muted); background: var(--bg); padding: 0 0 0 4px; transform: translateY(-50%); }
.ch-plot .dot { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); transform: translate(-50%, -50%); pointer-events: none; }
.ch-plot .msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: 14px; text-align: center; }
.ch-retry { margin-top: 10px; padding: 7px 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600; }
/* the previous chart, dimmed, while the next one loads */
.ch-plot > svg, .ch-plot .ylab { transition: opacity .2s; }
.ch-plot.busy { pointer-events: none; }
.ch-plot.busy > svg, .ch-plot.busy .ylab, .ch-plot.busy .dot { opacity: .3; }
/* loading: a thin line runs along the top of the plot; it shows up only after .25 s, so a quick answer never flashes it */
.ch-plot.busy::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; border-radius: 2px; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent) no-repeat;
  background-size: 35% 100%; background-color: var(--accent-soft);
  animation: ch-run 1.1s ease-in-out infinite, ch-show .2s .25s forwards;
}
@keyframes ch-run { from { background-position: -60% 0; } to { background-position: 160% 0; } }
@keyframes ch-show { to { opacity: 1; } }
.ch-ranges { position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(34px, auto); gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; }
/* "+" at the row's end: the other ranges (1D for coins, 2Y, 3Y); it shows the one picked from there */
.ch-ranges .more { padding: 8px 9px; display: grid; place-items: center; }
.ch-ranges .more svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.ch-more-pop {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5; display: flex; gap: 4px; padding: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
/* the same size as the row's buttons under it */
.ch-ranges .ch-more-pop button { min-width: 52px; padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text); background: var(--key-fn); }
.ch-ranges .ch-more-pop button.on { background: var(--accent); color: var(--accent-ink); }
.ch-ranges button { padding: 8px 0; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--dim); }
.ch-ranges button.on { background: var(--key-fn); color: var(--text); }
.ch-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.ch-stats div { background: var(--card); border-radius: 12px; padding: 8px 10px; }
.ch-stats small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ch-stats span { font-size: 14px; font-weight: 600; }
.ch-src { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; }
/* inflation (js/app.js inflation): the card under the stats */
.ch-inf { display: flex; flex-direction: column; min-height: 155px; margin-top: 10px; padding: 10px 14px 8px; border-radius: 14px; background: var(--card); }
/* one height for every pair (the full card with two countries): a message or one country leaves room, nothing below moves */
.ch-inf .ih { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.ch-inf .ih b { font-size: 14px; }
.ch-inf .per { margin: 1px 0 4px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-inf .row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; color: var(--dim); }
.ch-inf .row .flag { width: 20px; height: 20px; font-size: 7px; box-shadow: none; }
.ch-inf .row span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-inf .row b { margin-left: auto; color: var(--text); font-size: 15px; }
.ch-inf .real { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; padding-top: 7px;
  border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.ch-inf .real span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-inf .real b { flex: none; font-size: 17px; }
.ch-inf .real b.up { color: var(--up); } .ch-inf .real b.down { color: var(--down); }
.ch-inf .none { flex: 1; display: flex; align-items: center; margin: 4px 0 2px; font-size: 13px; color: var(--dim); text-wrap: balance; }
.ch-inf .tgl { display: flex; align-items: center; gap: 8px; flex: none; font-size: 12px; color: var(--dim); }
.ch-inf .tgl span { display: flex; align-items: center; gap: 6px; }
.ch-inf .tgl s { width: 16px; border-top: 2px dashed var(--adj); } /* the dashed line the switch draws: no legend row that would shift the sheet */
.ch-inf .tgl i { flex: none; position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--card-2, var(--line)); box-shadow: inset 0 0 0 1px var(--line); transition: background .15s; }
.ch-inf .tgl i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--dim); transition: transform .15s, background .15s; }
.ch-inf .tgl[aria-checked="true"] i { background: var(--adj); box-shadow: none; }
.ch-inf .tgl[aria-checked="true"] i::after { transform: translateX(14px); background: #fff; }
.ch-inf .tgl:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* menu */
.menu { display: flex; flex-direction: column; gap: 14px; padding-bottom: 6px; }
.menu h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 0 4px -6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--card); border-radius: 14px; padding: 4px; }
.seg button { padding: 11px 0; border-radius: 10px; font-weight: 600; color: var(--dim); }
.seg button.on { background: var(--key-fn); color: var(--text); }
.menu .row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; text-align: left;
  background: var(--card); border-radius: 14px; font-size: 16px;
}
.menu .row svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.menu .row small { display: block; font-size: 12.5px; color: var(--dim); }
.menu .rows { display: flex; flex-direction: column; gap: 6px; }
.menu .about { font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.6; }
.menu .about a { color: var(--dim); border-bottom: 1px solid var(--line); }
.ios-steps { font-size: 14px; color: var(--dim); line-height: 1.6; background: var(--card); border-radius: 14px; padding: 12px 14px; }
.ios-steps b { color: var(--text); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 24px); z-index: 80;
  transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
  white-space: nowrap;
}

/* ----- Small phones ----- */
@media (max-width: 360px) {
  :root { --pad: 12px; }
  .card { padding: 12px 14px; min-height: 84px; }
  .flag { width: 36px; height: 36px; }
  .code { font-size: 19px; }
  .val { font-size: 23px; } .val.l1 { font-size: 20px; } .val.l2 { font-size: 17px; } .val.l3 { font-size: 14px; }
  .rate { font-size: 12px; }
  .cur { column-gap: 9px; }
  .icon-btn { width: 38px; height: 38px; }
  .bar-tools { gap: 4px; }
}

/* ----- Tablets: 3 columns in compact ----- */
@media (min-width: 620px) {
  .compact .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ----- Desktop: list + chart panel, sheets become dialogs ----- */
@media (min-width: 960px) {
  /* byfox.dev background texture: corner glows + faint masked grid (z-index -1 keeps it under all content) */
  body::before, body::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1; }
  body::before {
    background-image:
      radial-gradient(circle at 20% 0%, rgba(78, 205, 196, .05) 0%, transparent 40%),
      radial-gradient(circle at 80% 100%, rgba(78, 205, 196, .03) 0%, transparent 40%);
  }
  body::after {
    background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 80px 80px; opacity: .25;
    -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 28px; align-items: start; padding-top: 14px; }
  .bar { max-width: 1180px; margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .only-desktop { display: block; }
  .only-mobile { display: none; }
  .col-chart { position: sticky; top: 76px; background: var(--card); border-radius: var(--r-card); padding: 20px; }
  .col-chart .ch-ranges, .col-chart .ch-stats div, .col-chart .ch-more-pop, .col-chart .ch-inf { background: var(--card-2); }
  .col-chart .ch-inf .tgl i { background: var(--card); }
  .col-chart .ch-pair .chip { background: var(--card-2); }
  .col-chart .ch-plot .ylab { background: var(--card); }
  .compact .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card { cursor: default; }
  .card .cur, .card .amt { cursor: pointer; }
  .card:hover .del { display: grid; }
  /* "make main" zone: the free middle third of a card, the bottom-left of a tile; cur/amt sit above it */
  .card .cur, .card .amt { position: relative; z-index: 1; }
  .mk {
    position: absolute; top: 0; bottom: 0; left: 33%; width: 34%;
    display: block; cursor: pointer;
  }
  /* nothing drawn: the text is the native title tooltip (same delay as the header buttons) */
  .cards > .card:first-child .mk, body.is-dragging .mk { display: none; }
  /* the tile's amount row is full width (country line); only the number and rate catch clicks, the rest is the make-main zone */
  .compact .card:not(:first-child) .amt { pointer-events: none; }
  .compact .card:not(:first-child) .val, .compact .card:not(:first-child) .rate { pointer-events: auto; }
  .compact .card:not(:first-child) .cur { align-self: flex-start; }
  .compact .card:not(:first-child) .mk { top: 50%; left: 0; width: 55%; }
  .card .amt:hover .val { color: var(--accent); }
  .cur:hover .code { color: var(--accent); }
  .cur:hover .code svg { stroke: var(--accent); }

  .sheet {
    top: 50%; bottom: auto; left: 50%; right: auto; width: 440px; max-width: calc(100vw - 40px);
    border-radius: var(--r-sheet); padding: 16px 18px 18px;
    transform: translate(-50%, -46%) scale(.97); opacity: 0;
    transition: transform .2s var(--ease), opacity .2s;
    background: var(--card);
  }
  .sheet.on { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .grab { display: none; }
  .sheet .keys button { height: 58px; background: var(--card-2); }
  .sheet .keys .k-fn { background: var(--key-fn); }
  .sheet .keys .k-op { background: var(--accent-soft); }
  .sheet .keys .k-ok, .sheet .keys .k-op.on { background: var(--accent); }
  .sheet .kp-preview .kp-chip, .sheet .search, .sheet .pk-replace, .sheet .menu .row, .sheet .seg, .sheet .ios-steps { background: var(--card-2); }
  .picker-sheet { height: min(680px, calc(100vh - 80px)); width: 520px; }
  /* keypad docks bottom-right, over the chart panel, so the list stays visible */
  .keypad-sheet {
    top: auto; left: auto; bottom: 24px; right: max(24px, calc((100vw - 1180px) / 2 + 16px));
    transform: translateY(16px);
  }
  .keypad-sheet.on { transform: none; }
  /* over the chart panel (or the units' group list) the two cards are one colour: a thin ring keeps the keypad's edge */
  .keypad-sheet.kp-over { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, var(--line)), var(--shadow); }
  .pk-item:hover, .pk-item.kb { background: var(--card-2); }
}

/* phone on its side: the chart takes the whole screen (that is what people turn the phone for). One line on top:
   pair, rate, date; the plot fills the rest, min/max/avg in one line over its corner; the ranges at the bottom (the
   source line goes). Side insets keep clear of the camera notch. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 959px) {
  .chart-sheet {
    top: 0; max-width: none; border-radius: 0;
    padding: 4px max(var(--pad), env(safe-area-inset-right, 0px)) calc(var(--sab) + 6px) max(var(--pad), env(safe-area-inset-left, 0px));
  }
  .chart-sheet .grab { margin-bottom: 4px; }
  .chart-sheet .chart-host {
    flex: 1; min-height: 0; display: grid; grid-template-columns: auto auto 1fr; grid-template-rows: auto minmax(0, 1fr) auto;
    column-gap: 18px; align-items: center;
  }
  .chart-sheet .ch-pair { grid-column: 1; grid-row: 1; }
  .chart-sheet .ch-now { grid-column: 2; grid-row: 1; margin: 0; }
  .chart-sheet .ch-now b { font-size: 24px; }
  .chart-sheet .ch-now b small { font-size: 15px; }
  .chart-sheet .ch-tools { grid-column: 3; grid-row: 1; margin: 0; }
  .chart-sheet .ch-plot { grid-column: 1 / -1; grid-row: 2; align-self: stretch; height: auto; min-height: 0; margin: 8px 0 6px; }
  .chart-sheet .ch-ranges { grid-column: 1 / -1; grid-row: 3; }
  /* min / max / avg: one line over the plot's top-left corner, the way trading charts show them (no height lost) */
  .chart-sheet .ch-stats {
    grid-column: 1 / -1; grid-row: 2; align-self: start; justify-self: start; z-index: 2; pointer-events: none;
    display: flex; gap: 14px; margin: 10px 0 0; padding: 3px 8px; border-radius: 8px;
    background: color-mix(in srgb, var(--bg) 75%, transparent);
  }
  .chart-sheet .ch-stats div { display: flex; align-items: baseline; gap: 5px; padding: 0; background: none; white-space: nowrap; }
  .chart-sheet .ch-stats span { font-size: 13px; }
  .chart-sheet .ch-src { display: none; }
  .chart-sheet .ch-inf { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* ----- Desktop: the same fixed top as on phones — the header, the strip, the main card with its rate source stay;
   only the other cards scroll, under a backing (--barh: the header's height, set by js/app.js) ----- */
/* The backings, the header and the full screens (units, route, analytics) wear the page's own background — the glows
   and the masked grid of body::before/::after — laid where the window has it, so no seam shows. Not «fixed»
   (that makes a browser repaint on every scroll step, the sticky parts twitch): each one is told where it stands
   (--px, --py: minus its place in the window; js/app.js sets --vw/--vh, the list's --lx, the units' --ux/--uy) */
@media (min-width: 960px) {
  .bar, body .units, body .chain, .bk-anv.in-col .cs-head, .bk-anv.in-col .cs-head::before, .strips::before, .cards > .card:first-child::before, .bk-country::before, .u-group::before {
    background-color: var(--bg);
    background-image:
      radial-gradient(circle at 20% 0%, rgba(78, 205, 196, .05) 0%, transparent 40%),
      radial-gradient(circle at 80% 100%, rgba(78, 205, 196, .03) 0%, transparent 40%),
      radial-gradient(ellipse at center, transparent 20%, var(--bg) 75%),
      linear-gradient(color-mix(in srgb, var(--line) 25%, var(--bg)) 1px, transparent 1px),
      linear-gradient(90deg, color-mix(in srgb, var(--line) 25%, var(--bg)) 1px, transparent 1px);
    background-size: var(--vw, 100vw) var(--vh, 100vh), var(--vw, 100vw) var(--vh, 100vh), var(--vw, 100vw) var(--vh, 100vh), 80px 80px, 80px 80px;
    background-repeat: no-repeat, no-repeat, no-repeat, repeat, repeat;
    background-position: var(--px, 0) var(--py, 0);
  }
  .bar {
    max-width: none;
    padding-left: max(var(--pad), calc((100% - 1180px) / 2 + var(--pad)));
    padding-right: max(var(--pad), calc((100% - 1180px) / 2 + var(--pad)));
  }
  /* each part sticks exactly where it already stands (the list's 14px top, the strip's 38 + 10): nothing moves when
     the scroll starts, the parts just stay */
  .strips { position: sticky; top: calc(var(--barh, 64px) + 14px); z-index: 6; }
  .strips::before {
    content: ""; position: absolute; pointer-events: none; left: -14px; right: -14px; top: -14px; height: 14px;
    --px: calc(var(--lx, 0px) + 14px); --py: calc(0px - var(--barh, 64px));
  }
  .cards > .card:first-child { position: sticky; top: calc(var(--barh, 64px) + 62px); z-index: 5; }
  .cards > .card:first-child::before {
    content: ""; position: absolute; z-index: -2; pointer-events: none; left: -14px; right: -14px; top: -62px; bottom: -60px;
    --px: calc(var(--lx, 0px) + 12.5px); --py: calc(-1px - var(--barh, 64px)); /* inside the card border (1.5px; the sticky top snaps to whole pixels) */
  }
  .cards > .card:first-child.has-modes::before { bottom: -104px; }
  .cards > .card:first-child::after {
    content: ""; position: absolute; z-index: -1; pointer-events: none; inset: -1.5px;
    border-radius: inherit; background: inherit; border: inherit;
  }
  .cards > .card.dragging:first-child::before, .cards > .card.swiping:first-child::before,
  .cards > .card.dragging:first-child::after, .cards > .card.swiping:first-child::after { display: none; }
  .col-chart { top: calc(var(--barh, 64px) + 14px); }
  /* each fixed part on its own layer, moved by the compositor (as on phones): no twitch while the page scrolls */
  .bar, .strips, .cards > .card:first-child, .bk-country, .u-group { will-change: transform; }
}

/* back / home (js/nav.js): a see-through pair floating over a fixed spot of each screen, never part of its layout */
.nav-fab {
  position: fixed; left: 0; top: 0; z-index: 95; display: flex; gap: 2px; padding: 3px; border-radius: 22px;
  background: color-mix(in srgb, var(--card) 62%, transparent); border: 1.5px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12); -webkit-backdrop-filter: blur(10px) saturate(1.3); backdrop-filter: blur(10px) saturate(1.3);
  opacity: 0; transition: opacity .18s var(--ease);
}
.nav-fab.on { opacity: 1; }
.nav-fab.v { flex-direction: column; }
.nav-fab.one [data-nav=home] { display: none; }
.nav-fab button { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--text); }
.nav-fab button:hover, .nav-fab button:focus-visible { background: color-mix(in srgb, var(--key-fn) 80%, transparent); outline: none; }
.nav-fab button:active { transform: scale(.92); }
.nav-fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
