/* Peca Bit — PWA app shell (mobile-first, light theme) */

:root {
  --brand-500: #3b6bff;
  --brand-600: #2a55e0;
  --brand-050: #eef3ff;
  --mint-500: #12c8a0;
  --up: #0aa06e; --up-bg: #e8f7f1;
  --down: #e0433f; --down-bg: #fdeceb;
  --ink-900: #0b1220; --ink-700: #2b3444; --ink-500: #5a6577;
  --ink-400: #8b95a7; --ink-200: #d8dee9; --ink-100: #eaeef5; --ink-050: #f5f7fb;
  --white: #fff;
  --radius: 14px; --radius-lg: 20px; --radius-pill: 999px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--ink-050);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; }
a { color: var(--brand-600); text-decoration: none; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---- device frame on wide screens ---- */
.device {
  max-width: 440px; margin-inline: auto; min-height: 100dvh;
  background: var(--white); position: relative;
  display: flex; flex-direction: column;
}
@media (min-width: 900px) {
  body { background: #e9edf5; padding: 26px 0; }
  .device {
    min-height: min(880px, calc(100dvh - 52px));
    height: min(880px, calc(100dvh - 52px));
    border-radius: 30px; overflow: hidden;
    box-shadow: 0 30px 70px rgba(11, 18, 32, .16), 0 0 0 1px rgba(11, 18, 32, .06);
  }
}

/* ---- app bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ink-100);
  display: flex; align-items: center; gap: 12px; min-height: 58px;
}
.appbar__brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.02em; color: var(--ink-900); }
.appbar__brand img { width: 28px; height: 28px; border-radius: 8px; }
.appbar__title { display: block; font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.appbar__sub { display: block; font-size: .7rem; color: var(--ink-400); font-weight: 500; line-height: 1.3; }
.appbar__spacer { margin-left: auto; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--ink-100);
  background: var(--white); display: grid; place-items: center; color: var(--ink-700); cursor: pointer;
}
.iconbtn:active { background: var(--ink-050); }
.iconbtn.is-on { color: #e6a400; border-color: #ffe8b0; background: #fff8e6; }

.livedot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .68rem; font-weight: 600; color: var(--ink-500);
  background: var(--ink-050); border: 1px solid var(--ink-100);
  border-radius: var(--radius-pill); padding: 4px 10px;
}
.livedot i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint-500); animation: blip 2s infinite; }
.livedot.is-offline i { background: var(--ink-400); animation: none; }
@keyframes blip { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* ---- scroll area ---- */
.view {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 20px);
}
.view[hidden] { display: none; }

.sec-title {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-400); margin: 22px 0 10px;
}
.sec-title:first-child { margin-top: 4px; }

/* ---- hero balance-style summary ---- */
.summary {
  background: linear-gradient(135deg, #14224a 0%, #0b1220 60%);
  color: #fff; border-radius: var(--radius-lg); padding: 18px 20px 20px; margin-bottom: 6px;
}
.summary__label { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.summary__value { font-family: var(--mono); font-size: 1.9rem; font-weight: 600; letter-spacing: -.03em; margin: 4px 0 2px; }
.summary__row { display: flex; gap: 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); }
.summary__cell { flex: 1; }
.summary__cell span { display: block; font-size: .66rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .05em; }
.summary__cell b { font-family: var(--mono); font-size: .92rem; font-weight: 600; }

/* ---- generic list rows ---- */
.list { display: grid; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; transition: border-color .15s ease, transform .12s ease;
}
.row:active { transform: scale(.988); border-color: var(--ink-200); }
.coin {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-size: .66rem; font-weight: 700; letter-spacing: -.02em;
}
.row__meta { flex: 1; min-width: 0; }
.row__meta b { display: block; font-size: .9rem; font-weight: 600; }
.row__meta span { font-size: .72rem; color: var(--ink-400); }
.row__px { text-align: right; }
.row__px b { display: block; font-family: var(--mono); font-size: .9rem; font-weight: 600; }
.chg { font-family: var(--mono); font-size: .74rem; font-weight: 600; }
.chg--up { color: var(--up); } .chg--down { color: var(--down); }
.pill { display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); font-family: var(--mono); font-size: .72rem; font-weight: 700; }
.pill--up { background: var(--up-bg); color: var(--up); }
.pill--down { background: var(--down-bg); color: var(--down); }

