:root {
  --bg: #f3efe7;
  --card: #ffffff;
  --card-strong: #fffaf2;
  --text: #1e2933;
  --muted: #667085;
  --primary: #1f6f5f;
  --primary-hover: #18594c;
  --primary-soft: #e6f3ee;
  --accent: #c26a2d;
  --accent-soft: #fff1e7;
  --border: #d7d2c7;
  --shadow: 0 18px 48px rgba(43, 39, 32, 0.08);
  --status-insufficient: #9a6b13;
  --status-review: #b45f06;
  --status-risk: #b42318;
  --status-cautious: #13715b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI Variable Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(194, 106, 45, 0.14) 0%, rgba(194, 106, 45, 0) 34%),
    radial-gradient(circle at top right, rgba(31, 111, 95, 0.16) 0%, rgba(31, 111, 95, 0) 30%),
    linear-gradient(180deg, #f7f2e9 0%, #f3efe7 38%, #f9f7f2 100%);
}

.container {
  max-width: 1120px;
  margin: 28px auto;
  padding: 0 18px 32px;
  display: grid;
  gap: 18px;
}

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

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.08;
}

h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.top-section {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  gap: 24px;
  align-items: stretch;
  background:
    linear-gradient(135deg, rgba(255, 250, 242, 0.96), rgba(255, 255, 255, 0.96)),
    var(--card);
}

.hero-copy {
  display: grid;
  gap: 12px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 12px;
  text-transform: uppercase;
}

.hero-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  max-width: 62ch;
}

.hero-side {
  border: 1px solid rgba(31, 111, 95, 0.14);
  border-radius: 20px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(230, 243, 238, 0.96), rgba(255, 255, 255, 0.98));
}

.hero-side-title {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--primary);
}

.hero-checklist {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--text);
}

