/*
 * Pick A Deal — one stylesheet, no build step.
 *
 * Design notes, because the choices here are not arbitrary:
 *
 * - This is a money app used almost entirely on phones, over patchy mobile
 *   data. So: bottom tab bar rather than a sideways-scrolling header, tap
 *   targets at 44px, tabular figures on every amount, and no web font blocking
 *   first paint.
 * - The brand is jade through cyan. Green because the product is money held in
 *   escrow and green is what trust looks like in that context; the cyan end
 *   keeps it from reading as yet another bank.
 * - Depth comes from layered surfaces and one soft shadow, not from borders
 *   everywhere. Borders are for separation, elevation is for hierarchy.
 * - Dark is the default and the design is drawn for it. Light mode is a real
 *   theme, not an inversion.
 */

:root {
  /* surfaces, dark (the default) */
  --bg: #070c13;
  --bg-2: #0b121b;
  --surface: #101b27;
  --surface-2: #16232f;
  --surface-3: #1c2b3a;
  --line: #21313f;
  --line-soft: #18242f;

  /* ink */
  --text: #e9eff6;
  --dim: #90a4b8;
  --faint: #64788c;

  /* brand */
  --brand: #00d094;
  --brand-2: #14b8f5;
  --brand-ink: #00251a;
  --brand-grad: linear-gradient(120deg, #00d094 0%, #14b8f5 100%);
  --brand-wash: #00d09418;
  --brand-ring: #00d09455;

  /* status */
  --ok: #3ddc97;
  --ok-wash: #3ddc9718;
  --warn: #ffb84d;
  --warn-wash: #ffb84d18;
  --bad: #ff6b6b;
  --bad-wash: #ff6b6b18;

  /* shape */
  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --shadow: 0 1px 2px #00000040, 0 8px 24px -12px #00000080;
  --shadow-lg: 0 2px 4px #00000040, 0 24px 48px -20px #000000a0;

  --gutter: 16px;
  --max: 760px;
  --bar: 62px; /* bottom tab bar */

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* An author `display` beats the UA stylesheet's [hidden], so state it here or
   `el.hidden = true` silently does nothing to anything we style. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* A single wash of brand colour behind everything, so the page has a light
   source instead of being a flat slab. Fixed, so it does not move on scroll. */
/*
 * Decoration must never make the page slide sideways.
 *
 * The glow behind the sign-in card is min(560px, 120vw) and bleeds past the card
 * on purpose. At 412px that is 494px, so the right-hand overhang gave the
 * document a scrollWidth of 454 against a 412 viewport: nothing looked wrong, but
 * the whole page could be dragged sideways under a thumb.
 *
 * `clip` rather than `hidden`: hidden would make the body a scroll container and
 * break position: sticky and scroll anchoring. This clips the bleed and changes
 * nothing else.
 */
body { overflow-x: clip; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(70ch 50ch at 12% -10%, #00d09412, transparent 60%),
    radial-gradient(60ch 40ch at 100% 0%, #14b8f50e, transparent 55%);
}

::selection { background: var(--brand-ring); color: var(--text); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ---------------------------------------------------------------- chrome */

header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
  border-bottom: 1px solid var(--line-soft);
}
/*
 * The blur lives on a pseudo-element, not on <header> itself.
 *
 * backdrop-filter makes an element a containing block for its position:fixed
 * descendants. With it on the header, the mobile tab bar's `bottom: 0`
 * resolved against the 50px-tall header and the bar rendered across the TOP of
 * the screen. On a pseudo-element the effect is identical and the nav is free
 * to pin to the viewport.
 */
header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
/* The mark: a rounded tile carrying the gradient, with the tick that the whole
   product is about — a deal that went through. */
.brand .mark {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  background: var(--brand-grad);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px -4px var(--brand-ring);
}
.brand .mark svg { width: 17px; height: 17px; display: block; }
.brand .mark path { stroke: var(--brand-ink); }

#whoami {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
  white-space: nowrap;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--line-soft);
}

/* --- navigation ---------------------------------------------------------
   One <nav>, two shapes. Wide: a row in the header. Narrow: a fixed bottom
   tab bar, because a header nav that scrolls sideways hides half itself and
   sits under the thumb's reach on a phone. */

nav { display: flex; gap: 2px; }
nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  color: var(--dim);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
nav a svg { width: 18px; height: 18px; flex: none; }
nav a:hover { color: var(--text); background: var(--surface); }
nav a.on { color: var(--brand); background: var(--brand-wash); }

@media (max-width: 760px) {
  nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg-2) 92%, transparent);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--line-soft);
  }
  nav a {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    border-radius: var(--r-sm);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  nav a svg { width: 21px; height: 21px; }
  nav a .lbl { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  nav a:hover { background: none; }
  nav a.on { background: none; }
  /* The active tab gets a lit bar above it rather than a filled pill: less
     visual weight at the bottom of the screen, still unmistakable. */
  nav a.on::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--brand-grad);
  }
  #whoami { display: none; }
}

