:root {
  color-scheme: dark;
  --bg: #08111e;
  --bg-2: #0d1727;
  --panel: rgba(13, 23, 39, 0.82);
  --panel-strong: rgba(15, 27, 46, 0.96);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #edf2ff;
  --muted: #9aa6bf;
  --accent: #8ef0d0;
  --accent-2: #7cb7ff;
  --accent-3: #ffd47e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(124, 183, 255, 0.24), transparent 26%),
    radial-gradient(circle at 85% 10%, rgba(142, 240, 208, 0.18), transparent 22%),
    radial-gradient(circle at 50% 110%, rgba(255, 212, 126, 0.1), transparent 28%),
    linear-gradient(180deg, #08111e 0%, #0a1320 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", "Aptos", "Inter", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(8, 17, 30, 0.6), rgba(8, 17, 30, 0.85)),
    radial-gradient(circle at 20% 20%, rgba(124, 183, 255, 0.14), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(142, 240, 208, 0.14), transparent 28%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 88%);
  opacity: 0.24;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 28px auto 44px;
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(17, 29, 49, 0.92), rgba(10, 18, 31, 0.9));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero {
  display: grid;
  gap: 16px;
  padding: 26px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -40px -70px auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(142, 240, 208, 0.22), transparent 70%);
  filter: blur(4px);
  pointer-events: none;
}

.hero-copy {
  max-width: 780px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}

h1,
h2,
h3,
.dropzone-copy strong {
  font-family: "Georgia", "Iowan Old Style", "Times New Roman", serif;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.95;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.1;
}

.lede {
  max-width: 62ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat strong {
  font-size: 0.98rem;
  color: var(--text);
}

.hero-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.88rem;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(142, 240, 208, 0.7);
  animation: pulse 1.8s infinite;
}

.upload-panel,
.canvas-panel,
.results-panel {
  padding: 20px;
}

.upload-form {
  display: grid;
  gap: 16px;
}

.dropzone {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  border: 1px dashed rgba(124, 183, 255, 0.4);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(17, 30, 51, 0.7), rgba(12, 21, 35, 0.8)),
    radial-gradient(circle at top left, rgba(124, 183, 255, 0.09), transparent 36%);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-active {
  transform: translateY(-1px);
  border-color: rgba(142, 240, 208, 0.7);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

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

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124, 183, 255, 0.2), rgba(142, 240, 208, 0.18));
  color: var(--accent);
  font-size: 1.25rem;
}

.dropzone-copy {
  display: grid;
  gap: 4px;
}

.dropzone-copy strong {
  font-size: 1rem;
}

.dropzone-copy span,
.file-name,
.meta-pill,
.progress-text,
.status {
  color: var(--muted);
}

.file-name {
  justify-self: end;
  font-size: 0.86rem;
}

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

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: #07111d;
  background: linear-gradient(135deg, var(--accent), #d7fff2);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(142, 240, 208, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(142, 240, 208, 0.22);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

button.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  box-shadow: none;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 2px;
}

.status {
  min-height: 20px;
  font-size: 0.94rem;
}

.progress-text {
  font-size: 0.86rem;
  white-space: nowrap;
}

.progress-track {
  height: 10px;
  margin-top: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 240ms ease;
}

.workspace {
  display: grid;
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.84rem;
}

.image-frame {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line);
}

.image-frame-large {
  min-height: 420px;
}

