/* Asseto: the exchange itself. Tokens and fonts come from base.css. */

:root {
  --line: hsl(var(--foreground) / 0.10);
  --line-soft: hsl(var(--foreground) / 0.06);
  --panel: hsl(150 18% 7% / 0.72);
  --panel-solid: hsl(150 18% 7%);
  --muted: hsl(var(--foreground) / 0.55);
  --faint: hsl(var(--foreground) / 0.34);
  --radius: 10px;
}

body.app {
  background:
    radial-gradient(120% 80% at 82% -10%, hsl(45 40% 30% / 0.16), transparent 60%),
    hsl(var(--background));
  min-height: 100vh;
}

.mono { font-family: var(--ui-mono); font-variant-numeric: tabular-nums; }
.pos { color: hsl(var(--up)); }
.neg { color: hsl(var(--down)); }
.dim { color: var(--muted); }

/* ---------------- shell ---------------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: hsl(150 20% 5% / 0.86);
  backdrop-filter: blur(14px);
}

.appbar-brand { display: flex; align-items: center; gap: 0.6rem; font-size: 1.25rem; letter-spacing: 0.08em; }
.appbar-brand img { width: 32px; height: 32px; }

.appbar-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  color: var(--muted); transition: color 0.15s ease, background 0.15s ease;
}
.appbar-x:hover { color: hsl(var(--foreground)); background: hsl(var(--foreground) / 0.08); }

.tabs { display: flex; gap: 0.25rem; margin-right: auto; }
.tabs a {
  padding: 0.4rem 0.85rem;
  border-radius: 99px;
  font-size: 1rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  transition: color 0.15s ease, background 0.15s ease;
}
.tabs a:hover { color: hsl(var(--foreground)); }
.tabs a.on { color: hsl(var(--accent-foreground)); background: hsl(var(--accent)); }

.wallet { display: flex; align-items: baseline; gap: 1.25rem; font-family: var(--ui-mono); font-size: 0.8125rem; }
.wallet b { font-weight: 500; font-size: 0.9375rem; }
.wallet span { display: block; color: var(--faint); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; }

/* wallet */
.account { display: flex; align-items: center; gap: 0.6rem; }
.btn-connect {
  font-family: var(--ui-sans); font-size: 0.8125rem; font-weight: 600;
  padding: 0.5rem 0.9rem; border-radius: 99px; border: 0; cursor: pointer;
  background: hsl(var(--accent)); color: hsl(var(--accent-foreground));
}
.btn-connect:hover { background: hsl(45 74% 80%); }
.chip {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.35rem 0.4rem 0.35rem 0.75rem;
  border: 1px solid var(--line); border-radius: 99px;
  font-family: var(--ui-mono); font-size: 0.8125rem;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--up)); }
.chip .sol { color: var(--faint); font-size: 0.75rem; }
.chip button {
  border: 0; background: transparent; color: var(--faint); cursor: pointer;
  font-family: var(--ui-sans); font-size: 0.6875rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.2rem 0.45rem; border-radius: 99px;
}
.chip button:hover { color: hsl(var(--foreground)); background: hsl(var(--foreground) / 0.08); }

.wallet-option {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: 100%; padding: 0.85rem 1rem; margin-bottom: 0.5rem;
  border: 1px solid var(--line); border-radius: 8px; background: transparent;
  color: hsl(var(--foreground)); font-family: var(--ui-sans); font-size: 0.9375rem; cursor: pointer;
}
.wallet-option:hover { border-color: hsl(var(--accent) / 0.6); }
.wallet-option span { color: var(--faint); font-size: 0.75rem; }
.wallet-option .wo-name { display: flex; align-items: center; gap: 0.6rem; color: hsl(var(--foreground)); font-size: 0.9375rem; }
.wallet-option img { border-radius: 5px; }

.gate {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem;
  padding: 1.25rem; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: 0.9375rem;
}

main { padding: 1.5rem; max-width: 1440px; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.head h1 { font-size: 2rem; line-height: 1.1; }
.head p { color: var(--muted); font-size: 0.9375rem; max-width: 60ch; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint);
  font-family: var(--ui-sans);
}

