@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-color: #0a0a0f;
  --panel-bg: #0c0c14;
  --card-bg: #11111a;
  --alert-bg: #161620;
  --text-main: #d1d5db;
  --text-muted: #9ca3af;
  --accent-red: #ff3131;
  --accent-red-glow: rgba(255, 49, 49, 0.8);
  --accent-neon: 0 0 15px rgba(255, 49, 49, 0.15), inset 0 0 5px rgba(255, 49, 49, 0.1);
  --accent-white: #ffffff;
  --card-hover: #161620;
  --card-border: rgba(255, 49, 49, 0.2);
  --card-border-hover: rgba(255, 49, 49, 0.5);
  --font-body: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', Courier, monospace;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* Animated background grid */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-size: 32px 32px;
  background-image: 
    linear-gradient(to right, rgba(255, 49, 49, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 49, 49, 0.05) 1px, transparent 1px);
  z-index: -2;
  opacity: 0.5;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; height: 2px;
  background: rgba(255, 49, 49, 0.1);
  box-shadow: 0 0 10px rgba(255,49,49,0.2);
  z-index: 10;
  pointer-events: none;
  animation: scanline 6s linear infinite;
}

@keyframes scanline {
  0% { transform: translateY(-10px); }
  100% { transform: translateY(100vh); }
}

h1, h2, h3, h4 {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-white);
  line-height: 1.2;
}

p {
  color: var(--text-muted);
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.3s ease;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 5%;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  z-index: 100;
  background: rgba(10, 10, 15, 0.9);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-white);
}

.nav-brand svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--accent-red);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

/* Usage Badge — "reviews left today" pill shown left of Home for signed-in users */
.usage-badge {
  display: none;
  align-items: center;
  gap: 0.5rem;
  flex: 0 1 140px;
  min-width: 0;
  margin: 0 1.25rem;
}

.usage-badge-text {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.usage-badge-bar {
  flex: 1;
  height: 4px;
  min-width: 30px;
  background: var(--card-border);
  border-radius: 2px;
  overflow: hidden;
}

.usage-badge-fill {
  height: 100%;
  background: var(--accent-red);
  border-radius: 2px;
  transition: width 0.3s ease;
}

@media (max-width: 900px) {
  .usage-badge {
    display: none !important;
  }
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-links a:hover {
  color: var(--accent-red);
  text-shadow: 0 0 8px var(--accent-red-glow);
}

.nav-links a.active {
  color: var(--accent-red);
}

/* Menu Toggle (Mobile) */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--accent-white);
  cursor: pointer;
}

@media (max-width: 900px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    flex-direction: column;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--card-border);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 999;
  }
  .nav-links.show {
    display: flex;
  }
  .menu-toggle {
    display: block;
  }
}

