:root {
  --bg: #090b10;
  --panel: #121620;
  --panel-2: #181d29;
  --line: #293143;
  --text: #f4f6fb;
  --muted: #9ba6ba;
  --accent: #77e5c1;
  --accent-strong: #43d6a8;
  --accent-ink: #06291f;
  --danger: #ff7e8a;
  --warning: #ffd27c;
  --success: #77e5c1;
  --radius: 16px;
  --shadow: 0 18px 50px rgb(0 0 0 / 28%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 300px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 75% -15%, #19362f 0, transparent 34rem), var(--bg); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, pre:focus-visible { outline: 3px solid rgb(119 229 193 / 48%); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .7rem 1rem; background: var(--text); color: var(--bg); border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-header { position: sticky; top: 0; z-index: 20; min-height: 70px; display: flex; align-items: center; gap: 1rem; padding: .8rem max(1rem, calc((100vw - 1440px) / 2)); border-bottom: 1px solid rgb(255 255 255 / 8%); background: rgb(9 11 16 / 88%); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: .7rem; margin-right: auto; color: var(--text); text-decoration: none; line-height: 1.05; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(145deg, var(--accent), #89aaff); color: #0b1420; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: .22rem; color: var(--muted); font-size: .72rem; letter-spacing: .05em; }
.session-state { display: flex; align-items: center; gap: .7rem; font-size: .9rem; }
.session-state small, .session-state strong { display: block; }
.session-state small { color: var(--muted); font-size: .7rem; }
.avatar { width: 30px; height: 30px; border: 1px solid #4b6570; border-radius: 50%; background: linear-gradient(145deg, #29414c, #17202b); }

main { width: min(1440px, 100%); margin: 0 auto; padding: 2.5rem max(1rem, 3vw) 5rem; }
.welcome { max-width: 760px; margin: 12vh auto; padding: clamp(2rem, 6vw, 5rem); text-align: center; border: 1px solid var(--line); border-radius: 28px; background: rgb(18 22 32 / 88%); box-shadow: var(--shadow); }
.welcome h1 { margin: .4rem 0 1rem; font-size: clamp(2.2rem, 6vw, 4.8rem); line-height: .98; letter-spacing: -.055em; }
.welcome p:not(.eyebrow) { max-width: 630px; margin: 0 auto 2rem; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin: 1rem 0 2rem; }
h1, h2, h3, p { margin-top: 0; }
.hero h1 { margin: .25rem 0 .55rem; font-size: clamp(2.2rem, 5vw, 4rem); letter-spacing: -.05em; line-height: 1; }
.hero p { max-width: 680px; }
.eyebrow { margin-bottom: .35rem; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.5; }
.compact { margin-bottom: .8rem; font-size: .86rem; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); align-items: start; gap: 1.35rem; }
.workflow { display: grid; gap: 1.35rem; }
.jobs-column { min-width: 0; }
.sticky-panel { position: sticky; top: 88px; }
.panel { padding: clamp(1.15rem, 2.5vw, 1.65rem); border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgb(21 26 37 / 98%), rgb(15 18 27 / 98%)); box-shadow: 0 8px 30px rgb(0 0 0 / 15%); }
.step-heading { display: flex; gap: .95rem; margin-bottom: 1.25rem; }
.step-heading > span { flex: 0 0 auto; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #3c4b5c; border-radius: 9px; color: var(--accent); font-size: .8rem; font-weight: 800; }
.step-heading h2, .section-heading h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.015em; }
.step-heading p { margin: .25rem 0 0; color: var(--muted); font-size: .84rem; }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1.15rem; }

