:root {
  --paper: #f7f3ea;
  --paper-2: #fffaf0;
  --ink: #1f211d;
  --muted: #68675f;
  --line: #d8cfbf;
  --cinnabar: #a83b2f;
  --cinnabar-2: #7b2c25;
  --sage: #50685c;
  --bluegray: #3d5564;
  --gold: #a77a35;
  --success: #497759;
  --warning: #9b6d22;
  --danger: #a83b2f;
  --shadow: 0 16px 34px rgba(41, 34, 24, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(167, 122, 53, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(167, 122, 53, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
a {
  font: inherit;
}

button {
  cursor: pointer;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  color: #fff;
  background: var(--cinnabar);
  font-weight: 700;
}

button.ghost,
.ghost-button {
  color: var(--ink);
  background: #efe8db;
  border-color: var(--line);
}

button.danger,
.danger {
  background: var(--danger);
}

.app-shell,
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: rgba(255, 250, 240, 0.96);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.brand strong {
  font-size: 20px;
  line-height: 1.2;
}

.seal {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--cinnabar);
  border: 2px solid var(--cinnabar-2);
  font-size: 26px;
  font-weight: 700;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-heading h2,
.section-heading p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.2;
}

.brand p,
.eyebrow,
.metric span,
.subcopy,
.small-text {
  color: var(--muted);
  font-size: 13px;
}

.nav-list,
.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-link,
.sidebar nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active,
.sidebar nav a:hover {
  border-color: var(--line);
  background: #f0eadf;
}

.side-panel,
.rules-box,
.upload-card,
.report-card,
.boundary-grid article,
.anchor-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf7ef;
}

.side-panel {
  margin-top: auto;
  padding: 16px;
}

.side-panel h2,
.rules-box h3,
.upload-card h3,
.report-card h3,
.boundary-grid h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.side-panel ul,
.rules-box ul,
.report-card ul {
  margin: 0;
  padding-left: 18px;
}

.side-panel li,
.rules-box li,
.report-card li {
  margin: 8px 0;
}

.content {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.topbar,
.hero {
  min-height: 142px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.topbar h2,
.hero h2 {
  max-width: 900px;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.18;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.12;
}

.hero p {
  max-width: 920px;
  line-height: 1.7;
}

.subcopy {
  margin-top: 12px;
  max-width: 860px;
  line-height: 1.7;
}

.hero-picker {
  margin-top: 16px;
  width: min(100%, 420px);
  min-height: 46px;
  display: grid;
  gap: 8px;
  color: #fff;
}

.hero-picker span {
  width: max-content;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--cinnabar);
  font-weight: 700;
}

.hero-picker input {
  width: 100%;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbf7ef;
  color: var(--ink);
  cursor: pointer;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--cinnabar);
  font-weight: 700;
}

.status-pill {
  flex: 0 0 auto;
  padding: 9px 12px;
  color: #fff;
  background: var(--sage);
  border-radius: var(--radius);
  font-size: 14px;
}

.metrics,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.stats-grid article,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.94);
}

.metric,
.stats-grid article {
  min-height: 118px;
  padding: 18px;
  display: grid;
  gap: 8px;
  align-content: center;
}

.metric strong,
.stats-grid strong {
  font-size: 34px;
  line-height: 1;
}

.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

.stats-grid small {
  color: var(--muted);
}

.metric-label {
  color: var(--cinnabar);
  font-weight: 700;
}

.panel {
  padding: 22px;
}

.section-heading,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.section-heading h2,
.section-head h2 {
  font-size: 24px;
}

.toolbar,
.actions,
.notes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.notes {
  margin: 12px 0;
}

.notes span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #efe8db;
  color: #5e5143;
  padding: 0 12px;
  font-size: 13px;
}

.language-control {
  margin: 12px 0;
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.language-control label {
  font-weight: 700;
}

.language-control select {
  min-height: 40px;
  min-width: 168px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fbf7ef;
}

.language-control span {
  color: var(--muted);
  font-size: 13px;
}

.upload-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 0 16px;
  color: #fff;
  background: var(--cinnabar);
  font-weight: 700;
  cursor: pointer;
}

.upload-button input {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
}

.upload-drop {
  min-height: 220px;
  border: 2px dashed #cbbda9;
  border-radius: var(--radius);
  background: #fffaf0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
}

.file-picker {
  width: min(100%, 420px);
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbf7ef;
  color: var(--ink);
  cursor: pointer;
}

.upload-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--bluegray);
  border-radius: 50%;
  font-size: 34px;
  line-height: 1;
}

.rules-box {
  padding: 18px;
}

.notice {
  margin-top: 16px;
  min-height: 42px;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: #4c4031;
  background: #efe8db;
}

.notice.error {
  color: #fff;
  background: var(--danger);
}

.vision-diagnostic {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf0;
  padding: 12px;
}

.vision-diagnostic[data-status="pass"] {
  border-color: rgba(73, 119, 89, 0.48);
  background: rgba(73, 119, 89, 0.08);
}

