:root {
  --ink: #1a2332;
  --muted: #5c6b7a;
  --paper: #f4f6f8;
  --panel: #ffffff;
  --line: #d5dde5;
  --accent: #0d6e6e;
  --accent-hover: #0a5858;
  --red: #c62828;
  --red-bg: #fdecea;
  --orange: #c05600;
  --orange-bg: #fff4e5;
  --yellow: #8a6d00;
  --yellow-bg: #fff9db;
  --gray: #546e7a;
  --gray-bg: #eceff1;
  --green: #1b5e40;
  --green-bg: #e8f5ef;
  --shadow: 0 12px 40px rgba(26, 35, 50, 0.08);
  --radius: 14px;
  --font: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  line-height: 1.55;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(13, 110, 110, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(198, 40, 40, 0.06), transparent 50%),
    linear-gradient(180deg, #e8eef2 0%, var(--paper) 40%, #eef2f5 100%);
}
.bg-grid::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(26, 35, 50, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 35, 50, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}

.top {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.4rem 1.25rem 1.2rem;
  animation: rise 0.55s ease both;
}
.brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
}
.live-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #9aa5b1;
}
.live.ok { color: var(--green); border-color: #b7dfc9; background: var(--green-bg); }
.live.ok .live-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(27, 94, 64, 0.15); }
.brand-mark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: 0.02em;
  display: block;
}
.brand-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.tagline {
  margin: 1rem 0 0;
  font-size: 1.05rem;
  color: var(--ink);
  max-width: 36em;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem 1.25rem;
  animation: rise 0.6s ease both;
}
.input-panel { animation-delay: 0.05s; }
.result-panel { animation-delay: 0.08s; }
.legend-panel { animation-delay: 0.12s; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.panel-head h2,
.legend-panel h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.head-actions { display: flex; gap: 0.4rem; }

textarea#code {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea#code:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.15);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.hint-inline {
  color: var(--muted);
  font-size: 0.85rem;
}
.hint, .fineprint, .muted {
  color: var(--muted);
  font-size: 0.85rem;
}
.hint { margin: 0.65rem 0 0; }

.btn {
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 550;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.58rem 1.05rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.verdict {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.verdict-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-weight: 650;
  font-size: 0.95rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}
.verdict-text { margin: 0; font-size: 1.02rem; }
.counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.count-chip {
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.hit {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
  border-left-width: 4px;
  animation: rise 0.35s ease both;
}
.hit:last-child { margin-bottom: 0; }
.hit.red { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-bg), #fff 40%); }
.hit.orange { border-left-color: var(--orange); background: linear-gradient(90deg, var(--orange-bg), #fff 40%); }
.hit.yellow { border-left-color: var(--yellow); background: linear-gradient(90deg, var(--yellow-bg), #fff 40%); }
.hit.gray { border-left-color: var(--gray); background: linear-gradient(90deg, var(--gray-bg), #fff 40%); }

.hit-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.35rem;
}
.hit-name {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.95rem;
}
.hit-sev {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
}
.hit-sev.red { background: var(--red-bg); color: var(--red); }
.hit-sev.orange { background: var(--orange-bg); color: var(--orange); }
.hit-sev.yellow { background: var(--yellow-bg); color: var(--yellow); }
.hit-sev.gray { background: var(--gray-bg); color: var(--gray); }
.hit-loc { font-size: 0.8rem; color: var(--muted); margin-left: auto; }
.hit-title { font-weight: 600; margin: 0 0 0.2rem; font-size: 0.92rem; }
.hit-desc { margin: 0 0 0.45rem; color: var(--muted); font-size: 0.88rem; }
.hit-snip {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: #f0f3f6;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.empty-hits {
  color: var(--muted);
  padding: 0.5rem 0;
}

.catalog-box {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}
.catalog-box summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  user-select: none;
}
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.35rem;
  margin-top: 0.75rem;
}
.cat-item {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.45rem;
  border-radius: 5px;
  background: #f5f7f9;
  color: var(--muted);
}
.cat-item.found {
  background: var(--red-bg);
  color: var(--red);
  font-weight: 600;
}
.cat-item.found.orange { background: var(--orange-bg); color: var(--orange); }
.cat-item.found.yellow { background: var(--yellow-bg); color: var(--yellow); }
.cat-item.found.gray { background: var(--gray-bg); color: var(--gray); }

.legend {
  list-style: none;
  margin: 0.5rem 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.legend li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.9rem;
}
.dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
}
.dot.red { background: var(--red); }
.dot.orange { background: var(--orange); }
.dot.yellow { background: #d4a017; }
.dot.gray { background: var(--gray); }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 1rem 2rem;
}
.foot .sep { margin: 0 0.35rem; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: rise 0.25s ease;
}

.verdict-badge.danger { background: var(--red-bg); color: var(--red); }
.verdict-badge.warn { background: var(--orange-bg); color: var(--orange); }
.verdict-badge.caution { background: var(--yellow-bg); color: var(--yellow); }
.verdict-badge.review { background: var(--gray-bg); color: var(--gray); }
.verdict-badge.clean { background: var(--green-bg); color: var(--green); }

.count-chip.red { background: var(--red-bg); color: var(--red); }
.count-chip.orange { background: var(--orange-bg); color: var(--orange); }
.count-chip.yellow { background: var(--yellow-bg); color: var(--yellow); }
.count-chip.gray { background: var(--gray-bg); color: var(--gray); }

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

@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .btn.primary { width: 100%; }
  .hit-loc { margin-left: 0; width: 100%; }
}
