:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191d;
  --muted: #5c6470;
  --line: #dfe3e8;
  --accent: #1f5fa9;
  --error: #b3261e;
  --error-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --ok: #1d6b3f;
  --ok-bg: #e9f5ee;
  --accent-soft: #e8f0fa;
  --line-2: #eceff3;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --panel: #1c2026;
    --ink: #e6e8eb;
    --muted: #9aa3b0;
    --line: #2c3238;
    --accent: #6ea8de;
    --error: #ef9a93;
    --error-bg: #3a1f1d;
    --warn: #e8bd6b;
    --warn-bg: #362a14;
    --ok: #86d4a4;
    --ok-bg: #16301f;
    --accent-soft: #1b2836;
    --line-2: #242a32;
  }
}

* { box-sizing: border-box; }

/* Must outrank any class that sets display, or `hidden` silently does nothing
   on .picker-panel, .file-actions and .summary-bar. */
[hidden] { display: none !important; }

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

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-inner, main, .footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar-inner { padding-block: 20px 22px; }

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 62ch;
}

main { padding-block: 22px 40px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ---------- tool picker ---------- */

.picker { position: relative; max-width: 940px; }

.trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}

.trigger:hover { border-color: var(--accent); }

.trigger-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trigger-name { font-family: var(--mono); font-size: 14px; font-weight: 500; }
.trigger-desc { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.chev { color: var(--muted); flex-shrink: 0; }

/* The list and the detail panel share one border and one shadow: divided,
   not separated, so they read as a single control rather than two cards. */
.picker-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 430px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 38px rgba(16, 20, 28, 0.18);
  overflow: hidden;
}

.picker-list {
  flex: 0 0 340px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.search-row { padding: 10px; border-bottom: 1px solid var(--line-2); }

.search {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 11px;
}

.scroll { flex: 1 1 auto; overflow-y: auto; }

.grp {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 7px 13px;
  z-index: 1;
}

.opt {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 13px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.opt:hover, .opt.active { background: var(--accent-soft); }
.opt.active .opt-name { color: var(--accent); }
.opt[aria-selected="true"] .opt-name { font-weight: 700; }

.tick { color: var(--accent); font-size: 13px; line-height: 1.5; }
.opt-name { display: block; font-family: var(--mono); font-size: 13.5px; font-weight: 500; }
.opt-desc { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.empty { padding: 18px 13px; color: var(--muted); font-size: 13.5px; }

.picker-detail {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.picker-detail h3 { margin: 0; font-family: var(--mono); font-size: 15px; }
.detail-desc { margin: 0; font-size: 13.5px; color: var(--ink); }
.detail-note { margin: 0; font-size: 12px; color: var(--muted); font-style: italic; }

.field-label {
  margin: 0 0 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Wrap rather than scroll: a horizontal scrollbar inside the panel hides the
   end of the line, which is usually the part worth reading. */
.picker-detail pre {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  color: var(--ink);
}

.picker-detail pre.cmd { color: var(--accent); }

.real-badge {
  display: inline-block;
  margin-left: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ok);
  background: var(--ok-bg);
  border-radius: 4px;
  padding: 1px 6px;
}

@media (max-width: 820px) {
  .picker-panel { flex-direction: column; height: auto; max-height: 70vh; }
  .picker-list { flex: 1 1 auto; max-width: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .scroll { max-height: 280px; }
}

select, input[type="text"] {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
}

select:focus-visible, input:focus-visible, button:focus-visible, .dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.summary { margin: 0; color: var(--muted); font-size: 14px; }

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 14px;
}

.inline-check, .inline-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  white-space: nowrap;
}

.freeform { margin-top: 16px; }

.freeform label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 5px;
}

#extra-args { width: 100%; font-family: var(--mono); font-size: 13px; }

.hint { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.dropzone-main { margin: 0 0 3px; font-weight: 500; }
.dropzone-sub { margin: 0; color: var(--muted); font-size: 13px; }

.filelist {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.filelist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.filelist li:last-child { border-bottom: 0; }

.fname {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.fsize { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.file-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.run-row { display: flex; align-items: center; gap: 14px; }

.primary {
  font: inherit;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 7px;
  padding: 9px 22px;
  cursor: pointer;
}

.primary:disabled { opacity: 0.45; cursor: not-allowed; }

.status { color: var(--muted); font-size: 14px; }

.results-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: baseline;
}

.results-header h2 { margin-bottom: 0; }

.results-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 16px;
}

.chip {
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip-error { background: var(--error-bg); color: var(--error); border-color: transparent; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

.result {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--panel);
}

.result.has-error { border-left-color: var(--error); }
.result.has-warning { border-left-color: var(--warn); }

.result summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}

.result summary::-webkit-details-marker { display: none; }

.rname {
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.rstatus {
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.has-error .rstatus { color: var(--error); }
.has-warning .rstatus { color: var(--warn); }

.result-body { padding: 0 14px 14px; }

pre {
  margin: 0;
  padding: 12px;
  background: var(--bg);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.downloads { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.download {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
}

.download:hover { border-color: var(--accent); }

.footer {
  padding-block: 0 32px;
  color: var(--muted);
  font-size: 12.5px;
}

.footer a { color: var(--accent); }

@media (max-width: 560px) {
  .trigger { max-width: none; }
}

/* Which dicom3tools snapshot produced the binary. Shown because behaviour
   changes between releases: what one snapshot reports as an error another may
   not mention at all, so a finding is only meaningful against a known version. */
.build-line {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.build-version {
  font-family: var(--mono);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
}

/* Header lays out as a row so the source link sits opposite the title; it drops
   below the text at phone width rather than squeezing it. */
.topbar-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-text { min-width: 0; }

.repo-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 11px;
  background: var(--bg);
}

.repo-link:hover {
  color: var(--ink);
  border-color: var(--accent);
}
