/* xpsflow workbench — the same system as the PDF report:
   bone paper, graphite ink, emission green for "good", anode copper for "review".
   Product register: one task, dense and calm; motion conveys state only. */
:root {
  --paper: #F6F6F1; --paper-2: #ECEDE6; --paper-3: #E3E4DC; --white: #FFFFFF;
  --ink: #15171A; --ink-2: #3E4247; --muted: #5F646B; --line: #D9DBD3; --line-2: #C9CBC3;
  --acc: #0F9D6B; --acc-d: #0A7A53; --acc-s: #DDF3E8; --cu: #C0632B; --cu-s: #F7E7DB; --red: #B4283C; --red-s: #F6DFE3; --steel: #5B6B7A;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Inter Tight", "Inter", system-ui, sans-serif;
  --r: 8px; --r-s: 6px;
  --t-fast: 150ms; --t: 220ms; --ease: cubic-bezier(.22, 1, .36, 1);
  --z-sticky: 10; --z-popover: 20; --z-toast: 40; --z-dialog: 50;
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--acc);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); font-size: 13.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
.app { display: grid; grid-template-columns: 300px minmax(0, 1fr) 380px; height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font-family: var(--sans); cursor: pointer; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); }
kbd { font-family: var(--mono); font-size: 10.5px; background: var(--white); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--ink-2); }

/* the trace: a spectrum drawn as the divider */
.trace { display: block; width: 100%; height: 22px; margin: 8px 0 2px; }

/* ------------------------------------------------------------------ rail */
.rail { border-right: 1px solid var(--line); padding: 18px 16px 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; background: var(--paper); min-height: 0; }
.brand-row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { font-family: var(--display); font-size: 23px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.brand-mark span { color: var(--acc); }
.icon-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); font-family: var(--mono); font-size: 12px; color: var(--muted); transition: border-color var(--t-fast), color var(--t-fast); }
.icon-btn:hover { border-color: var(--ink); color: var(--ink); }

.upload { display: flex; align-items: center; gap: 12px; border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 12px 14px; cursor: pointer; background: var(--white); color: var(--ink-2); transition: border-color var(--t-fast), background var(--t-fast), transform var(--t) var(--ease); }
.upload:hover, .upload.drag { border-color: var(--acc); background: var(--acc-s); color: var(--acc-d); }
.upload.drag { transform: scale(1.015); }
.upload input { display: none; }
.upload-title { font-weight: 600; color: var(--ink); }
.upload-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* primary run button with the step rail underneath */
.run { display: flex; flex-direction: column; gap: 8px; }
.primary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: var(--r); padding: 11px 12px; font-weight: 600; font-size: 13.5px; transition: background var(--t-fast), transform var(--t-fast); }
.primary .n { color: #7FE0B8; font-size: 11px; }
.primary:hover:not(:disabled) { background: var(--acc-d); border-color: var(--acc-d); }
.primary:active:not(:disabled) { transform: scale(.985); }
.primary:disabled { background: var(--paper-3); border-color: var(--paper-3); color: var(--muted); cursor: default; }
.primary.running { background: var(--acc-d); border-color: var(--acc-d); }
.steps { list-style: none; margin: 0; padding: 0 2px; display: flex; justify-content: space-between; position: relative; }
.steps::before { content: ""; position: absolute; left: 7px; right: 7px; top: 5px; height: 2px; background: var(--line); }
.steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); width: 20%; }
.steps li i { width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--line-2); transition: background var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t) var(--ease); }
.steps li.active i { border-color: var(--acc); background: var(--paper); animation: breathe 1.1s ease-in-out infinite; }
.steps li.done i { background: var(--acc); border-color: var(--acc); transform: scale(1.05); }
.steps li.review i { background: var(--cu); border-color: var(--cu); }
.steps li.done span, .steps li.active span { color: var(--ink); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(15,157,107,.35) } 50% { box-shadow: 0 0 0 5px rgba(15,157,107,0) } }

