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

:root {
  --red: #b52a2a;
  --red-light: #d43d3d;
  --red-dark: #8a1f1f;
  --bg: #0b0b0f;
  --bg-card: #111118;
  --bg-surface: #16161f;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.1);
  --text: #e8e8ec;
  --text-dim: #6b6b7b;
  --text-muted: #44445a;
  --accent-glow: rgba(181, 42, 42, 0.15);
  --green: #4ade80;
  --blue: #60a5fa;
  --yellow: #fbbf24;
  --pink: #f87171;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Backgrounds ---- */
.grid-bg {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 60px 60px; pointer-events: none;
}
.grid-bg::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, var(--accent-glow), transparent 70%);
}
.noise {
  position: fixed; inset: 0; z-index: 0; opacity: 0.035;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* ---- Animations ---- */
@keyframes staggerUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dropIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes orbitSpin { to { transform: rotate(360deg); } }
@keyframes corePulse { 0%,100% { transform:scale(1); opacity:0.8; } 50% { transform:scale(1.15); opacity:1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes loadFadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes loadFadeOut { from { opacity:1; } to { opacity:0; } }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--red); border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block;
}

/* ---- Shared Tags ---- */
.tag {
  font-family: 'JetBrains Mono', monospace; font-size: 0.68rem;
  padding: 0.25rem 0.6rem; border-radius: 6px;
  border: 1px solid var(--border); color: var(--text-dim); display: inline-block;
}
.tag.pass { border-color: rgba(74,222,128,0.25); color: var(--green); }
.tag.warn { border-color: rgba(251,191,36,0.25); color: var(--yellow); }
.tag.fail { border-color: rgba(248,113,113,0.25); color: var(--pink); }

/* ---- Method Badges ---- */
.item-method {
  font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; font-weight: 600;
  padding: 0.2rem 0.5rem; border-radius: 5px; flex-shrink: 0; text-transform: uppercase;
}
.method-get { background: rgba(74,222,128,0.12); color: var(--green); }
.method-post { background: rgba(96,165,250,0.12); color: var(--blue); }
.method-put { background: rgba(251,191,36,0.12); color: var(--yellow); }
.method-delete { background: rgba(248,113,113,0.12); color: var(--pink); }

.item-score {
  flex-shrink: 0; font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; font-weight: 600;
  padding: 0.3rem 0.6rem; border-radius: 8px;
}
.score-high { background: rgba(74,222,128,0.1); color: var(--green); }
.score-mid { background: rgba(251,191,36,0.1); color: var(--yellow); }
.score-low { background: rgba(248,113,113,0.1); color: var(--pink); }

.gemini-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; font-weight: 600;
  padding: 0.2rem 0.55rem; border-radius: 6px;
  background: linear-gradient(135deg, rgba(66,133,244,0.15), rgba(154,110,230,0.15));
  color: #9a6ee6; border: 1px solid rgba(154,110,230,0.2); letter-spacing: 0.04em;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

.footer { text-align: center; padding: 2rem; position: relative; z-index: 1; }
.footer p { font-size: 0.78rem; color: var(--text-muted); }

/* ================ LOADING OVERLAY ================ */
.loading-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(5,5,10,0.92); backdrop-filter: blur(24px);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 2.5rem;
  animation: loadFadeIn 0.35s ease-out;
}
.loading-overlay.active { display: flex; }
.loading-overlay.fade-out { animation: loadFadeOut 0.5s ease-in forwards; }

.orbital-spinner { position: relative; width: 100px; height: 100px; }
.orbital-spinner .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.orbital-spinner .ring-1 { border-top-color: var(--red-light); animation: orbitSpin 1.4s linear infinite; }
.orbital-spinner .ring-2 { inset: 10px; border-right-color: var(--red); animation: orbitSpin 1.8s linear infinite reverse; }
.orbital-spinner .ring-3 { inset: 20px; border-bottom-color: rgba(181,42,42,0.4); animation: orbitSpin 2.2s linear infinite; }
.orbital-spinner .core {
  position: absolute; inset: 32px; border-radius: 50%;
  background: radial-gradient(circle, var(--red-light), var(--red-dark));
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(181,42,42,0.1);
  animation: corePulse 2s ease-in-out infinite;
}