main {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom));
}
@media (max-width: 760px) {
  main { padding-bottom: calc(var(--bar) + 18px + env(safe-area-inset-bottom)); }
}

/* Each screen arrives rather than snapping in. Short enough not to be in the
   way when you are moving fast through a trade. */
/* Only on a route change. The trade room repaints itself in place while you
   are reading it, and re-running this on every poll made the page flicker as
   though it were reloading. */
#view.enter > * { animation: rise .26s cubic-bezier(.22,.9,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- type */

h1 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 2px 0 14px;
}
h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 22px 0 8px;
}
p { margin: 0 0 8px; }
a { color: var(--brand); text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--brand); }

.dim { color: var(--dim); }
.sm { font-size: 12.5px; line-height: 1.5; }
.strong { font-weight: 700; letter-spacing: -0.01em; }
.ok { color: var(--ok); }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req { color: var(--bad); }
.link { color: var(--brand); font-weight: 600; }

code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  padding: 2px 7px;
  border-radius: var(--r-xs);
  word-break: break-all;
}

/* Money must never wobble between renders, and digits must line up down a
   column, so everything numeric is tabular. */
.amount, .rate, .ref, .balance span, .move span, .mono { font-variant-numeric: tabular-nums; }

.headline { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0; }
.amount { font-size: 27px; font-weight: 800; letter-spacing: -0.03em; }
.rate {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ref { font-family: var(--mono); font-size: 13px; letter-spacing: .04em; font-weight: 700; }
/* A trade reference is an identifier, not prose — it should read as one. */
.ref-title { font-family: var(--mono); letter-spacing: -0.01em; font-size: 23px; margin-bottom: 12px; }

/* An error that says nothing looks like a bug; give it a shape. */
.err {
  display: block;
  margin: 10px 0;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  background: var(--bad-wash);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
  color: var(--bad);
  font-size: 13.5px;
  font-weight: 600;
}
.err:empty { display: none; }

/* ---------------------------------------------------------------- layout */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.accent { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.card.accent::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(160deg, var(--brand-wash), transparent 55%);
}
/* Arrived here from a "fix this" link: say which card was meant, once. */
.card.flash { animation: flash 1.6s ease-out 1; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 3px var(--brand-ring), var(--shadow); }
  100% { box-shadow: 0 0 0 0 transparent, var(--shadow); }
}

.card.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.card.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: linear-gradient(var(--warn-wash), var(--warn-wash)) , var(--surface); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.row > input, .row > select { flex: 1; min-width: 0; }

.block { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.block:last-child { border-bottom: 0; padding-bottom: 0; }
.block:first-child { padding-top: 0; }

.copyrow { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }

/* --- auth / hero --------------------------------------------------------
   The one screen a stranger judges the product by, so it gets a light source
   of its own. */
.auth, .hero { max-width: 420px; margin: 4vh auto 0; }
.auth h1, .hero h1 { font-size: 34px; text-align: center; margin-bottom: 6px; }
.auth > p, .hero > p { text-align: center; }
.auth::before, .hero::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -80px;
  width: min(560px, 100vw);
  height: 320px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(closest-side, #00d09426, transparent 72%);
  filter: blur(6px);
}
.hero { text-align: center; }

/* Three short reasons to trust the thing, under the sign-in card. */
.trust { display: grid; gap: 10px; margin-top: 18px; }
.trust div { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--dim); }
.trust .ico {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--brand-wash);
  color: var(--brand);
  font-size: 12px;
}

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--brand-grad);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  margin: 4px 0;
  box-shadow: 0 6px 18px -10px var(--brand-ring);
  transition: transform .12s, box-shadow .18s, opacity .15s, background .15s;
}
.btn:hover:not(:disabled) { box-shadow: 0 10px 26px -10px var(--brand-ring); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  box-shadow: none;
}
.btn.ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }

.btn.danger {
  background: transparent;
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  box-shadow: none;
}
.btn.danger:hover:not(:disabled) { background: var(--bad-wash); }

.btn.wide { display: flex; width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: var(--r-xs); }

