:root {
  --bar: 68px;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --text: #1d2420;
  --muted: #5d6862;
  --line: #dde2dc;
  --accent: #1f7a5c;
  --accent-soft: #e2f1ea;
  --accent-text: #ffffff;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #a63a32;
  --bad-soft: #fbe6e3;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --blue: #2d5394;
  --blue-soft: #e3ecfb;
  --purple: #6b3b8c;
  --purple-soft: #f2e6fa;
  --amber: #8a5413;
  --amber-soft: #fbeee0;
  color-scheme: light;
}

/* Dark follows the system unless the toggle chose light; or the toggle chose dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131715;
    --surface: #1b201d;
    --surface-2: #232925;
    --text: #e5ebe7;
    --muted: #9aa69f;
    --line: #313833;
    --accent: #4cc093;
    --accent-soft: #1e3a2f;
    --accent-text: #0d1a14;
    --warn: #e2a64a;
    --warn-soft: #3a2c14;
    --bad: #f08a80;
    --bad-soft: #3d1f1c;
    --blue: #9db9ec;
    --blue-soft: #1e2a40;
    --purple: #cfa6ec;
    --purple-soft: #2e2238;
    --amber: #e8b77b;
    --amber-soft: #362816;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131715;
  --surface: #1b201d;
  --surface-2: #232925;
  --text: #e5ebe7;
  --muted: #9aa69f;
  --line: #313833;
  --accent: #4cc093;
  --accent-soft: #1e3a2f;
  --accent-text: #0d1a14;
  --warn: #e2a64a;
  --warn-soft: #3a2c14;
  --bad: #f08a80;
  --bad-soft: #3d1f1c;
  --blue: #9db9ec;
  --blue-soft: #1e2a40;
  --purple: #cfa6ec;
  --purple-soft: #2e2238;
  --amber: #e8b77b;
  --amber-soft: #362816;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }
h3 { font-size: .95rem; margin: 0; }
p { margin: .25rem 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.lead { color: var(--muted); }

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: var(--bar); padding: 0 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand strong { display: block; }
.brand .muted { font-size: .85rem; }
.mark {
  display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 8px; background: var(--accent); color: var(--accent-text); font-weight: 700;
}
.status { font-size: .85rem; color: var(--muted); text-align: right; }
.bar-end { display: flex; align-items: center; gap: .75rem; min-width: 0; }

.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - var(--bar)); }
.content { min-width: 0; }
.notice-bar {
  position: sticky; top: var(--bar); z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin: 0; padding: .6rem 2rem; font-size: .92rem; font-weight: 550;
  background: var(--accent-soft); color: var(--accent); border-bottom: 1px solid var(--line);
}
.notice-bar[hidden] { display: none; }
.notice-bar[data-kind="bad"] { background: var(--bad-soft); color: var(--bad); }
.notice-bar[data-kind="busy"] {
  background-image: linear-gradient(90deg, transparent 0%, rgba(127, 127, 127, .14) 50%, transparent 100%);
  background-size: 40% 100%; background-repeat: no-repeat; animation: working 1.2s linear infinite;
}
.notice-bar[data-kind="busy"] span::before { content: ""; display: inline-block; width: .7rem; height: .7rem; margin-right: .5rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: spin .8s linear infinite; }
@keyframes working { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
body.help-open .layout { grid-template-columns: 230px minmax(0, 1fr) 440px; }

.help {
  border-left: 1px solid var(--line); background: var(--surface);
  padding: 1.25rem 1.25rem 3rem; font-size: .9rem;
  position: sticky; top: var(--bar); align-self: start; height: calc(100vh - var(--bar)); overflow-y: auto;
}
.help[hidden] { display: none; }
.help-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.help h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.help h3 { margin: 1.25rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.help p { color: var(--text); }
.help ol { margin: 0; padding-left: 1.2rem; }
.help ol li { margin-bottom: .45rem; }
.help-field { border-top: 1px solid var(--line); padding: .45rem 0; }
.help-field summary { cursor: pointer; font-weight: 600; }
.help-field p { margin: .35rem 0 .2rem; color: var(--muted); }
.help-field.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.help-example { margin: 1rem 0 0; }
.help-example figcaption { font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.help-example table { font-size: .78rem; }
.help-example th, .help-example td { padding: .3rem .45rem; }
.help-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.1rem; height: 1.1rem; padding: 0; margin-left: .35rem;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font: 600 .7rem/1 system-ui, sans-serif; cursor: pointer; vertical-align: middle;
  text-transform: none; letter-spacing: 0;
}
.required { color: var(--warn); font-weight: 700; margin-left: .2rem; cursor: help; }
.required-note { font-size: .82rem; color: var(--muted); margin-top: -.25rem; }
.required-note::first-letter { color: var(--warn); font-weight: 700; }
.steps .hint.warn { color: var(--warn); }
.help-link:hover { border-color: var(--accent); color: var(--accent); }
.steps {
  border-right: 1px solid var(--line); background: var(--surface); padding: 1rem .75rem;
  position: sticky; top: var(--bar); align-self: start; height: calc(100vh - var(--bar)); overflow-y: auto;
}
.steps ol { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; }
.steps button {
  width: 100%; display: flex; align-items: center; gap: .65rem;
  padding: .55rem .6rem; margin-bottom: 2px;
  border: 0; border-radius: 8px; background: none; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.steps button::before {
  content: counter(step);
  display: grid; place-items: center; flex: none;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  border: 1px solid var(--line); font-size: .78rem; color: var(--muted);
}
.steps button:hover:not(:disabled) { background: var(--surface-2); }
.steps button[aria-current="step"] { background: var(--accent-soft); font-weight: 600; }
.steps button[aria-current="step"]::before { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.steps button.done::before { content: "✓"; color: var(--accent); border-color: var(--accent); }
.steps button:disabled { color: var(--muted); cursor: not-allowed; opacity: .6; }
.steps .hint { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; }

main { padding: 1.75rem 2rem 4rem; min-width: 0; outline: none; }
.panel { max-width: none; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  margin: 1.25rem 0; padding: 2.5rem 1rem;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { font-size: 1.8rem; color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem;
}
label.card { cursor: pointer; display: block; }
label.card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card .big { font-size: 1.6rem; font-weight: 650; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem 1.1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-size: .85rem; font-weight: 600; }
.field small { color: var(--muted); font-size: .8rem; }
.field.check { margin-bottom: .9rem; }
.field.check > span { display: flex; align-items: center; gap: .5rem; }
input[type=text], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { font-family: var(--mono); font-size: .82rem; width: 100%; min-height: 16rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.still-required { font-size: .85rem; color: var(--warn); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1.5rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .2rem .7rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td select, td input { width: 100%; }
.used { font-size: .85rem; color: var(--accent); font-weight: 550; }
.used .link { margin-left: .4rem; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: .8rem; text-decoration: underline; cursor: pointer; }
.samples { color: var(--muted); max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block; padding: .05rem .45rem; border-radius: 6px;
  font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.badge.number { background: var(--blue-soft); color: var(--blue); }
.badge.date { background: var(--purple-soft); color: var(--purple); }
.badge.text { background: var(--surface-2); color: var(--muted); }
.badge.boolean { background: var(--amber-soft); color: var(--amber); }

.notice { border-radius: var(--radius); padding: .75rem 1rem; margin: .75rem 0; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); white-space: pre-wrap; font-family: var(--mono); font-size: .82rem; }
.notice.good { background: var(--accent-soft); color: var(--accent); }
.notice ul { margin: .25rem 0 0; padding-left: 1.2rem; }

.term-group h2 { display: flex; align-items: baseline; gap: .5rem; }
.term {
  display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: .6rem;
}
.term.mapped { border-left: 4px solid var(--accent); }
.term.unmapped { border-left: 4px solid var(--warn); }
.term .value { font-weight: 650; word-break: break-word; }
.term .key { font-family: var(--mono); font-size: .75rem; color: var(--muted); word-break: break-all; }
.searched {
  display: flex; justify-content: space-between; gap: .75rem; align-items: baseline;
  margin-bottom: .4rem; padding: .35rem .6rem; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-size: .85rem; font-weight: 550;
  animation: flash 1.2s ease-out;
}
.searched.none { background: var(--warn-soft); color: var(--warn); }
.candidates { display: flex; flex-direction: column; gap: .3rem; }
.candidate {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center;
  text-align: left; font: inherit; color: var(--text);
  padding: .35rem .6rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer;
}
.candidate:hover { border-color: var(--accent); }
.candidate[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.candidate .name { font-weight: 550; }
.candidate .meta { font-size: .78rem; color: var(--muted); }
.source {
  display: inline-block; margin-right: .4rem; padding: 0 .35rem; border-radius: 4px;
  font-size: .68rem; font-weight: 650; text-transform: uppercase; letter-spacing: .03em;
}
.source.flowmaps { background: var(--accent-soft); color: var(--accent); }
.source.glossary { background: var(--blue-soft); color: var(--blue); }
.score { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.term-tools { display: flex; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; align-items: center; }
.term-tools input[type=search] { flex: 1 1 12rem; }
.term-tools input[type=number] { width: 6.5rem; }

.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: .5rem 0 1rem; max-width: 420px; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; margin: 1rem 0; }
details.node { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .5rem; }
details.node summary { cursor: pointer; padding: .55rem .9rem; font-weight: 550; }
details.node pre { margin: 0; padding: .75rem .9rem; border-top: 1px solid var(--line); overflow: auto; max-height: 28rem; font-size: .8rem; }

.run-steps { padding-left: 1.2rem; }
.run-steps li { margin-bottom: 1rem; }
.run-steps p { margin: 0 0 .4rem; }
.run-steps a { color: var(--accent); font-weight: 600; }
.optional-step { color: var(--muted); }
.files { padding: 1rem 1.25rem 1.25rem; border-top: 1px solid var(--line); }
.files > p { margin-top: 0; }
.files .actions { margin: .75rem 0 0; }
.files h3 { margin: 1.5rem 0 .5rem; font-size: .9rem; }
.files textarea { display: block; }
.command { background: var(--surface-2); border-radius: 8px; padding: .75rem 1rem; font-family: var(--mono); font-size: .82rem; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1099px) {
  body.help-open .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .help {
    position: fixed; top: var(--bar); right: 0; bottom: 0; width: min(440px, 100vw); max-height: none;
    z-index: 3; box-shadow: -8px 0 24px rgba(0, 0, 0, .18);
  }
}

@media (max-width: 760px) {
  .notice-bar { padding: .6rem 1rem; }
  body.help-open .layout { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .steps {
    border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: .5rem 1rem;
    position: static; height: auto;
  }
  .steps ol { display: flex; gap: .25rem; }
  .steps button { white-space: nowrap; }
  .steps .hint { display: none; }
  main { padding: 1.25rem 1rem 3rem; }
  .term { grid-template-columns: 1fr; }
}