/* Footer */
.footer {
  text-align: center;
  padding: 3rem 1.5rem;
  border-top: 1px solid var(--card-border);
  margin-top: 5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer .tagline {
  margin-bottom: 1rem;
  color: var(--accent-white);
}

.footer svg {
  width: 20px;
  height: 20px;
  margin-top: 1rem;
  fill: currentColor;
}

.footer a:hover {
  color: var(--accent-red);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.875rem 2rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.05em;
  border: 1px solid var(--accent-red);
  color: var(--accent-white);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.btn-primary {
  background: var(--accent-red);
  color: #000;
  border-color: var(--accent-red);
  box-shadow: var(--accent-neon);
}

.btn-primary:hover {
  background: transparent;
  color: var(--accent-red);
  box-shadow: 0 0 20px var(--accent-red-glow);
  transform: scale(0.98);
}

.btn-explain {
  border: 1px solid rgba(0,170,255,0.4);
  color: #00aaff;
  background: rgba(0,170,255,0.08);
}
.btn-explain:hover {
  background: transparent;
  border-color: #00aaff;
  box-shadow: 0 0 20px rgba(0,170,255,0.3);
  transform: scale(0.98);
}

.btn-smell {
  border: 1px solid rgba(255,165,0,0.4);
  color: #ffa500;
  background: rgba(255,165,0,0.08);
}
.btn-smell:hover {
  background: transparent;
  border-color: #ffa500;
  box-shadow: 0 0 20px rgba(255,165,0,0.3);
  transform: scale(0.98);
}

.btn-pr {
  border: 1px solid rgba(139,92,246,0.4);
  color: #8b5cf6;
  background: rgba(139,92,246,0.08);
}
.btn-pr:hover {
  background: transparent;
  border-color: #8b5cf6;
  box-shadow: 0 0 20px rgba(139,92,246,0.3);
  transform: scale(0.98);
}

.btn-secondary {
  border-color: var(--card-border);
  color: var(--accent-red);
  box-shadow: var(--accent-neon);
  background: rgba(255,49,49,0.05);
  font-weight: 600;
  letter-spacing: 1px;
  font-size: 0.85rem;
}

.btn-secondary:hover {
  background: var(--accent-red);
  color: #000;
  box-shadow: 0 0 20px var(--accent-red-glow);
}

/* Fade-in Scroll */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Base Layout */
main {
  min-height: calc(100vh - 80px);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

/* Index Hero */
.hero {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4rem 1rem;
}

.glitch-wrapper {
  position: relative;
  margin-bottom: 1rem;
}

.glitch {
  font-size: clamp(3rem, 8vw, 6rem);
  text-transform: uppercase;
  position: relative;
}

.glitch::before, .glitch::after {
  content: "CodeAutopsy";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  opacity: 0.8;
}

.glitch::before {
  left: 2px;
  text-shadow: -2px 0 var(--accent-red);
  animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -2px 0 #0ff;
  animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
  0% { clip: rect(20px, 9999px, 85px, 0); }
  20% { clip: rect(5px, 9999px, 50px, 0); }
  40% { clip: rect(60px, 9999px, 15px, 0); }
  60% { clip: rect(10px, 9999px, 90px, 0); }
  80% { clip: rect(80px, 9999px, 30px, 0); }
  100% { clip: rect(25px, 9999px, 70px, 0); }
}

@keyframes glitch-anim-2 {
  0% { clip: rect(10px, 9999px, 30px, 0); }
  20% { clip: rect(80px, 9999px, 10px, 0); }
  40% { clip: rect(20px, 9999px, 50px, 0); }
  60% { clip: rect(50px, 9999px, 80px, 0); }
  80% { clip: rect(30px, 9999px, 20px, 0); }
  100% { clip: rect(70px, 9999px, 90px, 0); }
}

.hero p {
  font-size: 1.2rem;
  max-width: 600px;
  margin-bottom: 3rem;
}

.hero-btns {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Features Cards */
.features {
  padding: 6rem 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 2.5rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: var(--card-border-hover);
  box-shadow: var(--accent-neon);
  transform: translateY(-2px);
}

.card-icon {
  width: 40px;
  height: 40px;
  stroke: var(--accent-red);
  margin-bottom: 1.5rem;
}

.card h3 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

/* Stats Bar */
.stats {
  padding: 4rem 0;
  border-top: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
  background: var(--panel-bg);
}

.stats-grid {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 2rem;
  text-align: center;
}

.stat-item h3 {
  font-size: 3rem;
  color: var(--accent-red);
  margin-bottom: 0.5rem;
  text-shadow: 0 0 10px var(--accent-red-glow);
}

.stat-item p {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-transform: uppercase;
}

/* How It Works - Timeline */
.timeline-section {
  padding: 6rem 0;
}

.timeline-section h2 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 4rem;
}

.timeline {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 100%;
  background: var(--card-border);
}

.timeline-line {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 0; /* Animated via JS */
  background: var(--accent-red);
  box-shadow: 0 0 10px var(--accent-red);
  z-index: 1;
}

.timeline-step {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6rem;
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.timeline-step.visible {
  opacity: 1;
  transform: translateY(0);
}

.timeline-step:nth-child(even) {
  flex-direction: row-reverse;
}

.step-content {
  width: 45%;
  background: var(--card-bg);
  padding: 2rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  position: relative;
}

.step-number {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-color);
  border: 2px solid var(--accent-red);
  color: var(--accent-red);
  font-family: var(--font-mono);
  font-weight: 700;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--accent-red-glow);
}

.timeline-step:nth-child(odd) .step-number {
  right: -20px;
}

.timeline-step:nth-child(even) .step-number {
  left: -20px;
}

.step-icon {
  width: 45%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.step-visual {
  width: 100px;
  height: 100px;
  border: 2px dashed var(--card-border-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  position: relative;
}
.step-visual::before {
  content:'</>';
  font-family: var(--font-mono);
  color: var(--accent-red);
  font-size: 2rem;
}

/* About Page */
.about-hero {
  text-align: center;
  padding: 6rem 0 4rem;
  max-width: 800px;
  margin: 0 auto;
}

.about-hero h1 {
  font-size: 3rem;
  margin-bottom: 1.5rem;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin: 4rem 0;
}

.team-card {
  text-align: center;
  padding: 2rem;
}

.avatar-placeholder {
  width: 100px;
  height: 100px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-placeholder svg {
  width: 40px;
  height: 40px;
  stroke: var(--text-muted);
}

.tech-stack {
  text-align: center;
  margin-top: 6rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

.pill {
  padding: 0.5rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 50px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-white);
  transition: all 0.3s ease;
}

.pill:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  box-shadow: 0 0 10px var(--accent-red-glow);
}

/* Tool Page */
.tool-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  height: calc(100vh - 100px);
  margin-top: 1rem;
}

@media (min-width: 1024px) {
  .tool-layout {
    flex-direction: row;
    height: calc(100vh - 100px);
  }
}

.tool-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  height: 100%;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  background: var(--card-bg);
  flex-shrink: 0;
}

.panel-actions {
  display: flex;
  gap: 1rem;
}

select {
  background: var(--bg-color);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  padding: 0.5rem;
  font-family: var(--font-mono);
  border-radius: 4px;
  outline: none;
}
select:focus {
  border-color: var(--accent-red);
}

.code-area {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.line-numbers {
  width: 48px;
  min-width: 48px;
  background: var(--bg-color);
  border-right: 1px solid var(--card-border);
  padding: 1rem 0.5rem 1rem 0;
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  user-select: none;
  overflow: hidden;
  position: relative;
}

.line-numbers div {
  height: calc(0.9rem * 1.5);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.4rem;
  position: relative;
  transition: color 0.2s;
}

/* Blinking red dot on error lines */
.line-numbers div.error-line::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  background: var(--accent-red);
  border-radius: 50%;
  animation: hooter 0.6s ease-in-out infinite alternate;
  box-shadow: 0 0 6px var(--accent-red), 0 0 12px var(--accent-red);
}

@keyframes hooter {
  from { opacity: 1; box-shadow: 0 0 6px var(--accent-red), 0 0 14px var(--accent-red); }
  to   { opacity: 0.15; box-shadow: none; }
}

textarea {
  flex: 1;
  background: transparent;
  color: var(--accent-white);
  border: none;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  resize: none;
  outline: none;
  line-height: 1.5;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Tool Output */
.output-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: 0;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Score Ring */
.score-section {
  display: flex;
  align-items: center;
  gap: 2rem;
}

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

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

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

.score-circle {
  fill: none;
  stroke: var(--accent-red);
  stroke-width: 8;
  stroke-dasharray: 251; /* 2 * PI * R (40) */
  stroke-dashoffset: 251;
  transition: stroke-dashoffset 1.5s ease-out;
  stroke-linecap: round;
}

.score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-white);
}

/* Bugs List */
.bug-card {
  background: var(--alert-bg);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--accent-red);
  padding: 1.5rem;
  border-radius: 0;
}

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

