*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Light theme (default) */
:root {
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --bg-input: #eef0f4;
  --text: #1a1d27;
  --text-muted: #6b7085;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --green: #16a34a;
  --yellow: #ca8a04;
  --red: #dc2626;
  --line: #d4d7e0;
  --radius: 8px;
  --radius-lg: 12px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #232733;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --line: #2a2e3a;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* Header */
.header {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.header .container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.5px;
}

.logo-accent {
  color: var(--accent);
}

.header-tagline {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.header-right {
  margin-left: auto;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 40px;
  height: 24px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  padding: 0;
}

.theme-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s;
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(16px);
}

/* Form Section */
.section-form {
  padding: 60px 0 40px;
  text-align: center;
}

.form-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.form-subtitle {
  color: var(--text-muted);
  font-size: 1.125rem;
  margin-bottom: 32px;
}

.test-form {
  max-width: 640px;
  margin: 0 auto;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.input-url-wrapper {
  flex: 1;
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s;
  overflow: hidden;
}

.input-url-wrapper:focus-within {
  border-color: var(--accent);
}

.protocol-select {
  padding: 14px 4px 14px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border-right: 1px solid var(--line);
  min-width: 80px;
}

.input-url {
  flex: 1;
  padding: 14px 16px 14px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.input-url::placeholder {
  color: var(--text-muted);
}

.btn-submit {
  padding: 14px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-submit:hover {
  background: var(--accent-hover);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-options {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.form-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
}

.form-group select:focus {
  border-color: var(--accent);
}

/* Error & Rate Limit */
.error-msg,
.rate-limit-msg {
  max-width: 640px;
  margin: 16px auto 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  text-align: left;
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

.rate-limit-msg {
  background: rgba(234, 179, 8, 0.1);
  color: var(--yellow);
}

/* Results Section */
.section-results {
  padding: 24px 0 60px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.results-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-url {
  font-weight: 600;
  font-size: 1.125rem;
  word-break: break-all;
}

.meta-tag {
  padding: 4px 10px;
  background: var(--bg-input);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-badge {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-pending { background: rgba(139, 143, 163, 0.15); color: var(--text-muted); }
.status-connecting { background: rgba(99, 102, 241, 0.15); color: var(--accent); animation: pulse 1.5s ease-in-out infinite; }
.status-running { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.status-complete { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.status-error { background: rgba(239, 68, 68, 0.15); color: var(--red); }

.btn-cancel {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--text-muted);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-cancel:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Metric card base (animations in animations.css) */
.metric-card {
  position: relative;
  overflow: hidden;
}

/* Filmstrip */
.filmstrip {
  margin-bottom: 24px;
  overflow-x: auto;
  padding: 8px 0;
}

.filmstrip-track {
  display: flex;
  gap: 8px;
  min-height: 120px;
}

.filmstrip-frame {
  flex-shrink: 0;
  width: 160px;
  text-align: center;
}

.filmstrip-frame img {
  width: 160px;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--bg-card);
}

.filmstrip-frame .frame-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: border-color 0.3s;
  border: 1px solid transparent;
}

.metric-card[data-rating="good"] { border-color: var(--green); }
.metric-card[data-rating="needs-improvement"] { border-color: var(--yellow); }
.metric-card[data-rating="poor"] { border-color: var(--red); }

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 2.25rem;
  line-height: 2.25rem;
}

.metric-card[data-rating="good"] .metric-value { color: var(--green); }
.metric-card[data-rating="needs-improvement"] .metric-value { color: var(--yellow); }
.metric-card[data-rating="poor"] .metric-value { color: var(--red); }

.metric-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  min-height: 1rem;
}

/* Score Ring */
.score-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.score-ring {
  position: relative;
  width: 120px;
  height: 120px;
}

.score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 8;
}

.score-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 1s ease, stroke 0.3s;
}

.score-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 700;
}

.score-label {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Waterfall */
.waterfall-section {
  margin-bottom: 24px;
}

.waterfall-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.request-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.waterfall-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.wf-group {
  margin-bottom: 12px;
}

.wf-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.wf-group-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.wf-group-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.waterfall-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
}

.wf-row {
  display: grid;
  grid-template-columns: 200px 60px 1fr 60px;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  font-size: 0.75rem;
  background: var(--bg-card);
  border-radius: 4px;
}

.wf-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.wf-status {
  text-align: center;
  font-weight: 600;
}

.wf-status.s2xx { color: var(--green); }
.wf-status.s3xx { color: var(--yellow); }
.wf-status.s4xx, .wf-status.s5xx { color: var(--red); }

.wf-bar-container {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.wf-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.3s;
}

.wf-time {
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Actions */
.result-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 24px;
}

.btn-action {
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  white-space: nowrap;
}

/* Inline new test */
.inline-new-test-section {
  max-width: 480px;
  margin: 0 auto 32px;
}

.inline-new-test {
  display: flex;
  gap: 8px;
}

.inline-url-wrapper {
  flex: 1;
  min-width: 0;
}

.inline-url-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.inline-url-input:focus {
  outline: none;
  border-color: var(--accent);
}

.inline-url-input::placeholder {
  color: var(--text-muted);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: var(--bg-card);
}

.btn-export {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  padding: 8px 16px;
}

.btn-export:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Server TTFB */
.server-ttfb-section {
  margin-bottom: 24px;
}

.server-ttfb-section .section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.ttfb-live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--green);
  margin-left: 10px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}

.server-ttfb-attempts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ttfb-chip {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.ttfb-chip:hover {
  border-color: var(--accent);
}

.ttfb-chip.expanded {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.ttfb-chip-num {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
}

.ttfb-chip[data-rating="good"] { color: var(--green); border-color: rgba(22, 163, 74, 0.3); }
.ttfb-chip[data-rating="poor"] { color: var(--red); border-color: rgba(220, 38, 38, 0.3); }
.ttfb-chip[data-rating="needs-improvement"] { color: var(--yellow); border-color: rgba(202, 138, 4, 0.3); }

.ttfb-detail {
  display: none;
  margin-top: 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  animation: fadeIn 0.2s ease;
}

.ttfb-detail.visible {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ttfb-detail-bar {
  display: flex;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-input);
  margin-bottom: 8px;
}

.ttfb-bar-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  min-width: 2px;
}

.ttfb-bar-dns { background: #6366f1; }
.ttfb-bar-tcp { background: #f59e0b; }
.ttfb-bar-tls { background: #10b981; }
.ttfb-bar-wait { background: #ef4444; }

.ttfb-detail-legend {
  display: flex;
  gap: 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.ttfb-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ttfb-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* TTFB Bar Chart */
.ttfb-chart {
  margin: 12px 0 8px;
}

.ttfb-chart-area {
  position: relative;
  background: var(--bg-input);
  border-radius: 6px;
  padding: 4px 8px;
}

.ttfb-cols {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
}

.ttfb-col {
  flex: 1;
  min-width: 16px;
  max-width: 40px;
  border-radius: 3px 3px 0 0;
  position: relative;
  transition: height 0.3s ease;
  min-height: 4px;
}

.ttfb-col-label {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}

.ttfb-threshold {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px dashed var(--text-muted);
  opacity: 0.35;
  z-index: 1;
  pointer-events: none;
}

.ttfb-monitor-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-left: 12px;
}

.ttfb-monitor-link:hover {
  text-decoration: underline;
}

.ttfb-threshold::after {
  content: attr(data-label);
  position: absolute;
  right: 2px;
  top: -10px;
  font-size: 0.55rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* CrUX Section */
.crux-section {
  margin-top: 24px;
}

.crux-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.crux-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.crux-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.crux-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crux-value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.crux-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

@media (max-width: 600px) {
  .crux-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* CTA Section */
.cta-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.cta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.cta-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.cta-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.1);
}

.cta-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.cta-body {
  flex: 1;
  min-width: 0;
}

.cta-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.cta-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.cta-arrow {
  font-size: 1.2rem;
  color: var(--accent);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .cta-grid {
    grid-template-columns: 1fr;
  }
}

.cta-card--accent {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
}

.cta-card--accent .cta-title {
  color: var(--accent);
}

/* Consultation Banner (lead magnet under score) */
.consult-banner {
  /* Slightly more breathing room after the score ring */
  margin-top: 32px;
  margin-bottom: 32px;
  /* Tinted background so the banner reads as distinct from plain bg-card metric cards */
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-card));
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

/* Fallback for browsers without color-mix support */
@supports not (background: color-mix(in srgb, red 5%, blue)) {
  .consult-banner {
    background: var(--bg-card);
  }
}

.consult-banner.banner-red {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 5%, var(--bg-card));
}

.consult-banner.banner-yellow {
  border-color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 5%, var(--bg-card));
}

.consult-banner-inner {
  display: flex;
  align-items: center;
  gap: 18px;
}

.consult-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  /* Accent ring instead of neutral line — ties avatar to the banner accent */
  border: 2px solid var(--accent);
}

.consult-banner.banner-red .consult-avatar {
  border-color: var(--red);
}

.consult-banner.banner-yellow .consult-avatar {
  border-color: var(--yellow);
}

.consult-body {
  flex: 1;
  min-width: 0;
}

/* Badge styled as a pill chip, not just a plain text label */
.consult-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 7px;
}

@supports not (background: color-mix(in srgb, red 12%, transparent)) {
  .consult-badge {
    background: rgba(99, 102, 241, 0.12);
  }
}

.consult-banner.banner-red .consult-badge {
  color: var(--red);
  background: rgba(220, 38, 38, 0.12);
}

.consult-banner.banner-yellow .consult-badge {
  color: var(--yellow);
  background: rgba(202, 138, 4, 0.12);
}

.consult-headline {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  margin-bottom: 6px;
}

.consult-text {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 14px;
}

.consult-cta {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 18px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.2s, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.consult-cta:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .consult-cta {
    transition: background 0.2s;
  }
  .consult-cta:hover {
    transform: none;
  }
}

.consult-banner.banner-red .consult-cta {
  background: var(--red);
}

.consult-banner.banner-red .consult-cta:hover {
  background: #b91c1c;
}

.consult-banner.banner-yellow .consult-cta {
  background: var(--yellow);
}

.consult-banner.banner-yellow .consult-cta:hover {
  background: #a16207;
}

@media (max-width: 640px) {
  /* On mobile: keep the row layout but shrink avatar, so avatar + name stay
     visually connected — better than stacking avatar alone above the text */
  .consult-banner-inner {
    align-items: flex-start;
    gap: 14px;
  }

  .consult-banner-inner > .consult-avatar {
    width: 52px;
    height: 52px;
    /* Nudge down slightly to align with the badge text line */
    margin-top: 2px;
  }

  .consult-cta {
    width: 100%;
    text-align: center;
    padding: 11px 18px;
  }
}

/* CTA card with avatar */
.cta-avatar {
  /* Slightly larger than 44px minimum touch — reads better next to text */
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  /* Accent ring on the consult card avatar to reinforce brand identity */
  border: 2px solid var(--accent);
  opacity: 0.9;
  transition: opacity 0.2s;
}

.cta-card-consult:hover .cta-avatar {
  opacity: 1;
}

.cta-card-consult {
  border-color: var(--accent);
}

.cta-card-consult:hover {
  border-color: var(--accent-hover);
  box-shadow: 0 2px 16px rgba(99, 102, 241, 0.18);
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Loading spinner in submit button */
.btn-submit.loading {
  position: relative;
  color: transparent;
}

.btn-submit.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Metric pending animation */
.metric-value.pending {
  animation: pulse 1.5s ease-in-out infinite;
  font-size: 0.85rem;
  color: var(--text-muted, #888);
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* TTFB elapsed timer */
.ttfb-elapsed-timer {
  padding: 12px 16px;
  color: var(--text-muted, #888);
  font-size: 0.9rem;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Auth Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-text {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.modal-input:focus {
  border-color: var(--accent);
}

.modal-input-otp {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5em;
  font-variant-numeric: tabular-nums;
}

.modal-error {
  color: var(--red);
  font-size: 0.8rem;
  margin-top: 8px;
}

.modal-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 12px;
  padding: 0;
}

.modal-link:hover {
  text-decoration: underline;
}

.auth-step form {
  display: flex;
  flex-direction: column;
}

.auth-step .btn-submit {
  width: 100%;
}

/* Lead Magnet Slide-in Modal */
.leadmagnet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1100;
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.leadmagnet-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.leadmagnet-panel {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translate(100%, -50%);
  width: 400px;
  max-width: calc(100vw - 24px);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.25);
  z-index: 1101;
  padding: 28px 24px 24px;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.leadmagnet-panel.is-visible {
  transform: translate(0, -50%);
}

.leadmagnet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}

.leadmagnet-close:hover {
  background: var(--bg-input);
  color: var(--text);
}

.leadmagnet-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
}

.leadmagnet-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
}

.leadmagnet-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 8px;
}

.leadmagnet-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.leadmagnet-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leadmagnet-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.leadmagnet-input:focus {
  border-color: var(--accent);
}

.leadmagnet-input::placeholder {
  color: var(--text-muted);
}

.leadmagnet-submit {
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.leadmagnet-submit:hover {
  background: var(--accent-hover);
}

.leadmagnet-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.leadmagnet-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 2px;
}

.leadmagnet-consent input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.leadmagnet-consent label {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.leadmagnet-consent a {
  color: var(--accent);
  text-decoration: underline;
}

.leadmagnet-legal {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 8px;
  opacity: 0.75;
}

.leadmagnet-success {
  text-align: center;
  padding: 16px 0;
}

.leadmagnet-success-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.leadmagnet-success-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.leadmagnet-success-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.leadmagnet-error {
  color: var(--red);
  font-size: 0.78rem;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .leadmagnet-panel {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    top: auto;
    bottom: 0;
    right: 0;
    transform: translate(0, 100%);
    max-height: 85vh;
  }

  .leadmagnet-panel.is-visible {
    transform: translate(0, 0);
  }
}

/* History */
.history-section {
  margin-top: 32px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.history-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  transition: color 0.15s;
}

.history-clear-btn:hover {
  color: var(--red);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.15s;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-score {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.history-score.good {
  background: var(--green);
}

.history-score.average {
  background: var(--yellow);
}

.history-score.poor {
  background: var(--red);
}

.history-score.none {
  background: var(--text-muted);
  font-size: 0.7rem;
}

.history-info {
  min-width: 0;
}

.history-url {
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.history-compare-btn,
.history-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.15s;
}

.history-compare-btn:hover {
  color: var(--accent);
  background: var(--bg-input);
}

.history-delete-btn:hover {
  color: var(--red);
  background: var(--bg-input);
}

/* Compare */
.compare-section {
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}

.compare-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.compare-header-row,
.compare-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr 1fr;
  gap: 8px;
  padding: 8px 0;
}

.compare-header-row {
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 4px;
  font-weight: 600;
}

.compare-row {
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.compare-row:last-child {
  border-bottom: none;
}

.compare-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.compare-val {
  font-size: 0.9rem;
}

.compare-diff {
  font-weight: 600;
  font-size: 0.9rem;
  text-align: right;
}

.compare-diff.improved {
  color: var(--green);
}

.compare-diff.regressed {
  color: var(--red);
}

/* Compare Picker */
.compare-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-picker {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 300px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.compare-picker h3 {
  margin-bottom: 12px;
}

.compare-picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.compare-picker-item {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.15s;
}

.compare-picker-item:hover {
  border-color: var(--accent);
}

.compare-picker-close {
  background: none;
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  width: 100%;
  transition: all 0.15s;
}

.compare-picker-close:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Export */
.export-watermark {
  text-align: center;
  padding: 16px 0 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 640px) {
  .form-title { font-size: 1.5rem; }
  .form-subtitle { font-size: 1rem; }

  .form-row {
    flex-direction: column;
  }

  .form-options {
    flex-direction: column;
    align-items: stretch;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .wf-row {
    grid-template-columns: 140px 40px 1fr 50px;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-actions {
    flex-direction: column;
  }

  .inline-new-test {
    width: 100%;
  }

  .filmstrip-frame {
    width: 120px;
  }

  .filmstrip-frame img {
    width: 120px;
  }

  .compare-header-row, .compare-row {
    grid-template-columns: 70px 1fr 1fr 1fr;
  }

  .history-item {
    grid-template-columns: 35px 1fr auto;
    gap: 8px;
  }

  .history-score {
    width: 35px;
    height: 35px;
    font-size: 0.7rem;
  }
}
