/* Bilinear Flow Policy project page. Light only: the paper figures are drawn on white. */
:root {
  color-scheme: light;
  --ink: #1b1b1b;
  --text: #333333;
  --muted: #6b6b6b;
  --faint: #9c9c9c;
  --rule: #e6e6e6;
  --panel: #fafaf9;
  --panel-2: #f2f2ef;
  --bfp: #66C2A6;          /* policy colours from the paper: data marks and swatches only */
  --bfp-ink: #1e7a5b;
  --bfp-tint: #eef8f4;
  --flow: #8C8C8C;
  --ok: #1e7a5b;
  --bad: #b23f37;
  --measure: 46rem;        /* running text */
  --wide: 62rem;           /* figures */
  --full: 72rem;           /* the explorer */
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: #ffffff; color: var(--text); }
body { font-family: var(--sans); font-size: 17px; line-height: 1.65; font-feature-settings: 'cv11', 'ss01'; }
a { color: var(--bfp-ink); text-decoration: none; border-bottom: 1px solid rgba(30, 122, 91, .3); }
a:hover { border-bottom-color: var(--bfp-ink); }
h1, h2, h3, h4 { color: var(--ink); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
p { margin: 0 0 1rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
img, video, svg { max-width: 100%; height: auto; }
mjx-container[display="true"] { margin: .6rem 0 !important; }

.measure { max-width: var(--measure); margin-left: auto; margin-right: auto; padding: 0 16px; }
.wide { max-width: var(--wide); margin-left: auto; margin-right: auto; padding: 0 16px; }
.full { max-width: var(--full); margin-left: auto; margin-right: auto; padding: 0 16px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
          border-bottom: 1px solid var(--rule); }
.topbar .full { display: flex; align-items: center; justify-content: space-between; height: 48px; gap: 1rem; }
.topbar .brand { font-weight: 600; color: var(--ink); border: 0; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.topbar .brand img { width: 20px; height: 20px; }
.topbar nav { display: flex; gap: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { font-size: .86rem; color: var(--muted); border: 0; white-space: nowrap; }
.topbar nav a:hover { color: var(--ink); }

/* Hero */
.hero { text-align: center; padding: 3.5rem 0 1.5rem; }
.hero h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); max-width: 52rem; margin: 0 auto .9rem; }
.hero .byline { color: var(--muted); font-size: 1rem; }
.hero .byline span + span::before { content: '·'; margin: 0 .55rem; color: var(--faint); }
.hero .actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; margin-top: 1.4rem; }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 999px; font-size: .9rem;
       font-weight: 500; border: 1px solid var(--rule); color: var(--ink); background: #fff; cursor: pointer; font-family: inherit; }
.btn:hover { border-color: #bdbdbd; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #000; }
.btn[aria-disabled="true"] { color: var(--faint); cursor: default; }
.btn[aria-disabled="true"]:hover { border-color: var(--rule); }

/* Figures */
figure { margin: 1.5rem auto; }
figure img { display: block; margin: 0 auto; }
figcaption { font-size: .9rem; line-height: 1.55; color: var(--muted); margin-top: .7rem; max-width: var(--measure);
             margin-left: auto; margin-right: auto; }
figcaption b { color: var(--text); font-weight: 600; }
.teaser { padding-top: 1rem; }
.teaser figcaption { text-align: left; }

/* Abstract */
.abstract { padding: 1.5rem 16px 0; }
.abstract h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin-bottom: .8rem; }
.abstract p { font-size: 1rem; color: var(--text); }

/* Sections */
section.part { padding: 3.5rem 0 1rem; border-top: 1px solid var(--rule); margin-top: 3rem; }
.kicker { font-family: var(--mono); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }
.kicker b { color: var(--bfp-ink); font-weight: 600; }
section.part h2 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); margin-bottom: 1rem; }
section.part h3 { font-size: 1.15rem; margin: 2.2rem 0 .6rem; }
.lead { font-size: 1.08rem; }

.tldr { display: grid; grid-template-columns: auto 1fr; gap: .8rem; align-items: baseline; margin: 1.2rem 0 1.6rem; padding: .9rem 1.1rem;
        background: var(--bfp-tint); border-left: 3px solid var(--bfp); border-radius: 0 8px 8px 0; color: var(--ink); }
.tldr .tag { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--bfp-ink); font-weight: 600; }
.tldr p { margin: 0; font-size: 1.02rem; }

/* Deep dive */
details.deep { margin: 1.4rem 0; border: 1px solid var(--rule); border-radius: 10px; background: #fff; }
details.deep summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .7rem; padding: .85rem 1.1rem; color: var(--ink); font-weight: 500; }
details.deep summary::-webkit-details-marker { display: none; }
details.deep summary .pill { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
                             border: 1px solid var(--rule); border-radius: 999px; padding: .15rem .55rem; background: var(--panel); }
