:root {
  color-scheme: dark;
  --bg: #07100f;
  --panel: rgba(13, 27, 24, 0.95);
  --panel-strong: #10211e;
  --panel-soft: #132925;
  --line: rgba(151, 183, 173, 0.18);
  --line-strong: rgba(151, 183, 173, 0.32);
  --text: #eff8f4;
  --muted: #9db0aa;
  --muted-strong: #c6d5d0;
  --accent: #55e8c5;
  --accent-strong: #25cfa9;
  --accent-soft: rgba(85, 232, 197, 0.12);
  --cyan: #22d3ee;
  --locator: #ffb454;
  --warning: #f3c969;
  --danger: #ff8291;
  --success: #79e6a8;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 20px 52px rgba(0, 0, 0, 0.26);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(44, 186, 151, 0.11), transparent 27rem),
    radial-gradient(circle at 94% 40%, rgba(34, 211, 238, 0.055), transparent 32rem),
    linear-gradient(180deg, #091311 0%, #07100f 60%, #050b0a 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 58px;
  padding: 8px clamp(14px, 2.5vw, 42px);
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 15, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(85, 232, 197, 0.32);
  border-radius: 11px;
  color: var(--accent);
  background: linear-gradient(145deg, #17342e, #0c1d1a);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.88rem;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.65rem;
}

.header-badge {
  display: flex;
  gap: 7px;
  padding: 7px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 0.71rem;
}

.header-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(85, 232, 197, 0.1), 0 0 13px rgba(85, 232, 197, 0.6);
}

.app-shell {
  width: min(1900px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 34px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(245px, 0.8fr) minmax(220px, 0.75fr) minmax(250px, 1fr) auto;
  gap: 12px 16px;
  padding: 13px 15px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(13, 27, 24, 0.84);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.control-title {
  align-self: center;
}

.control-title h1 {
  margin: 0;
  font-size: clamp(1.05rem, 1.6vw, 1.4rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.control-file {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 9px;
  align-items: center;
}

.file-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.66rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-field {
  display: grid;
  gap: 5px;
}

.compact-field > span {
  display: flex;
  gap: 7px;
  align-items: baseline;
  color: var(--muted-strong);
  font-size: 0.7rem;
  font-weight: 700;
}

.compact-field em {
  color: var(--muted);
  font-size: 0.61rem;
  font-style: normal;
  font-weight: 400;
}

.compact-field input {
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  background: rgba(4, 12, 10, 0.72);
}

.compact-field input:hover,
.compact-field input:focus {
  border-color: rgba(85, 232, 197, 0.56);
  box-shadow: 0 0 0 3px rgba(85, 232, 197, 0.05);
}

.compact-field input::placeholder {
  color: #71817c;
}

.control-actions {
  display: flex;
  gap: 7px;
}

.primary-button,
.secondary-button,
.text-button {
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, filter 150ms ease;
}

.primary-button {
  display: flex;
  min-width: 118px;
  min-height: 38px;
  padding: 0 15px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  color: #052019;
  background: linear-gradient(135deg, #78f0d2, #35d7b1);
  box-shadow: 0 8px 20px rgba(37, 207, 169, 0.14);
  font-size: 0.77rem;
  font-weight: 800;
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.07);
}

.primary-button:disabled,
.secondary-button:disabled,
.text-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.secondary-button,
.text-button {
  border: 1px solid var(--line-strong);
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.025);
}

.secondary-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.7rem;
}

.choose-button {
  grid-row: 1 / span 2;
  min-height: 38px;
  white-space: nowrap;
}

.text-button {
  padding: 5px 8px;
  border-color: transparent;
  background: transparent;
  font-size: 0.68rem;
}

.secondary-button:hover:not(:disabled),
.text-button:hover:not(:disabled) {
  border-color: rgba(85, 232, 197, 0.43);
  color: var(--text);
  background: var(--accent-soft);
}

.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(5, 32, 25, 0.25);
  border-top-color: #052019;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.primary-button.is-loading .spinner {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.notice {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.7rem;
  line-height: 1.45;
}

.notice.is-error {
  border-color: rgba(255, 130, 145, 0.3);
  color: #ffc2ca;
  background: rgba(255, 130, 145, 0.07);
}

.notice.is-success {
  border-color: rgba(121, 230, 168, 0.26);
  color: #bdf5d2;
  background: rgba(121, 230, 168, 0.06);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 420px);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(19, 39, 35, 0.95), rgba(11, 23, 21, 0.97));
  box-shadow: var(--shadow);
}

