/* ------------------------------------------------------------------ */
/* Example-data page                                                   */
/* ------------------------------------------------------------------ */

.derive-page {
  background:
    radial-gradient(850px 500px at 50% -8%, rgba(168, 121, 255, 0.09), transparent 68%),
    var(--bg);
}

.derive-main {
  padding-bottom: 78px;
}

.derive-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 29px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.035em;
}

.derive-breadcrumb a {
  color: var(--muted-dim);
  transition: color 150ms ease;
}

.derive-breadcrumb a:hover {
  color: var(--ink-soft);
}

.derive-breadcrumb span:last-child {
  color: var(--muted);
}

.derive-stage {
  width: min(100%, 900px);
  margin: 24px auto 0;
}

.derive-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.024), transparent 160px),
    var(--panel);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.25),
    inset 0 1px rgba(255, 255, 255, 0.035);
  animation: intro-rise 420ms cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.derive-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 30px;
  width: 38px;
  height: 1px;
  background: var(--accent);
}

.derive-card-head {
  padding: 30px 32px 24px;
}

.derive-headline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.derive-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-dim);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.kicker-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.derive-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.derive-icon-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
}

.derive-icon-button .icon {
  width: 15px;
  height: 15px;
}

.derive-card h1 {
  max-width: 750px;
  margin-top: 14px;
  color: var(--ink);
  font-size: clamp(31px, 4.5vw, 43px);
  font-weight: 550;
  line-height: 1.07;
  letter-spacing: -0.052em;
}

.derive-card h1 span {
  color: var(--cream);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.04em;
}

.derive-lede {
  max-width: 620px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.derive-editor {
  padding: 0 32px 28px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 1px 0 9px;
}

.editor-label {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 550;
}

.format-badges {
  display: flex;
  align-items: center;
  gap: 5px;
}

.format-badge {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 6px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.format-badge.is-auto {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.editor-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-deep);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.editor-frame:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 121, 255, 0.1);
}

.example-input {
  display: block;
  width: 100%;
  min-height: 268px;
  max-height: 520px;
  padding: 17px 18px;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.8;
  tab-size: 2;
}

.example-input::placeholder {
  color: var(--faint);
}

.editor-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 31px;
  padding: 0 13px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.018);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
}

#detectedFormat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#detectedFormat.is-detected {
  color: var(--accent);
}

.derive-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 13px;
}

.derive-select-label {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.derive-select-shell {
  width: 155px;
}

.derive-select-shell .select-control {
  height: 36px;
  padding-left: 11px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
}

.derive-select-shell .select-chevron {
  right: 10px;
  width: 13px;
  height: 13px;
}

.derive-select-label.is-disabled {
  opacity: 0.45;
}

.sample-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.025em;
  cursor: pointer;
  transition: color 150ms ease;
}

.sample-button:hover {
  color: var(--accent);
}

.sample-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.sample-button-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
}

.derive-error {
  margin-top: 13px;
  padding: 10px 12px;
  border: 1px solid rgba(242, 138, 154, 0.3);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #f0b5aa;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.6;
}

.derive-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 72px;
  padding: 13px 32px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.014);
}

.derive-privacy {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.015em;
}

.derive-privacy .status-dot {
  width: 5px;
  height: 5px;
  box-shadow: none;
}

.derive-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.derive-actions .button {
  min-height: 42px;
  padding-inline: 21px;
  font-size: 10px;
}

.derive-actions .button-primary {
  min-width: 126px;
}

.button-arrow {
  margin-left: 2px;
  font-size: 14px;
  line-height: 0;
}

.derive-actions .button.is-busy {
  cursor: wait;
  opacity: 0.75;
}

/* ------------------------------------------------------------------ */
/* Review                                                              */
/* ------------------------------------------------------------------ */

.review-card .derive-card-head {
  padding-bottom: 19px;
}

.review-card h1 {
  margin-top: 12px;
}

.review-card h1:focus,
.review-card h1:focus-visible {
  outline: none;
}

.review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 32px 19px;
}

.review-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.015em;
}