details.deep summary .chev { margin-left: auto; width: 10px; height: 10px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
                             transform: rotate(45deg); transition: transform .2s; flex: none; }
details.deep[open] summary .chev { transform: rotate(-135deg); }
details.deep[open] summary { border-bottom: 1px solid var(--rule); }
details.deep .body { padding: 1rem 1.1rem .4rem; font-size: .97rem; }
details.deep .body figure { margin: 1rem auto; }
details.deep .body p:last-child { margin-bottom: .6rem; }

/* Method steps */
.steps { counter-reset: step; margin-top: 1.5rem; }
.step { display: grid; grid-template-columns: 2.2rem 1fr; gap: .8rem; padding: 1.2rem 0; border-top: 1px solid var(--rule); }
.step::before { counter-increment: step; content: counter(step); width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1px solid var(--ink);
                color: var(--ink); font-size: .8rem; font-weight: 600; display: grid; place-items: center; margin-top: .15rem; }
.step h3 { margin: 0 0 .25rem; }
.step .one { color: var(--bfp-ink); font-weight: 500; margin-bottom: .6rem; }
.eq { overflow-x: auto; padding: .2rem 0; }

/* Tables */
table.data { border-collapse: collapse; margin: 1rem auto; font-size: .93rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: .45rem .9rem; text-align: center; border-bottom: 1px solid var(--rule); }
table.data th { font-weight: 600; color: var(--ink); border-bottom: 1px solid #cfcfcf; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data tr.ours td { color: var(--ink); font-weight: 600; background: var(--bfp-tint); }
table.data td b { color: var(--ink); }
table.data small { font-size: .72em; color: var(--muted); font-weight: 400; }
table.data.hw { font-size: .88rem; }
table.data.hw th, table.data.hw td { padding: .4rem .55rem; }
table.data.hw .sep { border-left: 1px solid var(--rule); }
.table-scroll { overflow-x: auto; }

/* Task strips */
.tasks { display: grid; grid-template-columns: repeat(5, 1fr); gap: .7rem; margin: 1.2rem auto; }
.tasks figure { margin: 0; text-align: center; }
.tasks img { width: 100%; border-radius: 8px; border: 1px solid var(--rule); }
.tasks figcaption { font-family: var(--mono); font-size: .78rem; margin-top: .35rem; }
.shift-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem 1rem; }
.shift-grid figure { margin: 0; }
.shift-grid img { border-radius: 6px; }
.shift-grid figcaption { font-family: var(--mono); font-size: .78rem; margin-top: .3rem; text-align: center; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.pair figure { margin: .8rem 0; }

/* What's next */
.next { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .8rem; }
.next li { padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--panel); }
.next li b { display: block; color: var(--ink); margin-bottom: .2rem; }

/* Code blocks + footer */
pre { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.1rem; overflow-x: auto;
      font-family: var(--mono); font-size: .85rem; line-height: 1.5; color: var(--ink); }
footer { border-top: 1px solid var(--rule); margin-top: 3rem; padding: 2rem 16px 3rem; text-align: center; color: var(--muted); font-size: .88rem; }

/* ---------- TL;DR card ---------- */
.summary { margin-top: 1.6rem; padding: 1.2rem 1.3rem 1.3rem; border: 1px solid var(--rule); border-left: 3px solid var(--bfp);
           border-radius: 0 12px 12px 0; background: var(--bfp-tint); }
