:root {
  --bg:        #0a0a0f;
  --bg2:       #0f0f18;
  --surface:   #13131f;
  --surface2:  #1a1a2e;
  --border:    rgba(255,255,255,0.06);
  --border2:   rgba(255,255,255,0.12);
  --red:       #c8102e;
  --red2:      #e8183a;
  --red-glow:  rgba(200,16,46,0.18);
  --text:      #f0f0f5;
  --muted:     #6b7280;
  --muted2:    #9ca3af;
  --accent:    #00d4ff;
  --green:     #22c55e;
  --yellow:    #f59e0b;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'DM Sans', sans-serif;
  --display:   'Bebas Neue', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── ANIMATED BG ── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(200,16,46,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200,16,46,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}
.bg-blob1 {
  position: fixed;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,16,46,0.08) 0%, transparent 70%);
  top: -200px; right: -150px;
  pointer-events: none;
  z-index: 0;
  animation: float1 8s ease-in-out infinite;
}
.bg-blob2 {
  position: fixed;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,212,255,0.05) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
  z-index: 0;
  animation: float2 10s ease-in-out infinite;
}
@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-30px,40px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(20px,-30px)} }

/* ── LAYOUT ── */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 40px 0 48px;
  gap: 28px;
}

/* LEFT: logo */
.logo-wrap {
  position: relative;
  flex-shrink: 0;
}
.logo-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  filter: drop-shadow(0 0 18px rgba(200,16,46,0.35));
  animation: logo-pulse 3s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%,100% { filter: drop-shadow(0 0 14px rgba(200,16,46,0.3)); }
  50%      { filter: drop-shadow(0 0 30px rgba(200,16,46,0.55)); }
}
.logo-svg { width: 72px; height: 72px; }
.logo-badge {
  position: absolute;
  top: -7px; right: -7px;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.48rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

/* CENTER: branding */
.header-brand {
  flex: 1;
}
.site-title {
  font-family: var(--display);
  font-size: clamp(2.6rem, 5vw, 4rem);
  letter-spacing: 0.06em;
  line-height: 0.95;
  color: var(--text);
  margin-bottom: 4px;
}
.site-title span { color: var(--red2); }

.site-tagline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.site-tagline-text {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.site-tagline-sep {
  width: 1px; height: 12px;
  background: var(--border2);
}
.site-tagline-uni {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--red);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* RIGHT: stats */
.header-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
  flex-shrink: 0;
}
.hstat {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 4px 11px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted2);
  white-space: nowrap;
}
.hstat strong { color: var(--text); }

/* ── SECTION TITLE ── */
.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.section-label::before,
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── EXAM GRID ── */
.exams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

/* ── EXAM CARD ── */
.exam-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  display: block;
  animation: card-in 0.4s ease both;
}
.exam-card:nth-child(1) { animation-delay: 0.05s; }
.exam-card:nth-child(2) { animation-delay: 0.10s; }
.exam-card:nth-child(3) { animation-delay: 0.15s; }
.exam-card:nth-child(4) { animation-delay: 0.20s; }
.exam-card:nth-child(5) { animation-delay: 0.25s; }
.exam-card:nth-child(6) { animation-delay: 0.30s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.exam-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,0.03), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.exam-card:hover {
  border-color: var(--border2);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
}
.exam-card:hover::before { opacity: 1; }

/* Color accent per ogni card */
.exam-card[data-color="red"]:hover    { box-shadow: 0 12px 40px rgba(200,16,46,0.2), 0 0 0 1px rgba(200,16,46,0.25); border-color: rgba(200,16,46,0.4); }
.exam-card[data-color="cyan"]:hover   { box-shadow: 0 12px 40px rgba(0,212,255,0.15), 0 0 0 1px rgba(0,212,255,0.25); border-color: rgba(0,212,255,0.3); }
.exam-card[data-color="purple"]:hover { box-shadow: 0 12px 40px rgba(168,85,247,0.2), 0 0 0 1px rgba(168,85,247,0.25); border-color: rgba(168,85,247,0.35); }
.exam-card[data-color="green"]:hover  { box-shadow: 0 12px 40px rgba(34,197,94,0.15), 0 0 0 1px rgba(34,197,94,0.25); border-color: rgba(34,197,94,0.3); }
.exam-card[data-color="orange"]:hover { box-shadow: 0 12px 40px rgba(245,158,11,0.15), 0 0 0 1px rgba(245,158,11,0.25); border-color: rgba(245,158,11,0.3); }

