:root {
  --bg: #1c1c1e;
  --side: #2a2a2c;
  --side-border: #3a3a3c;
  --card: #2c2c2e;
  --text: #ffffff;
  --text-2: #8e8e93;
  --text-3: #d1d1d6;
  --muted: #636366;
  --green: #34c759;
  --red: #ff453a;
  --blue: #3b82f6;
  --select: #3a3a3c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Text", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
}

body {
  min-height: 100%;
  min-height: 100dvh;
}

.native {
  min-height: 100%;
  min-height: 100dvh;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "header header"
    "side main"
    "dock dock";
  background: var(--bg);
  overflow: hidden;
}

.side {
  grid-area: side;
}

.main {
  grid-area: main;
  min-height: 0;
}

.watch-tabs {
  display: none;
}

.side {
  background: var(--side);
  border-right: 1px solid var(--side-border);
  padding: 18px 10px 14px;
  display: flex;
  flex-direction: column;
}

.side h1 {
  display: none;
}

.pro {
  background: var(--blue);
  font-size: 8px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}

.side p {
  margin: 0 8px 6px;
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.side .app-label,
#app-nav {
  display: none;
}

.side button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text-3);
  font: 500 13px Inter, sans-serif;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.side button.on {
  background: var(--select);
  color: var(--text);
  font-weight: 600;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.toolbar {
  padding: 18px 20px 4px;
  flex-shrink: 0;
}

.toolbar h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 10px 14px 8px 12px;
  color: var(--text-2);
  font-size: 13.5px;
  flex-shrink: 0;
}

.filters button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  color: var(--text);
  font: 500 13.5px Inter, sans-serif;
  cursor: pointer;
  padding: 0;
}

.filters .count {
  justify-self: end;
  color: var(--text-2);
  font-size: 12.5px;
}

.filters .mid {
  justify-self: center;
}

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 12px 12px;
  align-content: start;
  overflow: auto;
}

@media (min-width: 1400px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.card {
  background: var(--card);
  border-radius: 8px;
  padding: 8px 10px 6px;
  min-height: 102px;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(108px, 6fr);
  gap: 6px;
  cursor: pointer;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card:hover {
  background: #323234;
}

.card.holding {
  transform: scale(0.985);
  background: #323234;
}

.card.dragging {
  z-index: 5;
  opacity: 1;
  transform: scale(1.045);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  cursor: grabbing;
}

.grid.custom-sort .card {
  cursor: grab;
}

.grid.reordering {
  user-select: none;
  touch-action: none;
}

.grid.reordering .card {
  cursor: grabbing;
}

.grid.reordering .card:not(.dragging) {
  opacity: 0.7;
}

.card > :first-child {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
}

.ex {
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.pair {
  color: #ececf0;
  font-size: 14.5px;
  font-weight: 300;
  letter-spacing: 0.1px;
  margin: 5px 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kind {
  color: var(--text-2);
  font-size: 10px;
  white-space: nowrap;
}

.right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  min-width: 0;
  text-align: right;
}

.spark {
  width: 78px;
  height: 46px;
  display: block;
}

.price-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 3px;
}

.tee {
  width: 9px;
  height: 13px;
  flex-shrink: 0;
  color: #8e8e93;
}

.price {
  font-size: 16.5px;
  font-weight: 400;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-family: Inter, "SF Pro Text", ui-sans-serif, system-ui, sans-serif;
}

.chg {
  font-size: 10.5px;
  font-weight: 300;
  margin-top: 4px;
}

.up {
  color: var(--green);
}

.dn {
  color: var(--red);
}

.placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  text-align: center;
  padding: 40px 20px;
  gap: 8px;
}

.placeholder h3 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
}

.placeholder p {
  margin: 0;
  font-size: 14px;
}

.detail {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 16px 12px;
}

.detail.hidden {
  display: none;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0 10px;
}

