/* Ledge app. Tokens, buttons and base type come from /styles.css. */

.app-body {
  --surface: #0f151e;
  --surface-2: #151d28;
  --edge: #2b3748;
  --ink-dim: #5d6d80;
  min-height: 100vh;
}
.app-body [hidden] { display: none !important; }
.app-body .num { font-variant-numeric: tabular-nums; }

/* Bar */
.app-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem var(--gutter);
  background: rgba(10, 14, 21, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule);
}
.app-bar .nav-home { font-size: 1.4rem; }
.mode-badge {
  margin-right: auto;
  font-size: 0.78rem; line-height: 1; color: var(--steel);
  border: 1px dashed rgba(199, 206, 216, 0.4); border-radius: 999px; padding: 0.3rem 0.65rem;
}

.account { position: relative; }
.account-menu summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 0.55rem;
  min-height: 2.6rem; padding: 0 0.85rem 0 0.35rem;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--stone);
  color: var(--paper); font-size: var(--step--1); font-variant-numeric: tabular-nums;
  transition: border-color 0.2s;
}
.account-menu summary:hover, .account-menu[open] summary { border-color: #3a4759; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after {
  content: ""; width: 0.4rem; height: 0.4rem; margin: -0.2rem 0 0 0.1rem;
  border: solid var(--mist); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
  transition: transform 0.2s;
}
.account-menu[open] summary::after { transform: rotate(-135deg); margin-top: 0.2rem; }
.account-menu summary img, .avatar { width: 1.9rem; height: 1.9rem; border-radius: 50%; flex: none; }
.avatar { display: inline-block; background: conic-gradient(from 200deg, #3b4a5c, #6b7f96, var(--steel), #3b4a5c); }
.account-pop {
  position: absolute; right: 0; top: calc(100% + 0.5rem); width: min(17rem, calc(100vw - 2rem));
  padding: 0.9rem 1rem 0.6rem; border: 1px solid var(--edge); border-radius: 12px; background: var(--surface-2);
  font-size: var(--step--1); color: var(--mist);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.8);
}
.account-wallet { color: var(--paper); }
.account-address { margin-top: 0.3rem; font-size: 0.8rem; overflow-wrap: anywhere; line-height: 1.45; }
.account-pop .link-button { margin-top: 0.4rem; }

/* Layout */
.app > section { padding: 0; }
.app {
  max-width: 84rem; margin: 0 auto;
  padding: 1.1rem var(--gutter) 6rem;
  display: grid; column-gap: clamp(2rem, 4vw, 4rem); row-gap: 2.5rem;
  grid-template-columns: minmax(0, 1fr) minmax(21rem, 26rem);
  grid-template-areas:
    "note note"
    "pool trade"
    "market trade"
    "market position"
    "activity position";
  align-items: start;
}
.demo-note { grid-area: note; font-size: 0.85rem; color: var(--mist); margin-bottom: -1rem; }
.pool { grid-area: pool; }
.trade { grid-area: trade; }
.market { grid-area: market; }
.position { grid-area: position; }
.activity { grid-area: activity; }
.app h2 { font: 500 1.7rem / 1.1 var(--serif); }

@media (max-width: 960px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "note" "pool" "trade" "market" "position" "activity";
    row-gap: 2rem;
  }
  .demo-note { margin-bottom: -0.75rem; }
}
@media (min-width: 700px) and (max-width: 960px) {
  .app {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "note note" "pool pool" "trade position" "market market" "activity activity";
  }
}

