/* Rule Blocks app. Tokens match landing.css (the marketing site). */
:root {
  color-scheme: light;
  --bg: #FCFCFD;
  --paper: #FFFFFF;
  --ink: #111318;
  --ink-2: #4B505A;
  --ink-3: #7A7F88;
  --line: #E6E8EC;
  --line-2: #D5D9DF;
  --soft: #F3F4F6;
  --ws: #F7F8FA;
  --dots: #D9DDE3;
  --pink: #FF2E88;
  --price: #2F6BFF;  --price-edge: #1C4AC2;  --price-tint: #EEF3FF;
  --odds: #0C8F80;   --odds-edge: #066358;   --odds-tint: #E7F5F3;
  --time: #F2A516;   --time-edge: #8F5D00;   --time-tint: #FEF6E4;
  --long: #12A150;   --long-edge: #0A7438;   --long-tint: #E8F6EE;
  --short: #E5484D;  --short-edge: #B0303A;  --short-tint: #FDEDEE;
  --exit: #3F4B5B;   --exit-edge: #252F3C;
  --all: #111318;
  --any: #56657A;
  --yes: #12A150;
  --no: #A9AFB8;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Rethink Sans", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.32, .72, 0, 1);
  --shadow-card: 0 1px 2px rgba(17,19,24,.04), 0 8px 24px -12px rgba(17,19,24,.10);
  --shadow-lift: 0 1px 2px rgba(17,19,24,.04), 0 30px 80px -30px rgba(17,19,24,.18);
  --top-h: 64px;
  --app-h: calc(100vh - var(--top-h) - 36px);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237A7F88' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--ink); color: #fff; }
button, select, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--price); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; background: #fff; padding: 8px 12px; border-radius: 8px; z-index: 80; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.num { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px;
  min-height: var(--top-h); padding: 12px 20px;
  background: rgba(252,252,253,.86); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -0.01em; text-decoration: none; color: inherit; flex: none; margin-right: 6px; }