.star { background: none; border: none; padding: 4px; cursor: pointer; color: var(--ink-200); flex: none; }
.star.is-on { color: #f2b32c; }

/* ---- movers scroller ---- */
.movers { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.movers::-webkit-scrollbar { display: none; }
.mover {
  flex: none; width: 132px; background: var(--white); border: 1px solid var(--ink-100);
  border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.mover__top { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.mover__top .coin { width: 26px; height: 26px; font-size: .56rem; }
.mover__top b { font-size: .78rem; }
.mover__px { font-family: var(--mono); font-size: .92rem; font-weight: 600; }
.spark { margin-top: 8px; height: 26px; width: 100%; }

/* ---- search + filters ---- */
.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius-pill);
  padding: 9px 14px; margin-bottom: 12px;
}
.search input { flex: 1; border: none; outline: none; font-size: .9rem; background: none; color: var(--ink-900); min-width: 0; }
.search svg { color: var(--ink-400); flex: none; }
.filters { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; border: 1px solid var(--ink-100); background: var(--white); color: var(--ink-700);
  border-radius: var(--radius-pill); padding: 7px 15px; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.filter.is-active { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }

/* ---- pair detail ---- */
.pairhead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.pairhead .coin { width: 44px; height: 44px; font-size: .74rem; }
.pairhead h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; }
.pairhead p { margin: 0; font-size: .74rem; color: var(--ink-400); }
.pairprice { font-family: var(--mono); font-size: 2rem; font-weight: 600; letter-spacing: -.03em; margin: 0; }
.pairsub { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--white); border: 1px solid var(--ink-100); border-radius: 12px; padding: 10px; }
.stat span { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-400); }
.stat b { font-family: var(--mono); font-size: .8rem; font-weight: 600; }

.chartcard { background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 6px; }
.chartcard__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.tf { display: flex; gap: 5px; }
.tf button {
  border: 1px solid var(--ink-100); background: var(--white); color: var(--ink-500);
  border-radius: 8px; padding: 4px 9px; font-size: .72rem; font-weight: 600; cursor: pointer;
}
.tf button.is-active { background: var(--brand-050); border-color: #cddaff; color: var(--brand-600); }
#candles { width: 100%; height: 210px; display: block; }

.book { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bookcol { background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius); padding: 12px; }
.bookcol h4 { margin: 0 0 8px; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); }
.bookrow { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .72rem; padding: 3px 0; position: relative; }
.bookrow em { position: absolute; inset: 0 auto 0 0; opacity: .12; border-radius: 3px; }
.bookrow span { position: relative; }
.bookrow.ask em { background: var(--down); } .bookrow.ask .p { color: var(--down); }
.bookrow.bid em { background: var(--up); } .bookrow.bid .p { color: var(--up); }

.trades { background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius); padding: 12px; }
.traderow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; font-family: var(--mono); font-size: .73rem; padding: 4px 0; }
.traderow:not(:last-child) { border-bottom: 1px solid var(--ink-050); }
.traderow .t { color: var(--ink-400); text-align: right; }

