/* AutoFlaxy member dashboard. Built only from tokens.css (frozen design, design/DESIGN.md).
   Mobile first: phones get a top bar and a bottom tab bar; 1024px and up get a sidebar. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.i { width: 20px; height: 20px; flex: none; }
.sprite { position: absolute; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: var(--fs-sm); }
.muted, .note, .hint, .lead { color: var(--muted); }
.note, .hint { font-size: var(--fs-sm); }
.gold { color: var(--gold); }
.bad { color: var(--negative); }
.numeric { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- buttons, chips */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-6); border: var(--border) solid transparent; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.sm { min-height: 44px; padding: 0 var(--space-4); font-size: var(--fs-sm); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border: var(--border) solid var(--line);
  border-radius: var(--radius); background: transparent; cursor: pointer;
}
.link-btn { min-height: 44px; border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: 32px; padding: 0 var(--space-3);
  border: var(--border) solid var(--line); border-radius: var(--radius); background: var(--surface-2);
  color: var(--ink); font-size: var(--fs-sm); font-weight: 500; text-decoration: none;
}
.chip .i { width: 16px; height: 16px; }
a.chip { min-height: 44px; }
.gold-chip { border-color: var(--gold); color: var(--gold); }

/* ---------------------------------------------------------------- shell */

.shell[hidden], .gate[hidden] { display: none; }

.side {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) var(--space-4); background: var(--ground); border-bottom: var(--border) solid var(--line);
}
.brand { display: block; }
.brand img { width: 128px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, minmax(44px, 1fr));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: var(--border) solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: 60px; color: var(--muted); font-size: var(--fs-xs); font-weight: 500; text-decoration: none;
}
.nav a[aria-current="page"] { color: var(--accent); }
.nav a span { max-width: 100%; text-align: center; line-height: 1.2; }

.acct { display: flex; align-items: center; gap: var(--space-2); }
.acct-addr { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--muted); }

.main { width: 100%; max-width: 1180px; margin: 0 auto; padding: var(--space-6) var(--space-4) calc(60px + var(--space-12)); }
.main:focus { outline: none; }
.page-title { font-size: var(--fs-2xl); margin-bottom: var(--space-4); }
.lead { max-width: 64ch; margin-bottom: var(--space-6); }

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .side {
    height: 100dvh; flex-direction: column; align-items: stretch; justify-content: flex-start;
    padding: var(--space-6) var(--space-4); border-bottom: 0; border-right: var(--border) solid var(--line);
  }
  .brand img { width: 176px; }
  .nav { position: static; display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-8); padding: 0; background: none; border: 0; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius); font-size: var(--fs-base); }
  .nav a:hover { color: var(--ink); }
  .nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
  .nav a[aria-current="page"] .i { color: var(--accent); }
  .account { margin-top: auto; }
  .acct { justify-content: space-between; padding-top: var(--space-4); border-top: var(--border) solid var(--line); }
  .main { padding: var(--space-8) var(--space-8) var(--space-12); }
  .page-title { font-size: var(--fs-3xl); }
}

/* ---------------------------------------------------------------- shared blocks */

.card { padding: var(--space-6) var(--space-4); background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--radius-lg); }
.card h2 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-lg); }
@media (min-width: 640px) { .card { padding: var(--space-6); } }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-6); padding: var(--space-3) var(--space-4);
  border: var(--border) solid var(--accent); border-radius: var(--radius); background: var(--surface);
}
.banner > p:first-of-type { flex: 1 1 200px; font-size: var(--fs-sm); }
.banner .msg { flex-basis: 100%; }
.banner .msg:empty { display: none; }
.flash { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-6); padding: var(--space-3) var(--space-4); border: var(--border) solid var(--positive); border-radius: var(--radius); color: var(--positive); font-size: var(--fs-sm); }

.state {
  display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-6) var(--space-4);
  border: var(--border) dashed var(--line); border-radius: var(--radius-lg);
}
.state > .i { color: var(--muted); margin-top: 2px; }
.state div { display: grid; gap: var(--space-3); justify-items: start; }
.state.bad { border-style: solid; border-color: var(--negative); }
.state.bad > .i { color: var(--negative); }

.msg { min-height: 0; font-size: var(--fs-sm); color: var(--muted); }
.msg:not(:empty) { margin-top: var(--space-3); }
.msg.bad { color: var(--negative); }