input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 13px;
  font: inherit;
  margin: 4px 0;
  min-height: 46px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--surface-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
  background: var(--surface);
}
/*
 * Chrome paints autofilled fields with its own background and text colour,
 * which on the sign-in screen came out as pale blue boxes in the middle of the
 * card. The colour cannot be set directly — an inset shadow the full height of
 * the field is the standard way to cover it — and the long transition stops it
 * flashing back on focus.
 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}
input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--surface) inset; }

input[type="file"] { padding: 9px; }
input[inputmode="decimal"], input[inputmode="numeric"] { font-variant-numeric: tabular-nums; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2390a4b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 17px;
  padding-right: 38px;
}

.field { margin-bottom: 10px; }
.field label {
  display: block;
  margin-bottom: 2px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--dim);
}

/* The name the BANK gave for an account number — the seller never types it. */
.acct {
  margin: 4px 0 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--line);
  background: var(--bg-2);
  min-height: 48px;
  display: flex;
  align-items: center;
}
.acct.looking { border-style: solid; }
.acct.found {
  border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent);
  background: var(--ok-wash);
}
.acct.bad {
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  background: var(--bad-wash);
  color: var(--bad);
}
.acct .nm { font-weight: 800; letter-spacing: -0.01em; text-transform: uppercase; }
.acct.found .nm { color: var(--ok); }

/* A fixed field is information, not an invitation to type. */
input[readonly] {
  background: var(--surface-2);
  color: var(--dim);
  cursor: default;
}
input[readonly]:hover { border-color: var(--line); }

/* Say the limit before it is hit, not only after a rejected submit. */
.hint { margin: 4px 0 0; color: var(--faint); font-size: 12px; }
.field.bad .hint { display: none; } /* the error replaces it, rather than stacking */

/* A rejected field says so where the person is looking, and keeps its value. */
.field.bad > input,
.field.bad > select,
.field.bad > textarea,
.row.bad > input {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px var(--bad-wash);
}
.field-err {
  margin: 4px 0 0;
  color: var(--bad);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
}
/* Inline rows (amount + button) are flex: give the message its own line. */
.row > .field-err { flex-basis: 100%; }

label.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
label.check input { width: auto; min-height: 0; margin-top: 3px; accent-color: var(--brand); }

.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  transition: background .2s;
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px #0006;
}
.switch input:checked + .slider { background: var(--brand-grad); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--brand); outline-offset: 2px; }

/* A segmented control, not two buttons. */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.tab {
  flex: 1;
  min-height: 38px;
  background: transparent;
  border: 0;
  color: var(--dim);
  padding: 8px;
  border-radius: var(--r-xs);
  font: inherit;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--brand-ink); background: var(--brand-grad); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
  background: var(--brand-wash);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}
.pill.ok { background: var(--ok-wash); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.pill.warn { background: var(--warn-wash); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.pill.bad { background: var(--bad-wash); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.pill.dim { background: var(--surface-2); color: var(--dim); border-color: var(--line); }

/* ---------------------------------------------------------------- lists */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .16s, border-color .16s, box-shadow .16s;
}
.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 45%, transparent); box-shadow: var(--shadow-lg); }
.tile.soon { opacity: .55; cursor: default; }
.tile.soon:hover { transform: none; border-color: var(--line); box-shadow: var(--shadow); }
.tile .ico {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  font-size: 25px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.tile .name { font-weight: 700; letter-spacing: -0.01em; }

/* --- a listing / a trade, as a tappable card --- */
.listing {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px;
  margin-bottom: 10px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .16s, border-color .16s, box-shadow .16s;
}
.listing:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 45%, transparent); box-shadow: var(--shadow-lg); }
.listing .row.spread { margin-bottom: 4px; }
.listing .rate { display: block; margin: 2px 0 4px; }

/* Monogram avatar. The colour is derived from the handle in screens.js, so the
   same trader is the same colour everywhere — something to recognise in a list
   of strangers. */
.who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px #ffffff1a;
}
.who .handle { font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.balance, .move {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.balance:last-child, .move:last-child { border-bottom: 0; padding-bottom: 0; }

/* --- inbox --- */
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--bad);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
nav a .badge { margin-left: 4px; }
@media (max-width: 760px) {
  /* On the tab bar the count belongs on the icon, not after the word. */
  nav a { position: relative; }
  nav a .badge { position: absolute; top: 2px; left: 50%; margin-left: 4px; }
}

.note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
  margin-bottom: 9px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .16s, transform .16s;
}
.note:hover { transform: translateX(2px); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.note.unread { border-left-color: var(--brand); background: linear-gradient(90deg, var(--brand-wash), transparent 40%), var(--surface); }
.note.high { border-left-color: var(--bad); background: linear-gradient(90deg, var(--bad-wash), transparent 40%), var(--surface); }
.note .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  margin-right: 7px;
  vertical-align: 1px;
  box-shadow: 0 0 0 3px var(--brand-wash);
}

