/*
  ApeX Utility — brand look from assets/mascot/DESIGN_GUIDE.md: one ground (ivory), one ink (black),
  one accent (yellow). The mascot art is cut from the approved master sheet (website/art/crop-mascot.js).
  Layout: equal 16–40px margins; each section composes differently
  (hero split, ordered steps, definition list, full-bleed split figure, table, list, accordion).
*/
:root {
  --ivory: #F4F0E7;
  --paper: #FBF9F4;
  --sand: #EAE4D6;
  --ink: #171714;
  --ink-2: #26261F;
  --muted: #5F5B51;
  --muted-dark: #B9B3A5;
  --yellow: #F2C94C;
  --yellow-2: #F7DC86;
  --yellow-3: #FBEBB8;
  --gold: #D2A338;

  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --gutter: max(16px, min(4vw, 40px));
  /* Compact rhythm: sections and their inner gaps stay tight (owner request) */
  --section: clamp(56px, 7vw, 104px);
  --stack: clamp(24px, 3vw, 40px);
  --measure: 62ch;

  /* Motion tokens */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --t-press: 140ms;
  --t-hover: 180ms;
  --t-ui: 240ms;

  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--font);
  font-variation-settings: "wdth" 100;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--ink); color: var(--yellow); }
input, textarea { caret-color: var(--ink); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.share :focus-visible, .foot :focus-visible { outline-color: var(--yellow); }
html { scrollbar-color: var(--ink-2) var(--ivory); }
img { display: block; max-width: 100%; height: auto; }

h1, h2, h3 {
  margin: 0;
  font-weight: 850;
  font-variation-settings: "wdth" 112;
  letter-spacing: -0.035em;
  line-height: 0.95;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 8.4vw, 6rem); }
h2 { font-size: clamp(2rem, 4.4vw, 3.5rem); }
h3 { font-size: clamp(1.5rem, 2.6vw, 2rem); letter-spacing: -0.02em; line-height: 1.05; }
p { margin: 0; max-width: var(--measure); }
a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 2px; }
code { font: 500 0.92em var(--mono); }

/* ---------- Buttons: fully round, flat, one fill ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 22px; border-radius: 999px;
  font: 700 1rem/1 var(--font); text-decoration: none; white-space: nowrap;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover) ease;
}
.btn:active { transform: scale(0.97); }
.btn-ink { background: var(--ink); color: var(--yellow); }
.btn-ink:hover { background: var(--ink-2); }
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-yellow:hover { background: var(--yellow-2); }
.btn-line { box-shadow: inset 0 0 0 2px var(--yellow); color: var(--yellow); }
.btn-line:hover { background: var(--ink-2); }
.btn-lg { min-height: 56px; padding: 0 30px; font-size: 1.125rem; }
.fine { font-size: 0.9375rem; color: var(--muted); }

/* ---------- Bar ---------- */
.bar {
  display: flex; align-items: center; gap: 24px;
  padding-block: 14px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  background: var(--ivory);
}
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; flex: none; }
.logo-face { height: 44px; width: auto; }
.logo-word {
  color: var(--ink); font-weight: 900; font-size: 1.75rem; line-height: 1;
  letter-spacing: -0.045em; font-variation-settings: "wdth" 118;
}
.bar nav { display: flex; gap: 24px; margin-left: auto; font-weight: 600; }
.bar nav a { text-decoration: none; transition: color var(--t-hover) ease; }
.bar nav a:hover { text-decoration: underline; }
@media (max-width: 860px) { .bar nav { display: none; } .bar .btn { margin-left: auto; } }