/* Pool: the floor is the one loud thing on the page */
.pool-floor { position: relative; padding: 0.8rem 0 1.3rem; }
.pool-label { font-size: var(--step--1); color: var(--mist); }
.pool-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.9rem; margin-top: 0.1rem; }
.pool-figure output {
  font: 500 clamp(3.2rem, 1.9rem + 4.6vw, 5.8rem) / 0.95 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ember); text-shadow: 0 0 34px rgba(255, 107, 31, 0.3);
  white-space: nowrap;
}
.pool-figure .lead { color: #4a5869; text-shadow: none; }
.pool-unit { font-size: var(--step--1); color: var(--mist); }
.pool-moves { display: flex; flex-wrap: wrap; gap: 0.2rem 1.1rem; margin-top: 0.7rem; font-size: var(--step--1); color: var(--steel); font-variant-numeric: tabular-nums; }
.pool-last:empty { display: none; }
.pool-last { color: var(--paper); }
.pool-last::before { content: ""; display: inline-block; width: 0.45rem; height: 0.45rem; margin-right: 0.5rem; border-radius: 50%; background: var(--ember); vertical-align: 0.08em; }

/* The ledge: a stone rule with an ember edge under the floor figure. */
.pool-floor::before, .pool-floor::after { content: ""; position: absolute; left: 0; bottom: 0; height: 1px; }
.pool-floor::before { right: 0; background: var(--rule); }
.pool-floor::after {
  width: var(--ledge, 38%); height: 2px; bottom: -0.5px;
  background: var(--ember);
  box-shadow: 0 1px 10px -1px rgba(255, 107, 31, 0.35);
}
.pool.is-rising .pool-figure output { animation: floor-rise 1.6s ease-out; }
.pool.is-rising .pool-floor::after { animation: ledge-flare 1.6s ease-out; }
@keyframes floor-rise {
  0%, 30% { text-shadow: 0 0 44px rgba(255, 107, 31, 0.75); }
  100% { text-shadow: 0 0 34px rgba(255, 107, 31, 0.3); }
}
@keyframes ledge-flare {
  0%, 25% { box-shadow: 0 0 18px 1px rgba(255, 107, 31, 0.8); }
  100% { box-shadow: 0 1px 10px -1px rgba(255, 107, 31, 0.35); }
}

.pool-stats { margin: 1.2rem 0 0; display: grid; gap: 0.9rem 1.5rem; grid-template-columns: repeat(5, minmax(0, auto)); justify-content: space-between; }
.pool-stats dt, .position-stats dt { font-size: 0.8rem; color: var(--mist); }
.pool-stats dd { margin: 0.1rem 0 0; color: var(--paper); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 700px) {
  .pool-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pool-stats > div:last-child { grid-column: 1 / -1; }
}

/* Market chart */
.market-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem 1.5rem; }
.chart-key { display: flex; gap: 1.2rem; font-size: 0.8rem; color: var(--mist); }
.key::before { content: ""; display: inline-block; width: 1rem; height: 2px; margin-right: 0.45rem; vertical-align: middle; }
.key--spot::before { background: var(--paper); }
.key--floor::before { background: var(--ember); box-shadow: 0 0 6px var(--ember-glow); }
.chart { position: relative; margin-top: 1rem; }
#chart { width: 100%; height: clamp(14rem, 34vh, 21rem); cursor: crosshair; touch-action: pan-y; border-radius: 6px; }
#chart:focus-visible { outline-offset: 6px; }
.chart-readout {
  position: absolute; top: 0.4rem; left: 0; pointer-events: none;
  display: grid; gap: 0.1rem; min-width: 9.5rem;
  padding: 0.5rem 0.7rem; border: 1px solid var(--edge); border-radius: 8px;
  background: rgba(15, 21, 30, 0.94);
  font-size: 0.8rem; color: var(--mist); font-variant-numeric: tabular-nums; line-height: 1.45;
}
.chart-readout b { font-weight: 500; color: var(--paper); }
.chart-readout .is-floor b { color: var(--ember); }
.chart-readout span { display: flex; justify-content: space-between; gap: 1rem; }
.chart-note { margin-top: 0.7rem; font-size: 0.8rem; color: var(--mist); }

/* Trade ticket: the only raised surface */
.trade {
  padding: 0.5rem 0.5rem 1.1rem !important;
  background: var(--surface);
  border: 1px solid var(--edge); border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(238, 241, 245, 0.05), 0 40px 80px -48px rgba(0, 0, 0, 0.95);
}
.trade form { padding: 0 0.6rem; }

.tabs {
  --i: 0;
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 0.25rem; background: var(--night); border-radius: 15px;
}
.tabs::before {
  content: ""; position: absolute; z-index: -1; top: 0.25rem; bottom: 0.25rem; left: 0.25rem;
  width: calc((100% - 0.5rem) / 3);
  border-radius: 11px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--edge);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.28s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.tabs button {
  min-height: 2.75rem; border: 0; border-radius: 11px; cursor: pointer;
  background: none; color: var(--mist); font: 500 var(--step--1) / 1 var(--sans);
  transition: color 0.2s;
}
.tabs button:hover { color: var(--steel); }
.tabs button[aria-selected="true"] { color: var(--paper); }
.tabs button:focus-visible { outline-offset: -2px; border-radius: 11px; }