.bug-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.badge-critical { background: rgba(255, 49, 49, 0.1); color: #ff3131; border: 1px solid rgba(255,49,49,0.2); }
.badge-warning  { background: rgba(255, 170, 0, 0.1); color: #ffaa00; border-left-color: #ffaa00; border: 1px solid rgba(255,170,0,0.2); }
.badge-suggestion { background: rgba(0, 170, 255, 0.1); color: #00aaff; border-left-color: #00aaff; border: 1px solid rgba(0,170,255,0.2); }

.bug-card.warning { border-left-color: #ffaa00; }
.bug-card.suggestion { border-left-color: #00aaff; }

.bug-line {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.bug-desc {
  margin-bottom: 1rem;
}

.bug-fix {
  background: var(--bg-color);
  padding: 1rem;
  border-radius: 0;
  border-left: 2px solid #00aaff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #a5d6ff;
  white-space: pre-wrap;
}

/* Improved code block */
.improved-code-section {
  border-top: 1px solid var(--card-border);
  padding-top: 2rem;
}

.improved-code {
  background: var(--panel-bg);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  color: var(--text-main);
  overflow-x: auto;
  position: relative;
}
.improved-code pre {
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

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

/* ── File Upload Drop Zone ── */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem 1rem;
  margin: 0.75rem 1rem 0;
  border: 1.5px dashed var(--card-border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: default;
  transition: border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.drop-zone svg {
  width: 24px; height: 24px;
  stroke: var(--text-muted);
  margin-bottom: 0.1rem;
}
.drop-zone.drag-over {
  border-color: var(--accent-red);
  background: rgba(255,42,42,0.05);
}
.drop-zone.drag-over svg { stroke: var(--accent-red); }
.drop-zone-hint { font-size: 0.65rem; color: var(--card-border-hover); }
.file-label {
  color: var(--accent-red);
  cursor: pointer;
  text-decoration: underline;
}

/* ── Output Action Buttons ── */
.output-action-btn {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  border-radius: 3px;
  transition: border-color 0.2s, color 0.2s;
}
.output-action-btn:hover { border-color: var(--accent-red); color: var(--accent-white); }
.output-action-btn.active { border-color: var(--accent-red); color: var(--accent-red); }

/* ── Diff View ── */
.diff-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.diff-pane {
  background: var(--panel-bg);
  overflow-x: auto;
}
.diff-pane-header {
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--card-border);
  color: var(--text-muted);
  background: var(--card-bg);
}
.diff-pane:first-child { border-right: 1px solid var(--card-border); }
.diff-pane pre {
  margin: 0;
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-main);
}
.diff-line-add { background: rgba(0, 200, 100, 0.12); color: #4ade80; }
.diff-line-remove { background: rgba(255, 42, 42, 0.12); color: var(--accent-red); }
.diff-line-add::before { content: '+ '; }
.diff-line-remove::before { content: '- '; }

/* ── Share Toast ── */
.share-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--accent-white);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.7rem 1.4rem;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Output Animations */
.running-pulse {
  animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 5px var(--accent-red-glow); }
  50% { box-shadow: 0 0 25px var(--accent-red-glow); }
  100% { box-shadow: 0 0 5px var(--accent-red-glow); }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,42,42,0.2);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* ── Mode Toggle Bar ─────────────────────────────────────────────────── */
.mode-toggle-bar {
  display: flex;
  gap: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--card-border);
  background: var(--bg-color);
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.25s ease;
}

.mode-btn:first-child { border-radius: 4px 0 0 4px; border-right: none; }
.mode-btn:last-child  { border-radius: 0 4px 4px 0; }

.mode-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  flex-shrink: 0;
}

.mode-btn:hover {
  color: var(--accent-white);
  border-color: var(--card-border-hover);
}

.mode-btn.active {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #000;
  box-shadow: 0 0 15px rgba(255,49,49,0.35);
}

/* ── Complexity Bar ───────────────────────────────────────────────────── */
.complexity-bar {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
}

.complexity-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.complexity-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.complexity-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #00aaff;
  font-weight: 600;
}

/* ── Section Block ────────────────────────────────────────────────────── */
.section-block {
  display: flex;
  flex-direction: column;
}

/* ── Empty State Illustration ─────────────────────────────────────────── */
.empty-state-illustration {
  width: 120px;
  height: 120px;
  margin: 0 auto 0.75rem;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}

/* ── Score Ring Smooth Animation ──────────────────────────────────────── */
.score-circle {
  fill: none;
  stroke-width: 8;
  stroke-dasharray: 251;
  stroke-dashoffset: 251;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.8s cubic-bezier(0.25, 1, 0.5, 1);
}

.score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  animation: scorePopIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s both;
}

@keyframes scorePopIn {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ── Code Explainer Cards ─────────────────────────────────────────────── */
.explain-summary {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent-red);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  animation: slideInUp 0.4s ease both;
}

.explain-card {
  background: var(--alert-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: border-color 0.2s, transform 0.2s;
  animation: slideInUp 0.35s ease both;
}

.explain-card:hover {
  border-color: var(--card-border-hover);
  transform: translateX(3px);
}

.explain-line-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-red);
  background: rgba(255,49,49,0.08);
  border: 1px solid rgba(255,49,49,0.2);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.explain-text {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.65;
  margin: 0;
}

.suggest-card {
  background: var(--alert-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  animation: slideInUp 0.35s ease both;
  transition: border-color 0.2s;
}

.suggest-card:hover { border-color: var(--card-border-hover); }

.suggest-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
}

/* ── General smooth transitions ───────────────────────────────────────── */
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1), transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.fade-in.visible > *:nth-child(1) { transition-delay: 0.05s; }
.fade-in.visible > *:nth-child(2) { transition-delay: 0.1s; }
.fade-in.visible > *:nth-child(3) { transition-delay: 0.15s; }

