// Mock fixtures for three verdict scenarios.
// Exposed on window for cross-script access.

const LAYER_META = [
  { key: 'l1_perplexity',    name: 'Perplexity',     short: 'L1',  weight: 0.18 },
  { key: 'l2_burstiness',    name: 'Burstiness',     short: 'L2',  weight: 0.13 },
  { key: 'l3_stylometrics',  name: 'Stylometrics',   short: 'L3',  weight: 0.14 },
  { key: 'l4_semantic',      name: 'Semantic',       short: 'L4',  weight: 0.10 },
  { key: 'l5_unicode',       name: 'Unicode',        short: 'L5',  weight: 0.07 },
  { key: 'l6_metadata',      name: 'Metadata',       short: 'L6',  weight: 0.08 },
  { key: 'l7_fonts',         name: 'Fonts',          short: 'L7',  weight: 0.05 },
  { key: 'l8_ensemble',      name: 'Ensemble',       short: 'L8',  weight: 0.15 },
  { key: 'l9_hallucination', name: 'Hallucination',  short: 'L9',  weight: 0.05 },
  { key: 'l10_revisions',    name: 'Revisions',      short: 'L10', weight: 0.05 },
];

const LAYER_DESCRIPTIONS = {
  l1_perplexity:    'Token-level surprise. Low perplexity = predictable, AI-like.',
  l2_burstiness:    'Variation in sentence length and structure. Humans burst, models smooth.',
  l3_stylometrics:  'Lexical fingerprints — AI phrases, hedging, type-token ratio.',
  l4_semantic:      'Inter-paragraph cosine similarity. AI prose drifts evenly.',
  l5_unicode:       'Invisible characters, homoglyphs, suspicious code points.',
  l6_metadata:      'PDF/DOCX producer fields, EOF markers, author traces.',
  l7_fonts:         'Font usage entropy and rendering anomalies in source files.',
  l8_ensemble:      'Three classifier models vote; weighted by domain match.',
  l9_hallucination: 'Extracted factual claims cross-referenced for verifiability.',
  l10_revisions:    'Git/Word revision history depth — humans iterate, models emit.',
};

// ── Sentence stream generators (deterministic-ish look) ───────────────────────
const HUMAN_SAMPLES = [
  "I started this draft on a Tuesday because the rain wouldn't let up.",
  "That paragraph above is wrong — I came back on Thursday and rewrote it.",
  "My advisor scribbled \"too much!\" in the margin here.",
  "Reading it now, the argument hinges on a footnote I should pull forward.",
  "There is something stubborn about the way the data refuses my framing.",
  "(Note to self: re-check the Bergstrom citation, the page number is off.)",
  "The boring truth is that most of this took three weekends and a lot of coffee.",
];
const AI_SAMPLES = [
  "In today's rapidly evolving digital landscape, it is crucial to delve into the multifaceted nature of artificial intelligence.",
  "Furthermore, the implementation of robust frameworks ensures scalability across diverse organizational contexts.",
  "It is important to note that these findings underscore the significance of continued empirical investigation.",
  "Ultimately, by leveraging cutting-edge methodologies, stakeholders can navigate complex challenges with unprecedented efficacy.",
  "Moreover, this comprehensive approach facilitates a holistic understanding of the subject matter.",
  "In conclusion, the convergence of these factors heralds a new paradigm for the industry at large.",
  "Notably, the synergistic interplay between data and design enables transformative outcomes.",
];

function pick(arr, i){ return arr[i % arr.length]; }
function buildSentences(n, mode){
  const out = [];
  for (let i=0;i<n;i++){
    let prob, text;
    if (mode === 'ai'){
      prob = 0.55 + Math.sin(i*1.7)*0.18 + (i%9===3? 0.18 : 0) + (i%13===0? -0.20 : 0);
      text = pick(AI_SAMPLES, i);
    } else if (mode === 'human'){
      prob = 0.18 + Math.sin(i*0.9)*0.10 + (i%7===2? 0.18 : 0);
      text = pick(HUMAN_SAMPLES, i);
    } else {
      // mixed
      const seg = Math.floor(i/12) % 2;
      prob = seg === 0
        ? 0.78 + Math.sin(i*1.3)*0.12
        : 0.22 + Math.sin(i*0.7)*0.10;
      text = seg === 0 ? pick(AI_SAMPLES, i) : pick(HUMAN_SAMPLES, i);
    }
    prob = Math.max(0.02, Math.min(0.98, prob));
    out.push({ index: i, sentence: text, ai_probability: +prob.toFixed(3) });
  }
  return out;
}

