:root {
  color-scheme: dark;
  --bg: #0a0c0f;
  --bg-raised: #12161b;
  --bg-sunken: #0d1116;
  --line: #1f262f;
  --line-soft: #171d24;
  --ink: #e8edf3;
  --ink-dim: #8b97a6;
  --ink-faint: #5d6875;
  --accent: #4f9dff;
  --pass: #36c98d;
  --warn: #e8b13a;
  --fail: #f2555a;
  --info: #6f8ba3;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1000px 500px at 50% -10%, #131c26 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding-inline: 20px;
}

/* ---------- top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--line-soft);
  padding-block: 14px;
  margin-bottom: 48px;
}
.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 16px; height: 16px; border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), #7be0b6);
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.brand-note { color: var(--ink-faint); font-size: 12.5px; }

/* ---------- hero ---------- */
.hero { padding-block: 8px 40px; }
h1 {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
  font-weight: 600;
}
.lede {
  color: var(--ink-dim);
  max-width: 60ch;
  margin: 0 0 28px;
  font-size: 16px;
}
.scan-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 560px;
}
#url-input {
  flex: 1 1 260px;
  min-width: 0;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 13px 15px;
  font: 15px var(--mono);
  transition: border-color .15s, box-shadow .15s;
}
#url-input::placeholder { color: var(--ink-faint); }
#url-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(79 157 255 / .15);
}
button {
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 13px 22px;
  background: var(--accent);
  color: #04101f;
  transition: filter .15s, opacity .15s;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .55; cursor: progress; }
