:root {
  --square-bg: #0b0e11;
  --square-card: #161a1e;
  --square-elevated: #1e2329;
  --square-line: #262c33;
  --square-text: #eaecef;
  --square-muted: #848e9c;
  --square-yellow: #f0b90b;
  --square-green: #0ecb81;
  --square-red: #f6465d;
}

body.has-bottom-nav {
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

body.is-square-view {
  background: var(--square-bg);
}

body.is-square-view .topbar,
body.is-square-view main,
body.is-square-view .footer,
body.is-square-view .back-to-top,
body.is-square-view .page-glow {
  display: none !important;
}

.square-view[hidden] {
  display: none !important;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 220;
  width: min(100%, 680px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 7px 12px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, .09);
  background: rgba(11, 14, 17, .96);
  box-shadow: 0 -12px 34px rgba(0, 0, 0, .35);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.bottom-nav__item {
  position: relative;
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 5px 8px;
  border: 0;
  border-radius: 13px;
  color: #727b87;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.bottom-nav__item svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav__item.is-active {
  color: var(--square-yellow);
  background: rgba(240, 185, 11, .09);
}

.bottom-nav__item.is-active::after {
  position: absolute;
  top: 4px;
  right: 18px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--square-yellow);
  content: '';
  box-shadow: 0 0 0 4px rgba(240, 185, 11, .11);
}

.square-view {
  min-height: 100vh;
  padding: 0 0 calc(88px + env(safe-area-inset-bottom));
  color: var(--square-text);
  background:
    radial-gradient(circle at 88% 4%, rgba(240, 185, 11, .11), transparent 25%),
    var(--square-bg);
}

.square-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(11px + env(safe-area-inset-top)) 14px 11px;
  border-bottom: 1px solid var(--square-line);
  background: rgba(11, 14, 17, .96);
  backdrop-filter: blur(18px);
}

.square-topbar__brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.square-topbar__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #0b0e11;
  background: var(--square-yellow);
  font-size: 18px;
  font-weight: 950;
  box-shadow: 0 8px 24px rgba(240, 185, 11, .22);
}

.square-topbar__brand strong,
.square-topbar__brand small {
  display: block;
}

.square-topbar__brand strong {
  font-size: 17px;
  line-height: 1.2;
}

.square-topbar__brand small {
  margin-top: 3px;
  color: var(--square-muted);
  font-size: 10px;
}

.square-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.square-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--square-yellow);
  font-size: 10px;
  font-weight: 800;
}

.square-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(240, 185, 11, .12);
}

.square-icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--square-line);
  border-radius: 10px;
  color: var(--square-text);
  background: rgba(255, 255, 255, .04);
  font-size: 18px;
  cursor: pointer;
}

.square-icon-btn.is-loading {
  animation: square-spin 1s linear infinite;
}

@keyframes square-spin {
  to { transform: rotate(360deg); }
}

.square-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--square-line);
  scrollbar-width: none;
}

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

.square-tabs button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--square-line);
  border-radius: 999px;
  color: var(--square-muted);
  background: rgba(255, 255, 255, .025);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.square-tabs button.is-active {
  border-color: var(--square-yellow);
  color: #0b0e11;
  background: var(--square-yellow);
}

.square-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 14px 0;
  padding: 9px 11px;
  border: 1px solid #2b3139;
  border-radius: 12px;
  color: #aeb4bc;
  background: #13161a;
  font-size: 11px;
  line-height: 1.45;
}

.square-notice__dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--square-yellow);
  box-shadow: 0 0 0 4px rgba(240, 185, 11, .12);
}

.square-feed {
  display: grid;
  gap: 12px;
  padding: 12px 14px 18px;
}

.square-card {
  padding: 14px;
  border: 1px solid var(--square-line);
  border-radius: 17px;
  background: var(--square-card);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .22);
}

.square-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.square-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #0b0e11;
  background: var(--avatar-color, var(--square-yellow));
  font-size: 15px;
  font-weight: 950;
}

.square-avatar {
  position: relative;
  overflow: hidden;
}

.square-avatar__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.square-avatar img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.square-card__meta {
  min-width: 0;
  flex: 1;
}

.square-card__meta strong,
.square-card__meta small {
  display: block;
}