.section-title { font-size: 11.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-title .count { font-family: var(--mono); color: var(--muted); font-weight: 500; font-size: 10.5px; }

.spectra { display: flex; flex-direction: column; gap: 2px; min-height: 40px; flex-shrink: 0; }
.sample { margin-top: 4px; }
.sample .sample-name { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); padding: 4px 6px 2px; letter-spacing: .01em; }
.sample .sample-name b { font-weight: 500; color: var(--ink-2); }
.sample .sample-name .n { margin-left: auto; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; cursor: pointer; border-radius: var(--r-s); border: 1px solid transparent; transition: background var(--t-fast), border-color var(--t-fast); position: relative; }
.row:hover { background: var(--paper-2); }
.row[aria-selected="true"] { background: var(--white); border-color: var(--line); }
.row[aria-selected="true"]::before { content: ""; position: absolute; left: -1px; top: 7px; bottom: 7px; width: 2px; background: var(--acc); border-radius: 2px; }
.row .name { font-weight: 600; font-size: 13px; }
.row .sub { color: var(--muted); font-size: 10.5px; font-family: var(--mono); margin-top: 1px; }
.row .marks { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 500; padding: 2px 7px 2px 6px; border-radius: 999px; white-space: nowrap; background: var(--paper-2); color: var(--ink-2); animation: chip-in var(--t) var(--ease); }
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip.excellent, .chip.good, .chip.pass, .chip.high, .chip.ok { background: var(--acc-s); color: var(--acc-d); }
.chip.acceptable, .chip.kind, .chip.moderate { background: var(--paper-2); color: var(--ink-2); }
.chip.review, .chip.low { background: var(--cu-s); color: var(--cu); }
.chip.poor, .chip.unusable, .chip.fail, .chip.error { background: var(--red-s); color: var(--red); }
.chip.fit::before { content: "✓"; width: auto; height: auto; background: none; font-size: 9px; }
@keyframes chip-in { from { opacity: 0; transform: translateY(2px) } to { opacity: 1; transform: none } }

