:root {
  --bg: #dfe3ef;
  --paper: #fffefb;
  --paper-soft: #f5f7f2;
  --ink: #1d252d;
  --ink-2: #263039;
  --muted: #69717a;
  --line: #d8ddd5;
  --line-strong: #aeb7ad;
  --red: #b83a35;
  --red-soft: #fff0ee;
  --orange: #a3651c;
  --orange-soft: #fff4e5;
  --blue: #315f82;
  --blue-soft: #edf5f9;
  --green: #195d36;
  --green-2: #2f7650;
  --green-soft: #e8f1e8;
  --gold: #b58b2f;
  --shadow: 0 16px 0 rgba(22, 35, 28, 0.06), 0 20px 34px rgba(36, 44, 58, 0.13);
  --shadow-tight: 0 8px 0 rgba(22, 35, 28, 0.045), 0 12px 22px rgba(36, 44, 58, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 7% 6%, rgba(255, 255, 255, 0.55), transparent 26%),
    radial-gradient(circle at 92% 14%, rgba(25, 93, 54, 0.1), transparent 25%),
    linear-gradient(rgba(25, 33, 44, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 33, 44, 0.028) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.32), transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(25, 93, 54, 0.08), transparent 34%);
  pointer-events: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

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

.audit-shell {
  width: min(1680px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.48fr);
  grid-template-rows: auto auto 570px 360px auto;
  gap: 16px 20px;
  align-items: start;
}

.audit-header,
.import-strip,
.editor-panel,
.result-panel,
.preview-panel,
.suggestion-panel,
.history-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(173, 181, 171, 0.9);
  border-radius: 3px;
  background: rgba(255, 254, 251, 0.98);
  box-shadow: var(--shadow);
}

.audit-header::after,
.editor-panel::after,
.result-panel::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), transparent 34%),
    linear-gradient(90deg, rgba(25, 93, 54, 0.055), transparent 42%);
  pointer-events: none;
}

.audit-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px 170px;
  gap: 24px;
  align-items: center;
  min-height: 148px;
  padding: 24px 34px;
  background:
    linear-gradient(90deg, rgba(255, 254, 251, 1) 0 68%, rgba(232, 241, 232, 0.92) 68% 100%);
}

.audit-header::before,
.editor-panel::before,
.result-panel::before,
.preview-panel::before,
.suggestion-panel::before,
.history-panel::before {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 1;
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  background: var(--green);
  box-shadow: 12px 0 0 rgba(25, 93, 54, 0.28), 24px 0 0 rgba(25, 93, 54, 0.14);
}

.header-main,
.header-actions,
.header-status,
.panel-head,
.editor-actions,
.score-card,
.metric-grid,
.panel-block,
.import-strip > * {
  position: relative;
  z-index: 1;
}

.section-kicker {
  display: inline-flex;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 8px;
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.25;
  text-transform: none;
}

.header-copy,
.panel-head p,
.history-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.header-status {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.header-status span {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: var(--green);
  color: white !important;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.14);
}

.header-status span:nth-child(1) {
  color: var(--red);
}

.header-status span:nth-child(2) {
  color: var(--orange);
}

.header-status span:nth-child(3) {
  color: var(--green);
}

.header-actions,
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.header-actions {
  justify-content: flex-end;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 42px;
  padding: 10px 16px;
}

.primary-btn {
  background: var(--green);
  color: white;
  box-shadow: 0 8px 0 rgba(25, 93, 54, 0.16), 0 12px 20px rgba(23, 33, 43, 0.12);
}

.primary-btn:hover:not(:disabled) {
  background: #134b2c;
  box-shadow: 0 10px 0 rgba(25, 93, 54, 0.16), 0 16px 24px rgba(23, 33, 43, 0.14);
}

.secondary-btn {
  border-color: rgba(25, 93, 54, 0.26);
  background: #f1f6f1;
  color: #20382e;
  box-shadow: 0 5px 0 rgba(25, 93, 54, 0.08);
}

.ghost-btn {
  border-color: rgba(173, 181, 171, 0.95);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
}

.danger-lite {
  color: var(--red);
}

