:root {
  --bg: #101114;
  --bg-2: #16161a;
  --ink: #ededed;
  --secondary: #a1a1a6;
  --muted: #85858b;
  --line: rgba(237, 237, 237, 0.08);
  --line-strong: rgba(237, 237, 237, 0.14);
  --card: rgba(255, 255, 255, 0.045);
  --card-2: rgba(255, 255, 255, 0.07);
  --accent: #d4f52b;
  --accent-ink: #1a1c0a;
  --good: #8fbf6a;
  --bad: #e5484d;
  --radius: 16px;
  --control: 10px;
  --nav: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: #0c0c0e;
  color: var(--ink);
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.app {
  width: min(100%, 430px);
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 40% at 100% -10%, rgba(212, 245, 43, 0.08), transparent 46%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 28%);
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 64px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 0;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(16, 17, 20, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.top-copy { flex: 1; min-width: 0; }
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}
h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 28px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--control);
  background: var(--card);
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn:active { transform: scale(0.96); }
.icon-btn[hidden] { display: none; }
.icon-btn svg { width: 18px; height: 18px; }

.view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 16px calc(var(--nav) + 16px + env(safe-area-inset-bottom));
}
.view.thread-mode {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.view.in .rise {
  animation: rise 0.5s var(--ease) both;
}
.view.in .rise:nth-child(2) { animation-delay: 0.04s; }
.view.in .rise:nth-child(3) { animation-delay: 0.08s; }
.view.in .rise:nth-child(4) { animation-delay: 0.12s; }
.view.in .rise:nth-child(n + 5) { animation-delay: 0.16s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.card, .row, .bubble, .sheet, .nav {
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}
.balance .sum {
  margin: 12px 0 4px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 44px;
}
.balance .sum span { color: var(--accent); }
.meta {
  display: flex;
  gap: 16px;
  color: var(--secondary);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.pip {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--good);
  display: inline-block;
  margin-right: 8px;
}
.pip.off { background: var(--bad); }
.sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 36%, rgba(212, 245, 43, 0.14) 50%, transparent 64%);
  transform: translateX(-70%);
  animation: sheen 8s var(--ease) infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%, 55% { transform: translateX(-70%); }
  100% { transform: translateX(70%); }
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { padding: 16px; }
.stat b {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 500;
}
.label { color: var(--muted); font-size: 13px; }

.search, .composer input, textarea, .sheet input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: var(--control);
  padding: 12px;
  outline: none;
}
.search:focus, textarea:focus, .sheet input:focus, .composer input:focus {
  border-color: rgba(212, 245, 43, 0.7);
}
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.row {
  width: 100%;
  text-align: left;
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}
.row {
  position: relative;
  overflow: hidden;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.row::after,
.icon-btn::after,
.chip::after,
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 32%, rgba(212, 245, 43, 0.2) 50%, transparent 68%);
  transform: translateX(-130%);
  pointer-events: none;
}
.icon-btn,
.chip,
.btn,
.nav-btn,
.shot img {
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.22s var(--ease);
}
.icon-btn,
.btn { position: relative; overflow: hidden; }
@media (hover: hover) {
  .row:hover,
  .icon-btn:hover,
  .pick:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(212, 245, 43, 0.5);
  }
  .row:hover::after,
  .icon-btn:hover::after,
  .chip:hover::after,
  .btn:hover::after {
    transform: translateX(130%);
    transition: transform 0.55s var(--ease);
  }
  .chip:hover:not(.on) {
    color: var(--ink);
    background: rgba(212, 245, 43, 0.1);
    border-color: rgba(212, 245, 43, 0.5);
  }
  .btn:hover { filter: brightness(1.08); }
  .btn.ghost:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(212, 245, 43, 0.5);
  }
  .nav-btn:hover:not(.on) { color: var(--ink); }
  .shot:hover img { transform: scale(1.03); }
  .search:hover, .composer input:hover, textarea:hover, .sheet input:hover {
    border-color: rgba(237, 237, 237, 0.2);
  }
}
.row:active, .btn:active { transform: scale(0.98); }
.row strong, .row em { font-style: normal; font-weight: 500; }
.row em, .preview, .empty { color: var(--secondary); }
.preview {
  grid-column: 1 / -1;
  font-size: 13px;
  line-height: 18px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 4px;
  background: var(--accent);
}
.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.chip {
  position: relative;
  overflow: hidden;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--secondary);
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: 8px;
}
.bubble {
  max-width: 86%;
  padding: 12px;
  border-radius: 14px 14px 14px 4px;
  background: var(--card);
  line-height: 20px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.mine {
  margin-left: auto;
  border-radius: 14px 14px 4px 14px;
  background: rgba(212, 245, 43, 0.12);
}
.bubble.system {
  max-width: 100%;
  margin: 0;
  text-align: center;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}
.bubble small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.shot {
  display: block;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 10px;
  overflow: hidden;
}
.shot img {
  display: block;
  width: min(100%, 260px);
  max-height: 320px;
  object-fit: contain;
  border-radius: 10px;
  background: #0c0c0e;
}
.pick img {
  display: block;
  width: 72px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
}
.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px -16px 0;
  padding: 8px 16px calc(var(--nav) + env(safe-area-inset-bottom));
  background: rgba(16, 17, 20, 0.8);
  backdrop-filter: blur(16px);
}
.composer-row { display: flex; gap: 8px; align-items: center; }
.composer-row #msg {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 44px;
}
.composer-row .clip {
  flex: none;
  width: 44px;
  height: 44px;
}
.composer-row .btn {
  flex: none;
  height: 44px;
  padding: 0 16px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.composer-row .btn::after { content: none; }
.picks { display: flex; gap: 8px; overflow-x: auto; }
.picks:empty { display: none; }
.pick {
  position: relative;
  flex: none;
  min-width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  display: grid;
  place-items: center;
  padding: 4px;
}
.pick img { width: 72px; height: 64px; }
.pick span {
  max-width: 96px;
  font-size: 11px;
  color: var(--secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 10px;
  background: #101114;
  color: var(--ink);
  line-height: 18px;
}
.light {
  position: fixed;
  inset: 0;
  z-index: 12;
  border: 0;
  padding: 24px;
  background: rgba(8, 8, 10, 0.88);
  display: grid;
  place-items: center;
}
.light[hidden] { display: none; }
.light img {
  max-width: min(100%, 860px);
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
}
.btn {
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--control);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.resell { display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.resell h2 { margin: 8px 0 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.resell input, .resell textarea {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: 10px;
  color: var(--ink);
  padding: 0 12px;
}
.resell textarea { height: 88px; padding: 10px 12px; resize: vertical; }
.resell .mini { margin: 0; color: var(--secondary); font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.actions .chip { flex: none; }
.preview-box, .logbox {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.45;
  color: var(--secondary);
}
.logbox { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; }
.deal { background: var(--card); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.deal-top, .line { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.deal-top b, .line b { font-weight: 500; font-variant-numeric: tabular-nums; }
.deal-top span, .line span { color: var(--secondary); font-size: 13px; }
.line b.up { color: var(--accent); }
.line b.down { color: var(--bad); }
.sumrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sumrow div { background: var(--card); border-radius: 12px; padding: 10px 12px; }
.sumrow span { display: block; color: var(--secondary); font-size: 12px; }
.sumrow b { font-weight: 500; font-variant-numeric: tabular-nums; }
.sumrow b.up { color: var(--accent); }
.sumrow b.down { color: var(--bad); }
.deal .btn { width: 100%; margin-top: 6px; }
.group-title {
  margin: 20px 0 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 500;
}
.switch {
  width: 44px;
  height: 28px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #232325;
  padding: 2px;
  justify-self: end;
}
.switch i {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #ededed;
  transform: translateX(0);
  transition: transform 0.28s var(--ease), background 0.28s var(--ease);
}
.switch.on { background: var(--accent); }
.switch.on i { transform: translateX(16px); background: var(--accent-ink); }
.set-row { align-items: center; }
.value {
  color: var(--muted);
  font-size: 13px;
  justify-self: end;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 430px);
  height: calc(var(--nav) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(16, 17, 20, 0.78);
  backdrop-filter: blur(18px);
  border-radius: 16px 16px 0 0;
  z-index: 6;
}
.nav-btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 52px;
}
.nav-btn.on { color: var(--accent-ink); }
.nav-ind {
  position: absolute;
  top: 6px;
  left: 8px;
  width: calc((100% - 16px) / 4);
  height: 52px;
  border-radius: 12px;
  background: var(--accent);
  z-index: 0;
  will-change: transform;
}
.sk {
  height: 72px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { padding: 24px 8px; text-align: center; }
.nav[hidden], .icon-btn[hidden] { display: none !important; }
.gate {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.gate p { margin: 0; font-size: 16px; line-height: 1.45; }
.gate p + p { margin-top: 10px; color: var(--secondary); font-size: 14px; line-height: 1.4; }

.sheet-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 8;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-back[hidden] { display: none; }
.sheet {
  width: min(100%, 430px);
  background: rgba(22, 22, 26, 0.92);
  backdrop-filter: blur(20px);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform 0.42s var(--ease);
}
.sheet.open { transform: translateY(0); }
.grab {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 4px auto 12px;
}
.sheet h2 { margin: 0 0 8px; font-size: 18px; font-weight: 500; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 12px; min-height: 16px; }
.sheet textarea { min-height: 120px; resize: vertical; }
.sheet input { height: 44px; margin-bottom: 12px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet-actions .btn { flex: 1; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  width: min(92%, 400px);
  background: #232325;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 16px;
  z-index: 9;
  opacity: 0;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .view.in .rise { opacity: 1; transform: none; }
}