/* --- the trade, drawn ---------------------------------------------------
   A trade is a state machine and the two people in it are anxious. These are
   the pieces that answer "where am I, what happened, what am I waiting on"
   without needing to be read word by word. */

/* What is being swapped for what. */
.swap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 14px;
  flex-wrap: wrap;
}
.swap .leg { display: flex; flex-direction: column; line-height: 1.15; }
.swap .legval { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.swap .arrow {
  font-size: 19px;
  color: var(--brand);
  background: var(--brand-wash);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}

/* How far through. */
.progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  border-radius: inherit;
  background: var(--brand-grad);
  transition: width .5s cubic-bezier(.22,.9,.3,1);
}

/* The rail. Filled behind you, lit where you are, hollow ahead. */
.steps { list-style: none; padding: 0; margin: 14px 0 0; }
.step {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 0 16px;
  color: var(--dim);
  font-size: 13.5px;
}
.step:last-child { padding-bottom: 0; }
/* The connector is drawn from each node down to the next. */
.step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 26px;
  bottom: 2px;
  width: 2px;
  border-radius: 2px;
  background: var(--line);
}
.step.completed:not(:last-child)::before { background: var(--brand); }

.step .node {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 2px solid var(--line);
  font-size: 11.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}
.step .label { line-height: 1.35; }

.step.completed { color: var(--text); }
.step.completed .node {
  background: var(--brand-grad);
  border-color: transparent;
  color: var(--brand-ink);
  font-size: 13px;
}

.step.active { color: var(--text); font-weight: 700; }
.step.active .node {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--surface);
}
/* A slow halo on the step you are actually on — the one place on the screen
   that should draw the eye. */
.step.active .node::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  animation: halo 1.9s ease-out infinite;
}
@keyframes halo {
  0% { opacity: .65; transform: scale(.82); }
  70%, 100% { opacity: 0; transform: scale(1.25); }
}

/* --- escrow + countdown, as one statement ---
   "Your money is held, and here is how long you have." */