// ── Three full payloads ───────────────────────────────────────────────────────
const SCEN_AI = {
  status: 'success',
  analysis_time_seconds: 12.4,
  document: {
    filename: 'essay_draft.pdf',
    word_count: 1847,
    file_type: 'pdf',
    file_size_bytes: 248192,
  },
  verdict: {
    final_score: 0.781,
    verdict: 'LIKELY AI-GENERATED',
    verdict_icon: '🟠',
    verdict_description: 'Most signals indicate AI authorship with moderate confidence.',
    confidence: 'MEDIUM — some signal variance',
    conflicts_detected: false,
    conflicts: [],
    recommended_action: 'Likely AI-generated — human review recommended before formal action.',
    layer_breakdown: [
      { layer:'l1_perplexity',    weight:0.18, ai_probability:0.83, signal:'AI',    evidence:'Mean perplexity 34.2 (low = AI-like)' },
      { layer:'l2_burstiness',    weight:0.13, ai_probability:0.79, signal:'AI',    evidence:'Sentence-length std=4.2, Gini=0.12' },
      { layer:'l3_stylometrics',  weight:0.14, ai_probability:0.88, signal:'AI',    evidence:'AI phrase density 3.2x, hedging 2.1x, TTR 0.41' },
      { layer:'l4_semantic',      weight:0.10, ai_probability:0.71, signal:'AI',    evidence:'Para-similarity std=0.04 (uniform drift)' },
      { layer:'l5_unicode',       weight:0.07, ai_probability:0.10, signal:'HUMAN', evidence:'No invisible characters found' },
      { layer:'l6_metadata',      weight:0.08, ai_probability:0.65, signal:'AI',    evidence:'Creator field: "ChatGPT Export"' },
      { layer:'l7_fonts',         weight:0.05, ai_probability:0.42, signal:'MIXED', evidence:'2 fonts; default-only stack' },
      { layer:'l8_ensemble',      weight:0.15, ai_probability:0.82, signal:'AI',    evidence:'deBERTa=0.91, RoBERTa-acad=0.78, RoBERTa-news=0.72' },
      { layer:'l9_hallucination', weight:0.05, ai_probability:0.61, signal:'AI',    evidence:'2 of 7 claims unverifiable; 1 contradicted' },
      { layer:'l10_revisions',    weight:0.05, ai_probability:0.74, signal:'AI',    evidence:'No revision history; PDF emitted in 1 pass' },
    ],
  },
  layers: {
    l1_perplexity: {
      ai_probability: 0.83, mean_perplexity: 34.2, std_perplexity: 8.1,
      per_sentence_scores: Array.from({length:30},(_,i)=> +(28 + Math.sin(i*0.8)*9 + (i%7===0?6:0)).toFixed(1)),
      low_perplexity_sentences: [
        { index: 4,  perplexity: 22.1, sentence: 'In today\u2019s rapidly evolving digital landscape, it is crucial to delve into the multifaceted nature of artificial intelligence.' },
        { index: 11, perplexity: 24.7, sentence: 'Furthermore, the implementation of robust frameworks ensures scalability across diverse organizational contexts.' },
        { index: 19, perplexity: 25.9, sentence: 'Ultimately, by leveraging cutting-edge methodologies, stakeholders can navigate complex challenges with unprecedented efficacy.' },
      ],
      evidence: 'Mean perplexity 34.2 (low = AI-like)',
    },
    l2_burstiness: {
      ai_probability: 0.79,
      sentence_length_std: 4.2, gini_coefficient: 0.12, mean_length: 21.7,
      length_distribution: [3,5,9,18,22,17,11,6,3,1],
      evidence: 'std=4.2, Gini=0.12 (humans typically std≥7)',
    },
    l3_stylometrics: {
      ai_probability: 0.88,
      features: {
        type_token_ratio: 0.41, ai_phrase_density: 3.2, hedging_density: 2.1,
        avg_sentence_length: 21.7, passive_voice_ratio: 0.18, nominalization_ratio: 0.34,
        first_person_ratio: 0.02, contractions_ratio: 0.01, em_dash_density: 0.92,
      },
      top_ai_signals: [
        'High AI-phrase density (3.2× per 100 words)',
        'Em-dash density 0.92× normal — characteristic of GPT-class models',
        'First-person ratio 0.02 — abnormally impersonal',
      ],
      evidence: 'AI phrase density: 3.2x, hedging: 2.1x, TTR: 0.41',
    },
    l4_semantic: {
      ai_probability: 0.71,
      paragraph_similarity_mean: 0.46, paragraph_similarity_std: 0.04,
      cosine_matrix_excerpt: [[1.00,0.48,0.42,0.45],[0.48,1.00,0.51,0.46],[0.42,0.51,1.00,0.49],[0.45,0.46,0.49,1.00]],
      evidence: 'Para-similarity std=0.04 (uniform = AI-like)',
    },
    l5_unicode: {
      ai_probability: 0.10, invisible_char_count: 0, homoglyph_count: 0, findings: [],
      evidence: 'No invisible characters found',
    },
    l6_metadata: {
      ai_probability: 0.65,
      creator: 'ChatGPT Export', producer: 'Skia/PDF m130', author: '',
      created: 'D:20260115023411Z', modified: 'D:20260115023411Z',
      eof_markers: 1, page_count: 6,
      signals: ['AI tool fingerprint in creator field', 'Single EOF marker — no incremental save', 'Author field empty'],
      evidence: 'Creator: "ChatGPT Export"; no edit history',
    },
    l7_fonts: {
      ai_probability: 0.42, font_count: 2, fonts: ['Times New Roman','Arial'],
      entropy: 0.31, default_only: true,
      evidence: '2 fonts; default-only stack',
    },
    l8_ensemble: {
      ai_probability: 0.82,
      model_results: [
        { model: 'deberta-v3-large',  ai_probability: 0.91, weight: 0.45, chunks_analyzed: 4 },
        { model: 'roberta-academic',  ai_probability: 0.78, weight: 0.35, chunks_analyzed: 4 },
        { model: 'roberta-news',      ai_probability: 0.72, weight: 0.20, chunks_analyzed: 4 },
      ],
      evidence: 'Ensemble: deberta=0.91, roberta-acad=0.78, roberta-news=0.72',
    },
    l9_hallucination: {
      ai_probability: 0.61,
      claims: [
        { text: 'GPT-4 was released in March 2023.',                       status: 'verified' },
        { text: 'The 2024 OECD report showed a 47% productivity gain.',    status: 'unverifiable' },
        { text: 'Stanford\u2019s 2025 study confirmed model collapse.',    status: 'unverifiable' },
        { text: 'Transformer architecture was introduced in 2017.',        status: 'verified' },
        { text: 'Claude was first released in 2021.',                      status: 'contradicted' },
        { text: 'GPU prices fell 38% in 2024.',                            status: 'verified' },
        { text: 'The Hopper H200 has 192GB of HBM3e memory.',              status: 'verified' },
      ],
      evidence: '2 of 7 claims unverifiable; 1 contradicted',
    },
    l10_revisions: {
      ai_probability: 0.74,
      docx_revision_count: 0, page_emit_passes: 1, last_save_minutes_after_create: 0,
      evidence: 'No revision history; document emitted in single pass',
    },
  },
  report: {
    executive_summary: 'This 1,847-word document shows multiple converging signals of AI generation — low perplexity (34.2), uniform paragraph drift, dense AI-phrase patterns, and a "ChatGPT Export" creator fingerprint. Unicode and font checks come back clean, which is consistent with native PDF emission rather than copy-paste laundering.',
    sentence_heatmap: buildSentences(64, 'ai'),
    suspicious_passages: [
      { rank:1, ai_probability:0.94, flagged_by:['l1_perplexity','l8_ensemble','l3_stylometrics'], location:'paragraph 3',
        quote: 'In today\u2019s rapidly evolving digital landscape, it is crucial to delve into the multifaceted nature of artificial intelligence and its profound implications across multiple domains.' },
      { rank:2, ai_probability:0.91, flagged_by:['l3_stylometrics','l8_ensemble'], location:'paragraph 7',
        quote: 'Furthermore, the implementation of robust frameworks ensures scalability across diverse organizational contexts, thereby fostering an environment conducive to sustainable innovation.' },
      { rank:3, ai_probability:0.88, flagged_by:['l1_perplexity','l4_semantic'], location:'paragraph 11',
        quote: 'Ultimately, by leveraging cutting-edge methodologies, stakeholders can navigate complex challenges with unprecedented efficacy and a renewed sense of purpose.' },
      { rank:4, ai_probability:0.83, flagged_by:['l3_stylometrics'], location:'paragraph 5',
        quote: 'Moreover, this comprehensive approach facilitates a holistic understanding of the subject matter while simultaneously addressing the nuanced concerns of stakeholders.' },
      { rank:5, ai_probability:0.79, flagged_by:['l8_ensemble'], location:'paragraph 12',
        quote: 'Notably, the synergistic interplay between data and design enables transformative outcomes that resonate with contemporary best practices in the field.' },
    ],
  },
  pdf_report_url: '/report/abc123.pdf',
};