.vision-diagnostic[data-status="warning"],
.vision-diagnostic[data-status="running"] {
  border-color: rgba(155, 109, 34, 0.5);
  background: rgba(155, 109, 34, 0.08);
}

.vision-diagnostic[data-status="rejected"],
.vision-diagnostic[data-status="error"] {
  border-color: rgba(168, 59, 47, 0.48);
  background: rgba(168, 59, 47, 0.08);
}

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

.diagnostic-head strong,
.diagnostic-head span {
  display: block;
}

.diagnostic-head span,
.diagnostic-note,
.diagnostic-recent {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.diagnostic-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.diagnostic-grid span {
  min-height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.72);
  padding: 0 10px;
  font-size: 13px;
}

.diagnostic-note,
.diagnostic-recent {
  margin: 8px 0 0;
}

.upload-list,
.report-list {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.upload-summary {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.upload-summary-title {
  color: var(--muted);
  font-size: 13px;
}

.upload-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.queue-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fffaf0;
  color: var(--ink);
  font-size: 13px;
}

.queue-chip strong {
  color: var(--cinnabar);
}

.queue-chip.done {
  border-color: rgba(53, 94, 96, 0.35);
  background: rgba(53, 94, 96, 0.08);
}

.queue-chip.scored {
  border-color: rgba(154, 42, 35, 0.35);
  background: rgba(154, 42, 35, 0.08);
}

.upload-card {
  padding: 16px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
}

.preview-box,
.upload-preview {
  min-height: 172px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #efe8db;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-box img,
.upload-preview img {
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  background: #fffaf0;
  display: block;
}

.upload-preview span {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  line-height: 1.7;
}

.upload-body {
  min-width: 0;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.api-box,
.manual-box {
  margin-top: 12px;
}

.manual-box {
  border: 1px solid rgba(53, 94, 96, 0.24);
  border-radius: 6px;
  background: rgba(80, 104, 92, 0.06);
  padding: 12px;
}

.manual-box > strong {
  display: block;
  font-size: 16px;
}

.pending-preview {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  line-height: 1.7;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  padding: 0 10px;
}

.field input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  padding: 0 10px;
}

.manual-review-panel {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(88px, 0.45fr) minmax(150px, 0.75fr) minmax(220px, 1.4fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid rgba(53, 94, 96, 0.24);
  border-radius: 6px;
  padding: 12px;
  background: rgba(53, 94, 96, 0.06);
}

.manual-grid,
.api-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.manual-grid label,
.api-box {
  min-width: 0;
  border: 1px solid #e0d6c4;
  border-radius: 6px;
  background: #fffaf0;
  padding: 10px;
}

.manual-grid label span,
.api-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.manual-grid input,
.manual-grid select,
.manual-grid textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbf7ef;
  color: var(--ink);
  padding: 8px;
}

.manual-grid textarea {
  min-height: 88px;
  resize: vertical;
}

.api-box strong {
  font-size: 22px;
}

.manual-note {
  min-width: 0;
}

.confirm-row,
.action-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.confirm-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
}

.primary-button,
.confirm-button {
  color: #fff;
  background: var(--cinnabar);
}

.secondary-button {
  color: #fff;
  background: var(--bluegray);
}

.ghost-button {
  color: var(--ink);
  background: #efe8db;
  border-color: var(--line);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.report-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

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

.report-score {
  color: var(--cinnabar);
  font-size: 28px;
  font-weight: 800;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.score-grid > div {
  min-width: 0;
  padding: 9px 10px;
  border-bottom: 1px solid #eee5d7;
}

.readable-field span,
.readable-field strong,
.theory-grid span,
.theory-grid strong,
.boundary-list li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.readable-field span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.readable-field strong {
  display: block;
  line-height: 1.45;
}

.technical-details {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.48);
}

.technical-details > summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.technical-details[open] > summary {
  border-bottom: 1px solid var(--line);
}

.technical-details > .score-grid,
.technical-details > h4,
.technical-details > p,
.technical-details > .flag-row,
.technical-details > .boundary-list {
  margin-left: 14px;
  margin-right: 14px;
}

.score-section-title {
  margin-top: 4px;
  font-weight: 800;
  color: var(--ink);
}

.muted-title {
  color: var(--muted);
}

.precheck-grid {
  opacity: 0.88;
}

.score-item {
  min-height: 60px;
  padding: 10px;
  border: 1px solid #e0d6c4;
  border-radius: 6px;
  background: #fffaf0;
}

.score-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.score-item strong {
  font-size: 22px;
}

.metric-breakdown {
  display: grid;
  gap: 6px;
  margin: 10px 0 12px;
  border: 1px solid #e0d6c4;
  border-radius: 6px;
  background: #fffaf0;
  overflow: hidden;
}

.metric-breakdown-row {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) 56px 56px 76px minmax(180px, 1.7fr) minmax(180px, 1.7fr);
  gap: 8px;
  align-items: start;
  padding: 9px 10px;
  border-top: 1px solid #e7ddcc;
  font-size: 12px;
}

.metric-breakdown-row:first-child {
  border-top: 0;
}

.metric-breakdown-head {
  color: #4e4032;
  background: #efe8db;
  font-weight: 800;
}

.metric-breakdown-row strong,
.metric-breakdown-row span,
.metric-breakdown-row p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.metric-breakdown-row span {
  color: var(--cinnabar);
  font-weight: 800;
}

.metric-breakdown-row p {
  color: #5d554b;
  line-height: 1.45;
}

.muted-score strong {
  font-size: 18px;
  color: var(--muted);
}

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

.tag {
  padding: 6px 8px;
  color: #fff;
  background: var(--sage);
  border-radius: 6px;
  font-size: 12px;
}

.tag.warn {
  background: var(--warning);
}

.tag.danger {
  background: var(--danger);
}

.empty-state {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbf7ef;
}

.anchor-ladder {
  display: grid;
  gap: 10px;
}

.anchor-row {
  display: grid;
  grid-template-columns: 120px 120px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 14px;
}

.anchor-row strong {
  font-size: 18px;
}

.anchor-row .range {
  color: var(--cinnabar);
  font-weight: 700;
}

.anchor-row .bar {
  height: 10px;
  border-radius: 999px;
  background: #e4d8c7;
  overflow: hidden;
}

.anchor-row .fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--sage), var(--gold), var(--cinnabar));
}

