/* investing tool editor. shared colors and the top bar come from ../site.css */
html, body { height: 100%; }
body { height: 100vh; height: 100dvh; overflow: hidden; }
.top.bar { display: flex; align-items: center; gap: 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); padding-bottom: 10px; }
.top.bar { justify-content: flex-start; }
.top.bar .more { padding: 4px 10px; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.crumb { font-size: 15px; font-weight: 600; }
.priv { margin-left: auto; font-size: 12px; color: var(--muted); }

#app { position: relative; flex: 1; overflow: hidden; touch-action: none; user-select: none; }
#grid { position: absolute; inset: 0; background-color: #fbfbfc; cursor: grab;
  background-image: radial-gradient(circle, #c3c3cc 1px, transparent 1.4px); background-size: 20px 20px; }
#app.panning #grid { cursor: grabbing; }
#app.picking, #app.picking * { cursor: crosshair !important; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#wires { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
#empty { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); margin: 0; color: var(--muted); pointer-events: none; text-align: center; padding: 0 16px 0 380px; line-height: 1.6; }

/* wires (arrows) */
.wire { fill: none; stroke: #8e8e96; stroke-width: 2; marker-end: url(#ah); }
.wire.sel { stroke: #2d5bd7; stroke-width: 2.5; marker-end: url(#ah-sel); }
.wire.start { stroke: #2e9d5b; stroke-width: 2.5; stroke-dasharray: 7 5; marker-end: url(#ah-start); }
.wire.temp { stroke: #2d5bd7; stroke-dasharray: 6 5; }
.wire.temp.start { stroke: #2e9d5b; }
.hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.wlabel { position: absolute; transform: translate(-50%, -50%); background: #fff; border: 1px solid #d6d6dc; padding: 2px 7px;
  font-size: 12px; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; cursor: pointer; color: #3a3a3f; }
.wlabel .pri { display: inline-block; min-width: 15px; margin-right: 5px; background: #ececef; text-align: center; font-weight: 600; }
.wlabel.sel { border-color: #2d5bd7; color: #2d5bd7; }
.wlabel.bad { border-color: #d9534f; }

/* blocks (states with actions) */
.block { position: absolute; width: 210px; }
.block .edge { position: absolute; inset: -8px; border: 8px solid transparent; cursor: crosshair; }
.block:hover .edge { border-color: rgba(45, 91, 215, .12); }
.block .body { position: relative; background: #fff; border: 1px solid #cfcfd6; box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.06); cursor: move; }
.block.sel .body { border-color: #2d5bd7; box-shadow: 0 0 0 2px rgba(45, 91, 215, .25); }
.block.start .body { border-left: 4px solid #2e9d5b; }
.block.drop .body { background: #f0f5ff; }
.block h3 { margin: 0; padding: 8px 10px; font-size: 14px; font-weight: 600; border-bottom: 1px solid #ececef; display: flex; gap: 6px; align-items: center; }
.block h3 .tag { margin-left: auto; font-size: 11px; font-weight: 600; color: #2e9d5b; }
.chips { padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.chip { padding: 5px 7px; background: #f6f6f8; font-size: 12px; line-height: 1.35; border-left: 3px solid transparent; }
.chip b { font-weight: 600; }
.chip span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.sel { background: #e8efff; }
.chip.bad { border-left-color: #d9534f; }
.chips .none { color: var(--muted); font-size: 12px; padding: 4px; }

/* the portfolio tile, on the grid */
#ctile { position: absolute; width: 300px; background: #fff; border: 1px solid #cfcfd6; border-top: 4px solid #2e9d5b;
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(0,0,0,.08); padding: 10px 12px 12px; cursor: move; user-select: text; }
.chead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.chead h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.csets { border-top: 1px solid #ececef; margin-top: 8px; padding-top: 8px; display: grid; gap: 6px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 2px; }
.keybox { display: grid; gap: 4px; padding: 6px 8px; background: #f6f7f9; border: 1px solid #ececef; border-radius: 6px; }
.keybox details > summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.keybox details[open] { display: grid; gap: 4px; }
.keyrow { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 2px; }
.muted.small { font-size: 11.5px; margin: 0; }
button.mini { font-size: 11px; padding: 2px 8px; }
#starttab { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); background: #2e9d5b; color: #fff; border: none;
  padding: 3px 14px 5px; font-size: 12px; font-weight: 600; cursor: grab; white-space: nowrap; }
#starttab:hover, #app.picking #starttab { background: #237a46; }

/* floating panels */
.panel { background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.08); }
#menu { position: absolute; left: 16px; top: 16px; bottom: 16px; width: 340px; overflow: auto; padding: 12px 14px 16px; touch-action: pan-y; user-select: text; }
.phead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.phead h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
button { font: inherit; }
.add, #tools button, .btn { background: #fff; border: 1px solid #cfcfd6; padding: 3px 10px; cursor: pointer; color: var(--fg); }
.add:hover, #tools button:hover, .btn:hover { background: #f3f3f6; }
.btn:disabled { color: var(--muted); cursor: default; background: #fafafa; }
.btn.danger { color: #b3261e; border-color: #e4b8b4; }
.btn.danger:hover { background: #fdf1f0; }
.add { width: 28px; height: 28px; padding: 0; font-size: 18px; line-height: 1; }
.total { display: flex; justify-content: space-between; border-top: 1px solid #ececef; margin-top: 8px; padding-top: 8px; font-size: 14px; }
.asset { display: grid; grid-template-columns: 82px 1fr 24px; gap: 4px 6px; padding: 8px 0; border-top: 1px solid #f0f0f3; }
.asset:first-child { border-top: none; padding-top: 0; }
.asset .row2 { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 0 2px; }
.x:hover { color: #b3261e; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0; }
input, select { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid #d6d6dc; background: #fff; color: var(--fg); width: 100%; min-width: 0; box-sizing: border-box; }
input:focus, select:focus { outline: 2px solid rgba(45, 91, 215, .35); border-color: #2d5bd7; }
input.mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12.5px; }
input.bad { border-color: #d9534f; }
small.err { display: block; color: #b3261e; font-size: 11px; line-height: 1.3; }
small.err:empty { display: none; }
label.f { display: block; font-size: 11px; color: var(--muted); }
label.f > input, label.f > select { margin-top: 2px; }
code { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12px; background: #f3f3f6; padding: 0 3px; }

/* menu (action list) */
.group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
.tool { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid #d6d6dc; padding: 7px 10px; margin-bottom: 6px; cursor: grab; }
.tool:hover { filter: brightness(.96); }
.tool b { display: block; font-size: 14px; font-weight: 600; }
.tool span { font-size: 12px; color: var(--muted); }
.ghost { position: fixed; z-index: 10; pointer-events: none; background: #fff; border: 1px solid #2d5bd7; padding: 6px 10px; font-size: 13px; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.15); transform: translate(-50%, -50%); }
.fns { margin-top: 18px; border-top: 1px solid #ececef; padding-top: 10px; }
.fns summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.fn { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid #f0f0f3; padding: 5px 2px; cursor: pointer; }
.fn:hover { background: #f6f8ff; }
.fn code { background: none; padding: 0; color: #2d5bd7; }
.fn span { display: block; font-size: 12px; color: var(--muted); }

/* inspector */
.back { background: none; border: none; color: var(--link); padding: 0; cursor: pointer; font-size: 13px; margin-bottom: 8px; }
.kind { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card { border: 1px solid #e3e3e8; padding: 8px 10px; margin: 8px 0; }
.card.open { border-color: #2d5bd7; }
.card .ch { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.card .ch b { flex: 1; font-size: 14px; }
.card .ch .mv { background: none; border: 1px solid #e3e3e8; cursor: pointer; padding: 0 5px; color: var(--muted); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fields .wide { grid-column: 1 / -1; }
.stack > * + * { margin-top: 8px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row > * { flex: 1; }

/* toolbar */
#tools { position: absolute; right: 16px; top: 16px; display: flex; align-items: center; gap: 6px; padding: 6px; }
#tools .run { background: #2e9d5b; color: #fff; border-color: #2e9d5b; font-weight: 600; padding: 3px 14px; }
#tools .run:hover { background: #237a46; }
#tools #zin, #tools #zout { width: 28px; padding: 3px 0; }
.sep { width: 1px; height: 22px; background: #e3e3e8; }
#zoom { font-size: 12px; color: var(--muted); min-width: 40px; text-align: center; }
#hint { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1d1d1f; color: #fff; padding: 8px 14px; font-size: 13px; pointer-events: none; z-index: 5; }

/* results */
#results { position: absolute; right: 16px; top: 64px; bottom: 16px; width: 400px; overflow: auto; padding: 12px 14px 16px; touch-action: pan-y; user-select: text; }
#results h3 { font-size: 14px; margin: 16px 0 6px; }
.figs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.figs div { background: #f6f6f8; padding: 8px 10px; }
.figs span { display: block; font-size: 11px; color: var(--muted); }
.figs b { font-size: 16px; }
.up { color: #237a46; } .down { color: #b3261e; }
.chart { width: 100%; height: 140px; border: 1px solid #ececef; background: #fcfcfd; }
.chart polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .strat { stroke: #2d5bd7; } .chart .hold { stroke: #b9b9c2; stroke-dasharray: 4 3; }
.legend { font-size: 12px; color: var(--muted); margin: 4px 0; }
.legend .k { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin: 0 4px 0 8px; }
.legend .k.strat { background: #2d5bd7; } .legend .k.hold { background: #b9b9c2; }
.plain { padding-left: 18px; margin: 0; font-size: 13px; }
.probs { padding-left: 18px; color: #b3261e; font-size: 13px; }
.log { padding-left: 0; list-style: none; margin: 0; font-size: 12px; }
.log li { padding: 4px 0; border-bottom: 1px solid #f0f0f3; }
.log span { color: var(--muted); }

/* formula boxes: a see-through textarea over a colored copy of the same text (both must match exactly) */
.xbox { position: relative; margin-top: 2px; }
.xin { position: relative; }
.xhl, .xta { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12.5px; line-height: 18px; padding: 4px 6px; margin: 0;
  border: 1px solid #d6d6dc; box-sizing: border-box; width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; letter-spacing: 0; tab-size: 2; }
.xhl { position: absolute; inset: 0; overflow: hidden; background: #fff; color: #000; pointer-events: none; }
.xta { position: relative; display: block; resize: none; overflow: hidden; min-height: 28px; background: transparent; color: transparent; caret-color: #000; }
.xta::placeholder { color: #a0a0a8; }
.xta::selection { background: rgba(45, 91, 215, .22); color: transparent; }
.xta:focus { outline: 2px solid rgba(45, 91, 215, .35); border-color: #2d5bd7; }
.xbox.bad .xta { border-color: #d9534f; }
.xpop { position: absolute; left: 0; right: 0; top: 100%; z-index: 4; background: #fff; border: 1px solid #c9c9d1; box-shadow: 0 6px 18px rgba(0,0,0,.14); font-size: 12px; color: var(--fg); max-height: 260px; overflow: auto; }
.xi { padding: 5px 8px; cursor: pointer; font-family: Consolas, "SF Mono", Menlo, monospace; }
.xi em { float: right; font-style: normal; color: var(--muted); font-family: var(--sans); font-size: 11px; }
.xi small { display: block; color: var(--muted); font-family: var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xi.on, .xi:hover { background: #e8efff; }
.xtip { padding: 3px 8px; color: var(--muted); font-size: 11px; border-top: 1px solid #f0f0f3; }
.xsig { padding: 6px 8px 2px; }
.xsig code { background: none; padding: 0; font-size: 12.5px; }
.xsig b { color: #2d5bd7; text-decoration: underline; }
.xsig em, .fn em { font-style: normal; font-size: 11px; color: #0000ff; }
.xarg { padding: 2px 8px; } .xarg.bad { color: #b3261e; }
.xdesc { padding: 2px 8px 7px; color: var(--muted); }

/* token colors: VS Code "Light+" theme */
/* blue variables, red operators, dark green functions (as asked in Changes V2); the rest from VS Code's light theme */
.t-fn { color: #116329; font-weight: 600; }
.t-var { color: #0070c1; }
.t-tick, .t-str { color: #267f99; }
.t-num { color: #795e26; }
.t-kw { color: #af00db; }
.t-op { color: #c41a16; }
.t-comma { color: #000000; }
.t-b0 { color: #0431fa; } .t-b1 { color: #319331; } .t-b2 { color: #7b3814; }
.t-bad { color: #e51400; background: rgba(229, 20, 0, .08); text-decoration: underline wavy #e51400; text-decoration-skip-ink: none; }
.t-err { text-decoration: underline wavy #e51400; text-decoration-skip-ink: none; }
.wlabel .t-bad, .wlabel .t-err { text-decoration: none; }
.legend2 { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.8; }
.legend2 span { margin-right: 8px; white-space: nowrap; }

/* running */
#tools select { width: auto; padding: 3px 4px; }
#tools .run.stop { background: #b3261e; border-color: #b3261e; }
.block.live .body { box-shadow: 0 0 0 3px #2e9d5b, 0 0 18px rgba(46, 157, 91, .55); }
.wire.taken { stroke: #2e9d5b; stroke-width: 3.5; }
.progress { height: 6px; background: #ececef; margin: 4px 0 8px; }
.progress span { display: block; height: 100%; background: #2e9d5b; transition: width .1s linear; }
#tools { max-width: calc(100% - 404px); flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 760px) {
  #menu { width: auto; right: 16px; top: auto; height: 42%; }
  #tools { flex-wrap: wrap; left: 16px; max-width: none; justify-content: flex-start; }
  #results { left: 16px; width: auto; top: auto; height: 60%; }
  #empty { padding: 0 16px; }
}

/* ---------- Changes V3 ---------- */
/* arrow labels pushed off their arrow (to stop overlaps) get a thin line back to it */
#wires .leader { stroke: #b9b9c2; stroke-width: 1; stroke-dasharray: 3 3; fill: none; pointer-events: none; }
#wires .leader.sel { stroke: #2d5bd7; }

/* the portfolio tile while a run plays: read-only holdings */
#ctile.running #assets, #ctile.running .csets, #ctile.running #addAsset { display: none; }
#livepf table { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
#livepf th { text-align: right; font-weight: 600; color: var(--muted); font-size: 10.5px; padding: 0 3px 3px; border-bottom: 1px solid #ececef; }
#livepf td { text-align: right; padding: 3px; border-bottom: 1px solid #f3f3f6; white-space: nowrap; }
#livepf th:first-child, #livepf td:first-child { text-align: left; font-weight: 600; }
#livepf tr.none td { color: #a0a0a8; }
#livepf .live-tag { font-size: 11px; color: #2e9d5b; font-weight: 600; margin: 0 0 4px; }
#livepf small { display: block; font-size: 10px; }

.apicalls { font-size: 12px; margin: 0; color: var(--muted); }
.apicalls b { color: var(--fg); }

/* Results: one box per price / indicator / portfolio function the strategy uses */
.readouts { display: grid; gap: 8px; }
.readout { border: 1px solid #ececef; background: #fcfcfd; padding: 8px 10px; }
.readout .rh { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.readout .rh b { font-size: 13px; }
.readout .rh .tk { font-size: 12px; font-weight: 600; color: #267f99; }
.readout code { display: block; font-size: 11.5px; color: var(--muted); margin: 2px 0 6px; }
.readout .rv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.readout .rv span { display: block; font-size: 10.5px; color: var(--muted); }
.readout svg { width: 100%; height: 34px; margin-top: 6px; display: block; }
.readout svg polyline { fill: none; stroke: #2d5bd7; stroke-width: 1.5; vector-effect: non-scaling-stroke; }

/* landing page (like the Scale of Math start screen): fades out when Start is pressed */
.landing { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  padding: calc(56px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px)); overflow: auto;
  background: linear-gradient(180deg, #f7fbf8 0%, #e6f3ea 100%); transition: opacity .45s linear; user-select: text; }
.landing[hidden] { display: none; }
.landing.leaving { opacity: 0; pointer-events: none; }
.landing .hsky { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; height: 45%; pointer-events: none; }
.landing .more { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; }
.landing .hbox { position: relative; box-sizing: border-box; max-width: min(680px, 100%); padding: clamp(20px, 5vw, 36px) clamp(20px, 6vw, 48px);
  background: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.12); border-top: 4px solid #2e9d5b; }
.landing h1 { font-size: clamp(2rem, 8vw, 3.2rem); line-height: 1.1; margin: 0; letter-spacing: -.01em; }
.landing .hsub { margin: 12px 0 16px; font-size: clamp(.95rem, 2.6vw, 1.1rem); color: var(--muted); }
.landing .hsteps { margin: 0 0 12px; padding-left: 1.3em; font-size: 15px; }
.landing .hsteps li { margin: 0 0 8px; }
.landing code { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: .9em; background: #f3f3f6; padding: 0 4px; }
.landing .hnote { margin: 0; font-size: 13px; color: var(--muted); }
.landing .hstart { position: relative; font: inherit; font-size: 1.2rem; font-weight: 600; padding: 12px 48px; border: none; background: #2e9d5b; color: #fff;
  cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.landing .hstart:hover { background: #237a46; }
.landing .hstart:focus-visible { outline: 2px solid #2d5bd7; outline-offset: 3px; }
@media (max-height: 640px) { .landing { justify-content: flex-start; } }
@media (prefers-reduced-motion: reduce) { .landing { transition: none; } }

/* ========== Windows 95 look ==========
   Overrides the rules above. Palette: face #c0c0c0, light #dfdfdf, highlight #fff, shadow #808080, dark #0a0a0a, title bar navy #000080.
   Raised = buttons and windows; sunken = text fields and wells. Titles: Franklin Gothic; everything else: MS Sans Serif. */
:root { --face: #c0c0c0; --navy: #000080; --muted: #404040; --line: #808080; --link: #000080;
  --sans: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Geneva, Arial, sans-serif;
  --title: "Franklin Gothic Medium", "Franklin Gothic", "ITC Franklin Gothic", "Libre Franklin", "Arial Narrow", Arial, sans-serif;
  --raised: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
  --pressed: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080;
  --sunken: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a; }
body { font-family: var(--sans); font-size: 13px; color: #000; background: var(--face); }
h1, h2, h3, .crumb, .landing h1 { font-family: var(--title); letter-spacing: 0; }
::selection { background: var(--navy); color: #fff; }

/* desktop: opaque squares over a slow light-blue-to-green diagonal gradient.
   The gradient layer drifts on its own (cheap: transform only); the gaps between squares pan and zoom with the grid. */
#app { background: #9fd3e8; }
#app::before, .landing::before { content: ""; position: absolute; left: 0; top: 0; width: 200vmax; height: 200vmax; pointer-events: none;
  background: linear-gradient(135deg, #a8d8f0 0%, #7fcf9a 25%, #a8d8f0 50%, #7fcf9a 75%, #a8d8f0 100%);
  animation: w95drift 60s linear infinite; will-change: transform; }
@keyframes w95drift { to { transform: translate(-50%, -50%); } }   /* exactly one period of the gradient, so the loop has no seam */
#grid { background-color: transparent; background-size: 20px 20px;
  background-image: linear-gradient(to right, rgba(255,255,255,.6) 1.5px, transparent 1.5px), linear-gradient(to bottom, rgba(255,255,255,.6) 1.5px, transparent 1.5px); }
#empty { color: #000; text-shadow: 0 0 6px rgba(255,255,255,.9); }

/* windows */
.panel, #ctile, .block .body, .landing .hbox { background: var(--face); border: none; border-radius: 0; box-shadow: var(--raised), 2px 2px 0 rgba(0,0,0,.18); }
#menu, #results { padding: 0 8px 10px; }
.phead { position: sticky; top: 0; z-index: 2; margin: 0 -8px 8px; padding: 3px 3px 3px 6px; background: var(--navy); color: #fff; border: 3px solid var(--face); border-bottom-width: 2px; }
.phead h2 { font-size: 13px; font-weight: 700; font-family: var(--sans); }
#menu > .back { margin-top: 8px; }
.x, #results .x { width: 18px; height: 16px; padding: 0; font-size: 13px; line-height: 13px; font-weight: 700; color: #000; background: var(--face); box-shadow: var(--raised); }
.x:hover { color: #000; } .x:active { box-shadow: var(--pressed); }

/* portfolio tile: a window with a navy title bar */
#ctile { padding: 3px 8px 10px; }
#ctile .chead { margin: 0 -5px 8px; padding: 2px 3px 2px 6px; background: var(--navy); color: #fff; }
#ctile .chead h2 { font-size: 13px; font-weight: 700; font-family: var(--sans); }
#ctile .chead .add { width: 18px; height: 16px; font-size: 14px; line-height: 12px; }
.csets, .total { border-top: 1px solid #808080; box-shadow: inset 0 1px #fff; }
.asset { border-top: 1px solid #a0a0a0; }
.keybox { background: var(--face); border: none; border-radius: 0; box-shadow: var(--sunken); padding: 8px 10px; }
.keybox[hidden] { display: none; }   /* display:grid above was overriding [hidden], so the key box showed for every price source */

/* blocks: like inactive windows (grey title bar); the selected one goes navy */
.block .body { padding: 3px; }
.block h3 { padding: 3px 6px; font-size: 13px; border: none; background: #808080; color: #fff; font-family: var(--sans); font-weight: 700; }
.block.sel .body { box-shadow: var(--raised), 0 0 0 2px var(--navy); }
.block.sel h3 { background: var(--navy); color: #fff; }
.block h3 .tag { color: #fff; background: #008000; padding: 0 4px; }
.block.start .body { border-left: none; }
.block.drop .body { background: #d4d0c8; }
.block:hover .edge { border-color: rgba(0, 0, 128, .15); }
.block.live .body { box-shadow: var(--raised), 0 0 0 3px #008000, 0 0 16px rgba(0, 128, 0, .5); }
.chips { padding: 5px 3px 3px; }
.chip { background: #fff; box-shadow: var(--sunken); padding: 5px 8px; border-left: none; }
.chip.sel { background: var(--navy); color: #fff; } .chip.sel span { color: #dfdfdf; }
.chip.bad { box-shadow: var(--sunken), inset 3px 0 0 #c00000; }

/* buttons */
.add, #tools button, .btn, .tool, button.mini, .card .ch .mv, .landing .hstart, .w95btn, .top.bar .more, .landing .more {
  background: var(--face); color: #000; border: none; border-radius: 0; box-shadow: var(--raised); text-shadow: none; filter: none; }
.add:hover, #tools button:hover, .btn:hover, .tool:hover, .landing .hstart:hover, .top.bar .more:hover, .landing .more:hover { background: var(--face); filter: none; }
.add:active, #tools button:active, .btn:active, .tool:active, button.mini:active, .card .ch .mv:active, .landing .hstart:active, .w95btn:active,
  .top.bar .more:active, .landing .more:active { box-shadow: var(--pressed); }
.add:focus-visible, #tools button:focus-visible, .btn:focus-visible, .tool:focus-visible, .landing .hstart:focus-visible, .w95btn:focus-visible {
  outline: 1px dotted #000; outline-offset: -5px; }
.btn:disabled { color: #808080; text-shadow: 1px 1px 0 #fff; background: var(--face); }
.btn.danger { color: #800000; } .btn.danger:hover { background: var(--face); }
.tool { padding: 6px 10px; }
.tool b { font-weight: 700; font-size: 13px; }
.tool span { color: #404040; font-size: 11px; }
#tools { padding: 4px; gap: 4px; }
#tools button { padding: 3px 10px; min-height: 23px; }
#tools .run { background: var(--face); color: #000; font-weight: 700; padding: 3px 14px; }
#tools .run:hover { background: var(--face); }
#tools .run.stop { background: var(--face); color: #800000; }
.sep { width: 2px; height: 20px; background: none; border-left: 1px solid #808080; border-right: 1px solid #fff; box-sizing: border-box; }
#zoom { color: #000; }
#starttab { background: var(--face); color: #000; font-weight: 700; padding: 3px 12px 4px; box-shadow: var(--raised); }
#starttab:hover, #app.picking #starttab { background: var(--face); box-shadow: var(--pressed); }
.back { color: var(--navy); text-decoration: underline; }

/* text fields and wells: sunken white */
input, select, .xhl, .xta { border: none; border-radius: 0; box-shadow: var(--sunken); background-color: #fff; color: #000; }
input, select { font-family: var(--sans); padding: 4px 6px; }
.xta { background: transparent; color: transparent; }
input:focus, select:focus, .xta:focus { outline: 1px dotted #000; outline-offset: -4px; border: none; }
input.bad, .xbox.bad .xta { box-shadow: var(--sunken), 0 0 0 1px #c00000; }
code { background: #fff; color: #000; }
label.f { color: #000; }
.muted { color: #404040; }
small.err { color: #c00000; }
.card { background: var(--face); border: none; box-shadow: var(--sunken); padding: 8px 10px; }
.card.open { box-shadow: var(--sunken), 0 0 0 1px var(--navy); }
.fns { border-top: 1px solid #808080; }
.fn:hover, .xi.on, .xi:hover { background: var(--navy); color: #fff; }
.fn:hover code, .xi.on em, .xi.on small, .xi:hover em, .xi:hover small, .fn:hover span { color: #fff; }
.fn code, .xsig b { color: var(--navy); }
.xpop { background: #fff; border: 1px solid #000; box-shadow: 2px 2px 0 rgba(0,0,0,.35); }
.group { color: #000; font-weight: 700; border-bottom: 1px solid #808080; box-shadow: 0 1px 0 #fff; padding-bottom: 2px; }

/* results */
.figs div, .readout { background: #fff; border: none; box-shadow: var(--sunken); }
.chart { background: #fff; border: none; box-shadow: var(--sunken); }
.chart .strat, .readout svg polyline { stroke: var(--navy); } .legend .k.strat { background: var(--navy); }
.up { color: #008000; } .down { color: #c00000; }
.progress { height: 16px; background: #fff; box-shadow: var(--sunken); padding: 3px; }
.progress span { background: repeating-linear-gradient(90deg, var(--navy) 0 8px, transparent 8px 10px); }   /* blocky progress bar */
.log li { border-bottom: 1px solid #a0a0a0; }
#livepf th, #livepf td { border-bottom-color: #a0a0a0; } #livepf .live-tag { color: #008000; }

/* arrows and labels */
.wire.sel, .wire.temp { stroke: var(--navy); } .wire.start, .wire.temp.start, .wire.taken { stroke: #008000; }
.wlabel { background: #ffffe1; border: 1px solid #000; color: #000; border-radius: 0; }
.wlabel .pri { background: var(--face); }
.wlabel.sel { border-color: var(--navy); color: #000; box-shadow: 0 0 0 1px var(--navy); }
#wires .leader.sel { stroke: var(--navy); }
#hint { background: #ffffe1; color: #000; border: 1px solid #000; box-shadow: 2px 2px 0 rgba(0,0,0,.3); }
.ghost { background: var(--face); border: none; box-shadow: var(--raised), 3px 3px 0 rgba(0,0,0,.3); }

/* top bar: a grey menu bar */
.top.bar { background: var(--face); border-bottom: none; box-shadow: inset 0 -1px #808080, inset 0 1px #fff; padding-top: calc(4px + env(safe-area-inset-top, 0px)); padding-bottom: 4px; }
.crumb { font-size: 16px; font-weight: 600; }
.priv { color: #000; }
.top.bar .more { padding: 3px 10px; font-size: 12px; }

/* scrollbars: checkered track, raised thumb (Chrome, Edge, Safari; Firefox gets plain grey ones) */
* { scrollbar-color: #c0c0c0 #dfdfdf; }
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: repeating-conic-gradient(#c0c0c0 0 25%, #fff 0 50%) 0 0 / 2px 2px; }
::-webkit-scrollbar-thumb { background: var(--face); box-shadow: var(--raised); }

/* landing page: a dialog window on the desktop, with a taskbar at the bottom */
.landing { background: #9fd3e8; padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px)); }
.landing::before { position: fixed; }
.landing::after { content: ""; position: fixed; inset: 0; pointer-events: none; background-size: 20px 20px;
  background-image: linear-gradient(to right, rgba(255,255,255,.6) 1.5px, transparent 1.5px), linear-gradient(to bottom, rgba(255,255,255,.6) 1.5px, transparent 1.5px); }
.landing .hbox { z-index: 2; padding: 3px; max-width: min(640px, 100%); border-top: none; }
.landing .htbar { display: flex; align-items: center; gap: 4px; padding: 3px 3px 3px 6px; background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; }
.landing .htbar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.landing .htbar .w95btn { width: 18px; height: 16px; padding: 0; font: 700 11px/12px var(--sans); }
.landing .hin { padding: clamp(14px, 4vw, 24px) clamp(14px, 4vw, 28px) 16px; }
.landing h1 { font-size: clamp(1.9rem, 7vw, 2.8rem); font-weight: 600; }
.landing .hsub { color: #000; font-size: 14px; }
.landing .hsteps { font-size: 13px; padding: 12px 12px 4px 2.4em; background: #fff; box-shadow: var(--sunken); }
.landing .hnote { color: #404040; font-size: 12px; margin-top: 12px; }
.landing code { font-family: "Courier New", Consolas, monospace; background: #ffffe1; }
.landing .hfoot { display: flex; justify-content: flex-end; padding: 0 clamp(14px, 4vw, 28px) 14px; }
.landing .hstart { font-size: 13px; font-weight: 700; padding: 5px 0; min-width: 96px; }
.landing .taskbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 4px;
  padding: 3px 3px calc(3px + env(safe-area-inset-bottom, 0px)); background: var(--face); box-shadow: inset 0 1px #dfdfdf, inset 0 2px #fff; }
.landing .taskbar .w95btn { display: flex; align-items: center; gap: 5px; padding: 3px 8px; min-height: 26px; font: 700 13px var(--sans); cursor: pointer; }
.landing .taskbar .logo { width: 16px; height: 14px; flex: none; background: conic-gradient(#ff0000 0 25%, #00a000 0 50%, #ffcc00 0 75%, #0050ff 0); transform: skewY(-6deg); }
.landing .more { position: static; font-size: 13px; padding: 3px 10px; min-height: 26px; display: flex; align-items: center; color: #000; text-decoration: none; }
.landing .clock { margin-left: auto; padding: 4px 10px; box-shadow: var(--sunken); font-size: 12px; min-width: 64px; text-align: center; }
@media (min-width: 761px) { #results { top: calc(var(--tools-h, 40px) + 24px); } }
/* phones: Results fills the space under the toolbar, and the Actions panel steps aside until Results is closed */
@media (max-width: 760px) { #results { top: calc(var(--tools-h, 40px) + 24px); height: auto; bottom: 16px; }
  #app:has(#results:not([hidden])) #menu { display: none; } }
.panel { z-index: 1; }   /* keeps each panel's sticky title bar inside its own window */
.crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.priv, .top.bar .more { white-space: nowrap; }
@media (max-width: 480px) { .top.bar { gap: 8px; } .crumb { font-size: 14px; } .priv { font-size: 11px; } }
@media (prefers-reduced-motion: reduce) { #app::before, .landing::before { animation: none; } }

/* "i" button (same size, shape and corner as The Size of All Numbers) and the About window above it */
.infob { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 30; width: 44px; height: 44px; padding: 0;
  border: none; border-radius: 0; background: var(--face); color: #000; font: 700 1.25rem/1 var(--sans); cursor: pointer; box-shadow: var(--raised), 2px 2px 0 rgba(0,0,0,.18); }
.infob:active, .infob[aria-expanded="true"] { box-shadow: var(--pressed); }
.infob:focus-visible { outline: 1px dotted #000; outline-offset: -6px; }
.infop { position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); z-index: 30; width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 140px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; padding: 0 8px 8px; user-select: text; touch-action: pan-y; }
.infop[hidden] { display: none; }
.infop .phead { position: static; flex: none; }
.infop .ib { overflow: auto; padding: 0 6px 6px; }
.infop h3 { font-family: var(--title); font-size: 16px; font-weight: 600; margin: 12px 0 4px; }
.infop h3:first-child { margin-top: 4px; }
.infop p { margin: 0 0 8px; line-height: 1.45; }
.infop .ifoot { flex: none; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 6px 2px; border-top: 1px solid #808080; box-shadow: inset 0 1px #fff; }
.infop .ifoot a { color: var(--navy); }
.infop .ifoot .btn { margin-left: auto; padding: 4px 12px; cursor: pointer; }
.keyf { margin: 4px 0; }
.keyf .keyrow input { font-family: "Courier New", Consolas, monospace; }
#results { bottom: 72px; }   /* clear of the i button */
@media (max-width: 760px) { #results { bottom: 72px; } #menu { bottom: 72px; } }

/* landing: just the title, the Tiingo note and a key box */
.landing .hkeynote { margin: 14px 0 12px; font-size: 14px; line-height: 1.5; color: #000; }
.landing .hkeynote b { color: #800000; }
.landing .keyf { font-size: 12px; }

/* banner slot and cookie bar (../footbar.js), Windows 95 style. The slot sits below the workspace (data-flow),
   so the i button and its window live inside #app and stay above it. */
.infob, .infop { position: absolute; }
.infop { max-height: calc(100% - 100px); }
.footbar.flow { background: var(--face); box-shadow: inset 0 1px #dfdfdf, inset 0 2px #fff; }
.fbox { background: #fff; box-shadow: var(--sunken); }
.consent { background: var(--face); color: #000; box-shadow: var(--raised), 3px 3px 0 rgba(0,0,0,.3); font-family: var(--sans); font-size: 13px; }
.consent a { color: var(--navy); }
.cbtns button { background: var(--face); color: #000; box-shadow: var(--raised); min-width: 88px; font-family: var(--sans); font-size: 13px; padding: 5px 14px; }
.cbtns button:active { box-shadow: var(--pressed); }
.cbtns button:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.infop .ifoot .btn + .btn { margin-left: 0; }
:root:not([data-slot]) .consent { bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }   /* landing page: above the taskbar */

/* Tiingo key boxes: text fields masked with CSS (not type=password, which makes browsers offer to save the key) */
.tkey.masked { -webkit-text-security: disc; }
@supports not (-webkit-text-security: disc) { .tkey.masked:not(:placeholder-shown) { color: transparent; text-shadow: 0 0 6px rgba(0,0,0,.8); caret-color: #000; } }
