/* Member workspace. Mobile first; the sidebar appears from 992px. */
.app { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
.app-header { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 60px; padding: 6px 16px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.app-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; text-decoration: none; color: var(--color-primary); }
.app-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header__actions { display: flex; align-items: center; gap: 4px; flex: none; }
.app-header__actions form { margin: 0; }
.icon-link { display: inline-flex; align-items: center; gap: 4px; min-height: var(--touch); padding: 0 10px; border: 0; background: transparent; border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text); font-size: var(--text-sm); }
.icon-link:hover { background: var(--color-primary-soft); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--color-primary); color: #fff; font-size: var(--text-xs); }

.app-body { display: flex; align-items: flex-start; max-width: 1440px; margin: 0 auto; }
.app-sidebar { display: none; }
.app-main { flex: 1 1 auto; min-width: 0; padding: 16px; }
.app-main:focus { outline: 0; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); background: var(--color-surface); border-top: 1px solid var(--color-border); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; font-size: 0.7rem; text-decoration: none; color: var(--color-muted); }
.bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav a[aria-current="page"] { color: var(--color-primary); font-weight: 700; }

@media (min-width: 992px) {
  .app { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .app-sidebar { position: sticky; top: 61px; display: flex; flex-direction: column; flex: 0 0 220px; gap: 2px; max-height: calc(100vh - 61px); overflow-y: auto; padding: 16px 12px; }
  .app-sidebar a { display: flex; align-items: center; min-height: var(--touch); padding: 0 14px; border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text); }
  .app-sidebar a:hover { background: var(--color-primary-soft); }
  .app-sidebar a[aria-current="page"] { background: var(--color-primary); color: #fff; font-weight: 600; }
  .app-main { padding: 24px 28px 48px; }
}

.page-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-title h1 { margin: 0; }
.eyebrow { margin: 0 0 4px; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-muted); }
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); margin-bottom: 14px; }
@media (min-width: 560px) { .grid--2, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.panel { min-width: 0; padding: 18px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); margin-bottom: 14px; }
.grid > .panel { margin-bottom: 0; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel__head h2 { margin: 0; font-size: var(--text-lg); }
.stat { font-size: var(--text-2xl); font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.muted { color: var(--color-muted); font-size: var(--text-sm); }

/* The two wallets look different on purpose: cash is money, tokens are not. */
.wallet-cash { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.wallet-cash .eyebrow, .wallet-cash .muted { color: #cfe3d9; }
.wallet-token { background: #fffaf0; border: 2px dashed var(--color-warning); }
.wallet-token .stat::after { content: " tokens"; font-size: var(--text-base); font-weight: 600; color: var(--color-warning-text); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 700; background: #e9eeeb; color: #3d4742; white-space: nowrap; }
.pill--ok { background: var(--color-success-soft); color: var(--color-success-text); }
.pill--ok::before { content: "\2713"; }
.pill--wait { background: var(--color-warning-soft); color: var(--color-warning-text); }
.pill--wait::before { content: "\25f7"; }
.pill--bad { background: var(--color-danger-soft); color: var(--color-danger-text); }
.pill--bad::before { content: "\2715"; }

.progress { height: 10px; border-radius: var(--radius-pill); background: #e3e9e5; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--color-primary); }

/* Records: a table on wide screens, stacked cards on narrow ones (cells carry data-label). */
.records { width: 100%; border-collapse: collapse; }
.records th, .records td { padding: 10px; border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; }
.records th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); }
.records .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 767px) {
  .records, .records tbody, .records tr, .records td { display: block; width: 100%; }
  .records thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .records tr { margin-bottom: 10px; padding: 6px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); }
  .records td { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; text-align: right; overflow-wrap: anywhere; }
  .records td:last-child { border-bottom: 0; }
  .records td::before { content: attr(data-label); flex: none; font-weight: 600; color: var(--color-muted); text-align: left; }
  .records td:empty { display: none; }
  .records .num { white-space: normal; }
}
.empty { padding: 28px 16px; text-align: center; color: var(--color-muted); border: 1px dashed var(--color-border-strong); border-radius: var(--radius); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.filters > * { flex: 1 1 150px; }
.filters > .btn { flex: 0 0 auto; }
.copy-row { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-row input { flex: 1 1 200px; min-width: 0; }
.definition { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 6px 12px; margin: 0; }
.definition dt { color: var(--color-muted); }
.definition dd { margin: 0; overflow-wrap: anywhere; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; }

/* binary tree */
.tree-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tree-toolbar form { display: flex; gap: 6px; flex: 1 1 230px; }
.tree-viewport { overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); padding: 16px; cursor: grab; max-height: 70vh; }
.tree-viewport.is-panning { cursor: grabbing; user-select: none; }
.tree-canvas { width: max-content; min-width: 100%; transform-origin: top left; }
.tree, .tree ul { display: flex; justify-content: center; align-items: flex-start; margin: 0; padding: 0; list-style: none; }
.tree ul { position: relative; padding-top: 20px; }
.tree ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 10px; border-left: 2px solid var(--color-border-strong); }
.tree li { position: relative; display: flex; flex-direction: column; align-items: center; padding: 10px 5px 0; }
.tree ul > li::before { content: ""; position: absolute; top: 0; width: 100%; border-top: 2px solid var(--color-border-strong); }
.tree ul > li:first-child::before { left: 50%; width: 50%; }
.tree ul > li:last-child::before { right: 50%; width: 50%; }
.tree ul > li::after { content: ""; position: absolute; top: 0; left: 50%; height: 10px; border-left: 2px solid var(--color-border-strong); }
.node { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 132px; min-height: 96px; padding: 8px; border: 2px solid var(--color-border-strong); border-radius: var(--radius); background: var(--color-surface); text-align: center; font-size: var(--text-xs); }
button.node:hover { border-color: var(--color-primary); }
.node strong { font-size: var(--text-sm); overflow-wrap: anywhere; }
.node--activated { border-color: var(--color-primary); }
.node--empty { border-style: dashed; justify-content: center; color: var(--color-muted); background: #fafbfa; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; padding: 0; list-style: none; }
.crumbs button { min-height: 36px; }
.tree-status { min-height: 1.5rem; }

.join { max-width: 640px; margin: 0 auto; }
