/* CUET Guide 2027 — data: cuet-guide-data.js (NTA / DU documents) and du-cutoffs-2026.js (DU's official minimum
   allocation scores). Live dates come from the self-updating exam page (/api/exam-info/cuet). */
const CG=window.CUET_GUIDE_DATA, DUC=window.DU_CUTOFFS_2026;
const cgS={
h2:{fontFamily:'var(--font-display)',fontWeight:800,fontSize:28,color:'var(--text-heading)',margin:'28px 0 8px'},
lede:{fontFamily:'var(--font-body)',fontSize:17,color:'var(--text-body)',lineHeight:1.6,margin:'0 0 14px',maxWidth:840},
panel:{background:'var(--white)',border:'1px solid var(--border-default)',borderRadius:'var(--radius-md)',padding:'18px 20px',margin:'14px 0',boxShadow:'var(--shadow-sm)'},
label:{fontFamily:'var(--font-body)',fontSize:13,fontWeight:700,color:'var(--text-muted)',letterSpacing:'.05em',textTransform:'uppercase'},
input:{background:'var(--white)',color:'var(--text-body)',border:'1px solid var(--border-default)',borderRadius:'var(--radius-sm)',padding:'11px 13px',fontSize:16,fontFamily:'var(--font-body)',width:150,maxWidth:'100%'},
select:{background:'var(--white)',color:'var(--text-body)',border:'1px solid var(--border-default)',borderRadius:'var(--radius-sm)',padding:'11px 13px',fontSize:16,fontFamily:'var(--font-body)',minWidth:160,maxWidth:'100%'},
hint:{fontFamily:'var(--font-body)',fontSize:14.5,color:'var(--text-muted)',marginTop:8,lineHeight:1.5},
callout:{background:'var(--white)',border:'1px solid var(--border-default)',borderLeft:'3px solid var(--brand-accent)',borderRadius:'var(--radius-sm)',padding:'16px 19px',fontFamily:'var(--font-body)',fontSize:16,color:'var(--text-body)',lineHeight:1.6,margin:'12px 0'},
th:{background:'var(--gray-50)',textAlign:'left',padding:'11px 14px',fontFamily:'var(--font-body)',fontSize:13.5,letterSpacing:'.03em',textTransform:'uppercase',color:'var(--text-muted)',whiteSpace:'nowrap'},
td:{padding:'10px 14px',borderTop:'1px solid var(--border-default)',fontFamily:'var(--font-body)',fontSize:16,color:'var(--text-body)'},
src:{fontFamily:'var(--font-body)',fontSize:13,color:'var(--text-muted)',marginTop:9,paddingTop:8,borderTop:'1px dashed var(--border-default)',lineHeight:1.55},
ok:{color:'var(--text-success,#0f7a6d)',fontWeight:700},a:{color:'var(--brand-primary)',fontWeight:600}};
function CgField({label,children}){return <div style={{display:'flex',flexDirection:'column',gap:4}}><label style={cgS.label}>{label}</label>{children}</div>;}
function CgTable({head,rows,rightFrom=99}){
return <div style={{border:'1px solid var(--border-default)',borderRadius:'var(--radius-md)',overflow:'auto',margin:'10px 0',background:'var(--white)'}}>
<table style={{borderCollapse:'collapse',width:'100%'}}>
<thead><tr>{head.map((h,i)=><th key={i} style={{...cgS.th,textAlign:i>=rightFrom?'right':'left'}}>{h}</th>)}</tr></thead>
<tbody>{rows.map((r,ri)=><tr key={ri}>{r.map((v,i)=><td key={i} style={{...cgS.td,textAlign:i>=rightFrom?'right':'left',fontWeight:i===0?700:400,fontVariantNumeric:'tabular-nums'}}>{v==null||v===''?'—':v}</td>)}</tr>)}</tbody>
</table></div>;}
/* "✓ Official · checked <date>" line with links to the documents used */
function CgSrc({docs,note}){return <div style={cgS.src}><span style={cgS.ok}>✓ Official source · checked {CG.meta.lastChecked}</span>{note?<span> · {note}</span>:null}
{docs.map(k=><span key={k}> · <a href={CG.docs[k].url} target="_blank" rel="noopener nofollow" style={cgS.a}>{CG.docs[k].name} ↗</a></span>)}</div>;}

