/* Arbbot: one stylesheet for every page.
   Light and dark themes, left-to-right and right-to-left. Spacing and borders
   use logical properties (inline/block, start/end) so Arabic mirrors itself. */

:root {
  color-scheme: light;
  --canvas: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --border: #e7e5e1;
  --border-strong: #d2cfc9;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #6f6a64;
  --accent: #0f766e;
  --accent-hover: #0c5f59;
  --accent-soft: #e3f3f1;
  --on-accent: #ffffff;
  --gain: #15803d;
  --loss: #b42318;
  --danger: #b42318;
  --danger-hover: #912018;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --warn: #a15c07;
  --warn-soft: #fffaeb;
  --warn-border: #fedf89;
  --backdrop: rgb(28 25 23 / 0.45);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 12px 32px rgb(0 0 0 / 0.1);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --font-ar: system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", "Geeza Pro", Tahoma, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #171717;
    --surface: #1f1f1f;
    --surface-2: #272727;
    --border: #303030;
    --border-strong: #454545;
    --text: #f5f5f4;
    --text-2: #c7c5c1;
    --text-3: #a3a19c;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: #13302d;
    --on-accent: #04302b;
    --gain: #4ade80;
    --loss: #f97066;
    --danger: #f97066;
    --danger-hover: #fda29b;
    --danger-soft: #2a1614;
    --danger-border: #5c2622;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --warn-border: #5c4813;
    --backdrop: rgb(0 0 0 / 0.6);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px rgb(0 0 0 / 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #171717;
  --surface: #1f1f1f;
  --surface-2: #272727;
  --border: #303030;
  --border-strong: #454545;
  --text: #f5f5f4;
  --text-2: #c7c5c1;
  --text-3: #a3a19c;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #13302d;
  --on-accent: #04302b;
  --gain: #4ade80;
  --loss: #f97066;
  --danger: #f97066;
  --danger-hover: #fda29b;
  --danger-soft: #2a1614;
  --danger-border: #5c2622;
  --warn: #fbbf24;
  --warn-soft: #2a2110;
  --warn-border: #5c4813;
  --backdrop: rgb(0 0 0 / 0.6);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px rgb(0 0 0 / 0.5);
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Arabic letters read smaller than Latin ones at the same size. */
html:lang(ar) {
  font-size: 106.25%;
}

/* Hidden for an instant while Arabic replaces the English written in the page. */
html.i18n-pending body {
  visibility: hidden;
}

body {
  margin: 0;
  min-block-size: 100vh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

:lang(ar) body {
  font-family: var(--font-ar);
  line-height: 1.8;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p,
ol,
ul,
table,
fieldset {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.35;
}

:lang(ar) h1,
:lang(ar) h2 {
  letter-spacing: 0;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-hover);
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.9375em;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: var(--surface-2);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 0.875rem;
}

.gain {
  color: var(--gain);
}

.loss {
  color: var(--loss);
}

.good {
  color: var(--gain);
}

.attention {
  color: var(--danger);
}

.skip-link {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  z-index: 30;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem 1.25rem;
  max-inline-size: 76rem;
  margin-inline: auto;
  padding: 0.625rem 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 650;
  font-size: 1.0625rem;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  inline-size: 1.75rem;
  block-size: 1.75rem;
  flex: none;
}

.brand-mark .mark-bg {
  fill: var(--accent);
}

.brand-mark .mark-line {
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark .mark-dot {
  fill: var(--on-accent);
}

.nav {
  display: flex;
  gap: 0.25rem;
}

.nav a {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-inline-start: auto;
}

.chip-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-block-size: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.icon-button {
  inline-size: 2.25rem;
  padding: 0;
}

.chip-button:hover,
.icon-button:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.icon {
  inline-size: 1.125rem;
  block-size: 1.125rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The theme button shows where it will take you: a moon in light, a sun in dark. */
.icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .icon-moon {
    display: none;
  }
}

/* An arrow that points "out": mirrored when the page reads right to left. */
[dir="rtl"] .icon-flip {
  transform: scaleX(-1);
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  min-block-size: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.mode-pill::before {
  content: "";
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--text-3);
}

.mode-pill:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.mode-pill.is-live {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.mode-pill.is-live::before {
  background: var(--danger);
}

/* ---------- page ---------- */

.page {
  max-inline-size: 76rem;
  margin-inline: auto;
  padding: 1.75rem 1.25rem 4rem;
}

.page-narrow {
  max-inline-size: 46rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-block-end: 1.25rem;
}

.lede {
  max-inline-size: 44rem;
  margin-block-start: 0.375rem;
  color: var(--text-2);
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.875rem;
  white-space: nowrap;
}

.pulse {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--text-3);
}

.live-chip.is-live .pulse {
  background: var(--gain);
  animation: pulse 2s ease-in-out infinite;
}

.live-chip.is-stale {
  border-color: var(--warn-border);
  background: var(--warn-soft);
  color: var(--warn);
}

.live-chip.is-stale .pulse {
  background: var(--warn);
}

.live-chip.is-down {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.live-chip.is-down .pulse {
  background: var(--danger);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ---------- summary strip ---------- */

/* Cells wrap and stretch, so a last row with fewer cells leaves no hole. */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-block: 1.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--border);
  overflow: hidden;
}

.stat {
  display: flex;
  flex: 1 1 12.5rem;
  flex-direction: column;
  gap: 0.125rem;
  min-inline-size: 0;
  padding: 1rem 1.125rem;
  background: var(--surface);
}

.stat-label {
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 500;
}

.stat-value {
  font-size: 1.375rem;
  font-weight: 650;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat-note {
  color: var(--text-2);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.stat .link-button {
  align-self: flex-start;
  margin-block-start: 0.25rem;
  font-size: 0.875rem;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-block: 1.5rem 1.25rem;
  border-block-end: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.625rem 0.875rem;
  margin-block-end: -1px;
  border: 0;
  border-block-end: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.tabs [role="tab"]:hover {
  color: var(--text);
}

.tabs [role="tab"][aria-selected="true"],
.tabs [role="tab"][aria-current="page"] {
  border-block-end-color: var(--accent);
  color: var(--accent);
}

.tabs [role="tab"]:focus-visible {
  outline-offset: -2px;
}

.count {
  min-inline-size: 1.375rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.375rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

[role="tabpanel"]:focus-visible {
  outline-offset: 6px;
  border-radius: var(--radius);
}

.block {
  margin-block-end: 2rem;
}

.block > h2 + .muted,
.block > .muted + .muted {
  margin-block-start: 0.25rem;
}

.block > .muted {
  max-inline-size: 52rem;
  font-size: 0.9375rem;
}

.block > .card,
.block > .empty,
.block > .loading {
  margin-block-start: 0.875rem;
}

.funds-line {
  margin-block-start: 0.375rem;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.funds-line.problem {
  color: var(--danger);
}

/* ---------- cards and tables ---------- */

.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow-x: auto;
}

.list {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.list caption {
  padding: 0.75rem 1rem 0;
  color: var(--text-2);
  font-weight: 600;
  text-align: start;
}

.list th,
.list td {
  padding: 0.75rem 1rem;
  text-align: start;
  vertical-align: top;
}

.list thead th {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.list tbody tr + tr td {
  border-block-start: 1px solid var(--border);
}

.list tbody tr:hover td {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.list .num {
  text-align: end;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.list td.lead {
  font-weight: 600;
}

.list td.needs {
  min-inline-size: 15rem;
  max-inline-size: 30rem;
  color: var(--text-2);
}

.list td.action {
  text-align: end;
  white-space: nowrap;
}

.list.compact th,
.list.compact td {
  padding-inline: 0.75rem;
}

/* A route (USDT → BTC → ETH → USDT) always reads left to right. */
.route {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  direction: ltr;
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 500;
}

.route .hop {
  padding: 0.0625rem 0.4375rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.route .arrow {
  color: var(--text-3);
}

.tag {
  display: inline-block;
  margin-inline-start: 0.5rem;
  padding: 0 0.4375rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  vertical-align: middle;
}

.status-tag {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-tag.is-good {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.status-tag.is-bad {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}

@media (max-width: 760px) {
  /* On a phone each row becomes its own card: a label beside every value. */
  .list thead {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .list,
  .list tbody,
  .list tr,
  .list td {
    display: block;
  }

  .list tbody tr {
    padding: 0.875rem 1rem;
  }

  .list tbody tr + tr {
    border-block-start: 1px solid var(--border);
  }

  .list tbody tr + tr td,
  .list td {
    border: 0;
  }

  .list tbody tr:hover td {
    background: none;
  }

  .list td,
  .list.compact td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.1875rem 0;
    text-align: start;
    white-space: normal;
  }

  .list td::before {
    content: attr(data-label);
    flex: none;
    color: var(--text-3);
    font-size: 0.8125rem;
    font-weight: 400;
  }

  .list td.lead {
    display: block;
    padding-block-end: 0.4375rem;
  }

  .list td.lead::before,
  .list td.action::before {
    content: none;
  }

  .list td.needs {
    display: block;
    min-inline-size: 0;
    max-inline-size: none;
    padding-block-start: 0.375rem;
  }

  .list td.needs::before {
    display: block;
  }

  .list td.action {
    display: block;
    padding-block-start: 0.625rem;
  }

  .list td.action .button {
    inline-size: 100%;
  }

  .list td.action:not(:has(.button:not([hidden]))),
  .list td.is-blank {
    display: none;
  }
}

/* ---------- empty, loading, messages ---------- */

.empty {
  padding: 1.5rem 1.25rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-2);
}

.empty h3 {
  margin-block-end: 0.25rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 650;
}

.empty .button {
  margin-block-start: 0.875rem;
}

.loading {
  display: grid;
  gap: 0.625rem;
  padding: 1.125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.skeleton {
  block-size: 0.875rem;
  border-radius: 6px;
  background: var(--surface-2);
  animation: pulse 1.6s ease-in-out infinite;
}

.skeleton-short {
  inline-size: 55%;
}

.skeleton-title {
  inline-size: 35%;
  block-size: 1.25rem;
}

.callout {
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
}

.callout h2 {
  margin-block-end: 0.25rem;
}

.callout-warn {
  border-color: var(--warn-border);
  border-inline-start-color: var(--warn);
  background: var(--warn-soft);
}

.callout-danger {
  border-color: var(--danger-border);
  border-inline-start-color: var(--danger);
  background: var(--danger-soft);
}

.page > .callout,
.block > .callout {
  margin-block: 0.875rem;
}

.toast {
  margin-block: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.75rem;
  padding: 0 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button.small {
  min-block-size: 2.25rem;
  padding: 0 0.875rem;
  font-size: 0.875rem;
}

.button.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button.primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.button.secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button.secondary:hover {
  background: var(--surface-2);
  color: var(--text);
}

.button.destructive {
  border-color: var(--danger-border);
  background: var(--surface);
  color: var(--danger);
}

.button.destructive:hover {
  background: var(--danger-soft);
}

.button.destructive-solid {
  background: var(--danger);
  color: var(--surface);
}

.button.destructive-solid:hover {
  background: var(--danger-hover);
}

.button:disabled,
.chip-button:disabled,
.icon-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent-hover);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-block-start: 1.25rem;
}

/* ---------- forms ---------- */

.field {
  margin-block-start: 1.125rem;
}

.field label {
  display: block;
  margin-block-end: 0.375rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  inline-size: 100%;
  min-block-size: 2.75rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* Keys, secrets and amounts are typed left to right in either language. */
input.mono,
input[type="password"],
input[type="number"] {
  direction: ltr;
  text-align: start;
}

[dir="rtl"] input.mono,
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="number"] {
  text-align: end;
}

input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

input:disabled {
  background: var(--surface-2);
  color: var(--text-2);
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.input-row input {
  flex: 1;
  min-inline-size: 0;
}

.help {
  margin-block-start: 0.375rem;
  color: var(--text-2);
  font-size: 0.875rem;
}

.field-error,
.form-error {
  margin-block-start: 0.375rem;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 500;
}

.form-error {
  margin-block-start: 1rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  background: var(--danger-soft);
}

.estimate {
  margin-block-start: 1rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.9375rem;
}

.estimate:empty {
  display: none;
}

/* ---------- dialogs ---------- */

dialog {
  inline-size: min(34rem, calc(100vw - 2rem));
  max-block-size: calc(100dvh - 2rem);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

dialog::backdrop {
  background: var(--backdrop);
}

dialog h2 {
  font-size: 1.25rem;
}

.dialog-route {
  margin-block-start: 0.625rem;
}

.steps {
  margin-block-start: 0.75rem;
  padding-inline-start: 1.375rem;
  color: var(--text-2);
}

.steps li + li {
  margin-block-start: 0.375rem;
}

.steps strong {
  color: var(--text);
  font-weight: 600;
}

/* A button's English name inside an Arabic sentence moves to the next line
   whole, rather than being cut in two with the halves swapped. */
.steps strong,
.steps a {
  display: inline-block;
  max-inline-size: 100%;
}

.choices {
  display: grid;
  gap: 0.625rem;
  margin-block-start: 1rem;
  padding: 0;
  border: 0;
}

.choice {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice input {
  flex: none;
  inline-size: 1.125rem;
  block-size: 1.125rem;
  margin: 0.25rem 0 0;
  accent-color: var(--accent);
}

.choice strong,
.choice .muted {
  display: block;
}

.choice .muted {
  font-size: 0.875rem;
}

#live-confirm {
  margin-block-start: 1rem;
}

dialog .callout,
dialog .help {
  margin-block-start: 1rem;
}

.result-message {
  margin-block-start: 0.5rem;
  color: var(--text-2);
}

/* ---------- facts (exchanges page, trade results) ---------- */

.facts {
  inline-size: 100%;
  margin-block-start: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  font-size: 0.9375rem;
  overflow: hidden;
}

.facts caption {
  padding-block-end: 0.5rem;
  color: var(--text);
  font-weight: 650;
  text-align: start;
}

.facts th,
.facts td {
  padding: 0.6875rem 1rem;
  text-align: start;
  vertical-align: top;
}

.facts th {
  color: var(--text-2);
  font-weight: 500;
}

.facts td {
  text-align: end;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.facts tr + tr th,
.facts tr + tr td {
  border-block-start: 1px solid var(--border);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.625rem;
}

.dot {
  inline-size: 0.625rem;
  block-size: 0.625rem;
  border-radius: 50%;
  background: var(--gain);
}

select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* A row of choices where one is on: which coin, which candle length. */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem 1.25rem;
  margin-block-end: 1.25rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip {
  min-block-size: 2.25rem;
  padding: 0 0.875rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover {
  background: var(--surface-2);
  color: var(--text);
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.list tr.benchmark td {
  background: var(--surface-2);
}

.dot.is-off {
  background: var(--text-3);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 1.25rem;
}

.confirm {
  margin-block-start: 1.25rem;
}

.confirm .actions {
  margin-block-start: 0;
}

.auto-recent {
  margin-block-start: 1.75rem;
}

.survey {
  margin-block-start: 2.5rem;
  padding-block-start: 1.75rem;
  border-block-start: 1px solid var(--border);
}

.survey > .muted + .muted {
  margin-block-start: 0.5rem;
}

/* Many narrow number columns: let the headings take two lines rather than the table scroll. */
.list.wrap-head thead th {
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.3;
}

.list.wrap-head th,
.list.wrap-head td {
  padding-inline: 0.625rem;
}

.subhead {
  margin-block: 1.5rem 0;
  font-size: 1rem;
  font-weight: 650;
}

.survey > .empty {
  margin-block-start: 0.875rem;
}

.advice {
  display: grid;
  gap: 0.5rem;
  margin-block-start: 1rem;
  padding: 0;
  list-style: none;
}

.advice li {
  padding: 0.75rem 1rem;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  background: var(--warn-soft);
  font-size: 0.9375rem;
}

.advice:empty {
  display: none;
}

.section {
  margin-block-start: 1.75rem;
}

.section > h2 {
  margin-block-end: 0.5rem;
}

.panel-card {
  margin-block-start: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.panel-card > h2:first-child,
.panel-card > .status-row:first-child {
  margin-block-start: 0;
}

.saved-key {
  margin-block-start: 1.25rem;
}

.saved-key .actions {
  margin-block-start: 0;
}

.confirm p {
  margin-block-end: 0.625rem;
  font-weight: 600;
}

/* ---------- sign-in page ---------- */

.auth {
  display: grid;
  place-items: center;
  min-block-size: calc(100vh - 3.75rem);
  padding: 1.5rem 1.25rem 4rem;
}

.auth-card {
  inline-size: min(26rem, 100%);
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.auth-card .lede {
  font-size: 0.9375rem;
}

.auth-card .button {
  inline-size: 100%;
}

.auth-card .callout {
  margin-block-start: 1rem;
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  /* Two rows on a phone: the mark and the controls, then the sections. It
     scrolls away with the page instead of covering a quarter of the screen. */
  .topbar {
    position: static;
  }

  .topbar-inner {
    flex-wrap: wrap;
    padding-inline: 1rem;
  }

  .brand-name {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .tabs {
    gap: 0;
  }

  .tabs [role="tab"] {
    padding-inline: 0.5rem;
    font-size: 0.875rem;
  }

  .nav {
    order: 3;
    flex: 1 0 100%;
  }

  .nav a {
    flex: 1;
    text-align: center;
  }

  .page {
    padding: 1.25rem 1rem 3rem;
  }

  .stat {
    flex-basis: 9.5rem;
    padding: 0.875rem 1rem;
  }

  .stat-value {
    font-size: 1.1875rem;
  }

  .signout-text {
    display: none;
  }

  #sign-out {
    inline-size: 2.25rem;
    padding: 0;
  }

  dialog {
    padding: 1.25rem;
  }

  .actions .button {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
