:root {
  --bg: #eef1f2;
  --paper: #fffdf8;
  --ink: #090909;
  --muted: #6d726f;
  --line: rgba(9, 9, 9, 0.12);
  --money: #246f74;
  --danger: #e24b3f;
  --gold: #c88820;
  --pink: #d73d78;
  --shadow: 0 18px 44px rgba(20, 17, 12, 0.17);
  --shadow-tight: 0 9px 22px rgba(20, 17, 12, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Avenir Next", "SF Pro Display", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 14% 0%, rgba(36, 111, 116, 0.11), transparent 28rem),
    radial-gradient(circle at 92% 12%, rgba(226, 75, 63, 0.08), transparent 24rem),
    linear-gradient(180deg, #f9f7ef 0%, #eef1f2 46%, #edf2ec 100%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.48;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), transparent 34%),
    radial-gradient(circle at 50% 118%, rgba(9, 9, 9, 0.08), transparent 34rem);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

svg {
  display: block;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px clamp(12px, 2.4vw, 30px);
  background: rgba(9, 9, 9, 0.94);
  color: #fffaf0;
  box-shadow: 0 10px 30px rgba(9, 9, 9, 0.22);
  backdrop-filter: blur(18px);
}

.brand {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  color: currentColor;
  font-size: clamp(1.16rem, 2.1vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.wallet span {
  height: 36px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid rgba(255, 250, 240, 0.13);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.08);
  color: #fffaf0;
  font-size: 0.82rem;
  font-weight: 880;
  font-variant-numeric: tabular-nums;
}

.wallet svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.95;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wallet .net {
  color: #f4c366;
}

.wallet .coin {
  color: #66d3d8;
}

.wallet .gem {
  color: #ff76a8;
}

.viewport {
  height: calc(100svh - 58px);
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: clamp(14px, 2vw, 24px);
  overflow: auto;
  padding: clamp(12px, 2.4vw, 28px) clamp(12px, 2.4vw, 30px) calc(96px + env(safe-area-inset-bottom));
}

.spotlight {
  position: sticky;
  top: clamp(12px, 2.4vw, 28px);
  align-self: start;
  display: grid;
  gap: 12px;
}

.trade-panel,
.activity-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow-tight);
}

.trade-cover {
  position: relative;
  height: 170px;
  overflow: hidden;
  background: #ded8ca;
}

.cover-svg {
  width: 100%;
  height: 100%;
}

.trade-body {
  display: grid;
  gap: 13px;
  padding: 14px;
}

.profile-line {
  min-width: 0;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
}

.avatar,
.owner-pic {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)),
    var(--avatar);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 24px rgba(15, 13, 9, 0.18);
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  font-size: 1rem;
}

.identity {
  min-width: 0;
}

.name-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.name,
.handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name {
  margin: 0;
  color: #24211d;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.05;
}

.handle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.check {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #2f9ccc;
  color: #fff;
}

