:root {
  --bg: #f5f2ea;
  --bg-deep: #ebe5da;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-border: rgba(32, 45, 61, 0.08);
  --text: #17202b;
  --muted: #687383;
  --primary: #0f6bff;
  --primary-soft: rgba(15, 107, 255, 0.12);
  --success: #0f7b65;
  --shadow: 0 30px 80px rgba(66, 76, 92, 0.12);
  --shadow-soft: 0 18px 40px rgba(66, 76, 92, 0.08);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --max-width: 1240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(circle at top left, rgba(165, 214, 255, 0.34), transparent 38%),
    radial-gradient(circle at 85% 12%, rgba(180, 225, 216, 0.34), transparent 28%),
    linear-gradient(180deg, #f8f5ee 0%, #f2ece1 100%);
  color: var(--text);
  font-family: "Manrope", sans-serif;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 32, 43, 0.22) transparent;
}

body.modal-open {
  overflow: hidden;
}

body::-webkit-scrollbar,
.modal-scroll::-webkit-scrollbar,
.detected-panel::-webkit-scrollbar {
  width: 12px;
}

body::-webkit-scrollbar-track,
.modal-scroll::-webkit-scrollbar-track,
.detected-panel::-webkit-scrollbar-track {
  background: transparent;
}

body::-webkit-scrollbar-thumb,
.modal-scroll::-webkit-scrollbar-thumb,
.detected-panel::-webkit-scrollbar-thumb {
  background: rgba(23, 32, 43, 0.18);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

body::-webkit-scrollbar-thumb:hover,
.modal-scroll::-webkit-scrollbar-thumb:hover,
.detected-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(23, 32, 43, 0.28);
  background-clip: padding-box;
}

.ambient {
  position: fixed;
  inset: auto;
  pointer-events: none;
  filter: blur(32px);
  opacity: 0.6;
  z-index: 0;
}

.ambient-one {
  top: 7rem;
  right: -4rem;
  width: 22rem;
  height: 22rem;
  background: rgba(120, 173, 255, 0.26);
  border-radius: 50%;
}

.ambient-two {
  left: -5rem;
  bottom: 10rem;
  width: 24rem;
  height: 24rem;
  background: rgba(197, 223, 205, 0.3);
  border-radius: 50%;
}

.ambient-three {
  left: 40%;
  top: 28rem;
  width: 16rem;
  height: 16rem;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 50%;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 0 auto;
  padding: 0.75rem 0 0.95rem;
  min-height: 100svh;
  display: flex;
  align-items: center;
}

.workspace {
  opacity: 0;
  transform: translateY(24px);
  animation: revealUp 0.85s ease forwards;
}

.workspace {
  animation-delay: 0.08s;
}

.eyebrow,
.card-kicker,
.panel-label,
.upload-badge {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.workspace h2,
.insight-card h3,
.upload-card h3,
.modal-card h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
  letter-spacing: -0.04em;
}

.status-pill,
.mini-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(30, 40, 52, 0.08);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

