:root {
  --bg: #0b1220;
  --bg-elev: #121b2e;
  --card: #16223a;
  --card-2: #1b2942;
  --line: #24344f;
  --text: #eaf0fb;
  --muted: #93a3be;
  --accent: #38d3c4;
  --accent-2: #4f8cff;
  --btc: #f7931a;
  --good: #35c987;
  --bad: #ff6b6b;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;
}
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f1f4fa;
  --line: #e2e8f2;
  --text: #16213a;
  --muted: #5f6d86;
  --accent: #12a99a;
  --accent-2: #2f6bf0;
  --shadow: 0 8px 24px rgba(24,43,77,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(79,140,255,.14), transparent 60%),
    radial-gradient(900px 480px at 8% 108%, rgba(56,211,196,.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand__logo { border-radius: 9px; box-shadow: var(--shadow); }
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.brand__accent { color: var(--accent); }
.brand__sub { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); cursor: pointer; transition: transform .12s, background .2s;
}
.icon-btn:active { transform: scale(.94); }
.icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: block; }

/* Status */
.status {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 12px;
}
.status__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status__dot.is-live { background: var(--good); box-shadow: 0 0 0 4px rgba(53,201,135,.16); }
.status__dot.is-stale { background: var(--btc); box-shadow: 0 0 0 4px rgba(247,147,26,.16); }
.status__dot.is-off { background: var(--bad); box-shadow: 0 0 0 4px rgba(255,107,107,.16); }
#statusText { flex: 1; }
.status__refresh {
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: inline-flex; padding: 4px; border-radius: 8px;
}
.status__refresh:active { color: var(--accent); }
.status__refresh.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Install-Button */
.install {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 13px; border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a; font-size: 15px; font-weight: 800; letter-spacing: .01em;
  box-shadow: var(--shadow);
}
.install[hidden] { display: none; }
.install:active { transform: scale(.98); }

.ioshint {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 16px; font-size: 13.5px; color: var(--text); box-shadow: var(--shadow);
}
.ioshint[hidden] { display: none; }
.ioshint p { margin: 0 0 6px; }
.ioshint ol { margin: 0; padding-left: 18px; color: var(--muted); }
.ioshint li { margin: 3px 0; }
.ioshint__share { color: var(--accent-2); font-weight: 700; }

/* Tabs */
.tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 5px; }
.tab {
  flex: 1; border: none; background: none; color: var(--muted);
  font-size: 14px; font-weight: 700; padding: 10px; border-radius: 10px; cursor: pointer;
  transition: color .2s, background .2s;
}
.tab--active { color: var(--text); background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.panel { display: none; flex-direction: column; gap: 14px; }
.panel--active { display: flex; }

/* Convert */
.conv { position: relative; }
.conv__row + .conv__row { margin-top: 8px; }
.conv__label { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.conv__field {
  display: flex; align-items: center; gap: 10px; margin-top: 6px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px;
}
.conv__amount {
  flex: 1; min-width: 0; background: none; border: none; color: var(--text);
  font-size: 27px; font-weight: 700; letter-spacing: -.01em; padding: 8px 0;
  outline: none; font-variant-numeric: tabular-nums;
}
.conv__amount--out { color: var(--accent); }
.conv__rate { text-align: center; font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }

.picker {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 9px 10px; cursor: pointer; color: var(--text); font-weight: 700; flex: none;
}
.picker:active { transform: scale(.97); }
.picker__flag { font-size: 19px; line-height: 1; }
.picker__code { font-size: 14px; letter-spacing: .02em; }
.picker svg { color: var(--muted); }

.swap {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a; border: 3px solid var(--card); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; z-index: 2;
  box-shadow: var(--shadow);
}
.swap:active { transform: translate(-50%, -50%) rotate(180deg) scale(.92); }
.swap { transition: transform .25s; }

/* BTC */
.btc__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.btc__title { font-weight: 800; color: var(--btc); font-size: 15px; }
.btc__live {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--good); background: rgba(53,201,135,.14); padding: 3px 8px; border-radius: 20px;
}
.btc__live.is-off { color: var(--bad); background: rgba(255,107,107,.14); }
.btc__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btc__item {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 13px;
  padding: 11px 13px; display: flex; flex-direction: column; gap: 3px;
}
.btc__item--wide { grid-column: 1 / -1; border-color: rgba(247,147,26,.35); }
.btc__k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.btc__v { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.btc__item--wide .btc__v { color: var(--btc); }

/* List */
.list__head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.list__base { display: flex; align-items: center; gap: 10px; background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px; }
.list__amount {
  flex: 1; min-width: 0; background: none; border: none; color: var(--text);
  font-size: 22px; font-weight: 700; padding: 6px 0; outline: none; font-variant-numeric: tabular-nums;
}
.list__search, .sheet__search {
  display: flex; align-items: center; gap: 9px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; color: var(--muted);
}
.list__search input, .sheet__search input {
  flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 14.5px;
}
.list__search input::placeholder, .sheet__search input::placeholder { color: var(--muted); }

.rows { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:last-child { border-bottom: none; }
.row__flag { font-size: 24px; line-height: 1; width: 30px; text-align: center; flex: none; }
.row__meta { flex: 1; min-width: 0; }
.row__code { font-weight: 800; font-size: 14.5px; display: flex; align-items: center; gap: 7px; }
.row__name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__val { text-align: right; flex: none; }
.row__amount { font-weight: 800; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.row__unit { font-size: 11px; color: var(--muted); }
.row--btc .row__code { color: var(--btc); }
.row--btc .row__amount { color: var(--btc); }
.star {
  border: none; background: none; cursor: pointer; color: var(--muted); padding: 4px; flex: none; font-size: 17px; line-height: 1;
}
.star.is-fav { color: var(--btc); }
.row--pinned { background: linear-gradient(90deg, rgba(247,147,26,.06), transparent); }

/* Footer */
.foot { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 4px 4px 0; }
.foot__brand { font-weight: 800; letter-spacing: .04em; opacity: .8; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(3,8,18,.6); backdrop-filter: blur(3px); }
.sheet__card {
  position: relative; width: 100%; max-width: 560px; max-height: 82dvh;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column; padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  animation: sheetUp .26s cubic-bezier(.22,1,.36,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet__title { font-weight: 800; font-size: 16px; }
.sheet__list { list-style: none; margin: 12px 0 0; padding: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__row {
  display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-radius: 10px; cursor: pointer;
}
.sheet__row:active, .sheet__row--active { background: var(--card-2); }
.sheet__row .flag { font-size: 23px; width: 28px; text-align: center; }
.sheet__row .code { font-weight: 800; font-size: 14.5px; width: 46px; }
.sheet__row .name { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet__row .check { color: var(--accent); opacity: 0; }
.sheet__row--active .check { opacity: 1; }

@media (min-width: 600px) {
  .sheet { align-items: center; }
  .sheet__card { border-radius: 22px; max-height: 78dvh; }
}