.more { border-top: 1px solid var(--line); padding-top: 8px; flex-shrink: 0; }
.more summary { font-size: 11.5px; color: var(--muted); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; padding: 4px 2px; border-radius: 4px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--t-fast); margin-left: 2px; }
.more[open] summary::before { transform: rotate(45deg); }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; padding-top: 6px; }
.actions button, .reports button { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-s); padding: 7px 8px; font-size: 12px; font-weight: 500; color: var(--ink); text-align: center; transition: border-color var(--t-fast), background var(--t-fast); }
.actions button:hover:not(:disabled), .reports button:hover:not(:disabled) { border-color: var(--acc); background: var(--acc-s); }
.actions button:disabled, .reports button:disabled { color: #A6A9A3; cursor: not-allowed; background: var(--paper); }
.reports { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: auto; flex-shrink: 0; padding-top: 6px; }
.status { flex-shrink: 0; font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: pre-wrap; border-top: 1px solid var(--line); padding-top: 8px; line-height: 1.5; }

/* ----------------------------------------------------------------- stage */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-head { padding: 18px 26px 0; }
.stage-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.kicker { font-size: 12px; font-weight: 600; color: var(--acc-d); margin-bottom: 3px; }
.stage-head h1 { font-family: var(--display); font-weight: 600; font-size: 28px; margin: 0; letter-spacing: -0.03em; line-height: 1.05; text-wrap: balance; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.plot-wrap { flex: 1 1 auto; min-height: 300px; margin: 6px 14px 0; position: relative; }
.plot { position: absolute; inset: 0; }
.skeleton { position: absolute; inset: 14px 44px 40px 60px; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; pointer-events: none; }
.skeleton div { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--paper-2) 25%, var(--paper-3) 50%, var(--paper-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton div:nth-child(1) { width: 40%; } .skeleton div:nth-child(2) { width: 70%; } .skeleton div:nth-child(3) { width: 100%; height: 120px; border-radius: 10px; }
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

.details { border-top: 1px solid var(--line); background: var(--paper); height: 42%; display: flex; flex-direction: column; min-height: 220px; }
.tabs { display: flex; gap: 2px; padding: 6px 18px 0; border-bottom: 1px solid var(--line); position: relative; }
.tab { background: none; border: none; padding: 8px 11px 10px; color: var(--muted); font-size: 12.5px; font-weight: 500; border-radius: 4px 4px 0 0; transition: color var(--t-fast); position: relative; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab .badge { display: inline-block; min-width: 14px; padding: 0 4px; margin-left: 5px; font-family: var(--mono); font-size: 9.5px; line-height: 14px; border-radius: 7px; background: var(--acc-s); color: var(--acc-d); vertical-align: 1px; }
.tab-ink { position: absolute; bottom: -1px; height: 2px; background: var(--acc); border-radius: 1px; transition: left var(--t) var(--ease), width var(--t) var(--ease); }
.tab-body { padding: 14px 22px; overflow: auto; flex: 1; animation: fade-in var(--t) var(--ease); }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.grid th, table.grid td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { font-size: 11px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--ink); letter-spacing: .01em; }
table.grid tr:last-child td { border-bottom: none; }
table.grid td.num, table.grid th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.grid tbody tr { animation: fade-in var(--t) var(--ease) both; animation-delay: calc(var(--i, 0) * 25ms); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; }
.bar { display: inline-block; height: 6px; border-radius: 3px; vertical-align: middle; transition: width var(--t) var(--ease); }
.stats { display: flex; gap: 14px; margin-bottom: 14px; }
.stat { flex: 1; border-top: 2px solid var(--ink); padding-top: 6px; }
.stat.hl { border-top-color: var(--acc); }
.stat.hl .v { color: var(--acc-d); }
.stat .v { font-family: var(--display); font-size: 21px; letter-spacing: -0.03em; line-height: 1.1; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.share { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 4px 0 12px; }
.share span { transition: flex var(--t) var(--ease); }
pre.yaml { font-family: var(--mono); font-size: 11.5px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; white-space: pre-wrap; margin: 0; }
.finding { display: flex; gap: 9px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.conf { display: inline-block; width: 70px; height: 5px; border-radius: 3px; background: var(--paper-2); overflow: hidden; vertical-align: middle; }
.conf span { display: block; height: 100%; }
.cands { margin-top: 12px; font-size: 12px; }
.cands .c { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; margin: 0 6px 6px 0; background: var(--white); }
.cands .c.chosen { border-color: var(--acc); background: var(--acc-s); color: var(--acc-d); }
.cands .c .p { font-family: var(--mono); color: var(--muted); font-size: 11px; }
.views { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.view h4 { margin: 0 0 4px; font-size: 12.5px; }
.view .why { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; line-height: 1.45; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: -0.5px; }
.callout { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--white); font-size: 12.5px; margin-bottom: 12px; }
.callout b { color: var(--acc-d); }
.progress { height: 4px; background: var(--paper-2); border-radius: 2px; overflow: hidden; margin: 6px 0 12px; }
.progress span { display: block; height: 100%; background: var(--acc); transition: width var(--t) var(--ease); }

/* first-run empty state */
.empty { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 8%; animation: fade-in var(--t) var(--ease); }
.empty-inner { max-width: 620px; }
.empty h2 { font-family: var(--display); font-weight: 600; font-size: 32px; letter-spacing: -0.035em; line-height: 1.08; margin: 6px 0 12px; text-wrap: balance; }
.empty p { color: var(--ink-2); font-size: 14.5px; line-height: 1.6; max-width: 62ch; margin: 0; text-wrap: pretty; }
.hints { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 22px; font-size: 12.5px; color: var(--muted); }
.hints kbd { margin-right: 3px; }

/* ------------------------------------------------------------------ chat */
.chat { border-left: 1px solid var(--line); display: flex; flex-direction: column; background: var(--paper); min-height: 0; }
.chat-head { padding: 18px 18px 10px; border-bottom: 1px solid var(--line); }
.chat-row { display: flex; justify-content: space-between; align-items: center; }
.chat-title { font-family: var(--display); font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.chat-sub { color: var(--muted); font-size: 10.5px; font-family: var(--mono); margin-top: 2px; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost { background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 500; transition: border-color var(--t-fast); }
.ghost:hover { border-color: var(--ink); }
.ghost[aria-expanded="true"] { border-color: var(--ink); background: var(--paper-2); }
.llm-config { padding: 10px 18px 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); background: var(--paper-2); }
.llm-config label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.llm-config input, .llm-config select { font-family: var(--mono); font-size: 11.5px; font-weight: 400; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--white); color: var(--ink); }
.llm-config input:focus, .llm-config select:focus { border-color: var(--acc); }
.llm-row { display: flex; align-items: center; gap: 10px; }
.messages { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 13px; line-height: 1.5; max-width: 100%; white-space: pre-wrap; word-wrap: break-word; border-radius: 12px; animation: msg-in var(--t) var(--ease); }
@keyframes msg-in { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }
.msg.user { background: var(--ink); color: #fff; align-self: flex-end; max-width: 88%; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.system { color: var(--ink-2); font-size: 12.5px; background: var(--acc-s); }
.msg.error { background: var(--red-s); color: var(--red); }
.msg table { border-collapse: collapse; font-size: 11.5px; margin: 6px 0; }
.msg td, .msg th { border-bottom: 1px solid var(--line); padding: 3px 8px 3px 0; text-align: left; }
.msg code { font-family: var(--mono); font-size: 11.5px; background: var(--paper-2); padding: 0 4px; border-radius: 4px; }
.tool { font-family: var(--mono); font-size: 11px; color: var(--ink-2); background: var(--white); border: 1px solid var(--line); border-radius: var(--r-s); padding: 6px 10px; animation: msg-in var(--t) var(--ease); }
.tool .name { color: var(--acc-d); font-weight: 700; }
.tool .ok { color: var(--acc-d); }
.tool .err { color: var(--red); }
.tool details { margin-top: 4px; }
.tool summary { cursor: pointer; color: var(--muted); }
.tool pre { margin: 4px 0 0; white-space: pre-wrap; max-height: 180px; overflow: auto; }
.composer { display: flex; gap: 8px; margin: 12px 18px 16px; }
.composer textarea { flex: 1; resize: none; font-family: var(--sans); font-size: 13px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--white); outline: none; transition: border-color var(--t-fast); }
.composer textarea:focus { border-color: var(--acc); }
.composer button { background: var(--acc); color: #fff; border: none; border-radius: var(--r); padding: 0 18px; font-weight: 600; font-size: 13px; transition: background var(--t-fast); }
.composer button:hover { background: var(--acc-d); }
.composer button:disabled { opacity: .5; cursor: default; }
.thinking { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--acc); animation: pulse 1s infinite ease-in-out; margin-right: 6px; }
@keyframes pulse { 0%, 100% { opacity: .2 } 50% { opacity: 1 } }

/* --------------------------------------------------------- toasts, help */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: var(--z-toast); max-width: 380px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r); font-size: 12.5px; box-shadow: 0 8px 24px rgba(21,23,26,.18); animation: msg-in var(--t) var(--ease); }
.toast.error { background: var(--red); }
.toast.ok { background: var(--acc-d); }
.help { border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; background: var(--paper); color: var(--ink); max-width: 380px; box-shadow: 0 20px 60px rgba(21,23,26,.2); }
.help::backdrop { background: rgba(21,23,26,.25); }
.help h3 { margin: 0 0 10px; font-family: var(--display); font-size: 17px; letter-spacing: -0.02em; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0 0 14px; font-size: 12.5px; }
.help dt { white-space: nowrap; } .help dd { margin: 0; color: var(--ink-2); }

@media (max-width: 1180px) { .app { grid-template-columns: 260px minmax(0, 1fr); } .chat { display: none; } }
@media (max-width: 760px) { .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; } .rail { border-right: none; border-bottom: 1px solid var(--line); } .details { height: auto; } .plot-wrap { min-height: 280px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Boot overlay for the in-browser build */
.boot { position: fixed; inset: 0; z-index: 60; background: #F6F6F1; display: flex; align-items: center; justify-content: center; transition: opacity 320ms cubic-bezier(.22,1,.36,1); }
.boot.done { opacity: 0; pointer-events: none; }
.boot.error .boot-track i { background: #B4283C; }
.boot-card { width: min(420px, 86vw); text-align: center; }
.boot-card .brand-mark { font-family: "Inter Tight", Inter, system-ui, sans-serif; font-size: 34px; font-weight: 600; letter-spacing: -0.03em; }
.boot-card .brand-mark span { color: #0F9D6B; }
.boot-card p { margin: 14px 0 8px; color: #3E4247; }
.boot-track { height: 4px; background: #E3E4DC; border-radius: 2px; overflow: hidden; }
.boot-track i { display: block; height: 100%; width: 0; background: #0F9D6B; transition: width 300ms cubic-bezier(.22,1,.36,1); }
.boot-note { font-size: 12px; color: #767B82; }