.brand-mark { width: 42px; height: 42px; margin: -8px -6px -8px -8px; display: block; transition: transform .2s var(--ease); }
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.04); }
.templates { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 0 14px; font-size: 13.5px; font-weight: 500; cursor: pointer; min-height: 36px; white-space: nowrap; color: var(--ink-2);
  transition: border-color .2s, background .2s, color .2s, box-shadow .2s, transform .15s var(--ease);
}
.chip-btn:hover { border-color: #C9CDD3; color: var(--ink); box-shadow: 0 4px 14px rgba(17,19,24,.07); }
.chip-btn:active { transform: scale(.97); }
.chip-btn[data-template][aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: none; }
.templates, .starters-row { position: relative; }
.templates .chip-btn, .starters-row .chip-btn { position: relative; z-index: 1; background: transparent; transition: border-color .2s, color .18s var(--ease), box-shadow .2s, transform .15s var(--ease); }
.templates .chip-btn[aria-pressed="true"], .starters-row .chip-btn[aria-pressed="true"] { background: transparent; border-color: transparent; }
.feed {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3);
  background: var(--soft); border-radius: 999px; padding: 6px 14px 6px 12px; white-space: nowrap; min-height: 32px;
}
.feed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--no); flex: none; transition: background-color .25s, box-shadow .25s; }
.feed.live::before { background: var(--yes); box-shadow: 0 0 0 4px rgba(18,161,80,.14); }
.feed.bad::before { background: var(--short); box-shadow: 0 0 0 4px rgba(229,72,77,.14); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px; color: var(--ink-2);
  transition: border-color .2s, color .2s, box-shadow .2s, transform .15s var(--ease);
}
.icon-btn:hover { border-color: #C9CDD3; color: var(--ink); box-shadow: 0 4px 14px rgba(17,19,24,.07); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .spk { fill: currentColor; stroke-width: 1.2; }
.icon-btn .wave { display: none; }
.icon-btn[aria-pressed="true"] { color: var(--ink); }
.icon-btn[aria-pressed="true"] .wave { display: inline; }
.icon-btn[aria-pressed="true"] .mute { display: none; }
.starters { display: none; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: 184px minmax(0, 1fr) 316px; gap: 16px;
  padding: 16px 20px 20px; align-items: start;
}
body.panel-off .layout { grid-template-columns: 184px minmax(0, 1fr); }
body.panel-off .side { display: none; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- palette ---------- */
.palette {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 12px 10px;
  height: var(--app-h); overflow: auto; scrollbar-width: thin;
}
.pal-scroll { display: flex; flex-direction: column; gap: 4px; }
.pal-h { font-size: 12px; font-weight: 500; color: var(--ink-3); margin: 14px 6px 4px; }
.pal-h:first-child { margin-top: 2px; }
.pal-help { font-size: 12px; color: var(--ink-3); margin: 16px 6px 2px; line-height: 1.5; }
.pb {
  --c: var(--price);
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 1px solid transparent; border-radius: 12px; padding: 7px 8px 7px 10px; min-height: 40px; cursor: grab;
  background: transparent; color: var(--ink); font-weight: 500; font-size: 14px; touch-action: pan-y;
  transition: background .15s, border-color .15s, box-shadow .2s, transform .15s var(--ease);
}
.pb::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; order: -1; }
.pb > span:not(.grip) { flex: 1; }
.pb .grip { order: 2; color: var(--ink-3); opacity: 0; transition: opacity .15s; }
.pb:hover { background: var(--paper); border-color: var(--line); box-shadow: 0 4px 14px rgba(17,19,24,.07); }
.pb:hover .grip { opacity: .7; }
.pb:active { transform: scale(.98); }
.pb.c-odds { --c: var(--odds); }
.pb.c-time { --c: var(--time); }
.pb.c-logic { --c: var(--all); }
.pb.c-any { --c: var(--any); }
.pb.c-exit { --c: var(--exit); }
.grip { display: inline-grid; grid-template-columns: repeat(2, 3px); gap: 3px; flex: none; padding: 2px; opacity: .75; }
.grip i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; display: block; }
.pal-ghost {
  position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; width: 176px;
  background: var(--paper) !important; border-color: var(--line) !important; box-shadow: 0 18px 40px -10px rgba(17,19,24,.3) !important;
}

/* ---------- workspace ---------- */
.ws {
  position: relative; overflow: hidden; height: var(--app-h); border-radius: 22px;
  background-color: var(--ws);
  background-image: radial-gradient(var(--dots) 1.1px, transparent 1.1px);
  background-size: 20px 20px;
  border: 1px solid var(--line);
  touch-action: none; cursor: grab;
}
.ws.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.wires { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.ws-empty {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); max-width: 440px; width: calc(100% - 32px); text-align: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; font-size: 14px; color: var(--ink-2);
  box-shadow: var(--shadow-card); display: none; pointer-events: none;
}
.ws.is-empty .ws-empty { display: block; }
.zoom {
  position: absolute; left: 14px; bottom: 14px; display: flex; align-items: center; gap: 2px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 4px; box-shadow: var(--shadow-card);
}
.zoom button { border: 0; background: transparent; min-width: 36px; height: 36px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 16px; color: var(--ink-2); transition: background .15s, color .15s; }
.zoom button:hover { background: var(--soft); color: var(--ink); }
#z-fit { font-size: 13px; padding: 0 12px; }
#z-val { font-family: var(--mono); font-size: 12px; min-width: 46px; text-align: center; color: var(--ink-3); }