/* ---------------- tables ---------------- */

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 0.6rem 1rem;
  font-family: var(--ui-sans);
  font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint); text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
tbody td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--line-soft); font-size: 0.9375rem; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: hsl(var(--foreground) / 0.035); }
.num { text-align: right; font-family: var(--ui-mono); font-variant-numeric: tabular-nums; font-size: 0.875rem; }
th.num { text-align: right; }

.sym { display: flex; flex-direction: column; gap: 0.15rem; }
.sym b { font-family: var(--ui-mono); font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.02em; }
.sym small { color: var(--muted); font-size: 0.8125rem; }

.tag {
  display: inline-block; margin-left: 0.5rem; padding: 0.05rem 0.4rem;
  border-radius: 4px; font-family: var(--ui-sans); font-size: 0.625rem; letter-spacing: 0.08em;
  text-transform: uppercase; vertical-align: middle;
}
.tag.hostile { background: hsl(var(--down) / 0.16); color: hsl(var(--down)); }
.tag.mine { background: hsl(var(--accent) / 0.18); color: hsl(var(--accent)); }
.tag.flat { background: hsl(var(--foreground) / 0.1); color: var(--muted); }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--faint); font-size: 0.9375rem; }

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

.btn {
  font-family: var(--ui-sans); font-size: 0.8125rem; font-weight: 500;
  padding: 0.55rem 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; color: hsl(var(--foreground));
  cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.btn:hover { border-color: hsl(var(--foreground) / 0.28); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: hsl(var(--accent)); border-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn.primary:hover { background: hsl(45 74% 80%); }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

label.field { display: block; margin-bottom: 0.9rem; }
label.field > span {
  display: block; margin-bottom: 0.35rem;
  font-family: var(--ui-sans); font-size: 0.6875rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--faint);
}
input[type="text"], input[type="number"], select, textarea {
  width: 100%; padding: 0.6rem 0.7rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: hsl(150 20% 4% / 0.6); color: hsl(var(--foreground));
  font-family: var(--ui-mono); font-size: 0.9375rem;
}
textarea { font-family: var(--ui-sans); font-size: 0.875rem; resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: hsl(var(--accent) / 0.6); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, hsl(var(--foreground) / 0.5) 50%), linear-gradient(135deg, hsl(var(--foreground) / 0.5) 50%, transparent 50%); background-position: right 1rem center, right 0.72rem center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type="range"] { width: 100%; accent-color: hsl(var(--accent)); }

.checks { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.checks label {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.65rem; border: 1px solid var(--line); border-radius: 99px;
  font-family: var(--ui-sans); font-size: 0.75rem; color: var(--muted); cursor: pointer;
}
.checks label:has(input:checked) { border-color: hsl(var(--accent) / 0.7); color: hsl(var(--accent)); background: hsl(var(--accent) / 0.08); }
.checks input { accent-color: hsl(var(--accent)); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1; padding: 0.5rem 0; border: 0; background: transparent; cursor: pointer;
  font-family: var(--ui-sans); font-size: 0.8125rem; color: var(--muted);
}
.seg button.on { color: hsl(var(--accent-foreground)); }
.seg button.on.long { background: hsl(var(--up)); }
.seg button.on.short { background: hsl(var(--down)); }

/* ---------------- trade view ---------------- */

.trade { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.trade-main { min-width: 0; }

td.act { text-align: right; white-space: nowrap; }
td.act .btn { margin-left: 0.35rem; }
.go-long:hover { border-color: hsl(var(--up)); color: hsl(var(--up)); }
.go-short:hover { border-color: hsl(var(--down)); color: hsl(var(--down)); }
tbody tr.click:focus-visible { outline: 2px solid hsl(var(--accent)); outline-offset: -2px; }
.asset {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1.75rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft);
}
.asset .who { margin-right: auto; }
.asset .who b { display: block; font-family: var(--ui-mono); font-size: 0.9375rem; letter-spacing: 0.03em; }
.asset .who span { color: var(--muted); font-size: 1.0625rem; }
.stat span { display: block; font-family: var(--ui-sans); font-size: 0.625rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 0.15rem; }
.stat b { font-family: var(--ui-mono); font-size: 1rem; font-weight: 500; }
.story { flex-basis: 100%; color: var(--faint); font-size: 0.875rem; }

.chart-wrap { position: relative; height: 420px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.tfbar { display: flex; gap: 0.25rem; padding: 0.5rem 0.75rem; border-top: 1px solid var(--line-soft); }
.tfbar button {
  padding: 0.25rem 0.6rem; border: 0; border-radius: 6px; background: transparent;
  color: var(--faint); font-family: var(--ui-mono); font-size: 0.75rem; cursor: pointer;
}
.tfbar button.on { background: hsl(var(--foreground) / 0.1); color: hsl(var(--foreground)); }

.ticket { padding: 1rem; }
.ticket .lev-row { display: flex; justify-content: space-between; font-family: var(--ui-mono); font-size: 0.8125rem; color: var(--muted); }
.quick { display: flex; gap: 0.35rem; margin: -0.4rem 0 0.9rem; }
.quick button { flex: 1; padding: 0.25rem 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--faint); font-family: var(--ui-mono); font-size: 0.6875rem; cursor: pointer; }
.quick button:hover { color: hsl(var(--foreground)); }

.readout { margin: 1rem 0; border-top: 1px solid var(--line-soft); }
.readout div { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--line-soft); font-size: 0.8125rem; }
.readout dt, .readout span:first-child { color: var(--faint); font-family: var(--ui-sans); }
.readout b { font-family: var(--ui-mono); font-weight: 500; }