.button, .icon-button { border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; transition: transform .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: .65rem 1rem; text-decoration: none; }
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: .42; }
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.primary:hover:not(:disabled) { background: var(--accent-strong); }
.button.secondary { border: 1px solid #526176; background: #252d3c; color: var(--text); }
.button.ghost { border: 1px solid var(--line); background: transparent; color: var(--text); }
.button.small { min-height: 34px; padding: .4rem .7rem; font-size: .78rem; }
.button.full { width: 100%; }
.icon-button { width: 36px; height: 36px; background: #232a38; color: var(--text); font-size: 1.25rem; }

.upload-drop { display: grid; place-items: center; min-height: 170px; padding: 1.5rem; border: 1px dashed #516175; border-radius: 14px; background: rgb(255 255 255 / 1.5%); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.upload-drop:hover, .upload-drop.dragging { border-color: var(--accent); background: rgb(119 229 193 / 5%); }
.upload-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-drop strong { margin: .4rem 0 .15rem; }
.upload-drop span:last-child { color: var(--muted); font-size: .83rem; }
.upload-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: #222c38; color: var(--accent); font-size: 1.35rem; }
.progress-row, .file-summary { display: flex; align-items: center; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; }
.progress-row progress { flex: 1; accent-color: var(--accent); }
.progress-row span { font-size: .82rem; }
.file-summary { justify-content: space-between; }
.file-summary strong, .file-summary span { display: block; overflow-wrap: anywhere; }
.file-summary span { margin-top: .25rem; color: var(--muted); font-size: .78rem; }

.filter-chain { display: grid; gap: .8rem; margin-bottom: .8rem; }
.filter-card { border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); overflow: hidden; }
.filter-card-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .65rem; padding: .85rem 1rem; }
.drag-handle { color: #68758a; user-select: none; }
.filter-card-header label { margin: 0; }
.filter-card-header select { font-weight: 750; }
.card-actions { display: flex; gap: .25rem; }
.filter-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; padding: 1rem; border-top: 1px solid var(--line); background: rgb(4 6 10 / 18%); }
.option-empty { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.option-row { display: grid; grid-template-columns: 1fr auto; gap: .55rem; margin-bottom: .55rem; }

label { display: grid; align-content: start; gap: .38rem; color: #dbe1eb; font-size: .8rem; font-weight: 720; }
label small { min-height: 1em; color: var(--muted); font-size: .7rem; font-weight: 450; line-height: 1.35; }
input, select { width: 100%; min-height: 42px; padding: .58rem .7rem; border: 1px solid #3b4658; border-radius: 9px; background: #0e121a; color: var(--text); }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--accent); }
.checkbox-label { grid-template-columns: 20px 1fr; align-items: center; padding-top: 1.5rem; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 5rem; }
.input-suffix span { position: absolute; right: .75rem; top: 50%; color: var(--muted); font-size: .72rem; transform: translateY(-50%); }
.form-grid, .option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .95rem; }
.advanced-block { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
summary { cursor: pointer; font-weight: 760; }
.control-group { margin: 1rem 0; padding: .9rem; border: 1px solid var(--line); border-radius: 10px; }
.control-group legend { padding: 0 .35rem; }
.toggle-label { display: flex; grid-template-columns: none; flex-direction: row; align-items: center; gap: .55rem; cursor: pointer; }
.toggle-label input { flex: 0 0 auto; }
.four-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.nested-option { grid-column: 1 / -1; margin: .2rem 0; padding: .9rem; border: 1px solid #354156; border-radius: 10px; }
.nested-option legend { padding: 0 .4rem; color: var(--accent); font-size: .8rem; font-weight: 780; }
.nested-option > .option-grid { margin-top: .7rem; }
.advanced-block[open] summary { margin-bottom: .8rem; }
.filter-advanced { grid-column: 1 / -1; margin-top: 0; }
.filter-advanced > .option-grid { margin-top: .8rem; }
.installed-details > summary { font-size: 1rem; }
.installed-details[open] > summary { margin-bottom: 1rem; }

.submit-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border: 1px solid #3a574f; border-radius: 14px; background: #11231f; }
.submit-bar strong, .submit-bar span { display: block; }
.submit-bar span { margin-top: .2rem; color: #9ebbb2; font-size: .76rem; }
.notice { padding: .9rem 1rem; border-radius: 10px; line-height: 1.45; }
.notice.error, .field-error { color: #ffd7db; background: rgb(255 126 138 / 10%); border: 1px solid rgb(255 126 138 / 30%); }
.field-error { padding: .65rem .75rem; border-radius: 8px; font-size: .8rem; }
.status-pill { flex: 0 0 auto; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px; font-size: .75rem; font-weight: 750; }
.status-pill.success { border-color: rgb(119 229 193 / 35%); background: rgb(119 229 193 / 8%); color: var(--success); }
.status-pill.warning { border-color: rgb(255 210 124 / 35%); background: rgb(255 210 124 / 8%); color: var(--warning); }
.status-pill.error { border-color: rgb(255 126 138 / 35%); background: rgb(255 126 138 / 8%); color: var(--danger); }
.status-pill.neutral { color: var(--muted); }

.payload-panel > summary { font-size: .9rem; }
.payload-panel[open] > summary { margin-bottom: 1rem; }
.code-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .4rem; color: var(--muted); font: .75rem ui-monospace, SFMono-Regular, Consolas, monospace; }
pre { max-height: 420px; margin: 0; overflow: auto; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: #080a0f; color: #d9e3ef; font: .75rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.jobs-list { display: grid; gap: .7rem; }
.job-card { padding: .9rem; border: 1px solid var(--line); border-radius: 11px; background: #171c27; }
.job-card-top { display: flex; justify-content: space-between; align-items: start; gap: .7rem; }
.job-card button.job-open { padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.job-card strong { display: block; font-size: .88rem; overflow-wrap: anywhere; }
.job-card small { color: var(--muted); }
.job-meta { display: flex; justify-content: space-between; gap: .5rem; margin-top: .65rem; color: var(--muted); font-size: .71rem; }
.job-status { display: inline-flex; align-items: center; gap: .35rem; font-size: .7rem; font-weight: 800; text-transform: capitalize; }
.job-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8290a6; }
.job-status.running::before, .job-status.queued::before { background: var(--warning); box-shadow: 0 0 0 4px rgb(255 210 124 / 10%); }
.job-status.succeeded::before, .job-status.completed::before { background: var(--success); }
.job-status.failed::before, .job-status.cancelled::before, .job-status.canceled::before { background: var(--danger); }
.job-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.output-links { display: grid; gap: .35rem; margin-top: .7rem; }
.output-links a { overflow-wrap: anywhere; font-size: .76rem; }

.skeleton-stack { display: grid; gap: .7rem; }
.skeleton-stack i { display: block; height: 70px; border-radius: 11px; background: linear-gradient(90deg, #181e29 25%, #232b39 45%, #181e29 65%); background-size: 300% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -150% 0; } }
.empty-state { padding: 1.5rem 1rem; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); }
.empty-state p { margin: .4rem 0 0; font-size: .8rem; line-height: 1.5; }

.installed { margin-top: 1.35rem; }
.tab-list { display: flex; gap: .35rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-list button { padding: .55rem .8rem; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 750; white-space: nowrap; }
.tab-list button[aria-selected="true"] { background: #25302f; color: var(--accent); }
[role="tabpanel"] { padding-top: 1rem; }
.evidence-block { margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 11px; background: rgb(119 229 193 / 3%); }
.evidence-block p { margin: .3rem 0 .7rem; }
.evidence-details summary { color: var(--accent); font-size: .8rem; }
.evidence-details[open] summary { margin-bottom: .6rem; }
.discovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.discovery-card { padding: .9rem; border: 1px solid var(--line); border-radius: 10px; background: #111620; }
.discovery-card header { display: flex; justify-content: space-between; gap: .7rem; margin-bottom: .55rem; }
.discovery-card p { margin: .2rem 0; color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.model-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .7rem; }
.model-card { padding: .8rem; border: 1px solid var(--line); border-radius: 9px; background: #111620; }
.model-card strong, .model-card span { display: block; overflow-wrap: anywhere; }
.model-card span { margin-top: .3rem; color: var(--muted); font-size: .72rem; }
.help-controls { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: .7rem; margin-bottom: 1rem; }

body:has(dialog[open]) { overflow: hidden; }
dialog { width: min(760px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 1.3rem; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / 72%); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 1rem; }
.dialog-heading h2 { margin: 0; overflow-wrap: anywhere; }
#job-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.detail-item { padding: .7rem; border: 1px solid var(--line); border-radius: 8px; }
.detail-item small, .detail-item strong { display: block; overflow-wrap: anywhere; }
.detail-item small { margin-bottom: .2rem; color: var(--muted); }
dialog section h3 { margin: 1rem 0 .5rem; }

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .jobs-column { order: 2; }
  .discovery-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .site-header { min-height: 62px; }
  .session-state > span:not(.avatar), .brand small { display: none; }
  main { padding-top: 1.5rem; }
  .hero { display: block; }
  .hero .status-pill { display: inline-block; margin-top: .5rem; }
  .filter-options, .form-grid, .option-grid { grid-template-columns: 1fr; }
  .submit-bar { align-items: stretch; flex-direction: column; }
  .help-controls { grid-template-columns: 1fr; }
  #job-detail { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