/* ---------- Sections share the gutter ---------- */
section, .foot {
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* ---------- Hero ---------- */
/* No bottom padding: the mascot's flat-cut hoodie stands on the hero's bottom edge */
.hero {
  background: var(--ivory);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(24px, 4vw, 56px);
  padding-top: clamp(16px, 2.5vw, 36px);
  overflow: hidden;
}
.hero h1 { font-size: clamp(2.6rem, 6.6vw, 5.25rem); }
.hero-copy { display: grid; gap: 20px; min-width: 0; align-self: center; padding-bottom: clamp(36px, 4.5vw, 64px); }
.lede { font-size: clamp(1.0625rem, 1.4vw, 1.25rem); line-height: 1.45; max-width: 40ch; }
.chains { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 0; font-weight: 700; font-size: 0.9375rem; }
.chains li:not(:last-child)::after { content: "·"; margin: 0 9px; color: var(--gold); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-top: 4px; }

/* The mascot stands in the wrap's left padding; its banana hand reaches over the phone's left edge */
.phone-wrap {
  --lean: clamp(150px, 19vw, 250px);
  position: relative; justify-self: center; align-self: end; min-width: 0;
  width: min(100%, calc(360px + var(--lean)));
  padding-left: var(--lean);
  padding-bottom: clamp(28px, 3.5vw, 48px);
}
.mascot {
  position: absolute; left: 0; bottom: 0; z-index: 1;
  width: calc(var(--lean) * 1.12); height: auto;
  filter: drop-shadow(0 12px 14px rgba(23, 23, 20, 0.18));
}
.phone {
  position: relative; margin: 0; width: 100%;
  background: #CFDCC2; border-radius: 28px; overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(23, 23, 20, 0.5), 0 8px 18px -10px rgba(23, 23, 20, 0.28);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-copy { padding-bottom: 0; }
}
/* Narrow screens: no room beside the phone, so the mascot peeks over its top edge instead */
@media (max-width: 700px) {
  .phone-wrap { padding-left: 0; width: min(100%, 400px); display: grid; justify-items: center; }
  .mascot { position: relative; width: min(64%, 250px); margin-bottom: -44px; z-index: 0; filter: none; }
  .phone { z-index: 1; }
}

/* Telegram fragment (real product UI keeps its own chrome) */
.tg-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--ink); color: var(--ivory); }
.tg-head b { display: block; font-size: 15px; }
.tg-head small { opacity: 0.7; font-size: 12.5px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--yellow); display: grid; place-items: center; flex: none; overflow: hidden; }
.avatar img { width: 32px; height: auto; }
.tg-chat { display: flex; flex-direction: column; gap: 8px; padding: 10px 10px 12px; min-height: 420px; justify-content: flex-end; } /* fits the tallest replay step, so the hero never jumps */
.tg-msg { max-width: 92%; display: flex; flex-direction: column; gap: 4px; }
.tg-msg.me { align-self: flex-end; }
.bubble {
  background: #FFFFFF; border-radius: 14px 14px 14px 4px; padding: 8px 11px;
  font-size: 13.5px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; color: #1A1E17;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
.me .bubble { background: #E4F6CC; border-radius: 14px 14px 4px 14px; }
.bubble code { font-size: 11.5px; }
.kb { display: grid; gap: 4px; }
.kb > div { display: flex; gap: 4px; }
.kb span {
  flex: 1 1 0; min-width: 0; text-align: center; padding: 8px 4px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.62); font-size: 12px; font-weight: 600; color: #1A1E17;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb span.pressed { background: #FFFFFF; box-shadow: 0 0 0 2px var(--ink) inset; }
.phone figcaption {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--paper); color: var(--ink); font: 500 13px/1.3 var(--font);
}
/* The mascot's banana hand covers the caption's left end beside the phone */
@media (min-width: 701px) { .phone figcaption { padding-left: calc(var(--lean) * 0.2 + 16px); } }
.replay { border: 0; background: none; padding: 4px 0; font: 700 13px var(--font); color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- How it works ---------- */
.how { background: var(--paper); padding-block: var(--section); display: grid; gap: var(--stack); }
.how h2 { max-width: 14ch; }
.steps {
  list-style: none; counter-reset: step; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 28px 32px;
}
.steps li { counter-increment: step; display: grid; gap: 10px; align-content: start; font-size: 1.0625rem; }
.steps li::before {
  content: counter(step);
  font: 900 clamp(2.75rem, 5vw, 4rem)/0.8 var(--font); font-variation-settings: "wdth" 62;
  color: var(--gold); letter-spacing: -0.04em;
}
.steps strong { display: block; font-size: 1.25rem; margin-bottom: 4px; }

/* ---------- Load sequence: headline lines rise from their own mask (pure CSS, first frame) ---------- */
.lines .line { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.lines .line > span { display: block; }
[data-lines] .line { display: block; overflow: clip; padding-bottom: 0.1em; margin-bottom: -0.1em; }
[data-lines] .line > span { display: block; }
@media (prefers-reduced-motion: no-preference) {
  .js .hero .lines .line > span { transform: translateY(105%); animation: rise-line 900ms var(--ease-expo) forwards; animation-delay: calc(var(--i) * 110ms + 100ms); }
  .js .hero .lede, .js .hero .chains, .js .hero-actions { opacity: 0; transform: translateY(16px); animation: rise-in 700ms var(--ease-out) forwards; }
  .js .hero .lede { animation-delay: 360ms; }
  .js .hero .chains { animation-delay: 410ms; }
  .js .hero-actions { animation-delay: 460ms; }
  .js .mascot { opacity: 0; transform: translateY(36px) rotate(-4deg); transform-origin: 50% 100%; animation: rise-in 800ms var(--ease-expo) 560ms forwards; }
}
@keyframes rise-line { to { transform: none; } }
@keyframes rise-in { to { opacity: 1; transform: none; } }

input[type="range"] { cursor: pointer; }

/* ---------- Features (commands) ---------- */
.commands {
  background: var(--ivory); padding-block: var(--section);
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--stack) clamp(32px, 5vw, 80px); align-items: start;
}
.commands-intro { display: grid; gap: 18px; position: sticky; top: 24px; }
.commands-intro p { font-size: 1.125rem; max-width: 38ch; }
.cmd-list { margin: 0; display: grid; gap: 22px; }
.cmd-list > div { display: grid; gap: 6px; }
.cmd-list dt code { font-size: 1.0625rem; background: var(--yellow); padding: 3px 8px; border-radius: 6px; }
.cmd-list dd { margin: 0; max-width: 52ch; }
@media (max-width: 900px) { .commands { grid-template-columns: minmax(0, 1fr); } .commands-intro { position: static; } }

/* ---------- Revenue share ---------- */
.share { background: var(--ink); color: var(--ivory); padding-block: var(--section); display: grid; gap: var(--stack); overflow: hidden; }
.share-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; }
.share-text { display: grid; gap: 16px; }
.share-head h2 { color: var(--yellow); }
.share-head p { font-size: 1.125rem; color: var(--muted-dark); max-width: 56ch; }

.split { margin: 0; display: grid; gap: 24px; }
/* Still trading chart (website/art/chart.js); its top-right corner is kept free for the mascot on a rocket */
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; }
.split-note { color: var(--muted-dark); margin-top: calc(var(--stack) * -0.5); }

