/* Functions: graphing + geometry. Builds on calc.css; one colour per curve, quiet everything else. */
main.fx { max-width: none; padding: 0 16px 16px; display: block; }
.fx-work { display: grid; grid-template-columns: 372px minmax(0, 1fr); gap: 12px; height: calc(100vh - 76px); height: calc(100dvh - 76px); min-height: 520px; }
.fx-flex { flex: 1; }

/* ---------- expression list ---------- */
.fx-list { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.fx-list-bar { display: flex; align-items: center; gap: 2px; padding: 8px 8px; border-bottom: 1px solid var(--line); }
.fx-list-bar > .ghost { font-size: 12.5px; padding: 4px 7px; white-space: nowrap; }
.fx-help-btn { width: 26px; height: 26px; padding: 0 6px !important; border-radius: 50% !important; border: 1px solid var(--line) !important; font-weight: 500; }
.fx-help-btn[aria-expanded="true"] { background: var(--text); color: var(--on-accent); border-color: var(--text) !important; }
.fx-rows { flex: 1; overflow: auto; scrollbar-width: thin; min-height: 0; }

.fx-row { --c: var(--text-3); position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto 28px; border-bottom: 1px solid var(--fill-1); min-height: 50px; background: var(--surface); }
.fx-row.sel .fx-gut { box-shadow: inset 3px 0 0 var(--c); }
.fx-row.edit .fx-main { background: var(--surface); }
.fx-row.dragging { z-index: 3; box-shadow: 0 6px 20px rgba(0,0,0,.10); border-radius: 6px; }
.fx-gut { display: flex; flex-direction: column; align-items: center; gap: 5px; padding-top: 7px; background: var(--surface-2); border-right: 1px solid var(--fill-1); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.fx-row.sel .fx-gut { background: color-mix(in srgb, var(--c) 7%, var(--surface-2)); }
.fx-n { font-size: 10.5px; color: var(--text-3); line-height: 1; }
.fx-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--c); background: var(--c); padding: 0; cursor: pointer; position: relative; flex: none; }
.fx-dot.off { background: var(--surface); }
.fx-dot.none { visibility: hidden; }
.fx-dot.err { border-color: var(--bad); background: var(--surface); }
.fx-dot.err::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--bad); }
.fx-dot:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.fx-dot svg { position: absolute; inset: -2px; }
.fx-main { padding: 9px 6px 8px 12px; min-width: 0; cursor: text; }
.fx-in { display: none; width: 100%; border: 0; outline: none; font: 400 15px/1.5 var(--font); padding: 1px 0; background: transparent; color: var(--text); }
.fx-row.edit .fx-in { display: block; }
.fx-in::placeholder { color: var(--faint); }
.fx-tex { min-height: 24px; font-size: 15px; line-height: 1.5; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; white-space: nowrap; color: var(--text); }
.fx-tex::-webkit-scrollbar { display: none; }
.fx-tex .katex { font-size: 1.1em; }
.fx-tex .raw { color: var(--text); }
.fx-tex .ph { color: var(--faint); }
.fx-row.edit .fx-tex { min-height: 0; font-size: 12px; color: var(--text-3); padding-top: 1px; }
.fx-row.edit .fx-tex:empty { display: none; }
.fx-row.edit .fx-tex .katex { font-size: 1.05em; color: var(--text-2); }
.fx-res { align-self: center; padding: 0 4px 0 6px; color: var(--text-2); font-size: 13.5px; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.fx-res b { font-weight: 500; color: var(--text); }
.fx-res:empty { padding: 0; }
.fx-row > .x { align-self: center; opacity: 0; }
.fx-row:hover > .x, .fx-row.edit > .x, .fx-row > .x:focus { opacity: 1; }
.fx-sub:empty { display: none; }
.fx-sub { display: grid; gap: 5px; margin-top: 5px; }
.fx-err { color: var(--bad); font-size: 12px; line-height: 1.35; }
.fx-info { color: var(--text-3); font-size: 12px; line-height: 1.4; }
.fx-info b { color: var(--text-2); font-weight: 500; }
.fx-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; color: var(--text-3); }
.fx-chips .chip { padding: 1px 9px; }
.fx-ghost { opacity: .9; }
.fx-ghost .fx-gut { background: var(--surface-2); }
.fx-ghost .fx-n { color: var(--faint); }

/* note rows */
.fx-row.note { grid-template-columns: 36px minmax(0, 1fr) 28px; min-height: 40px; }
.fx-row.note .fx-gut { background: var(--surface); }
.fx-note { width: 100%; border: 0; outline: none; resize: none; font: 400 13px/1.45 var(--font); color: var(--text-2); background: transparent; padding: 0; overflow: hidden; }

/* slider + domain lines */
.fx-sl { display: grid; grid-template-columns: 22px 46px minmax(0, 1fr) 46px; align-items: center; gap: 4px; }
.fx-sl.step { grid-template-columns: 22px 46px minmax(0, 1fr) 46px 64px; }
.fx-lim { border: 0; background: transparent; font: 400 11.5px var(--font); color: var(--text-3); width: 100%; text-align: center; padding: 2px 3px; border-radius: 5px; outline: none; font-variant-numeric: tabular-nums; }
.fx-lim:hover { background: var(--bg); }
.fx-lim:focus { background: var(--fill-1); color: var(--text); }
.fx-lim.bad { color: var(--bad); }
.fx-stepw { display: flex; align-items: center; gap: 2px; font-size: 11px; color: var(--text-3); }
.fx-play { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); cursor: pointer; padding: 0; display: grid; place-items: center; }
.fx-play:hover { border-color: var(--text-2); color: var(--text); }
.fx-play.on { background: var(--c); border-color: var(--c); color: var(--on-accent); }
input[type=range].fx-range { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; --p: 50%; }
.fx-range::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--c) var(--p), var(--line) var(--p)); }
.fx-range::-moz-range-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--c) var(--p), var(--line) var(--p)); }
.fx-range::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; margin-top: -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--c); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.fx-range::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 2px solid var(--c); }
.fx-range:focus { outline: none; }
.fx-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.fx-dom { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); }
.fx-dom .fx-lim { width: 56px; background: var(--bg); }
.fx-dom .fx-lim:focus { background: var(--fill-1); }

