:root{
  --bg: #0a0b0d;
  --bg-elev-1: #131417;
  --bg-elev-2: #1a1c20;
  --bg-elev-3: #222429;
  --border: #2a2d33;
  --border-soft: #1f2226;
  --text: #eef0f3;
  --text-dim: #9aa0aa;
  --text-faint: #656b76;
  --accent: #e0333f;
  --accent-hover: #f04452;
  --accent-dim: #7a1a22;
  --accent-glow: rgba(224,51,63,0.35);
  --green: #34c77b;
  --amber: #e0a733;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow: 0 8px 30px rgba(0,0,0,0.45);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html,body{
  height:100%;
  background: radial-gradient(1200px 800px at 80% -10%, rgba(224,51,63,0.08), transparent 60%),
              radial-gradient(900px 700px at -10% 110%, rgba(224,51,63,0.05), transparent 60%),
              var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#app{ min-height:100vh; display:flex; flex-direction:column; }

.hidden{ display:none !important; }

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

/* ---------- buttons ---------- */
.btn{
  font-family: var(--font);
  font-weight:600;
  font-size:0.9rem;
  padding:0.7rem 1.3rem;
  border-radius: var(--radius-sm);
  border:1px solid var(--border);
  cursor:pointer;
  transition: all .15s ease;
  background: var(--bg-elev-2);
  color: var(--text);
}
.btn:hover{ border-color: var(--text-faint); transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }
.btn:disabled{ opacity:0.35; cursor:not-allowed; transform:none; }

.btn-primary{
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  border-color: var(--accent);
  color:#fff;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover{ background: linear-gradient(180deg, #ff5561, var(--accent-hover)); }

.btn-secondary{ background: var(--bg-elev-3); }
.btn-ghost{ background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover{ color: var(--text); background: var(--bg-elev-2); }

/* ---------- screens ---------- */
.screen{ display:none; flex:1; flex-direction:column; }
.screen.active{ display:flex; }

/* ---------- topbar / home ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:1.2rem 2.5rem;
  border-bottom:1px solid var(--border-soft);
}
.brand{ display:flex; align-items:center; gap:0.6rem; }
.brand-mark{
  background: linear-gradient(145deg, var(--accent-hover), var(--accent-dim));
  color:#fff; font-weight:800; font-size:0.85rem;
  width:34px; height:34px; border-radius:9px;
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.brand-name{ font-weight:700; font-size:1.15rem; letter-spacing:-0.02em; }
.topbar-stats{ color: var(--text-dim); font-size:0.85rem; font-family: var(--mono); }

.home-main{
  flex:1; display:flex; flex-direction:column; align-items:center;
  padding:3.5rem 2rem 2rem; gap:2.5rem; max-width:1080px; margin:0 auto; width:100%;
}
.hero{ text-align:center; max-width:680px; }
.hero h1{ font-size:2.4rem; font-weight:800; letter-spacing:-0.03em; line-height:1.15; }
.subtitle{ color: var(--text-dim); margin-top:0.8rem; font-size:1.02rem; }

.mode-grid{
  display:grid; grid-template-columns: repeat(2, minmax(260px,1fr));
  gap:1.1rem; width:100%;
}
.mode-card{
  text-align:left; background: var(--bg-elev-1); border:1px solid var(--border);
  border-radius: var(--radius-md); padding:1.5rem; cursor:pointer;
  color:var(--text); font-family:var(--font); transition: all .18s ease;
  position:relative; overflow:hidden;
}
.mode-card::before{
  content:''; position:absolute; inset:0; opacity:0; transition:opacity .18s ease;
  background: linear-gradient(135deg, rgba(224,51,63,0.10), transparent 60%);
}
.mode-card:hover{ border-color: var(--accent-dim); transform: translateY(-3px); box-shadow: var(--shadow); }
.mode-card:hover::before{ opacity:1; }
.mode-icon{ font-size:1.6rem; margin-bottom:0.6rem; }
.mode-card h3{ font-size:1.08rem; font-weight:700; margin-bottom:0.4rem; }
.mode-card p{ color: var(--text-dim); font-size:0.87rem; line-height:1.4; }
.mode-tag{
  display:inline-block; margin-top:0.9rem; font-size:0.72rem; font-weight:700;
  text-transform:uppercase; letter-spacing:0.04em; color: var(--accent);
  background: rgba(224,51,63,0.12); padding:0.25rem 0.6rem; border-radius:6px;
}

.domain-picker{
  width:100%; background: var(--bg-elev-1); border:1px solid var(--border);
  border-radius: var(--radius-md); padding:1.5rem;
}
.domain-picker h4{ margin-bottom:1rem; font-size:1rem; }
.domain-checks{ display:grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap:0.6rem; margin-bottom:1.2rem; }
.domain-check{
  display:flex; align-items:center; gap:0.6rem; background: var(--bg-elev-2);
  border:1px solid var(--border); border-radius: var(--radius-sm); padding:0.7rem 0.9rem;
  font-size:0.85rem; cursor:pointer;
}
.domain-check input{ accent-color: var(--accent); width:16px; height:16px; }
.picker-actions{ display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; }
.quick-btn-row{ display:flex; gap:0.7rem; flex-wrap:wrap; }
.quick-len-btn{ flex:1; min-width:120px; }
.quick-len-btn:hover{ border-color: var(--accent-dim); color: var(--accent); }
.count-label{ color: var(--text-dim); font-size:0.87rem; display:flex; align-items:center; gap:0.5rem; }
.count-label input{
  width:80px; background: var(--bg-elev-3); border:1px solid var(--border);
  color:var(--text); border-radius:6px; padding:0.4rem 0.6rem; font-family:var(--mono);
}

.home-footer{ text-align:center; padding:1.5rem; color: var(--text-faint); font-size:0.8rem; }

/* ---------- exam screen ---------- */
.exam-topbar{
  display:flex; align-items:center; gap:1.5rem; padding:1rem 2rem;
  border-bottom:1px solid var(--border-soft); background: var(--bg-elev-1);
}
.exam-progress-wrap{ flex:1; }
.exam-progress-bar{ height:6px; background: var(--bg-elev-3); border-radius:99px; overflow:hidden; }
.exam-progress-fill{ height:100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); width:0%; transition: width .25s ease; }
#exam-progress-label{ font-size:0.78rem; color: var(--text-dim); margin-top:0.4rem; display:inline-block; font-family: var(--mono); }
.exam-timer{
  font-family: var(--mono); font-weight:700; font-size:1.1rem; padding:0.4rem 0.9rem;
  background: var(--bg-elev-3); border-radius:8px; border:1px solid var(--border); min-width:80px; text-align:center;
}
.exam-timer.low{ color: var(--accent); border-color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse{ 50%{ opacity:0.55; } }

.exam-main{ flex:1; padding:2rem; max-width:900px; margin:0 auto; width:100%; display:flex; flex-direction:column; gap:1.5rem; }
.question-card{
  background: var(--bg-elev-1); border:1px solid var(--border); border-radius: var(--radius-lg);
  padding:2rem; box-shadow: var(--shadow);
}
.question-meta{ display:flex; align-items:center; justify-content:space-between; margin-bottom:1.2rem; }
.domain-badge{
  font-size:0.72rem; font-weight:700; text-transform:uppercase; letter-spacing:0.04em;
  color: var(--accent); background: rgba(224,51,63,0.12); padding:0.3rem 0.7rem; border-radius:6px;
}
.flag-btn{
  background:none; border:1px solid var(--border); color: var(--text-dim); font-size:0.8rem;
  padding:0.35rem 0.7rem; border-radius:6px; cursor:pointer; transition: all .15s ease;
}
.flag-btn.active{ background: rgba(224,51,63,0.15); border-color: var(--accent); color: var(--accent); }

.question-text{ font-size:1.28rem; font-weight:600; line-height:1.5; margin-bottom:1.6rem; }

.options-list{ display:flex; flex-direction:column; gap:0.7rem; }
.option{
  display:flex; align-items:center; gap:0.9rem; padding:0.9rem 1.1rem;
  background: var(--bg-elev-2); border:1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor:pointer; transition: all .12s ease; font-size:0.95rem;
}
.option:hover{ border-color: var(--text-faint); background: var(--bg-elev-3); }
.option.selected{ border-color: var(--accent); background: rgba(224,51,63,0.08); }
.option .opt-letter{
  width:26px; height:26px; border-radius:7px; background: var(--bg-elev-3); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center; font-size:0.78rem; font-weight:700; color: var(--text-dim);
  flex-shrink:0;
}
.option.selected .opt-letter{ background: var(--accent); border-color: var(--accent); color:#fff; }

.option.correct{ border-color: var(--green); background: rgba(52,199,123,0.09); }
.option.correct .opt-letter{ background: var(--green); border-color: var(--green); color:#0a0b0d; }
.option.incorrect{ border-color: var(--accent); background: rgba(224,51,63,0.09); }
.option.incorrect .opt-letter{ background: var(--accent); border-color: var(--accent); color:#fff; }
.option.disabled{ cursor:default; }

.explanation-box{
  margin-top:1.2rem; padding:1rem 1.2rem; background: var(--bg-elev-2);
  border-left:3px solid var(--accent); border-radius:0 8px 8px 0; font-size:0.87rem; color: var(--text-dim); line-height:1.5;
}
.explanation-box strong{ color: var(--text); }

.qnav-strip{ display:flex; flex-wrap:wrap; gap:0.4rem; }
.qnav-dot{
  width:30px; height:30px; border-radius:7px; background: var(--bg-elev-2); border:1px solid var(--border);
  font-size:0.7rem; font-family:var(--mono); color: var(--text-faint); display:flex; align-items:center; justify-content:center;
  cursor:pointer;
}
.qnav-dot.current{ border-color: var(--accent); color: var(--text); }
.qnav-dot.answered{ background: var(--bg-elev-3); color: var(--text-dim); }
.qnav-dot.flagged{ box-shadow: inset 0 -3px 0 var(--amber); }

.exam-footer{
  display:flex; gap:0.8rem; justify-content:flex-end; padding:1.2rem 2rem;
  border-top:1px solid var(--border-soft); background: var(--bg-elev-1);
}

/* ---------- results ---------- */
.results-main{ flex:1; max-width:820px; margin:0 auto; width:100%; padding:3rem 2rem; }
.results-header{ text-align:center; margin-bottom:2.5rem; }
.results-header h1{ font-size:1.8rem; font-weight:800; margin-bottom:1.5rem; }

.score-ring-wrap{ position:relative; width:200px; height:200px; margin:0 auto; }
.score-ring{ width:100%; height:100%; transform: rotate(-90deg); }
.score-ring-bg{ fill:none; stroke: var(--bg-elev-3); stroke-width:12; }
.score-ring-fill{ fill:none; stroke: var(--accent); stroke-width:12; stroke-linecap:round; stroke-dasharray:553; stroke-dashoffset:553; transition: stroke-dashoffset 1s ease, stroke .3s ease; }
.score-ring-text{
  position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center;
}
#score-percent{ font-size:2.4rem; font-weight:800; font-family: var(--mono); }
.score-verdict{ font-size:0.85rem; font-weight:700; text-transform:uppercase; letter-spacing:0.05em; margin-top:0.2rem; }
.score-verdict.pass{ color: var(--green); }
.score-verdict.fail{ color: var(--accent); }
.score-summary-text{ color: var(--text-dim); margin-top:1.2rem; font-size:0.95rem; }

.domain-breakdown{
  background: var(--bg-elev-1); border:1px solid var(--border); border-radius: var(--radius-md);
  padding:1.5rem; margin-bottom:1.5rem;
}
.domain-breakdown h3{ margin-bottom:1rem; font-size:1rem; }
.domain-bar-row{ margin-bottom:0.9rem; }
.domain-bar-row:last-child{ margin-bottom:0; }
.domain-bar-label{ display:flex; justify-content:space-between; font-size:0.82rem; color: var(--text-dim); margin-bottom:0.35rem; }
.domain-bar-track{ height:8px; background: var(--bg-elev-3); border-radius:99px; overflow:hidden; }
.domain-bar-fill{ height:100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); border-radius:99px; }

.results-actions{ display:flex; gap:0.8rem; justify-content:center; flex-wrap:wrap; margin-bottom:1.5rem; }

.review-panel{ display:flex; flex-direction:column; gap:1rem; }
.review-item{
  background: var(--bg-elev-1); border:1px solid var(--border); border-radius: var(--radius-md); padding:1.3rem;
}
.review-item-q{ font-weight:600; margin-bottom:0.8rem; }
.review-item .options-list{ gap:0.5rem; }
.review-item .option{ padding:0.6rem 0.9rem; font-size:0.87rem; cursor:default; }

@media (max-width: 720px){
  .mode-grid{ grid-template-columns: 1fr; }
  .hero h1{ font-size:1.7rem; }
  .exam-footer{ flex-wrap:wrap; }
  .topbar{ padding:1rem 1.2rem; }
}
