:root {
  --bg: #f6f7fa;
  --bg-strong: #edf0f5;
  --ink: #040404;
  --muted: #626875;
  --accent: #ea495b;
  --accent-2: #141824;
  --accent-3: #cdd5e3;
  --card: #ffffff;
  --surface-soft: rgba(234, 73, 91, 0.06);
  --surface-neutral: rgba(17, 24, 39, 0.04);
  --surface-strong: rgba(17, 24, 39, 0.08);
  --stroke: rgba(17, 24, 39, 0.08);
  --shadow: 0 18px 48px rgba(17, 24, 39, 0.08);
  --radius: 24px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f6f7fa 0%, #f1f4f9 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.orb {
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.55;
  z-index: 0;
}

.orb--one {
  background: radial-gradient(circle, rgba(234, 73, 91, 0.16), transparent 65%);
  top: -120px;
  left: -80px;
}

.orb--two {
  background: radial-gradient(circle, rgba(108, 130, 181, 0.14), transparent 70%);
  bottom: -120px;
  right: -120px;
}

.orb--three {
  background: radial-gradient(circle, rgba(205, 213, 227, 0.28), transparent 70%);
  top: 40%;
  right: 10%;
  width: 280px;
  height: 280px;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
  align-items: center;
}

body.mode-auto-export .page {
  padding-top: 24px;
}

body.mode-auto-export .hero {
  display: none;
}

body.mode-auto-export .results {
  margin-top: 0;
}

.hero__text h1 {
  font-family: "Bricolage Grotesque", "IBM Plex Sans", sans-serif;
  font-size: clamp(2.4rem, 3.6vw, 3.6rem);
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 600;
  color: var(--accent-2);
  margin-bottom: 18px;
}

.lead {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 20px;
}

.hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero__chips span {
  background: rgba(234, 73, 91, 0.08);
  color: var(--accent);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.upload {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.dropzone {
  position: relative;
  border: 1px dashed rgba(17, 24, 39, 0.16);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  background: rgba(17, 24, 39, 0.02);
  transition: transform var(--transition), border-color var(--transition);
}

.dropzone.dragover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone__content h3 {
  margin: 0 0 8px;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 1.2rem;
}

.dropzone__content p {
  margin: 0 0 12px;
  color: var(--muted);
}

.dropzone__file {
  display: inline-block;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.06);
}

.upload__field {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.upload__field select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--card);
  font-size: 0.95rem;
  color: var(--ink);
}

.button {
  width: 100%;
  padding: 14px 18px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.button--primary {
  background: var(--accent);
  color: #fff;
  margin-top: 16px;
  box-shadow: 0 14px 28px rgba(234, 73, 91, 0.18);
}

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

.button--ghost {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  width: auto;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
}

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

.button:disabled,
.button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 10px;
}

.status {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--accent-2);
}

.status--info {
  color: var(--muted);
}

.status--success {
  color: var(--accent);
}

.status--error {
  color: #b53a2a;
}

.query-banner {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid rgba(234, 73, 91, 0.14);
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.query-banner strong {
  color: var(--accent);
  font-size: 0.88rem;
}

.query-banner p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.results {
  margin-top: 56px;
}

.hidden {
  display: none;
}

.section-head h2 {
  font-family: "Bricolage Grotesque", sans-serif;
  margin-bottom: 6px;
}

.section-head p {
  margin-top: 0;
  color: var(--muted);
}

.block {
  margin-bottom: 32px;
}

.block__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.block__title {
  flex: 1;
  min-width: 0;
}

.block__toggle {
  white-space: nowrap;
}

.block.is-collapsed [data-collapsible-body] {
  display: none;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 24px 0 32px;
}

.stat {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--stroke);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.05);
}

.stat__label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.stat__value {
  display: block;
  font-size: 1.6rem;
  font-weight: 600;
  margin-top: 6px;
  font-family: "Bricolage Grotesque", sans-serif;
}

.stat__hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 20px 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.card h3 {
  margin: 0 0 12px;
  font-family: "Bricolage Grotesque", sans-serif;
}

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

.card__head h3 {
  margin: 0;
}

.button--tiny {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 999px;
}

.card canvas {
  width: 100% !important;
  height: 320px !important;
}

.downloads {
  margin-bottom: 32px;
}

.downloads__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.success {
  margin-top: 48px;
}

.success__controls {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.success__note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.success__hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.success__formula {
  margin: 6px 0 22px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-neutral);
  border: 1px solid var(--stroke);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-line;
}

.success__config select {
  width: 100%;
}

.success__checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.success-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid var(--stroke);
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.success-toggle:hover {
  background: var(--surface-neutral);
}

.success-toggle__icon {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(28, 26, 23, 0.3);
  border-radius: 4px;
  position: relative;
  flex-shrink: 0;
}

.success-toggle[data-state="and"] .success-toggle__icon {
  border-color: var(--accent);
  background: var(--accent);
}

.success-toggle[data-state="and"] .success-toggle__icon::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

.success-toggle[data-state="or"] .success-toggle__icon {
  border-radius: 50%;
  border-color: var(--accent-3);
}

.success-toggle[data-state="or"] .success-toggle__icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-3);
  top: 2px;
  left: 2px;
}

.success-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: var(--surface-neutral);
  border: 1px solid var(--stroke);
}