.status-pill[data-variant="success"] .status-dot {
  background: linear-gradient(180deg, #1dd6a8, #0aa87d);
  box-shadow: 0 0 0 6px rgba(29, 214, 168, 0.16);
}

.status-pill[data-variant="warning"] .status-dot {
  background: linear-gradient(180deg, #ffb347, #ff8f1f);
  box-shadow: 0 0 0 6px rgba(255, 179, 71, 0.16);
}

.status-pill[data-variant="neutral"] .status-dot {
  background: linear-gradient(180deg, #8ea2ba, #6a7c92);
  box-shadow: 0 0 0 6px rgba(142, 162, 186, 0.16);
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: linear-gradient(180deg, #8ea2ba, #6a7c92);
  box-shadow: 0 0 0 6px rgba(142, 162, 186, 0.16);
}

.composer-card,
.insight-card,
.composer-card,
.insight-card,
.modal-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.hero-actions,
.upload-actions,
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 1.6rem;
}

.button {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition:
    transform 0.24s ease,
    box-shadow 0.24s ease,
    background 0.24s ease,
    color 0.24s ease,
    border-color 0.24s ease;
  font: inherit;
}

.button:hover,
.button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
  transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(15, 107, 255, 0.16);
  outline-offset: 2px;
}

.button-primary,
.button-secondary,
.button-ghost {
  min-height: 3.25rem;
  padding: 0 1.2rem;
  border-radius: 999px;
  font-weight: 700;
}

.button-primary {
  background: linear-gradient(135deg, #0f6bff, #2b87ff);
  color: #fff;
  box-shadow: 0 18px 32px rgba(15, 107, 255, 0.24);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  border: 1px solid rgba(26, 35, 47, 0.08);
}

.button-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px dashed rgba(26, 35, 47, 0.12);
}

.button-wide {
  width: 100%;
}

.signal-list p,
.workspace-caption,
.empty-state,
.logic-list,
.upload-card p,
.upload-hint,
.field-label,
.summary-strip p,
.metric-card p {
  color: var(--muted);
}

.workspace {
  width: 100%;
  padding: 1.05rem;
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-soft);
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.workspace h2 {
  margin-top: 0.3rem;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
}

.workspace-actions .button-secondary {
  min-width: 9rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  gap: 0.9rem;
  align-items: start;
}

.composer-card,
.insight-card {
  padding: 0.82rem;
  border-radius: var(--radius-xl);
}

.upload-card {
  padding: 1rem;
  border-radius: calc(var(--radius-xl) - 6px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 248, 252, 0.82));
  border: 1px dashed rgba(15, 107, 255, 0.24);
}

.upload-card.is-dragging {
  background: linear-gradient(180deg, rgba(241, 248, 255, 0.98), rgba(226, 239, 255, 0.84));
  border-color: rgba(15, 107, 255, 0.46);
}

.upload-card h3 {
  margin-top: 0.55rem;
  font-size: 1.28rem;
}

.upload-hint {
  margin-top: 0.72rem;
  font-size: 0.9rem;
}

.control-form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.72rem;
}

.field {
  display: grid;
  gap: 0.5rem;
}

.field-label {
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 3.05rem;
  padding: 0 1rem;
  border: 1px solid rgba(32, 45, 61, 0.1);
  border-radius: 1.05rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font: inherit;
}

.select-shell {
  position: relative;
}

.select-shell::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 0.65rem;
  height: 0.65rem;
  border-right: 2px solid rgba(23, 32, 43, 0.42);
  border-bottom: 2px solid rgba(23, 32, 43, 0.42);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

select {
  appearance: none;
}

.insight-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.insight-head h3 {
  margin-top: 0.45rem;
  font-size: 1.18rem;
}

.detected-panel,
.logic-panel,
.summary-strip,
.metric-card {
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(32, 45, 61, 0.08);
}

.detected-panel {
  min-height: 11.4rem;
  max-height: 15rem;
  margin-top: 0.75rem;
  padding: 0.85rem;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 32, 43, 0.2) transparent;
}

.detected-list {
  display: grid;
  gap: 0.75rem;
}

.detected-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(32, 45, 61, 0.07);
}

.detected-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.detected-row strong,
.metric-card h3 {
  font-size: 0.98rem;
}

.detected-row span {
  color: var(--muted);
  text-align: right;
  word-break: break-word;
}

.logic-panel {
  margin-top: 0.75rem;
  padding: 0.85rem;
}

.logic-list {
  margin: 0.58rem 0 0;
  padding-left: 1.2rem;
  line-height: 1.48;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 29, 0.35);
  backdrop-filter: blur(12px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 1080px);
  max-height: min(90vh, 860px);
  padding: 1.05rem;
  border-radius: 2rem;
  background: var(--surface-strong);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.modal-header h2 {
  margin-top: 0.45rem;
  font-size: clamp(1.7rem, 4vw, 2.7rem);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-scroll {
  overflow: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 32, 43, 0.22) transparent;
  scrollbar-gutter: stable;
  border-radius: calc(var(--radius-lg) - 2px);
  padding-right: 0.35rem;
  margin-top: 1rem;
}