.boundary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.boundary-grid article {
  min-height: 146px;
  padding: 16px;
}

.boundary-grid p {
  margin: 0;
  color: #34372f;
  line-height: 1.65;
}

@media (max-width: 900px) {
  .app-shell,
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list,
  .sidebar nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metrics,
  .stats-grid,
  .boundary-grid,
  .score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-grid,
  .upload-card {
    grid-template-columns: 1fr;
  }

  .manual-review-panel {
    grid-template-columns: 1fr;
  }

  .manual-grid,
  .api-grid,
  .diagnostic-grid {
    grid-template-columns: 1fr;
  }

  .metric-breakdown-row {
    grid-template-columns: minmax(92px, 1fr) 48px 48px 64px;
  }

  .metric-breakdown-row p {
    grid-column: 1 / -1;
  }

  .diagnostic-head {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .content,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .section-heading,
  .section-head,
  .report-head {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-list,
  .sidebar nav,
  .metrics,
  .stats-grid,
  .boundary-grid,
  .score-grid,
  .card-grid,
  .anchor-row {
    grid-template-columns: 1fr;
  }
}

.hint {
  margin: 6px 0 12px;
  color: #6e6254;
  font-size: 13px;
  line-height: 1.55;
}

.explain-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.explain-grid article {
  border: 1px solid rgba(120, 83, 43, 0.18);
  border-radius: 8px;
  background: rgba(255, 251, 244, 0.82);
  padding: 14px;
}

.explain-grid strong,
.explain-grid span {
  display: block;
}

.explain-grid strong {
  font-size: 18px;
}

.explain-grid span {
  margin-top: 4px;
  color: #9f6c12;
  font-weight: 700;
}

.explain-grid p {
  margin: 10px 0 0;
  color: #584f45;
  line-height: 1.6;
}

.theory-alignment-panel {
  border: 1px solid rgba(48, 97, 79, 0.28);
  border-radius: 8px;
  background: #f7fbf7;
  padding: 16px;
  margin: 18px 0 22px;
}

.theory-alignment-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.theory-alignment-head h4 {
  margin: 0;
}

.theory-alignment-head strong {
  flex: 0 0 auto;
  color: #2f6b4f;
  background: #e5f1e9;
  border-radius: 999px;
  padding: 7px 12px;
}

.theory-alignment-head strong[data-passed="true"] {
  color: #7a2d16;
  background: #f7e6dc;
}

.alignment-target-score {
  display: grid;
  grid-template-columns: 150px minmax(96px, 140px) 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  border: 1px solid rgba(48, 97, 79, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 10px;
}

.alignment-target-score span {
  font-weight: 700;
  color: #2f493e;
}

.alignment-target-score input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(70, 85, 100, 0.28);
  border-radius: 6px;
  padding: 7px 9px;
}

.alignment-target-score em {
  color: #5f574d;
  font-style: normal;
  line-height: 1.45;
}

.alignment-target-score em[data-passed="true"] {
  color: #2f6b4f;
  font-weight: 700;
}

.theory-alignment-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.alignment-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(120, 83, 43, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 10px;
}

.alignment-row input {
  margin-top: 3px;
}

.alignment-row strong,
.alignment-row em {
  display: block;
}

.alignment-row em {
  margin-top: 4px;
  color: #5f574d;
  font-style: normal;
  line-height: 1.55;
}

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

  .alignment-target-score {
    grid-template-columns: 1fr;
  }

  .theory-alignment-head {
    flex-direction: column;
  }
}