button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-dim);
  padding: 9px 16px;
  font-size: 14px;
}
button.ghost:hover { color: var(--ink); border-color: #2c3742; }
.hint { color: var(--ink-faint); font-size: 13px; margin: 14px 0 0; }
.error {
  margin-top: 18px;
  padding: 12px 15px;
  border-radius: var(--radius);
  border: 1px solid rgb(242 85 90 / .3);
  background: rgb(242 85 90 / .08);
  color: #ffb4b7;
  font-size: 14px;
}

/* ---------- progress ---------- */
.progress { padding-block: 8px 56px; }
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.stages li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--line-soft);
  background: var(--bg-raised);
  font-size: 14.5px;
}
.stages li:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.stages li:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.stages .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-faint); flex: none;
}
.stages li.running .dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.stages li.done .dot { background: var(--pass); }
.stages li.running .stage-name { color: var(--ink); }
.stage-name { color: var(--ink-dim); min-width: 140px; }
.stage-msg { color: var(--ink-faint); font-size: 13.5px; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
.progress-detail {
  color: var(--ink-faint); font: 12.5px var(--mono);
  margin: 14px 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- report head ---------- */
.report { padding-bottom: 72px; }
.report-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 24px; flex-wrap: wrap;
  padding-bottom: 28px; margin-bottom: 28px;
  border-bottom: 1px solid var(--line-soft);
}
.score-block { display: flex; align-items: center; gap: 22px; }
.gauge { position: relative; width: 104px; height: 104px; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.gauge-track { stroke: var(--line); }
.gauge-value { stroke: var(--pass); transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1), stroke .3s; }
.gauge-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0;
  line-height: 1;
}
.gauge-number { font-size: 27px; font-weight: 600; letter-spacing: -0.03em; }
.gauge-unit {
  font-size: 9.5px; color: var(--ink-faint);
  letter-spacing: .08em; margin-top: 3px;
}
.score-meta h2 { margin: 6px 0 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.muted { color: var(--ink-faint); font-size: 13px; margin: 0; }
.risk-pill {
  display: inline-block; font-size: 11px; font-weight: 650;
  letter-spacing: .09em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid currentColor;
}
.risk-low { color: var(--pass); }
.risk-medium { color: var(--warn); }
.risk-high, .risk-critical { color: var(--fail); }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- priority ---------- */
.priority {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 20px 24px;
  margin-bottom: 36px;
}
.priority h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.priority ol { margin: 0; padding-left: 20px; display: grid; gap: 13px; }
.priority li::marker { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.priority .p-title { font-weight: 550; }
.priority .p-fix { color: var(--ink-dim); font-size: 13.5px; display: block; margin-top: 3px; }

/* ---------- categories ---------- */
.category { margin-bottom: 34px; }
.category-head {
  display: flex; align-items: baseline; gap: 12px;
  padding-bottom: 10px; margin-bottom: 2px;
}
.category-head h3 {
  margin: 0; font-size: 12px; font-weight: 650;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim);
}
.category-score { font: 12px var(--mono); color: var(--ink-faint); }

.check {
  border: 1px solid var(--line-soft);
  background: var(--bg-raised);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
}
.check + .check { border-top: none; }
.check:first-of-type { border-radius: var(--radius) var(--radius) 0 0; }
.check:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
.check.is-fail { background: linear-gradient(90deg, rgb(242 85 90 / .07), transparent 40%); }
.check.is-warn { background: linear-gradient(90deg, rgb(232 177 58 / .06), transparent 40%); }

.badge {
  grid-row: 1 / span 2;
  align-self: start;
  font-size: 10px; font-weight: 700; letter-spacing: .07em;
  padding: 4px 7px; border-radius: 5px; margin-top: 2px;
  min-width: 44px; text-align: center;
}
.badge-pass { background: rgb(54 201 141 / .14); color: var(--pass); }
.badge-warn { background: rgb(232 177 58 / .14); color: var(--warn); }
.badge-fail { background: rgb(242 85 90 / .16); color: var(--fail); }
.badge-info { background: rgb(111 139 163 / .14); color: var(--info); }

.check-title { font-weight: 550; font-size: 14.5px; }
.check-summary { color: var(--ink-dim); font-size: 13.5px; }
.check-detail { color: var(--ink-faint); font-size: 12.5px; margin-top: 6px; }

.items { grid-column: 2; margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 1px; }
.items li {
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
}
.item-badge {
  font: 10.5px var(--mono); color: var(--fail);
  background: rgb(242 85 90 / .12); border-radius: 4px;
  padding: 2px 6px; flex: none;
}
.check.is-warn .item-badge { color: var(--warn); background: rgb(232 177 58 / .12); }
.check.is-info .item-badge, .check.is-pass .item-badge { color: var(--info); background: rgb(111 139 163 / .12); }
.item-primary { font: 12.5px var(--mono); color: var(--ink); word-break: break-all; flex: 1 1 200px; }
.item-secondary { color: var(--ink-faint); font-size: 12px; flex-basis: 100%; }

.more { color: var(--ink-faint); font-size: 12.5px; padding-left: 2px; }
details.extra summary {
  cursor: pointer; color: var(--ink-dim); font-size: 13px;
  padding: 12px 2px 0; list-style: none;
}
details.extra summary::-webkit-details-marker { display: none; }
details.extra summary::before { content: "▸ "; color: var(--ink-faint); }
details.extra[open] summary::before { content: "▾ "; }

.report-foot { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line-soft); }

/* ---------- print ---------- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #111; }
  .topbar, .report-actions, .hero, .progress { display: none !important; }
  .check, .priority, .items li { background: #fff !important; border-color: #ddd !important; }
  .check-summary, .muted, .item-secondary, .check-detail { color: #555 !important; }
  .item-primary, .check-title, .gauge-number { color: #111 !important; }
  .category { break-inside: avoid; }
  .check { break-inside: avoid; }
}

@media (max-width: 560px) {
  .stage-name { min-width: 0; }
  .stages li { flex-wrap: wrap; gap: 6px 12px; }
  .check { grid-template-columns: 1fr; }
  .badge { grid-row: auto; justify-self: start; }
  .items { grid-column: 1; }
}