.review-chip.is-accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.review-chip strong {
  color: var(--ink-soft);
  font-weight: 500;
}

.review-table-wrap {
  margin: 0 32px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--field);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.review-table {
  width: 100%;
  min-width: 620px;
  border-spacing: 0;
  border-collapse: separate;
  font-size: 11px;
}

.review-table th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.022);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.review-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  color: var(--ink-soft);
  vertical-align: middle;
}

.review-table tr:last-child td {
  border-bottom: 0;
}

.review-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.022);
}

.field-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
}

.field-key-block {
  min-width: 0;
}

.review-field-key {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-source {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-chip {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 7px;
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
  white-space: nowrap;
}

.blank-cell {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  white-space: nowrap;
}

.sample-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
}

.sample-pill {
  display: inline-flex;
  align-items: center;
  max-width: 152px;
  height: 20px;
  padding: 0 6px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.parsed-preview {
  margin: 14px 32px 22px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.012);
}

.parsed-preview summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 39px;
  padding: 0 13px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.parsed-preview summary::-webkit-details-marker {
  display: none;
}

.parsed-preview summary:hover {
  color: var(--ink-soft);
}

.parsed-preview summary .icon {
  width: 13px;
  height: 13px;
  margin-left: auto;
  transition: transform 150ms ease;
}

.parsed-preview[open] summary .icon {
  transform: rotate(180deg);
}

.summary-meta {
  color: var(--faint);
  font-size: 7.5px;
}

.parsed-preview-scroll {
  max-height: 260px;
  overflow: auto;
  border-top: 1px solid var(--line-soft);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.parsed-table {
  width: max-content;
  min-width: 100%;
  border-spacing: 0;
  border-collapse: separate;
  font-family: var(--mono);
  font-size: 9.5px;
}

.parsed-table th,
.parsed-table td {
  max-width: 230px;
  padding: 8px 12px;
  overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.parsed-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--panel-soft);
  color: var(--faint);
  font-size: 8px;
  font-weight: 500;
}

.parsed-table td {
  color: var(--muted);
}

.parsed-table td.is-empty {
  color: var(--faint);
}

.parsed-table tr:last-child td {
  border-bottom: 0;
}

.review-foot {
  min-height: 78px;
}

/* ------------------------------------------------------------------ */
/* Steps                                                               */
/* ------------------------------------------------------------------ */

.derive-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.012);
}

.derive-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 60px;
  padding: 14px 16px;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.5;
}

.derive-note + .derive-note {
  border-left: 1px solid var(--line-soft);
}

.derive-note strong {
  color: var(--muted);
  font-weight: 550;
}

.note-index {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------------ */

/* ------------------------------------------------------------------ */
/* Typography refinement                                               */
/* ------------------------------------------------------------------ */

.derive-breadcrumb {
  font-size: 11px;
}

.derive-kicker {
  font-size: 10.5px;
}

.derive-lede {
  font-size: 16px;
}

.editor-label {
  font-size: 13px;
}

.format-badge {
  font-size: 10.5px;
}

.example-input {
  font-size: 14.5px;
}

.editor-statusbar {
  font-size: 11.5px;
}

.derive-select-label {
  font-size: 14px;
}

.derive-select-shell .select-control {
  font-size: 13.5px;
}

.sample-button {
  font-size: 12.5px;
}

.derive-error {
  font-size: 12.5px;
}

.derive-privacy {
  font-size: 11px;
}

.derive-actions .button {
  font-size: 13.5px;
}

.review-meta {
  font-size: 12px;
}

.review-table {
  font-size: 13.5px;
}

.review-table th {
  font-size: 10.5px;
}

.review-chip {
  font-size: 11px;
}

.review-field-key {
  font-size: 13.5px;
}

.field-source {
  font-size: 11px;
}

.type-chip {
  font-size: 11px;
}

.blank-cell {
  font-size: 12.5px;
}

.sample-pill {
  font-size: 11px;
}

.summary-meta {
  font-size: 11.5px;
}

.parsed-preview summary {
  font-size: 12px;
}

.parsed-table {
  font-size: 12.5px;
}

.derive-note {
  font-size: 13px;
}

.note-index {
  font-size: 10.5px;
}

/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 800px) {
  .derive-main {
    padding-bottom: 60px;
  }

  .derive-card-head {
    padding: 26px 24px 21px;
  }

  .derive-editor {
    padding: 0 24px 24px;
  }

  .derive-card-foot {
    padding-inline: 24px;
  }

  .review-meta {
    padding-inline: 24px;
  }

  .review-table-wrap {
    margin-inline: 24px;
  }

  .parsed-preview {
    margin-inline: 24px;
  }
}

