/* fx.byfox.dev — 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;
  --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;
  --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; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
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;
}
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; }
.bar-tools { display: flex; align-items: center; gap: 6px; }

.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; }
.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: 14px; }
.cards > .card:first-child::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -13px; height: 1px; background: var(--line);
}
.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.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 0 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; }
.rate .arr { opacity: .7; }

/* 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; }

/* 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; }

.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 span {
  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; }
.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; }

/* 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-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: 28px; height: 28px; font-size: 11px; }
.ch-pair .swap { width: 36px; height: 36px; }
.ch-pair .swap svg { width: 18px; height: 18px; }
.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 .chg { font-size: 14px; font-weight: 600; }
.ch-now .chg.up { color: var(--up); } .ch-now .chg.down { color: var(--down); }
.ch-date { font-size: 13px; color: var(--dim); margin: 0 2px; min-height: 18px; }
.ch-plot { position: relative; height: 230px; margin: 10px 0 6px; touch-action: pan-y; }
.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; }
.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 .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; }
.ch-ranges { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; }
.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; }

/* 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) {
  .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 { background: var(--card-2); }
  .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; }
  .card .amt:hover .val { 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 span, .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; }
  .pk-item:hover, .pk-item.kb { background: var(--card-2); }
}

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