/* ── Loading message fade transition ──────────────────────────────────── */
#loading-msg {
  transition: opacity 0.2s ease;
}

/* ── Bug card entrance animation ──────────────────────────────────────── */
.bug-card {
  animation: slideInUp 0.3s ease both;
}
.bug-card:nth-child(1) { animation-delay: 0.05s; }
.bug-card:nth-child(2) { animation-delay: 0.1s; }
.bug-card:nth-child(3) { animation-delay: 0.15s; }
.bug-card:nth-child(4) { animation-delay: 0.2s; }
.bug-card:nth-child(5) { animation-delay: 0.25s; }

/* ── GitHub Import Styles ─────────────────────────────────────────────── */
#github-modal {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#github-modal > div {
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

#github-modal svg {
  transition: opacity 0.3s ease;
}

#github-repos-list > div,
#github-files-list > div {
  animation: slideInUp 0.2s ease both;
}

#github-repos-list > div:nth-child(1),
#github-files-list > div:nth-child(1) { animation-delay: 0.02s; }
#github-repos-list > div:nth-child(2),
#github-files-list > div:nth-child(2) { animation-delay: 0.04s; }
#github-repos-list > div:nth-child(3),
#github-files-list > div:nth-child(3) { animation-delay: 0.06s; }
#github-repos-list > div:nth-child(4),
#github-files-list > div:nth-child(4) { animation-delay: 0.08s; }
#github-repos-list > div:nth-child(5),
#github-files-list > div:nth-child(5) { animation-delay: 0.1s; }

