/*
 * css/app.css: the app page only (/app). Everything shared lives in css/site.css.
 */

.app { padding-top: 34px; padding-bottom: 20px; }
.app-head { display: grid; gap: 14px; margin-bottom: 30px; max-width: 860px; }
.app-head h1 { font-size: clamp(34px, 5vw, 58px); }
.app-prelim { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); background: var(--glass-in); border: 1px solid rgba(255, 255, 255, .85); box-shadow: var(--glass-rim), inset 0 1px 0 #fff, inset 0 -14px 22px -18px rgba(33, 70, 208, .2); border-radius: 14px; padding: 12px 14px; }
.small { font-size: 12.5px; }

.app-grid { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 28px; align-items: start; }
.app-main { display: grid; gap: 40px; min-width: 0; }
.app-side { position: sticky; top: 82px; display: grid; gap: 12px; min-width: 0; }
@media (max-width: 1040px) {
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .app-side { position: static; }
}

.block { display: grid; gap: 16px; min-width: 0; scroll-margin-top: 80px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.block-head h2 { font-size: clamp(26px, 3vw, 34px); }

/* ---------------------------------------------------------------------------------------------- loans */

.loans { display: grid; gap: 16px; }
.empty { display: grid; gap: 12px; justify-items: start; }
.empty h3 { font-size: 22px; }
.empty p { max-width: 62ch; }

.loan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.loan-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.loan-name h3 { font-size: 22px; }
.loan-name p { font-size: 13px; }
/* .tok is the shared token disc (.tk in site.css) at this page's sizes */
.loan-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 18px; margin-top: 18px; }
.loan-figs > div { display: grid; gap: 4px; min-width: 0; }
.loan-figs dt { font: 500 10.5px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.loan-figs dd { font: 500 17px/1.2 var(--mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.loan-figs dd small { display: block; font: 400 12px/1.3 var(--sans); letter-spacing: 0; color: var(--ink-3); margin-top: 3px; }
@media (max-width: 720px) { .loan-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.loan .meter { margin: 30px 2px 30px; }
.loan-note { font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.loan-note b { font-weight: 500; color: var(--ink); }
.loan-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.loan-acts .spacer { flex: 1; }
@media (max-width: 560px) {
  .loan-acts .btn { flex: 1 1 calc(50% - 4px); }
  .loan-acts .btn-primary, .loan-acts .btn-wide { flex-basis: 100%; }
  .loan-acts .spacer { display: none; }
}

/* ---------------------------------------------------------------------------------------------- open a loan */

.open-head { display: grid; gap: 8px; justify-items: start; margin-bottom: 18px; }
.open-head h2 { font-size: clamp(26px, 3vw, 34px); }
.open-head p { max-width: 60ch; font-size: 14px; }
.open-form { display: grid; gap: 16px; max-width: 560px; }
.open-kv { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 14px; }
.say { min-height: 20px; font-size: 13.5px; color: var(--ink-3); }
.say.bad { color: var(--bad); }
.say.ok { color: var(--ok); }
.field > label > span + span { color: var(--ink-3); font-size: 12px; }

/* ---------------------------------------------------------------------------------------------- markets */

.table-card { overflow-x: auto; overflow-y: hidden; }
.markets th { white-space: normal; line-height: 1.35; letter-spacing: .1em; vertical-align: bottom; }
.markets td:first-child { white-space: nowrap; }
.markets .mk { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.markets .mk small { color: var(--ink-3); font-weight: 400; }
.markets .tok { width: 30px; height: 30px; font-size: 8.5px; }
.markets td.r { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; }
@media (max-width: 720px) {
  .markets .col-wide { display: none; }
  .markets th, .markets td { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 420px) {
  .markets .tok { width: 22px; height: 22px; }
  .markets .mk { gap: 7px; }
  .markets th { letter-spacing: .04em; font-size: 9px; }
  .markets td { font-size: 12.5px; }
  .markets th, .markets td { padding-left: 6px; padding-right: 6px; }
  .markets th:first-child, .markets td:first-child { padding-left: 10px; }
  .markets th:last-child, .markets td:last-child { padding-right: 10px; }
  .markets .mk small { display: none; }
}
@media (max-width: 350px) { .markets .tok { display: none; } }

/* ---------------------------------------------------------------------------------------------- the arena */

.arena-top { display: grid; gap: 14px; }
.arena-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.arena-counts > div { display: grid; gap: 4px; padding: 12px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.arena-counts b { font: 500 20px/1 var(--mono); letter-spacing: -.03em; overflow-wrap: anywhere; }
.arena-counts span { font: 500 9.5px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.arena-part { padding: 16px 22px 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.arena-list { display: grid; gap: 8px; }
.arena-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); font-size: 13px; min-width: 0; }
.arena-row .who { font-family: var(--mono); letter-spacing: -.02em; font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arena-row .what { grid-column: 1 / -1; color: var(--ink-3); font-size: 12.5px; line-height: 1.45; }
.arena-row .what b { color: var(--ink); font-weight: 500; font-family: var(--mono); letter-spacing: -.02em; }
.arena-row a { color: var(--blue); }
.arena-row .chip { height: 24px; font-size: 11.5px; }
.arena-note { padding: 0 4px; line-height: 1.5; }
#agent-addr { color: var(--blue); }
@media (max-width: 560px) { .arena-part { padding: 14px 18px 16px; } }

/* ---------------------------------------------------------------------------------------------- sheets */

.sheet-lede { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.preview { display: grid; gap: 10px; }
.preview-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.preview-box b { font-weight: 500; color: var(--ink); }
.preview-box.agent { border-color: rgba(33, 70, 208, .28); background: var(--blue-tint); }
.preview-box .eyebrow { display: block; margin-bottom: 7px; }
.sheet .meter { margin: 26px 2px 24px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 999px; background: var(--paper-2); }
.seg button { height: 36px; border: 0; border-radius: 999px; background: transparent; font: 500 13.5px/1 var(--sans); color: var(--ink-2); }
.seg button[aria-pressed='true'] { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(11, 22, 48, .12); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--blue); flex: none; }
.wallets { display: grid; gap: 8px; }
.wallets button { display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--white); font: 500 15px/1 var(--sans); text-align: left; }
.wallets button:hover { border-color: var(--blue); }
.wallets img { width: 28px; height: 28px; border-radius: 7px; }
.wallets .noicon { width: 28px; height: 28px; border-radius: 7px; background: var(--blue-tint); }

/* ---------------------------------------------------------------------------------------------- progress toast */

.toast.work { align-items: center; }
.toast .spin { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .28); border-top-color: #fff; animation: spin .8s linear infinite; }
.toast .t-body { display: grid; gap: 2px; min-width: 0; }
.toast .t-body b { font-weight: 500; }
.toast .t-body span { color: rgba(255, 255, 255, .78); font-size: 12.5px; overflow-wrap: anywhere; }
.toast .t-x { margin-left: auto; flex: none; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; display: grid; place-items: center; padding: 0; }
.toast .t-x svg { width: 10px; height: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { height: 150px; border-radius: var(--radius); background: linear-gradient(100deg, var(--surface) 30%, var(--white) 50%, var(--surface) 70%) 0 0 / 300% 100%; border: 1px solid var(--line); animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -300% 0; } }

/* what the ticks on a loan-to-value bar mean */
.meter-key { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -4px 2px 16px; font: 500 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.meter-key span { display: inline-flex; align-items: center; gap: 6px; }
.meter-key span::before { content: ''; height: 10px; border-left: 1.5px solid var(--ink); }
.meter-key [data-k='target']::before { border-color: var(--ok); border-left-style: dashed; }
.meter-key [data-k='guard']::before { border-color: var(--blue); }
.meter-key [data-k='open']::before { border-color: var(--warn); border-left-style: dashed; }
.meter-key [data-k='lltv']::before { border-color: var(--bad); }
.sheet .meter-key { margin-top: 0; margin-bottom: 4px; }
body.is-busy [data-act], body.is-busy #open-act { pointer-events: none; opacity: .6; }

/* Notes appear at the top of the window, over the header: never over the buttons at the bottom of a card or a sheet. */
.app-page .toasts { top: calc(10px + env(safe-area-inset-top, 0px)); bottom: auto; }
.app-page .toast { animation-name: drop; }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }
@media (max-width: 380px) {
  .app-page .nav-cta .btn-quiet { display: none; }
  .app-page .nav .wrap { gap: 10px; }
}