.summary-stack { display: flex; flex-direction: column; gap: .2rem; }
.summary .tag { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--bfp-ink); font-weight: 600; }
.summary p { margin: .4rem 0 .9rem; font-size: 1.02rem; color: var(--ink); }
.summary a:not(.btn) { border-bottom: 1px solid rgba(30,122,91,.45); }
.summary .btn { align-self: center; margin-top: 1.1rem; }
.summary .mini { display: block; text-align: center; }
.summary table.data tr.ours td { background: var(--ink); color: #fff; font-weight: 600; }
.summary table.data { margin: 0 auto; background: #fff; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.summary table.data th, .summary table.data td { padding: .38rem .9rem; }
.summary table.data th:first-child { font-weight: 500; color: var(--muted); font-size: .8rem; }
.summary .mini-cap { font-size: .78rem; color: var(--muted); margin-top: .45rem; line-height: 1.4; }

/* ---------- Real-robot explorer ---------- */
section.hero-ex { padding-top: 3rem; }
.explorer { position: relative; border: 1px solid var(--rule); border-radius: 14px; background: #fff; padding: 1rem 1.1rem 1rem; margin-top: 1.2rem; }
.ex-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; background: var(--panel); }
.seg button { border: 0; background: transparent; font: inherit; font-family: var(--mono); font-size: .84rem; color: var(--muted);
              padding: .35rem .95rem; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.seg button.on { background: var(--ink); color: #fff; }
.seg.small button { font-family: var(--sans); font-size: .8rem; padding: .22rem .7rem; }
.seg.small button .cnt { font-family: var(--mono); font-size: .72rem; opacity: .75; }
.seg.small button .sw { width: 9px; height: 9px; }
.recs-row { display: flex; align-items: flex-start; gap: 1rem; margin: 0 0 1rem; padding: .8rem .9rem; border: 1px solid var(--rule); border-radius: 12px; background: var(--panel); }
.recs-label { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding-top: .35rem; white-space: nowrap; }
.recs { display: flex; flex-wrap: wrap; gap: .8rem; }
.rec { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; padding: .45rem .45rem .5rem; border: 1px solid var(--rule); border-radius: 12px;
       background: #fff; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.rec:hover { border-color: #bdbdbd; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.rec.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.rec .frames { display: flex; gap: 4px; position: relative; }
.rec .th { width: 96px; height: 96px; }
.rec .play { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: rgba(0,0,0,.6);
             display: grid; place-items: center; pointer-events: none; transition: background .15s; }
.rec:hover .play { background: rgba(0,0,0,.8); }
.rec .now { display: none; position: absolute; left: 6px; top: 6px; font-size: .66rem; font-weight: 600; color: #fff; background: var(--ink); padding: .1rem .45rem; border-radius: 999px; }
.rec.on .now { display: block; }
.rec.on .play { display: none; }
.rec .t { font-weight: 600; font-size: .88rem; margin-top: .35rem; }
.rec .s { display: flex; gap: .2rem; }
.rec .s .chip { margin-left: 0; }
.map .star { pointer-events: none; }
.trial .n b { font-weight: 600; color: var(--ink); font-size: .68rem; }
.info { position: relative; margin-left: auto; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1px solid var(--rule); color: var(--muted);
        display: grid; place-items: center; font-size: .8rem; font-weight: 600; cursor: help; user-select: none; }
.info .tip { display: none; position: absolute; right: 0; top: 2rem; width: 20rem; padding: .7rem .85rem; background: #fff; border: 1px solid #d9d9d9;
             border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.12); font-size: .82rem; font-weight: 400; color: var(--text); line-height: 1.5; z-index: 6; cursor: auto; }
.info:hover .tip, .info:focus .tip, .info:focus-within .tip { display: block; }
.info .tip b { color: var(--ink); }

.ex-body { --h: 490px; display: grid; grid-template-columns: auto auto auto; justify-content: center; column-gap: 1.4rem; row-gap: .45rem; align-items: start; }
.ex-head { height: 2rem; display: flex; align-items: center; gap: .55rem; white-space: nowrap; }
.ex-goal { font-weight: 600; color: var(--ink); font-size: 1.02rem; }
.ex-sub { color: var(--muted); font-size: .86rem; display: inline-flex; align-items: center; gap: .3rem; }
.chip { display: inline-block; font-size: .72rem; font-weight: 600; line-height: 1.4; padding: 0 .5rem; border-radius: 999px; border: 1.5px solid; margin-left: .3rem; }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.bad { color: var(--bad); border-color: var(--bad); }
.map svg { display: block; height: var(--h); width: auto; }
.map .goal { cursor: pointer; transition: stroke-width .1s; }
.map .goal:hover { stroke: var(--ink); stroke-width: 2; }
.map .goal.sel { stroke: var(--ink); stroke-width: 2.6; }
.map text { font-family: var(--sans); pointer-events: none; }
.map .tick { font-size: 9px; fill: var(--faint); }
.map .lab { font-size: 9.5px; fill: var(--muted); font-weight: 500; }
.map .cnt { font-size: 9px; font-weight: 600; fill: var(--ink); }
.explorer video { display: block; height: var(--h); width: auto; max-width: 100%; border-radius: 8px; background: var(--panel-2); aspect-ratio: 456 / 490; }
.ex-trials { height: var(--h); display: flex; flex-direction: column; gap: .5rem; overflow-y: auto; padding-right: 2px; }
.trial { display: grid; grid-template-columns: 2.6rem 56px 56px; gap: .35rem; align-items: center; padding: .3rem .4rem;
         border: 1px solid var(--rule); border-radius: 10px; background: #fff; cursor: pointer; font: inherit; color: var(--text); }
.trial:hover { border-color: #bdbdbd; }
.trial.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.trial .n { font-size: .72rem; color: var(--muted); text-align: left; line-height: 1.2; }
.th { width: 56px; height: 56px; border-radius: 7px; background-color: var(--panel-2); background-repeat: no-repeat; background-origin: border-box;
      background-clip: border-box; position: relative; box-sizing: border-box; border: 3px solid #d9d9d6; }
.th[data-ok="1"] { border-color: var(--ok); }
.th[data-ok="0"] { border-color: var(--bad); }
.th::before { content: attr(data-pol); position: absolute; left: 1px; top: 1px; font-size: .58rem; font-weight: 600; color: #fff; background: rgba(0,0,0,.5);
              padding: 0 .28rem; border-radius: 4px; line-height: 1.5; }
.ex-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem 1.5rem; margin-top: .8rem; padding-top: .7rem; border-top: 1px solid var(--rule); }
.ex-legend { font-size: .8rem; color: var(--muted); line-height: 1.45; display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; }
.ex-legend div { display: flex; align-items: center; gap: .45rem; }
.ex-legend .ramp { display: inline-flex; gap: 2px; }
.ex-legend .ramp i { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.3); display: inline-block; }
.ex-legend .k-train { width: 11px; height: 11px; border-radius: 50%; background: #d5d5d2; border: 1px solid #c0c0bc; display: inline-block; }
.ex-legend svg { flex: none; margin-left: -.15rem; }
.ex-legend .k-hull { width: 16px; height: 11px; background: #f1f1ed; border: 1.5px dashed #b9b9b4; display: inline-block; border-radius: 3px; }
.ex-legend .k-ok, .ex-legend .k-bad { width: 13px; height: 13px; border-radius: 4px; border: 3px solid var(--ok); display: inline-block; box-sizing: border-box; }
.ex-legend .k-bad { border-color: var(--bad); }

.ex-hover { position: absolute; z-index: 5; pointer-events: none; background: #fff; border: 1px solid #d9d9d9; border-radius: 10px;
            box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: .55rem .6rem .5rem; width: max-content; }
.ex-hover[hidden] { display: none; }
.ex-hover .t { font-size: .84rem; font-weight: 600; color: var(--ink); margin-bottom: .35rem; }
.ex-hover .t span { font-weight: 400; color: var(--muted); margin-left: .4rem; }
.ex-hover .row { display: flex; gap: .35rem; }
.ex-hover .th { width: 96px; height: 96px; }
.ex-hover .th::before { font-size: .66rem; left: 3px; top: 3px; }

/* References */
.refs { padding-left: 1.4rem; font-size: .92rem; color: var(--text); }
.refs li { margin-bottom: .5rem; }
.refs li:target { background: var(--bfp-tint); }
a.cite { font-size: .78em; vertical-align: super; line-height: 0; border: 0; margin-left: .1em; }

@media (max-width: 900px) {
  .ex-body { grid-template-columns: 1fr; --h: auto; justify-content: stretch; }
  .ex-body > .ex-col:nth-child(2) { order: -1; }
  .ex-head { height: auto; white-space: normal; }
  .map svg { height: auto; width: 100%; max-width: 320px; margin: 0 auto; }
  .explorer video { height: auto; width: 100%; max-width: 456px; margin: 0 auto; }
  .ex-trials { height: auto; flex-direction: row; flex-wrap: wrap; }
  .pair { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .tasks { grid-template-columns: repeat(3, 1fr); }
  .shift-grid { grid-template-columns: 1fr; }
  .tldr { grid-template-columns: 1fr; gap: .3rem; }
  .step { grid-template-columns: 1fr; }
  .step::before { margin-bottom: .2rem; }
  .ex-hover { display: none !important; }
  .topbar nav { display: none; }
}

/* ---------- Notebook page ---------- */
.nb { padding-bottom: 2rem; }
.nb-md { margin: 1.6rem 0 .8rem; }
.nb-md h1 { font-size: 1.5rem; margin: 2rem 0 .8rem; }
.nb-md h2 { font-size: 1.2rem; margin: 2rem 0 .6rem; }
.nb-md ol, .nb-md ul { padding-left: 1.4rem; }
.nb-md li { margin-bottom: .3rem; }
.nb-md table.data { margin: .8rem 0; }
.nb-md table.data th:first-child, .nb-md table.data td:first-child { text-align: left; }
.nb-code { margin: 0 0 .8rem; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: .9rem 1rem; overflow-x: auto;
           font-family: var(--mono); font-size: .8rem; line-height: 1.55; color: var(--ink); white-space: pre; }
.nb-code .c { color: var(--muted); }
.nb-code .s { color: var(--bfp-ink); }
.btn svg { vertical-align: -3px; }
