:root {
  --bg: #f3efe6;
  --ink: #1f1d1a;
  --muted: #5f5a52;
  --card: rgba(255, 255, 255, 0.76);
  --stroke: rgba(31, 29, 26, 0.16);
  --ok: #2f8f4e;
  --warn: #b57d1b;
  --error: #b03028;
  --accent: #085f63;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #fef1d9 0%, transparent 40%),
    radial-gradient(circle at 80% 15%, #cee9e5 0%, transparent 35%),
    linear-gradient(165deg, #f9f7f2 0%, #ebe6dc 100%);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.6;
  pointer-events: none;
}

.orb-a {
  top: -120px;
  right: -80px;
  background: #a8d3cd;
}

.orb-b {
  bottom: -130px;
  left: -100px;
  background: #e3c79c;
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 18px 54px;
}

.workspace-grid {
  display: grid;
  gap: 18px;
  margin-top: 10px;
  align-items: start;
}

.hero {
  margin-bottom: 10px;
  animation: rise 0.5s ease-out;
}

.brand-row {
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

.brand-logo {
  height: clamp(48px, 5vw, 62px);
  width: auto;
  object-fit: contain;
}

.card {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 18px;
  margin-top: 18px;
  box-shadow: 0 14px 30px rgba(22, 20, 18, 0.08);
  animation: rise 0.5s ease-out;
}

.workspace-grid .card {
  margin-top: 0;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.mode-tab {
  border: 1px solid var(--stroke);
  background: #f7f3ec;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
}

.mode-tab.active {
  background: var(--ink);
  color: #f7f3ec;
}

.field {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

label {
  font-weight: 500;
}

input,
select,
textarea {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #fffcf8;
  padding: 12px;
  font-size: 15px;
  font-family: "IBM Plex Mono", monospace;
}

.pipeline-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

textarea {
  resize: vertical;
}

textarea.error-highlight {
  border-color: rgba(176, 48, 40, 0.75);
  box-shadow: 0 0 0 2px rgba(176, 48, 40, 0.14);
  background: #fff6f4;
}

@keyframes jumpFlashPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(176, 48, 40, 0.45);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(176, 48, 40, 0);
  }
}

textarea.jump-flash {
  animation: jumpFlashPulse 0.55s ease-out;
}

.payload-highlight-hint {
  margin: 0;
  color: #8f261f;
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
}

.payload-preview-wrap {
  margin-top: 12px;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  background: #fffaf2;
  padding: 10px;
}

.payload-preview-label {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.payload-preview {
  margin: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #fffdf8;
  padding: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.payload-preview.invalid {
  border-color: rgba(176, 48, 40, 0.4);
  background: #fff6f4;
  color: #8f261f;
}

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

.discover-panel {
  margin-top: 12px;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  background: #fffdf8;
  padding: 10px;
}

.discover-title {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-family: "IBM Plex Mono", monospace;
}

.discover-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.discover-chip {
  border: 1px solid var(--stroke);
  background: #f6f0e6;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
}

.discover-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.discover-sample {
  margin-top: 10px;
  border-top: 1px dashed var(--stroke);
  padding-top: 10px;
}

.discover-sample-title {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 13px;
}

.discover-sample-why {
  margin: 0 0 8px;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.discover-sample-input {
  margin: 0;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #fffaf2;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

button {
  font-family: inherit;
  font-size: 14px;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

.btn-primary {
  border: none;
  color: #fff;
  background: linear-gradient(120deg, #085f63, #11757a);
  box-shadow: 0 10px 18px rgba(8, 95, 99, 0.2);
}

.btn-secondary {
  border: 1px solid var(--stroke);
  background: #f6f0e6;
}

.hidden {
  display: none;
}

/* Loader Animations */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loader-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(31, 29, 26, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.loader-inline.hidden {
  display: none !important;
}

.field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.field-wrapper select {
  flex: 1;
}

.field-wrapper .loader-inline {
  position: absolute;
  right: 10px;
  margin: 0;
  z-index: 1;
  pointer-events: none;
}

.result-loader {
  margin-left: auto;
}

.loader-text {
  animation: pulse 1.2s ease-in-out infinite;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result h2 {
  margin: 0;
}

.result.discover-mode #validation-metric-grid,
.result.discover-mode #pipeline-check,
.result.discover-mode #errors-block,
.result.discover-mode #warnings-block,
.result.discover-mode #raw-details {
  display: none !important;
}

.result-summary {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: #fffaf2;
  padding: 10px;
}

.metric-label {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 700;
  word-break: break-word;
}

.pipeline-check {
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: #f6f0e6;
  padding: 10px 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.pipeline-check.ok {
  border-color: rgba(47, 143, 78, 0.4);
  background: #e7f5ea;
  color: #1f6a36;
}

.pipeline-check.error {
  border-color: rgba(176, 48, 40, 0.4);
  background: #fbe8e6;
  color: #8f261f;
}

.issue-block {
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fffdf8;
}

.issue-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.issue-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.issue-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.issue-jump-btn {
  border: 1px solid var(--stroke);
  background: #fff6f4;
  color: #8f261f;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.issue-list.empty {
  list-style: none;
  padding-left: 0;
  color: var(--muted);
  font-style: italic;
}

.raw-details {
  margin-top: 12px;
}

.raw-details summary {
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--accent);
}

.pill {
  font-family: "IBM Plex Mono", monospace;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.pill.neutral {
  background: #ece7df;
  color: #5f5a52;
}

.pill.ok {
  background: #dbeedc;
  color: #1f6a36;
}

.pill.warn {
  background: #f6ead1;
  color: #8b5f12;
}

.pill.error {
  background: #f5d6d3;
  color: #8f261f;
}

pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 12px 0 0;
  border-radius: 12px;
  border: 1px dashed var(--stroke);
  background: #fffaf2;
  padding: 14px;
  max-height: 50vh;
  overflow: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 1000px) {
  .workspace-grid {
    grid-template-columns: minmax(520px, 1.15fr) minmax(420px, 0.85fr);
  }

  .workspace-grid .result {
    position: sticky;
    top: 16px;
  }

  .workspace-grid .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 20px 12px 36px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  .actions button {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-logo {
    height: 40px;
  }
}