#github-repo-search {
  transition: border-color 0.2s;
}

#github-repo-search:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 10px rgba(255, 49, 49, 0.15);
}

/* Spinner animation */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   HISTORY DASHBOARD PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Page Header ────────────────────────────────────────────────────────── */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 2rem;
}

.history-header h1 {
  font-size: 2rem;
  margin: 0;
  background: linear-gradient(135deg, var(--accent-white) 0%, var(--accent-red) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Stats Summary ──────────────────────────────────────────────────────── */
.history-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.history-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.history-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-red), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.history-stat-card:hover {
  border-color: var(--card-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--accent-neon);
}

.history-stat-card:hover::before {
  opacity: 1;
}

.history-stat-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-red);
  text-shadow: 0 0 10px var(--accent-red-glow);
  margin-bottom: 0.35rem;
}

.history-stat-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── Chart Section ──────────────────────────────────────────────────────── */
.history-chart-wrap {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  transition: border-color 0.3s;
}

.history-chart-wrap:hover {
  border-color: var(--card-border-hover);
}

.history-chart-container {
  width: 100%;
  overflow-x: auto;
}

.history-chart-container canvas {
  width: 100% !important;
  height: 200px;
  display: block;
}

/* ── Filter Bar ─────────────────────────────────────────────────────────── */
.history-filter-bar {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 140px;
}