.visual-panel {
  position: sticky;
  top: 72px;
  padding: 13px;
}

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

.panel-heading h2,
.id-summary h3 {
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: -0.015em;
}

.overlay-legend {
  display: flex;
  gap: 11px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.63rem;
}

.overlay-legend span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.overlay-legend i {
  display: inline-block;
  width: 15px;
  height: 7px;
}

.legend-callout {
  border: 1px dashed var(--cyan);
}

.legend-locator {
  border-top: 2px dashed var(--locator);
}

.legend-target {
  border-top: 3px solid var(--accent);
}

.image-stage {
  position: relative;
  display: flex;
  min-height: 540px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(85, 232, 197, 0.32);
  border-radius: var(--radius-md);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.018) 75%),
    #07100f;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  transition: border-color 150ms ease;
}

.image-stage.is-dragging {
  border-color: var(--accent);
}

.upload-prompt {
  display: grid;
  max-width: 360px;
  padding: 32px;
  place-items: center;
  color: var(--muted-strong);
  text-align: center;
  cursor: pointer;
}

.upload-prompt strong {
  margin-top: 13px;
  font-size: 0.88rem;
}

.upload-prompt > span:last-child {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.68rem;
}

.upload-icon {
  display: grid;
  width: 49px;
  height: 49px;
  place-items: center;
  border: 1px solid rgba(85, 232, 197, 0.25);
  border-radius: 14px;
  color: var(--accent);
  background: var(--accent-soft);
}

.upload-icon svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.image-surface {
  position: relative;
  flex: 0 0 auto;
  overflow: visible;
  line-height: 0;
  background: #fff;
  box-shadow: 0 9px 30px rgba(0, 0, 0, 0.35);
}

#imagePreview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

.result-overlay,
.overlay-labels {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.result-overlay {
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}

.overlay-labels {
  z-index: 3;
  pointer-events: none;
}

.overlay-entity {
  cursor: pointer;
  pointer-events: visiblePainted;
}

.callout-outline {
  fill: rgba(34, 211, 238, 0.055);
  stroke: var(--cyan);
  stroke-width: 2;
  stroke-dasharray: 8 6;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
  transition: fill 130ms ease, stroke-width 130ms ease;
}

.model-locator-line {
  fill: none;
  stroke: var(--locator);
  stroke-width: 2;
  stroke-dasharray: 8 6;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
}

.anchor-link-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 3 4;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
}

.leader-tip {
  fill: rgba(255, 180, 84, 0.22);
  stroke: var(--locator);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
}

.target-anchor {
  fill: var(--accent);
  stroke: rgba(7, 16, 15, 0.85);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
}

.target-anchor.is-primary {
  fill: var(--accent);
  stroke: #073d32;
}

.target-anchor.is-additional {
  fill: var(--cyan);
  stroke: #064653;
}

.overlay-id-label {
  position: absolute;
  z-index: 2;
  min-width: 32px;
  padding: 4px 6px;
  border: 2px solid var(--accent);
  border-radius: 7px;
  color: #fff;
  background: rgba(9, 22, 19, 0.94);
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.36);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.67rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  transform:
    translate(-50%, calc(-100% - var(--label-shift-y, 8px)))
    translateX(var(--label-shift-x, 0));
}

.overlay-id-label.is-candidate {
  border-color: var(--warning);
  color: #fff2c7;
}

.overlay-id-label.is-primary {
  border-color: var(--accent);
  color: #eafff9;
  background: rgba(9, 52, 43, 0.96);
}

.overlay-id-label.is-additional {
  border-color: var(--cyan);
  color: #d8fbff;
  background: rgba(6, 49, 56, 0.96);
}

.overlay-entity.is-linked-active .callout-outline,
.overlay-entity.is-linked-selected .callout-outline {
  fill: rgba(34, 211, 238, 0.15);
  stroke-width: 4;
}

.overlay-entity.is-linked-active .model-locator-line,
.overlay-entity.is-linked-selected .model-locator-line {
  stroke-width: 4;
  filter: drop-shadow(0 0 4px rgba(255, 180, 84, 0.88));
}

.overlay-entity.is-linked-active .anchor-link-line,
.overlay-entity.is-linked-selected .anchor-link-line {
  stroke-width: 4;
  filter: drop-shadow(0 0 4px rgba(85, 232, 197, 0.9));
}

.overlay-entity.is-linked-active .leader-tip,
.overlay-entity.is-linked-selected .leader-tip,
.overlay-entity.is-linked-active .target-anchor,
.overlay-entity.is-linked-selected .target-anchor {
  stroke-width: 5;
  filter: drop-shadow(0 0 5px rgba(85, 232, 197, 0.9));
}