.submit { width: 100%; padding: 0.8rem; border: 0; border-radius: 8px; cursor: pointer; font-family: var(--ui-sans); font-size: 0.9375rem; font-weight: 600; color: hsl(var(--accent-foreground)); }
.submit.long { background: hsl(var(--up)); }
.submit.short { background: hsl(var(--down)); }
.submit.connect { background: hsl(var(--accent)); }
.submit:disabled { opacity: 0.5; cursor: not-allowed; }

.tape { max-height: 240px; overflow-y: auto; }
.tape .row { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.35rem 1rem; font-family: var(--ui-mono); font-size: 0.75rem; border-bottom: 1px solid var(--line-soft); }
.tape .row span:first-child { color: var(--muted); font-family: var(--ui-sans); }

/* ---------------- desk ---------------- */

.desk { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.desk-form { padding: 1.25rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.proc { padding: 1.5rem; font-family: var(--ui-mono); font-size: 0.8125rem; color: var(--muted); }
.proc div { padding: 0.25rem 0; opacity: 0; animation: fade 0.3s ease forwards; }
.proc div.ok::before { content: '+ '; color: hsl(var(--up)); }
.proc div:not(.ok)::before { content: '· '; }
@keyframes fade { to { opacity: 1; } }

/* The certificate is a document, so it is printed on paper, not on the app. */
.cert {
  background: #f4efe4;
  color: #221d16;
  padding: 2rem;
  border-radius: 4px;
  box-shadow: 0 24px 60px hsl(0 0% 0% / 0.5);
  font-family: 'Instrument Serif', serif;
}
.cert.hostile { background: #f3e7e3; }
.cert-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid #221d1633; padding-bottom: 0.75rem; margin-bottom: 1.25rem; }
.cert-head .wm { font-size: 1.25rem; letter-spacing: 0.12em; }
.cert-head .serial { font-family: var(--ui-mono); font-size: 0.6875rem; text-align: right; color: #221d16aa; }
.cert h2 { font-size: 1.75rem; line-height: 1.1; }
.cert .sub { font-family: var(--ui-sans); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: #221d1699; margin-bottom: 1.25rem; }
.cert dl { display: grid; grid-template-columns: 8rem 1fr; gap: 0.35rem 1rem; margin: 0 0 1.25rem; font-size: 1rem; }
.cert dt { font-family: var(--ui-sans); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: #221d1699; padding-top: 0.2rem; }
.cert dd { margin: 0; }
.cert .mark { font-family: var(--ui-mono); font-size: 2rem; letter-spacing: -0.02em; }
.cert .band { font-family: var(--ui-mono); font-size: 0.8125rem; color: #221d16aa; margin-bottom: 1.25rem; }
.cert .layers { border-top: 1px solid #221d1622; margin-bottom: 1rem; }
.cert .layers div { display: grid; grid-template-columns: 6rem 4rem 1fr; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid #221d1614; font-size: 0.8125rem; }
.cert .layers .k { font-family: var(--ui-sans); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: #221d1699; padding-top: 0.15rem; }
.cert .layers .f { font-family: var(--ui-mono); font-size: 0.75rem; }
.cert .notes p { font-size: 0.9375rem; margin-bottom: 0.4rem; }
.cert-foot { display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid #221d1633; margin-top: 1.25rem; padding-top: 0.75rem; }
.cert-foot .sig { font-size: 1.0625rem; }
.cert-foot .sig small { display: block; font-family: var(--ui-sans); font-size: 0.6875rem; color: #221d1699; }
.cert-foot .stamp {
  font-family: var(--ui-sans); font-size: 0.6875rem; letter-spacing: 0.12em;
  border: 1px solid #221d1655; border-radius: 4px; padding: 0.3rem 0.6rem; color: #221d16bb;
  transform: rotate(-3deg);
}
.cert-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ---------------- portfolio ---------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.card { padding: 1rem 1.25rem; }
.card span { display: block; font-family: var(--ui-sans); font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 0.35rem; }
.card b { font-family: var(--ui-mono); font-size: 1.5rem; font-weight: 400; }

/* ---------------- toasts and notices ---------------- */

.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 8px;
  background: hsl(150 18% 8% / 0.95); backdrop-filter: blur(8px);
  font-size: 0.875rem; box-shadow: 0 12px 30px hsl(0 0% 0% / 0.45);
  animation: rise 0.25s ease;
}
.toast.bad { border-color: hsl(var(--down) / 0.5); }
.toast.good { border-color: hsl(var(--up) / 0.4); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-solid); color: hsl(var(--foreground));
  padding: 0; max-width: min(560px, calc(100vw - 2rem));
}
dialog::backdrop { background: hsl(150 20% 3% / 0.72); backdrop-filter: blur(3px); }
.modal { padding: 1.5rem; }
.modal h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.modal p { color: var(--muted); font-size: 0.9375rem; margin-bottom: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .toast, .proc div { animation: none; opacity: 1; }
  html { scroll-behavior: auto; }
}

@media (max-width: 1100px) {
  .trade { grid-template-columns: 1fr; }
  /* On a narrow screen the order form comes first. Nobody should have to
     scroll past a chart to find the buttons that place the trade. */
  .trade-side { order: -1; }
  .desk { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .appbar { flex-wrap: wrap; gap: 0.75rem 1rem; padding: 0.75rem 1rem; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .wallet { gap: 1rem; }
  .account { order: 2; }
  .chip .sol { display: none; }
  main { padding: 1rem; }
  .chart-wrap { height: 320px; }
  .cert { padding: 1.25rem; }
  .cert dl { grid-template-columns: 6rem 1fr; }
}

/* ---------------- the live desk ---------------- */

.live { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.live-main { min-width: 0; }

.chain-badge {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.8rem; border: 1px solid hsl(var(--up) / 0.35); border-radius: 99px;
  font-family: var(--ui-mono); font-size: 0.75rem; color: hsl(var(--up));
}
.chain-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--up)); }

#addresses { font-family: var(--ui-mono); font-size: 0.6875rem; line-height: 1.8; word-break: break-all; }
#addresses a { border-bottom: 1px solid hsl(var(--foreground) / 0.2); }
#addresses a:hover { color: hsl(var(--accent)); }

@media (max-width: 1100px) {
  .live { grid-template-columns: 1fr; }
  .live-side { order: -1; }
}

/* Nobody should mistake the sandbox for the exchange. */
.paper-note {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: hsl(45 60% 60% / 0.07);
  font-size: 0.875rem;
  color: var(--muted);
}
.paper-note a { color: hsl(var(--accent)); border-bottom: 1px solid hsl(var(--accent) / 0.4); }
.tabs a.live-link { color: hsl(var(--up)); }
.tabs a.live-link::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: hsl(var(--up));
  vertical-align: middle;
}
