/* Reading density for the six transaction desks. The signed receipt and
   connected passbook keep their existing layout and reserved space. */
body:is(.borrow-page,.earn-page,.redeem-page,.fx-page,.lending-page,.turbo-page,.perps-page) .field-head {
  align-items: baseline;
  gap: 6px 12px;
}
body:is(.borrow-page,.earn-page,.redeem-page,.fx-page,.lending-page,.turbo-page,.perps-page) .field-head > label {
  min-width: 0;
}
body:is(.borrow-page,.earn-page,.redeem-page,.fx-page,.lending-page,.turbo-page,.perps-page) .field-head > .hint {
  margin-left: auto;
  text-align: right;
}
/* The illustration's native 360-unit width keeps its lettering readable
   without enlarging the entire explanation into a second screen. */
.earn-page #money-flow .savings-map { max-width: 360px; }
.earn-page #money-flow .savings-layout { align-items: start; }
/* A sample has no observed timestamp: do not reserve a blank timestamp row.
   Configured markets retain the reserved loading space to prevent jumps. */
.lending-page.desk-sample .lending-rate #lending-apr-note { min-height: 0; }
.lending-page.desk-sample .lending-rate > .stage-line:has(> time:empty) { display: none; }
.turbo-page .turbo-conditions .rows > div {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: start;
}
.turbo-page .turbo-conditions .rows dd { text-align: left; }
@media (min-width: 1100px) {
  .turbo-page .turbo-conditions[aria-labelledby="turbo-conditions-title"] .rows {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
    align-items: start;
  }
  .turbo-page .turbo-conditions[aria-labelledby="turbo-conditions-title"] .rows > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    min-width: 0;
    padding-block: 10px;
  }
}
/* Fable review: controls get the first mobile row; empty books follow.
   Connected books keep their original ordering. */
.earn-page #earn-choice { padding-right: 12px; }
.turbo-page:not(.desk-closed) main > .turbo-conditions { display: block !important; }
@media (max-width: 899px) {
  .fx-page:not(:has(#connect[data-owner])) .desk-body > .passbook { order: 1; }
}
@media (max-width: 700px) {
  .redeem-page #money-flow .slip-memo dl > div {
    grid-template-columns: 96px minmax(0, 1fr);
    column-gap: 10px;
  }
}
@media (max-width: 560px) {
  .earn-page #earn-choice { min-height: 49px; }
  .fx-page #direction-choice { gap: 4px; }
  .fx-page #direction-choice button { padding-inline: 6px; gap: 2px; font-size: 12px; min-height: 44px; }
  /* Count only displayed metric cells after a read. While loading, count
     skeleton cells too, so missing readings cannot create a false last row. */
  body:is(.borrow-page,.turbo-page):is([data-read="loading"],[data-read="failed"]) .desk-head > .ledger > div:last-child:nth-child(odd),
  body:is(.borrow-page,.turbo-page):not([data-read="loading"]):not([data-read="failed"]) .desk-head > .ledger > div:nth-last-child(1 of :not([hidden]):not(:has(> dd[data-empty]:not([data-shown])))):nth-child(odd of :not([hidden]):not(:has(> dd[data-empty]:not([data-shown])))) {
    grid-column: 1 / -1;
    background: var(--washi-tex) 0 0 / 480px, var(--washi-hi);
  }
}
/* Measured longest APR explanations: one line at 1440; two Japanese and
   three English lines at 390. Keep that space reserved during loading. */
@media (min-width: 1100px) {
  .lending-page:not(.desk-sample) .lending-rate #lending-apr-note { min-height: 1.8em; }
}
@media (max-width: 560px) {
  .lending-page:not(.desk-sample):lang(ja) .lending-rate #lending-apr-note { min-height: 3.6em; }
}

/* Round 2: the example tag is metadata, followed by rows of actual metrics.
   It must not consume the first metric column on narrow screens. */
@media (max-width: 560px) {
  body:is(.borrow-page,.earn-page,.redeem-page,.fx-page,.lending-page,.turbo-page,.perps-page).desk-sample[data-read] .desk-head .ledger:has(> div > dd)::before { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .lending-page:lang(ja) #supply-form .stage-line > span { text-wrap: balance; }
}

/* Round 3: explanations remain readable without enlarging their text. */
@media (min-width: 900px) {
  .earn-page #e-paid-label { white-space: normal; }
}
body:is(.borrow-page,.earn-page,.redeem-page,.fx-page,.lending-page,.turbo-page,.perps-page):not(:has(#connect[data-owner])) .passbook {
  background: linear-gradient(90deg, var(--paper) 65%, #fbf6eaeb), var(--vignette, none) right bottom / auto 100% no-repeat, var(--paper);
}
body:is(.earn-page,.redeem-page,.lending-page,.turbo-page,.perps-page) .flow-explanation-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 6px;
}
.fx-page .lp-bond-link { display: inline-flex; align-items: center; min-height: 44px; }