.check svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.price-chip {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  min-width: 94px;
  min-height: 40px;
  display: inline-grid;
  justify-content: center;
  align-content: center;
  gap: 1px;
  padding: 5px 11px 6px;
  border-radius: 999px;
  background: var(--money);
  color: #fff;
  box-shadow: 0 9px 18px rgba(36, 111, 116, 0.28);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.price-chip small {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.52rem;
  font-weight: 920;
  line-height: 1;
  text-transform: uppercase;
}

.price-chip b {
  display: block;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 950;
  line-height: 1.08;
}

.trade-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.trade-stats span {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid rgba(9, 9, 9, 0.08);
  border-radius: 8px;
  background: rgba(9, 9, 9, 0.035);
  color: #28241f;
  font-size: 0.82rem;
  font-weight: 880;
  font-variant-numeric: tabular-nums;
}

.trade-stats small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 860;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.buy,
.card-buy {
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fffaf0;
  font-size: 0.78rem;
  font-weight: 930;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

.buy:hover,
.card-buy:hover {
  transform: translateY(-1px);
}

.buy:disabled,
.card-buy:disabled {
  background: #cec5b6;
  color: #756d62;
  cursor: not-allowed;
}

.activity-panel {
  display: grid;
  padding: 12px;
}

.activity-row {
  min-height: 43px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(9, 9, 9, 0.07);
  color: #28241f;
  font-size: 0.79rem;
  font-weight: 810;
}

.activity-row:last-child {
  border-bottom: 0;
}

.activity-row .owner-pic {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 0.62rem;
}

.activity-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-price {
  color: var(--money);
  font-size: 0.72rem;
  font-weight: 920;
  font-variant-numeric: tabular-nums;
}

.market {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 10px;
  align-content: start;
  align-items: start;
}

.profile-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(9, 9, 9, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow-tight);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.profile-card:hover,
.profile-card.is-active {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: var(--shadow);
}

.profile-card.is-mine {
  border-color: rgba(36, 111, 116, 0.45);
}

.card-open {
  position: relative;
  z-index: 1;
  width: 100%;
  display: grid;
  grid-template-rows: var(--cover) auto;
  padding: 0;
  background: transparent;
  text-align: left;
}

.card-cover {
  position: relative;
  min-height: var(--cover);
  overflow: hidden;
  background: #ded8ca;
}

.card-body {
  display: grid;
  gap: 9px;
  padding: 0 10px 10px;
}

.card-body .avatar {
  position: relative;
  z-index: 4;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  border: 1px solid rgba(255, 250, 240, 0.72);
  font-size: 0.82rem;
}

.card-body .name {
  font-size: 0.96rem;
}

.card-body .handle {
  margin-top: 3px;
  font-size: 0.76rem;
}

.owner {
  min-width: 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.owner-pic {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 0.58rem;
}

.owner-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.owner small,
.card-meta small {
  color: #8b908c;
  font-size: 0.54rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.owner strong,
.owner span:last-child,
.owner-copy {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner strong {
  color: #353732;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.05;
}

.card-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  color: #58534b;
  font-variant-numeric: tabular-nums;
}

.card-meta span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.card-meta b {
  color: #3c3f3b;
  font-size: 0.68rem;
  font-weight: 930;
  line-height: 1.1;
}

.trend-up {
  color: var(--money);
}

.trend-down {
  color: var(--danger);
}

.card-buy {
  position: relative;
  z-index: 5;
  width: calc(100% - 20px);
  height: 38px;
  margin: 0 10px 10px;
  font-size: 0.7rem;
}

.empty {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(9, 9, 9, 0.2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 850;
}

.add {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 45;
  width: min(520px, calc(100vw - 22px));
  height: 52px;
  display: none;
  grid-template-columns: 1fr 52px;
  overflow: hidden;
  border: 1px solid rgba(9, 9, 9, 0.14);
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

body[data-mode="new"] .add {
  display: grid;
}

.add input,
.add button {
  min-width: 0;
  border: 0;
  background: transparent;
}

.add input {
  padding: 0 17px;
  outline: 0;
  color: #28241f;
  font-size: 1rem;
  font-weight: 820;
}

.add input::placeholder {
  color: #8e867b;
}

.add button {
  background: var(--ink);
  color: #fffaf0;
  font-size: 1.28rem;
  font-weight: 950;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 44;
  width: min(720px, calc(100vw - 20px));
  height: calc(70px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border: 1px solid rgba(255, 250, 240, 0.16);
  border-bottom: 0;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  background: rgba(9, 9, 9, 0.92);
  box-shadow: 0 -15px 36px rgba(9, 9, 9, 0.22);
  backdrop-filter: blur(18px);
}

.dock button {
  position: relative;
  display: grid;
  place-items: center;
  gap: 3px;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 250, 240, 0.6);
  font-size: 0.66rem;
  font-weight: 920;
  letter-spacing: 0;
  text-transform: uppercase;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.dock button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.95;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock button.is-active {
  background: #fffaf0;
  color: var(--ink);
}

.dock button:active {
  transform: translateY(1px);
}

.toast {
  position: fixed;
  left: 50%;
  top: 72px;
  z-index: 90;
  min-width: 138px;
  min-height: 40px;
  display: none;
  place-items: center;
  padding: 0 16px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(9, 9, 9, 0.92);
  color: #fffaf0;
  box-shadow: var(--shadow-tight);
  font-size: 0.84rem;
  font-weight: 920;
  font-variant-numeric: tabular-nums;
}

.toast.is-visible {
  display: grid;
  animation: toast 1.35s ease both;
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.98);
  }
  18%,
  76% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.98);
  }
}

@media (max-width: 960px) {
  .viewport {
    height: auto;
    min-height: calc(100svh - 58px);
    display: block;
    overflow: visible;
    padding: 10px 10px calc(88px + env(safe-area-inset-bottom));
  }

  .spotlight {
    display: none;
  }

  .market {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 54px;
    padding: 8px 9px;
  }

  .brand {
    max-width: 34vw;
    font-size: 1.06rem;
  }

  .wallet {
    gap: 5px;
  }

  .wallet span {
    height: 34px;
    gap: 5px;
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .wallet svg {
    width: 17px;
    height: 17px;
  }

  .wallet .gem {
    display: none;
  }

  .card-body {
    gap: 8px;
    padding: 0 9px 9px;
  }

  .card-body .avatar {
    width: 44px;
    height: 44px;
    margin-top: -22px;
    font-size: 0.76rem;
  }

  .card-body .name {
    font-size: 0.88rem;
  }

  .card-body .handle {
    font-size: 0.7rem;
  }

  .price-chip {
    top: 8px;
    right: 8px;
    min-width: 82px;
    min-height: 37px;
    padding: 5px 9px 6px;
  }

  .price-chip small {
    font-size: 0.48rem;
  }

  .price-chip b {
    font-size: 0.68rem;
  }

  .owner {
    grid-template-columns: 25px minmax(0, 1fr);
    gap: 6px;
    font-size: 0.67rem;
  }

  .owner-pic {
    width: 25px;
    height: 25px;
    border-radius: 6px;
    font-size: 0.52rem;
  }

  .card-meta {
    font-size: 0.61rem;
  }

  .card-buy {
    width: calc(100% - 18px);
    height: 35px;
    margin: 0 9px 9px;
    font-size: 0.7rem;
  }

  .dock {
    width: 100vw;
    height: calc(66px + env(safe-area-inset-bottom));
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .dock button {
    border-radius: 10px;
    font-size: 0.61rem;
  }

  .dock button svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 350px) {
  .market {
    grid-template-columns: 1fr;
  }

  .brand {
    max-width: 42vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