.square-card__meta strong {
  overflow: hidden;
  color: var(--square-text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.square-card__meta small {
  margin-top: 3px;
  color: var(--square-muted);
  font-size: 10px;
}

.square-card__more {
  color: var(--square-muted);
  font-size: 19px;
  line-height: 1;
}

.square-card__text {
  margin: 12px 0 0;
  color: var(--square-text);
  font-size: 14px;
  line-height: 1.58;
  white-space: pre-line;
  word-break: break-word;
}

.square-market {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 11px;
  border: 1px solid #2b3139;
  border-radius: 12px;
  background: #101419;
}

.square-market__symbol {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.square-market__badge {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  color: #0b0e11;
  background: var(--square-yellow);
  font-size: 11px;
  font-weight: 950;
}

.square-market__name,
.square-market__sub {
  display: block;
}

.square-market__name {
  font-size: 12px;
  font-weight: 850;
}

.square-market__sub {
  margin-top: 2px;
  color: var(--square-muted);
  font-size: 10px;
}

.square-market__pnl {
  flex: 0 0 auto;
  color: var(--square-green);
  font-size: 11px;
  font-weight: 850;
  text-align: right;
}

.square-market__pnl.is-down {
  color: var(--square-red);
}

.square-media {
  margin-top: 12px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid #262c33;
  border-radius: 14px;
  background: #0e1114;
}

.square-media__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--square-text);
  font-size: 11px;
}

.square-media__head strong {
  font-size: 12px;
}

.square-media__change {
  color: var(--square-green);
  font-weight: 850;
}

.square-media__change.is-down {
  color: var(--square-red);
}

.square-sparkline {
  display: block;
  width: 100%;
  height: 116px;
  margin-top: 6px;
}

.square-media__position {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  padding: 8px 9px;
  border-radius: 9px;
  color: #aeb4bc;
  background: #1a1f24;
  font-size: 10px;
}

.square-media__position b {
  color: var(--square-green);
  font-weight: 850;
}

.square-post-image-wrap {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid #262c33;
  border-radius: 14px;
  background: #0e1114;
}

.square-post-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.square-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.square-tag {
  padding: 4px 8px;
  border: 1px solid rgba(240, 185, 11, .25);
  border-radius: 999px;
  color: var(--square-yellow);
  background: rgba(240, 185, 11, .1);
  font-size: 10px;
  font-weight: 750;
}

.square-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid #242a31;
  color: var(--square-muted);
  font-size: 11px;
}

.square-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.square-stat svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.square-lightbox {
  position: fixed;
  inset: 0;
  z-index: 520;
  display: grid;
  grid-template-rows: 1fr auto;
  background: rgba(0, 0, 0, .96);
  backdrop-filter: blur(16px);
}

.square-lightbox[hidden] {
  display: none !important;
}

.square-lightbox__close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 50%;
  color: #fff;
  background: rgba(22, 26, 30, .88);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.square-lightbox__stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: calc(62px + env(safe-area-inset-top)) 12px 92px;
}

.square-lightbox__stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
  transform: scale(var(--lightbox-scale, 1));
  transition: transform .18s ease;
}

.square-lightbox__controls {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: rgba(22, 26, 30, .94);
  box-shadow: 0 16px 45px rgba(0, 0, 0, .5);
  transform: translateX(-50%);
}

.square-lightbox__controls button {
  min-width: 38px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  color: #eaecef;
  background: rgba(255, 255, 255, .08);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.square-lightbox__controls span {
  min-width: 52px;
  color: #f0b90b;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

body.lightbox-open {
  overflow: hidden;
}

.square-footnote {
  padding: 2px 14px 20px;
  color: #626b77;
  font-size: 10px;
  line-height: 1.65;
  text-align: center;
}

.square-footnote a {
  color: var(--square-yellow);
  text-decoration: none;
}

.square-empty {
  margin: 12px 14px;
  padding: 28px 18px;
  border: 1px solid var(--square-line);
  border-radius: 16px;
  color: var(--square-muted);
  background: var(--square-card);
  text-align: center;
}

.square-empty strong,
.square-empty span {
  display: block;
}

.square-empty strong {
  color: var(--square-text);
  font-size: 15px;
}

.square-empty span {
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.6;
}

@media (min-width: 760px) {
  .square-view {
    max-width: 760px;
    margin: 0 auto;
    border-right: 1px solid var(--square-line);
    border-left: 1px solid var(--square-line);
  }
}

@media (max-width: 380px) {
  .square-feed {
    padding-right: 10px;
    padding-left: 10px;
  }

  .square-card {
    padding: 12px;
  }

  .square-stats {
    gap: 5px;
  }

  .square-card__text {
    font-size: 13px;
  }
}

.square-card.is-new {
  opacity: 0;
  transform: translateY(-7px);
}

.square-card.is-new.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity .35s ease, transform .35s ease;
}

.square-card.is-removing {
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity .25s ease, transform .25s ease;
}

@media (prefers-reduced-motion: reduce) {
  .square-card.is-new,
  .square-card.is-new.is-visible,
  .square-card.is-removing {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