/* live: next step, fee change and notices from the exam page (updated automatically from NTA / DU) */
let cgLiveP=null;
function CgLive(){const [d,setD]=React.useState(null);
React.useEffect(()=>{if(!cgLiveP)cgLiveP=fetch('/api/exam-info/cuet').then(r=>r.ok?r.json():null).catch(()=>null);cgLiveP.then(setD);},[]);
if(!d||!d.exams)return null;
return <div style={{...cgS.panel,background:'var(--gray-50)'}}>
{d.exams.map(e=><div key={e.key} style={{fontFamily:'var(--font-body)',fontSize:15,color:'var(--text-body)',margin:'4px 0',lineHeight:1.5}}><b>📅 {e.name}:</b> {e.next}
{(e.notices||[]).slice(0,1).map((n,i)=><div key={i}>📢 {n.text} <a href={n.url} target="_blank" rel="noopener nofollow" style={cgS.a}>official ↗</a></div>)}</div>)}
<div style={{fontFamily:'var(--font-body)',color:'var(--text-muted)',fontSize:13}}>Updated automatically from the NTA and DU websites (checked twice a day) · dates marked “expected” are based on 2026 until the official notice · <a href="/cuet-exam" style={cgS.a}>all dates &amp; FAQs →</a></div></div>;}

const RNDS=[['r1','Round I'],['r2','Round II'],['r3','Round III'],['spot','Spot round']];
const fmt=(v)=>v==null?null:Number(v).toFixed(2);
function CgCutoffs(){
const {Badge}=window.ScorebuddyDesignSystem_ee75f2;
const [prog,setProg]=React.useState(DUC.programmes.indexOf('B.Com. (Hons.)'));
const [col,setCol]=React.useState(-1);
const [cat,setCat]=React.useState(0);
const [rnd,setRnd]=React.useState(0);
const [score,setScore]=React.useState('');
const s=parseFloat(score);
const rows=DUC.rows.filter(r=>(prog<0||r[1]===prog)&&(col<0||r[0]===col));
const val=(r,k)=>{const x=r[2+k];return x&&x[cat]!=null?x[cat]:null;};
const sorted=rows.slice().sort((a,b)=>(val(b,rnd)??-1)-(val(a,rnd)??-1));
const shown=sorted.slice(0,150);
const chance=(v)=>{if(isNaN(s)||v==null)return null;return s>=v?<Badge tone="success">At or above</Badge>:s>=v-15?<Badge tone="neutral">Within 15</Badge>:<Badge tone="danger">Below</Badge>;};
const body=shown.map(r=>[prog<0?DUC.programmes[r[1]]:DUC.colleges[r[0]],...RNDS.map((x,k)=>{const v=val(r,k);return v==null?null:<span style={k===rnd?{fontWeight:800}:null}>{fmt(v)}</span>;}),...(isNaN(s)?[]:[chance(val(r,rnd))])]);
const nAbove=isNaN(s)?0:rows.filter(r=>{const v=val(r,rnd);return v!=null&&s>=v;}).length;
return <div id="cutoffs">
<h2 style={cgS.h2}>DU cutoff finder — <span style={{color:'var(--brand-accent)'}}>every 2026 round, by category</span></h2>
<p style={cgS.lede}>These are the <b>minimum allocation scores</b> the University of Delhi published for CSAS(UG)-2026: the lowest programme score that got a seat in each round. Pick a programme or a college, your category and a round; type your programme score to compare. Scores are on DU’s merit scale for that programme (for four papers, out of 1000).</p>
<div style={cgS.panel}>
<div style={{display:'flex',gap:10,flexWrap:'wrap',alignItems:'end'}}>
<CgField label="Programme"><select value={prog} onChange={e=>setProg(+e.target.value)} style={{...cgS.select,maxWidth:340}}><option value={-1}>All programmes</option>{DUC.programmes.map((p,i)=><option key={i} value={i}>{p}</option>)}</select></CgField>
<CgField label="College"><select value={col} onChange={e=>setCol(+e.target.value)} style={{...cgS.select,maxWidth:300}}><option value={-1}>All colleges</option>{DUC.colleges.map((c,i)=><option key={i} value={i}>{c}</option>)}</select></CgField>
<CgField label="Category"><select value={cat} onChange={e=>setCat(+e.target.value)} style={cgS.select}>{DUC.cats.map((c,i)=><option key={i} value={i}>{c}</option>)}</select></CgField>
<CgField label="Sort by round"><select value={rnd} onChange={e=>setRnd(+e.target.value)} style={cgS.select}>{RNDS.map((r,i)=><option key={i} value={i}>{r[1]}</option>)}</select></CgField>
<CgField label="Your score"><input type="number" value={score} onChange={e=>setScore(e.target.value)} placeholder="e.g. 850" style={cgS.input}></input></CgField>
</div>
{!isNaN(s)&&rows.length?<p style={{...cgS.hint,color:'var(--text-body)',fontSize:16}}>Your score is at or above the {RNDS[rnd][1]} {DUC.cats[cat]} minimum for <b>{nAbove}</b> of {rows.length} listed {prog<0?'programmes':'colleges'}.</p>:null}
{rows.length?<CgTable head={[prog<0?'Programme':'College',...RNDS.map(r=>r[1]),...(isNaN(s)?[]:['You vs '+RNDS[rnd][1]])]} rows={body} rightFrom={1}></CgTable>
:<p style={cgS.hint}>No published score for this choice in our table — see DU’s PDFs below (they list every programme, including B.A./B.Sc. Programme combinations).</p>}
{sorted.length>shown.length?<p style={cgS.hint}>Showing the top {shown.length} of {sorted.length}; choose a programme or college to narrow the list.</p>:null}
<p style={cgS.hint}>“—” = DU published no score for that round and category (no seat left, or no allocation in that round). A later round can be lower <i>or</i> higher. The spot round is separate: its scores come only from candidates who applied to it. Your programme score is worked out by DU from your normalised CUET scores in the programme’s subject combination.</p>
<CgSrc docs={['R1','R2','R3','SP']} note={DUC.rows.length+' college–programme rows · Honours programmes, B.Com., BMS and BBA (FIA) · each score matched to its own line in DU’s PDFs; rows that could not be matched exactly were left out'}></CgSrc>
</div></div>;}