.filter-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filter-select {
  background: var(--bg-color);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 8px rgba(255,49,49,0.15);
}

/* ── Cards Grid ─────────────────────────────────────────────────────────── */
.history-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* ── Individual Review Card ─────────────────────────────────────────────── */
.history-review-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  animation: cardFadeIn 0.35s ease both;
}

@keyframes cardFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* shimmer sweep */
.history-review-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(120deg, transparent 0%, rgba(255,49,49,0.06) 50%, transparent 100%);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
  pointer-events: none;
  z-index: 1;
}

.history-review-card:hover {
  border-color: rgba(255, 49, 49, 0.5);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 49, 49, 0.2),
    0 0 20px rgba(255, 49, 49, 0.08);
  transform: translateY(-6px) scale(1.018);
}

.history-review-card:hover::before {
  left: 130%;
}


.history-review-card:nth-child(1) { animation-delay: 0.02s; }
.history-review-card:nth-child(2) { animation-delay: 0.04s; }
.history-review-card:nth-child(3) { animation-delay: 0.06s; }
.history-review-card:nth-child(4) { animation-delay: 0.08s; }
.history-review-card:nth-child(5) { animation-delay: 0.10s; }
.history-review-card:nth-child(6) { animation-delay: 0.12s; }

.review-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.review-lang-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: rgba(255,49,49,0.08);
  color: var(--accent-red);
  border: 1px solid rgba(255,49,49,0.2);
}

.review-score-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  border: 1px solid;
}

.review-score-badge.score-good {
  background: rgba(74,222,128,0.1);
  color: #4ade80;
  border-color: rgba(74,222,128,0.3);
}

.review-score-badge.score-avg {
  background: rgba(250,204,21,0.1);
  color: #facc15;
  border-color: rgba(250,204,21,0.3);
}

.review-score-badge.score-bad {
  background: rgba(255,49,49,0.1);
  color: var(--accent-red);
  border-color: rgba(255,49,49,0.3);
}

.review-card-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.review-meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.review-meta-item svg {
  width: 12px;
  height: 12px;
  stroke: var(--text-muted);
  flex-shrink: 0;
}

.review-code-preview {
  background: var(--bg-color);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 60px;
  overflow: hidden;
  position: relative;
}

.review-code-preview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(transparent, var(--bg-color));
  pointer-events: none;
}

.review-card-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.25rem;
  border-top: 1px solid var(--card-border);
  margin-top: auto;
}

.review-rerun-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--card-border);
  color: var(--accent-red);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.25s ease;
  text-decoration: none;
}

.review-rerun-btn:hover {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #000;
  box-shadow: 0 0 12px rgba(255,49,49,0.3);
}

.review-rerun-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
}

/* ── Empty / No-results States ──────────────────────────────────────────── */
.history-empty {
  text-align: center;
  padding: 4rem 2rem;
}