/* tables */
.fx-row.tbl .fx-main { cursor: default; padding-right: 0; }
.fx-tw { overflow-x: auto; margin-right: 6px; }
table.sheet.fx-sheet { width: auto; min-width: 100%; table-layout: auto; }
.fx-sheet th { padding: 0; background: var(--surface-2); text-align: right; }
.fx-sheet th .fx-hd { display: flex; align-items: center; gap: 4px; padding: 0 4px 0 7px; }
.fx-sheet th input { height: 30px; font-weight: 500; color: var(--text); text-align: right; padding: 0 2px; min-width: 52px; }
.fx-sheet td input { min-width: 64px; }
.fx-sheet .fx-dot { width: 12px; height: 12px; border-width: 2px; }
.fx-sheet td.rn, .fx-sheet th.rn { width: 28px; padding: 0 6px; }
.fx-tbl-act { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; font-size: 12px; color: var(--text-3); }

/* help */
.fx-help { border-bottom: 1px solid var(--line); padding: 10px 14px 12px; max-height: 46%; overflow: auto; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); scrollbar-width: thin; }
.fx-help h3 { font-size: 11.5px; font-weight: 600; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; margin: 10px 0 4px; }
.fx-help h3:first-child { margin-top: 0; }
.fx-help dl { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 2px 10px; margin: 0; }
.fx-help dt { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--text); cursor: pointer; border-radius: 4px; padding: 1px 4px; margin-left: -4px; }
.fx-help dt:hover { background: var(--fill-1); }
.fx-help dd { margin: 0; color: var(--text-3); padding: 1px 0; }
.fx-help p { margin: 8px 0 0; color: var(--text-3); }

/* ---------- graph ---------- */
.fx-stage { position: relative; display: flex; flex-direction: column; overflow: hidden; min-width: 0; min-height: 0; }
.fx-bar { flex-wrap: nowrap; padding: 8px 10px; }
.fx-bar .hint { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-tools { flex: none; }
.fx-tools button { display: grid; place-items: center; padding: 3px 7px; }
.fx-tools svg { display: block; }
.fx-plot { position: relative; flex: 1; min-height: 0; background: var(--surface); }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
#cv.pan { cursor: grab; }
#cv.grab { cursor: grab; }
#cv.grabbing { cursor: grabbing; }
#cv.ptr { cursor: pointer; }
.fx-zoom { position: absolute; right: 10px; top: 10px; display: grid; gap: 4px; }
.fx-zoom button { width: 30px; height: 30px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text-2); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 7px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.fx-zoom button:hover { border-color: var(--line-2); color: var(--text); }
.fx-zoom button[aria-pressed="true"] { color: var(--text); border-color: var(--text-2); }
.fx-zoom button[aria-pressed="false"] { color: var(--text-3); }
.fx-tip { position: absolute; left: 0; top: 0; pointer-events: none; transform: translate(-50%, calc(-100% - 12px)); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px; font-size: 12px; color: var(--text); white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.06); font-variant-numeric: tabular-nums; }
.fx-tip[hidden] { display: none; }

/* colour popover + toast */
.fx-pop { position: fixed; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.12); padding: 8px; display: grid; gap: 8px; }
.fx-pop[hidden] { display: none; }
.fx-sw { display: flex; gap: 6px; }
.fx-sw button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; padding: 0; }
.fx-sw button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c); }
.fx-pop .seg { width: 100%; }
.fx-pop .seg button { display: grid; place-items: center; }
.fx-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--text); color: var(--on-accent); font-size: 13px; border-radius: 9px; padding: 8px 14px; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.fx-toast[hidden] { display: none; }

@media (max-width: 860px) {
  .fx-work { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .fx-list { max-height: none; }
  .fx-rows { max-height: 46vh; }
  .fx-stage { height: 72vh; height: 72dvh; min-height: 360px; }
  .fx-bar { overflow: visible; }
  .fx-tools { flex: 1 1 auto; display: flex; flex-wrap: wrap; }   /* the construction tools wrap instead of being clipped */
  .fx-bar .hint { display: none; }
}
@media (max-width: 560px) {
  main.fx { padding: 0 10px 12px; }
  .bar { flex-wrap: wrap; gap: 8px; }
  .export > span { display: none; }
  .fx-list-bar > .ghost { padding: 4px 5px; }
}
.fx-ghost .fx-in { display: block; }
.fx-ghost .fx-main { cursor: text; }

/* theme-auto:start · generated by scripts/theme/hexmap.py: dark values (the rule of scripts/theme/colour.py) for
   colours that are not tokens, written as var(--x-rrggbb, #rrggbb): light is the fallback, unchanged */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --x-f4f4f1: #292724; --x-ffffff: #23211e;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-f4f4f1: #292724; --x-ffffff: #23211e;
  }
}
/* theme-auto:end */
