:root {
  --ink: #19212a;
  --muted: #66717f;
  --line: #dfe4ea;
  --paper: #fbfcfd;
  --panel: #ffffff;
  --green: #0f766e;
  --blue: #3457d5;
  --coral: #d95f3a;
  --gold: #a86d00;
  --shadow: 0 20px 45px rgba(28, 38, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(52, 87, 213, 0.06), transparent 34%),
    linear-gradient(180deg, #f3f6f9, #edf2f1 52%, #f8f4ef);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
}

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

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

.control-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 26px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #fff;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.brand p,
.eyebrow,
.compact span,
.field span,
.stats-grid span {
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field,
.compact {
  display: grid;
  gap: 7px;
}

.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd7df;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 108px;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(52, 87, 213, 0.12);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  margin-top: 4px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: var(--green);
}

.primary:hover {
  background: #0b625c;
}

.secondary {
  color: var(--ink);
  background: #e9edf1;
}

.secondary:hover {
  background: #dfe5eb;
}

.results-panel {
  padding: 28px 34px 40px;
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  font-weight: 800;
  color: var(--coral);
  letter-spacing: 0;
}

h2 {
  font-size: 26px;
  line-height: 1.22;
}

.toolbar-controls {
  display: flex;
  gap: 12px;
  align-items: end;
}

.compact select {
  min-width: 112px;
}

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

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
}

.stats-grid strong {
  display: block;
  font-size: 24px;
  color: var(--blue);
  margin-bottom: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  border: 1px solid #d7dde5;
  border-radius: 999px;
  background: #fff;
  padding: 7px 11px;
  color: #394554;
  font-size: 13px;
}

.results {
  display: grid;
  gap: 12px;
}

.loading-state {
  place-items: center;
  min-height: 420px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 28px;
}

.loading-state p {
  color: var(--muted);
}

.loader {
  width: 44px;
  height: 44px;
  border: 4px solid #d9e2ea;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.78s linear infinite;
}

.empty-state {
  place-items: center;
  min-height: 420px;
  text-align: center;
  border: 1px dashed #cbd5df;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  padding: 28px;
}

.empty-state p {
  max-width: 620px;
  color: var(--muted);
  line-height: 1.7;
}

.card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 16px;
  box-shadow: 0 10px 28px rgba(28, 38, 54, 0.07);
  animation: resultFade 0.24s ease both;
}

.score {
  display: grid;
  place-items: center;
  align-self: start;
  min-height: 80px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--green));
}

.score strong {
  display: block;
  font-size: 24px;
}

.score span {
  font-size: 12px;
  opacity: 0.9;
}

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

.card h3 {
  font-size: 18px;
  line-height: 1.35;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.tag {
  padding: 5px 8px;
  border-radius: 6px;
  background: #eef4f3;
  color: #23433f;
  font-size: 12px;
}

.tag.rank {
  background: #fff4df;
  color: var(--gold);
}

.text-block {
  color: #3f4b59;
  line-height: 1.65;
  margin-bottom: 10px;
}

.paper-list {
  padding: 10px 12px;
  border-left: 3px solid var(--coral);
  background: #fff8f5;
  color: #51443d;
  line-height: 1.55;
  font-size: 13px;
}

.reason {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.reason span {
  padding: 5px 8px;
  border-radius: 6px;
  background: #eef1ff;
  color: #293a9b;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(18, 25, 34, 0.42);
  z-index: 20;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-card {
  width: min(460px, 100%);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-card p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  min-width: 104px;
}

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

@keyframes resultFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .control-panel {
    position: static;
    height: auto;
  }
}

@media (max-width: 680px) {
  .control-panel,
  .results-panel {
    padding: 18px;
  }

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

  .toolbar,
  .card-head {
    display: grid;
  }

  .toolbar-controls,
  .actions {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
}