function CgCombos(){
return <div id="combos">
<h2 style={cgS.h2}>Which CUET subjects <span style={{color:'var(--brand-accent)'}}>each DU programme needs</span></h2>
<p style={cgS.lede}>DU counts only the subject combination a programme asks for. Where there are several, your <b>best</b> combination is used. You must also take CUET in the subjects you studied in Class 12 (if a Class 12 subject isn’t in CUET, take the closest one — e.g. Biology for Biochemistry).</p>
<CgTable head={['Programme','Stream','Accepted CUET combinations']} rows={CG.combos.map(([p,g,c])=>[p,g,<div>{c.map((x,i)=><div key={i}>{c.length>1&&!/^\(/.test(x)?'Option '+(i+1)+': ':''}{x}</div>)}</div>])}></CgTable>
<div style={cgS.callout}><b>Reading the table.</b> L = a language from List A (13 languages); “subject” = a domain subject from List B. “Prorated” means DU scales the scores because the papers don’t carry the same weight. For B.Sc. programmes, B.A./B.Sc. Programme combinations and other courses, read the programme’s page in the Bulletin — the layout of some pages makes them easy to misread, so we have left those out here rather than risk a mistake.</div>
<CgSrc docs={['BOI']}></CgSrc></div>;}

function CgExam(){
return <div>
<h2 style={cgS.h2}>CUET (UG): <span style={{color:'var(--brand-accent)'}}>pattern, subjects &amp; fees</span></h2>
<CgLive></CgLive>
<CgTable head={['','CUET (UG) — as in the 2026 bulletin']} rows={CG.pattern}></CgTable>
<h2 style={{...cgS.h2,fontSize:22}}>Application fee</h2>
<CgTable head={['Category','Up to 3 subjects','Each extra subject']} rows={CG.fees} rightFrom={1}></CgTable>
<h2 style={{...cgS.h2,fontSize:22}}>The 37 subjects</h2>
<div style={cgS.panel}><p style={{...cgS.lede,margin:'0 0 8px'}}><b>Languages (13):</b> {CG.languages.join(', ')}.</p>
<p style={{...cgS.lede,margin:'0 0 8px'}}><b>Domain-specific subjects (23):</b> {CG.domains.join(', ')}.</p>
<p style={{...cgS.lede,margin:0}}><b>General Aptitude Test:</b> {CG.gat}</p></div>
<div style={cgS.callout}><b>Normalisation in one line.</b> When a subject is held in several shifts, NTA turns raw marks into percentiles within each shift, then maps them across shifts with the equi-percentile method — so a hard shift doesn’t cost you. Universities use these normalised scores.</div>
<CgSrc docs={['NTA']}></CgSrc></div>;}

function CgCsas(){
return <div>
<h2 style={cgS.h2}>Getting into DU: <span style={{color:'var(--brand-accent)'}}>CSAS (UG), step by step</span></h2>
<p style={cgS.lede}>CUET gives you scores; Delhi University’s Common Seat Allocation System turns them into seats. Applying to DU is a separate step on its own portal.</p>
<CgTable head={['Step','What happens']} rows={CG.csasSteps}></CgTable>
<div style={{display:'flex',gap:16,flexWrap:'wrap'}}>
<div style={{flex:'1 1 300px'}}><h2 style={{...cgS.h2,fontSize:22}}>CSAS fees (non-refundable)</h2><CgTable head={['Item','Fee']} rows={CG.csasFees} rightFrom={1}></CgTable></div>
<div style={{flex:'1 1 260px'}}><h2 style={{...cgS.h2,fontSize:22}}>Reserved seats</h2><CgTable head={['Category','Share of seats']} rows={CG.reservation} rightFrom={1}></CgTable>
<p style={cgS.hint}>Plus PwBD and supernumerary seats (CW, Orphans, Single Girl Child, Kashmiri Migrants, ECA, Sports, Ward). The UR merit list includes everyone on merit, whatever their category.</p></div></div>
<h2 style={{...cgS.h2,fontSize:22}}>If two candidates have the same score</h2>
<ol style={{...cgS.lede,paddingLeft:22}}>{CG.tie.map((t,i)=><li key={i}>{t}</li>)}</ol>
<div style={cgS.callout}><b>The two rules that cost students seats most often:</b> not clicking “Accept” before the round’s deadline (you are out of the later regular rounds), and pressing “Freeze” too early (no more upgrades). Check your dashboard in every round.</div>
<CgSrc docs={['CSAS','BOI']}></CgSrc></div>;}

function CgUnis(){
const r=CG.reported;
return <div>
<h2 style={cgS.h2}>Universities that <span style={{color:'var(--brand-accent)'}}>accept CUET (UG)</span></h2>
<CgTable head={['Type (NTA’s 2026 list)','Universities']} rows={CG.universities.concat([['Total in these four groups',CG.universities.reduce((a,b)=>a+b[1],0)]])} rightFrom={1}></CgTable>
<p style={cgS.hint}>NTA’s list also has “other government institutions”, not counted above. Each university runs its own admission after the result — check its website for programmes, combinations and dates.</p>
<CgSrc docs={['NTAU']}></CgSrc>
<h2 style={{...cgS.h2,fontSize:22}}>CUET (UG) 2026 in numbers</h2>
<CgTable head={['','2026']} rows={[['Registered',r.registered],['Appeared',r.appeared],['Result declared',r.result]]} rightFrom={1}></CgTable>
<p style={cgS.hint}>As reported in the news, citing NTA — not taken from an NTA document.</p></div>;}

function CgSources(){const m=CG.meta;
return <div id="sources" style={{fontFamily:'var(--font-body)',fontSize:14.5,color:'var(--text-body)',marginTop:40,paddingTop:18,borderTop:'1px solid var(--border-default)',lineHeight:1.65}}>
<h2 style={{...cgS.h2,fontSize:22,margin:'0 0 8px'}}>Sources, method &amp; disclaimer</h2>
<p style={{margin:'0 0 10px'}}><b>How this guide was made.</b> The Scorebuddy team compiled it in {m.compiled} from official documents only: the NTA CUET (UG)-2026 Information Bulletin and website, and the University of Delhi’s Bulletin of Information (UG) 2026-27, CSAS(UG)-2026 document and minimum allocation score lists. Text was extracted from the PDFs by software and each figure was matched back to the official text; anything we could not match exactly was left out. The only figures not from an official document are the 2026 candidate numbers and result date, which are labelled “as reported”. Last checked: {m.lastChecked}. The 📅 live box updates automatically from the NTA and DU websites.</p>
<p style={{margin:'0 0 6px'}}><b>Official documents used</b></p>
<ul style={{margin:'0 0 10px',paddingLeft:20}}>{Object.values(CG.docs).map(d=><li key={d.url}><a href={d.url} target="_blank" rel="noopener nofollow" style={cgS.a}>{d.name} ↗</a></li>)}</ul>
<p style={{margin:'0 0 10px'}}><b>Not official, not affiliated.</b> Scorebuddy is an independent test-preparation platform. It is not affiliated with, endorsed by or connected to the National Testing Agency, the Ministry of Education, the University of Delhi or any university named here. Their names belong to them and are used only to identify them. <b>The official documents are the only authority</b>: if anything here differs from them, they are right.</p>
<p style={{margin:'0 0 10px'}}><b>No guarantee.</b> Cutoffs change every year and every round; a 2026 score is not a promise for 2027. This guide is for planning only — not admissions advice — and meeting a past minimum score does not guarantee a seat. Always confirm on cuet.nta.nic.in and admission.uod.ac.in before applying or deciding.</p>
<p style={{margin:0}}><b>Found an error?</b> Write to <a href={'mailto:'+m.contact+'?subject=CUET%20Guide%20correction'} style={cgS.a}>{m.contact}</a> with the official link and we will correct it.</p>
</div>;}

function CuetGuidePage(){
const {Badge,Tag}=window.ScorebuddyDesignSystem_ee75f2;
const TABS=[['cutoffs','DU cutoff finder'],['combos','Subjects per programme'],['exam','Pattern, subjects & fees'],['csas','DU admission (CSAS)'],['unis','Universities']];
const start=(location.hash||'').slice(1);
const [tab,setTab]=React.useState(TABS.some(t=>t[0]===start)?start:'cutoffs');
return <div>
<section style={{padding:'56px 20px 8px',maxWidth:1180,margin:'0 auto'}}>
<Badge tone="brand">2027 CYCLE · CUET (UG) · DELHI UNIVERSITY</Badge>
<h1 style={{fontFamily:'var(--font-display)',fontWeight:800,fontSize:'clamp(32px,6vw,48px)',color:'var(--text-heading)',margin:'16px 0 12px'}}>CUET <span style={{color:'var(--brand-accent)'}}>Guide 2027</span></h1>
<p style={{fontFamily:'var(--font-body)',fontSize:18.5,color:'var(--text-body)',lineHeight:1.6,maxWidth:800,margin:0}}>Every 2026 Delhi University cutoff — all rounds, all categories — the CUET subjects each programme needs, the exam pattern and fees, and how DU’s seat allocation works. Built from NTA and DU documents.</p>
<p style={{fontFamily:'var(--font-body)',fontSize:14,color:'var(--text-muted)',lineHeight:1.55,maxWidth:820,margin:'12px 0 0'}}>Compiled by Scorebuddy from official documents · not an official publication of NTA or DU · last checked {CG.meta.lastChecked} · <a href="#sources" onClick={e=>{e.preventDefault();const s=document.getElementById('sources');if(s)s.scrollIntoView({behavior:'smooth'});}} style={cgS.a}>sources &amp; disclaimer</a> · <a href="/cuet-exam" style={cgS.a}>exam dates &amp; FAQs →</a></p>
</section>
<section style={{padding:'20px 20px 60px',maxWidth:1180,margin:'0 auto'}}>
<div style={{display:'flex',gap:8,flexWrap:'wrap',borderBottom:'1px solid var(--border-default)',paddingBottom:14,position:'sticky',top:73,background:'var(--color-bg-page)',zIndex:5,paddingTop:6}}>
{TABS.map(([id,l])=><Tag key={id} active={tab===id} onClick={()=>{setTab(id);try{history.replaceState(null,'','#'+id);}catch(e){}scrollTo(0,0);}}>{l}</Tag>)}
</div>
{tab==='cutoffs'&&<CgCutoffs></CgCutoffs>}
{tab==='combos'&&<CgCombos></CgCombos>}
{tab==='exam'&&<CgExam></CgExam>}
{tab==='csas'&&<CgCsas></CgCsas>}
{tab==='unis'&&<CgUnis></CgUnis>}
<div style={{...cgS.callout,marginTop:28}}><b>Practise for CUET:</b> <a href="/cuet.html?view=full" style={cgS.a}>free CUET mock tests</a> on the real exam screen · <a href="/cuet-previous-year-papers.html" style={cgS.a}>previous year papers since 2022</a> · <a href="/cuet-exam" style={cgS.a}>exam dates, countdowns &amp; FAQs</a></div>
<CgSources></CgSources>
</section></div>;}
window.CuetGuidePage=CuetGuidePage;