.escrow {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.escrow.locked {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  background: linear-gradient(120deg, var(--ok-wash), transparent 60%), var(--surface);
}
.escrow .lock {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.escrow.locked .lock { background: var(--ok-wash); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.escrow .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.escrow.locked .what .strong { color: var(--ok); }

.pill.timer {
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 12px;
  font-variant-numeric: tabular-nums;
}
/* Running out of time should feel like it. */
.pill.timer.bad { animation: throb 1.1s ease-in-out infinite; }
@keyframes throb { 50% { opacity: .55; } }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--dim);
  font-size: 13.5px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
}
.notice.warn { color: var(--warn); background: var(--warn-wash); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice .ico {
  flex: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--brand-wash);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.notice.warn .ico { background: var(--warn-wash); color: var(--warn); }

.stars { font-size: 32px; letter-spacing: 6px; line-height: 1.2; }
.star { cursor: pointer; color: var(--surface-3); transition: color .12s, transform .12s; }
.star:hover { transform: scale(1.1); }
.star.on { color: var(--warn); }

/* --- empty states --------------------------------------------------------
   "No trades yet" as bare grey text reads like something failed to load. */
.empty {
  text-align: center;
  padding: 38px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--bg-2);
}
.empty .ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.empty .title { font-weight: 700; letter-spacing: -0.01em; margin-bottom: 3px; }
.empty .hint { color: var(--dim); font-size: 13px; }

/* --- loading -------------------------------------------------------------
   Skeletons rather than the word "Loading…", so the shape of the screen is
   already there when the data lands. */
.sk { display: grid; gap: 10px; }
.sk-line, .sk-card {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s linear infinite;
}
.sk-line { height: 13px; }
.sk-line.short { width: 42%; }
.sk-line.mid { width: 68%; }
.sk-card { height: 92px; border-radius: var(--r); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------------------------------------------------------------- chat */

.chat {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}
.msg {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 12px;
  max-width: 82%;
  align-self: flex-start;
  font-size: 14px;
}
.msg.mine {
  background: var(--brand-wash);
  border-color: color-mix(in srgb, var(--brand) 25%, transparent);
  border-radius: 14px 14px 4px 14px;
  align-self: flex-end;
}
.msg .who { color: var(--brand); font-size: 11px; font-weight: 700; display: block; }

/* ---------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(430px, calc(100vw - 28px));
  pointer-events: none;
}
@media (max-width: 760px) {
  #toasts { bottom: calc(var(--bar) + 14px + env(safe-area-inset-bottom)); }
}
.toast {
  pointer-events: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-sm);
  padding: 12px 15px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .26s cubic-bezier(.22,.9,.3,1) both;
  transition: opacity .4s, transform .4s;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast.info { border-left-color: var(--brand-2); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* Links inside an error or a toast: the way out of whatever just blocked you. */
.toast a, .err a { color: var(--brand); font-weight: 700; white-space: nowrap; }

/*
 * A toast offering a way out waits to be used, so it needs room for the link
 * and a way to dismiss it. Plain toasts keep fading on their own.
 */
.toast.sticky {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 8px;
}
.toast.sticky > span { flex: 1; }
.toast-close {
  flex: none;
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.toast-close:hover { color: var(--text); background: var(--surface-3); }

/* ---------------------------------------------------------------- scrollbar */

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-pill); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- light mode */

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;

    --bg: #f4f7fa;
    --bg-2: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f6f9fc;
    --surface-3: #dde5ee;
    --line: #e2e9f1;
    --line-soft: #edf1f6;

    --text: #0c1520;
    --dim: #5b6b7d;
    --faint: #8496a8;

    --brand: #00a272;
    --brand-2: #0a8fd0;
    --brand-ink: #ffffff;
    --brand-grad: linear-gradient(120deg, #00a272 0%, #0a8fd0 100%);
    --brand-wash: #00a27214;
    --brand-ring: #00a27240;

    --ok: #0a9f63;
    --ok-wash: #0a9f6314;
    --warn: #b7791f;
    --warn-wash: #b7791f14;
    --bad: #d64545;
    --bad-wash: #d6454514;

    --shadow: 0 1px 2px #0f172a0d, 0 8px 20px -12px #0f172a26;
    --shadow-lg: 0 2px 4px #0f172a0f, 0 22px 44px -20px #0f172a33;
  }
  :root:not([data-theme="dark"]) body::before {
    background:
      radial-gradient(70ch 50ch at 12% -10%, #00a27214, transparent 60%),
      radial-gradient(60ch 40ch at 100% 0%, #0a8fd010, transparent 55%);
  }
  :root:not([data-theme="dark"]) .avatar { box-shadow: inset 0 0 0 1px #00000014; }
  :root:not([data-theme="dark"]) .slider::before { box-shadow: 0 1px 3px #0f172a33; }
}

/* ------------------------------------------------------- expiry warning */
/*
 * Shown the instant the payment countdown reaches zero, by the client — it does
 * not wait for the server to notice. Paying into a closed window is the one
 * mistake on the trade screen that costs real money, so this is the loudest
 * thing on the page and it stays until the state actually changes.
 */
.expiry-warning {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 14px;
  padding: 13px 15px;
  border: 1px solid var(--bad);
  border-left: 4px solid var(--bad);
  border-radius: var(--r-sm);
  background: var(--bad-wash, #ff4d4d18);
  font-size: 14px;
}
.expiry-warning strong { color: var(--bad); }

/* A control that is no longer safe to use: marked, never silently removed. */
.btn.stale {
  opacity: .55;
  filter: grayscale(.6);
}
.btn.stale:hover { opacity: .75; }

/* The "what you attached" line under a file input. Red when it is too big —
   said at the moment of choosing, not held back until submit. */
[data-filenote] { margin-top: 5px; word-break: break-word; }
[data-filenote].bad { color: var(--bad); font-weight: 600; }

/* A rating already given: shown, not editable. */
.stars.given { opacity: .9; cursor: default; }

/* An irreversible step asks inside its own form, never in a blocking dialog. */
.confirm-strip {
  flex-basis: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  border-radius: var(--r-sm);
  background: var(--warn-wash);
}
.confirm-strip p { margin: 0 0 10px; font-size: 14px; }
.confirm-strip .row { gap: 8px; }

/* A card for something wrong enough to need acting on — money that cannot be
   sent, for instance. `.card.warn` exists; this is its louder sibling. */
.card.bad {
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  background: linear-gradient(var(--bad-wash), var(--bad-wash)), var(--surface);
}

/* "or" divider above an alternative sign-in route. */
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0 12px; color: var(--faint); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* The KingsChat button reads as an alternative, not a second primary action. */
.btn.kc { display: block; text-align: center; text-decoration: none; }