.disclaimer {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

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

.section-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.upload-summary,
.result-timestamp {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.upload-area {
  border: 1.5px dashed rgba(31, 111, 95, 0.32);
  border-radius: 22px;
  padding: 28px 24px;
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 12px;
  background: linear-gradient(180deg, rgba(230, 243, 238, 0.78), rgba(255, 255, 255, 0.98));
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.upload-area:hover,
.upload-area.is-dragging {
  transform: translateY(-1px);
  border-color: rgba(31, 111, 95, 0.7);
  box-shadow: 0 16px 30px rgba(31, 111, 95, 0.12);
  background: linear-gradient(180deg, rgba(230, 243, 238, 0.98), rgba(255, 255, 255, 0.98));
}

.upload-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.upload-subtitle {
  font-size: 14px;
  line-height: 1.6;
}

.upload-area input {
  display: none;
}

.upload-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.tip-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #8b4d20;
  font-size: 13px;
  border: 1px solid rgba(194, 106, 45, 0.18);
}

.thumbnail-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  min-height: 28px;
  margin-bottom: 16px;
}

.thumbnail-item {
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 18px;
  overflow: hidden;
  background: #f6f3ed;
  position: relative;
  box-shadow: 0 10px 24px rgba(28, 36, 45, 0.08);
}

.thumbnail-frame {
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.thumbnail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.thumbnail-meta {
  padding: 10px 12px 12px;
  display: grid;
  gap: 4px;
}

.thumbnail-name {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumbnail-detail {
  font-size: 12px;
  color: var(--muted);
}

.remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  border-radius: 8px;
  min-width: 46px;
  height: 28px;
  padding: 0 8px;
  background: rgba(16, 24, 40, 0.8);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.remove-btn:hover {
  background: rgba(16, 24, 40, 0.95);
}

.empty-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  padding: 10px 0;
}

.primary-btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(31, 111, 95, 0.24);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-btn {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.secondary-btn:hover {
  border-color: rgba(31, 111, 95, 0.35);
  background: #faf8f4;
}

.secondary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.focus-panel {
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.94);
}

.focus-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.focus-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.focus-option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.focus-option {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 999px;
  padding: 8px 12px;
  background: #faf8f4;
  cursor: pointer;
}

.focus-option input {
  margin: 0;
  accent-color: var(--primary);
}

.focus-option-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.focus-more-panel {
  margin-top: 10px;
}

.focus-more-panel summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  list-style: none;
}

.focus-more-panel summary::-webkit-details-marker {
  display: none;
}

.focus-option-grid-more {
  margin-top: 12px;
}

.analysis-timeline {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.analysis-timeline-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.analysis-timeline-compact .timeline-step {
  flex: 1 1 140px;
  min-width: 0;
  padding: 8px 10px;
  gap: 8px;
  align-items: center;
}

.analysis-timeline-compact .timeline-dot {
  width: 10px;
  height: 10px;
  margin-top: 0;
  flex-shrink: 0;
}

.analysis-timeline-compact .timeline-step strong {
  display: inline;
  font-size: 13px;
  margin-bottom: 0;
  margin-right: 4px;
  color: var(--text);
}

.analysis-timeline-compact .timeline-line {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.timeline-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #faf8f4;
  transition: border-color 160ms ease, background 160ms ease;
}

.timeline-step strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.timeline-step p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.timeline-step.is-active {
  border-color: rgba(31, 111, 95, 0.28);
  background: var(--primary-soft);
}

.timeline-step.is-done {
  border-color: rgba(19, 113, 91, 0.24);
  background: rgba(19, 113, 91, 0.08);
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 4px;
  background: #c8c6be;
  box-shadow: 0 0 0 5px rgba(200, 198, 190, 0.18);
}

.timeline-step.is-active .timeline-dot,
.timeline-step.is-done .timeline-dot {
  background: var(--primary);
  box-shadow: 0 0 0 5px rgba(31, 111, 95, 0.14);
}

.loading-state {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #faf8f4;
}

.loading-state p {
  margin: 0;
  font-size: 14px;
}

.loading-subtext {
  margin-top: 4px;
  color: var(--muted);
}

.loading-preview {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.loading-preview-item {
  padding: 10px 12px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 8px;
  background: #fff;
}

.loading-preview-label {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.loading-preview-value {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.error-text {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid #f7c8c4;
  border-radius: 14px;
  background: #fff3f2;
  color: #b42318;
  font-size: 13px;
  line-height: 1.6;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cfd4dc;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.result-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 16px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid rgba(31, 111, 95, 0.14);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(230, 243, 238, 0.94), rgba(255, 255, 255, 0.98));
}

.result-hero-copy,
.result-hero-side,
.result-stack {
  display: grid;
  gap: 12px;
}

.result-hero-side {
  align-content: stretch;
}

.result-side-section {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.recommendation-panel {
  display: grid;
  gap: 10px;
}

.recommendation-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.signal-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
}

.signal-red {
  color: var(--status-risk);
  background: #fff1f1;
  border-color: #f7c8c4;
}

.signal-yellow {
  color: var(--status-review);
  background: #fff5df;
  border-color: #f7d79a;
}

.signal-green {
  color: var(--status-cautious);
  background: #ecf8f4;
  border-color: #acd9ca;
}

.recommendation-summary {
  margin: 0;
  font-size: 20px;
  line-height: 1.55;
  color: var(--text);
}

.result-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

.result-grid {
  display: grid;
  gap: 14px;
}

.result-grid-simple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.result-grid-simple > .result-stack {
  display: contents;
}

.result-block {
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.92);
}

.risk-overview-block {
  background: linear-gradient(135deg, rgba(230, 243, 238, 0.9), rgba(255, 255, 255, 0.98));
}

.result-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.mini-label,
.result-side-label,
.result-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.mini-label,
.result-side-label {
  font-weight: 700;
}

.hero-judgement {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.hero-side-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.hero-side-list li {
  font-size: 14px;
  line-height: 1.6;
}

.result-subsection {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.result-section ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.result-block p {
  margin: 0;
}

.ingredient-raw {
  margin-top: 10px;
  min-height: 80px;
  max-height: 240px;
}

.ingredient-insight-list,
.action-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.action-section + .action-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.ingredient-raw-details {
  margin-top: 12px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 10px;
  background: #fbfaf7;
}

.ingredient-raw-details summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

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

.focus-result-block {
  margin-top: 14px;
}

.result-details,
.debug-details {
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.result-details {
  grid-column: 1 / -1;
}

.result-details summary,
.debug-details summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.result-details summary::-webkit-details-marker,
.debug-details summary::-webkit-details-marker {
  display: none;
}

.result-details-body {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.debug-details {
  margin-top: 4px;
}

.debug-details .detail-section {
  padding: 0 16px 16px;
}

#fieldCompleteness {
  color: var(--text);
  font-weight: 600;
  font-size: 24px;
}

.progress-track {
  margin-top: 12px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #ece8de;
  overflow: hidden;
}

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

.hint-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.strong-hint {
  color: var(--text);
  font-size: 15px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.field-card {
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  padding: 12px;
  background: #faf8f4;
}

.field-card-label {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-card-value {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}

.field-card-value.is-empty {
  color: var(--muted);
}

.priority-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.attention-list {
  display: grid;
  gap: 12px;
}

.attention-item {
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  padding: 14px;
  background: #faf8f4;
}

.attention-high {
  border-color: #f2c1bb;
  background: #fff6f5;
}

.attention-medium {
  border-color: #f0d49c;
  background: #fff9ef;
}

.attention-low {
  border-color: rgba(31, 111, 95, 0.18);
  background: #f5fbf8;
}

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

.attention-item-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.attention-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.attention-level-high {
  color: var(--status-risk);
  background: #fde7e4;
}

.attention-level-medium {
  color: var(--status-review);
  background: #fff2da;
}

.attention-level-low {
  color: var(--status-cautious);
  background: #e8f6f1;
}

.attention-item-detail,
.attention-item-scope {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.attention-item-scope {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.focus-note-grid {
  display: grid;
  gap: 12px;
}

.focus-note-card {
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  padding: 14px;
  background: #faf8f4;
}

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

.focus-note-title {
  margin: 0;
  font-size: 15px;
}

.focus-note-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.ocr-raw {
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8f5ef;
  min-height: 52px;
  max-height: 220px;
  white-space: pre-wrap;
  overflow: auto;
  font-size: 13px;
  line-height: 1.5;
}

.ocr-per-image {
  margin-top: 8px;
}

.ocr-per-image li {
  font-size: 13px;
  color: var(--muted);
}

.technical-block summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

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

.technical-content {
  margin-top: 12px;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  z-index: 100;
}

.image-modal img {
  max-width: min(900px, 92vw);
  max-height: 80vh;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #111827;
}

.modal-close {
  align-self: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
  color: #fff;
  padding: 6px 12px;
  cursor: pointer;
}

.hidden {
  display: none;
}

@media (min-width: 860px) {
  .focus-note-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 859px) {
  .top-section,
  .result-hero {
    grid-template-columns: 1fr;
  }

  .result-hero-side {
    gap: 10px;
  }

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

@media (max-width: 640px) {
  .container {
    margin: 18px auto;
    padding: 0 12px 24px;
  }

  .card {
    border-radius: 20px;
    padding: 18px;
  }

  .section-heading {
    flex-direction: column;
  }

  .focus-panel-header,
  .recommendation-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .upload-summary,
  .result-timestamp {
    white-space: normal;
  }

  .thumbnail-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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