.rows { display: grid; gap: var(--space-1); margin-top: var(--space-4); }
.rows div { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: var(--border) solid var(--line); }
.rows div:last-child { border-bottom: 0; }
.rows dt { color: var(--muted); }
.rows dd { font-weight: 700; text-align: right; }
.steps .rows dd { white-space: nowrap; } /* join amounts are short; keep "5.00 USDT" on one line */

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-6); padding-top: var(--space-4); border-top: var(--border) solid var(--line); }
.facts dt { color: var(--muted); font-size: var(--fs-sm); }
.facts dd { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: var(--heading-weight); }
.facts.wide { margin: 0 0 var(--space-6); padding: var(--space-4); border: var(--border) solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.actions .note { flex-basis: 100%; }

.sk-wrap { display: grid; gap: var(--space-3); }
.sk { height: 72px; border-radius: var(--radius); background: var(--surface-2); }
.sk:first-child { height: 40px; width: 60%; }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.5; } }
}

.back { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; margin-bottom: var(--space-2); text-decoration: none; }

/* ---------------------------------------------------------------- dashboard */

.dash { display: grid; gap: var(--space-4); }
@media (min-width: 900px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "profile refer" "earn bidx" "latest latest"; }
  .profile { grid-area: profile; } .refer { grid-area: refer; } .earn { grid-area: earn; } .bidx-card { grid-area: bidx; } .latest { grid-area: latest; }
}

.profile-head { display: flex; align-items: center; gap: var(--space-4); }
.id-badge {
  display: grid; place-items: center; width: 64px; height: 64px; flex: none; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  font-family: var(--font-display); font-size: var(--fs-lg); font-weight: var(--heading-weight);
}
.profile h2 { font-size: var(--fs-2xl); }
.wallet-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-1); }
.wallet-line > a { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 44px; text-decoration: none; }
.wallet-line .i { width: 16px; height: 16px; }

.refer { display: grid; gap: var(--space-4); align-content: start; }
.link-box {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); border: var(--border) solid var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.link-box .mono { min-width: 0; overflow-wrap: anywhere; }
.refer > .btn { justify-self: start; }

.big { margin-top: var(--space-2); font-family: var(--font-display); font-size: var(--fs-4xl); font-weight: var(--heading-weight); line-height: 1; letter-spacing: var(--tracking); }

.bidx-head { display: flex; gap: var(--space-4); align-items: center; }
.bidx-head img { width: 56px; height: 56px; flex: none; }
.bidx-head .note { margin-top: var(--space-1); }

.list { display: grid; margin-top: var(--space-3); }
.list a {
  display: grid; grid-template-columns: auto 1fr; gap: 0 var(--space-3); align-items: center;
  min-height: 52px; padding: var(--space-2) 0; border-bottom: var(--border) solid var(--line); color: var(--ink); text-decoration: none;
}
.list li:last-child a { border-bottom: 0; }
.list .muted { grid-column: 2; font-size: var(--fs-sm); }
.list a:hover b { color: var(--accent); }
@media (min-width: 640px) {
  .list a { grid-template-columns: 96px 1fr auto; }
  .list .muted { grid-column: auto; text-align: right; }
}

/* ---------------------------------------------------------------- slots */

.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-6); font-size: var(--fs-sm); color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend.wide { display: grid; gap: var(--space-2); margin-top: var(--space-6); }
.legend.wide li { display: grid; grid-template-columns: auto 1fr; gap: 0 var(--space-3); color: var(--ink); }
.legend.wide small { grid-column: 2; color: var(--muted); }
@media (min-width: 640px) { .legend.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.dot { --c: var(--line); display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--c); }
.dot.on { background: var(--c); }
.r-up { --c: var(--series-up); }
.r-wallet { --c: var(--series-wallet); }
.r-next { --c: var(--series-next); }
.r-pool { --c: var(--accent-2); }
.r-down { --c: var(--series-down); }
.r-recycle { --c: var(--series-recycle); }

