/* Muddy Bot website. Phone first; light and dark follow the device unless Night mode is picked. */
:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --ink: #141815;
  --ink-2: #565e58;
  --ink-3: #7a827c;
  --line: #e0e3de;
  --accent: #0d7a54;
  --accent-ink: #ffffff;
  --accent-soft: #e1f1e8;
  --gain: #0d7a54;
  --loss: #c0392b;
  --loss-soft: #fbe8e5;
  --warn: #8a5a00;
  --warn-soft: #fff2d8;
  --shadow: 0 1px 2px rgb(20 24 21 / 0.06), 0 1px 1px rgb(20 24 21 / 0.04);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d100e;
    --surface: #161a17;
    --surface-2: #20251f;
    --ink: #ecefec;
    --ink-2: #a5ada7;
    --ink-3: #7c857f;
    --line: #283029;
    --accent: #36c28b;
    --accent-ink: #05140c;
    --accent-soft: #15291f;
    --gain: #46d095;
    --loss: #ff7466;
    --loss-soft: #2e1714;
    --warn: #f2b552;
    --warn-soft: #2a2213;
    --shadow: none;
  }
}

/* Night mode picked with the moon button (theme.js / app.js), whatever the phone is set to. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d100e;
  --surface: #161a17;
  --surface-2: #20251f;
  --ink: #ecefec;
  --ink-2: #a5ada7;
  --ink-3: #7c857f;
  --line: #283029;
  --accent: #36c28b;
  --accent-ink: #05140c;
  --accent-soft: #15291f;
  --gain: #46d095;
  --loss: #ff7466;
  --loss-soft: #2e1714;
  --warn: #f2b552;
  --warn-soft: #2a2213;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap { max-width: 560px; margin: 0 auto; padding: 8px 16px 64px; }
.boot { color: var(--ink-3); text-align: center; padding-top: 30vh; }

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }

/* -- top bar ------------------------------------------------------------ */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.who { color: var(--ink-2); font-size: 14px; text-align: right; }
.top-end { display: flex; align-items: center; gap: 6px; }
.corner { display: flex; justify-content: flex-end; padding: 10px 0 0; }
.btn.theme-btn { width: 40px; min-height: 40px; padding: 0; display: inline-grid; place-items: center; border-radius: 10px; }
.btn.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* -- cards -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.card > h2, .label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 10px;
}
.label { margin: 18px 0 6px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.nb { white-space: nowrap; }

/* -- account status ------------------------------------------------------- */
.acct-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.acct-name { font-size: 14px; color: var(--ink-2); margin: 0 0 4px; font-weight: 600; }
.state { font-size: 24px; font-weight: 750; display: flex; align-items: center; gap: 10px; margin: 0; }
.state-sub { color: var(--ink-2); font-size: 14px; margin: 4px 0 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.on { background: var(--gain); box-shadow: 0 0 0 4px var(--accent-soft); }
.dot.warn { background: var(--warn); }
.value { text-align: right; flex: none; }
.value b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.value span { font-size: 12px; color: var(--ink-3); }

/* -- buttons -------------------------------------------------------------- */
.btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:focus-visible, input:focus-visible, .seg button:focus-visible, .tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--loss-soft); border-color: transparent; color: var(--loss); }
.btn-danger-solid { background: var(--loss); border-color: var(--loss); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btns.end { justify-content: flex-end; }

/* -- trades --------------------------------------------------------------- */
.pos { padding: 14px 0; border-top: 1px solid var(--line); }
.pos:first-child { border-top: 0; padding-top: 4px; }
.pos-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.contract { font-size: 17px; font-weight: 700; }
.pnl { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pnl small { display: block; font-size: 13px; font-weight: 600; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.sub { color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.empty { color: var(--ink-3); font-size: 15px; margin: 4px 0; }
.order { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.order:first-child { border-top: 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stat span { display: block; font-size: 12px; color: var(--ink-3); }
.stat b { font-size: 16px; }
details.alert { margin-top: 6px; font-size: 14px; }
details.alert > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.alert > p {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.history { margin-top: 10px; }
.trade { padding: 12px 0; border-top: 1px solid var(--line); }
.trade:first-of-type { border-top: 0; }

/* -- notices -------------------------------------------------------------- */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--warn-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 15px;
}
.notice.info { background: var(--accent-soft); }
.notice .btn { flex: none; }

/* -- forms ---------------------------------------------------------------- */
input[type="text"], input[type="tel"], input[type="number"], input[type="password"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;            /* 16px+ keeps iPhone from zooming in */
}
.field { margin-top: 14px; }
.field > label > input { margin-top: 6px; font-weight: 400; }
details.field > summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 650; }
details.field[open] > summary { margin-bottom: 4px; }
.steps.small { font-size: 14px; color: var(--ink-2); }
.field:first-of-type { margin-top: 0; }
.field > label, .field-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--ink-3); font-size: 13px; margin: 6px 0 0; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.affix { position: relative; flex: 1; min-width: 0; }
.affix input { padding-left: 28px; }
.affix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.affix.suffix input { padding-left: 12px; padding-right: 32px; }
.affix.suffix span { left: auto; right: 12px; }
.field-sub { display: block; color: var(--ink-2); font-size: 14px; margin: 2px 0 8px; }
.current { font-weight: 650; }

.seg, .tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 3px;
  margin-bottom: 8px;
  border-radius: 11px;
  background: var(--surface-2);
}
.tabs { grid-template-columns: repeat(2, 1fr); margin: 8px 0 4px; }
.seg button, .tabs button {
  min-height: 38px;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.seg button[aria-pressed="true"], .tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

/* -- lists ---------------------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rules { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.rules li { margin: 4px 0; }

.person { padding: 12px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; padding-top: 0; }
.person-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.person-name { font-weight: 700; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 650; white-space: nowrap; }
.chip.on { background: var(--accent-soft); color: var(--gain); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

.linkbox {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font: 13px/1.4 var(--mono);
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}

/* -- sign-in steps --------------------------------------------------------- */
.page-title { font-size: 26px; margin: 18px 0 6px; }
.bigsteps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.bigsteps > li { counter-increment: step; position: relative; padding-left: 40px; margin: 0 0 22px; }
.bigsteps > li:last-child { margin-bottom: 4px; }
.bigsteps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--gain);
  font-size: 14px;
  font-weight: 750;
}
.bigsteps h3 { font-size: 16px; margin: 3px 0 4px; }
.bigsteps p { margin: 0 0 10px; }
textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.35 var(--mono);
  resize: vertical;
  word-break: break-all;
}
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -- signed out ----------------------------------------------------------- */
.hero { text-align: center; padding: 10vh 4px 8px; }
.hero img { width: 76px; height: 76px; border-radius: 20px; }
.hero h1 { font-size: 30px; margin: 18px 0 8px; }
.hero p { color: var(--ink-2); margin: 0 auto; max-width: 34ch; }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.fine { color: var(--ink-3); font-size: 13px; text-align: center; margin: 12px 0 0; }

.foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin-top: 24px; }

/* -- toasts and confirm ------------------------------------------------------- */
#toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  max-width: 528px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.22);
  pointer-events: auto;
  animation: rise 0.18s ease-out;
}
.toast.bad { background: var(--loss); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

dialog {
  width: calc(100% - 32px);
  max-width: 420px;
  padding: 20px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h3 { margin: 0 0 8px; font-size: 19px; }
dialog p { margin: 0; color: var(--ink-2); }

/* -- the page Robinhood's sign-in returns to -------------------------------- */
body.plain { padding: 48px 16px; }
.card.narrow { max-width: 520px; margin: 0 auto; }
.plain h1 { font-size: 20px; margin: 0 0 12px; }

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