.img {
  width: 100%;
  display: block;
  max-height: 620px;
  object-fit: contain;
  background:
    radial-gradient(circle at 50% 10%, rgba(124, 183, 255, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.img:not([src]) {
  visibility: hidden;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
  background:
    radial-gradient(circle at 50% 32%, rgba(124, 183, 255, 0.14), transparent 18%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 1.4rem;
}

.items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.item {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.02)),
    var(--panel-strong);
  border: 1px solid var(--line);
}

.item-top {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: start;
}

.item h3 {
  margin: 0;
  font-size: 1rem;
}

.item .small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.78rem;
}

.item img {
  width: 100%;
  min-height: 240px;
  object-fit: contain;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(124, 183, 255, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
}

.item pre {
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: #dce6ff;
  font-size: 0.84rem;
  line-height: 1.6;
}

.item .error {
  color: #ffcfb8;
}

/* ── status tag variants ── */
.status-tag.status-gen { background: rgba(124, 183, 255, 0.12); border-color: rgba(124, 183, 255, 0.35); color: var(--accent-2); }
.status-tag.status-ready { background: rgba(255, 212, 126, 0.12); border-color: rgba(255, 212, 126, 0.35); color: var(--accent-3); }
.status-tag.status-complete { background: rgba(142, 240, 208, 0.12); border-color: rgba(142, 240, 208, 0.35); color: var(--accent); }
.status-tag.status-error { background: rgba(255, 130, 100, 0.14); border-color: rgba(255, 130, 100, 0.35); color: #ffcfb8; }

/* ── AI section (tags, scores, json) ── */
.ai-section {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.ai-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ai-tab {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  box-shadow: none;
  cursor: pointer;
  transition: background 140ms, color 140ms, border-color 140ms;
}

.ai-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.ai-tab.active {
  background: rgba(142, 240, 208, 0.1);
  border-color: rgba(142, 240, 208, 0.4);
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

.ai-tab-content {
  max-height: 420px;
  overflow: auto;
}

/* ── tag table ── */
.tag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.tag-table th {
  text-align: left;
  padding: 7px 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  position: sticky;
  top: 0;
  background: var(--panel-strong);
}

.tag-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.tag-group-cell {
  color: var(--accent-2);
  font-weight: 600;
  text-transform: capitalize;
}

.tag-key-cell {
  color: var(--accent-3);
}

.tag-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* ── scores bar ── */
.scores-grid {
  display: grid;
  gap: 10px;
}

.score-item {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  gap: 10px;
  align-items: center;
}

.score-label {
  text-transform: capitalize;
  font-size: 0.82rem;
  color: var(--muted);
}

.score-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 400ms ease;
}

.score-val {
  font-size: 0.82rem;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── JSON inside card ── */
.json-pre {
  margin: 0;
  max-height: 300px;
  overflow: auto;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: #b8d4ff;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── AI footer / embedding badge ── */
.ai-footer {
  font-size: 0.8rem;
}

.embed-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
}

.embed-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(124, 183, 255, 0.12);
  border: 1px solid rgba(124, 183, 255, 0.3);
  color: var(--accent-2);
}

.muted-text {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── JSON modal overlay ── */
.modal-overlay[hidden] {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 8, 16, 0.82);
  backdrop-filter: blur(12px);
}

.modal-panel {
  width: min(900px, 100%);
  max-height: 88vh;
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(17, 29, 49, 0.98), rgba(10, 18, 31, 0.96));
  border: 1px solid var(--line-strong);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  box-shadow: none;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  transform: none;
  box-shadow: none;
}

.modal-body {
  overflow: auto;
  padding: 20px 22px;
}

.modal-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #b8d4ff;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(142, 240, 208, 0.55);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(142, 240, 208, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(142, 240, 208, 0);
  }
}

@media (min-width: 860px) {
  .workspace {
    grid-template-columns: 1.06fr 0.94fr;
    align-items: start;
  }

  .items {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 1200px);
    margin-top: 10px;
  }

  .hero,
  .upload-panel,
  .canvas-panel,
  .results-panel {
    padding: 16px;
    border-radius: 22px;
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .dropzone {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon copy"
      "icon file";
  }

  .dropzone-icon {
    grid-row: span 2;
  }

  .file-name {
    justify-self: start;
  }

  .status-row,
  .section-head,
  .item-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .tag-row {
    justify-content: flex-start;
  }
}