/* Three equal columns: the banana shows the proportions, the text stays evenly set */
.legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px clamp(24px, 4vw, 56px); }
.legend p { display: grid; gap: 8px; align-content: start; font-size: 1rem; line-height: 1.45; color: var(--muted-dark); max-width: 28ch; }
.legend .big { font-weight: 900; font-size: clamp(2.25rem, 4.5vw, 3.75rem); line-height: 0.9; letter-spacing: -0.04em; font-variation-settings: "wdth" 100; }
.leg-a .big { color: var(--yellow); }
.leg-b .big { color: var(--yellow-2); }
.leg-c .big { color: var(--yellow-3); }
@media (max-width: 760px) { .legend { grid-template-columns: minmax(0, 1fr); } }

.calc { background: var(--ink-2); padding: clamp(20px, 3vw, 40px); display: grid; gap: 22px; border-radius: 4px; }
.calc h3 { color: var(--yellow); }
.calc-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 20px 40px; }
.calc label { display: grid; grid-template-columns: 1fr auto; gap: 12px; font-weight: 600; color: var(--muted-dark); }
.calc output { font-weight: 800; color: var(--ivory); font-variant-numeric: tabular-nums; text-align: right; }
.calc input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--yellow); height: 28px; margin: 0; }
.calc-result { display: grid; gap: 10px; }
.calc-result p:first-child { font-size: clamp(1.25rem, 2.2vw, 1.75rem); line-height: 1.25; font-weight: 600; max-width: 30ch; }
.calc-result strong { color: var(--yellow); font-weight: 900; font-variant-numeric: tabular-nums; }
.calc-detail { color: var(--muted-dark); }
.calc .fine { color: var(--muted-dark); max-width: 80ch; }

/* ---------- Fees ---------- */
.fees { background: var(--yellow); padding-block: var(--section); display: grid; gap: var(--stack); }
.fees h2 { max-width: 20ch; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 1rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 11px 16px 11px 0; vertical-align: top; }
thead th { font-weight: 700; padding-bottom: 8px; }
tbody tr { border-top: 2px solid var(--ink); }
tbody th { font-weight: 700; }
.fees-note { font-size: 1rem; max-width: 64ch; }