.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
@media (min-width: 768px) { .slots { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); } }
@media (min-width: 1280px) { .slots { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.slot {
  display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4);
  background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--radius-lg);
  color: var(--ink); text-decoration: none; transition: border-color var(--motion-base) ease;
}
a.slot:hover { border-color: var(--accent); }
.slot header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.slot-n { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: var(--heading-weight); line-height: 1; }
.price { font-weight: 700; }
.dots { display: grid; grid-template-columns: repeat(7, 12px); justify-content: space-between; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius); background: var(--ground); }
.fill { font-size: var(--fs-sm); color: var(--muted); }
.mini { display: flex; gap: var(--space-4); font-size: var(--fs-sm); }
.mini div { display: flex; gap: var(--space-1); }
.mini dt { color: var(--muted); }
.mini dd { font-weight: 700; }
.milestone { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--gold); }
.milestone img { width: 20px; height: 28px; object-fit: cover; border-radius: var(--radius-sm); }
.slot-go { margin-top: auto; font-size: var(--fs-sm); font-weight: 700; color: var(--accent); }
.slot.locked { background: transparent; border-style: dashed; }
.slot.locked .slot-n, .slot.locked .price { color: var(--muted); }
.lock-line { display: flex; gap: var(--space-2); font-size: var(--fs-sm); }
.lock-line .i { color: var(--muted); }

/* ---------------------------------------------------------------- matrix tree (same grid as the website) */

/* phones: the tree runs edge to edge so each of the 8 bottom places is a 46px tap target */
.tree-card { margin-inline: calc(var(--space-4) * -1); padding: var(--space-6) 0; border-inline: 0; border-radius: 0; }
.tree { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); row-gap: var(--space-6); }
.cell { position: relative; display: flex; justify-content: center; min-height: 48px; color: var(--ink); text-decoration: none; }
.span8 { grid-column: span 8; } .span4 { grid-column: span 4; } .span2 { grid-column: span 2; }
.kids::after {
  content: ""; position: absolute; top: 100%; left: 25%; right: 25%; height: var(--space-6);
  border: 1.5px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
}
.node {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: calc(100% - var(--space-1)); max-width: 64px; min-height: 48px; padding: var(--space-1) 2px;
  border: 2px solid var(--c); border-radius: var(--radius); background: var(--ground); color: var(--ink); text-decoration: none;
}
.node small { font-size: 10px; line-height: 1; color: var(--muted); }
.node b { font-size: var(--fs-xs); line-height: 1.4; }
a.cell .node { background: color-mix(in srgb, var(--c) 18%, var(--ground)); }
a.cell:hover .node { background: color-mix(in srgb, var(--c) 32%, var(--ground)); }
.node.empty { border-style: dashed; }
.node.you { --c: var(--series-you); max-width: none; width: auto; padding: var(--space-2) var(--space-6); font-weight: 700; }
@media (min-width: 640px) {
  .tree-card { margin-inline: 0; padding: var(--space-8) var(--space-6); border-inline: var(--border) solid var(--line); border-radius: var(--radius-lg); }
  .tree { column-gap: var(--space-2); row-gap: var(--space-8); }
  .kids::after { height: var(--space-8); }
  .node { min-height: 56px; }
  .node small { font-size: var(--fs-xs); }
  .node b { font-size: var(--fs-sm); }
}

/* ---------------------------------------------------------------- tables (cards below 640px) */

.table { display: grid; gap: var(--space-2); }
.tr {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2) var(--space-3); padding: var(--space-4);
  border: var(--border) solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); text-decoration: none;
}
a.tr:hover { border-color: var(--accent); }
.tr.th { display: none; }
.tr .who { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-3); }
.tr .who > span { display: grid; }
.tr [data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.tr [data-label] { font-weight: 700; }
.pill { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 var(--space-2); border-radius: var(--radius); background: var(--surface-2); color: var(--accent); font-size: var(--fs-sm); }
@media (min-width: 640px) {
  .table { gap: 0; border: var(--border) solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
  .tr { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); align-items: center; min-height: 56px; padding: var(--space-2) var(--space-4); border: 0; border-bottom: var(--border) solid var(--line); border-radius: 0; background: none; }
  .tr:last-child { border-bottom: 0; }
  .tr.th { display: grid; min-height: 44px; color: var(--muted); font-size: var(--fs-sm); }
  .tr .who { grid-column: auto; }
  .tr > :not(.who) { text-align: right; }
  .tr [data-label]::before { display: none; }
  a.tr:hover { background: var(--surface-2); }
}

/* ---------------------------------------------------------------- ranks */

.ranks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-6); }
@media (min-width: 1024px) { .ranks { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); } }
.rank { display: grid; gap: var(--space-3); align-content: start; padding: var(--space-4); }
.rank img { width: 96px; margin: 0 auto; }
.rank div { display: grid; gap: var(--space-1); justify-items: start; }
.rank.held { border-color: var(--gold); }
.pool { max-width: 640px; }
.pool .note { margin-top: var(--space-2); }

