/* fxbyfox.com — unit converter screen (js/units.js). Uses the app's tokens from app.css. */
.units {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
  background: var(--bg);
}
.units[hidden] { display: none; }
body.units-open { overflow: hidden; }
/* swipe left back to the currencies (js/units.js): the dimming over them, under the units screen */
.u-shade { position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .4); pointer-events: none; }
.u-shade[hidden] { display: none; }
#fxMain { transform-origin: 50% 50%; }
/* the scrollbar's room stays when units-open hides it: no sideways jump on a computer at the end of the flip;
   a card moved past the screen's edge (the flip, the first-visit peek) doesn't widen the page on a phone */
html { scrollbar-gutter: stable; }
body { overflow-x: clip; }

.u-bar {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: calc(var(--sat) + 10px) var(--pad) 10px;
  max-width: 1180px; width: 100%; margin: 0 auto;
}
/* computer: the other converter as a chip right of the logo (currencies <-> units); phones have the strip / coin */
.to-other { display: none; }
@media (min-width: 960px) {
  .to-other {
    display: flex; align-items: center; gap: 8px; flex: none; margin: 0 auto 0 18px; padding: 7px 14px 7px 11px;
    border: 1px solid transparent; border-radius: 999px; background: var(--card);
    font: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; transition: border-color .15s;
  }
  .to-other svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .to-other:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
  .u-bar .to-other { margin: 0 0 0 8px; }
  .u-title { visibility: hidden; } /* the chip says where you are; the title only keeps the tools on the right */
}
.u-title { flex: 1; min-width: 0; display: flex; }
.u-back { display: flex; align-items: center; gap: 2px; min-width: 0; margin: 0 0 0 -4px; padding: 6px 4px 6px 0; font: inherit; font-size: 20px; font-weight: 700; letter-spacing: .02em; color: var(--accent); white-space: nowrap; }
.u-back span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.u-back svg { flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#uLayout .ic-list, .u-tiles #uLayout .ic-grid { display: none; }
.u-tiles #uLayout .ic-list { display: block; }
#uLayout svg rect { fill: none; }
@media (max-width: 959px) {
  .u-bar .brand img { width: 40px; height: 40px; border-radius: 10px; }
  /* five buttons now (the favourites' star): a little smaller, so the title by the logo keeps its room */
  .u-bar .icon-btn { width: 40px; height: 40px; }
  .u-bar .icon-btn svg { width: 21px; height: 21px; }
  .u-back { font-size: 18px; }
}

.u-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.u-wrap {
  max-width: 1180px; margin: 0 auto; padding: 4px var(--pad) calc(var(--sab) + 28px);
  display: flex; flex-direction: column; gap: 10px;
}
.u-find { display: flex; align-items: center; gap: 10px; }
.u-find .search input { height: 44px; font-size: 16px; }
#uDone { display: none; }
.browsing #uDone { display: block; }
.u-list { display: none; }
.browsing .u-list { display: block; }
.browsing .u-main { display: none; }
/* phone: the search and the group title stay put; only the cards (or the group list) scroll under them */
@media (max-width: 959px) {
  .u-scroll { overflow: hidden; display: flex; flex-direction: column; }
  .u-wrap { flex: 1; min-height: 0; width: 100%; padding-bottom: 0; }
  .u-side { flex: none; }
  .browsing .u-side { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .browsing .u-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    margin: 4px calc(-1 * var(--pad)) 0; padding: 0 var(--pad) calc(var(--sab) + 28px); }
  .u-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .u-group { flex: none; }
  .u-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    margin: 10px calc(-1 * var(--pad)) 0; padding: 0 var(--pad) calc(var(--sab) + 28px); }
  .u-body > .u-cards { margin-top: 0; }
}

/* the group in view: name, section, "all groups" */
.u-group {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--card); border-radius: 16px; text-align: left;
}
.u-group .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.u-group b { font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; } /* long names wrap, never cut */
.u-group small { font-size: 12.5px; color: var(--dim); }
.u-all { flex: none; display: flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--accent); }
.u-all svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.u-note { margin: 12px 4px 0; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.45; }
.u-note:empty { display: none; }