.loading-text { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.loading-title { font-size: 1.1rem; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.loading-status { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--text-dim); min-height: 1.4em; }
.cursor-blink { display: inline-block; width: 7px; height: 14px; background: var(--red-light); margin-left: 3px; vertical-align: middle; animation: blink 1s step-end infinite; }

.loading-steps { display: flex; flex-direction: column; gap: 0.55rem; width: 320px; }
.load-step {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem 0.75rem; border-radius: 10px; font-size: 0.82rem;
  color: var(--text-muted); transition: all 0.4s ease;
  transform: translateX(-6px); opacity: 0;
}
.load-step.active { color: var(--text-dim); background: rgba(255,255,255,0.02); transform: translateX(0); opacity: 1; }
.load-step.done { color: var(--text-dim); transform: translateX(0); opacity: 0.5; }
.load-step .step-icon {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  border: 1.5px solid var(--text-muted); transition: all 0.3s;
}
.load-step.active .step-icon { border-color: var(--red-light); background: rgba(181,42,42,0.1); }
.load-step.active .step-icon::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--red-light); animation: corePulse 1.2s ease-in-out infinite; }
.load-step.done .step-icon { border-color: var(--green); background: rgba(74,222,128,0.1); }
.load-step.done .step-icon::after { content: '✓'; font-size: 0.6rem; color: var(--green); line-height: 1; }
.load-step .step-text { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; }
.load-step .step-time { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; color: var(--text-muted); }

.loading-progress { width: 320px; height: 3px; background: var(--bg-surface); border-radius: 2px; overflow: hidden; }
.loading-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--red-dark), var(--red-light));
  border-radius: 2px; transition: width 0.5s ease;
  box-shadow: 0 0 8px rgba(181,42,42,0.4);
}

/* ================ HOME PAGE ================ */
.home-page {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem;
}
.home-page .content {
  display: flex; flex-direction: column; align-items: center; gap: 2rem;
  max-width: 640px; width: 100%; animation: staggerUp 0.7s ease-out both;
}
.logo-wrap { animation: staggerUp 0.5s ease-out both; }
.logo-wrap img { width: 120px; height: auto; filter: drop-shadow(0 0 30px rgba(181,42,42,0.25)); }
.heading { text-align: center; animation: staggerUp 0.6s ease-out 0.1s both; }
.heading h1 { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; margin-bottom: 0.6rem; }
.heading h1 strong {
  background: linear-gradient(135deg, var(--red-light), var(--red));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.heading p { font-size: 1rem; color: var(--text-dim); line-height: 1.6; max-width: 480px; margin: 0 auto; }

.search-section { width: 100%; animation: staggerUp 0.7s ease-out 0.2s both; }
.search-bar { position: relative; width: 100%; }
.search-input-wrap {
  position: relative; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-card);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.search-input-wrap:focus-within {
  border-color: rgba(181,42,42,0.4);
  box-shadow: 0 0 0 3px rgba(181,42,42,0.08), 0 8px 40px rgba(0,0,0,0.3);
}
.search-prefix {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace; font-size: 0.82rem;
  color: var(--red-light); pointer-events: none; opacity: 0.7;
}
.search-input {
  width: 100%; padding: 1.1rem 7rem 1.1rem 3rem; border: none; outline: none;
  font-family: 'DM Sans', sans-serif; font-size: 1rem;
  color: var(--text); background: transparent;
}
.search-input::placeholder { color: var(--text-muted); }
.search-submit {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: var(--red); border: none; color: #fff;
  padding: 0.55rem 1.1rem; border-radius: 10px;
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s, transform 0.15s;
  display: flex; align-items: center; gap: 0.4rem;
}
.search-submit:hover { background: var(--red-light); transform: translateY(-50%) scale(1.03); }
.search-submit:active { transform: translateY(-50%) scale(0.97); }
.search-submit svg { width: 15px; height: 15px; }

.dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  max-height: 360px; overflow-y: auto; z-index: 100;
  display: none; box-shadow: 0 20px 60px rgba(0,0,0,0.4); animation: dropIn 0.2s ease-out;
}
.dropdown.active { display: block; }
.dropdown-item {
  padding: 0.85rem 1.1rem; cursor: pointer;
  display: flex; align-items: center; gap: 0.85rem;
  border-bottom: 1px solid var(--border); transition: background 0.15s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg-surface); }