.button-compact {
  min-height: 3rem;
  padding: 0 1rem;
}

.icon-button {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid rgba(32, 45, 61, 0.08);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  transition:
    transform 0.24s ease,
    background 0.24s ease;
}

.modal-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0 0 0.95rem;
  background:
    linear-gradient(180deg, rgba(248, 245, 238, 0.98) 0%, rgba(248, 245, 238, 0.94) 72%, rgba(248, 245, 238, 0) 100%);
  backdrop-filter: blur(14px);
}

.summary-strip {
  display: grid;
  gap: 0.32rem;
  align-content: start;
  min-height: 7.35rem;
  padding: 0.95rem 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 249, 252, 0.84));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.summary-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  padding: 0.36rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 107, 255, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-label::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: linear-gradient(180deg, #0f6bff, #56a1ff);
  box-shadow: 0 0 0 5px rgba(15, 107, 255, 0.1);
}

.summary-strip strong {
  display: block;
  font-family: "Sora", sans-serif;
  font-size: 1.08rem;
  letter-spacing: -0.04em;
  line-height: 1.2;
  word-break: break-word;
}

.summary-strip p {
  margin: 0.06rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 0.2rem;
}

.metric-card {
  padding: 1rem;
}

.metric-card p {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.metric-value {
  font-family: "Sora", sans-serif;
  font-size: 1.55rem;
  letter-spacing: -0.05em;
}

.metric-note {
  margin-top: 0.65rem;
  font-size: 0.91rem;
  color: var(--muted);
  line-height: 1.55;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .workspace-grid,
  .modal-summary,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-strip {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(calc(100% - 1rem), var(--max-width));
    min-height: auto;
    padding: 0.65rem 0 0.85rem;
  }

  .composer-card,
  .insight-card,
  .workspace,
  .modal-card {
    padding: 1rem;
  }

  .upload-actions,
  .hero-actions,
  .modal-actions,
  .workspace-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .workspace h2 {
    font-size: 1.45rem;
  }

  .button-primary,
  .button-secondary,
  .button-ghost {
    width: 100%;
  }

  .icon-button {
    width: 100%;
    border-radius: 999px;
  }

  .modal-summary {
    padding-bottom: 0.8rem;
  }
}

@media (max-height: 960px) and (min-width: 721px) {
  .shell {
    padding: 0.55rem 0 0.7rem;
    align-items: stretch;
  }

  .workspace {
    padding: 0.95rem;
  }

  .workspace-header {
    margin-bottom: 0.72rem;
  }

  .workspace h2 {
    font-size: clamp(1.45rem, 2.4vw, 2.1rem);
  }

  .status-pill,
  .mini-chip {
    padding: 0.62rem 0.9rem;
    font-size: 0.86rem;
  }

  .composer-card,
  .insight-card {
    padding: 0.75rem;
  }

  .upload-card {
    padding: 0.9rem;
  }

  .upload-card h3 {
    font-size: 1.18rem;
  }

  .upload-hint,
  .upload-card p,
  .logic-list,
  .field-label,
  .detected-row strong,
  .detected-row span {
    font-size: 0.88rem;
  }

  .control-form {
    gap: 0.6rem;
    margin-top: 0.65rem;
  }

  .button-primary,
  .button-secondary,
  .button-ghost,
  input,
  select {
    min-height: 2.95rem;
  }

  .detected-panel {
    min-height: 9.8rem;
    max-height: 12.75rem;
    margin-top: 0.65rem;
    padding: 0.8rem;
  }

  .logic-panel {
    margin-top: 0.65rem;
    padding: 0.8rem;
  }
}