/* unit cards, as the currency cards: the name on top; the symbol (left) and the amount (right) on one line; the footer
   is the country and what the unit is (left) and one of the unit typed in, in this unit (right).
   Nothing is cut and nothing overlaps: texts wrap (the card grows); the amount stays on one line and js shrinks it to the
   room it has (fitVals), or puts it on a line of its own (.own). */
.u-cards { position: relative; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; touch-action: pan-y; }
/* swipe right to the top (js/units.js): the card over its background (.swipe-bg from app.css) */
.u-card { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.u-card.swiping { position: relative; z-index: 2; }
.swipe-bg.to-left { justify-content: flex-end; } /* "★ В избранное" on the side the card opens (a left swipe) */
/* the favourites: a star by a favourite's name on its group screen; the header star filled while they are on */
.u-star { margin-right: 5px; font-style: normal; color: var(--accent); }
#uFav .ic-star { fill: none; }
#uFav[aria-pressed="true"] { color: var(--accent); }
#uFav[aria-pressed="true"] .ic-star { fill: currentColor; }
/* the everyday units, then a line, then the rest (list view only: a grid row would be as tall as a tile) */
.u-sep { height: 1px; margin: 4px 14px; background: color-mix(in srgb, var(--dim) 30%, transparent); }
.u-tiles .u-sep { display: none; }
/* the favourites: a line between the groups in the tiles too (rows as tall as their tiles, not all equal there) */
.u-tiles .u-cards.u-favs { grid-auto-rows: auto; }
.u-tiles .u-cards.u-favs .u-sep { display: block; grid-column: 1 / -1; margin: 2px 14px; }
.u-btn {
  width: 100%; display: grid; grid-template-columns: 36px minmax(0, 1fr); grid-template-areas: "f n" "f m" "f o";
  align-items: center; column-gap: 12px; row-gap: 2px;
  min-height: 76px; padding: 12px 16px; background: var(--card); border-radius: 20px; border: 1.5px solid transparent; text-align: left;
  transition: border-color .2s, background .2s;
}
.u-card.active .u-btn { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--card-active); }
.u-card.lift { animation: lift .18s var(--ease); }
.u-card.bad .u-val, .u-ctry .bad { color: var(--danger); } /* typed off the scale (js: renderVals) */
.u-ctry .bad { font-weight: 600; }
.u-btn .flag { grid-area: f; width: 36px; height: 36px; }
.u-name { grid-area: n; min-width: 0; font-size: 16px; font-weight: 600; line-height: 1.25; overflow-wrap: break-word; }
.u-mid { grid-area: m; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.u-mid.own { flex-direction: column; align-items: stretch; gap: 0; }
.u-sym { flex: 0 1 auto; max-width: 50%; font-size: 14px; font-weight: 500; line-height: 1.25; color: var(--accent); overflow-wrap: break-word; }
.u-sym:empty { display: none; }
.own .u-sym { max-width: none; }
.own .u-val { flex: none; }
.u-val { flex: 1 1 0; min-width: 0; text-align: right; font-size: 24px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; }
.u-val.l1 { font-size: 20px; } .u-val.l2 { font-size: 17px; } .u-val.l3 { font-size: 15px; }
/* footer: the "one typed unit" amount stays on the line of the country if the country keeps at least ~45% of it; else it
   moves whole to a line of its own on the right (flex-wrap), never broken in the middle of a number or a symbol */
.u-foot { grid-area: o; min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 10px; row-gap: 1px; }
.u-ctry { flex: 1 1 45%; min-width: 0; font-size: 12px; line-height: 1.3; color: var(--dim); overflow-wrap: break-word; }
.u-eq { flex: 0 1 auto; margin-left: auto; max-width: 100%; text-align: right; font-size: 12px; line-height: 1.3; color: var(--dim); overflow-wrap: break-word; }
.u-eq:empty { display: none; }
.u-eq .n { white-space: nowrap; }
.u-eq .s { display: inline-block; max-width: 100%; }

/* tiles (the view button): the same parts, smaller; the flag beside the name, the footer on two lines at the bottom */
.u-tiles .u-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.u-tiles .u-card { display: flex; }
.u-tiles .u-btn {
  grid-template-columns: 24px minmax(0, 1fr); grid-template-areas: "f n" "m m" "o o"; grid-template-rows: auto auto 1fr;
  column-gap: 8px; row-gap: 3px; height: 100%; min-height: 0; padding: 11px 12px; border-radius: 16px;
}
.u-tiles .u-btn .flag { width: 24px; height: 24px; }
.u-tiles .u-name { font-size: 14px; }
.u-tiles .u-mid { gap: 8px; }
.u-tiles .u-sym { font-size: 12.5px; }
.u-tiles .u-val { font-size: 20px; }
.u-tiles .u-val.l1 { font-size: 17px; } .u-tiles .u-val.l2 { font-size: 15px; } .u-tiles .u-val.l3 { font-size: 13px; }
.u-tiles .u-foot { align-self: stretch; flex-direction: column; justify-content: space-between; gap: 4px; }
.u-tiles .u-ctry, .u-tiles .u-eq { font-size: 11px; }
.u-tiles .u-foot { flex-wrap: nowrap; }
.u-tiles .u-ctry { flex: 0 1 auto; }
.u-tiles .u-eq { align-self: flex-end; margin-left: 0; }
@media (min-width: 620px) { .u-tiles .u-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* the group list and search results */
.u-list { margin: 4px 0 0; }
.u-gi { width: 100%; display: flex; flex-direction: column; padding: 9px 10px; border-radius: 14px; text-align: left; }
.u-gi b { font-size: 16px; font-weight: 600; }
.u-gi small { font-size: 12.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-gi.note small { white-space: normal; }
.u-fixed { padding: 8px 4px 0; font-size: 13px; color: var(--dim); }
.u-gi.on { background: var(--accent-soft); }
.u-gi.on b { color: var(--accent); }
.u-gi:active { background: var(--card); }
.u-gi mark { background: none; color: var(--accent); }
.u-nc { display: flex; align-items: center; gap: 12px; padding: 9px 6px; }
.u-nc-i {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--key-fn); color: var(--dim); font: italic 700 15px/1 Georgia, serif;
}
.u-nc .t { flex: 1; min-width: 0; font-size: 14px; }
.u-nc .t b { font-weight: 600; }
.u-nc .t span { color: var(--dim); }
.u-nc small { display: block; font-size: 12px; color: var(--dim); }

/* the way in from the main screen: a strip above the main card, like the rate source bar under it; shows the group
   used last (or what the converter has, before the first use) */
.u-strip {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 38px; margin: 0 0 10px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 13px; background: var(--card);
  font: inherit; font-size: 13px; color: var(--dim); text-align: left; white-space: nowrap; cursor: pointer;
  transition: border-color .15s;
}
.u-strip svg { flex: none; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.u-strip .ic { width: 20px; height: 20px; stroke-width: 1.9; color: var(--accent); }
.u-strip .go { width: 16px; height: 16px; stroke-width: 2.2; }
.u-strip .tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.u-strip .tx i { font-style: normal; color: var(--dim); }
@media (hover: hover) { .u-strip:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); } }

@media (min-width: 960px) {
  .u-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 28px; align-items: start; padding-top: 14px; }
  .u-main { grid-column: 1; grid-row: 1; }
  .browsing .u-main { display: block; }
  .u-side {
    grid-column: 2; grid-row: 1; position: sticky; top: 14px;
    display: flex; flex-direction: column; max-height: calc(100vh - 110px);
    background: var(--card); border-radius: var(--r-card); padding: 16px;
  }
  .u-side .search { background: var(--card-2); }
  #uDone, .browsing #uDone { display: none; }
  .u-list { display: block; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 8px -16px 0; padding: 0 16px 8px; }
  .u-gi:hover, .u-list .pk-item:hover { background: var(--card-2); }
  .u-gi.on { background: var(--accent-soft); }
  .u-btn:hover .u-val { color: var(--accent); }
  .u-group:hover .u-all { text-decoration: underline; }
}

/* computer: the group's title stays on top while its cards scroll, as on phones */
@media (min-width: 960px) {
  .u-group { position: sticky; top: 14px; z-index: 5; } /* where it stands (the list's 14px top): it does not move */
  .u-group::before {
    content: ""; position: absolute; z-index: -2; pointer-events: none;
    left: -14px; right: -14px; top: -14px; bottom: -10px;
    --px: calc(var(--ux, 0px) + 14px); --py: var(--uy, 0px); /* the page's background: app.css */
  }
  .u-group::after { content: ""; position: absolute; z-index: -1; pointer-events: none; inset: 0; border-radius: inherit; background: var(--card); }
}