.item-info { flex: 1; min-width: 0; }
.item-endpoint {
  font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-desc { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.15rem; }
.dropdown-loading {
  padding: 1.5rem; text-align: center; color: var(--text-dim); font-size: 0.88rem;
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
}

.quick-actions {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  justify-content: center; margin-top: 0.5rem; animation: staggerUp 0.8s ease-out 0.35s both;
}
.quick-label { font-size: 0.78rem; color: var(--text-muted); margin-right: 0.25rem; }
.quick-chip {
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  padding: 0.35rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); cursor: pointer; transition: all 0.2s;
}
.quick-chip:hover {
  border-color: rgba(181,42,42,0.4); color: var(--red-light);
  background: rgba(181,42,42,0.06);
}

/* ================ ANALYSIS PAGE ================ */
.analysis-topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11,11,15,0.85); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.btn-back {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  padding: 0.4rem 0.8rem; border-radius: 8px; font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 0.35rem; text-decoration: none;
}
.btn-back:hover { border-color: var(--border-strong); color: var(--text); }
.btn-back svg { width: 14px; height: 14px; }
.topbar-url {
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.topbar-score {
  font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 700;
  margin-left: auto; flex-shrink: 0;
}

.analysis-container {
  max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem 4rem;
  animation: staggerUp 0.5s ease-out both;
}

/* Score Hero */
.score-hero {
  display: flex; align-items: center; gap: 2rem;
  padding: 2rem; border-radius: 16px;
  background: var(--bg-card); border: 1px solid var(--border); margin-bottom: 1.5rem;
}
.score-hero-ring { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.score-hero-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.score-hero-ring .ring-bg { fill: none; stroke: var(--bg-surface); stroke-width: 6; }
.score-hero-ring .ring-fill {
  fill: none; stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 339.292; stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 1.5s ease-out;
}
.score-hero-ring .score-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 2rem; font-weight: 700;
}
.score-hero-info { flex: 1; }
.score-hero-info h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.3rem; word-break: break-all; }
.score-hero-info .analysis-id {
  font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.75rem;
}
.score-hero-info .hero-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ---- 5 Criteria Grid ---- */
.criteria-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.criteria-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  transition: border-color 0.25s, transform 0.2s;
}
.criteria-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.criteria-card.cc-wide {
  grid-column: 1 / -1;
}

.cc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.cc-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.cc-icon-accent {
  background: rgba(181,42,42,0.1);
  color: var(--red-light);
}

.cc-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
}

.cc-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.cc-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.cc-bar {
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
}

.cc-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 1.2s ease-out;
  width: 0%;
}

/* Sections */
.section-title {
  font-size: 1rem; font-weight: 700; margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.5rem;
}

/* AI Summary */
.ai-summary {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.5rem; margin-bottom: 2rem;
}
.ai-summary-header {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem;
  font-size: 0.85rem; font-weight: 600;
}
.ai-summary p { font-size: 0.9rem; color: var(--text-dim); line-height: 1.7; }
.ai-summary p + p { margin-top: 0.75rem; }

/* Recommendations */
.recs-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 2rem; }
.rec-item {
  display: flex; gap: 0.75rem; padding: 1rem 1.15rem; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
}
.rec-severity { width: 4px; border-radius: 2px; flex-shrink: 0; }
.rec-severity.critical { background: var(--pink); }
.rec-severity.warning { background: var(--yellow); }
.rec-severity.info { background: var(--blue); }
.rec-content { flex: 1; }
.rec-content .rec-title { font-size: 0.88rem; font-weight: 600; margin-bottom: 0.2rem; }
.rec-content .rec-body { font-size: 0.82rem; color: var(--text-dim); line-height: 1.6; }

/* ---- Responsive ---- */
@media (max-width: 700px) {
  .score-hero { flex-direction: column; text-align: center; }
  .score-hero-info .hero-tags { justify-content: center; }
  .criteria-grid { grid-template-columns: 1fr; }
  .criteria-card.cc-wide { grid-column: auto; }
  .loading-steps, .loading-progress { width: 280px; }
  .heading h1 { font-size: 1.6rem; }
}