.import-strip {
  display: grid;
  grid-template-columns: 92px minmax(360px, 1fr) 170px minmax(260px, 360px);
  gap: 12px;
  align-items: center;
  margin-top: 0;
  padding: 14px 18px;
  box-shadow: var(--shadow-tight);
}

.import-strip label,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(173, 181, 171, 0.95);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  outline: none;
  transition: border 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input {
  min-height: 44px;
  padding: 11px 13px;
}

textarea {
  min-height: 0;
  padding: 16px;
  resize: vertical;
  line-height: 1.8;
  cursor: text;
}

.body-input {
  background:
    linear-gradient(90deg, rgba(25, 93, 54, 0.035), transparent 18%),
    rgba(255, 255, 255, 0.86);
}

.body-input:hover {
  border-color: rgba(25, 93, 54, 0.42);
}

input:focus,
textarea:focus {
  border-color: rgba(36, 122, 83, 0.78);
  background: white;
  box-shadow: 0 0 0 4px rgba(36, 122, 83, 0.12);
}

.inline-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.workspace {
  display: contents;
}

.editor-panel,
.result-panel,
.preview-panel,
.suggestion-panel,
.history-panel {
  padding: 26px 22px 22px;
}

.editor-panel,
.result-panel,
.preview-panel,
.suggestion-panel {
  height: 100%;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-panel .body-input {
  flex: 1 1 auto;
  min-height: 0;
}

.editor-actions {
  flex: 0 0 auto;
  margin-top: 10px;
}

.result-panel {
  position: static;
  display: block;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(216, 221, 213, 0.88);
}

.audit-header,
.import-strip,
.history-panel {
  grid-column: 1 / -1;
}

.editor-panel {
  grid-column: 1;
  grid-row: 3;
}

.suggestion-panel {
  grid-column: 2;
  grid-row: 4;
  align-self: stretch;
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.suggestion-panel .panel-head {
  flex: 0 0 auto;
}

.suggestion-panel .suggestion-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.counter {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid rgba(25, 93, 54, 0.16);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.field-label {
  display: block;
  margin: 14px 0 8px;
}

.score-card {
  padding: 20px;
  border: 0;
  border-radius: 3px;
  background: var(--green);
  color: white;
}

.risk-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.risk-label.muted {
  background: #edf1ee;
  color: var(--muted);
}

.risk-label.high {
  background: var(--red-soft);
  color: var(--red);
}

.risk-label.medium {
  background: var(--orange-soft);
  color: var(--orange);
}

.risk-label.safe {
  background: var(--green-soft);
  color: var(--green);
}

.score-card strong {
  display: block;
  margin: 14px 0 8px;
  color: white;
  font-size: 54px;
  line-height: 0.95;
}

.score-card p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.65;
}

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

.metric-grid div {
  padding: 13px;
  border: 1px solid rgba(173, 181, 171, 0.82);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.74);
}

.metric-grid div:nth-child(1) strong {
  color: var(--red);
}

.metric-grid div:nth-child(2) strong {
  color: var(--orange);
}

.metric-grid div:nth-child(3) strong {
  color: var(--blue);
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.metric-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.panel-block {
  margin-top: 18px;
}

.category-list,
.suggestion-list,
.history-list,
.checklist {
  display: grid;
  gap: 8px;
}

.category-card,
.suggestion-card,
.history-card,
.check-row {
  border: 1px solid rgba(173, 181, 171, 0.8);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.76);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.category-card:hover,
.suggestion-card:hover,
.history-card:hover {
  transform: translateY(-1px);
  border-color: rgba(36, 122, 83, 0.32);
  box-shadow: var(--shadow-tight);
}

.category-card,
.suggestion-card,
.history-card {
  padding: 11px;
}

.category-card strong,
.suggestion-card strong,
.history-card strong {
  display: block;
  margin-bottom: 6px;
}

.category-meta,
.suggestion-card p,
.history-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.term-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.term-chip {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-size: 11px;
  font-weight: 900;
}

.check-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: start;
  padding: 9px;
}

.check-dot {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
}

.check-row.pass .check-dot {
  background: var(--green-soft);
  color: var(--green);
}

.check-row.fail .check-dot {
  background: var(--red-soft);
  color: var(--red);
}

.check-row.warn .check-dot {
  background: var(--orange-soft);
  color: var(--orange);
}

.check-row strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.check-row span:last-child {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.review-area {
  display: contents;
}

.preview-panel {
  grid-column: 1;
  grid-row: 4;
}

.result-panel {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.highlight-preview {
  min-height: 0;
  height: calc(100% - 86px);
  max-height: none;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.9;
  display: block;
  cursor: text;
  outline: none;
}

.highlight-preview:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.highlight-preview:focus {
  border-color: rgba(25, 93, 54, 0.78);
  background: white;
  box-shadow: 0 0 0 4px rgba(36, 122, 83, 0.12);
}

.preview-hit {
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 900;
}

.preview-hit.high {
  color: var(--red);
  background: var(--red-soft);
}

.preview-hit.medium {
  color: var(--orange);
  background: var(--orange-soft);
}

.preview-hit.low {
  color: var(--blue);
  background: var(--blue-soft);
}

.preview-title-line {
  min-height: 28px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(173, 181, 171, 0.72);
  font-weight: 900;
}

.preview-body-line {
  min-height: 220px;
}

.hit {
  border-radius: 5px;
  padding: 1px 4px;
  font-weight: 900;
}

.hit.high {
  background: var(--red-soft);
  color: var(--red);
}

.hit.medium {
  background: var(--orange-soft);
  color: var(--orange);
}

.hit.low {
  background: var(--blue-soft);
  color: var(--blue);
}

.empty-box {
  padding: 18px;
  border: 1px dashed #b9c5bd;
  border-radius: 3px;
  background:
    repeating-linear-gradient(135deg, rgba(25, 93, 54, 0.025) 0 8px, transparent 8px 16px),
    rgba(250, 252, 249, 0.72);
  color: var(--muted);
}

.suggestion-card {
  display: grid;
  gap: 8px;
}

.replace-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.replace-line code {
  padding: 8px 9px;
  border-radius: 3px;
  background: #f2f4f1;
  color: var(--ink);
  white-space: normal;
}

.small-copy-btn {
  justify-self: start;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(25, 93, 54, 0.18);
  background: rgba(255, 255, 255, 0.82);
  color: var(--green);
  font-size: 12px;
}

.history-panel {
  margin-top: 0;
}

.history-card {
  display: grid;
  gap: 8px;
}

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

.history-actions button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 12px;
}

.scan-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 11px;
  border-radius: 3px;
  background: var(--blue-soft);
  color: var(--blue);
}

.scan-progress span {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(43, 111, 158, 0.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 760ms linear infinite;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1280px) {
  .audit-shell {
    display: block;
    grid-template-rows: none;
  }

  .audit-header,
  .workspace,
  .review-area,
  .import-strip {
    grid-template-columns: 1fr;
  }

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

  .review-area {
    display: grid;
    gap: 16px;
    margin-top: 16px;
  }

  .editor-panel,
  .result-panel,
  .suggestion-panel,
  .review-area,
  .history-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .result-panel,
  .suggestion-panel {
    display: block;
    height: auto;
    max-height: none;
  }

  .editor-panel,
  .preview-panel {
    height: auto;
  }

  .highlight-preview {
    min-height: 320px;
    height: auto;
  }

  .import-strip,
  .history-panel {
    margin-top: 16px;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .header-status {
    display: flex;
    flex-wrap: wrap;
  }

  .audit-header {
    background: rgba(255, 254, 251, 0.98);
  }
}

@media (max-width: 640px) {
  .audit-shell {
    width: min(100% - 18px, 1460px);
    padding-top: 10px;
  }

  .audit-header,
  .editor-panel,
  .result-panel,
  .preview-panel,
  .suggestion-panel,
  .history-panel {
    padding: 14px;
  }

  .audit-header {
    min-height: auto;
  }

  .header-actions,
  .editor-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 31px;
  }

  textarea {
    min-height: 330px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .replace-line {
    grid-template-columns: 1fr;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