/* ---------- ApeX Pro: the web app as its own dark screen ---------- */
.pro {
  background: var(--paper); padding-block: var(--section);
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--stack) clamp(32px, 5vw, 80px); align-items: center;
}
.pro-intro { display: grid; gap: 18px; justify-items: start; }
.pro-intro > p { font-size: 1.125rem; max-width: 40ch; }
.pro-facts li { padding-block: 6px; }
.pro-facts li::before { top: 12px; }
.screen { margin: 0; display: grid; gap: 10px; min-width: 0; }
.screen-bar, .screen-body { background: var(--ink); color: var(--ivory); }
.screen-bar { display: flex; align-items: center; gap: 18px; padding: 14px 18px; border-radius: 14px 14px 0 0; border-bottom: 1px solid var(--ink-2); }
.screen-logo { font-weight: 900; letter-spacing: -0.03em; font-size: 1.125rem; }
.screen-logo b { color: var(--yellow); }
.screen-tabs { display: flex; gap: 4px; font-size: 0.875rem; font-weight: 600; color: var(--muted-dark); overflow: hidden; }
.screen-tabs span { padding: 5px 10px; border-radius: 6px; white-space: nowrap; }
.screen-tabs .on { background: var(--ink-2); color: var(--yellow); }
.screen-body { margin-top: -10px; padding: 16px; border-radius: 0 0 14px 14px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.screen-panel { border: 1px solid var(--ink-2); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.screen-title { margin: 0 0 4px; font-size: 0.8125rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
.screen-live { margin-left: auto; font-size: 0.75rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted-dark); }
.screen-live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ADE80; margin-right: 6px; }
.screen-rows { list-style: none; margin: 0; padding: 0; }
.screen-rows li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--ink-2); font-size: 0.875rem; }
.screen-rows li:first-child { border-top: 0; }
.screen-rows li > span:first-child { min-width: 0; color: var(--muted-dark); }
.screen-rows b { color: var(--yellow); font-weight: 700; }
.screen-rows small { display: block; font-family: var(--mono); font-size: 0.75rem; color: var(--muted-dark); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-rows li > small { color: var(--muted-dark); flex: none; }
.screen-btn { flex: none; font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 6px; background: var(--ink-2); }
.screen figcaption { font-size: 0.875rem; color: var(--muted); }
@media (max-width: 900px) { .pro { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .screen-body { grid-template-columns: minmax(0, 1fr); } .screen-tabs span:not(.on) { display: none; } }

/* ---------- Security ---------- */
.security {
  background: var(--paper); padding-block: var(--section);
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--stack) clamp(32px, 5vw, 80px); align-items: start;
}
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.facts li { padding: 10px 0 10px 36px; position: relative; font-size: 1.0625rem; }
.facts li::before {
  content: ""; position: absolute; left: 0; top: 16px; width: 22px; height: 14px;
  background: var(--gold);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 14'%3E%3Cpath d='M2 7l6 5L20 2' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 14'%3E%3Cpath d='M2 7l6 5L20 2' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (max-width: 900px) { .security { grid-template-columns: minmax(0, 1fr); } }

/* ---------- FAQ ---------- */
.faq { background: var(--ivory); padding-block: var(--section); display: grid; gap: var(--stack); }
.qa { display: grid; gap: 6px; max-width: 880px; }
details { background: var(--paper); border-radius: 4px; }
summary {
  list-style: none; cursor: pointer; padding: 16px 52px 16px 20px; position: relative;
  font-weight: 750; font-size: clamp(1.0625rem, 1.5vw, 1.25rem); letter-spacing: -0.01em;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ""; position: absolute; right: 24px; top: 50%; width: 14px; height: 14px; margin-top: -10px;
  border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: rotate(45deg);
  transition: transform 0.3s var(--ease-expo);
}
details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
details p { padding: 0 20px 18px; max-width: 64ch; }

/* ---------- Footer: the name returns at full width ---------- */
.foot { background: var(--ink); color: var(--ivory); padding-block: clamp(48px, 6vw, 88px) max(32px, env(safe-area-inset-bottom, 0px)); display: grid; gap: 28px; overflow: hidden; }
.foot-name {
  max-width: none; color: var(--yellow); font-weight: 900; letter-spacing: -0.05em; line-height: 0.85;
  font-size: clamp(3rem, 9.5vw, 11rem); font-variation-settings: "wdth" 112; white-space: nowrap;
}
.foot-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.foot .fine { color: var(--muted-dark); }
.foot-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .foot-name { white-space: normal; font-size: 19vw; font-variation-settings: "wdth" 100; }
  .btn-lg { width: 100%; }
  .hero-actions .fine { width: 100%; }
  .kb span { font-size: 11px; padding: 7px 2px; }
  .bubble { font-size: 13px; }
  .tg-chat { min-height: 400px; }
  .hero { gap: 28px; }
  /* Fee table becomes stacked rows */
  table { min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr { display: grid; gap: 4px; padding-block: 16px; }
  tbody th, tbody td { padding: 0; }
  tbody td::before { content: attr(data-label) ": "; font-weight: 600; }
  .legend .big { font-size: 2.5rem; }
  summary { padding: 14px 44px 14px 16px; }
  details p { padding: 0 16px 14px; }
}
@media (max-width: 380px) {
  .logo-face { height: 36px; }
  .logo-word { font-size: 1.4rem; }
  .bar .btn { padding: 0 16px; }
}