.slot { padding: 0.85rem 1rem 0.95rem; border-radius: 14px; }
.slot-top { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.8rem; color: var(--mist); }
.amount { margin-top: 1rem; background: var(--night); border: 1px solid var(--rule); transition: border-color 0.2s; }
.amount:focus-within { border-color: #4a5a6f; }
.balance { font-variant-numeric: tabular-nums; }
.amount-row { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.3rem; }
.amount-row input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 0;
  color: var(--paper); font: 500 clamp(1.7rem, 1.3rem + 1.2vw, 2.1rem) / 1.15 var(--sans); font-variant-numeric: tabular-nums;
}
.amount-row input::placeholder { color: #3f4d5e; }
.amount-unit { color: var(--paper); font-weight: 500; }
.max {
  border: 1px solid var(--rule); background: none; color: var(--steel); cursor: pointer;
  border-radius: 999px; padding: 0.3rem 0.65rem; font: 500 0.75rem / 1 var(--sans);
}
.max:hover { color: var(--paper); border-color: var(--mist); }

.receive { margin-top: 0.3rem; background: transparent; border: 1px solid transparent; }
.receive-row { margin-top: 0.3rem; display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; min-height: 2.4rem; color: var(--ink-dim); font: 500 clamp(1.7rem, 1.3rem + 1.2vw, 2.1rem) / 1.15 var(--sans); font-variant-numeric: tabular-nums; }
.receive-row .n { color: var(--paper); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.receive-row .placeholder { color: #3f4d5e; }
.receive-row .u { color: var(--paper); font-size: var(--step-0); }
.receive-row.is-fresh .n { animation: settle 0.35s ease-out; }
@keyframes settle { from { opacity: 0.35; } to { opacity: 1; } }

.quote { margin: 0.5rem 1rem 0; display: grid; gap: 0.45rem; font-size: var(--step--1); }
.quote div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.quote dt { color: var(--mist); }
.quote dd { margin: 0; color: var(--steel); text-align: right; font-variant-numeric: tabular-nums; }
.quote-floor { margin-top: 0.35rem; padding-top: 0.7rem; border-top: 1px solid var(--rule); }
.quote .quote-floor dt { color: var(--paper); }
.quote .quote-floor dd { color: var(--ember); font-size: var(--step-0); }
.quote-floor .delta { margin-left: 0.4rem; color: var(--paper); font-size: var(--step--1); }

.hint { margin: 0.8rem 1rem 0; min-height: 3em; font-size: 0.85rem; color: var(--mist); line-height: 1.5; }
.submit { width: 100%; margin-top: 0.9rem; min-height: 3.4rem; border-radius: 14px; font-weight: 600; }
.submit:disabled { background: var(--surface-2); color: var(--mist); box-shadow: inset 0 0 0 1px var(--rule); cursor: not-allowed; }

/* Position and activity: open sections, no cards */
.position, .activity { padding-top: 1.4rem !important; border-top: 1px solid var(--rule); }
.empty { margin-top: 0.7rem; color: var(--mist); font-size: var(--step--1); max-width: 30rem; }
.empty .button { margin-top: 1rem; }
.position-stats { margin: 1.1rem 0 0; display: grid; gap: 1rem 1.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.position-stats dd { margin: 0.1rem 0 0; color: var(--paper); font-variant-numeric: tabular-nums; }
.position-main dd { font: 500 2.3rem / 1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.position-note { margin-top: 1.1rem; font-size: 0.85rem; color: var(--mist); }
.position-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem 1rem; margin-top: 1rem; font-size: 0.85rem; color: var(--mist); font-variant-numeric: tabular-nums; }

.activity-list { list-style: none; padding: 0; margin: 0.7rem 0 0; }
.activity-list li {
  display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) auto; gap: 0.1rem 1rem; align-items: baseline;
  padding: 0.8rem 0.6rem; margin: 0 -0.6rem; border-radius: 10px; font-size: var(--step--1);
}
.activity-list li { position: relative; }
.activity-list li + li::before { content: ""; position: absolute; top: 0; left: 0.6rem; right: 0.6rem; height: 1px; background: var(--rule); }
.activity-list li.is-new { animation: arrive 1.8s ease-out; }
@keyframes arrive { from { background-color: rgba(238, 241, 245, 0.07); } to { background-color: transparent; } }
.act-kind { font: 500 1.2rem / 1 var(--serif); color: var(--paper); grid-row: span 2; }
.act-what { color: var(--paper); font-variant-numeric: tabular-nums; }
.act-what span { color: var(--mist); }
.act-floor { color: var(--mist); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.act-floor b { font-weight: 500; color: var(--ember); }
.act-time { grid-column: 2 / -1; font-size: 0.8rem; color: var(--mist); }
@media (max-width: 520px) {
  .activity-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .act-kind { grid-row: auto; }
  .act-floor { grid-column: 2; grid-row: 1; }
  .act-what, .act-time { grid-column: 1 / -1; }
}

/* Wallet dialog */
.wallets {
  width: min(25rem, calc(100vw - 2rem)); padding: 1.3rem 1.3rem 1.2rem;
  background: var(--surface); color: var(--steel);
  border: 1px solid var(--edge); border-radius: 20px;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9);
}
.wallets[open] { animation: rise-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.wallets::backdrop { background: rgba(5, 8, 12, 0.72); backdrop-filter: blur(4px); }
.wallets-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.wallets h2 { font: 500 1.9rem / 1.1 var(--serif); }
.close {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none;
  background: none; border: 1px solid transparent; border-radius: 50%; color: var(--mist); cursor: pointer;
}
.close:hover { color: var(--paper); border-color: var(--rule); }
.wallet-list { list-style: none; padding: 0; margin: 1.1rem 0 0; display: grid; gap: 0.4rem; }
.wallet-list:empty { display: none; }
.wallet-list button {
  width: 100%; display: flex; align-items: center; gap: 0.8rem;
  min-height: 3.5rem; padding: 0.6rem 0.9rem; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--night); color: var(--paper); font: 500 var(--step-0) / 1.2 var(--sans); cursor: pointer; text-align: left;
  transition: border-color 0.2s, background-color 0.2s;
}
.wallet-list button:hover { border-color: #4a5a6f; background: var(--surface-2); }
.wallet-list img, .wallet-list .avatar { width: 2rem; height: 2rem; border-radius: 8px; flex: none; }
.wallet-found { margin-left: auto; font-size: 0.75rem; font-weight: 400; color: var(--mist); }
.wallets-none { margin-top: 1.1rem; font-size: var(--step--1); color: var(--mist); }
.wallets .form-error { margin-top: 0.8rem; font-size: var(--step--1); color: #ffc3a3; }
.wallets-or { display: flex; align-items: center; gap: 0.8rem; margin-top: 1rem; font-size: 0.8rem; color: var(--ink-dim); }
.wallets-or::before, .wallets-or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.demo-account {
  width: 100%; display: grid; gap: 0.2rem; margin-top: 1rem; padding: 0.8rem 0.95rem;
  text-align: left; cursor: pointer; color: var(--paper);
  background: none; border: 1px dashed rgba(199, 206, 216, 0.35); border-radius: 12px;
  font: inherit; transition: border-color 0.2s, background-color 0.2s;
}
.demo-account:hover { border-color: var(--steel); background: rgba(238, 241, 245, 0.03); }
.demo-account-title { font-weight: 500; }
.demo-account-desc { font-size: 0.8rem; color: var(--mist); line-height: 1.4; }
.wallets-foot { margin-top: 1rem; font-size: 0.8rem; color: var(--mist); line-height: 1.5; }

/* Toast */
.toast {
  position: fixed; right: var(--gutter); bottom: 1.5rem; z-index: 30;
  max-width: min(26rem, calc(100vw - 2rem)); padding: 0.8rem 1.1rem;
  background: var(--paper); color: var(--night); border-radius: 12px;
  font-size: var(--step--1); font-weight: 500; line-height: 1.45;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.is-error { background: #ffd9c4; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) {
  .toast { left: 1rem; right: 1rem; bottom: 1rem; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .app-body *, .app-body *::before, .app-body *::after { animation: none !important; transition: none !important; }
}