.detail-back {
  width: 32px;
  height: 32px;
  margin-top: 2px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.detail-back svg {
  width: 20px;
  height: 20px;
}

.detail-title {
  flex: 1;
  min-width: 0;
}

.detail-title .pair {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 300;
}

.detail-px {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-px .price {
  display: block;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.2px;
  font-family: Inter, "SF Pro Text", ui-sans-serif, system-ui, sans-serif;
}

.detail-px .chg {
  margin-top: 4px;
  font-size: 13px;
}

.detail-tf {
  display: flex;
  gap: 16px;
  padding: 2px 0 10px 32px;
}

.detail-tf button {
  background: none;
  border: 0;
  color: var(--text-2);
  font: 500 13px Inter, sans-serif;
  cursor: pointer;
  padding: 4px 0;
}

.detail-tf button.on {
  color: var(--text);
  box-shadow: inset 0 -2px 0 #2962ff;
}

.chart-wrap {
  flex: 1;
  min-height: 220px;
  background: #131722;
  border: 1px solid #1f2128;
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
}

.chart-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.ico {
  width: 16px;
  height: 16px;
  color: var(--text-2);
}

.empty-search {
  grid-column: 1 / -1;
  color: var(--text-2);
  text-align: center;
  padding: 36px 12px;
  font-size: 14px;
}

.app-header {
  grid-area: header;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: relative;
  z-index: 4;
  padding: 10px 16px;
  flex-shrink: 0;
  background: var(--bg);
}

.app-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile,
.header-actions button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--text-3);
  cursor: pointer;
  padding: 0;
}

.profile {
  justify-self: start;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #2c2c2e;
  color: var(--text-2);
}

.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 2px;
}

.profile svg,
.header-actions svg {
  width: 22px;
  height: 22px;
  display: block;
}

.profile svg {
  width: 18px;
  height: 18px;
}

.header-actions button.on,
.header-actions button[aria-pressed="true"] {
  color: var(--text);
}

.profile-menu {
  position: absolute;
  top: calc(100% - 4px);
  left: 12px;
  z-index: 8;
  min-width: 200px;
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.profile-menu strong {
  display: block;
  font-size: 14px;
}

.profile-menu p {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 12.5px;
}

.profile-action {
  margin-top: 8px;
  width: 100%;
  background: #3a3a3c;
  border: 0;
  color: var(--text);
  font: 600 12.5px Inter, sans-serif;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.settings-page {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 20px 28px;
}

.settings-heading {
  display: none;
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.settings-block {
  max-width: 560px;
}

.settings-block h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
}

.settings-block p {
  margin: 0 0 12px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.4;
}

.settings-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.settings-switch {
  appearance: none;
  flex: 0 0 46px;
  width: 46px;
  height: 28px;
  margin: 0;
  background: #3a3a3c;
  border: 0;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
}

.settings-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d1d1d6;
}

.settings-switch:checked {
  background: var(--blue);
}

.settings-switch:checked::after {
  left: 21px;
  background: #fff;
}

.profile.in .profile-svg {
  display: none;
}

.profile-initial {
  display: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.profile.in .profile-initial {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.62);
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
}

.auth-close svg {
  width: 16px;
  height: 16px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-tabs button {
  background: none;
  border: 0;
  color: var(--text-2);
  font: 600 15px Inter, sans-serif;
  padding: 4px 2px 8px;
  cursor: pointer;
}

.auth-tabs button.on {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--text);
}

.auth-lede,
.auth-pin-copy {
  margin: 0 0 14px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.4;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-card input {
  width: 100%;
  background: #1c1c1e;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font: 400 16px Inter, sans-serif;
  padding: 12px 14px;
  outline: none;
}

#one-time-code {
  font: 700 28px/1.2 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.42em;
  text-align: center;
  padding-left: 0.42em;
}

.auth-card button[type="submit"] {
  background: var(--blue);
  border: 0;
  color: #fff;
  font: 600 14px Inter, sans-serif;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}

.auth-card button[type="submit"]:disabled,
.auth-resend:disabled {
  opacity: 0.55;
  cursor: default;
}

.auth-resend {
  background: none;
  border: 0;
  color: var(--text-3);
  font: 500 13px Inter, sans-serif;
  cursor: pointer;
  padding: 4px;
}

.auth-status {
  min-height: 1.2em;
  margin: 12px 0 0;
  color: var(--text-2);
  font-size: 13px;
}

.auth-status.err {
  color: var(--red);
}

.native.hinting .grid {
  padding-bottom: 88px;
}

.hint-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(66px + env(safe-area-inset-bottom, 0px));
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.hint-bar p {
  margin: 0;
  flex: 1 1 220px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
}

.hint-actions {
  display: flex;
  gap: 8px;
}

.hint-actions button {
  background: var(--blue);
  border: 0;
  color: #fff;
  font: 600 12.5px Inter, sans-serif;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.hint-actions .hint-dismiss {
  background: #3a3a3c;
  color: var(--text);
}

.search-bar {
  position: relative;
  padding: 4px 16px 10px;
  flex-shrink: 0;
}

.search-bar .search-ico {
  position: absolute;
  left: 28px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -11px;
  color: var(--text-2);
}

.search-bar input {
  width: 100%;
  background: #2c2c2e;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font: 400 15px Inter, sans-serif;
  padding: 10px 12px 10px 38px;
  outline: none;
}

.search-bar input::placeholder {
  color: var(--muted);
}

.watch-tabs {
  align-items: flex-end;
  gap: 18px;
  padding: 0 16px;
  height: 34px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  flex-shrink: 0;
}

.watch-tabs::-webkit-scrollbar {
  display: none;
}

.watch-tabs button {
  flex: 0 0 auto;
  background: none;
  border: 0;
  color: var(--text-2);
  font: 400 14.5px Inter, sans-serif;
  padding: 0 0 6px;
  cursor: pointer;
  position: relative;
}

.watch-tabs button.on {
  color: var(--text);
  font-weight: 600;
}

.watch-tabs button.on::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 22px;
  height: 1.6px;
  margin-left: -11px;
  background: var(--text);
  border-radius: 2px;
}

.dock {
  display: flex;
  grid-area: dock;
  align-items: stretch;
  justify-content: space-around;
  border-top: 0.5px solid #2c2c2e;
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
}

.dock button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 58px;
  background: none;
  border: 0;
  color: var(--muted);
  font: 400 11px Inter, sans-serif;
  cursor: pointer;
  padding: 0;
}

