/* Tiller: chart-table look. Paper, navy ink, one signal orange.
   Orange means "the model picked this"; teal/red/amber are outcomes only.
   Layout: a scrolling work column on the left, the browser filling the right. */
:root {
  --paper: #F3EEE3;
  --sheet: #FBF8F1;
  --ink: #12263A;
  --ink-2: #44566A;
  --ink-3: #6B7A87;
  --rule: #D9D0BE;
  --pick: #E4572E;
  --pick-soft: #F8DDD2;
  --ok: #1F7A6B;
  --bad: #A8322A;
  --warn: #8A6A12;
  --navy: #0E1B2A;
  --top: 57px;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Figtree', system-ui, sans-serif;
  --mono: 'Martian Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--sans); }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: .005em; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 23px; }
h3 { font-size: 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.legend { font: 500 10px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-style: normal; }
.muted { color: var(--ink-3); font-size: 13.5px; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.error { margin: 10px 0 0; color: var(--bad); font-weight: 600; font-size: 14px; }
.link { border: 0; background: none; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-align: left; }
:focus-visible { outline: 2px solid var(--pick); outline-offset: 2px; }

/* header */
.top { height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--ink); background: var(--sheet); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font: 400 28px/1 var(--serif); }
.tagline { margin: 0; color: var(--ink-2); font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--rule); border-radius: 3px; background: var(--paper); font: 500 10.5px/1 var(--mono); white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.chip[data-state=ok] .dot { background: var(--ok); }
.chip[data-state=bad] .dot { background: var(--bad); }
.account { position: relative; }
.who-btn { display: flex; align-items: center; gap: 8px; max-width: 240px; padding: 7px 10px; border: 1px solid var(--ink); border-radius: 3px; background: var(--paper); color: var(--ink); font: 500 13px var(--sans); cursor: pointer; }
.who-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 270px; padding: 14px; background: var(--sheet); border: 1px solid var(--ink); border-radius: 4px; box-shadow: 4px 4px 0 var(--ink); display: grid; gap: 6px; }
.menu p { margin: 0; }
.slider { display: flex; align-items: center; gap: 10px; }
.slider input { flex: 1; accent-color: var(--pick); }
.slider b { font: 600 13px var(--mono); min-width: 40px; text-align: right; }

/* layout: left work column, right browser */
.layout { display: grid; grid-template-columns: var(--left-w, clamp(400px, 30vw, 560px)) 9px minmax(0, 1fr); height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); }
.left { overflow-y: auto; padding: 18px 16px 28px 20px; display: grid; gap: 22px; align-content: start; background: var(--paper); min-width: 0; }
.resizer { cursor: col-resize; background: var(--sheet); border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); display: flex; align-items: center; justify-content: center; touch-action: none; }
.resizer span { width: 3px; height: 44px; border-radius: 2px; background: var(--ink-3); }
.resizer:hover, .resizer:focus-visible, .resizing .resizer { background: var(--pick-soft); }
.resizer:hover span, .resizing .resizer span { background: var(--pick); }
.resizing { cursor: col-resize; user-select: none; }
.resizing iframe { pointer-events: none; }
.right { min-width: 0; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; align-items: center; overflow-y: auto; background:
  linear-gradient(rgba(18,38,58,.06) 1px, transparent 1px) 0 0 / 40px 40px,
  linear-gradient(90deg, rgba(18,38,58,.06) 1px, transparent 1px) 0 0 / 40px 40px,
  #E9E2D3; }

/* the browser takes every pixel it can while keeping 1280:800 */
.frame { width: min(100%, calc((100dvh - var(--top) - 150px) * 1.6)); border: 1px solid var(--ink); background: var(--navy); border-radius: 4px; overflow: hidden; box-shadow: 6px 6px 0 var(--ink); flex: none; }
.frame-bar { display: flex; align-items: center; gap: 12px; padding: 6px 12px; min-height: 34px; background: var(--ink); }
.frame-bar #frameNote { margin-left: auto; text-align: right; }
.takeover { border: 1px solid #9FB3C8; background: transparent; color: #E8EEF4; border-radius: 3px; padding: 4px 9px; font: 600 11.5px var(--sans); cursor: pointer; white-space: nowrap; }
.takeover:hover { background: rgba(255,255,255,.12); }
.takeover.on { background: var(--pick); border-color: var(--pick); color: #fff; }
.frame-bar .legend { color: #9FB3C8; }
.screen { aspect-ratio: 1280 / 800; position: relative; }
.screen iframe, .screen img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--navy); object-fit: contain; }

.totals { width: min(100%, calc((100dvh - var(--top) - 150px) * 1.6)); display: grid; grid-template-columns: minmax(0, 1fr) repeat(4, auto); gap: 0 22px; align-items: end; background: var(--sheet); border: 1px solid var(--ink); border-radius: 4px; padding: 10px 14px; }
.totals div { display: grid; gap: 1px; min-width: 0; }
.totals b { font: 600 15px/1.3 var(--mono); font-variant-numeric: tabular-nums; }
.totals .goal { font: 400 18px/1.25 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.totals b.tag { font-size: 10px; justify-self: start; }

.ask { width: min(100%, calc((100dvh - var(--top) - 150px) * 1.6)); display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr); gap: 16px; align-items: center; background: var(--sheet); border: 1px solid var(--pick); border-radius: 4px; padding: 12px 14px; box-shadow: 4px 4px 0 var(--pick); }
.ask p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
#askOptions { display: grid; gap: 6px; }
.ask-option { width: 100%; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border: 1px solid var(--ink); border-radius: 3px; background: var(--paper); font: inherit; color: var(--ink); cursor: pointer; }
.ask-option:hover { background: var(--pick-soft); }
.ask-option b { font: 600 12px var(--mono); background: var(--ink); color: var(--sheet); border-radius: 3px; text-align: center; padding: 3px 0; }
.ask-option span { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-option i { font: 600 12px var(--mono); font-style: normal; }

/* form */
.panel { background: var(--sheet); border: 1px solid var(--ink); border-radius: 4px; padding: 18px; box-shadow: 4px 4px 0 var(--ink); }
.field { display: grid; gap: 5px; margin-top: 12px; }
.field textarea, .field input { width: 100%; padding: 11px 12px; border: 1px solid var(--ink); border-radius: 3px; background: #fff; color: var(--ink); font: 400 16px/1.4 var(--sans); resize: vertical; }
.field textarea { min-height: 62px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 14px; }
.btn { padding: 10px 16px; border: 1px solid var(--ink); border-radius: 3px; background: var(--ink); color: var(--sheet); font: 600 14px var(--sans); cursor: pointer; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 7px 11px; font-size: 13px; background: var(--paper); color: var(--ink); }
.btn.small:hover:not(:disabled) { background: var(--ink); color: var(--sheet); }
.btn.ghost, .btn.small.ghost { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.go { background: var(--pick); color: #fff; font-size: 15px; padding: 11px 22px; box-shadow: 3px 3px 0 var(--ink); }
.btn.go:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.wide { width: 100%; margin-top: 16px; }
.seg { border: 0; padding: 0; margin: 0 0 0 auto; display: flex; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 8px 11px; border: 1px solid var(--ink); font-size: 12.5px; font-weight: 600; background: var(--paper); white-space: nowrap; }
.seg label + label span { border-left: 0; }
.seg input:checked + span { background: var(--ink); color: var(--sheet); }
.seg input:focus-visible + span { outline: 2px solid var(--pick); outline-offset: 2px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; font-weight: 500; cursor: pointer; margin-top: 12px; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.quota { margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--rule); font-size: 13px; color: var(--ink-2); }

/* blocks */
.block { min-width: 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--ink); padding-bottom: 5px; margin-bottom: 10px; }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.preset { text-align: left; display: grid; gap: 4px; align-content: start; padding: 10px 11px; border: 1px solid var(--rule); border-radius: 3px; background: var(--sheet); color: var(--ink); cursor: pointer; font: inherit; transition: border-color .15s, transform .15s; }
.preset-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.preset-head .legend { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind { font: 600 9.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; font-style: normal; color: var(--sheet); background: var(--ink); padding: 4px 6px; border-radius: 2px; white-space: nowrap; }
.preset b { font-weight: 600; font-size: 14px; line-height: 1.3; }
.preset-goal { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.preset-expect { font-size: 12px; color: var(--warn); font-weight: 600; line-height: 1.35; }
.preset:hover:not(:disabled) { border-color: var(--ink); transform: translate(-1px, -1px); }
.preset:disabled { opacity: .45; cursor: not-allowed; }

/* steps */
.run-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.share-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; margin: 0 0 10px; }
.share-line input { padding: 7px 9px; border: 1px solid var(--rule); border-radius: 3px; background: #fff; font: 500 11px var(--mono); color: var(--ink); min-width: 0; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.log .empty { background: var(--sheet); border: 1px dashed var(--ink-3); border-radius: 4px; padding: 14px 16px; color: var(--ink-2); font-size: 13.5px; }
.log .empty p { margin: 0 0 8px; }
.log .empty p:last-child { margin: 0; }
.log .note { font: 500 11px var(--mono); color: var(--ink-3); padding: 0 2px; overflow-wrap: anywhere; }
.step { background: var(--sheet); border: 1px solid var(--rule); border-left: 3px solid var(--ink); border-radius: 3px; padding: 10px 12px; min-width: 0; }
.step-head { display: flex; gap: 10px; align-items: baseline; }
.step-n { font: 600 13px var(--mono); }
.step-where { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; letter-spacing: .02em; }
.step-ms { white-space: nowrap; }
.read { margin-top: 8px; opacity: .7; }
.read.final { opacity: 1; }
.bars { display: grid; gap: 3px; margin-top: 4px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 70px 46px; gap: 8px; align-items: center; }
.bar-label { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar.win .bar-label { color: var(--ink); font-weight: 600; }
.track { height: 8px; background: var(--paper); border: 1px solid var(--rule); border-radius: 1px; overflow: hidden; }
.fill { height: 100%; background: var(--ink-3); transition: width .35s ease-out; }
.bar.win .fill { background: var(--pick); }
.bar-p { font: 500 11px var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.outcome { display: grid; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--rule); }
.outcome:empty { display: none; }
.pick { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.pick::before { content: ''; display: inline-block; width: 8px; height: 8px; background: var(--pick); margin-right: 8px; transform: rotate(45deg) translateY(-1px); }
.did, .thought { font: 400 11px/1.5 var(--mono); color: var(--ink-3); overflow-wrap: anywhere; }
.thought { font-style: italic; }
.verdict { padding: 11px 13px; border-radius: 3px; font-weight: 600; font-size: 14px; border: 1px solid var(--ink); background: var(--sheet); overflow-wrap: anywhere; }
.verdict.done { border-color: var(--ok); color: var(--ok); }
.verdict.blocked, .verdict.step-limit, .verdict.timeout, .verdict.stopped { border-color: var(--warn); color: var(--warn); }
.verdict.error { border-color: var(--bad); color: var(--bad); }

.tag { display: inline-block; font: 600 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 4px 6px; border-radius: 2px; border: 1px solid currentColor; color: var(--ink-3); white-space: nowrap; }
.tag.done { color: var(--ok); }
.tag.error { color: var(--bad); }
.tag.blocked, .tag.step-limit, .tag.timeout, .tag.stopped { color: var(--warn); }
.tag.running, .tag.human { color: var(--pick); }

/* saved runs */
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history-item { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; align-items: center; text-align: left; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 3px; background: var(--sheet); color: var(--ink); font: inherit; cursor: pointer; }
.history-item:hover { border-color: var(--ink); }
.history-goal { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .legend { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.foot p { margin: 0; font-size: 12px; color: var(--ink-3); }

/* account dialog */
.dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--ink); border-radius: 4px; background: var(--sheet); color: var(--ink); box-shadow: 8px 8px 0 var(--ink); }
.dialog::backdrop { background: rgba(14, 27, 42, .55); }
.dialog form { position: relative; }
.dialog .close { position: absolute; right: -8px; top: -8px; border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 6px; }
.dialog .switch { margin: 14px 0 0; font-size: 13.5px; color: var(--ink-2); }
#codeFields input { font: 600 22px var(--mono); letter-spacing: .3em; text-align: center; }
#codeFields .link { margin-top: 10px; font-size: 13px; color: var(--ink-2); }

/* shared replay page: no form, no examples */
.replay .left { align-content: start; }

/* narrow: stack, form first, then the browser, then the rest */
@media (max-width: 1080px) {
  .layout { display: flex; flex-direction: column; height: auto; }
  .left, .right { overflow: visible; }
  .resizer { display: none; }
  .left { display: contents; }
  .left > * { margin: 0 16px; }
  .panel { order: 1; margin-top: 16px !important; }
  .right { order: 2; padding: 16px; margin-top: 16px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
  #examplesBlock { order: 3; margin-top: 18px !important; }
  #outputBlock { order: 4; margin-top: 18px !important; }
  #historyBlock { order: 5; margin-top: 18px !important; }
  .foot { order: 6; margin: 18px 16px 28px !important; }
  .frame, .totals, .ask { width: 100%; }
  .tagline { display: none; }
  .top { padding: 0 14px; gap: 10px; }
  .chip { margin-left: auto; }
}
@media (max-width: 640px) {
  .chip { display: none; }
  .account { margin-left: auto; }
  .totals { grid-template-columns: repeat(4, 1fr); gap: 8px 12px; }
  .totals .goal-cell { grid-column: 1 / -1; }
  .ask { grid-template-columns: 1fr; }
  .seg { margin-left: 0; }
  .frame { box-shadow: 3px 3px 0 var(--ink); }
  .who-btn span { max-width: 120px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