.success-card__title {
  font-weight: 600;
  color: var(--ink);
}

.success-card__checks {
  display: grid;
  gap: 8px;
}

.success-card__note,
.success-card__empty {
  font-size: 0.8rem;
  color: var(--muted);
}

.button--inline {
  width: auto;
  margin-top: 0;
  justify-self: start;
}

.success__insights {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.insight {
  background: rgba(4, 116, 108, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

.table-wrap {
  margin-top: 40px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table--compact th,
.table--compact td {
  padding: 10px 12px;
  font-size: 0.85rem;
}

.classification {
  margin-top: 48px;
}

.subtopics {
  margin-top: 48px;
}

.subtopics__charts {
  margin-bottom: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.table__examples {
  max-width: 320px;
}

.classification__grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(280px, 0.9fr);
  gap: 20px;
  align-items: stretch;
}

.table-scroll {
  max-height: 70vh;
  min-height: 520px;
  height: 100%;
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  background: var(--card);
}

.table-scroll .table {
  border-radius: 0;
  box-shadow: none;
}

.table-scroll .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(234, 73, 91, 0.08);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.filters--classification {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
}

.filters--classification .filter {
  flex: 1 1 220px;
  min-width: 200px;
}

.filter {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.filter input,
.filter select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--card);
  font-size: 0.9rem;
  color: var(--ink);
}

.filter--checkbox {
  align-items: start;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--ink);
  font-size: 0.9rem;
}

.checkbox input {
  width: 16px;
  height: 16px;
}

.chat-viewer {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  max-height: 70vh;
  min-height: 520px;
  height: 100%;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-viewer__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-neutral);
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-viewer__toolbar span {
  font-weight: 600;
  color: var(--ink);
}

.chat-viewer--collapsed .chat-viewer__details {
  display: none;
}

.chat-viewer--collapsed {
  gap: 10px;
}


.chat-viewer__details {
  display: grid;
  gap: 14px;
}

.chat-head__title h3 {
  margin: 0 0 6px;
  font-family: "Bricolage Grotesque", sans-serif;
}

.chat-head__title span {
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-thread {
  background: var(--surface-neutral);
  border-radius: 16px;
  padding: 12px 14px;
  flex: 1;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.chat-thread__head {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--surface-neutral);
  padding-bottom: 6px;
  z-index: 1;
}

.chat-thread__messages {
  display: grid;
  gap: 12px;
}

.chat-viewer__flow {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(234, 73, 91, 0.06);
  font-size: 0.85rem;
  color: var(--muted);
}

.chat-viewer__flow strong {
  color: var(--accent);
}

.chat-viewer__flow ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.chat-viewer__flow li {
  margin-bottom: 4px;
}

.chat-flow__key {
  font-weight: 600;
  color: var(--ink);
}

.chat-flow__value {
  color: var(--muted);
}


.chat-message {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--surface-neutral);
  border-left: 3px solid rgba(17, 24, 39, 0.12);
  white-space: pre-wrap;
}

.chat-message--user {
  background: rgba(234, 73, 91, 0.1);
  border-left-color: rgba(234, 73, 91, 0.6);
}

.chat-message--aiso {
  background: rgba(108, 130, 181, 0.1);
  border-left-color: rgba(108, 130, 181, 0.55);
}

.chat-message__role {
  display: block;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  margin-bottom: 6px;
}

.table th,
.table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--stroke);
  font-size: 0.9rem;
}

.table__topic {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: rgba(234, 73, 91, 0.05);
}

.table th {
  background: rgba(234, 73, 91, 0.08);
  font-weight: 600;
}

.errors {
  margin-top: 28px;
  background: rgba(234, 73, 91, 0.08);
  border-radius: 14px;
  padding: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.errors ul {
  padding-left: 18px;
  margin: 8px 0 0;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.26);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
  padding: 24px;
  animation: modalFade 0.25s ease;
}

.modal.hidden {
  display: none;
}

.modal__card {
  background: var(--card);
  border-radius: 22px;
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
  text-align: left;
}

.modal__card h2 {
  font-family: "Bricolage Grotesque", sans-serif;
  margin: 0;
}

.modal__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--accent);
  margin: 0 0 12px;
  font-weight: 600;
}

.modal__lead {
  color: var(--muted);
  margin: 10px 0 18px;
}

.modal__stage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(234, 73, 91, 0.08);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(28, 26, 23, 0.08);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(120deg, var(--accent), var(--accent-3));
  transition: width 0.4s ease;
}

.modal__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 14px;
}

body.modal-open {
  overflow: hidden;
}

body.modal-open .page,
body.modal-open .orb {
  filter: blur(8px);
  transition: filter 0.35s ease;
}

body.modal-open .page {
  pointer-events: none;
}


@keyframes modalFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.is-ready [data-reveal] {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 720px) {
  .hero {
    grid-template-columns: 1fr;
  }

  body.mode-auto-export .page {
    padding-top: 20px;
  }

  .page {
    padding: 40px 18px 80px;
  }

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

  .chat-viewer {
    max-height: none;
    height: auto;
  }

  .chat-thread {
    max-height: 420px;
  }

  .downloads__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .table-scroll {
    max-height: 420px;
    min-height: auto;
    height: auto;
  }

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

  .table th,
  .table td {
    padding: 10px 12px;
    font-size: 0.8rem;
  }
}