/* ── Clear Modal ────────────────────────────────────────────────────────── */
.history-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.history-modal {
  background: var(--panel-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 2.5rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.history-modal-icon {
  margin-bottom: 1rem;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .history-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .history-cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 2rem 0 1.5rem;
  }
  .history-header h1 {
    font-size: 1.5rem;
  }
  .history-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .history-filter-bar {
    flex-direction: column;
    gap: 0.75rem;
  }
  .filter-group {
    min-width: 100%;
  }
}

.hover-char {
  display: inline;
  transition: color 0.2s ease;
  cursor: default;
}
/* ── Mega Menu ───────────────────────────────────────────────────────── */
.nav-features-item {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-features-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.nav-features-item:hover .chevron,
.nav-features-item.open .chevron {
  transform: rotate(180deg);
}

.mega-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #0d0d12;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.5rem;
  display: flex;
  flex-direction: row;
  gap: 0;
  width: max-content;
  max-width: 860px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.25,1,0.5,1), visibility 0.22s;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  z-index: 999;
}

.mega-menu::after {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
}

.mega-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 6px;
  background: #0d0d12;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  border-left: 1px solid var(--card-border);
  border-right: 1px solid var(--card-border);
}

.nav-features-item:hover .mega-menu,
.nav-features-item.open .mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

.mega-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  flex: 0 0 200px;
  transition: background 0.18s ease, transform 0.18s ease;
}

.mega-item:hover {
  background: rgba(255,49,49,0.06);
  transform: translateY(-2px);
}

.mega-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,49,49,0.08);
  border: 1px solid rgba(255,49,49,0.18);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mega-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent-red);
}

.mega-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mega-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-white);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.mega-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: normal;
}

.mega-badge {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(255,49,49,0.12);
  color: var(--accent-red);
  border: 1px solid rgba(255,49,49,0.2);
}

.mega-divider {
  width: 1px;
  background: var(--card-border);
  margin: 0.5rem 0;
  flex-shrink: 0;
}