/* ---- profile ---- */
.profile-head {
  background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius-lg);
  padding: 20px; display: flex; align-items: center; gap: 14px; margin-bottom: 6px;
}
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #3b6bff, #12c8a0); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 1.1rem;
}
.profile-head b { display: block; font-size: 1rem; }
.profile-head span { display: block; font-size: .76rem; color: var(--ink-400); }
.profile-head .badge { display: inline-block; }
.badge {
  margin-top: 6px; font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px;
  border-radius: var(--radius-pill); background: var(--ink-050); color: var(--ink-500); border: 1px solid var(--ink-100);
}
.menu { background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius); overflow: hidden; }
.menu button {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: none; border: none; padding: 14px 16px; cursor: pointer; color: var(--ink-900);
}
.menu button:not(:last-child) { border-bottom: 1px solid var(--ink-050); }
.menu button:active { background: var(--ink-050); }
.menu .mi { width: 32px; height: 32px; border-radius: 10px; background: var(--ink-050); display: grid; place-items: center; color: var(--ink-500); flex: none; }
.menu .mt { flex: 1; }
.menu .mt b { display: block; font-size: .88rem; font-weight: 600; }
.menu .mt span { font-size: .72rem; color: var(--ink-400); }
.menu .ma { color: var(--ink-200); flex: none; }

/* ---- notices, empty states ---- */
.note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--brand-050); border: 1px solid #dbe5ff; border-radius: var(--radius);
  padding: 12px 14px; font-size: .78rem; color: var(--ink-700); line-height: 1.5;
}
.note svg { flex: none; color: var(--brand-600); margin-top: 1px; }
.note strong { color: var(--ink-900); }

.empty { text-align: center; padding: 48px 24px; color: var(--ink-400); }
.empty svg { margin: 0 auto 14px; color: var(--ink-200); }
.empty b { display: block; color: var(--ink-700); font-size: .95rem; margin-bottom: 5px; }
.empty p { font-size: .82rem; margin: 0 0 16px; }

.skel { background: linear-gradient(90deg, var(--ink-050) 25%, #eef1f7 50%, var(--ink-050) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* ---- tab bar ---- */
.tabbar {
  position: sticky; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--ink-100);
  padding-bottom: var(--safe-b); height: calc(var(--tabbar-h) + var(--safe-b));
}
.tab {
  background: none; border: none; cursor: pointer;
  display: grid; justify-items: center; align-content: center; gap: 3px;
  font-size: .62rem; font-weight: 600; color: var(--ink-400); padding: 0;
}
.tab.is-active { color: var(--brand-500); }
.tab svg { width: 21px; height: 21px; }

/* ---- toast / modal ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  transform: translate(-50%, 12px); z-index: 90;
  background: var(--ink-900); color: #fff; font-size: .8rem;
  padding: 11px 18px; border-radius: var(--radius-pill);
  box-shadow: 0 10px 30px rgba(11, 18, 32, .28);
  opacity: 0; pointer-events: none; transition: opacity .22s ease, transform .22s ease;
  max-width: calc(100% - 40px); text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.sheet {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: flex-end; justify-content: center; background: rgba(11, 18, 32, .42);
}
.sheet.is-on { display: flex; }
.sheet__card {
  background: #fff; width: 100%; max-width: 440px;
  border-radius: 22px 22px 0 0; padding: 24px 22px calc(24px + var(--safe-b));
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(18px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet__card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.sheet__card p { margin: 0 0 18px; font-size: .87rem; color: var(--ink-500); line-height: 1.55; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: .92rem; padding: 12px 22px; border-radius: var(--radius-pill);
  border: 1px solid transparent; cursor: pointer; width: 100%;
}
.btn--primary { background: var(--brand-500); color: #fff; }
.btn--ghost { background: #fff; border-color: var(--ink-200); color: var(--ink-900); }

.installbar {
  display: none; align-items: center; gap: 12px; margin-bottom: 14px;
  background: var(--white); border: 1px solid var(--ink-100); border-radius: var(--radius); padding: 12px 14px;
}
.installbar.is-on { display: flex; }
.installbar b { display: block; font-size: .84rem; }
.installbar span { font-size: .72rem; color: var(--ink-400); }
.installbar button {
  margin-left: auto; flex: none; width: auto; padding: 8px 16px; font-size: .8rem;
  border-radius: var(--radius-pill); border: none; background: var(--brand-500); color: #fff; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