.card-icon {
  font-size: 2rem;
  margin-bottom: 14px;
  display: block;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-name {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  flex: 1;
  margin-right: 8px;
}

.card-status {
  flex-shrink: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 5px;
}
.card-status.ready  { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.card-status.wip    { background: var(--yellow); box-shadow: 0 0 8px rgba(245,158,11,0.5); }
.card-status.soon   { background: var(--muted); }

.card-code {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.meta-chip {
  font-family: var(--mono);
  font-size: 0.62rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--muted2);
}
.meta-chip.q   { color: var(--accent); border-color: rgba(0,212,255,0.2); background: rgba(0,212,255,0.05); }
.meta-chip.mod { color: #a78bfa; border-color: rgba(167,139,250,0.2); background: rgba(167,139,250,0.05); }
.meta-chip.ai  { color: #34d399; border-color: rgba(52,211,153,0.2); background: rgba(52,211,153,0.05); }

/* Progress bar inside card */
.card-progress {
  margin-top: 4px;
}
.card-prog-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  font-family: var(--mono);
  color: var(--muted);
  margin-bottom: 5px;
}
.card-prog-bar {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}
.card-prog-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

/* ── COMING SOON CARD ── */
.exam-card.coming-soon {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.coming-soon-overlay {
  position: absolute;
  top: 14px; right: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* ── CTA ARROW ── */
.card-arrow {
  position: absolute;
  bottom: 20px; right: 20px;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  transition: all 0.2s;
  color: var(--muted);
}
.exam-card:hover .card-arrow {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  transform: translate(2px, -2px);
}

/* ── INFO BAR ── */
.info-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 48px;
}
.info-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.info-icon { font-size: 1.4rem; flex-shrink: 0; }
.info-text { font-size: 0.78rem; line-height: 1.5; color: var(--muted2); }
.info-text strong { color: var(--text); display: block; margin-bottom: 1px; font-size: 0.82rem; }

/* ── FOOTER ── */
footer {
  text-align: center;
  padding: 32px 0 0;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
  letter-spacing: 0.05em;
}
footer span { color: var(--red2); }

/* ── RESPONSIVE ── */

/* Tablet (≤768px) */
@media (max-width: 768px) {
  header { padding: 28px 0 32px; gap: 16px; }
  .logo-img, .logo-svg { width: 58px; height: 58px; }
  .site-title { font-size: 2.6rem; }
  .header-stats { gap: 4px; }
  .hstat { font-size: 0.64rem; padding: 3px 8px; }
  .exams-grid { grid-template-columns: 1fr; gap: 12px; }
  .exam-card { padding: 20px; }
  .info-bar { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* Mobile (≤540px) — stack header vertically */
@media (max-width: 540px) {
  .wrap { padding: 0 14px 60px; }

  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 0 28px;
    gap: 14px;
  }

  .logo-wrap { display: flex; align-items: center; gap: 12px; }
  .logo-img, .logo-svg { width: 48px; height: 48px; }

  /* Logo + titolo sulla stessa riga su mobile */
  header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .header-brand { min-width: 0; }
  .site-title { font-size: 2rem; }
  .site-tagline-text { font-size: 0.6rem; }
  .site-tagline-uni { font-size: 0.56rem; }

  .header-stats {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 4px;
  }
  .hstat { font-size: 0.62rem; padding: 3px 8px; }

  .exams-grid { grid-template-columns: 1fr; gap: 10px; }
  .exam-card { padding: 16px 16px 46px; border-radius: 12px; }
  .card-icon { font-size: 1.5rem; margin-bottom: 8px; }
  .card-name { font-size: 0.9rem; }

  .info-bar { grid-template-columns: 1fr; gap: 8px; }
  .info-item { padding: 11px 13px; }

  footer { font-size: 0.64rem; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 99px; }


/* ══════════════════════════════════════════
   SYNC BAR
══════════════════════════════════════════ */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 9px 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 180px;
}
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #444;
  flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}
.sync-dot.ok   { background: #22c55e; box-shadow: 0 0 7px #22c55e99; }
.sync-dot.err  { background: #ef4444; box-shadow: 0 0 7px #ef444499; }
.sync-dot.busy { background: #f59e0b; box-shadow: 0 0 7px #f59e0b99;
                 animation: sdpulse 1s infinite; }
@keyframes sdpulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.sync-label { font-size: 13px; color: #999; }
.sync-time  { font-size: 11px; color: #555;
              font-family: 'JetBrains Mono', monospace; }
.sync-uuid  { font-size: 10px; color: #3a3a4a;
              font-family: 'JetBrains Mono', monospace;
              cursor: help; margin-left: auto; }
.sync-actions { display: flex; gap: 7px; align-items: center; }

.btn-sync {
  padding: 5px 13px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: #bbb; font-size: 12px;
  cursor: pointer; transition: all .2s;
  white-space: nowrap;
}
.btn-sync:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-sync:disabled { opacity: .4; cursor: default; }
.btn-sync.primary {
  border-color: rgba(0,212,255,0.3);
  background: rgba(0,212,255,0.08);
  color: #00d4ff;
}
.btn-sync.primary:hover { background: rgba(0,212,255,0.18); }

/* ══════════════════════════════════════════
   CARD — menu contestuale
══════════════════════════════════════════ */
.exam-card { position: relative; }

.card-menu-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: transparent;
  border: none;
  color: #555;
  font-size: 18px; line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
  z-index: 10;
  transition: color .2s, background .2s;
}
.exam-card:hover .card-menu-btn { color: #888; }
.card-menu-btn:hover { color: #ccc !important;
  background: rgba(255,255,255,0.08); }

.card-dropdown {
  position: absolute;
  top: 36px; right: 10px;
  background: #14141e;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 5px;
  z-index: 200;
  min-width: 210px;
  box-shadow: 0 10px 36px rgba(0,0,0,.6);
  display: none;
}
.card-dropdown.open { display: block; }

.dd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px; color: #bbb;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.dd-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.dd-item.success { color: #22c55e; }
.dd-item.success:hover { background: rgba(34,197,94,0.08); }
.dd-item.warning { color: #f59e0b; }
.dd-item.warning:hover { background: rgba(245,158,11,0.08); }

/* ══════════════════════════════════════════
   CARD ARCHIVIATA
══════════════════════════════════════════ */
.exam-card.archived {
  opacity: .42;
  filter: grayscale(.65);
  transition: opacity .25s, filter .25s;
}
.exam-card.archived:hover { opacity: .68; filter: grayscale(.3); }

.card-passed-badge {
  position: absolute;
  top: 11px; right: 38px;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.28);
  color: #22c55e;
  font-size: 10px; padding: 2px 9px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: .04em;
  pointer-events: none;
}

/* ══════════════════════════════════════════
   SEZIONE ARCHIVIATI
══════════════════════════════════════════ */
.archived-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 10px 2px;
  margin-top: 6px;
}
.archived-header:hover .arc-label { color: #999; }

.arc-label {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #555;
  transition: color .2s;
}
.arc-arrow {
  color: #444; font-size: 10px;
  transition: transform .25s;
}
.arc-arrow.open { transform: rotate(90deg); }

.arc-count {
  background: rgba(255,255,255,0.05);
  color: #555;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
}

#archived-grid {
  display: none;
  margin-top: 10px;
}
#archived-grid.open { display: grid; }

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.1);
  color: #ddd; font-size: 13px;
  padding: 10px 22px;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  z-index: 9999; pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); }