const SCEN_HUMAN = {
  status: 'success',
  analysis_time_seconds: 9.7,
  document: {
    filename: 'thesis_chapter_03.docx',
    word_count: 4218,
    file_type: 'docx',
    file_size_bytes: 612803,
  },
  verdict: {
    final_score: 0.082,
    verdict: 'LIKELY HUMAN-AUTHORED',
    verdict_icon: '✅',
    verdict_description: 'Signals are consistent across the board with human authorship.',
    confidence: 'HIGH — strong agreement across 9 of 10 layers',
    conflicts_detected: false,
    conflicts: [],
    recommended_action: 'No action needed. Document presents as human-authored.',
    layer_breakdown: [
      { layer:'l1_perplexity',    weight:0.18, ai_probability:0.12, signal:'HUMAN', evidence:'Mean perplexity 71.4 (high = bursty / human)' },
      { layer:'l2_burstiness',    weight:0.13, ai_probability:0.08, signal:'HUMAN', evidence:'Sentence-length std=11.3, Gini=0.31' },
      { layer:'l3_stylometrics',  weight:0.14, ai_probability:0.14, signal:'HUMAN', evidence:'TTR 0.58, low AI-phrase density (0.4x)' },
      { layer:'l4_semantic',      weight:0.10, ai_probability:0.09, signal:'HUMAN', evidence:'Para-similarity std=0.21 (varied)' },
      { layer:'l5_unicode',       weight:0.07, ai_probability:0.04, signal:'HUMAN', evidence:'Clean — no invisible characters' },
      { layer:'l6_metadata',      weight:0.08, ai_probability:0.05, signal:'HUMAN', evidence:'Author: M. Petrova; 17 EOF markers' },
      { layer:'l7_fonts',         weight:0.05, ai_probability:0.18, signal:'HUMAN', evidence:'5 fonts; entropy 0.74' },
      { layer:'l8_ensemble',      weight:0.15, ai_probability:0.07, signal:'HUMAN', evidence:'deBERTa=0.09, RoBERTa-acad=0.06, RoBERTa-news=0.08' },
      { layer:'l9_hallucination', weight:0.05, ai_probability:0.11, signal:'HUMAN', evidence:'8 of 9 claims verified; specific citations' },
      { layer:'l10_revisions',    weight:0.05, ai_probability:0.06, signal:'HUMAN', evidence:'214 tracked revisions over 19 days' },
    ],
  },
  layers: {
    l1_perplexity: {
      ai_probability: 0.12, mean_perplexity: 71.4, std_perplexity: 22.3,
      per_sentence_scores: Array.from({length:30},(_,i)=> +(60 + Math.sin(i*1.1)*22 + (i%5===0?10:0)).toFixed(1)),
      low_perplexity_sentences: [],
      evidence: 'Mean perplexity 71.4 (human-typical)',
    },
    l2_burstiness: {
      ai_probability: 0.08,
      sentence_length_std: 11.3, gini_coefficient: 0.31, mean_length: 18.4,
      length_distribution: [12,18,22,21,16,12,9,7,4,2],
      evidence: 'std=11.3, Gini=0.31',
    },
    l3_stylometrics: {
      ai_probability: 0.14,
      features: {
        type_token_ratio: 0.58, ai_phrase_density: 0.4, hedging_density: 0.6,
        avg_sentence_length: 18.4, passive_voice_ratio: 0.09, nominalization_ratio: 0.21,
        first_person_ratio: 0.11, contractions_ratio: 0.07, em_dash_density: 0.18,
      },
      top_ai_signals: [],
      evidence: 'TTR 0.58, low AI-phrase density',
    },
    l4_semantic: {
      ai_probability: 0.09,
      paragraph_similarity_mean: 0.32, paragraph_similarity_std: 0.21,
      cosine_matrix_excerpt: [[1.00,0.18,0.41,0.22],[0.18,1.00,0.27,0.55],[0.41,0.27,1.00,0.31],[0.22,0.55,0.31,1.00]],
      evidence: 'Para-similarity std=0.21 (varied)',
    },
    l5_unicode: {
      ai_probability: 0.04, invisible_char_count: 0, homoglyph_count: 0, findings: [],
      evidence: 'Clean',
    },
    l6_metadata: {
      ai_probability: 0.05,
      creator: 'Microsoft Word for Mac', producer: 'Word 16.78', author: 'M. Petrova',
      created: 'D:20260102090231Z', modified: 'D:20260121153028Z',
      eof_markers: 17, page_count: 22,
      signals: [],
      evidence: 'Author present; multi-session edit trail',
    },
    l7_fonts: {
      ai_probability: 0.18, font_count: 5, fonts: ['Garamond','Helvetica Neue','Courier','Symbol','Cambria Math'],
      entropy: 0.74, default_only: false,
      evidence: '5 fonts; entropy 0.74',
    },
    l8_ensemble: {
      ai_probability: 0.07,
      model_results: [
        { model: 'deberta-v3-large',  ai_probability: 0.09, weight: 0.45, chunks_analyzed: 8 },
        { model: 'roberta-academic',  ai_probability: 0.06, weight: 0.35, chunks_analyzed: 8 },
        { model: 'roberta-news',      ai_probability: 0.08, weight: 0.20, chunks_analyzed: 8 },
      ],
      evidence: 'All three models < 0.10',
    },
    l9_hallucination: {
      ai_probability: 0.11,
      claims: [
        { text: 'Bergstrom & West (2020) reported a 22% baseline.',         status: 'verified' },
        { text: 'The dataset was collected between Jan and June 2024.',     status: 'verified' },
        { text: 'IRB approval was obtained on 2024-02-11.',                 status: 'verified' },
        { text: 'Pearson r = 0.71, p < .001.',                              status: 'verified' },
        { text: 'Replication in Lund yielded similar results.',             status: 'unverifiable' },
        { text: 'See Appendix C, Table 4.',                                 status: 'verified' },
      ],
      evidence: 'Claims grounded; specific citations',
    },
    l10_revisions: {
      ai_probability: 0.06,
      docx_revision_count: 214, page_emit_passes: 12, last_save_minutes_after_create: 27563,
      evidence: '214 tracked revisions over 19 days',
    },
  },
  report: {
    executive_summary: 'A 4,218-word academic chapter with strong human authorship signals: high perplexity (71.4), bursty sentence lengths, varied paragraph similarity, and a 214-revision edit history spanning 19 days. Author and metadata fields are intact.',
    sentence_heatmap: buildSentences(72, 'human'),
    suspicious_passages: [
      { rank:1, ai_probability:0.42, flagged_by:['l3_stylometrics'], location:'paragraph 14',
        quote: 'It is therefore essential to consider the broader implications of these methodological choices when interpreting the results.' },
      { rank:2, ai_probability:0.36, flagged_by:['l1_perplexity'], location:'paragraph 22',
        quote: 'In summary, the data support the hypothesis that the intervention produced a measurable effect on retention.' },
    ],
  },
  pdf_report_url: '/report/def456.pdf',
};

