:root {
  color-scheme: dark;
  --bg: #0b0912;
  --bg-soft: #141022;
  --card: rgba(23, 18, 38, 0.92);
  --card-soft: rgba(31, 24, 49, 0.78);
  --border: rgba(255, 255, 255, 0.08);
  --text: #fff9ff;
  --text-soft: #d1c2e8;
  --text-weak: #9887b3;
  --accent: #8d6bff;
  --accent-soft: #e6a1ca;
  --danger: #f0a9b9;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(141, 107, 255, 0.14), transparent 28%),
    radial-gradient(circle at bottom right, rgba(230, 161, 202, 0.1), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
}

.page {
  max-width: 1260px;
  margin: 0 auto;
  padding: 48px 20px 72px;
}

.hero {
  max-width: 760px;
  margin-bottom: 28px;
}

.hero__eyebrow {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 14px 0 0;
  font-size: 38px;
  line-height: 1.08;
}

.hero p {
  margin: 14px 0 0;
  color: var(--text-soft);
  line-height: 1.8;
  font-size: 16px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.82fr);
  gap: 20px;
}

.column {
  display: grid;
  gap: 20px;
}

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

.card h2,
.result-block h3,
.preview-box__head h3 {
  margin: 0;
}

.section-head,
.preview-box__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: block;
}

.field--stack {
  margin-top: 18px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 14px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(14, 10, 24, 0.94);
  color: var(--text);
  outline: none;
  font: inherit;
}

.field input,
.field select {
  min-height: 52px;
  padding: 0 14px;
}

.field textarea {
  min-height: 240px;
  padding: 16px;
  resize: vertical;
  line-height: 1.7;
}

.upload-zone {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 22px;
  border: 1px dashed rgba(141, 107, 255, 0.34);
  border-radius: 22px;
  background: var(--card-soft);
  cursor: pointer;
}

.upload-zone input {
  display: none;
}

.upload-zone strong {
  font-size: 18px;
}

.upload-zone span,
.upload-zone em,
.empty,
.status,
.history-meta {
  color: var(--text-soft);
}

.upload-zone em {
  font-style: normal;
  color: var(--text-weak);
}

.preview-box {
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}

.actions {
  margin-top: 20px;
}

.button {
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.button--primary {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
}

.button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.status {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.status--loading {
  border-color: rgba(141, 107, 255, 0.26);
  color: var(--text);
}

.status--error {
  border-color: rgba(240, 169, 185, 0.26);
  color: #ffe4ea;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-weak);
  font-size: 12px;
}

.empty {
  margin-top: 18px;
  line-height: 1.8;
}

.result {
  margin-top: 18px;
  display: grid;
  gap: 16px;
}

.result-block {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}

.result-block p {
  margin: 12px 0 0;
  line-height: 1.8;
}

.result-block--inner {
  margin-top: 16px;
}

.list {
  margin: 12px 0 0;
  padding-left: 18px;
  line-height: 1.8;
}

.confidence-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.confidence-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.confidence-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 100%);
}

.confidence-value {
  min-width: 72px;
  color: var(--text-soft);
  font-size: 13px;
}

.memory-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  list-style: none;
}

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

.memory-grid {
  margin-top: 16px;
}

.preview-text {
  margin: 12px 0 0;
  padding: 16px;
  border-radius: 16px;
  background: rgba(10, 8, 18, 0.88);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
  color: var(--text-soft);
}

.preview-text--compact {
  max-height: 200px;
}

.history-list {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.history-item {
  width: 100%;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.history-item strong {
  display: block;
  font-size: 15px;
}

.history-meta {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.7;
}

.is-hidden {
  display: none;
}

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

@media (max-width: 640px) {
  .page {
    padding: 28px 14px 48px;
  }

  .hero h1 {
    font-size: 30px;
  }

  .field-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 18px;
  }
}