/* ---------------------------------------------------------------- join gate */

.gate { display: grid; justify-items: center; gap: var(--space-4); align-content: start; min-height: 100dvh; padding: var(--space-6) var(--space-4) var(--space-12); }
.gate-card { width: 100%; max-width: 460px; }
.gate-logo { width: 200px; margin: 0 auto var(--space-6); }
.gate h1 { font-size: var(--fs-2xl); text-align: center; }
.gate-card > .note { margin-top: var(--space-2); text-align: center; }
.steps { display: grid; gap: var(--space-6); margin-top: var(--space-6); }
.steps li { display: grid; grid-template-columns: 32px 1fr; gap: var(--space-3); }
.steps li > div { display: grid; gap: var(--space-2); min-width: 0; }
.step-n { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--accent); font-weight: 700; }
.step-t { font-weight: 700; }
.steps .rows { margin-top: 0; }
.ok { display: flex; align-items: center; gap: var(--space-2); color: var(--positive); }
.ok .mono { color: var(--ink); }
input {
  width: 100%; min-height: 48px; padding: 0 var(--space-3); border: var(--border) solid var(--line);
  border-radius: var(--radius); background: var(--surface-2); color: var(--ink); font-size: var(--fs-base);
}
input:focus-visible { border-color: var(--accent); }
.hint.bad { color: var(--negative); }
.gate-card > .link-btn { display: block; margin: var(--space-2) auto 0; }
.gate-card > .gate-link { display: flex; width: fit-content; margin: var(--space-4) auto 0; }
.peek { width: 100%; max-width: 460px; display: grid; gap: var(--space-2); }
.peek label { font-weight: 700; }
.peek-row { display: flex; gap: var(--space-2); }
.peek-row input { flex: 1; min-width: 0; }
.net-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-1); font-size: var(--fs-sm); color: var(--muted); text-align: center; }
.net-line a { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 44px; text-decoration: none; }
.net-line .i { width: 14px; height: 14px; }

@media (min-width: 640px) { .gate { padding-top: var(--space-12); } }

/* ---------------------------------------------------------------- history and wallet picker */

.history-notice { margin-bottom: var(--space-4); }
.tr > *, .facts dd, .card, .slot, .profile-head > div, .rows dd { min-width: 0; overflow-wrap: anywhere; }
.history .tx-link { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 44px; min-width: 44px; }
.history .who > span { gap: var(--space-1); }
.activity a { grid-template-columns: minmax(0, 1fr); }
.activity .muted { grid-column: 1; text-align: left; }
.id-badge { overflow-wrap: anywhere; }
.node b { max-width: 100%; overflow-wrap: anywhere; }
.wallet-picker { color: var(--ink); width: calc(100% - var(--space-8)); max-width: 400px; max-height: calc(100dvh - var(--space-8)); }
.wallet-picker::backdrop { background: color-mix(in srgb, var(--ground) 80%, transparent); }
.btn.wa { background: var(--positive); color: var(--accent-ink); }
.wa-banner { border-color: var(--positive); }
.wa-banner > .i { color: var(--positive); }
.wa-popup { color: var(--ink); width: calc(100% - var(--space-8)); max-width: 400px; text-align: center; }
.wa-popup::backdrop { background: color-mix(in srgb, var(--ground) 90%, transparent); }
.wa-popup h2 { justify-content: center; margin-block: var(--space-3); }
.wa-popup .note { margin-bottom: var(--space-6); }
.wa-mark { width: 48px; height: 48px; color: var(--positive); }
#wallet-options { display: grid; gap: var(--space-3); margin-block: var(--space-6); }
.wallet-option { justify-content: flex-start; padding: var(--space-3); overflow-wrap: anywhere; }
.wallet-option img { width: 32px; height: 32px; flex: none; }
.wallet-option span { min-width: 0; }
@media (min-width: 640px) {
  .history .tx-link { justify-self: end; }
  .activity a { grid-template-columns: minmax(0, 1fr) auto; }
  .activity .muted { grid-column: auto; text-align: right; }
}