/* wires */
.wire .hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.wire .ln { fill: none; stroke: var(--no); stroke-width: 2.4; stroke-dasharray: 1 7; stroke-linecap: round; marker-end: url(#a-off); pointer-events: none; transition: stroke .3s; }
.wire[data-st="on"] .ln { stroke: var(--yes); stroke-width: 2.8; stroke-dasharray: none; marker-end: url(#a-on); }
.wire[data-st="struct"] .ln { stroke: var(--exit); stroke-width: 2.2; stroke-dasharray: none; marker-end: url(#a-struct); }
.wire.sel .ln { stroke: var(--price); stroke-dasharray: none; marker-end: url(#a-sel); }
.wire.temp .ln { stroke: var(--price); stroke-dasharray: 6 6; marker-end: url(#a-sel); }
.wire-x {
  position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; z-index: 5;
  border: 1.5px solid var(--price); background: #fff; color: var(--price); cursor: pointer; display: grid; place-items: center; padding: 0;
  box-shadow: 0 4px 12px rgba(47,107,255,.25);
}
.wire-x svg { width: 11px; height: 11px; }

/* nodes */
.node {
  --c: var(--price); --w: 270px;
  position: absolute; width: var(--w); background: var(--paper); border-radius: 14px;
  border: 1px solid #E3E6EA;
  box-shadow: 0 1px 2px rgba(17,19,24,.04), 0 6px 18px rgba(17,19,24,.07);
  transition: border-color .25s, box-shadow .25s;
}
.node.k-odds { --c: var(--odds); --w: 300px; }
.node.k-time { --c: var(--time); }
.node.k-hold, .node.k-then { --c: var(--time); --w: 220px; }
.node.k-logic { --c: var(--all); --w: 168px; }
.node.k-logic.any { --c: var(--any); }
.node.k-trade { --c: var(--long); --w: 280px; }
.node.k-trade.short { --c: var(--short); }
.node.k-exit { --c: var(--exit); --w: 170px; }
.node.k-safe { --c: var(--exit); --w: 280px; }
.node.on { border-color: var(--yes); box-shadow: 0 0 0 1px var(--yes), 0 0 0 5px rgba(18,161,80,.12), 0 6px 18px rgba(17,19,24,.07); }
.node.sel { box-shadow: 0 0 0 2px var(--price), 0 0 0 6px rgba(47,107,255,.16), 0 10px 26px rgba(17,19,24,.12); }
.node.loose { border-style: dashed; border-color: var(--no); }
.node.dropped { animation: drop-in .26s var(--spring); }
@keyframes drop-in { from { transform: scale(1.06); opacity: .6; } }
.n-head {
  background: var(--c); color: #fff; border-radius: 13px 13px 0 0; padding: 4px 6px 4px 10px; min-height: 36px;
  display: flex; align-items: center; gap: 7px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.k-time .n-head, .k-hold .n-head, .k-then .n-head { color: var(--ink); }
.n-title { font-weight: 700; font-size: 12.5px; letter-spacing: .01em; }
.n-head .grip { opacity: .6; }
.n-head .x { margin-left: auto; }
.n-body { padding: 12px 12px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.n-body .w { color: var(--ink-2); }
.n-body select, .n-body input {
  background-color: var(--soft); border: 1px solid var(--line); border-radius: 9px; padding: 4px 8px; min-height: 32px;
  font-weight: 500; font-size: 14px; max-width: 100%; transition: border-color .15s, background-color .15s;
}
.n-body select { -webkit-appearance: none; appearance: none; padding-right: 24px; background-image: var(--chev); background-repeat: no-repeat; background-position: right 8px center; background-size: 10px 6px; }
.n-body select:hover, .n-body input:hover { border-color: var(--line-2); }
.n-body select:focus, .n-body input:focus { outline: none; border-color: var(--price); background-color: #fff; box-shadow: 0 0 0 3px rgba(47,107,255,.14); }
.n-body input[type=number] { width: 88px; font-family: var(--mono); font-weight: 500; }
.n-body input.sn { width: 64px; }
.n-body select.wide { width: 100%; }
.n-foot { padding: 0 12px 11px; display: flex; }
.lamp {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3);
  background: var(--soft); border-radius: 999px; padding: 3px 10px 3px 8px; line-height: 1.4;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
.lamp::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--no); flex: none; }
.lamp.yes { color: var(--long-edge); background: var(--long-tint); }
.lamp.yes::before { background: var(--yes); animation: live-pulse 2.4s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(18,161,80,.38); } 50% { box-shadow: 0 0 0 5px rgba(18,161,80,0); } }
.lamp .lv { font-family: var(--mono); font-weight: 500; }
.k-trade .lamp .lv, .k-logic .lamp .lv, .k-then .lamp .lv, .p-say .lamp .lv { font-family: var(--sans); font-weight: 600; }
.note-in { font-size: 12px; color: var(--ink-3); width: 100%; }
.seg { position: relative; display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.seg button {
  position: relative; z-index: 1;
  border: 0; background: transparent; color: var(--ink-2); padding: 4px 13px; border-radius: 999px; cursor: pointer; font-weight: 500; font-size: 13.5px; min-height: 30px;
  transition: color .18s var(--ease);
}
.seg button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
/* the sliding selection pill (positioned by RBmotion.indicator) */
.seg-pill {
  position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 999px; pointer-events: none; z-index: 0;
  transition: opacity .2s var(--ease);
}
.seg-pill.off { opacity: 0; }
.seg > .seg-pill { background: var(--paper); box-shadow: 0 1px 2px rgba(17,19,24,.08), 0 2px 8px rgba(17,19,24,.08); }
.chip-pill { background: var(--ink); }
/* text that swaps inside a resizing container */
.mt { display: inline-block; }
.x {
  border: 0; background: transparent; color: inherit; opacity: .7; cursor: pointer;
  width: 28px; height: 28px; border-radius: 999px; display: inline-grid; place-items: center; flex: none; padding: 0;
  transition: opacity .15s, background .15s;
}
.x:hover { opacity: 1; background: rgba(0,0,0,.12); }
.x svg { width: 11px; height: 11px; }

/* ports */
.port {
  position: absolute; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; z-index: 3;
  background: #fff; border: 2.5px solid var(--c); cursor: crosshair; touch-action: none; padding: 0;
  transition: box-shadow .15s, transform .15s var(--ease);
}
.port::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; }
.port.in { left: -10px; }
.port.out { right: -10px; background: var(--c); }
.port:hover, .port.hot { box-shadow: 0 0 0 5px rgba(47,107,255,.24); transform: scale(1.12); }
body.wiring .port.in { box-shadow: 0 0 0 4px rgba(47,107,255,.2); }
.port.pending { box-shadow: 0 0 0 6px rgba(47,107,255,.36); }
.port-label { position: absolute; left: 14px; font-size: 11px; font-weight: 600; color: var(--ink-3); margin-top: -8px; pointer-events: none; }

/* ---------- side panels ---------- */
.side { display: flex; flex-direction: column; gap: 12px; height: var(--app-h); overflow: auto; padding-bottom: 4px; scrollbar-width: thin; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.panel-share { padding: 12px; }
.note { font-size: 13px; color: var(--ink-3); margin: 12px 0 0; }
.sentence { margin: 0 0 14px; font-size: 15px; line-height: 1.6; text-wrap: pretty; }
.sentence .s-price { color: var(--price-edge); font-weight: 600; }
.sentence .s-odds { color: var(--odds-edge); font-weight: 600; }
.sentence .s-time { color: var(--time-edge); font-weight: 600; }
.sentence .s-long { color: var(--long-edge); font-weight: 600; }
.sentence .s-short { color: var(--short-edge); font-weight: 600; }
.sentence .s-safe { color: var(--ink-2); }
.sentence .s-join { font-weight: 800; }
.sentence.issue { color: var(--ink-2); }
.now-big {
  font-size: 24px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; display: inline-flex; align-items: center; gap: 10px;
  background: var(--soft); border-radius: 999px; padding: 9px 18px 9px 16px; max-width: 100%;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
.now-big .mt { white-space: nowrap; }
.now-big::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--no); flex: none; }
.now-big.yes { color: var(--long-edge); background: var(--long-tint); }
.now-big.yes::before { background: var(--yes); animation: live-pulse 2.4s ease-in-out infinite; }
.now-list { list-style: none; margin: 14px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--ink-2); }
.now-list li { display: flex; gap: 10px; align-items: baseline; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--no); flex: none; transform: translateY(-1px); }
.dot.yes { background: var(--yes); box-shadow: 0 0 0 3px rgba(18,161,80,.16); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center; text-decoration: none;
  width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 10px 18px;
  font-weight: 600; font-size: 14.5px; cursor: pointer; min-height: 46px; color: var(--ink);
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s, color .2s;
}
#run-hist { display: flex; margin-inline: auto; }
#run-hist:disabled { opacity: 1; background: var(--ink-2); border-color: var(--ink-2); cursor: progress; }
#run-hist .mt { white-space: nowrap; }
.btn.small { min-height: 38px; padding: 6px 16px; width: auto; font-size: 13.5px; }
.btn + .btn { margin-top: 10px; }
.btn:hover:not(:disabled) { border-color: #C9CDD3; box-shadow: 0 4px 14px rgba(17,19,24,.07); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: #262A33; border-color: #262A33; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.danger { color: var(--short-edge); }
.btn.danger:hover:not(:disabled) { border-color: rgba(229,72,77,.45); background: var(--short-tint); box-shadow: none; }
.h-sum { margin: 18px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.pos { color: var(--long-edge); }
.neg { color: var(--short-edge); }
.h-msg { margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.h-chart { margin: 14px 0 4px; width: 100%; height: auto; display: block; background: var(--ws); border-radius: 12px; }
.h-chart .ln { fill: none; stroke: var(--ink-3); stroke-width: 1.4; }
.h-trades { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.h-trades li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 14px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.h-trades .why { grid-column: 1 / -1; color: var(--ink-2); font-size: 13px; }
.h-trades .pl { font-family: var(--mono); font-weight: 500; text-align: right; }
.h-fine { font-size: 12px; color: var(--ink-3); margin: 14px 0 0; line-height: 1.55; }
#account .rb-rule { border-radius: 14px !important; border-color: var(--line) !important; }
#account .rb-foot { font-size: 12px; color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0; z-index: 95;
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 500;
  box-shadow: 0 12px 32px -8px rgba(17,19,24,.35);
  transition: opacity .2s, transform .25s var(--ease); pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive: tablet ---------- */
@media (max-width: 1100px) {
  .layout, body.panel-off .layout { grid-template-columns: 184px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; height: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; overflow: visible; }
  #panel-toggle { display: none; }
  body.panel-off .side { display: grid; }
  .top { position: static; flex-wrap: wrap; row-gap: 10px; }
  .top .templates { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .top .templates::-webkit-scrollbar { display: none; }
  .top .templates .chip-btn { flex: none; }
  .feed-pre { display: none; }
}
@media (min-width: 761px) { .flow-view { display: none; } }

/* ---------- phone: 760px and narrower ---------- */
@media (max-width: 760px) {
  .top { position: sticky; min-height: 0; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); gap: 10px; flex-wrap: nowrap; }
  .brand { font-size: 17px; margin-right: 0; }
  .brand-mark { width: 44px; height: 44px; }
  .top .templates { display: none; }
  .feed { margin-left: auto; font-size: 12.5px; padding: 5px 12px 5px 10px; white-space: normal; line-height: 1.3; min-width: 0; }
  .feed-pre { display: none; }
  .icon-btn { width: 44px; height: 44px; }

  .starters { display: block; padding: 14px 0 2px; }
  .starters-h { margin: 0 16px 8px; font-size: 13px; color: var(--ink-3); }
  .starters-row {
    display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 8px; scroll-snap-type: x proximity; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent);
  }
  .starters-row::-webkit-scrollbar { display: none; }
  .starters-row .chip-btn { flex: none; min-height: 40px; padding: 0 16px; font-size: 14px; scroll-snap-align: start; scroll-margin-left: 16px; }

  .layout, body.panel-off .layout { grid-template-columns: minmax(0, 1fr); padding: 8px 16px 40px; gap: 12px; counter-reset: sec; }
  .palette, .ws { display: none; }
  .flow-view { display: block; }
  .side { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 20px; }
  .side > .panel:first-child { display: none; }
  .panel { border-radius: 22px; padding: 20px; }
  .panel-share { padding: 12px; }
  .side h2, .p-h.sec-h { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 14px; color: var(--ink); }
  .side h2::before, .p-h.sec-h::before {
    counter-increment: sec; content: counter(sec, decimal-leading-zero);
    display: inline-grid; place-items: center; min-width: 34px; height: 30px; padding: 0 8px; border-radius: 999px;
    background: var(--soft); font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; flex: none;
  }
  .now-big { font-size: 26px; }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* ---------- phone builder ---------- */
.p-say {
  position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 20px 20px 22px;
  box-shadow: var(--shadow-lift); margin: 6px 0 36px; transition: border-color .3s, box-shadow .3s;
}
.p-say.on { border-color: rgba(18,161,80,.5); box-shadow: 0 0 0 4px rgba(18,161,80,.10), var(--shadow-lift); }
.p-say-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.p-kicker { margin: 0; font-size: 13px; font-weight: 500; color: var(--ink-3); display: inline-flex; align-items: center; gap: 8px; }
.p-kicker::before { content: ""; width: 8px; height: 8px; border-radius: 2.5px; background: var(--pink); }
.p-say .sentence { margin: 0; font-size: 19px; line-height: 1.5; letter-spacing: -0.012em; font-weight: 500; }
.p-say .sentence .s-safe { display: block; margin-top: 12px; font-size: 15px; line-height: 1.55; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.p-h { font-size: 13px; font-weight: 500; color: var(--ink-3); margin: 0 0 10px 2px; }
.pgroup {
  background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 6px;
  display: flex; flex-direction: column; transition: border-color .3s, box-shadow .3s;
}
.pg-body .pgroup { background: var(--soft); border-color: var(--line); border-radius: 16px; margin: 4px 0; padding: 6px; }
.pg-body .pgroup.any { border-style: dashed; border-color: var(--line-2); }
.pgroup.on { border-color: rgba(18,161,80,.55); box-shadow: 0 0 0 3px rgba(18,161,80,.10); }
.pg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 4px 6px; }
.pg-head .seg button { min-height: 38px; padding: 4px 14px; font-size: 14px; }
.prow {
  --c: var(--price);
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 14px;
  padding: 12px 10px 12px 12px; min-height: 60px; font: inherit; color: inherit; cursor: pointer; transition: background .15s;
}
.prow > .p-dot { align-self: flex-start; margin-top: 5px; }
button.prow:hover { background: var(--soft); }
button.prow:active { background: #ECEDF0; }
.pg-body .pgroup button.prow:hover, .pg-body .pgroup button.prow:active { background: rgba(255,255,255,.75); }
.prow.k-odds, .pick-row.c-odds { --c: var(--odds); }
.prow.k-time, .prow.k-hold, .pick-row.c-time { --c: var(--time); }
.prow.k-trade { --c: var(--long); }
.prow.k-trade.short { --c: var(--short); }
.prow.k-safe { --c: var(--exit); }
.p-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--c, var(--price)); flex: none; }
.p-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.p-text { font-size: 15.5px; line-height: 1.4; overflow-wrap: anywhere; }
.p-text .s-price { color: var(--price-edge); font-weight: 600; }
.p-text .s-odds { color: var(--odds-edge); font-weight: 600; }
.p-text .s-time { color: var(--time-edge); font-weight: 600; }
.p-text .s-join { font-weight: 800; }
.p-chev { width: 8px; height: 14px; color: var(--ink-3); flex: none; opacity: .7; }
.p-join { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 4px; border: 0; background: none; cursor: pointer; font: inherit; color: var(--ink-2); -webkit-tap-highlight-color: transparent; }
.p-join::before, .p-join::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.pj-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 12px; letter-spacing: .06em; transition: background .2s, color .2s, border-color .2s, transform .15s; }
.pj-pill b { font-weight: 800; }
.pj-swap { width: 14px; height: 14px; opacity: .6; }
.p-join:active .pj-pill { transform: scale(.94); }
.p-join.is-or .pj-pill { background: var(--ink, #111318); border-color: var(--ink, #111318); color: #fff; }
.p-join.is-or::before, .p-join.is-or::after { border-top-style: dashed; }
.pg-head .pg-hint { margin: 0; flex: 1; }
.pg-add { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 4px 4px; }
.p-add {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  min-height: 44px; padding: 0 16px 0 12px; font-weight: 600; font-size: 14px; color: var(--ink); cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s var(--ease);
}
.p-add::before {
  content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 16px; font-weight: 500; line-height: 1;
}
.p-add:hover { border-color: #C9CDD3; box-shadow: 0 4px 14px rgba(17,19,24,.07); }
.p-add:active { transform: scale(.97); }
.p-add.ghost { color: var(--ink-2); background: transparent; }
.p-add.ghost::before { background: var(--soft); color: var(--ink); }
.p-add.wide { width: 100%; justify-content: center; margin: 14px 0 0; border-style: dashed; border-color: var(--line-2); min-height: 52px; border-radius: 18px; text-align: left; }
.p-empty { margin: 8px 10px; color: var(--ink-3); font-size: 14px; }
.p-note { font-size: 13px; color: var(--ink-3); margin: 0 0 10px 2px; }
.psec { margin: 0; }
.psec + .psec { margin-top: 28px; }
.flow-view .f-arrow { margin-left: 24px; }
.f-arrow { position: relative; height: 30px; margin: 4px 0 6px; }
.f-arrow::before { content: ""; position: absolute; left: 0; top: 0; bottom: 7px; border-left: 2px dotted var(--no); }
.f-arrow::after { content: ""; position: absolute; left: -5px; bottom: 0; border: 6px solid transparent; border-top: 8px solid var(--no); border-bottom: 0; }
.f-arrow[data-st="on"]::before { border-left-style: solid; border-color: var(--yes); }
.f-arrow[data-st="on"]::after { border-top-color: var(--yes); }
.f-arrow.struct::before { border-left-style: solid; border-color: var(--exit); }
.f-arrow.struct::after { border-top-color: var(--exit); }
.f-arrow + .psec { margin-top: 0; }
.p-then {
  display: flex; align-items: center; gap: 8px; background: var(--time-tint); color: var(--ink); border: 1px solid #F3DDA6;
  border-radius: 18px; padding: 8px 8px 8px 16px; flex-wrap: wrap;
}
.p-then::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--time); flex: none; margin-right: 4px; }
.p-then .w { font-weight: 600; color: var(--time-edge); }
.p-then .x { margin-left: auto; width: 44px; height: 44px; }
.p-then input, .p-exit-ctl input {
  min-height: 44px; font-size: 16px; width: 80px; font-family: var(--mono); font-weight: 500;
  background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px;
}
.p-then input { background: #fff; border-color: #F3DDA6; }
.p-then input:focus, .p-exit-ctl input:focus { outline: none; border-color: var(--price); box-shadow: 0 0 0 3px rgba(47,107,255,.14); background: #fff; }
.p-exit { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 12px; min-height: 60px; flex-wrap: wrap; }
.p-exit + .p-exit { border-top: 1px solid var(--line); }
.p-exit-ctl { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.p-switch { display: inline-flex; align-items: center; gap: 12px; font-weight: 500; font-size: 15.5px; cursor: pointer; position: relative; min-height: 44px; }
.p-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.p-knob { --k: 0; width: 50px; height: 30px; border-radius: 15px; background: #E2E5EA; position: relative; flex: none; box-shadow: inset 0 0 0 1px rgba(17,19,24,.04); }
.p-knob::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--long); opacity: var(--k); }
.p-thumb {
  position: absolute; left: 2px; top: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(17,19,24,.14), 0 3px 8px rgba(17,19,24,.12);
  transform: translateX(calc(var(--k) * 20px)); transition: width .2s var(--ease);
}
.p-switch:active .p-thumb { width: 30px; }
.p-switch input:checked + .p-knob { --k: 1; }
.p-switch:active input:checked + .p-knob .p-thumb { transform: translateX(calc(var(--k) * 16px)); }
.p-switch input:focus-visible + .p-knob { outline: 2px solid var(--price); outline-offset: 3px; }
.p-switch input:disabled + .p-knob { opacity: .45; }
.p-switch input:disabled ~ span:last-child { color: var(--ink-3); }
.prow > .x { margin-left: auto; width: 44px; height: 44px; }
div.prow { cursor: default; }

/* bottom sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 70; }
.sheet-back {
  position: absolute; inset: 0; background: rgba(17,19,24,.28); opacity: 0;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 26px 26px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; max-height: 88dvh; overflow: auto; overscroll-behavior: contain;
  /* the second shadow is a white strip under the sheet, so a small overshoot never shows a gap */
  box-shadow: 0 -12px 48px -12px rgba(17,19,24,.25), 0 80px 0 0 #fff;
  transform: translateY(100%); will-change: transform;
}
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: #D5D8DE; margin: 4px auto 16px; }
.sheet h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.15; margin: 0 0 18px; display: flex; align-items: center; gap: 10px; }
.sheet .n-body { padding: 0; gap: 10px 8px; font-size: 16px; }
.sheet .n-body .w { color: var(--ink-2); }
.sheet .n-body select, .sheet .n-body input { min-height: 48px; font-size: 16px; border-radius: 12px; padding: 6px 12px; }
.sheet .n-body select { padding-right: 32px; background-position: right 12px center; }
.sheet .n-body input[type=number] { width: 124px; }
.sheet .n-body input.sn { width: 96px; }
.sheet .n-body .note-in { font-size: 14px; }
.sheet .seg button { min-height: 44px; padding: 4px 18px; font-size: 15px; }
.sheet h2 { --c: var(--price); }
.sheet h2.k-odds { --c: var(--odds); }
.sheet h2.k-time, .sheet h2.k-hold, .sheet h2.k-then { --c: var(--time); }
.sheet h2.k-trade { --c: var(--long); }
.sheet h2.k-trade.short { --c: var(--short); }
.sheet h2.k-safe, .sheet h2.k-exit { --c: var(--exit); }
.sheet h2 .p-dot { width: 14px; height: 14px; }
.sh-hold { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 26px; }
.sheet-actions .btn { flex: 1; margin: 0; min-height: 52px; font-size: 16px; }
.sheet > div > .btn { min-height: 52px; font-size: 16px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.pick-row {
  --c: var(--price); display: flex; gap: 14px; align-items: flex-start; text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 16px; padding: 14px 16px; min-height: 64px; cursor: pointer; font: inherit; color: inherit;
  transition: border-color .15s, background .15s, transform .15s var(--ease);
}
.pick-row:hover { border-color: #C9CDD3; }
.pick-row:active { background: var(--soft); transform: scale(.985); }
.pick-row b { display: block; font-size: 16px; font-weight: 600; }
.pick-d { display: block; font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }
.pick-row .p-dot { margin-top: 5px; }
body.sheet-open { overflow: hidden; }

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

/* problems with a block: errors stop the rule, warnings are advice */
.v-issue { display: block; width: 100%; margin-top: 6px; font-size: 13px; line-height: 1.4; font-weight: 500; text-align: left; }
.v-issue.err { color: #B0303A; }
.v-issue.warn { color: #8F5D00; }
.prow.has-err, .p-exit.has-err { box-shadow: inset 0 0 0 1.5px #E5484D; border-radius: 12px; background: #FFF5F5; }
.prow.has-warn { box-shadow: inset 0 0 0 1.5px #F2C26B; border-radius: 12px; background: #FFFBF0; }
.p-exit .v-issue { flex-basis: 100%; }
.node.has-err { border-color: #E5484D !important; }
.node.has-warn { border-color: #F2C26B !important; }
.node .v-issue { padding: 0 0 2px; }
.pg-hint { margin: -2px 4px 6px; font-size: 13px; color: var(--ink-3); }
