/* Structure and shared components, reading only tokens. squares.css holds the sheet, the panel, the painter and the
   pages. */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100svh; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--font-text); -webkit-font-smoothing: antialiased; overflow-x: clip; }
img, svg, canvas { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
::selection { background: var(--cobalt); color: #fff; }

/* ---------- type ---------- */
h1, h2, .display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.015em; line-height: 0.98; text-wrap: balance; }
h1 { font-size: clamp(40px, 5vw, 68px); }
h2 { font-size: clamp(30px, 3.4vw, 46px); }
h1 em, h2 em, .display em { font-style: italic; color: var(--cobalt); }
h3, .h3 { font: 600 18px/1.3 var(--font-text); letter-spacing: -0.01em; }
.lede { font-size: clamp(17px, 1.4vw, 18.5px); line-height: 1.5; color: var(--ink-2); max-width: 36em; }
.lede b { color: var(--ink); font-weight: 600; }
.muted { color: var(--muted); }
.fine { font-size: 13.5px; color: var(--muted); }
.mono, .num, .label, .kicker, .chip { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.kicker-sq { width: 8px; height: 8px; background: var(--cobalt); }
.cobalt { color: var(--cobalt); }

/* ---------- layout ---------- */
.wrap { width: min(var(--wrap), 100% - 2 * var(--gut)); margin-inline: auto; }
.section { padding-top: clamp(64px, 8vw, 112px); }
.page-head { padding-top: clamp(40px, 6vw, 76px); padding-bottom: 32px; display: grid; gap: 16px; justify-items: start; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.section-head p { max-width: 34em; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 18px; }
main { padding-bottom: 120px; }
main.enter { animation: page-in 320ms var(--ease); }
@keyframes page-in { from { opacity: 0; } }

/* ---------- header ---------- */
#top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); border-bottom: var(--border); }
.top-bar { height: var(--top-h); display: flex; align-items: center; gap: 32px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand-word { display: flex; padding-top: 3px; }
.nav { display: flex; gap: 2px; }
.nav a { position: relative; padding: 8px 12px; color: var(--ink-2); font-size: 15px; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current] { color: var(--ink); }
.nav a[aria-current]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px; background: var(--ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.demo-strip { background: var(--ink); color: #D9D5CC; font-size: 13px; text-align: center; padding: 6px var(--gut); }
.demo-strip b { color: #fff; font-weight: 600; }
.tabbar { display: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--line-3); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap; transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--cobalt); color: #fff; border-color: var(--cobalt); }
.btn.primary:hover { background: #2234C4; border-color: #2234C4; }
.btn.ink { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.ink:hover { background: #000; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.lg { height: 52px; padding: 0 24px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); background: var(--bg-2); }
.link { background: none; border: 0; padding: 0; color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-3); }
.link:hover { color: var(--ink); text-decoration-color: currentColor; }
.arrow-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 15px; }
.arrow-link:hover { color: var(--ink); }
.icon { display: inline-flex; }

/* ---------- chips, banners ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-sm); border: var(--border); background: var(--surface); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chip.demo { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.chip.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.chip.yours { color: var(--cobalt); border-color: color-mix(in srgb, var(--cobalt) 40%, transparent); }
.banner { padding: 14px 18px; border-radius: var(--r); border: var(--border); background: var(--surface); }
.banner.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.banner.yours { border-color: color-mix(in srgb, var(--cobalt) 45%, transparent); background: var(--cobalt-soft); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }

/* ---------- segmented controls ---------- */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-sm); border: var(--border); background: var(--surface); }
.seg button { height: 30px; padding: 0 12px; border-radius: 4px; border: 0; background: none; color: var(--ink-2); cursor: pointer; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field-label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.input { width: 100%; height: 44px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-3); background: var(--surface); font-size: 16px; }
.input:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-soft); }
.input[aria-invalid] { border-color: var(--bad); }
.problem { color: var(--bad); font-size: 13.5px; }
.problem:empty { display: none; }
.stepper { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--line-3); background: var(--surface); overflow: hidden; }
.stepper button { height: 100%; border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 18px; }
.stepper button:hover { background: var(--bg-2); color: var(--ink); }
.stepper input { width: 100%; height: 100%; border: 0; border-inline: var(--border); text-align: center; font: 500 16px var(--font-mono); background: none; }
.stepper input:focus { outline: none; background: var(--cobalt-soft); }

/* ---------- cards ---------- */
.card { border-radius: var(--r-lg); border: var(--border); background: var(--surface); padding: 22px; }

/* ---------- stats, CA box ---------- */
.stat { display: grid; gap: 4px; }
.stat-value { font-size: 22px; font-family: var(--font-mono); }
.stat-hint { font-size: 12.5px; color: var(--muted); }
.ca { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 14px; border-radius: var(--r); border: 1px dashed var(--line-3); max-width: 100%; }
.ca-addr { font-size: 13px; word-break: break-all; user-select: all; }
.ca-soon { color: var(--warn); font-size: 13px; }
.ca-note { font-size: 13px; flex-basis: 100%; color: var(--muted); }
.ca.small { padding: 0 12px; height: 34px; border-radius: var(--r-sm); flex-wrap: nowrap; }
.ca.small .label { font-size: 10px; }

/* ---------- empty, failed ---------- */
.empty { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 56px 16px; }
.empty h3 { font: 400 28px/1.1 var(--font-display); }
.more { display: grid; justify-items: center; margin-top: 24px; }

/* ---------- wallet ---------- */
.wallet-box { position: relative; }
.wallet-btn.on { padding: 0 12px; gap: 10px; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; padding: 6px; border-radius: var(--r); border: var(--border); background: var(--surface); box-shadow: var(--paper-shadow); display: grid; gap: 2px; z-index: 30; }
.menu-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; color: var(--ink-2); }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); border: 0; background: none; text-align: left; cursor: pointer; font-size: 14.5px; }
.menu-item:hover { background: var(--bg-2); }
.wallet-list { display: grid; gap: 8px; }
.wallet-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); border: var(--border); background: var(--surface); cursor: pointer; text-align: left; }
.wallet-row:hover:not([disabled]) { border-color: var(--ink); }
.wallet-row[disabled] { opacity: 0.6; cursor: default; }
.wallet-row img { border-radius: 8px; }
.wallet-name { flex: 1; font-weight: 600; }
.wallet-tag { font: 12px var(--font-mono); color: var(--muted); }
.wallet-help { display: grid; gap: 10px; margin-top: 14px; }

