.histagent-product-bar {
  grid-template-columns: 210px minmax(420px, 1fr) auto;
}

.histagent-product-bar .atlas-product-brand {
  gap: 12px;
  letter-spacing: 0;
}

.histagent-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.histagent-steps li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 135px;
  color: #8a9791;
  font-size: 11px;
}

.histagent-steps li:not(:last-child)::after {
  width: 42px;
  height: 1px;
  margin: 0 14px;
  background: #cfdbd5;
  content: "";
}

.histagent-steps span {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  border: 1px solid #bbc9c2;
  border-radius: 50%;
  background: #fff;
  color: #6c7c74;
  font-size: 10px;
  font-weight: 800;
}

.histagent-steps li.complete,
.histagent-steps li.active {
  color: var(--atlas-ink);
}

.histagent-steps li.complete span {
  border-color: var(--atlas-teal);
  background: var(--atlas-teal-pale);
  color: var(--atlas-teal-dark);
}

.histagent-steps li.active span {
  border-color: var(--atlas-orange);
  background: var(--atlas-orange-pale);
  color: #885715;
}

.histagent-generate {
  min-width: 174px;
  padding: 11px 17px;
  border: 0;
  border-radius: 999px;
  background: var(--atlas-teal);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 740;
}

.histagent-generate:hover {
  background: var(--atlas-teal-dark);
}

.histagent-generate:disabled {
  cursor: wait;
  opacity: 0.68;
}

.histagent-workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) minmax(0, 1fr);
  min-height: calc(100vh - 186px);
}

.histagent-controls {
  padding: 14px;
  border-right: 1px solid var(--atlas-line-dark);
  background: #f8faf8;
}

.histagent-upload {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 67px;
  margin-bottom: 7px;
  padding: 11px;
  border: 1px dashed var(--atlas-line-dark);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.histagent-upload[data-dragging="true"] {
  border-color: var(--atlas-teal);
  background: #f1faf6;
}

.histagent-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.histagent-upload-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--atlas-teal-pale);
  color: var(--atlas-teal-dark);
  font-size: 20px;
}

.histagent-upload > span:last-child {
  display: grid;
  gap: 2px;
}

.histagent-upload strong {
  font-size: 11px;
}

.histagent-upload small {
  color: var(--atlas-muted);
  font-size: 9px;
}

.histagent-example-button {
  width: 100%;
  margin-bottom: 16px;
  padding: 7px 9px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #fff;
  color: var(--atlas-teal-dark);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
}

.histagent-parameter-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
  margin: 4px 0 16px;
}

.histagent-parameter-grid > label,
.histagent-parameter-grid > div {
  display: grid;
  gap: 5px;
  align-content: start;
}

.histagent-parameter-grid > label > span:first-child,
.histagent-parameter-grid > div > span {
  color: #54675e;
  font-size: 10px;
  font-weight: 650;
}

.histagent-parameter-grid > div > strong {
  min-height: 34px;
  padding: 9px 8px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #f1f5f2;
  color: #43564d;
  font-size: 10px;
  text-align: center;
}

.histagent-unit-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #fff;
}

.histagent-unit-input input {
  min-width: 0;
  padding: 8px 4px 8px 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--atlas-ink);
  font: inherit;
  font-size: 10px;
}

.histagent-unit-input small {
  padding-right: 7px;
  color: var(--atlas-muted);
  font-size: 9px;
}

.histagent-selected-spot {
  margin-top: 10px;
  padding-top: 13px;
  border-top: 1px solid var(--atlas-line);
}

.histagent-control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.histagent-control-heading span {
  color: #54675e;
  font-size: 11px;
  font-weight: 700;
}

.histagent-control-heading b {
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--atlas-orange-pale);
  color: #8b5b1d;
  font-size: 9px;
}

.histagent-crop-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  max-width: 300px;
  margin-inline: auto;
}

.histagent-crop-pair figure {
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--atlas-line);
  border-radius: 7px;
  background: #fff;
}

.histagent-crop-pair img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #eef1ef;
}

.histagent-crop-pair figcaption {
  padding: 5px;
  color: var(--atlas-muted);
  font-size: 8px;
  text-align: center;
}

.histagent-selected-spot p {
  margin: 6px 0 0;
  color: var(--atlas-muted);
  font-size: 9px;
  text-align: center;
}

.histagent-run-status {
  min-height: 30px;
  margin: 13px 0 0;
  color: var(--atlas-muted);
  font-size: 9.5px;
  line-height: 1.45;
}

.histagent-run-status[data-error="true"] {
  color: #9a4439;
}

.histagent-tissue-panel {
  display: grid;
  grid-template-rows: auto auto auto auto;
  min-width: 0;
  padding: 8px;
  background: #fff;
}

