:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #17201b;
  --muted: #5d6a61;
  --line: #d7ded5;
  --panel: #ffffff;
  --accent: #167a5b;
  --accent-dark: #0f5a43;
  --warning: #9c5b12;
  --soft: #edf5f1;
  --score: #3156a6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 20px;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.topbar p,
.hint,
.message,
.stats,
td {
  color: var(--muted);
}

.stats {
  min-width: 210px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 26px rgba(23, 32, 27, 0.05);
}

.main-panel {
  min-height: 560px;
}

.stack,
.analyze-grid {
  display: grid;
  gap: 12px;
}

.analyze-grid {
  grid-template-columns: minmax(220px, 1fr) 120px 140px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input[type="file"],
input[type="number"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.checkline {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #3156a6;
}

button.secondary:hover {
  background: #233f7c;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.hint {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.6;
}

.message {
  min-height: 22px;
  margin: 16px 0 8px;
  font-size: 14px;
}

.message.error {
  color: #a02929;
}

.query-block {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.query-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.badge {
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.result-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 86px 86px;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: #fbfcfb;
}

.compound {
  font-weight: 800;
}

.score {
  color: var(--score);
  font-weight: 800;
  text-align: right;
}

.peak-count {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.chart {
  width: 100%;
  height: 180px;
  display: block;
  background: #fff;
  border-top: 1px solid var(--line);
}

.matches {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.matches th,
.matches td {
  border-top: 1px solid var(--line);
  padding: 8px 10px;
  text-align: right;
}

.matches th:first-child,
.matches td:first-child {
  text-align: left;
}

.empty {
  padding: 42px 12px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar,
  .workspace {
    display: grid;
  }

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

  .stats {
    text-align: left;
  }

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