:root {
  --bg: #0b1020;
  --bg-2: #0e1430;
  --panel: #131a36;
  --panel-2: #182142;
  --line: #243056;
  --line-soft: #1c264a;
  --text: #eaf0ff;
  --muted: #98a3c9;
  --muted-2: #6f7aa3;
  --brand: #5b7cff;
  --brand-2: #9d5bff;
  --good: #18c08f;
  --avg: #ffac33;
  --bad: #ff5470;
  --good-soft: rgba(24, 192, 143, 0.14);
  --avg-soft: rgba(255, 172, 51, 0.14);
  --bad-soft: rgba(255, 84, 112, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --maxw: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(91, 124, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(157, 91, 255, 0.14), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

a { color: inherit; }

/* ---------- HEADER ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(11, 16, 32, 0.72);
  border-bottom: 1px solid var(--line-soft);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); font-size: 16px; letter-spacing: -0.01em; }
.brand-mark { display: grid; place-items: center; filter: drop-shadow(0 6px 14px rgba(91,124,255,.4)); }
.brand-text strong { font-weight: 800; }
.brand-text { font-weight: 500; color: var(--muted); }
.brand-text strong { color: var(--text); margin-right: 4px; }
.header-cta { text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted); padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; transition: .2s; }
.header-cta:hover { color: var(--text); border-color: var(--brand); background: rgba(91,124,255,.1); }

/* ---------- HERO ---------- */
.hero { text-align: center; padding: 64px 0 36px; }
.hero-title {
  font-size: clamp(34px, 6vw, 56px); line-height: 1.05; margin: 0 0 16px;
  font-weight: 800; letter-spacing: -0.03em;
  background: linear-gradient(180deg, #fff, #b9c6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { max-width: 620px; margin: 0 auto 32px; color: var(--muted); font-size: clamp(15px, 2.2vw, 18px); }
.hero-sub em { color: var(--text); font-style: normal; font-weight: 600; }

.search { display: flex; gap: 10px; max-width: 600px; margin: 0 auto; }
.search-field {
  position: relative; flex: 1; display: flex; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; transition: .2s; box-shadow: var(--shadow);
}
.search-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(91,124,255,.18); }
.search-icon { position: absolute; left: 16px; color: var(--muted-2); pointer-events: none; }
#url-input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--text); font-size: 16px; padding: 17px 16px 17px 46px; width: 100%;
  font-family: inherit;
}
#url-input::placeholder { color: var(--muted-2); }

.btn-primary {
  border: 0; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 16px;
  color: #fff; padding: 0 26px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 30px -8px rgba(91,124,255,.6); transition: .18s; white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 34px -8px rgba(91,124,255,.7); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: progress; transform: none; }
.btn-primary.outline { background: transparent; border: 1px solid var(--brand); box-shadow: none; text-decoration: none; display: inline-flex; align-items: center; padding: 13px 22px; }
.btn-primary.outline:hover { background: rgba(91,124,255,.12); }

.btn-secondary {
  cursor: pointer; font-family: inherit; font-weight: 600; font-size: 15px;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  padding: 13px 22px; border-radius: 12px; transition: .18s;
}
.btn-secondary:hover { border-color: var(--brand); background: rgba(91,124,255,.1); }

.examples { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; color: var(--muted-2); font-size: 14px; }
.chip { cursor: pointer; font-family: inherit; font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; transition: .15s; }
.chip:hover { color: var(--text); border-color: var(--brand); }

/* ---------- LOADING ---------- */
.loading { padding: 30px 0 60px; }
.loader-card {
  display: flex; align-items: center; gap: 18px; max-width: 520px; margin: 0 auto 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { display: flex; flex-direction: column; gap: 3px; }
.loading-text strong { font-size: 16px; }
.loading-text span { color: var(--muted); font-size: 14px; }
.loading-steps { list-style: none; display: flex; gap: 10px; justify-content: center; padding: 0; margin: 0; flex-wrap: wrap; }
.loading-steps li { font-size: 13px; color: var(--muted-2); padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px; position: relative; transition: .3s; }
.loading-steps li.active { color: var(--text); border-color: var(--brand); background: rgba(91,124,255,.1); }
.loading-steps li.done { color: var(--good); border-color: rgba(24,192,143,.4); background: var(--good-soft); }
.loading-steps li.done::before { content: "✓ "; }

/* ---------- ERROR ---------- */
.error-box { padding: 30px 0 60px; }
.error-card { max-width: 560px; margin: 0 auto; text-align: center; background: var(--panel); border: 1px solid var(--bad); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.error-card h2 { margin: 0 0 10px; color: var(--bad); }
.error-card p { color: var(--muted); margin: 0 0 22px; word-break: break-word; }

/* ---------- REPORT ---------- */
.report { padding: 18px 0 70px; animation: fadeUp .4s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.report-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.report-target { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.report-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); }
.report-url { font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; word-break: break-all; }
.report-url:hover { color: var(--brand); }
.report-time { font-size: 13px; color: var(--muted-2); }

.seg-toggle { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; flex-shrink: 0; }
.seg { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--muted); background: transparent; border: 0; padding: 9px 16px; border-radius: 9px; transition: .15s; }
.seg.active { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 6px 16px -6px rgba(91,124,255,.7); }
.seg:not(.active):hover { color: var(--text); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-head { margin-bottom: 18px; }
.card-head h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.card-head .muted, .muted { color: var(--muted-2); font-weight: 500; font-size: .82em; }
.card-sub { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- GAUGES ---------- */
.scores-card { padding-bottom: 18px; }
.gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 6px; border-radius: var(--radius-sm); transition: .2s; }
.gauge-ring { position: relative; width: 120px; height: 120px; }
.gauge-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.gauge-track { fill: none; stroke: var(--line); stroke-width: 9; }
.gauge-fill { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1); }
.gauge-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge-label { font-size: 14px; font-weight: 600; color: var(--muted); text-align: center; }
.score-legend { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); }
.score-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; vertical-align: middle; }
.dot-green { background: var(--good); } .dot-orange { background: var(--avg); } .dot-red { background: var(--bad); }

.is-good { color: var(--good); } .is-avg { color: var(--avg); } .is-bad { color: var(--bad); }
.stroke-good { stroke: var(--good); } .stroke-avg { stroke: var(--avg); } .stroke-bad { stroke: var(--bad); }

/* ---------- CWV ---------- */
.cwv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cwv { position: relative; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 16px 16px 15px; overflow: hidden; }
.cwv::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.cwv.good::before { background: var(--good); } .cwv.avg::before { background: var(--avg); } .cwv.bad::before { background: var(--bad); }
.cwv-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cwv-abbr { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.cwv-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.cwv.good .cwv-badge { background: var(--good-soft); color: var(--good); }
.cwv.avg .cwv-badge { background: var(--avg-soft); color: var(--avg); }
.cwv.bad .cwv-badge { background: var(--bad-soft); color: var(--bad); }
.cwv-val { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.cwv-name { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- FIELD DATA ---------- */
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field-metric { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 16px; }
.field-metric-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.field-metric-head .fm-name { font-weight: 700; font-size: 14px; }
.field-metric-head .fm-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dist-bar { display: flex; height: 9px; border-radius: 999px; overflow: hidden; background: var(--line); }
.dist-seg { height: 100%; }
.dist-seg.good { background: var(--good); } .dist-seg.avg { background: var(--avg); } .dist-seg.bad { background: var(--bad); }
.dist-legend { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); }
.dist-legend span b { color: var(--text); font-variant-numeric: tabular-nums; }
.field-overall { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; margin-top: 2px; }
.field-overall.good { background: var(--good-soft); color: var(--good); }
.field-overall.avg { background: var(--avg-soft); color: var(--avg); }
.field-overall.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- FILMSTRIP ---------- */
.filmstrip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.film-frame { flex: 0 0 auto; text-align: center; }
.film-frame img { height: 150px; width: auto; border-radius: 8px; border: 1px solid var(--line); display: block; background: #fff; }
.film-frame span { display: block; font-size: 11px; color: var(--muted-2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.final-shot { margin-top: 16px; }
.final-shot img { max-height: 320px; width: auto; border-radius: 10px; border: 1px solid var(--line); }
.final-shot .fs-label { font-size: 12px; color: var(--muted-2); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- AUDIT LISTS ---------- */
.audit-list { display: flex; flex-direction: column; }
.audit-item { border-top: 1px solid var(--line-soft); }
.audit-item:first-child { border-top: 0; }
.audit-summary { display: flex; align-items: center; gap: 14px; padding: 14px 4px; cursor: pointer; list-style: none; }
.audit-summary::-webkit-details-marker { display: none; }
.audit-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.audit-dot.good { background: var(--good); } .audit-dot.avg { background: var(--avg); } .audit-dot.bad { background: var(--bad); }
.audit-title { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); min-width: 0; }
.audit-savings { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-chev { color: var(--muted-2); transition: .2s; flex-shrink: 0; }
details[open] .audit-chev { transform: rotate(90deg); }
.audit-detail { padding: 0 4px 16px 38px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.audit-detail a { color: var(--brand); }

/* ---------- WATERFALL ---------- */
.waterfall-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; font-size: 12px; color: var(--muted); }
.waterfall-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.waterfall { display: flex; flex-direction: column; gap: 3px; font-family: "JetBrains Mono", monospace; }
.wf-row { display: grid; grid-template-columns: 230px 1fr 64px; align-items: center; gap: 12px; font-size: 12px; padding: 3px 0; }
.wf-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.wf-track { position: relative; height: 16px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.wf-bar { position: absolute; top: 0; bottom: 0; border-radius: 4px; min-width: 2px; }
.wf-size { color: var(--muted-2); text-align: right; font-variant-numeric: tabular-nums; }
/* resource-type colours */
.rt-document { background: #5b7cff; } .rt-script { background: #ffac33; }
.rt-stylesheet { background: #18c08f; } .rt-image { background: #9d5bff; }
.rt-font { background: #ff5470; } .rt-fetch, .rt-xhr { background: #2dd4bf; }
.rt-media { background: #f472b6; } .rt-other, .rt-ping, .rt-eventsource { background: #6f7aa3; }

.rerun { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }

/* ---------- FOOTER ---------- */
.site-footer { border-top: 1px solid var(--line-soft); margin-top: 40px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 26px 0; flex-wrap: wrap; font-size: 13px; color: var(--muted-2); }
.footer-inner a { color: var(--muted); text-decoration: none; font-weight: 600; }
.footer-inner a:hover { color: var(--brand); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 820px) {
  .gauges { grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .cwv-grid { grid-template-columns: repeat(2, 1fr); }
  .field-grid { grid-template-columns: 1fr; }
  .wf-row { grid-template-columns: 130px 1fr 52px; gap: 8px; }
}
@media (max-width: 560px) {
  .hero { padding: 40px 0 28px; }
  .search { flex-direction: column; }
  .btn-primary { padding: 15px; }
  .cwv-grid { grid-template-columns: 1fr; }
  .gauge-ring { width: 104px; height: 104px; }
  .report-head { flex-direction: column; align-items: stretch; }
  .seg-toggle { width: 100%; }
  .seg { flex: 1; justify-content: center; }
  .wf-row { grid-template-columns: 92px 1fr 46px; }
  .header-cta { display: none; }
}