/* ---------- modal, toasts ---------- */
.modal-veil { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(22, 22, 21, 0.38); animation: fade var(--t) var(--ease); }
.modal-panel { width: min(480px, 100%); max-height: calc(100svh - 32px); overflow: auto; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--paper-shadow); padding: 24px; animation: pop var(--t) var(--ease); overflow-wrap: anywhere; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 30px; }
.modal-panel.locked .modal-x { visibility: hidden; }
.modal-body { display: grid; gap: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; justify-items: center; }
.toast { padding: 10px 16px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-size: 14px; box-shadow: var(--paper-shadow); animation: pop var(--t) var(--ease); }
.toast.bad { background: var(--bad); }

/* ---------- footer ---------- */
#foot { border-top: var(--border); padding: 48px 0 calc(48px + env(safe-area-inset-bottom)); }
.foot { display: grid; grid-template-columns: 1fr auto; gap: 24px 48px; }
.foot-brand { display: grid; gap: 12px; justify-items: start; }
.foot-brand p { color: var(--muted); max-width: 30em; }
.foot-links { display: flex; gap: 22px; flex-wrap: wrap; align-items: start; color: var(--ink-2); font-size: 15px; }
.foot-links a:hover { color: var(--ink); }
.foot-base { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 13.5px; padding-top: 20px; border-top: var(--border); color: var(--muted); }

/* ---------- motion switch: when off, nothing moves (the visible switch, not the OS setting, decides) ---------- */
[data-motion="off"] *, [data-motion="off"] *::before, [data-motion="off"] *::after { animation: none !important; transition: none !important; }

/* ---------- phones ---------- */
@media (max-width: 860px) {
  .nav, .top-actions .ca { display: none; }
  .tabbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 25; display: flex; justify-content: space-around; padding: 5px; border-radius: var(--r); border: var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); box-shadow: var(--paper-shadow); }
  .tabbar a { flex: 1; text-align: center; padding: 9px 8px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 14px; }
  .tabbar a[aria-current] { background: var(--ink); color: #fff; }
  #foot { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .foot { grid-template-columns: 1fr; }
  .wallet-btn.on .muted { display: none; }
  .top-bar { gap: 12px; }
}