/* mobile — hide mega, show as normal links */
@media (max-width: 900px) {
  .mega-menu {
    display: none;
    position: static !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
    box-shadow: none !important;
    border-radius: 8px;
    flex-direction: column;
    margin-top: 0.5rem;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-features-item.open .mega-menu {
    display: flex !important;
  }
  .mega-menu::before,
  .mega-menu::after {
    display: none !important;
  }
  .mega-item {
    flex: unset !important;
    width: 100% !important;
    flex-shrink: 0;
  }
  /* prevent hover from triggering on touch/small screens */
  .nav-features-item:hover .mega-menu {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .nav-features-item.open .mega-menu {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
  }
}
/* ── Comprehensive Mobile Responsive Fixes (max-width: 768px) ── */
@media (max-width: 768px) {

  /* Container */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Hero */
  .hero {
    padding: 2rem 1rem;
    min-height: calc(100vh - 60px);
  }
  .hero p {
    font-size: 1rem;
    margin-bottom: 2rem;
  }
  .hero-btns {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
  }
  .hero-btns .btn {
    width: 100%;
    max-width: 300px;
    text-align: center;
  }

  /* Features grid */
  .features-grid {
    grid-template-columns: 1fr;
  }

  /* Stats */
  .stats-grid {
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }

  /* ── Tool Layout ── */
  .tool-layout {
    height: auto;
    min-height: unset;
    gap: 0.75rem;
    padding: 0 0.5rem;
  }

  /* Both panels height auto, no fixed sizes */
  .tool-panel {
    height: auto;
    min-height: unset;
    flex: unset;
  }

  /* Input panel: mode indicator + header + drop + code + run btn */
  .tool-panel:first-child {
    display: flex;
    flex-direction: column;
  }

  /* Mode indicator compact */
  #mode-indicator {
    font-size: 0.65rem !important;
    padding: 0.4rem 0.75rem !important;
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  #mode-indicator span:last-child {
    display: none; /* hide "via features menu to switch" on mobile */
  }

  /* Panel header — one row, compact */
  .panel-header {
    padding: 0.5rem 0.75rem;
    flex-wrap: nowrap;
    gap: 0.4rem;
    align-items: center;
  }
  .panel-header select,
  #language-select {
    font-size: 0.7rem;
    padding: 0.3rem 0.4rem;
    max-width: 85px;
    flex-shrink: 0;
  }
  .panel-actions {
    flex-wrap: nowrap;
    gap: 0.35rem;
    flex: 1;
    justify-content: flex-end;
  }
  .panel-actions button {
    font-size: 0.65rem !important;
    padding: 0.3rem 0.45rem !important;
    white-space: nowrap;
  }

  /* Compact drop zone — one line, no icon, no hint */
  .drop-zone {
    padding: 0.5rem 0.75rem !important;
    flex-direction: row !important;
    gap: 0.4rem !important;
    justify-content: flex-start !important;
    min-height: unset !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }
  .drop-zone svg {
    display: none !important;
  }
  .drop-zone-hint {
    display: none !important;
  }
  .drop-zone span:first-of-type {
    font-size: 0.72rem;
  }

  /* Code area — natural height based on content, min enough to see code */
  .code-area {
    min-height: 240px;
    max-height: 45vh;
    overflow-y: auto;
  }

  /* Run button — always visible, never hidden */
  #run-btn {
    font-size: 0.85rem !important;
    padding: 0.85rem !important;
    width: 100%;
    flex-shrink: 0;
  }
  /* The div wrapping run btn */
  #run-btn + div,
  .tool-panel:first-child > div:last-of-type {
    flex-shrink: 0;
  }

  /* Output panel header — wrap gracefully */
  .tool-panel:last-child .panel-header {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
  }
  .tool-panel:last-child .panel-header h3,
  #output-title {
    font-size: 0.85rem !important;
    flex-shrink: 0;
    min-width: 0;
  }
  /* Action buttons row — wraps below title if needed */
  .tool-panel:last-child .panel-header > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
  }
  .output-action-btn {
    font-size: 0.65rem !important;
    padding: 0.25rem 0.5rem !important;
    white-space: nowrap;
  }
  /* History button in output header */
  .tool-panel:last-child .panel-header button:not(.output-action-btn) {
    font-size: 0.65rem !important;
    padding: 0.25rem 0.5rem !important;
  }

  /* Output content min height */
  .output-content {
    min-height: 300px;
  }

  /* History page */
  .history-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  .history-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .history-filter-bar {
    flex-direction: column;
    gap: 0.75rem;
  }
  .history-cards-grid {
    grid-template-columns: 1fr;
  }

  /* About page */
  .team-grid {
    grid-template-columns: 1fr;
  }
  .about-hero h1 {
    font-size: 1.6rem;
  }

  /* How it works */
  .timeline {
    padding-left: 1rem;
  }
  .how-grid,
  .steps-grid {
    grid-template-columns: 1fr;
  }

  /* Buttons */
  .btn {
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
  }

  /* Cards */
  .card {
    padding: 1.5rem;
  }

  /* Auth page */
  .auth-box {
    padding: 1.5rem !important;
  }

  /* Mega menu items on mobile */
  .mega-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }
  .mega-title {
    font-size: 0.8rem;
  }
  .mega-desc {
    font-size: 0.7rem;
  }

  /* Score section in results */
  .score-section {
    flex-direction: column;
    gap: 0.75rem;
  }

  /* Bug cards readable on mobile */
  .bug-card {
    padding: 0.75rem !important;
  }
  .bug-desc {
    font-size: 0.8rem !important;
  }
}

/* Extra small phones */
@media (max-width: 400px) {
  .glitch {
    font-size: 2.2rem;
  }
  .history-stats {
    grid-template-columns: 1fr;
  }
  .panel-actions button {
    font-size: 0.6rem !important;
    padding: 0.25rem 0.35rem !important;
  }
  .code-area {
    min-height: 200px;
    max-height: 38vh;
  }
}