.overlay-id-label.is-linked-active,
.overlay-id-label.is-linked-selected {
  border-color: #fff;
  background: #0d6b59;
  box-shadow: 0 0 0 3px rgba(85, 232, 197, 0.32), 0 4px 12px rgba(0, 0, 0, 0.42);
}

.drop-overlay {
  position: absolute;
  z-index: 8;
  inset: 9px;
  display: none;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 9px;
  color: var(--accent);
  background: rgba(6, 19, 16, 0.9);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.image-stage.is-dragging .drop-overlay {
  display: grid;
}

.visual-hint {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.5;
}

.side-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.result-panel {
  padding: 14px;
}

.result-heading {
  flex-wrap: wrap;
}

.result-actions {
  display: flex;
  gap: 6px;
}

.result-empty {
  display: grid;
  min-height: 185px;
  place-content: center;
  text-align: center;
}

.result-empty strong {
  font-size: 0.9rem;
}

.result-empty p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.id-summary {
  display: flex;
  gap: 12px;
  padding: 11px 12px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(85, 232, 197, 0.18);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(85, 232, 197, 0.09), rgba(34, 211, 238, 0.035));
}

.id-list {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.id-pill {
  display: inline-flex;
  min-height: 27px;
  padding: 0 8px;
  align-items: center;
  border: 1px solid rgba(85, 232, 197, 0.35);
  border-radius: 999px;
  color: #c6ffef;
  background: rgba(4, 16, 13, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 850;
}

.id-empty {
  color: var(--muted);
  font-size: 0.68rem;
}

.callout-results {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.callout-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(5, 14, 12, 0.5);
  cursor: pointer;
  transition: border-color 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

.callout-card.is-linked-active,
.callout-card.is-linked-selected {
  border-color: rgba(34, 211, 238, 0.7);
  background: rgba(34, 211, 238, 0.055);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.1);
}

.callout-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  padding: 11px 12px;
  align-items: start;
  border-bottom: 1px solid var(--line);
}

.callout-number {
  display: grid;
  min-width: 40px;
  height: 24px;
  padding: 0 6px;
  place-items: center;
  border: 1px solid rgba(34, 211, 238, 0.42);
  border-radius: 7px;
  color: #abf3fe;
  background: rgba(34, 211, 238, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.63rem;
  font-weight: 800;
}

.callout-copy {
  min-width: 0;
}

.callout-copy strong {
  display: block;
  color: var(--muted-strong);
  font-size: 0.75rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.status-chip {
  display: inline-flex;
  min-height: 22px;
  padding: 0 7px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.6rem;
  white-space: nowrap;
}

.status-chip[data-status="matched"] {
  border-color: rgba(121, 230, 168, 0.3);
  color: #baf4d0;
  background: rgba(121, 230, 168, 0.07);
}

.status-chip[data-status="ambiguous"],
.status-chip[data-status="partially_matched"] {
  border-color: rgba(243, 201, 105, 0.34);
  color: #f9dda0;
  background: rgba(243, 201, 105, 0.07);
}

.status-chip[data-status="not_found"],
.status-chip[data-status="not_fenceline"] {
  border-color: rgba(255, 130, 145, 0.27);
  color: #ffc1c9;
  background: rgba(255, 130, 145, 0.06);
}

.leader-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.leader-row {
  display: grid;
  grid-template-columns: minmax(68px, auto) minmax(0, 1fr);
  gap: 11px;
  padding: 10px 12px;
  background: #0c1b18;
  cursor: pointer;
  transition: background 130ms ease, box-shadow 130ms ease;
}

.leader-row.is-linked-active,
.leader-row.is-linked-selected {
  position: relative;
  z-index: 1;
  background: rgba(85, 232, 197, 0.095);
  box-shadow: inset 3px 0 var(--accent);
}

.leader-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.leader-title strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.66rem;
}

.leader-data {
  display: grid;
  gap: 6px;
}

.data-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.data-label {
  flex: 0 0 57px;
  padding-top: 3px;
  color: var(--muted);
  font-size: 0.61rem;
}

.data-values {
  display: flex;
  gap: 5px;
  min-width: 0;
  flex-wrap: wrap;
}

.mini-id {
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: #d7e7e2;
  background: rgba(255, 255, 255, 0.025);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.64rem;
  font-weight: 750;
}

.mini-id.is-primary {
  border-color: rgba(85, 232, 197, 0.42);
  color: #c4ffef;
  background: rgba(85, 232, 197, 0.08);
}

.mini-id.is-candidate {
  border-color: rgba(243, 201, 105, 0.36);
  color: #f5dda6;
}

.reason-text,
.empty-leaders {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.5;
}

.empty-leaders {
  padding: 11px 12px;
  background: #0c1b18;
}

.raw-result {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(4, 11, 10, 0.55);
}

.raw-result summary {
  padding: 10px 12px;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 0.69rem;
  user-select: none;
}

.raw-result pre {
  max-height: 410px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  color: #c1ddd4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.63rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.prompt-panel > summary {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.prompt-panel > summary::-webkit-details-marker {
  display: none;
}

.prompt-panel > summary::after {
  color: var(--muted);
  content: "⌄";
  font-size: 1rem;
  transition: transform 150ms ease;
}

.prompt-panel[open] > summary::after {
  transform: rotate(180deg);
}

.prompt-panel > summary > span:first-child {
  min-width: 0;
}

.prompt-panel > summary strong {
  display: block;
  font-size: 0.83rem;
}

.prompt-state {
  margin-left: auto;
  color: var(--accent);
  font-size: 0.64rem;
  white-space: nowrap;
}

.prompt-content {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.prompt-source,
.prompt-note {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.5;
}

.prompt-note {
  margin: 0;
}

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

.prompt-heading h3 {
  margin: 0;
  font-size: 0.72rem;
}

.prompt-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.prompt-length {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.58rem;
  white-space: nowrap;
}

.prompt-length.is-invalid {
  color: var(--danger);
}

.prompt-content pre,
.prompt-editor {
  max-height: 42vh;
  margin: 0;
  overflow: auto;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #c7ddd6;
  background: rgba(4, 11, 10, 0.62);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.prompt-editor {
  width: 100%;
  min-height: 300px;
  resize: vertical;
}

.prompt-editor:not(:disabled):hover {
  border-color: var(--line-strong);
}

.prompt-editor:disabled {
  cursor: wait;
  opacity: 0.72;
}

footer {
  display: flex;
  width: min(1900px, calc(100% - 28px));
  margin: 0 auto;
  padding: 0 0 24px;
  gap: 18px;
  justify-content: space-between;
  color: #6f827c;
  font-size: 0.62rem;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1250px) {
  .control-panel {
    grid-template-columns: minmax(230px, 0.8fr) minmax(220px, 0.75fr) minmax(230px, 1fr);
  }

  .control-actions {
    grid-column: 3;
    justify-self: end;
  }

  .compact-field {
    grid-column: 3;
    grid-row: 1;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 380px);
  }
}

@media (max-width: 980px) {
  .control-panel {
    grid-template-columns: minmax(210px, 0.8fr) minmax(230px, 1fr) auto;
  }

  .control-file {
    grid-column: 1;
    grid-row: 2;
  }

  .compact-field {
    grid-column: 2;
    grid-row: 2;
  }

  .control-actions {
    grid-column: 3;
    grid-row: 2;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .visual-panel {
    position: static;
  }

  .side-column {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.72fr);
    align-items: start;
  }
}

@media (max-width: 720px) {
  .site-header {
    min-height: 54px;
    padding: 8px 12px;
  }

  .header-badge {
    display: none;
  }

  .app-shell {
    width: calc(100% - 16px);
    padding-top: 8px;
  }

  .control-panel {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .control-title,
  .control-file,
  .compact-field,
  .control-actions {
    grid-column: 1;
    grid-row: auto;
  }

  .control-file {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .control-actions {
    justify-self: stretch;
  }

  .primary-button {
    flex: 1;
  }

  .visual-heading {
    align-items: flex-start;
  }

  .overlay-legend {
    max-width: 160px;
  }

  .image-stage {
    min-height: 370px;
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .result-actions {
    width: 100%;
  }

  .result-actions .secondary-button {
    flex: 1;
  }

  .id-summary {
    display: grid;
  }

  .id-list {
    justify-content: flex-start;
  }

  footer {
    display: grid;
    width: calc(100% - 18px);
  }
}

@media (max-width: 440px) {
  .brand strong {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand small {
    display: none;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .overlay-legend {
    display: none;
  }

  .callout-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .callout-header > .status-chip {
    grid-column: 2;
    justify-self: start;
  }

  .leader-row {
    grid-template-columns: 1fr;
  }

  .leader-title {
    flex-direction: row;
    align-items: center;
  }
}

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