.histagent-tissue-header {
  min-height: 49px;
}

.atlas-legend i.histagent-candidate {
  box-sizing: border-box;
  border: 1px solid rgba(31, 157, 136, 0.78);
  background: rgba(255,255,255,0.5);
}

.atlas-legend i.histagent-context {
  box-sizing: border-box;
  border: 1px solid #bd8440;
  background: transparent;
}

.histagent-tissue-stage {
  position: relative;
  min-height: 0;
  aspect-ratio: var(--histagent-image-ratio, 1 / 1);
  overflow: hidden;
  border: 1px solid var(--atlas-line-dark);
  border-radius: 7px;
  background:
    linear-gradient(45deg, #e9eeeb 25%, transparent 25%),
    linear-gradient(-45deg, #e9eeeb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9eeeb 75%),
    linear-gradient(-45deg, transparent 75%, #e9eeeb 75%),
    #f3f6f4;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  cursor: grab;
  touch-action: pan-y pinch-zoom;
}

.histagent-tissue-stage[data-zoom]:not([data-zoom="1.00"]) {
  touch-action: none;
}

.histagent-tissue-stage[data-dragging="true"] {
  cursor: grabbing;
}

.histagent-tissue-layer {
  position: absolute;
  inset: 0;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center center;
  will-change: transform;
}

.histagent-tissue-layer > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.histagent-spot-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: inherit;
}

.histagent-spot-grid:focus-visible {
  outline: 2px solid var(--atlas-teal);
  outline-offset: -3px;
}

.histagent-tissue-stage[data-dragging="true"] .histagent-spot-grid {
  cursor: grabbing;
}

.histagent-context-ring {
  position: absolute;
  z-index: 2;
  border: 1px dashed rgba(168, 105, 31, 0.88);
  border-radius: 50%;
  background: rgba(239, 163, 58, 0.05);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.histagent-map-tools {
  z-index: 12;
}

.histagent-map-tools button {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--atlas-line-dark);
  border-radius: 6px;
  background: rgba(255,255,255,0.95);
  color: #40564c;
  box-shadow: 0 1px 4px rgba(27, 50, 40, 0.12);
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.histagent-map-tools button:hover,
.histagent-map-tools button:focus-visible {
  border-color: var(--atlas-teal);
  color: var(--atlas-teal-dark);
  outline: none;
}

.histagent-map-tools button:disabled {
  cursor: default;
  opacity: 0.42;
}

.histagent-stage-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 24px;
  background: rgba(247, 250, 248, 0.94);
  text-align: center;
}

.histagent-stage-loading[hidden] {
  display: none;
}

.histagent-stage-loading > span {
  width: 35px;
  height: 35px;
  margin-bottom: 13px;
  border: 3px solid #d6e6df;
  border-top-color: var(--atlas-teal);
  border-radius: 50%;
  animation: atlas-spin 0.8s linear infinite;
}

.histagent-stage-loading strong {
  font-size: 13px;
}

.histagent-stage-loading small {
  max-width: 330px;
  margin-top: 5px;
  color: var(--atlas-muted);
  font-size: 10px;
}

.histagent-selection-summary {
  margin-top: 10px;
}

.histagent-results {
  grid-template-rows: minmax(0, 1fr) minmax(220px, 0.78fr);
}

.histagent-evidence-section {
  min-height: 0;
}

.histagent-readout {
  padding: 9px 10px 10px;
  border: 1px solid var(--atlas-line-dark);
  border-radius: 9px;
  background: #fff;
}

.histagent-evidence-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.histagent-evidence-heading strong {
  font-size: 10.5px;
}

.histagent-evidence-heading span {
  color: var(--atlas-muted);
  font-size: 8.5px;
}

.histagent-gene-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  counter-reset: ranked-gene;
  list-style: none;
}

.histagent-gene-list li {
  counter-increment: ranked-gene;
  padding: 4px 6px;
  border-radius: 5px;
  background: var(--atlas-teal-pale);
  color: var(--atlas-teal-dark);
  font-size: 8.8px;
  line-height: 1;
}

.histagent-gene-list li::before {
  margin-right: 3px;
  color: #7ba99c;
  content: counter(ranked-gene);
  font-size: 7.5px;
  font-style: normal;
}

.histagent-evidence-fields {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.histagent-evidence-fields article {
  padding: 8px 9px;
  border-left: 3px solid var(--atlas-teal);
  border-radius: 0 7px 7px 0;
  background: #fff;
}

.histagent-evidence-fields article:nth-child(2) {
  border-left-color: var(--atlas-orange);
}

.histagent-evidence-fields article:nth-child(3) {
  border-left-color: #96a7a0;
}

.histagent-evidence-fields span {
  display: block;
  margin-bottom: 3px;
  color: var(--atlas-muted);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.histagent-evidence-fields strong {
  display: block;
  color: var(--atlas-ink);
  font-size: 9.5px;
  line-height: 1.3;
}

.histagent-evidence-fields p {
  margin: 3px 0 0;
  color: #5d7067;
  font-size: 8.5px;
  line-height: 1.35;
}

.histagent-evidence-empty {
  display: grid;
  min-height: 210px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--atlas-line-dark);
  border-radius: 9px;
  color: var(--atlas-muted);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.histagent-chat-section {
  grid-template-rows: auto minmax(105px, 1fr) auto auto;
}

.atlas-message.error p {
  border: 1px solid #d9b58a;
  background: #fff7ec;
  color: #65451f;
}

.histagent-chat-retry {
  margin-top: 6px;
  padding: 5px 9px;
  border: 1px solid var(--atlas-teal);
  border-radius: 999px;
  background: #fff;
  color: var(--atlas-teal-dark);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  font-weight: 750;
}

.histagent-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.histagent-suggestions button {
  padding: 5px 7px;
  border: 1px solid var(--atlas-line);
  border-radius: 999px;
  background: #fff;
  color: #53675e;
  cursor: pointer;
  font: inherit;
  font-size: 8.5px;
}

.histagent-suggestions button:hover {
  border-color: var(--atlas-teal);
  color: var(--atlas-teal-dark);
}

.histagent-evidence-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.histagent-evidence-actions > span {
  padding: 3px 7px;
  border: 1px solid #e2a449;
  border-radius: 999px;
  background: var(--atlas-orange-pale);
  color: #946120;
  font-size: 10px;
}

#histagent-atlas-action {
  padding: 4px 8px;
  border: 1px solid var(--atlas-teal);
  border-radius: 999px;
  background: #fff;
  color: var(--atlas-teal-dark);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  font-weight: 750;
}

#histagent-atlas-action:hover,
#histagent-atlas-action:focus-visible {
  background: var(--atlas-teal-pale);
}

@media (min-width: 961px) {
  .histagent-page {
    height: 100vh;
    overflow: hidden;
  }

  .histagent-page .atlas-main {
    box-sizing: border-box;
    height: calc(100vh - 72px);
    padding: 12px 16px;
  }

  .histagent-product {
    display: grid;
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .histagent-product-bar {
    min-height: 60px;
    padding-block: 8px;
  }

  .histagent-workspace {
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .histagent-controls,
  .histagent-tissue-panel,
  .histagent-results {
    min-height: 0;
  }

  .histagent-controls {
    overflow-y: auto;
  }

  .histagent-tissue-panel {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    overflow: hidden;
  }

  .histagent-tissue-stage {
    width: min(100%, calc(100vh - 290px));
    max-height: 100%;
    align-self: center;
    justify-self: center;
  }

  .histagent-results {
    overflow: hidden;
  }
}

@media (max-width: 1240px) {
  .histagent-product-bar {
    grid-template-columns: 180px minmax(360px, 1fr) auto;
  }

  .histagent-steps li {
    min-width: 112px;
  }

  .histagent-steps li:not(:last-child)::after {
    width: 25px;
    margin-inline: 9px;
  }

  .histagent-workspace {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  .histagent-product-bar {
    grid-template-columns: 1fr auto;
  }

  .histagent-steps {
    grid-column: 1 / -1;
    grid-row: 2;
    order: 3;
  }

  .histagent-workspace {
    grid-template-columns: 220px minmax(0, 480px);
    justify-content: center;
  }

  .histagent-results {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(390px, auto);
    border-top: 1px solid var(--atlas-line-dark);
    border-left: 0;
  }

  .histagent-evidence-section {
    border-right: 1px solid var(--atlas-line-dark);
    border-bottom: 0;
  }
}

@media (max-width: 720px) {
  .histagent-product-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .histagent-product-bar .atlas-product-brand {
    display: none;
  }

  .histagent-generate {
    width: 100%;
  }

  .histagent-steps {
    grid-column: 1;
    grid-row: auto;
    order: 0;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .histagent-generate {
    order: 1;
  }

  .histagent-steps li {
    min-width: max-content;
  }

  .histagent-steps li:not(:last-child)::after {
    width: 18px;
  }

  .histagent-workspace {
    display: block;
  }

  .histagent-controls {
    border-right: 0;
    border-bottom: 1px solid var(--atlas-line-dark);
  }

  .histagent-tissue-panel {
    grid-template-rows: auto auto auto auto;
    padding: 6px;
  }

  .histagent-results {
    display: block;
  }

  .histagent-evidence-section {
    border-right: 0;
    border-bottom: 1px solid var(--atlas-line-dark);
  }

  .histagent-chat-section {
    min-height: 380px;
  }
}