.dock button.on {
  color: var(--text);
  font-weight: 600;
}

.dock .ico {
  width: 24px;
  height: 24px;
  color: inherit;
}

@media (max-width: 820px) {
  html,
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .native {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .side {
    display: none;
  }

  .app-header {
    padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
  }

  .watch-tabs {
    display: flex;
    overflow-x: auto;
    overflow-y: visible;
    touch-action: pan-x pan-y;
  }

  .native.app-page .watch-tabs,
  .native.detail-open .watch-tabs {
    display: none;
  }

  .dock {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
  }

  .hint-bar {
    left: 12px;
    right: 12px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .native.hinting .main {
    padding-bottom: calc(128px + env(safe-area-inset-bottom, 0px));
  }

  .main {
    min-height: 0;
    overflow: visible;
    flex: 1 0 auto;
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }

  .toolbar {
    display: none;
  }

  .settings-page {
    padding: 10px 16px 28px;
  }

  .settings-heading {
    display: block;
  }

  .search-bar {
    padding: 4px 12px 10px;
  }

  .filters {
    padding: 10px 12px 8px;
    font-size: 12.5px;
  }

  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 4px 8px 12px;
    overflow: visible;
  }

  .card {
    padding: 7px 8px 5px;
    min-height: 96px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .pair {
    font-size: 13.5px;
    margin: 3px 0 2px;
  }

  .spark {
    width: 70px;
    height: 42px;
  }

  .detail {
    padding: 2px 10px 8px;
    min-height: calc(100dvh - 90px);
  }

  .detail-title .pair,
  .detail-px .price {
    font-size: 18px;
  }

  .detail-tf {
    padding-left: 8px;
    gap: 14px;
  }

  .chart-wrap {
    min-height: min(70dvh, 520px);
  }
}

@media (max-width: 520px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .spark {
    width: 64px;
    height: 38px;
  }
}