const SCEN_MIXED = {
  status: 'success',
  analysis_time_seconds: 14.1,
  document: {
    filename: 'lit_review_v4.pdf',
    word_count: 2604,
    file_type: 'pdf',
    file_size_bytes: 391022,
  },
  verdict: {
    final_score: 0.518,
    verdict: 'INDETERMINATE — MIXED SIGNALS',
    verdict_icon: '🟡',
    verdict_description: 'Signals split between AI and human authorship — consistent with hybrid drafting (human edited AI text, or vice versa).',
    confidence: 'LOW — high inter-layer variance',
    conflicts_detected: true,
    conflicts: [
      { layers: ['l1_perplexity','l5_unicode'], delta: 0.62, note: 'Perplexity says AI; Unicode shows hand-typed character distribution.' },
      { layers: ['l3_stylometrics','l10_revisions'], delta: 0.51, note: 'Stylometrics flag AI phrasing; revision history shows 47 human edits.' },
    ],
    recommended_action: 'Manual review required. Consider requesting source draft + edit history.',
    layer_breakdown: [
      { layer:'l1_perplexity',    weight:0.18, ai_probability:0.74, signal:'AI',    evidence:'Mean perplexity 38.9 (low)' },
      { layer:'l2_burstiness',    weight:0.13, ai_probability:0.45, signal:'MIXED', evidence:'Bimodal length distribution detected' },
      { layer:'l3_stylometrics',  weight:0.14, ai_probability:0.71, signal:'AI',    evidence:'AI phrase density 2.4x; mixed contractions' },
      { layer:'l4_semantic',      weight:0.10, ai_probability:0.52, signal:'MIXED', evidence:'Para-similarity bimodal — std=0.18' },
      { layer:'l5_unicode',       weight:0.07, ai_probability:0.12, signal:'HUMAN', evidence:'Smart-quote distribution typical of OS keyboard' },
      { layer:'l6_metadata',      weight:0.08, ai_probability:0.55, signal:'MIXED', evidence:'PDF re-emitted; original creator stripped' },
      { layer:'l7_fonts',         weight:0.05, ai_probability:0.38, signal:'MIXED', evidence:'3 fonts; one custom embed' },
      { layer:'l8_ensemble',      weight:0.15, ai_probability:0.61, signal:'AI',    evidence:'deBERTa=0.74, RoBERTa-acad=0.52, RoBERTa-news=0.49' },
      { layer:'l9_hallucination', weight:0.05, ai_probability:0.44, signal:'MIXED', evidence:'4 of 9 claims unverifiable' },
      { layer:'l10_revisions',    weight:0.05, ai_probability:0.23, signal:'HUMAN', evidence:'47 manual edits across 3 sessions' },
    ],
  },
  layers: {
    l1_perplexity: {
      ai_probability: 0.74, mean_perplexity: 38.9, std_perplexity: 14.2,
      per_sentence_scores: Array.from({length:30},(_,i)=> +(35 + Math.sin(i*0.9)*14 + (i%4===0?7:0)).toFixed(1)),
      low_perplexity_sentences: [
        { index: 6,  perplexity: 24.3, sentence: 'It is widely acknowledged that recent advances have transformed the field.' },
        { index: 17, perplexity: 26.8, sentence: 'These findings underscore the importance of further investigation.' },
      ],
      evidence: 'Mean perplexity 38.9 (low)',
    },
    l2_burstiness: {
      ai_probability: 0.45,
      sentence_length_std: 7.8, gini_coefficient: 0.22, mean_length: 19.6,
      length_distribution: [6,11,17,18,14,11,8,6,5,4],
      evidence: 'Bimodal — std=7.8 with two peaks',
    },
    l3_stylometrics: {
      ai_probability: 0.71,
      features: {
        type_token_ratio: 0.49, ai_phrase_density: 2.4, hedging_density: 1.5,
        avg_sentence_length: 19.6, passive_voice_ratio: 0.14, nominalization_ratio: 0.28,
        first_person_ratio: 0.06, contractions_ratio: 0.04, em_dash_density: 0.61,
      },
      top_ai_signals: ['AI-phrase density 2.4×', 'Em-dash density elevated (0.61)'],
      evidence: 'AI phrase density 2.4x; mixed contractions',
    },
    l4_semantic: {
      ai_probability: 0.52,
      paragraph_similarity_mean: 0.39, paragraph_similarity_std: 0.18,
      cosine_matrix_excerpt: [[1.00,0.51,0.22,0.48],[0.51,1.00,0.31,0.53],[0.22,0.31,1.00,0.27],[0.48,0.53,0.27,1.00]],
      evidence: 'Para-similarity bimodal — std=0.18',
    },
    l5_unicode: {
      ai_probability: 0.12,
      invisible_char_count: 0, homoglyph_count: 0,
      findings: [
        { char: '—', hex: 'U+2014', name: 'EM DASH', count: 14, first_positions: [128, 612, 1844] },
        { char: '\u2019', hex: 'U+2019', name: 'RIGHT SINGLE QUOTATION MARK', count: 23, first_positions: [42, 280, 911] },
      ],
      evidence: 'Smart-quote distribution typical of OS keyboard',
    },
    l6_metadata: {
      ai_probability: 0.55,
      creator: '[stripped]', producer: 'macOS Quartz PDFContext', author: 'jdoe',
      created: 'D:20260204101822Z', modified: 'D:20260204110304Z',
      eof_markers: 2, page_count: 9,
      signals: ['PDF re-emitted via macOS print pipeline', 'Original creator field removed'],
      evidence: 'PDF re-emitted; original creator stripped',
    },
    l7_fonts: {
      ai_probability: 0.38, font_count: 3, fonts: ['Times New Roman','Helvetica','CMU Serif (custom embed)'],
      entropy: 0.55, default_only: false,
      evidence: '3 fonts; one custom embed',
    },
    l8_ensemble: {
      ai_probability: 0.61,
      model_results: [
        { model: 'deberta-v3-large',  ai_probability: 0.74, weight: 0.45, chunks_analyzed: 5 },
        { model: 'roberta-academic',  ai_probability: 0.52, weight: 0.35, chunks_analyzed: 5 },
        { model: 'roberta-news',      ai_probability: 0.49, weight: 0.20, chunks_analyzed: 5 },
      ],
      evidence: 'Models split; deBERTa-acad disagrees',
    },
    l9_hallucination: {
      ai_probability: 0.44,
      claims: [
        { text: 'The 2023 NeurIPS proceedings included 3,584 papers.',         status: 'verified' },
        { text: 'A recent meta-analysis (n=12) showed effect d=0.42.',         status: 'unverifiable' },
        { text: 'The Hopper architecture supports FP8 natively.',              status: 'verified' },
        { text: 'Mistral released a 22B model in early 2025.',                 status: 'unverifiable' },
        { text: 'Anthropic published the Constitutional AI paper in 2022.',    status: 'verified' },
        { text: 'Open-source models matched GPT-4 on MMLU by Q3 2024.',        status: 'contradicted' },
        { text: 'OpenAI\u2019s o-series introduced reasoning tokens.',         status: 'verified' },
      ],
      evidence: '4 of 9 claims unverifiable',
    },
    l10_revisions: {
      ai_probability: 0.23,
      docx_revision_count: 47, page_emit_passes: 4, last_save_minutes_after_create: 73,
      evidence: '47 manual edits across 3 sessions',
    },
  },
  report: {
    executive_summary: 'A 2,604-word literature review with split signals. Stylometric and perplexity layers point to AI scaffolding; revision history (47 edits, 3 sessions) and unicode distribution point to human typing. The document was likely AI-drafted and human-edited (or the reverse).',
    sentence_heatmap: buildSentences(60, 'mixed'),
    suspicious_passages: [
      { rank:1, ai_probability:0.89, flagged_by:['l1_perplexity','l3_stylometrics'], location:'paragraph 2',
        quote: 'In recent years, the field has witnessed an unprecedented acceleration in research output, fundamentally reshaping our understanding of the underlying mechanisms.' },
      { rank:2, ai_probability:0.81, flagged_by:['l8_ensemble','l3_stylometrics'], location:'paragraph 6',
        quote: 'It is widely acknowledged that recent advances in transformer-based architectures have transformed the landscape of natural language processing.' },
      { rank:3, ai_probability:0.74, flagged_by:['l1_perplexity'], location:'paragraph 9',
        quote: 'These findings underscore the importance of further investigation into the long-term consequences of large-scale model deployment.' },
    ],
  },
  pdf_report_url: '/report/ghi789.pdf',
};

// ── Recent history ────────────────────────────────────────────────────────────
const FAKE_RECENT = [
  { filename: 'midterm_response.pdf',   icon:'🟠', score: 0.781, ago: '2 min ago', scenario: 'ai' },
  { filename: 'thesis_chapter_03.docx', icon:'✅', score: 0.082, ago: '1 hr ago',  scenario: 'human' },
  { filename: 'lit_review_v4.pdf',      icon:'🟡', score: 0.518, ago: '3 hr ago',  scenario: 'mixed' },
  { filename: 'cover_letter.docx',      icon:'🔴', score: 0.912, ago: 'yesterday', scenario: 'ai' },
  { filename: 'lab_notes_apr.txt',      icon:'✅', score: 0.064, ago: '2 days ago',scenario: 'human' },
];

Object.assign(window, {
  LAYER_META, LAYER_DESCRIPTIONS,
  SCEN_AI, SCEN_HUMAN, SCEN_MIXED, FAKE_RECENT,
});