@media (max-width: 700px) {
  .derive-breadcrumb {
    margin-top: 22px;
  }

  .derive-stage {
    margin-top: 18px;
  }

  .derive-card {
    border-radius: 11px;
  }

  .derive-card-head {
    padding: 22px 18px 19px;
  }

  .derive-card h1 {
    margin-top: 12px;
    font-size: clamp(28px, 8.4vw, 36px);
  }

  .derive-lede {
    font-size: 12.5px;
  }

  .derive-editor {
    padding: 0 18px 20px;
  }

  .example-input {
    min-height: 236px;
    padding: 14px;
    font-size: 11px;
    line-height: 1.75;
  }

  .editor-statusbar {
    padding-inline: 10px;
    font-size: 7.5px;
  }

  .derive-options {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .derive-select-label {
    width: 100%;
    justify-content: space-between;
  }

  .derive-select-shell {
    width: 168px;
  }

  .sample-button {
    padding-left: 2px;
  }

  .derive-card-foot {
    flex-wrap: wrap;
    gap: 11px;
    padding: 12px 18px;
  }

  .derive-privacy {
    width: 100%;
    font-size: 7.5px;
  }

  .derive-actions {
    width: 100%;
  }

  .derive-actions .button {
    flex: 1 1 auto;
  }

  .review-meta {
    padding: 0 18px 16px;
  }

  .review-table-wrap {
    margin-inline: 18px;
    overflow: hidden;
  }

  .review-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .review-table thead {
    display: none;
  }

  .review-table tbody {
    display: block;
  }

  .review-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 12px 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  }

  .review-table tr:last-child {
    border-bottom: 0;
  }

  .review-table td {
    display: block;
    padding: 0;
    border: 0;
  }

  .review-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .review-table td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .review-table td:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
  }

  .review-table td:nth-child(3)::before {
    content: "Blank";
    margin-right: 7px;
    color: var(--faint);
    font-family: var(--mono);
    font-size: 7px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .review-table td:nth-child(4) {
    grid-column: 1 / -1;
    grid-row: 3;
    padding-top: 7px;
    border-top: 1px dashed var(--line-soft);
  }

  .review-table td:nth-child(4)::before {
    display: block;
    margin-bottom: 5px;
    content: "Examples";
    color: var(--faint);
    font-family: var(--mono);
    font-size: 7px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .sample-values {
    max-width: none;
  }

  .parsed-preview {
    margin: 13px 18px 19px;
  }

  .derive-notes {
    grid-template-columns: 1fr;
    margin-top: 12px;
  }

  .derive-note {
    min-height: 0;
    padding: 11px 13px;
    font-size: 10px;
  }

  .derive-note + .derive-note {
    border-top: 1px solid var(--line-soft);
    border-left: 0;
  }
}

@media (max-width: 420px) {
  .derive-card-head {
    padding-inline: 15px;
  }

  .derive-editor {
    padding-inline: 15px;
  }

  .derive-card-foot {
    padding-inline: 15px;
  }

  .derive-card h1 {
    font-size: 28px;
  }

  .editor-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .format-badge {
    font-size: 6.5px;
  }

  .derive-select-shell {
    width: 156px;
  }

  .review-meta {
    padding-inline: 15px;
  }

  .review-table-wrap {
    margin-inline: 15px;
  }

  .parsed-preview {
    margin-inline: 15px;
  }

  .derive-privacy {
    line-height: 1.5;
  }

  .derive-actions .button {
    padding-inline: 12px;
  }

  .derive-actions .button-primary {
    min-width: 0;
  }
}
